@jielga/tmdatagrid 2.0.0-beta.14 → 2.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +5 -212
  2. package/dist/index.d.ts +959 -620
  3. package/dist/index.js +3041 -2405
  4. package/dist/index.js.map +1 -1
  5. package/dist/styles.css +1 -1
  6. package/docs/anatomy.md +102 -0
  7. package/docs/cell-selection.md +154 -0
  8. package/docs/column-layout.md +204 -0
  9. package/docs/columns.md +262 -0
  10. package/docs/components.md +303 -0
  11. package/docs/editing.md +573 -0
  12. package/docs/editors.md +248 -0
  13. package/docs/export.md +326 -0
  14. package/docs/filtering.md +358 -0
  15. package/docs/getting-started.md +123 -0
  16. package/docs/grouping.md +165 -0
  17. package/docs/loading-and-empty.md +92 -0
  18. package/docs/localization.md +79 -0
  19. package/docs/menu.md +143 -0
  20. package/docs/pagination.md +144 -0
  21. package/docs/persistence.md +111 -0
  22. package/docs/portfolio-rebalancer.md +94 -0
  23. package/docs/query-builder.md +175 -0
  24. package/docs/quick-search.md +83 -0
  25. package/docs/row-details.md +111 -0
  26. package/docs/row-interaction.md +148 -0
  27. package/docs/row-pinning.md +132 -0
  28. package/docs/row-selection.md +134 -0
  29. package/docs/row-styling.md +133 -0
  30. package/docs/scrolling.md +111 -0
  31. package/docs/server-query.md +246 -0
  32. package/docs/server-side.md +206 -0
  33. package/docs/sorting.md +101 -0
  34. package/docs/styling.md +126 -0
  35. package/docs/summary-row.md +76 -0
  36. package/docs/testing.md +309 -0
  37. package/docs/toolbar.md +161 -0
  38. package/docs/use-tm-data-grid.md +361 -0
  39. package/package.json +21 -45
  40. package/skills/appearance/SKILL.md +31 -15
  41. package/skills/cell-selection/SKILL.md +47 -45
  42. package/skills/columns/SKILL.md +22 -22
  43. package/skills/data/SKILL.md +85 -15
  44. package/skills/editing/SKILL.md +6 -6
  45. package/skills/editing/references/common-mistakes.md +12 -12
  46. package/skills/filtering/SKILL.md +14 -14
  47. package/skills/getting-started/SKILL.md +5 -5
  48. package/skills/grouping/SKILL.md +11 -11
  49. package/skills/options/SKILL.md +5 -5
  50. package/skills/rows/SKILL.md +15 -15
  51. package/skills/server-side/SKILL.md +4 -4
  52. package/skills/testing/SKILL.md +4 -4
  53. package/src/{tmdatagrid/components → components}/TMDataGrid.tsx +7 -0
  54. package/src/{tmdatagrid/components → components}/TMDataGridCellEditor.tsx +5 -4
  55. package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.module.css +5 -1
  56. package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.tsx +40 -15
  57. package/src/{tmdatagrid/components → components}/TMDataGridEditColumn.tsx +9 -15
  58. package/src/{tmdatagrid/components → components}/TMDataGridEntryRows.tsx +102 -66
  59. package/src/components/TMDataGridExportPicker.module.css +77 -0
  60. package/src/components/TMDataGridExportPicker.tsx +234 -0
  61. package/src/{tmdatagrid/components → components}/TMDataGridFilterPanel.tsx +17 -5
  62. package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.tsx +7 -5
  63. package/src/{tmdatagrid/components → components}/TMDataGridFilterSurface.tsx +8 -3
  64. package/src/{tmdatagrid/components → components}/TMDataGridFooter.tsx +20 -7
  65. package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.tsx +16 -5
  66. package/src/{tmdatagrid/components → components}/TMDataGridMenu.tsx +104 -6
  67. package/src/{tmdatagrid/components → components}/TMDataGridSelectColumn.tsx +2 -1
  68. package/src/{tmdatagrid/components → components}/TMDataGridTable.module.css +9 -5
  69. package/src/{tmdatagrid/components → components}/TMDataGridTable.tsx +74 -55
  70. package/src/{tmdatagrid/components → components}/TMDataGridToolbar.module.css +5 -0
  71. package/src/{tmdatagrid/components → components}/TMDataGridToolbar.tsx +44 -8
  72. package/src/{tmdatagrid/components → components}/editors/editorShared.ts +2 -1
  73. package/src/{tmdatagrid/components → components}/icons.ts +1 -0
  74. package/src/{tmdatagrid/core → core}/autosize.ts +5 -2
  75. package/src/{tmdatagrid/core → core}/columnOrdering.ts +33 -14
  76. package/src/{tmdatagrid/core → core}/columnUtils.ts +19 -0
  77. package/src/core/dom.ts +74 -0
  78. package/src/core/export.ts +840 -0
  79. package/src/{tmdatagrid/core → core}/labels.ts +40 -2
  80. package/src/{tmdatagrid/core → core}/labelsSv.ts +17 -1
  81. package/src/{tmdatagrid/core → core}/persistence.ts +22 -5
  82. package/src/{tmdatagrid/core → core}/summary.ts +20 -4
  83. package/src/{tmdatagrid/index.ts → index.ts} +42 -4
  84. package/src/{tmdatagrid/useTMDataGrid.tsx → useTMDataGrid.tsx} +98 -43
  85. package/src/useTMDataGridExport.ts +78 -0
  86. package/src/tmdatagrid/core/cellExport.ts +0 -320
  87. /package/src/{tmdatagrid/TMDataGridContext.ts → TMDataGridContext.ts} +0 -0
  88. /package/src/{tmdatagrid/components → components}/TMDataGrid.module.css +0 -0
  89. /package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.module.css +0 -0
  90. /package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.tsx +0 -0
  91. /package/src/{tmdatagrid/components → components}/TMDataGridDraftActions.tsx +0 -0
  92. /package/src/{tmdatagrid/components → components}/TMDataGridFilterPanel.module.css +0 -0
  93. /package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.module.css +0 -0
  94. /package/src/{tmdatagrid/components → components}/TMDataGridFilterSurface.module.css +0 -0
  95. /package/src/{tmdatagrid/components → components}/TMDataGridFooter.module.css +0 -0
  96. /package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.module.css +0 -0
  97. /package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.tsx +0 -0
  98. /package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.module.css +0 -0
  99. /package/src/{tmdatagrid/components → components}/TMDataGridHeaderFilterRow.module.css +0 -0
  100. /package/src/{tmdatagrid/components → components}/TMDataGridHeaderFilterRow.tsx +0 -0
  101. /package/src/{tmdatagrid/components → components}/TMDataGridRowNumberColumn.tsx +0 -0
  102. /package/src/{tmdatagrid/components → components}/TMDataGridSearch.tsx +0 -0
  103. /package/src/{tmdatagrid/components → components}/editors/TMDataGridBooleanEditor.tsx +0 -0
  104. /package/src/{tmdatagrid/components → components}/editors/TMDataGridDateEditor.tsx +0 -0
  105. /package/src/{tmdatagrid/components → components}/editors/TMDataGridMultiSelectEditor.tsx +0 -0
  106. /package/src/{tmdatagrid/components → components}/editors/TMDataGridNumberEditor.tsx +0 -0
  107. /package/src/{tmdatagrid/components → components}/editors/TMDataGridSelectEditor.tsx +0 -0
  108. /package/src/{tmdatagrid/components → components}/editors/TMDataGridStringEditor.tsx +0 -0
  109. /package/src/{tmdatagrid/components → components}/filters/DgAutocompleteFilter.tsx +0 -0
  110. /package/src/{tmdatagrid/components → components}/filters/DgDateRangeFilter.tsx +0 -0
  111. /package/src/{tmdatagrid/components → components}/filters/DgRangeSliderFilter.tsx +0 -0
  112. /package/src/{tmdatagrid/components → components}/filters/DgTriStateFilter.tsx +0 -0
  113. /package/src/{tmdatagrid/components → components}/filters/TMDataGridFilterValueInput.tsx +0 -0
  114. /package/src/{tmdatagrid/components → components}/filters/controlLayout.ts +0 -0
  115. /package/src/{tmdatagrid/components → components}/filters/filterControlFor.ts +0 -0
  116. /package/src/{tmdatagrid/components → components}/sticky.module.css +0 -0
  117. /package/src/{tmdatagrid/components → components}/useHideableColumns.ts +0 -0
  118. /package/src/{tmdatagrid/core → core}/capabilities.ts +0 -0
  119. /package/src/{tmdatagrid/core → core}/cellNavigation.ts +0 -0
  120. /package/src/{tmdatagrid/core → core}/cellRange.ts +0 -0
  121. /package/src/{tmdatagrid/core → core}/columnOptions.ts +0 -0
  122. /package/src/{tmdatagrid/core → core}/controlledState.ts +0 -0
  123. /package/src/{tmdatagrid/core → core}/controlledStateSync.ts +0 -0
  124. /package/src/{tmdatagrid/core → core}/draftCellContext.ts +0 -0
  125. /package/src/{tmdatagrid/core → core}/editEngine.ts +0 -0
  126. /package/src/{tmdatagrid/core → core}/editorFocus.ts +0 -0
  127. /package/src/{tmdatagrid/core → core}/expanding.ts +0 -0
  128. /package/src/{tmdatagrid/core → core}/filterControls.ts +0 -0
  129. /package/src/{tmdatagrid/core → core}/filterOperators.ts +0 -0
  130. /package/src/{tmdatagrid/core → core}/filterSurface.ts +0 -0
  131. /package/src/{tmdatagrid/core → core}/grouping.ts +0 -0
  132. /package/src/{tmdatagrid/core → core}/matchHighlight.ts +0 -0
  133. /package/src/{tmdatagrid/core → core}/pageReset.ts +0 -0
  134. /package/src/{tmdatagrid/core → core}/quickSearch.ts +0 -0
  135. /package/src/{tmdatagrid/core → core}/resizePreview.ts +0 -0
  136. /package/src/{tmdatagrid/core → core}/rowPinning.ts +0 -0
  137. /package/src/{tmdatagrid/core → core}/rowSelection.ts +0 -0
  138. /package/src/{tmdatagrid/core → core}/sizes.ts +0 -0
  139. /package/src/{tmdatagrid/core → core}/useSettledTableState.ts +0 -0
