next-data-kit 11.0.0 → 12.0.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/MIGRATION.md +58 -0
- package/README.md +227 -126
- package/dist/{chunk-5D747NEB.js → chunk-A4ILIJJR.js} +4 -4
- package/dist/chunk-A4ILIJJR.js.map +1 -0
- package/dist/chunk-BERW2A2B.js +123 -0
- package/dist/chunk-BERW2A2B.js.map +1 -0
- package/dist/index-j8_iNoy6.d.ts +120 -0
- package/dist/index.d.ts +12 -110
- package/dist/index.js +5 -116
- package/dist/index.js.map +1 -1
- package/dist/server/drizzle.d.ts +3 -3
- package/dist/server/drizzle.js +4 -4
- package/dist/server/drizzle.js.map +1 -1
- package/dist/server.d.ts +63 -44
- package/dist/server.js +119 -66
- package/dist/server.js.map +1 -1
- package/dist/{source--l-z9HHB.d.ts → source-BPO-9lNK.d.ts} +16 -6
- package/dist/style.css +1 -0
- package/dist/ui.d.ts +401 -0
- package/dist/ui.js +696 -0
- package/dist/ui.js.map +1 -0
- package/package.json +36 -9
- package/registry/r/data-kit.json +59 -23
- package/registry/r/registry.json +45 -15
- package/dist/chunk-5D747NEB.js.map +0 -1
package/MIGRATION.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# Migrating
|
|
2
2
|
|
|
3
|
+
## Migrating from 11.x to 12.0
|
|
4
|
+
|
|
5
|
+
12.0 drops TanStack Table, adds a ready UI that needs no shadcn (`next-data-kit/ui` + `next-data-kit/style.css`), names every export `dataKit…`, nests each column's filter options under `filter`, and sets a table's URL prefix once on the server.
|
|
6
|
+
|
|
7
|
+
### Steps
|
|
8
|
+
|
|
9
|
+
1. `npm install next-data-kit@12`, and remove `@tanstack/react-table` if only next-data-kit used it.
|
|
10
|
+
2. Choose a UI.
|
|
11
|
+
- **shadcn:** set the registry to `https://unpkg.com/next-data-kit@12/registry/r/{name}.json` and run `npx shadcn add @ndk/data-kit`, overwriting only `components/ui/ndk/data-kit/`. Delete 11's `data-kit.tsx`, `hook.tsx`, `view.tsx`, `labels.tsx` and `toolbar.tsx` there: they still import TanStack. Import `DataKit` from `@/components/ui/ndk/data-kit`.
|
|
12
|
+
- **No shadcn:** import `DataKit` from `next-data-kit/ui` and the stylesheet once (with Tailwind: `@import 'next-data-kit/style.css' layer(components);`).
|
|
13
|
+
3. Rename the server imports: `sourceX` → `dataKitSourceX`, `filterCustom` → `dataKitFilterCustom`, `urlEncode` / `urlDecode` → `dataKitUrlEncode` / `dataKitUrlDecode`.
|
|
14
|
+
4. Nest each column's filter:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// 11
|
|
18
|
+
role: { filter: 'multiSelect', option: ['admin', 'user'] },
|
|
19
|
+
createdAt: { filter: 'dateRange', preset: ['7d'], sort: true },
|
|
20
|
+
team: { field: 'teamId', filter: 'select', hidden: true },
|
|
21
|
+
// 12
|
|
22
|
+
role: { filter: { variant: 'multiSelect', option: ['admin', 'user'] } },
|
|
23
|
+
createdAt: { sort: true, filter: { variant: 'dateRange', preset: ['7d'] } },
|
|
24
|
+
team: { field: 'teamId', filter: { variant: 'select', hidden: true } },
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`filterCustom(…)` stays where it was, renamed: `user: { filter: dataKitFilterCustom({ schema, query }) }`. Column keys can't contain `.` any more.
|
|
28
|
+
5. Several tables on one page: `query({ searchParams, key: 'user' })` → `query({ searchParams, prefix: 'user' })`, and drop `dataKey` from the views (the prefix comes back in the data). A prefix uses `a-z`, `0-9` and `-`.
|
|
29
|
+
6. Rewrite the columns:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// 11
|
|
33
|
+
const columns: ColumnDef<TDataKitRow<typeof tableUser>>[] = [
|
|
34
|
+
{ accessorKey: 'name', header: 'Name', meta: { className: 'font-medium' } },
|
|
35
|
+
{ accessorKey: 'role', header: 'Role', cell: ({ row }) => <Badge>{row.original.role}</Badge>, meta: { option: { admin: 'Admin' } } },
|
|
36
|
+
{ id: 'status', header: 'Status', meta: { option: { online: 'Online' } } },
|
|
37
|
+
];
|
|
38
|
+
<DataKit data={data} columns={columns} hidden={['status']} selectable={(user) => user.id !== me} actions={(selection) => …} sizes={[10, 25]} controls={chip} />
|
|
39
|
+
// 12
|
|
40
|
+
<DataKit
|
|
41
|
+
data={data}
|
|
42
|
+
columns={[
|
|
43
|
+
{ id: 'name', header: 'Name', className: 'font-medium' },
|
|
44
|
+
{ id: 'role', header: 'Role', cell: ({ row }) => <Badge>{row.role}</Badge>, filter: { option: { admin: 'Admin' } } },
|
|
45
|
+
{ id: 'status', table: false, filter: { label: 'Status', option: { online: 'Online' } } },
|
|
46
|
+
]}
|
|
47
|
+
selection={{ enabled: ({ row }) => row.id !== me, action: (selection) => … }}
|
|
48
|
+
pagination={{ size: [10, 25] }}
|
|
49
|
+
toolbar={{ control: chip }}
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Columns are typed from `data`, so the `ColumnDef<…>` annotation goes. A column whose `cell` read a computed value (`accessorFn`) only needs its `id` and `cell`.
|
|
54
|
+
7. Your own layouts: `useDataKitTable` now comes from `next-data-kit/ui` and returns plain data: `table.row` (`item.row` is the row) replaces `table.getRowModel().rows` (`row.original`), `table.kit` replaces `table.options.meta.dataKit`, and `columns` is optional. `DataKitTableView` is now `DataKitTable`. Remove `'use no memo'` from your own components.
|
|
55
|
+
8. `kit.set.page(n)` → `kit.set.page.number(n)` and `kit.set.size(n)` → `kit.set.page.size(n)`.
|
|
56
|
+
9. Labels: import `DataKitLabelsProvider` from `next-data-kit/ui`. `filter.all` and `date.pick` are gone; `filter.find`, `date.from`, `date.to`, `date.format` and `pagination.label` are new.
|
|
57
|
+
10. Types: `TDataKitRow` / `TDataKitDataOf` → `TDataKitTableRow` / `TDataKitTableData` (also exported from `next-data-kit`). `data.meta.column[key]` is now `{ sort, filter?: { variant, option?, preset?, hidden } }`.
|
|
58
|
+
|
|
59
|
+
URLs don't change.
|
|
60
|
+
|
|
3
61
|
## Migrating from 10.x to 11.0
|
|
4
62
|
|
|
5
63
|
11.0 declares a table as columns instead of per-filter zod/query pairs, plugs in any data source, and renders it with one `DataKit` component on TanStack Table 8.
|