@helix-x/datagrid-ui 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 +15 -0
- package/README.md +141 -0
- package/dist/index.cjs +2351 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +502 -0
- package/dist/index.d.ts +502 -0
- package/dist/index.js +2307 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Easy Freight
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# @helix-x/datagrid-ui
|
|
2
|
+
|
|
3
|
+
A dependency-free React data grid: virtualized rows, server-side paging /
|
|
4
|
+
sorting / filtering, inline row editing, multi-select, CSV + clipboard export
|
|
5
|
+
and persisted column preferences.
|
|
6
|
+
|
|
7
|
+
Its only runtime requirement is React. Styling is plain Tailwind utility
|
|
8
|
+
classes, so there is no CSS file to import and no theme engine to configure.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
The package is a standalone module — it can be installed from a registry, a
|
|
13
|
+
tarball, a git URL, or a relative path:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @helix-x/datagrid-ui
|
|
17
|
+
# or, consuming it from a checkout next to your app:
|
|
18
|
+
npm install file:../helix-x-datagrid
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
React 18 or 19 must already be present; it is a peer dependency and is never
|
|
22
|
+
bundled into the output.
|
|
23
|
+
|
|
24
|
+
### Tailwind
|
|
25
|
+
|
|
26
|
+
The grid renders Tailwind utility classes. Tailwind only generates classes it
|
|
27
|
+
can see, and it skips `node_modules` during automatic content detection, so
|
|
28
|
+
point it at the shipped bundle explicitly:
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
/* your Tailwind v4 entry point */
|
|
32
|
+
@import "tailwindcss";
|
|
33
|
+
@source "../node_modules/@helix-x/datagrid-ui/dist/index.js";
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
On Tailwind v3, add the same path to `content` in `tailwind.config.js`.
|
|
37
|
+
|
|
38
|
+
### Theme requirements
|
|
39
|
+
|
|
40
|
+
The grid uses the `brand`, `gray` and `error` colour families and the
|
|
41
|
+
class-based `dark` variant. If your project does not already define them:
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
@custom-variant dark (&:is(.dark *));
|
|
45
|
+
|
|
46
|
+
@theme {
|
|
47
|
+
--color-brand-25: #f2f7ff;
|
|
48
|
+
--color-brand-50: #ecf3ff;
|
|
49
|
+
--color-brand-200: #c2d6ff;
|
|
50
|
+
--color-brand-400: #7592ff;
|
|
51
|
+
--color-brand-500: #465fff;
|
|
52
|
+
--color-brand-600: #3641f5;
|
|
53
|
+
|
|
54
|
+
--color-error-50: #fef3f2;
|
|
55
|
+
--color-error-300: #fda29b;
|
|
56
|
+
--color-error-500: #f04438;
|
|
57
|
+
--color-error-600: #d92d20;
|
|
58
|
+
--color-error-700: #b42318;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { DataGrid, type ColumnDef, type GridApi } from '@helix-x/datagrid-ui';
|
|
66
|
+
|
|
67
|
+
const columns: ColumnDef<Person, Ctx>[] = [
|
|
68
|
+
{ field: 'id', header: 'ID', width: 90, filter: 'number' },
|
|
69
|
+
{ field: 'name', header: 'Name', flex: 1, filter: 'text', editable: true },
|
|
70
|
+
{ field: 'status', header: 'Status', filter: 'set',
|
|
71
|
+
filterParams: { values: ['ACTIVE', 'CLOSED'] },
|
|
72
|
+
editable: true, editor: 'select',
|
|
73
|
+
editorParams: { options: [{ label: 'Active', value: 'ACTIVE' }] } },
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
<DataGrid
|
|
77
|
+
columns={columns}
|
|
78
|
+
getRowId={(row) => row.id}
|
|
79
|
+
dataSource={{ getRows: (request, signal) => api.list(request, signal) }}
|
|
80
|
+
storageKey="people"
|
|
81
|
+
context={{ onEdit }}
|
|
82
|
+
onRowCommit={async (draft) => {
|
|
83
|
+
const parsed = schema.safeParse(draft);
|
|
84
|
+
if (!parsed.success) return { ok: false, errors: toFieldErrors(parsed.error) };
|
|
85
|
+
await api.save(draft);
|
|
86
|
+
return { ok: true };
|
|
87
|
+
}}
|
|
88
|
+
apiRef={apiRef}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Server contract
|
|
93
|
+
|
|
94
|
+
`getRows` receives a request that is structurally identical to ag-grid's
|
|
95
|
+
server-side row model request, so an endpoint written for that model works
|
|
96
|
+
unchanged:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
{ startRow, endRow, sortModel: [{ colId, sort }], filterModel,
|
|
100
|
+
rowGroupCols: [], valueCols: [], pivotCols: [], pivotMode: false, groupKeys: [] }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
and returns `{ rows, lastRow }`. Filter models use the same four shapes
|
|
104
|
+
(`text`, `number`, `date`, `set`) that ag-grid emits.
|
|
105
|
+
|
|
106
|
+
### Performance note
|
|
107
|
+
|
|
108
|
+
Column definitions should be memoised on `[]`. Anything volatile — in-flight
|
|
109
|
+
ids, permission checks, event handlers — belongs in `context`, which is passed
|
|
110
|
+
to every `cellRenderer`. Changing `context` re-renders cells without rebuilding
|
|
111
|
+
a single column definition.
|
|
112
|
+
|
|
113
|
+
## Local development
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install # build toolchain only; React comes from the host app
|
|
117
|
+
npm run build # dist/ — ESM, CJS and .d.ts
|
|
118
|
+
npm run dev # rebuild on change
|
|
119
|
+
npm run typecheck
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
When an app consumes this package through a relative path or `npm link`, npm
|
|
123
|
+
creates a symlink and Node can resolve a *second* copy of React from the
|
|
124
|
+
package's own tree. Nothing here installs React (`.npmrc` sets
|
|
125
|
+
`legacy-peer-deps` so the peer range is not auto-installed), but bundlers
|
|
126
|
+
should still be told to dedupe:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
// vite.config.ts
|
|
130
|
+
resolve: { dedupe: ['react', 'react-dom'] }
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Packaging
|
|
134
|
+
|
|
135
|
+
`npm pack` produces an installable tarball; `prepack` rebuilds `dist/` first,
|
|
136
|
+
so the published artifact is never stale.
|
|
137
|
+
|
|
138
|
+
## Not in this version
|
|
139
|
+
|
|
140
|
+
Row grouping, pivoting, tree data, master/detail, variable row heights, and
|
|
141
|
+
`.xlsx` output (CSV with a BOM opens natively in Excel).
|