@jielga/tmdatagrid 0.1.0
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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/index.d.ts +592 -0
- package/dist/index.js +1590 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/package.json +111 -0
- package/skills/columns/SKILL.md +195 -0
- package/skills/features/SKILL.md +214 -0
- package/skills/getting-started/SKILL.md +209 -0
- package/skills/options/SKILL.md +208 -0
- package/skills/server-side/SKILL.md +150 -0
- package/src/tmdatagrid/TMDataGrid.module.css +410 -0
- package/src/tmdatagrid/TMDataGrid.tsx +101 -0
- package/src/tmdatagrid/TMDataGridColumnsPanel.tsx +91 -0
- package/src/tmdatagrid/TMDataGridContext.ts +32 -0
- package/src/tmdatagrid/TMDataGridFilterPanel.tsx +182 -0
- package/src/tmdatagrid/TMDataGridFooter.tsx +74 -0
- package/src/tmdatagrid/TMDataGridHeaderCell.tsx +466 -0
- package/src/tmdatagrid/TMDataGridTable.tsx +297 -0
- package/src/tmdatagrid/TMDataGridToolbar.tsx +131 -0
- package/src/tmdatagrid/capabilities.ts +117 -0
- package/src/tmdatagrid/columnOrdering.ts +140 -0
- package/src/tmdatagrid/columnUtils.ts +43 -0
- package/src/tmdatagrid/filterOperators.ts +171 -0
- package/src/tmdatagrid/icons.ts +25 -0
- package/src/tmdatagrid/index.ts +68 -0
- package/src/tmdatagrid/persistence.ts +187 -0
- package/src/tmdatagrid/sizes.ts +29 -0
- package/src/tmdatagrid/useTMDataGrid.tsx +378 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jielga
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# TMDataGrid
|
|
2
|
+
|
|
3
|
+
A data grid for React built on [TanStack Table v9](https://tanstack.com/table) and
|
|
4
|
+
[Mantine](https://mantine.dev). Rows are always virtualized, columns are resizable,
|
|
5
|
+
reorderable, sortable, filterable, hideable and pinnable, and every piece of grid
|
|
6
|
+
chrome is a component you opt into.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @jielga/tmdatagrid
|
|
12
|
+
```
|
|
13
|
+
|
|
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
|
+
Import both stylesheets once in your app, Mantine's first:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import "@mantine/core/styles.css";
|
|
22
|
+
import "@jielga/tmdatagrid/styles.css";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The grid must be rendered inside a Mantine `MantineProvider`.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
`useTMDataGrid` creates the table, `TMDataGrid` provides it through context, and
|
|
30
|
+
the parts rendered inside read what they need from that context.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import {
|
|
34
|
+
createTMDataGridColumnHelper,
|
|
35
|
+
TMDataGrid,
|
|
36
|
+
useTMDataGrid,
|
|
37
|
+
} from "@jielga/tmdatagrid";
|
|
38
|
+
|
|
39
|
+
type Employee = { id: number; firstName: string; age: number };
|
|
40
|
+
|
|
41
|
+
const columnHelper = createTMDataGridColumnHelper<Employee>();
|
|
42
|
+
|
|
43
|
+
const columns = columnHelper.columns([
|
|
44
|
+
columnHelper.accessor("id", { header: "ID", meta: { type: "number" } }),
|
|
45
|
+
columnHelper.accessor("firstName", { header: "First name" }),
|
|
46
|
+
columnHelper.accessor("age", {
|
|
47
|
+
header: "Age",
|
|
48
|
+
meta: { type: "number", align: "right" },
|
|
49
|
+
}),
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
export function Employees({ data }: { data: Employee[] }) {
|
|
53
|
+
const grid = useTMDataGrid({
|
|
54
|
+
data,
|
|
55
|
+
columns,
|
|
56
|
+
getRowId: (row) => String(row.id),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<TMDataGrid {...grid} size="md" style={{ flex: 1, minHeight: 0 }}>
|
|
61
|
+
<TMDataGrid.Toolbar>
|
|
62
|
+
<TMDataGrid.SummaryCount />
|
|
63
|
+
<TMDataGrid.Spacer />
|
|
64
|
+
<TMDataGrid.FilterButton />
|
|
65
|
+
<TMDataGrid.ColumnsButton />
|
|
66
|
+
</TMDataGrid.Toolbar>
|
|
67
|
+
|
|
68
|
+
<TMDataGrid.Table<Employee> />
|
|
69
|
+
<TMDataGrid.Footer />
|
|
70
|
+
</TMDataGrid>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Only the parts you render exist. Leave out `TMDataGrid.Footer` and there is no
|
|
76
|
+
pagination; a column that defines no filter shows no filter control.
|
|
77
|
+
|
|
78
|
+
## Documentation
|
|
79
|
+
|
|
80
|
+
The documentation is written as markdown under [`src/docs/`](src/docs) and served by the
|
|
81
|
+
demo site:
|
|
82
|
+
|
|
83
|
+
| Page | Contents |
|
|
84
|
+
| ---------------------------------------------- | -------------------------------- |
|
|
85
|
+
| [Getting started](src/docs/getting-started.md) | Structure and defaults |
|
|
86
|
+
| [useTMDataGrid](src/docs/use-tm-data-grid.md) | Options, meta and persistence |
|
|
87
|
+
| [Components](src/docs/components.md) | Props for every component |
|
|
88
|
+
| [Columns](src/docs/columns.md) | Definitions, sizing and filters |
|
|
89
|
+
| [Features](src/docs/features.md) | Enabling and disabling behaviour |
|
|
90
|
+
| [Server-side](src/docs/server-side.md) | Manual pagination and filtering |
|
|
91
|
+
|
|
92
|
+
## Development
|
|
93
|
+
|
|
94
|
+
The grid lives in [`src/tmdatagrid/`](src/tmdatagrid); everything else in `src`
|
|
95
|
+
is the demo site that documents it.
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
npm install
|
|
99
|
+
npm run dev # demo site with the grid example and docs
|
|
100
|
+
npm run lint # oxlint
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Building
|
|
104
|
+
|
|
105
|
+
Two independent outputs, neither committed:
|
|
106
|
+
|
|
107
|
+
| Command | Output | Contents |
|
|
108
|
+
| ------------------- | ------------ | --------------------- |
|
|
109
|
+
| `npm run build:lib` | `dist/` | The published package |
|
|
110
|
+
| `npm run build` | `dist-demo/` | The demo site |
|
|
111
|
+
|
|
112
|
+
`build:lib` runs three steps. Vite bundles `src/tmdatagrid/index.ts` into
|
|
113
|
+
`dist/index.js` with every peer dependency left external, and emits the CSS
|
|
114
|
+
modules as a single `dist/styles.css`. TypeScript then writes per-file
|
|
115
|
+
declarations to `.types-tmp/`, and rollup flattens those into one
|
|
116
|
+
`dist/index.d.ts`.
|
|
117
|
+
|
|
118
|
+
The declarations are flattened rather than shipped as a tree because
|
|
119
|
+
TypeScript emits relative imports verbatim: an extensionless `./TMDataGrid`
|
|
120
|
+
resolves only under `moduleResolution: bundler` and breaks for anyone on
|
|
121
|
+
`node16`/`nodenext`. A single file has no relative imports to resolve, so it
|
|
122
|
+
works everywhere without putting `.js` extensions in the sources.
|
|
123
|
+
|
|
124
|
+
## Publishing
|
|
125
|
+
|
|
126
|
+
Releases are managed by [Changesets](https://github.com/changesets/changesets).
|
|
127
|
+
Nothing publishes from an ordinary push — a release happens only when the
|
|
128
|
+
version PR is merged.
|
|
129
|
+
|
|
130
|
+
Describe your change in the same PR that makes it:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
npm run changeset # pick patch/minor/major, write a summary
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
That writes a markdown file under `.changeset/`. Commit it alongside the code.
|
|
137
|
+
|
|
138
|
+
Once on `main`, [`release.yml`](.github/workflows/release.yml) opens a
|
|
139
|
+
**chore: version packages** PR that collects every pending changeset, bumps
|
|
140
|
+
`package.json`, writes `CHANGELOG.md` and syncs the skills. The PR is the
|
|
141
|
+
release proposal: review the version it picked and the changelog it wrote, then
|
|
142
|
+
merge it to publish to npm with provenance.
|
|
143
|
+
|
|
144
|
+
The package build runs from `prepublishOnly` rather than as a workflow step, so
|
|
145
|
+
`npm publish` cannot ship a stale `dist` whether it runs in CI or by hand.
|
|
146
|
+
|
|
147
|
+
### Skill versions
|
|
148
|
+
|
|
149
|
+
`npm run version-packages` is `changeset version` followed by
|
|
150
|
+
[`scripts/sync-skill-version.mjs`](scripts/sync-skill-version.mjs), which sets
|
|
151
|
+
`metadata.library_version` in every `skills/*/SKILL.md` to the new version.
|
|
152
|
+
|
|
153
|
+
Intent reports a skill as stale when its `library_version` trails the package
|
|
154
|
+
version, so without that step every release would leave all five skills stale.
|
|
155
|
+
Because it runs inside the version command, the bump and the skill sync land in
|
|
156
|
+
the same PR and are reviewed together.
|
|
157
|
+
|
|
158
|
+
To check what a release would contain without publishing anything:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
npm publish --dry-run
|
|
162
|
+
```
|