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.
Files changed (112) hide show
  1. package/MIGRATION.md +75 -0
  2. package/README.md +289 -698
  3. package/dist/chunk-5D747NEB.js +12 -0
  4. package/dist/chunk-5D747NEB.js.map +1 -0
  5. package/dist/index.d.ts +109 -110
  6. package/dist/index.js +109 -205
  7. package/dist/index.js.map +1 -1
  8. package/dist/server/drizzle.d.ts +11 -0
  9. package/dist/server/drizzle.js +39 -0
  10. package/dist/server/drizzle.js.map +1 -0
  11. package/dist/server.d.ts +273 -88
  12. package/dist/server.js +269 -282
  13. package/dist/server.js.map +1 -1
  14. package/dist/source--l-z9HHB.d.ts +60 -0
  15. package/package.json +75 -107
  16. package/registry/r/data-kit.json +74 -0
  17. package/registry/r/registry.json +72 -0
  18. package/dist/action-DCmAhOQa.d.cts +0 -196
  19. package/dist/action-DCmAhOQa.d.ts +0 -196
  20. package/dist/chunk-5TIEIY7M.cjs +0 -393
  21. package/dist/chunk-5TIEIY7M.cjs.map +0 -1
  22. package/dist/chunk-MTJATM72.cjs +0 -2423
  23. package/dist/chunk-MTJATM72.cjs.map +0 -1
  24. package/dist/chunk-O377UO7C.js +0 -2379
  25. package/dist/chunk-O377UO7C.js.map +0 -1
  26. package/dist/chunk-VFSNUXOW.js +0 -382
  27. package/dist/chunk-VFSNUXOW.js.map +0 -1
  28. package/dist/client/components/data-kit-infinity.d.ts +0 -23
  29. package/dist/client/components/data-kit-infinity.d.ts.map +0 -1
  30. package/dist/client/components/data-kit-table.d.ts +0 -34
  31. package/dist/client/components/data-kit-table.d.ts.map +0 -1
  32. package/dist/client/components/data-kit.d.ts +0 -25
  33. package/dist/client/components/data-kit.d.ts.map +0 -1
  34. package/dist/client/components/index.d.ts +0 -4
  35. package/dist/client/components/index.d.ts.map +0 -1
  36. package/dist/client/components/ui/button.d.ts +0 -14
  37. package/dist/client/components/ui/button.d.ts.map +0 -1
  38. package/dist/client/components/ui/checkbox.d.ts +0 -5
  39. package/dist/client/components/ui/checkbox.d.ts.map +0 -1
  40. package/dist/client/components/ui/dropdown-menu.d.ts +0 -28
  41. package/dist/client/components/ui/dropdown-menu.d.ts.map +0 -1
  42. package/dist/client/components/ui/index.d.ts +0 -8
  43. package/dist/client/components/ui/index.d.ts.map +0 -1
  44. package/dist/client/components/ui/pagination.d.ts +0 -14
  45. package/dist/client/components/ui/pagination.d.ts.map +0 -1
  46. package/dist/client/components/ui/popover.d.ts +0 -10
  47. package/dist/client/components/ui/popover.d.ts.map +0 -1
  48. package/dist/client/components/ui/select.d.ts +0 -18
  49. package/dist/client/components/ui/select.d.ts.map +0 -1
  50. package/dist/client/components/ui/table.d.ts +0 -11
  51. package/dist/client/components/ui/table.d.ts.map +0 -1
  52. package/dist/client/context/index.d.ts +0 -22
  53. package/dist/client/context/index.d.ts.map +0 -1
  54. package/dist/client/hooks/index.d.ts +0 -7
  55. package/dist/client/hooks/index.d.ts.map +0 -1
  56. package/dist/client/hooks/useDataKit.d.ts +0 -9
  57. package/dist/client/hooks/useDataKit.d.ts.map +0 -1
  58. package/dist/client/hooks/usePagination.d.ts +0 -18
  59. package/dist/client/hooks/usePagination.d.ts.map +0 -1
  60. package/dist/client/hooks/useSelection.d.ts +0 -13
  61. package/dist/client/hooks/useSelection.d.ts.map +0 -1
  62. package/dist/client/index.d.ts +0 -11
  63. package/dist/client/index.d.ts.map +0 -1
  64. package/dist/client/utils/cn.d.ts +0 -10
  65. package/dist/client/utils/cn.d.ts.map +0 -1
  66. package/dist/client/utils/index.d.ts +0 -60
  67. package/dist/client/utils/index.d.ts.map +0 -1
  68. package/dist/client.cjs +0 -85
  69. package/dist/client.cjs.map +0 -1
  70. package/dist/client.d.cts +0 -62
  71. package/dist/client.d.ts +0 -7
  72. package/dist/client.d.ts.map +0 -1
  73. package/dist/client.js +0 -4
  74. package/dist/client.js.map +0 -1
  75. package/dist/index-DUVfK8q6.d.ts +0 -284
  76. package/dist/index-qXbjvUTB.d.cts +0 -284
  77. package/dist/index.cjs +0 -300
  78. package/dist/index.cjs.map +0 -1
  79. package/dist/index.d.cts +0 -117
  80. package/dist/internal/hooks.cjs +0 -12
  81. package/dist/internal/hooks.cjs.map +0 -1
  82. package/dist/internal/hooks.d.cts +0 -1
  83. package/dist/internal/hooks.d.ts +0 -1
  84. package/dist/internal/hooks.js +0 -3
  85. package/dist/internal/hooks.js.map +0 -1
  86. package/dist/server/utils.d.ts +0 -52
  87. package/dist/server/utils.d.ts.map +0 -1
  88. package/dist/server.cjs +0 -315
  89. package/dist/server.cjs.map +0 -1
  90. package/dist/server.d.cts +0 -99
  91. package/dist/styles.css +0 -2
  92. package/dist/types/client/component.d.ts +0 -129
  93. package/dist/types/client/component.d.ts.map +0 -1
  94. package/dist/types/client/hook.d.ts +0 -116
  95. package/dist/types/client/hook.d.ts.map +0 -1
  96. package/dist/types/client/selectable.d.ts +0 -43
  97. package/dist/types/client/selectable.d.ts.map +0 -1
  98. package/dist/types/index.cjs +0 -4
  99. package/dist/types/index.cjs.map +0 -1
  100. package/dist/types/index.d.cts +0 -291
  101. package/dist/types/index.d.ts +0 -12
  102. package/dist/types/index.d.ts.map +0 -1
  103. package/dist/types/index.js +0 -3
  104. package/dist/types/index.js.map +0 -1
  105. package/dist/types/next-data-kit.d.ts +0 -95
  106. package/dist/types/next-data-kit.d.ts.map +0 -1
  107. package/dist/types/server/action.d.ts +0 -44
  108. package/dist/types/server/action.d.ts.map +0 -1
  109. package/dist/types/server/database/mongo.d.ts +0 -56
  110. package/dist/types/server/database/mongo.d.ts.map +0 -1
  111. package/dist/useDataKit-XFp3_mUc.d.cts +0 -276
  112. 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.