package/README.md CHANGED
@@ -1,219 +1,12 @@
1
- # TMDataGrid
1
+ # @jielga/tmdatagrid
2
2
 
3
- A data grid for React built on [TanStack Table v9](https://tanstack.com/table)
4
- and [Mantine](https://mantine.dev). Rows are always virtualized, columns are
5
- resizable, reorderable, sortable, filterable, hideable and pinnable, and every
6
- part of the grid interface is a component you render yourself.
3
+ A React data grid built on TanStack Table v9 and Mantine - always virtualized, with resizable, reorderable, sortable, filterable, hideable and pinnable columns.
7
4
 
8
- ## Installation
5
+ - Documentation: <https://jielga.github.io/TMDataGrid/>
6
+ - Source, issues and the contributor guide: <https://github.com/Jielga/TMDataGrid>
9
7
 
10
8
  ```sh
11
9
  npm install @jielga/tmdatagrid
12
10
  ```
13
11
 
14
- Peer dependencies: `react` and `react-dom` (19.1 or later), `@mantine/core`,
15
- `@tanstack/react-table` (v9), `@tanstack/react-store`, `@tanstack/store`,
16
- `@tanstack/react-virtual` and `@tabler/icons-react`.
17
-
18
- > **TanStack Table v9 is still in beta.** The grid is built against
19
- > `^9.0.0-beta.21` and uses its feature-registry API, which beta releases may
20
- > change without a major bump. Pin `@tanstack/react-table` and
21
- > `@tanstack/table-core` to an exact version if you need reproducible installs.
22
-
23
- Import both stylesheets once in your app, Mantine's first:
24
-
25
- ```ts
26
- import "@mantine/core/styles.css";
27
- import "@jielga/tmdatagrid/styles.css";
28
- ```
29
-
30
- The grid must be rendered inside a Mantine `MantineProvider`.
31
-
32
- ## Usage
33
-
34
- `useTMDataGrid` creates the table, `TMDataGrid` provides it through context, and
35
- the parts rendered inside read what they need from that context.
36
-
37
- ```tsx
38
- import {
39
- createTMDataGridColumnHelper,
40
- TMDataGrid,
41
- useTMDataGrid,
42
- } from "@jielga/tmdatagrid";
43
-
44
- type Employee = { id: number; firstName: string; age: number };
45
-
46
- const columnHelper = createTMDataGridColumnHelper<Employee>();
47
-
48
- const columns = columnHelper.columns([
49
- columnHelper.accessor("id", { header: "ID", meta: { type: "number" } }),
50
- columnHelper.accessor("firstName", { header: "First name" }),
51
- columnHelper.accessor("age", {
52
- header: "Age",
53
- meta: { type: "number", align: "right" },
54
- }),
55
- ]);
56
-
57
- export function Employees({ data }: { data: Employee[] }) {
58
- const grid = useTMDataGrid({
59
- data,
60
- columns,
61
- getRowId: (row) => String(row.id),
62
- enablePagination: true,
63
- });
64
-
65
- return (
66
- <TMDataGrid {...grid} size="md" style={{ flex: 1, minHeight: 0 }}>
67
- <TMDataGrid.Toolbar>
68
- <TMDataGrid.SummaryCount />
69
- <TMDataGrid.Spacer />
70
- <TMDataGrid.FilterButton />
71
- <TMDataGrid.ColumnsButton />
72
- </TMDataGrid.Toolbar>
73
-
74
- <TMDataGrid.Table<Employee> />
75
- <TMDataGrid.Footer />
76
- </TMDataGrid>
77
- );
78
- }
79
- ```
80
-
81
- Only the parts you render exist, and only the features you enable have state.
82
- Pagination is opt in through `enablePagination` (implied by `manualPagination`);
83
- by default every row renders, virtualized. A column that defines no filter shows
84
- no filter control.
85
-
86
- ## Documentation
87
-
88
- The documentation is markdown under [`src/docs/`](src/docs), served by the demo
89
- site. There is one page per topic, each holding the prose, its demos and a
90
- reference table. [`docsPages.ts`](src/docs/docsPages.ts) is the registry and the
91
- sidebar order.
92
-
93
- | Section | Pages |
94
- | -------------------- | ---------------------------------------------------------------- |
95
- | Start here | [Getting started](src/docs/getting-started.md), [Grid anatomy](src/docs/anatomy.md) |
96
- | Columns | [Defining columns](src/docs/columns.md), [Sorting](src/docs/sorting.md), [Filtering](src/docs/filtering.md), [Visibility, pinning, ordering and size](src/docs/column-layout.md) |
97
- | Rows | [Selection](src/docs/row-selection.md), [Details](src/docs/row-details.md), [Grouping](src/docs/grouping.md), [Summary row](src/docs/summary-row.md), [Row pinning and numbering](src/docs/row-pinning.md), [Clicks and context menus](src/docs/row-interaction.md), [Row styling](src/docs/row-styling.md) |
98
- | Cells and editing | [Cell selection](src/docs/cell-selection.md), [Editing](src/docs/editing.md), [Editors and validation](src/docs/editors.md) |
99
- | Data | [Pagination](src/docs/pagination.md), [Quick search](src/docs/quick-search.md), [Persistence](src/docs/persistence.md), [Server-side](src/docs/server-side.md), [Loading and empty states](src/docs/loading-and-empty.md), [Scrolling and virtualization](src/docs/scrolling.md) |
100
- | Appearance | [Size, styling and theming](src/docs/styling.md), [Toolbar](src/docs/toolbar.md), [Localization](src/docs/localization.md) |
101
- | Reference | [useTMDataGrid](src/docs/use-tm-data-grid.md), [Testing](src/docs/testing.md) |
102
-
103
- ## Development
104
-
105
- The grid lives in [`src/tmdatagrid/`](src/tmdatagrid); everything else in `src`
106
- is the demo site that documents it.
107
-
108
- | Path | Contents |
109
- | ------------------- | ------------------------------------------------------------ |
110
- | `index.ts` | The public API, and the only entry point the package exposes |
111
- | `useTMDataGrid.tsx` | The hook that builds the table, and the types it is built on |
112
- | `core/` | Headless logic: filtering, ordering, persistence, capabilities |
113
- | `components/` | The React components and their co-located CSS modules |
114
-
115
- ### Examples
116
-
117
- The demo site's examples live in [`src/examples/`](src/examples):
118
-
119
- | Path | Contents |
120
- | ----------------- | -------------------------------------------------------------- |
121
- | `demoRegistry.ts` | Pairs each demo module with its own source through `import.meta.glob` |
122
- | `demos/` | One file per demo: one idea, no headings, no explanation |
123
- | `data/` | Shared datasets, and the column set used by unrelated demos |
124
- | `playground/` | Every feature at once, behind switches |
125
-
126
- To add a demo, add a file under `demos/` and name it from a ` ```demo ` fence on
127
- the docs page that explains it. The registry pairs each module with its own
128
- source, so the code on screen cannot drift from the code running.
129
- [`demos.test.tsx`](src/examples/demos.test.tsx) mounts every registered demo, so
130
- a demo that stops working fails the suite whether or not it still compiles.
131
-
132
- ```sh
133
- npm install
134
- npm run dev # demo site: examples, playground and docs
135
- npm run lint # oxlint
136
- npm run test # vitest, once
137
- npm run test:watch
138
- ```
139
-
140
- ## Testing
141
-
142
- For testing an application that *uses* the grid, including the test ids, roles
143
- and ARIA attributes it publishes and how to drive it from Playwright, see
144
- [Testing](src/docs/testing.md). What follows is about this repo's own suite.
145
-
146
- Vitest with React Testing Library, in jsdom. Tests sit next to the code they
147
- cover as `*.test.ts(x)` and are excluded from both the package and the
148
- declaration build; shared fixtures live in [`src/test/`](src/test) so they stay
149
- out of `src/tmdatagrid/` entirely.
150
-
151
- Two things to know before adding to them:
152
-
153
- - `vitest.setup.ts` installs what jsdom does not provide: an in-memory
154
- `Storage`, `matchMedia`, `ResizeObserver`, and element sizes. Element sizes
155
- matter, because without a measurable box the virtualizer renders no rows.
156
- - The Mantine provider in the harness runs with `env="test"`, which disables
157
- transitions. Without it a popover never finishes mounting and its panel is
158
- never found.
159
-
160
- ## Building
161
-
162
- Two independent outputs, neither committed:
163
-
164
- | Command | Output | Contents |
165
- | ------------------- | ------------ | --------------------- |
166
- | `npm run build:lib` | `dist/` | The published package |
167
- | `npm run build` | `dist-demo/` | The demo site |
168
-
169
- `build:lib` runs three steps. Vite bundles `src/tmdatagrid/index.ts` into
170
- `dist/index.js` with every peer dependency left external, and emits the CSS
171
- modules as a single `dist/styles.css`. TypeScript then writes per-file
172
- declarations to `.types-tmp/`, and rollup flattens those into one
173
- `dist/index.d.ts`.
174
-
175
- The declarations are flattened rather than shipped as a tree because
176
- TypeScript emits relative imports verbatim: an extensionless `./TMDataGrid`
177
- resolves only under `moduleResolution: bundler` and breaks for anyone on
178
- `node16`/`nodenext`. A single file has no relative imports to resolve, so it
179
- works everywhere without putting `.js` extensions in the sources.
180
-
181
- ## Publishing
182
-
183
- Releases are managed by [Changesets](https://github.com/changesets/changesets).
184
- Nothing publishes from an ordinary push. A release happens only when the version
185
- PR is merged.
186
-
187
- Describe your change in the same PR that makes it:
188
-
189
- ```sh
190
- npm run changeset # pick patch/minor/major, write a summary
191
- ```
192
-
193
- That writes a markdown file under `.changeset/`. Commit it alongside the code.
194
-
195
- Once on `main`, [`release.yml`](.github/workflows/release.yml) opens a
196
- **chore: version packages** PR that collects every pending changeset, bumps
197
- `package.json`, writes `CHANGELOG.md` and syncs the skills. Review the version it
198
- picked and the changelog it wrote, then merge it to publish to npm with
199
- provenance.
200
-
201
- The package build runs from `prepublishOnly` rather than as a workflow step, so
202
- `npm publish` cannot ship a stale `dist` whether it runs in CI or by hand.
203
-
204
- ### Skill versions
205
-
206
- `npm run version-packages` is `changeset version` followed by
207
- [`scripts/sync-skill-version.mjs`](scripts/sync-skill-version.mjs), which sets
208
- `metadata.library_version` in every `skills/*/SKILL.md` to the new version.
209
-
210
- Intent reports a skill as stale when its `library_version` trails the package
211
- version, so without that step every release would leave every skill stale.
212
- Because it runs inside the version command, the bump and the skill sync land in
213
- the same PR.
214
-
215
- To check what a release would contain without publishing anything:
216
-
217
- ```sh
218
- npm publish --dry-run
219
- ```
12
+ The package ships its reference documentation under `docs/` and its TanStack Intent skills under `skills/`, so an agent working in a project that installs it can load both.