next-data-kit 9.9.2 → 11.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 +75 -0
- package/README.md +289 -698
- package/dist/chunk-5D747NEB.js +12 -0
- package/dist/chunk-5D747NEB.js.map +1 -0
- package/dist/index.d.ts +109 -110
- package/dist/index.js +109 -205
- package/dist/index.js.map +1 -1
- package/dist/server/drizzle.d.ts +11 -0
- package/dist/server/drizzle.js +39 -0
- package/dist/server/drizzle.js.map +1 -0
- package/dist/server.d.ts +273 -88
- package/dist/server.js +269 -282
- package/dist/server.js.map +1 -1
- package/dist/source--l-z9HHB.d.ts +60 -0
- package/package.json +75 -107
- package/registry/r/data-kit.json +74 -0
- package/registry/r/registry.json +72 -0
- package/dist/action-DCmAhOQa.d.cts +0 -196
- package/dist/action-DCmAhOQa.d.ts +0 -196
- package/dist/chunk-5TIEIY7M.cjs +0 -393
- package/dist/chunk-5TIEIY7M.cjs.map +0 -1
- package/dist/chunk-MTJATM72.cjs +0 -2423
- package/dist/chunk-MTJATM72.cjs.map +0 -1
- package/dist/chunk-O377UO7C.js +0 -2379
- package/dist/chunk-O377UO7C.js.map +0 -1
- package/dist/chunk-VFSNUXOW.js +0 -382
- package/dist/chunk-VFSNUXOW.js.map +0 -1
- package/dist/client/components/data-kit-infinity.d.ts +0 -23
- package/dist/client/components/data-kit-infinity.d.ts.map +0 -1
- package/dist/client/components/data-kit-table.d.ts +0 -34
- package/dist/client/components/data-kit-table.d.ts.map +0 -1
- package/dist/client/components/data-kit.d.ts +0 -25
- package/dist/client/components/data-kit.d.ts.map +0 -1
- package/dist/client/components/index.d.ts +0 -4
- package/dist/client/components/index.d.ts.map +0 -1
- package/dist/client/components/ui/button.d.ts +0 -14
- package/dist/client/components/ui/button.d.ts.map +0 -1
- package/dist/client/components/ui/checkbox.d.ts +0 -5
- package/dist/client/components/ui/checkbox.d.ts.map +0 -1
- package/dist/client/components/ui/dropdown-menu.d.ts +0 -28
- package/dist/client/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/client/components/ui/index.d.ts +0 -8
- package/dist/client/components/ui/index.d.ts.map +0 -1
- package/dist/client/components/ui/pagination.d.ts +0 -14
- package/dist/client/components/ui/pagination.d.ts.map +0 -1
- package/dist/client/components/ui/popover.d.ts +0 -10
- package/dist/client/components/ui/popover.d.ts.map +0 -1
- package/dist/client/components/ui/select.d.ts +0 -18
- package/dist/client/components/ui/select.d.ts.map +0 -1
- package/dist/client/components/ui/table.d.ts +0 -11
- package/dist/client/components/ui/table.d.ts.map +0 -1
- package/dist/client/context/index.d.ts +0 -22
- package/dist/client/context/index.d.ts.map +0 -1
- package/dist/client/hooks/index.d.ts +0 -7
- package/dist/client/hooks/index.d.ts.map +0 -1
- package/dist/client/hooks/useDataKit.d.ts +0 -9
- package/dist/client/hooks/useDataKit.d.ts.map +0 -1
- package/dist/client/hooks/usePagination.d.ts +0 -18
- package/dist/client/hooks/usePagination.d.ts.map +0 -1
- package/dist/client/hooks/useSelection.d.ts +0 -13
- package/dist/client/hooks/useSelection.d.ts.map +0 -1
- package/dist/client/index.d.ts +0 -11
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/utils/cn.d.ts +0 -10
- package/dist/client/utils/cn.d.ts.map +0 -1
- package/dist/client/utils/index.d.ts +0 -60
- package/dist/client/utils/index.d.ts.map +0 -1
- package/dist/client.cjs +0 -85
- package/dist/client.cjs.map +0 -1
- package/dist/client.d.cts +0 -62
- package/dist/client.d.ts +0 -7
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -4
- package/dist/client.js.map +0 -1
- package/dist/index-DUVfK8q6.d.ts +0 -284
- package/dist/index-qXbjvUTB.d.cts +0 -284
- package/dist/index.cjs +0 -300
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -117
- package/dist/internal/hooks.cjs +0 -12
- package/dist/internal/hooks.cjs.map +0 -1
- package/dist/internal/hooks.d.cts +0 -1
- package/dist/internal/hooks.d.ts +0 -1
- package/dist/internal/hooks.js +0 -3
- package/dist/internal/hooks.js.map +0 -1
- package/dist/server/utils.d.ts +0 -52
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server.cjs +0 -315
- package/dist/server.cjs.map +0 -1
- package/dist/server.d.cts +0 -99
- package/dist/styles.css +0 -2
- package/dist/types/client/component.d.ts +0 -129
- package/dist/types/client/component.d.ts.map +0 -1
- package/dist/types/client/hook.d.ts +0 -116
- package/dist/types/client/hook.d.ts.map +0 -1
- package/dist/types/client/selectable.d.ts +0 -43
- package/dist/types/client/selectable.d.ts.map +0 -1
- package/dist/types/index.cjs +0 -4
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -291
- package/dist/types/index.d.ts +0 -12
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/types/next-data-kit.d.ts +0 -95
- package/dist/types/next-data-kit.d.ts.map +0 -1
- package/dist/types/server/action.d.ts +0 -44
- package/dist/types/server/action.d.ts.map +0 -1
- package/dist/types/server/database/mongo.d.ts +0 -56
- package/dist/types/server/database/mongo.d.ts.map +0 -1
- package/dist/useDataKit-XFp3_mUc.d.cts +0 -276
- package/dist/useDataKit-XFp3_mUc.d.ts +0 -276
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Migrating
|
|
2
|
+
|
|
3
|
+
## Migrating from 10.x to 11.0
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
### Steps
|
|
8
|
+
|
|
9
|
+
1. `npm install next-data-kit@11` (needs zod 4, React 19).
|
|
10
|
+
2. Refresh the components: `npx shadcn add @ndk/data-kit`, overwriting only `components/ui/ndk/data-kit/`. Delete the old `root.tsx`, `table.tsx`, `filter.tsx` and `selection.tsx` there.
|
|
11
|
+
3. Rewrite each `dataKitDefine` as a `dataKit`:
|
|
12
|
+
- `adapter: adapterMongoose({ model })` → `source: sourceMongoose({ model })`; a custom adapter function → `sourceDefine({ ...sourceMongooseQuery, list })` or `{ list }`, which gets `{ filter, sort, page: { offset, limit, count } }` and returns `{ rows, total }`.
|
|
13
|
+
- Each `filter: { key: { schema, query } }` → `column: { key: { filter: variant, option? } }`. Keep `query` on the column only when the variant's own condition isn't the one you need; use `filterCustom({ schema, query })` for a filter with no toolbar control.
|
|
14
|
+
- `filterSearch({ field })` → `search: [...]` (add columns for those fields, with `field` when the database path differs).
|
|
15
|
+
- `sort: { field, default }` → `sort: true` on each sortable column, and `sort: 'field.desc'` at the top.
|
|
16
|
+
- `page.size` and `scope` stay; `item: (props) => …props.document…` → `row: (props) => …props.row…`.
|
|
17
|
+
4. In pages, `kit.query({ input: kit.parse({ searchParams }) })` → `table.query({ searchParams })`. Server actions keep `{ input }`; validate with `table.schema`.
|
|
18
|
+
5. In views, replace `DataKitRoot` + parts with `<DataKit data={data} columns={…} />`. Columns become TanStack `ColumnDef`s (`head` → `header`, `cell: ({ item })` → `cell: ({ row }) => row.original…`, `className` → `meta: { className }`), and the column `id` / `accessorKey` must match the server column key for sorting and filter labels. `DataKitSelection` → `actions`; per-part labels → one `DataKitLabelsProvider`.
|
|
19
|
+
6. URLs change: filter values are variant-encoded (`role=a,b`, `age=18-30`, `createdAt=7d`) and sort is `column.direction`. Old links fall back to the defaults.
|
|
20
|
+
|
|
21
|
+
### Renames
|
|
22
|
+
|
|
23
|
+
| 10.x | 11.0 |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `dataKitDefine` | `dataKit` |
|
|
26
|
+
| `adapterMongoose`, `adapterMemory` | `sourceMongoose`, `sourceMemory` |
|
|
27
|
+
| `filterSearch` | `search` option |
|
|
28
|
+
| `kit.parse` | removed (`query({ searchParams })`) |
|
|
29
|
+
| `items`, `item()` | `rows`, `row()` |
|
|
30
|
+
| `TDataKitResult` | `TDataKitData` (+ `TDataKitRow`, `TDataKitDataOf`) |
|
|
31
|
+
| `DataKitRoot`, `DataKitTable`, `DataKitFilter`, `DataKitSelection`, `useDataKitRoot` | `DataKit`, `useDataKitTable`, `DataKitToolbar`, `DataKitTableView`, `DataKitPagination`, `DataKitInfinite`, `DataKitLabelsProvider` |
|
|
32
|
+
|
|
33
|
+
## Migrating from 9.x to 10.0
|
|
34
|
+
|
|
35
|
+
10.0 is a rewrite. Tables are declared once on the server with only the filters and sorts you allow; the UI moves into your project as a shadcn registry item; the package ships no CSS and no Radix.
|
|
36
|
+
|
|
37
|
+
### What changes
|
|
38
|
+
|
|
39
|
+
| 9.x | 10.0 |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `dataKitServerAction({ model, input, item, filterCustom, … })` | `dataKitDefine({ adapter, filter, sort, page, item })` + `kit.parse` / `kit.query` |
|
|
42
|
+
| `model: UserModel` | `adapter: adapterMongoose({ model: UserModel })` (`.lean()` by default, `hydrate: true` for documents) |
|
|
43
|
+
| `adapter: adapterMemory(items)` | `adapter: adapterMemory({ items })` |
|
|
44
|
+
| `filterCustom: { role: (value) => … }` | `filter: { role: { schema: z.enum([...]), query: (props) => … } }` |
|
|
45
|
+
| `createSearchFilter(['name'])` | `filterSearch({ field: ['name'] })` |
|
|
46
|
+
| client `filters[].configuration` / `filterConfig` | removed: the client can no longer choose a database field |
|
|
47
|
+
| `queryAllowed`, `filterAllowed`, `sortAllowed` | removed: only declared keys exist |
|
|
48
|
+
| `input.query` (exact matches from the client) | `scope: (props) => …` from server-side `context` |
|
|
49
|
+
| `sorts`, column `sortable: { path }`, legacy `sort` | `sort: { field, default }`, `DataKitTable` column `sort` |
|
|
50
|
+
| sort value `1` / `-1` | `direction: 'asc' \| 'desc'` |
|
|
51
|
+
| `limit: { default }`, `maxLimit` | `page: { size: { default, max } }` |
|
|
52
|
+
| result `{ type: 'ITEMS', items, documentTotal }` | `{ items, total, page: { number, size }, sort, filter }` |
|
|
53
|
+
| `DataKitTable` (props for everything) | `DataKitRoot` + `DataKitTable` / `DataKitFilter` / `DataKitPagination` / `DataKitSelection` |
|
|
54
|
+
| `DataKit` (custom layout) | `DataKitRoot` with `children={(kit) => …}` or `useDataKitRoot()` |
|
|
55
|
+
| `DataKitInfinity` | `DataKitRoot append source={{ fetch }}` + `DataKitInfinite` |
|
|
56
|
+
| `selectable: { enabled, actions }` | `DataKitTable selectable` + `DataKitSelection` |
|
|
57
|
+
| `controller` ref (`itemPush`, `itemUpdate`, `itemDelete`, `refetchData`) | `kit.item.push / update / remove`, `kit.refresh()` |
|
|
58
|
+
| `memory: 'search-params'` | default (URL + navigation), or `source={{ fetch, url: true }}` |
|
|
59
|
+
| `memory: 'memory'` | `source={{ fetch }}` |
|
|
60
|
+
| `refetchInterval` | `refetch={{ intervalMs }}` |
|
|
61
|
+
| per-row `state` | plain React state in your copied `DataKitTable` |
|
|
62
|
+
| `useSelection`, `usePagination` | `kit.selection`, `kit.page.count` |
|
|
63
|
+
| `DataKitProvider`, `createDataKitContext` | removed |
|
|
64
|
+
| bundled styles (`ndk:` classes) | removed: your shadcn components and theme |
|
|
65
|
+
| peers: Radix, `cva`, `lucide-react`, zod 3 | peers: `react` 19, `react-dom` 19, `zod` 4, optional `mongoose` |
|
|
66
|
+
| CommonJS build | ESM only |
|
|
67
|
+
|
|
68
|
+
### Steps
|
|
69
|
+
|
|
70
|
+
1. `npm install next-data-kit@10` and remove `@radix-ui/*`, `class-variance-authority` and `react-intersection-observer` if only next-data-kit used them.
|
|
71
|
+
2. Add `"@ndk": "https://unpkg.com/next-data-kit@10/registry/r/{name}.json"` to `registries` in `components.json`, then `npx shadcn add @ndk/data-kit`.
|
|
72
|
+
3. Replace each `dataKitServerAction` with a `dataKitDefine` next to the page that uses it, and give every filter a zod `schema`.
|
|
73
|
+
4. In the page, `kit.parse({ searchParams })` then `kit.query({ input, context })`, and pass the result to the view as `initial`.
|
|
74
|
+
5. Replace `DataKitTable` / `DataKit` / `DataKitInfinity` with `DataKitRoot` and the parts.
|
|
75
|
+
6. Keep a server action only for `source.fetch` (infinite scroll), and check auth in it.
|