{"_id":"@ai-path/tb-core","_rev":"2-edb7f72925ce7edec30f9e22597361c0","name":"@ai-path/tb-core","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@ai-path/tb-core","version":"0.2.0","license":"MIT","_id":"@ai-path/tb-core@0.2.0","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"homepage":"https://github.com/aipathjp/lattica#readme","bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"dist":{"shasum":"cf02ee9876f42c58665961e12adf4ef4e272c1cb","tarball":"https://registry.npmjs.org/@ai-path/tb-core/-/tb-core-0.2.0.tgz","fileCount":9,"integrity":"sha512-4CGG9iDarVfWbOu/BNQnWnSVJ8tCz+S6cYrr1APH42VsSvzzYw1kBjHevF6nnSz3IWOjgeOgMpIhw1RFWeI2pA==","signatures":[{"sig":"MEUCIQCIVcva0sFxDiz3h8bTEBhOoOGHPL52siXUgTq3amykUAIgbJ2U26XfXDL2dnwwfcI4OFbe/7oNpmouiDlou6gmjpY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":652804},"main":"./dist/index.cjs","type":"module","_from":"file:ai-path-tb-core-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"fsakurai","email":"f-sakurai@ai-path.jp"},"_resolved":"/private/var/folders/tf/0c43660d4k1dg4ssxq0n63ww0000gn/T/8dbb763417c057b38b8965041720922e/ai-path-tb-core-0.2.0.tgz","_integrity":"sha512-4CGG9iDarVfWbOu/BNQnWnSVJ8tCz+S6cYrr1APH42VsSvzzYw1kBjHevF6nnSz3IWOjgeOgMpIhw1RFWeI2pA==","repository":{"url":"git+https://github.com/aipathjp/lattica.git","type":"git","directory":"packages/core"},"_npmVersion":"10.9.3","description":"Framework-agnostic core engine for the Taible data grid: data model, coordinate system, selection, virtualization math, command/undo-redo.","directories":{},"sideEffects":false,"_nodeVersion":"22.18.0","publishConfig":{"access":"public","provenance":false},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tb-core_0.2.0_1783181296095_0.22747458868769987","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@ai-path/tb-core","version":"0.3.0","description":"Framework-agnostic core engine for the Taible data grid: data model, coordinate system, selection, virtualization math, command/undo-redo.","repository":{"type":"git","url":"git+https://github.com/aipathjp/lattica.git","directory":"packages/core"},"homepage":"https://github.com/aipathjp/lattica#readme","bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"license":"MIT","type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"publishConfig":{"access":"public","provenance":false},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_id":"@ai-path/tb-core@0.3.0","_integrity":"sha512-12VdpLyfSpODCNUdbimKuqRZqObBpp1ZPi6xgZ7Ji4M5aGAxlZ87j4nOqB0Ca7JsH6lMc7lLKIHgAm0oYCdCpw==","_resolved":"/private/var/folders/tf/0c43660d4k1dg4ssxq0n63ww0000gn/T/477e245ae41fcab19ae49abf8b826b21/ai-path-tb-core-0.3.0.tgz","_from":"file:ai-path-tb-core-0.3.0.tgz","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-12VdpLyfSpODCNUdbimKuqRZqObBpp1ZPi6xgZ7Ji4M5aGAxlZ87j4nOqB0Ca7JsH6lMc7lLKIHgAm0oYCdCpw==","shasum":"20a484cb0dc61a6466c176c52572b930a1fc4c9b","tarball":"https://registry.npmjs.org/@ai-path/tb-core/-/tb-core-0.3.0.tgz","fileCount":9,"unpackedSize":683991,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCZTqWRMxQfsatpexhhTwBjyhtlrGi9r7EAjLuFMLzthgIgBTSTojEzpWsw+Ma/NTBW7tI1cIF/cm7b36K/S/blY/I="}]},"_npmUser":{"name":"fsakurai","email":"f-sakurai@ai-path.jp"},"directories":{},"maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tb-core_0.3.0_1783188073986_0.413344377527727"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-04T16:08:15.945Z","modified":"2026-07-04T18:01:14.275Z","0.2.0":"2026-07-04T16:08:16.255Z","0.3.0":"2026-07-04T18:01:14.153Z"},"bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"license":"MIT","homepage":"https://github.com/aipathjp/lattica#readme","repository":{"type":"git","url":"git+https://github.com/aipathjp/lattica.git","directory":"packages/core"},"description":"Framework-agnostic core engine for the Taible data grid: data model, coordinate system, selection, virtualization math, command/undo-redo.","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"readme":"# @ai-path/tb-core\n\nThe framework-agnostic data-grid engine at the heart of Taible. It provides the pure, DOM-free building blocks a grid is made of — coordinate math, a sparse cell store, selection and undo models, multi-level headers, search, validation, conditional formatting, comments, borders, and fill/series logic — so that view layers (such as `@ai-path/tb-react`) and tooling can compose them without pulling in any rendering concerns.\n\n## Install\n\n```sh\npnpm add @ai-path/tb-core\n```\n\n## API overview\n\nThe package re-exports cell/value types from `./types.js` plus a set of focused models and pure helpers. The most commonly used exports are listed below.\n\n### Coordinates\n\nA1-notation conversion and addressing helpers.\n\n```ts\nimport { toA1, parseA1, columnIndexToLabel, addressKey } from '@ai-path/tb-core';\n\ntoA1({ row: 0, col: 0 }); // 'A1'\nparseA1('B3');            // { row: 2, col: 1 }\ncolumnIndexToLabel(26);   // 'AA'\naddressKey({ row: 1, col: 1 }); // stable string key for maps/sets\n```\n\n### DataStore\n\nA sparse, observable cell store with change events.\n\n```ts\nimport { DataStore } from '@ai-path/tb-core';\n\nconst store = new DataStore();\nconst off = store.subscribe((change) => console.info('changed', change));\nstore.set({ row: 0, col: 0 }, 42);\nstore.get({ row: 0, col: 0 }); // 42\noff();\n```\n\n### Selection & undo\n\n`SelectionModel` tracks the active cell and selected ranges; `UndoManager` runs\nreversible `Command`s (and `CompositeCommand`s) with undo/redo.\n\n```ts\nimport { SelectionModel, UndoManager, type Command } from '@ai-path/tb-core';\n\nconst selection = new SelectionModel({ rowCount: 100, colCount: 26 });\nselection.moveTo({ row: 0, col: 0 });\n\nconst undo = new UndoManager();\nconst cmd: Command = { label: 'demo', apply() {/* … */}, invert() { return cmd; } };\nundo.execute(cmd);\nundo.undo();\n```\n\n### Search & conditional formatting\n\n`searchGrid` is a pure scan over a cell accessor; `ConditionalFormatModel` maps a\nvalue to a `CfStyle` via an ordered list of `CfRule`s (first match wins).\n\n```ts\nimport { searchGrid, ConditionalFormatModel, type CfRule } from '@ai-path/tb-core';\n\nconst matches = searchGrid(rows, cols, (r, c) => getDisplay(r, c), 'total', {\n  caseSensitive: false,\n  wholeCell: false,\n});\n\nconst cf = new ConditionalFormatModel();\nconst rule: CfRule = { kind: 'gt', value: 100, style: { background: '#fee', bold: true } };\ncf.addRule(rule);\ncf.styleFor(150); // -> { background: '#fee', bold: true }\n```\n\n### Other models\n\n- `SizeManager` — row/column size tracking with defaults and overrides.\n- `HeaderModel` / `computeHeaderLayout` — multi-level grouped column headers (`ColumnDef`, `ColumnGroupDef`, `ColumnNode`).\n- `MergeModel`, `BorderModel`, `CommentModel`, `ValidationModel` (with `validators`).\n- `SummaryFn` helpers: `summarize`, `summarizeColumn`, `toNumberOrNull`.\n- Ranges: `normalizeRange`, `rangeContains`, `rangesIntersect`, `forEachCell`, `clampRange`.\n- Viewport: `computeVisibleWindow`, `forEachIndex`.\n- Fill: `detectSeries` / `extendSeries` (`SeriesKind`) and `fillRegion` (`FillDirection`).\n- Persistence: `serializeState` / `deserializeState` / `emptyState` (`GridStateSnapshot`).\n- Eventing: `Emitter`, `HookBus`.\n","readmeFilename":"README.md"}