{"_id":"@bw-ui/datatable-history","_rev":"3-e7b829775e7c582ac8830f22b13bd33a","name":"@bw-ui/datatable-history","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@bw-ui/datatable-history","version":"1.0.0","keywords":["bw-ui","datatable","plugin","undo","redo","history"],"author":{"name":"Black & White UI Engineering"},"license":"MIT","_id":"@bw-ui/datatable-history@1.0.0","maintainers":[{"name":"rchoudhary.dev","email":"rchoudhary.dev@gmail.com"}],"homepage":"https://bw-ui.dev/bw-datatable","bugs":{"url":"https://github.com/bw-ui/bw-datatable/issues"},"dist":{"shasum":"ab64ffd9b69a32fb7b622efc646c0394e350d95e","tarball":"https://registry.npmjs.org/@bw-ui/datatable-history/-/datatable-history-1.0.0.tgz","fileCount":4,"integrity":"sha512-RYTlBGNX6dwZPwGD2+oggne3424b4GCGH/saK5qfv9dJZbL8Lz8EMjrxl6Vmc/b/NskQitsBPX7K/z3Jv7ylAw==","signatures":[{"sig":"MEYCIQD8og+uOg6vKVGnu9PZDYYRk/KKO8W79tehv0AZJUB5vwIhAJCZ71mEfadOFCiQh8rCBp+Rte9HYPEMA4YkosfOoJHR","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13597},"main":"dist/history.min.js","type":"module","types":"types.d.ts","module":"dist/history.esm.min.js","exports":{".":{"import":"./dist/history.esm.min.js","require":"./dist/history.min.js"}},"scripts":{"dev":"node build.js --watch","build":"node build.js"},"_npmUser":{"name":"rchoudhary.dev","email":"rchoudhary.dev@gmail.com"},"repository":{"url":"git+https://github.com/bw-ui/bw-datatable.git","type":"git","directory":"packages/core"},"_npmVersion":"10.9.3","description":"Undo/Redo plugin for @bw-ui/datatable","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.20.0"},"peerDependencies":{"@bw-ui/datatable":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/datatable-history_1.0.0_1764604970450_0.816328224801226","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bw-ui/datatable-history","version":"1.0.1","keywords":["bw-ui","datatable","plugin","undo","redo","history"],"author":{"name":"Black & White UI Engineering"},"license":"MIT","_id":"@bw-ui/datatable-history@1.0.1","maintainers":[{"name":"rchoudhary.dev","email":"rchoudhary.dev@gmail.com"}],"homepage":"https://github.com/bw-ui/datatable#readme","bugs":{"url":"https://github.com/bw-ui/datatable/issues"},"dist":{"shasum":"6e3266f27c32d635620355c19ee092bdbd7c1fcb","tarball":"https://registry.npmjs.org/@bw-ui/datatable-history/-/datatable-history-1.0.1.tgz","fileCount":4,"integrity":"sha512-CAWScAwbVjIhmuspMoNJh8k4K2ecbcHlVWDpS/lfLn83hAqcZtkIs46qHNFtYA1pJMxMXWD+XII1Up5bY3hobA==","signatures":[{"sig":"MEQCIB7gPsoDykXwLNvbMPy5LBvNEOztMtpxE0G8BP4JCyqEAiAh4q3/mF3aV4LceFgi55NMAYkfd+M0TAvuUee/sDBTCQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11288},"main":"dist/history.min.js","type":"module","types":"src/index.d.ts","module":"dist/history.esm.min.js","exports":{".":{"import":"./dist/history.esm.min.js","require":"./dist/history.min.js"}},"gitHead":"3953ac723b4335e86ba18cd918a31837f2b30d45","scripts":{"dev":"node build.js --watch","build":"node build.js"},"_npmUser":{"name":"rchoudhary.dev","email":"rchoudhary.dev@gmail.com"},"repository":{"url":"git+https://github.com/bw-ui/datatable.git","type":"git","directory":"packages/plugins/history"},"_npmVersion":"10.9.3","description":"Undo/Redo plugin for @bw-ui/datatable","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.20.2"},"peerDependencies":{"@bw-ui/datatable":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/datatable-history_1.0.1_1764683207764_0.4423484380732863","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@bw-ui/datatable-history","version":"1.0.2","description":"Undo/Redo plugin for @bw-ui/datatable","type":"module","main":"dist/history.min.js","module":"dist/history.esm.min.js","types":"src/index.d.ts","exports":{".":{"import":"./dist/history.esm.min.js","require":"./dist/history.min.js"}},"scripts":{"build":"node build.js","dev":"node build.js --watch"},"keywords":["bw-ui","datatable","plugin","undo","redo","history"],"author":{"name":"Black & White UI Engineering"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/bw-ui/bw-datatable.git"},"bugs":{"url":"https://github.com/bw-ui/bw-datatable/issues"},"homepage":"https://bw-ui.github.io/bw-datatable/","peerDependencies":{"@bw-ui/datatable":"^1.0.0"},"devDependencies":{"esbuild":"^0.20.2"},"_id":"@bw-ui/datatable-history@1.0.2","gitHead":"47f3eb05ee98558e6e685c6c15091cb227830297","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-RHYAWXYje+aJ80YUrhdtjJFtKFzhA6r9j2BFWhyGuFFDR7e9hxS3k81lSf86i/t/aXFNXw+2bohCB5XngwCJoA==","shasum":"98a4f85a144f8393e7160bb339fa03847dd30935","tarball":"https://registry.npmjs.org/@bw-ui/datatable-history/-/datatable-history-1.0.2.tgz","fileCount":4,"unpackedSize":11372,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHKmBwSNGd47pMQBj82c+GePFLN1eCsESQhFb0uS8nZGAiEAz9WGFjrh3jM/xwGfuFSwl40+5Vzlsa5Vca5S1zbsKS4="}]},"_npmUser":{"name":"rchoudhary.dev","email":"rchoudhary.dev@gmail.com"},"directories":{},"maintainers":[{"name":"rchoudhary.dev","email":"rchoudhary.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/datatable-history_1.0.2_1764776946035_0.8257777968410869"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-01T16:02:50.385Z","modified":"2025-12-03T15:49:06.448Z","1.0.0":"2025-12-01T16:02:50.687Z","1.0.1":"2025-12-02T13:46:47.961Z","1.0.2":"2025-12-03T15:49:06.221Z"},"bugs":{"url":"https://github.com/bw-ui/bw-datatable/issues"},"author":{"name":"Black & White UI Engineering"},"license":"MIT","homepage":"https://bw-ui.github.io/bw-datatable/","keywords":["bw-ui","datatable","plugin","undo","redo","history"],"repository":{"type":"git","url":"git+https://github.com/bw-ui/bw-datatable.git"},"description":"Undo/Redo plugin for @bw-ui/datatable","maintainers":[{"name":"rchoudhary.dev","email":"rchoudhary.dev@gmail.com"}],"readme":"# @bw-ui/datatable-history\n\nUndo/Redo plugin for BWDataTable.\n\n## Features\n\n- ⏪ **Undo/Redo** - Revert cell edits, selection changes\n- ⌨️ **Keyboard Shortcuts** - Ctrl+Z, Ctrl+Y, Ctrl+Shift+Z\n- 📚 **History Stack** - Configurable max history size\n- 🔄 **Full State Restore** - Data, sort, filters, selection\n\n## Installation\n\n```bash\nnpm install @bw-ui/datatable-history\n```\n\n## Usage\n\n```javascript\nimport { BWDataTable } from '@bw-ui/datatable';\nimport { HistoryPlugin } from '@bw-ui/datatable-history';\n\nconst table = new BWDataTable('#table', { data }).use(HistoryPlugin, {\n  maxHistory: 50, // Max undo states (default: 50)\n  shortcuts: true, // Enable keyboard shortcuts (default: true)\n});\n\n// Programmatic undo/redo\ntable.undo();\ntable.redo();\n\n// Check availability\nif (table.canUndo()) {\n  console.log('Can undo');\n}\n\nif (table.canRedo()) {\n  console.log('Can redo');\n}\n\n// Clear history\ntable.clearHistory();\n\n// Get history state\nconst history = table.getHistory();\nconsole.log(\n  `Undo: ${history.undoStack.length}, Redo: ${history.redoStack.length}`\n);\n```\n\n## Options\n\n| Option       | Type      | Default | Description                 |\n| ------------ | --------- | ------- | --------------------------- |\n| `maxHistory` | `number`  | `50`    | Maximum undo states to keep |\n| `shortcuts`  | `boolean` | `true`  | Enable keyboard shortcuts   |\n\n## Keyboard Shortcuts\n\n| Shortcut                       | Action |\n| ------------------------------ | ------ |\n| `Ctrl+Z` / `Cmd+Z`             | Undo   |\n| `Ctrl+Y` / `Cmd+Y`             | Redo   |\n| `Ctrl+Shift+Z` / `Cmd+Shift+Z` | Redo   |\n\n## API\n\n### Methods (added to table)\n\n```javascript\n// Undo last action\ntable.undo(); // Returns: boolean (true if undone)\n\n// Redo last undone action\ntable.redo(); // Returns: boolean (true if redone)\n\n// Check if undo is available\ntable.canUndo(); // Returns: boolean\n\n// Check if redo is available\ntable.canRedo(); // Returns: boolean\n\n// Clear all history\ntable.clearHistory();\n\n// Get history state\ntable.getHistory();\n// Returns: {\n//   undoStack: HistorySnapshot[],\n//   redoStack: HistorySnapshot[],\n//   canUndo: boolean,\n//   canRedo: boolean,\n// }\n```\n\n## Events\n\n```javascript\n// History state changed\ntable.on('history:change', ({ canUndo, canRedo, undoCount, redoCount }) => {\n  // Update UI buttons\n  undoBtn.disabled = !canUndo;\n  redoBtn.disabled = !canRedo;\n});\n\n// After undo\ntable.on('history:undo', ({ action }) => {\n  console.log('Undid:', action);\n});\n\n// After redo\ntable.on('history:redo', ({ action }) => {\n  console.log('Redid:', action);\n});\n\n// History cleared\ntable.on('history:clear', () => {\n  console.log('History cleared');\n});\n```\n\n## What Gets Tracked\n\nThe History plugin automatically tracks:\n\n- ✅ **Cell edits** - When you edit a cell value\n- ✅ **Row selection** - When selection changes\n- ✅ **Sort state** - Column and direction\n- ✅ **Filter state** - Search term and column filters\n\n## Example: Undo/Redo Buttons\n\n```javascript\nconst table = new BWDataTable('#table', { data }).use(HistoryPlugin);\n\nconst undoBtn = document.getElementById('undo');\nconst redoBtn = document.getElementById('redo');\n\n// Update button states\ntable.on('history:change', ({ canUndo, canRedo }) => {\n  undoBtn.disabled = !canUndo;\n  redoBtn.disabled = !canRedo;\n});\n\nundoBtn.addEventListener('click', () => table.undo());\nredoBtn.addEventListener('click', () => table.redo());\n```\n\n## TypeScript\n\n```typescript\nimport { BWDataTable } from '@bw-ui/datatable';\nimport { HistoryPlugin, HistoryPluginOptions } from '@bw-ui/datatable-history';\n\nconst options: HistoryPluginOptions = {\n  maxHistory: 100,\n  shortcuts: true,\n};\n\nconst table = new BWDataTable('#table', { data }).use(HistoryPlugin, options);\n\n// Methods are typed\nconst canUndo: boolean = table.canUndo();\nconst history = table.getHistory();\n```\n\n## License\n\nMIT © [BW UI](https://github.com/AshwinPavanKadha/bw-ui)\n","readmeFilename":"README.md"}