@jielga/tmdatagrid 2.0.0-beta.13 → 2.0.0-beta.15
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.
- package/README.md +5 -212
- package/dist/index.d.ts +967 -610
- package/dist/index.js +2944 -2327
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/docs/anatomy.md +102 -0
- package/docs/cell-selection.md +154 -0
- package/docs/column-layout.md +204 -0
- package/docs/columns.md +262 -0
- package/docs/components.md +303 -0
- package/docs/editing.md +572 -0
- package/docs/editors.md +248 -0
- package/docs/export.md +326 -0
- package/docs/filtering.md +358 -0
- package/docs/getting-started.md +123 -0
- package/docs/grouping.md +165 -0
- package/docs/loading-and-empty.md +92 -0
- package/docs/localization.md +79 -0
- package/docs/menu.md +143 -0
- package/docs/pagination.md +144 -0
- package/docs/persistence.md +111 -0
- package/docs/portfolio-rebalancer.md +94 -0
- package/docs/query-builder.md +175 -0
- package/docs/quick-search.md +83 -0
- package/docs/row-details.md +111 -0
- package/docs/row-interaction.md +148 -0
- package/docs/row-pinning.md +132 -0
- package/docs/row-selection.md +134 -0
- package/docs/row-styling.md +133 -0
- package/docs/scrolling.md +111 -0
- package/docs/server-query.md +246 -0
- package/docs/server-side.md +206 -0
- package/docs/sorting.md +101 -0
- package/docs/styling.md +126 -0
- package/docs/summary-row.md +76 -0
- package/docs/testing.md +309 -0
- package/docs/toolbar.md +161 -0
- package/docs/use-tm-data-grid.md +361 -0
- package/package.json +21 -45
- package/skills/appearance/SKILL.md +31 -15
- package/skills/cell-selection/SKILL.md +44 -41
- package/skills/columns/SKILL.md +33 -32
- package/skills/data/SKILL.md +85 -15
- package/skills/editing/SKILL.md +6 -6
- package/skills/editing/references/common-mistakes.md +12 -12
- package/skills/filtering/SKILL.md +40 -18
- package/skills/getting-started/SKILL.md +5 -5
- package/skills/grouping/SKILL.md +11 -11
- package/skills/options/SKILL.md +5 -5
- package/skills/rows/SKILL.md +15 -15
- package/skills/server-side/SKILL.md +131 -7
- package/skills/testing/SKILL.md +4 -4
- package/src/{tmdatagrid/components → components}/TMDataGrid.tsx +28 -20
- package/src/{tmdatagrid/components → components}/TMDataGridCellEditor.tsx +5 -4
- package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.module.css +5 -1
- package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.tsx +40 -15
- package/src/components/TMDataGridExportPicker.module.css +77 -0
- package/src/components/TMDataGridExportPicker.tsx +234 -0
- package/src/{tmdatagrid/components → components}/TMDataGridFilterPanel.tsx +22 -6
- package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.tsx +7 -5
- package/src/{tmdatagrid/components → components}/TMDataGridFilterSurface.tsx +8 -3
- package/src/{tmdatagrid/components → components}/TMDataGridFooter.tsx +20 -7
- package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.tsx +16 -5
- package/src/{tmdatagrid/components → components}/TMDataGridHeaderFilterRow.tsx +2 -4
- package/src/{tmdatagrid/components → components}/TMDataGridMenu.tsx +115 -16
- package/src/{tmdatagrid/components → components}/TMDataGridSelectColumn.tsx +2 -1
- package/src/{tmdatagrid/components → components}/TMDataGridTable.tsx +74 -55
- package/src/{tmdatagrid/components → components}/TMDataGridToolbar.module.css +5 -0
- package/src/{tmdatagrid/components → components}/TMDataGridToolbar.tsx +44 -8
- package/src/{tmdatagrid/components → components}/editors/editorShared.ts +2 -1
- package/src/{tmdatagrid/components → components}/icons.ts +1 -0
- package/src/{tmdatagrid/core → core}/autosize.ts +5 -2
- package/src/{tmdatagrid/core → core}/columnOrdering.ts +33 -14
- package/src/{tmdatagrid/core → core}/columnUtils.ts +44 -5
- package/src/core/dom.ts +74 -0
- package/src/core/export.ts +840 -0
- package/src/{tmdatagrid/core → core}/filterControls.ts +10 -1
- package/src/{tmdatagrid/core → core}/labels.ts +40 -2
- package/src/{tmdatagrid/core → core}/labelsSv.ts +17 -1
- package/src/{tmdatagrid/core → core}/persistence.ts +22 -5
- package/src/{tmdatagrid/core → core}/summary.ts +20 -4
- package/src/{tmdatagrid/index.ts → index.ts} +43 -4
- package/src/{tmdatagrid/useTMDataGrid.tsx → useTMDataGrid.tsx} +100 -45
- package/src/useTMDataGridExport.ts +78 -0
- package/src/tmdatagrid/core/cellExport.ts +0 -320
- /package/src/{tmdatagrid/TMDataGridContext.ts → TMDataGridContext.ts} +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGrid.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridDraftActions.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridEditColumn.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridEntryRows.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridFilterPanel.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridFilterSurface.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridFooter.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridHeaderFilterRow.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridRowNumberColumn.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridSearch.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridTable.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/editors/TMDataGridBooleanEditor.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/editors/TMDataGridDateEditor.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/editors/TMDataGridMultiSelectEditor.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/editors/TMDataGridNumberEditor.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/editors/TMDataGridSelectEditor.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/editors/TMDataGridStringEditor.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/filters/DgAutocompleteFilter.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/filters/DgDateRangeFilter.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/filters/DgRangeSliderFilter.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/filters/DgTriStateFilter.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/filters/TMDataGridFilterValueInput.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/filters/controlLayout.ts +0 -0
- /package/src/{tmdatagrid/components → components}/filters/filterControlFor.ts +0 -0
- /package/src/{tmdatagrid/components → components}/sticky.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/useHideableColumns.ts +0 -0
- /package/src/{tmdatagrid/core → core}/capabilities.ts +0 -0
- /package/src/{tmdatagrid/core → core}/cellNavigation.ts +0 -0
- /package/src/{tmdatagrid/core → core}/cellRange.ts +0 -0
- /package/src/{tmdatagrid/core → core}/columnOptions.ts +0 -0
- /package/src/{tmdatagrid/core → core}/controlledState.ts +0 -0
- /package/src/{tmdatagrid/core → core}/controlledStateSync.ts +0 -0
- /package/src/{tmdatagrid/core → core}/draftCellContext.ts +0 -0
- /package/src/{tmdatagrid/core → core}/editEngine.ts +0 -0
- /package/src/{tmdatagrid/core → core}/editorFocus.ts +0 -0
- /package/src/{tmdatagrid/core → core}/expanding.ts +0 -0
- /package/src/{tmdatagrid/core → core}/filterOperators.ts +0 -0
- /package/src/{tmdatagrid/core → core}/filterSurface.ts +0 -0
- /package/src/{tmdatagrid/core → core}/grouping.ts +0 -0
- /package/src/{tmdatagrid/core → core}/matchHighlight.ts +0 -0
- /package/src/{tmdatagrid/core → core}/pageReset.ts +0 -0
- /package/src/{tmdatagrid/core → core}/quickSearch.ts +0 -0
- /package/src/{tmdatagrid/core → core}/resizePreview.ts +0 -0
- /package/src/{tmdatagrid/core → core}/rowPinning.ts +0 -0
- /package/src/{tmdatagrid/core → core}/rowSelection.ts +0 -0
- /package/src/{tmdatagrid/core → core}/sizes.ts +0 -0
- /package/src/{tmdatagrid/core → core}/useSettledTableState.ts +0 -0
package/README.md
CHANGED
|
@@ -1,219 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @jielga/tmdatagrid
|
|
2
2
|
|
|
3
|
-
A data grid
|
|
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
|
-
|
|
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
|
-
|
|
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 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), [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](src/docs/loading-and-empty.md), [Scrolling](src/docs/scrolling.md) |
|
|
100
|
-
| Appearance | [Size and styling](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.
|