next-data-kit 9.1.0 → 9.3.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/README.md +65 -0
- package/dist/client/components/data-kit-table.d.ts.map +1 -1
- package/dist/client/hooks/useDataKit.d.ts.map +1 -1
- package/dist/client.cjs +2957 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +60 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2913 -7
- package/dist/client.js.map +1 -1
- package/dist/index-CzDzNX62.d.cts +558 -0
- package/dist/index-CzDzNX62.d.ts +558 -0
- package/dist/index.cjs +1367 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -533
- package/dist/index.d.ts +5 -533
- package/dist/index.js +1367 -114
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/client/component.d.ts +12 -0
- package/dist/types/client/component.d.ts.map +1 -1
- package/dist/types/client/hook.d.ts +12 -0
- package/dist/types/client/hook.d.ts.map +1 -1
- package/dist/types/index.d.cts +24 -0
- package/dist/types/index.js +2 -6
- package/dist/types/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/client/components/data-kit-infinity.js +0 -86
- package/dist/client/components/data-kit-infinity.js.map +0 -1
- package/dist/client/components/data-kit-table.js +0 -188
- package/dist/client/components/data-kit-table.js.map +0 -1
- package/dist/client/components/data-kit.js +0 -79
- package/dist/client/components/data-kit.js.map +0 -1
- package/dist/client/components/index.js +0 -4
- package/dist/client/components/index.js.map +0 -1
- package/dist/client/components/ui/button.js +0 -36
- package/dist/client/components/ui/button.js.map +0 -1
- package/dist/client/components/ui/checkbox.js +0 -10
- package/dist/client/components/ui/checkbox.js.map +0 -1
- package/dist/client/components/ui/dropdown-menu.js +0 -52
- package/dist/client/components/ui/dropdown-menu.js.map +0 -1
- package/dist/client/components/ui/index.js +0 -8
- package/dist/client/components/ui/index.js.map +0 -1
- package/dist/client/components/ui/pagination.js +0 -31
- package/dist/client/components/ui/pagination.js.map +0 -1
- package/dist/client/components/ui/popover.js +0 -18
- package/dist/client/components/ui/popover.js.map +0 -1
- package/dist/client/components/ui/select.js +0 -39
- package/dist/client/components/ui/select.js.map +0 -1
- package/dist/client/components/ui/table.js +0 -29
- package/dist/client/components/ui/table.js.map +0 -1
- package/dist/client/context/index.js +0 -28
- package/dist/client/context/index.js.map +0 -1
- package/dist/client/hooks/index.js +0 -7
- package/dist/client/hooks/index.js.map +0 -1
- package/dist/client/hooks/useDataKit.js +0 -261
- package/dist/client/hooks/useDataKit.js.map +0 -1
- package/dist/client/hooks/usePagination.js +0 -51
- package/dist/client/hooks/usePagination.js.map +0 -1
- package/dist/client/hooks/useSelection.js +0 -93
- package/dist/client/hooks/useSelection.js.map +0 -1
- package/dist/client/index.js +0 -15
- package/dist/client/index.js.map +0 -1
- package/dist/client/utils/cn.js +0 -22
- package/dist/client/utils/cn.js.map +0 -1
- package/dist/client/utils/index.js +0 -133
- package/dist/client/utils/index.js.map +0 -1
- package/dist/server/utils.js +0 -117
- package/dist/server/utils.js.map +0 -1
- package/dist/types/client/component.js +0 -7
- package/dist/types/client/component.js.map +0 -1
- package/dist/types/client/hook.js +0 -7
- package/dist/types/client/hook.js.map +0 -1
- package/dist/types/client/selectable.js +0 -7
- package/dist/types/client/selectable.js.map +0 -1
- package/dist/types/next-data-kit.js +0 -7
- package/dist/types/next-data-kit.js.map +0 -1
- package/dist/types/server/action.js +0 -7
- package/dist/types/server/action.js.map +0 -1
- package/dist/types/server/database/mongo.js +0 -7
- package/dist/types/server/database/mongo.js.map +0 -1
package/README.md
CHANGED
|
@@ -59,6 +59,16 @@ You can use the built-in Zod schema to validate inputs before processing:
|
|
|
59
59
|
```typescript
|
|
60
60
|
'use server';
|
|
61
61
|
|
|
62
|
+
## Styling
|
|
63
|
+
Next Data Kit ships with its own Tailwind CSS styles which are **automatically injected** into your application. You do not need to import any CSS files manually.
|
|
64
|
+
|
|
65
|
+
### Prefixing
|
|
66
|
+
To prevent class name conflicts with your application, all Next Data Kit utility classes are prefixed with `ndk:`. For example, instead of `flex`, components use `ndk:flex`.
|
|
67
|
+
|
|
68
|
+
If you need to override styles or use Data Kit's class names in your own custom components that interact with the library's internal state, remember to use the `ndk:` prefix.
|
|
69
|
+
|
|
70
|
+
### Tailwind Configuration (Optional)
|
|
71
|
+
Since styles are injected, you generally don't need to configure your Tailwind setup to be aware of Next Data Kit unless you are building custom components that rely on the library's internal theme variables.
|
|
62
72
|
import { dataKitServerAction, dataKitSchemaZod } from 'next-data-kit/server';
|
|
63
73
|
|
|
64
74
|
export async function fetchUsers(input: unknown) {
|
|
@@ -564,6 +574,50 @@ Full-featured table component with built-in UI.
|
|
|
564
574
|
| `bordered` | `boolean \| 'rounded'` | Border style |
|
|
565
575
|
| `refetchInterval` | `number` | Auto-refresh interval (ms) |
|
|
566
576
|
|
|
577
|
+
**Controller Ref:**
|
|
578
|
+
|
|
579
|
+
The `controller` prop allows external manipulation of the table. Pass a ref and access these methods:
|
|
580
|
+
|
|
581
|
+
```tsx
|
|
582
|
+
import { useRef } from 'react';
|
|
583
|
+
import { DataKitTable } from 'next-data-kit/client';
|
|
584
|
+
import type { TDataKitController } from 'next-data-kit/types';
|
|
585
|
+
|
|
586
|
+
function MyTable() {
|
|
587
|
+
const controllerRef = useRef<TDataKitController<User> | null>(null);
|
|
588
|
+
|
|
589
|
+
const handleAddUser = () => {
|
|
590
|
+
controllerRef.current?.itemPush({ id: '123', name: 'New User' }, 0);
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
const handleUpdateUser = () => {
|
|
594
|
+
// Update by index
|
|
595
|
+
controllerRef.current?.itemUpdate({ index: 0, data: { name: 'Updated Name' } });
|
|
596
|
+
// Or update by id
|
|
597
|
+
controllerRef.current?.itemUpdate({ id: '123', data: { name: 'Updated Name' } });
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const handleDeleteUser = () => {
|
|
601
|
+
// Delete by index
|
|
602
|
+
controllerRef.current?.itemDelete({ index: 0 });
|
|
603
|
+
// Or delete by id
|
|
604
|
+
controllerRef.current?.itemDelete({ id: '123' });
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
return <DataKitTable action={fetchUsers} controller={controllerRef} table={columns} />;
|
|
608
|
+
}
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
Available methods:
|
|
612
|
+
- `itemPush(item, position?)` - Add new item (0 = start, 1 = end)
|
|
613
|
+
- `itemUpdate(props)` - Update item by index or id with partial data
|
|
614
|
+
- `itemDelete(props)` - Delete item by index or id
|
|
615
|
+
- `refetchData()` - Refresh table data from server
|
|
616
|
+
- `deleteBulk(items)` - Delete multiple items
|
|
617
|
+
- `getSelectedItems()` - Get currently selected items
|
|
618
|
+
- `clearSelection()` - Clear all selections
|
|
619
|
+
|
|
620
|
+
|
|
567
621
|
#### `<DataKit>` Component
|
|
568
622
|
|
|
569
623
|
Headless component for custom layouts (grids, cards, etc).
|
|
@@ -650,6 +704,17 @@ Returns:
|
|
|
650
704
|
- `clearFilters()` - Clear all filters
|
|
651
705
|
- `refresh()` - Refresh the table data
|
|
652
706
|
- `reset()` - Reset to initial state
|
|
707
|
+
- `setItems(items)` - Replace all items
|
|
708
|
+
- `setItemAt(index, item)` - Replace item at index
|
|
709
|
+
- `itemUpdate(props)` - Update item by index or id with partial data
|
|
710
|
+
- By index: `itemUpdate({ index: 0, data: { name: 'New Name' } })`
|
|
711
|
+
- By id: `itemUpdate({ id: '123', data: { name: 'New Name' } })`
|
|
712
|
+
- `deleteItemAt(index)` - Delete item at index
|
|
713
|
+
- `itemDelete(props)` - Delete item by index or id
|
|
714
|
+
- By index: `itemDelete({ index: 0 })`
|
|
715
|
+
- By id: `itemDelete({ id: '123' })`
|
|
716
|
+
- `itemPush(item, position)` - Add item (position: 0 = start, 1 = end)
|
|
717
|
+
- `deleteBulk(items)` - Delete multiple items
|
|
653
718
|
|
|
654
719
|
#### `useSelection<T>()`
|
|
655
720
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-kit-table.d.ts","sourceRoot":"","sources":["../../../src/client/components/data-kit-table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,EAyBF,SAAS,EACT,SAAS,EAGb,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACP,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EAEvB,sBAAsB,EAC1B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"data-kit-table.d.ts","sourceRoot":"","sources":["../../../src/client/components/data-kit-table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,EAyBF,SAAS,EACT,SAAS,EAGb,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACP,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EAEvB,sBAAsB,EAC1B,MAAM,aAAa,CAAC;AAufrB,eAAO,MAAM,YAAY,IAnfpB,OAAO,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,EAClG,SAAS,mBACL,QAAQ,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC,KAAK,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;IAC9E,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE;QACR,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACnF,CAAC;IACF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACjC,UAAU,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACjG,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;KAAE,EAAE,CAAC;CAC9C,CAAC;;;CA+dA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDataKit.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useDataKit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAiC,kBAAkB,EAAc,iBAAiB,EAAiB,MAAM,aAAa,CAAC;AAGnI,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,OAAO,QAAQ,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"useDataKit.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useDataKit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAiC,kBAAkB,EAAc,iBAAiB,EAAiB,MAAM,aAAa,CAAC;AAGnI,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,OAAO,QAAQ,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAgUtH,CAAC;AAEF,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
|