next-data-kit 8.3.1 → 9.0.1
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 +11 -1
- package/dist/client/components/data-kit-table.d.ts.map +1 -1
- package/dist/client/components/data-kit-table.js +7 -6
- package/dist/client/components/data-kit-table.js.map +1 -1
- package/dist/client/components/data-kit.d.ts.map +1 -1
- package/dist/client/components/data-kit.js +1 -1
- package/dist/client/components/data-kit.js.map +1 -1
- package/dist/client/components/ui/switch.js +1 -1
- package/dist/client/components/ui/switch.js.map +1 -1
- package/dist/client/components/ui/table.js +1 -1
- package/dist/client/components/ui/table.js.map +1 -1
- package/dist/index.cjs +83 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +84 -78
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -0
- package/dist/types/client/component.d.ts +4 -0
- package/dist/types/client/component.d.ts.map +1 -1
- package/dist/types/index.d.cts +4 -0
- package/package.json +7 -3
package/dist/index.d.cts
CHANGED
|
@@ -422,7 +422,11 @@ type TDataKitFilterItem = TDataKitFilterItemText | TDataKitFilterItemSelect | TD
|
|
|
422
422
|
* Bulk action definition for selectable tables
|
|
423
423
|
*/
|
|
424
424
|
type TDataKitBulkAction<TItem> = {
|
|
425
|
+
type: 'SEPARATOR';
|
|
426
|
+
} | {
|
|
427
|
+
type?: 'MENU';
|
|
425
428
|
name: string;
|
|
429
|
+
icon?: React.ReactNode;
|
|
426
430
|
function: (selectedItems: TItem[]) => Promise<[boolean, {
|
|
427
431
|
deselectAll?: boolean;
|
|
428
432
|
updatedItems?: TItem[];
|
package/dist/index.d.ts
CHANGED
|
@@ -422,7 +422,11 @@ type TDataKitFilterItem = TDataKitFilterItemText | TDataKitFilterItemSelect | TD
|
|
|
422
422
|
* Bulk action definition for selectable tables
|
|
423
423
|
*/
|
|
424
424
|
type TDataKitBulkAction<TItem> = {
|
|
425
|
+
type: 'SEPARATOR';
|
|
426
|
+
} | {
|
|
427
|
+
type?: 'MENU';
|
|
425
428
|
name: string;
|
|
429
|
+
icon?: React.ReactNode;
|
|
426
430
|
function: (selectedItems: TItem[]) => Promise<[boolean, {
|
|
427
431
|
deselectAll?: boolean;
|
|
428
432
|
updatedItems?: TItem[];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as React2 from 'react';
|
|
3
3
|
import React2__default, { createContext, useRef, useState, useCallback, useEffect, useContext, useMemo } from 'react';
|
|
4
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { Filter, Loader2, MoreHorizontal, ArrowUp, ArrowDown, ChevronLeft, ChevronRight, ChevronDownIcon, CheckIcon, ChevronUpIcon } from 'lucide-react';
|
|
6
6
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
7
7
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
@@ -784,7 +784,7 @@ function TableRow({ className, ...props }) {
|
|
|
784
784
|
{
|
|
785
785
|
"data-slot": "table-row",
|
|
786
786
|
className: cn(
|
|
787
|
-
"hover:bg-gray-50 dark:hover:bg-gray-900
|
|
787
|
+
"hover:bg-gray-50 dark:hover:bg-gray-900 data-[state=selected]:bg-gray-50 dark:data-[state=selected]:bg-gray-900 border-b border-gray-100 dark:border-gray-800 transition-colors",
|
|
788
788
|
className
|
|
789
789
|
),
|
|
790
790
|
...props
|
|
@@ -923,6 +923,19 @@ function DropdownMenuItem({
|
|
|
923
923
|
}
|
|
924
924
|
);
|
|
925
925
|
}
|
|
926
|
+
function DropdownMenuSeparator({
|
|
927
|
+
className,
|
|
928
|
+
...props
|
|
929
|
+
}) {
|
|
930
|
+
return /* @__PURE__ */ jsx(
|
|
931
|
+
DropdownMenuPrimitive.Separator,
|
|
932
|
+
{
|
|
933
|
+
"data-slot": "dropdown-menu-separator",
|
|
934
|
+
className: cn("bg-gray-100 dark:bg-gray-900 -mx-1 my-1 h-px", className),
|
|
935
|
+
...props
|
|
936
|
+
}
|
|
937
|
+
);
|
|
938
|
+
}
|
|
926
939
|
function Switch({
|
|
927
940
|
className,
|
|
928
941
|
...props
|
|
@@ -932,7 +945,7 @@ function Switch({
|
|
|
932
945
|
{
|
|
933
946
|
"data-slot": "switch",
|
|
934
947
|
className: cn(
|
|
935
|
-
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-
|
|
948
|
+
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-zinc-200 focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-zinc-700 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
936
949
|
className
|
|
937
950
|
),
|
|
938
951
|
...props,
|
|
@@ -1313,12 +1326,13 @@ var DataKitRoot = (props) => {
|
|
|
1313
1326
|
dataKit.actions.setSort(path, nextValue);
|
|
1314
1327
|
}, [dataKit.sorts, dataKit.actions]);
|
|
1315
1328
|
const handleSelectionAction = useCallback(async (actionKey) => {
|
|
1316
|
-
|
|
1329
|
+
const action2 = selectable?.actions?.[actionKey];
|
|
1330
|
+
if (!action2 || action2.type === "SEPARATOR" || actionLoading) return;
|
|
1317
1331
|
setActionLoading(actionKey);
|
|
1318
1332
|
setActionsMenuOpen(false);
|
|
1319
1333
|
try {
|
|
1320
1334
|
const selectedItems = dataKit.items.filter((item) => selection.isSelected(item.id));
|
|
1321
|
-
const result = await
|
|
1335
|
+
const result = await action2.function(selectedItems);
|
|
1322
1336
|
if (result[0]) {
|
|
1323
1337
|
const data = result[1];
|
|
1324
1338
|
if (data.deselectAll) selection.deselectAll();
|
|
@@ -1393,68 +1407,55 @@ var DataKitRoot = (props) => {
|
|
|
1393
1407
|
selection.deselectAll();
|
|
1394
1408
|
}, [dataKit.items.length]);
|
|
1395
1409
|
return /* @__PURE__ */ jsxs("div", { ref: tableRef, className: `space-y-3 ${className ?? ""}`, children: [
|
|
1396
|
-
/* @__PURE__ */
|
|
1397
|
-
/* @__PURE__ */ jsx(
|
|
1398
|
-
/* @__PURE__ */ jsx(
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
/* @__PURE__ */
|
|
1403
|
-
/* @__PURE__ */ jsx("
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1410
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: filters.length > 0 && /* @__PURE__ */ jsxs(Popover, { open: isFilterOpen, onOpenChange: setIsFilterOpen, children: [
|
|
1411
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
|
|
1412
|
+
/* @__PURE__ */ jsx(Filter, { className: "mr-1.5 size-4" }),
|
|
1413
|
+
"Filters"
|
|
1414
|
+
] }) }),
|
|
1415
|
+
/* @__PURE__ */ jsxs(PopoverContent, { align: "start", className: "w-80", container: overlayContainer, children: [
|
|
1416
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-3", children: filters.map((f) => /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
|
|
1417
|
+
/* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: f.label }),
|
|
1418
|
+
f.type === "TEXT" && /* @__PURE__ */ jsx(
|
|
1419
|
+
"input",
|
|
1420
|
+
{
|
|
1421
|
+
type: "text",
|
|
1422
|
+
className: "h-9 w-full rounded-md border bg-transparent px-3 text-sm outline-none focus:ring-2 focus:ring-ring",
|
|
1423
|
+
placeholder: f.placeholder,
|
|
1424
|
+
value: dataKit.filter[f.id] ?? "",
|
|
1425
|
+
onChange: (e) => dataKit.actions.setFilter(f.id, e.target.value)
|
|
1426
|
+
}
|
|
1427
|
+
),
|
|
1428
|
+
f.type === "SELECT" && /* @__PURE__ */ jsxs(
|
|
1429
|
+
Select,
|
|
1430
|
+
{
|
|
1431
|
+
value: String(dataKit.filter[f.id] || "__all__"),
|
|
1432
|
+
onValueChange: (v) => dataKit.actions.setFilter(f.id, v === "__all__" ? "" : v),
|
|
1433
|
+
children: [
|
|
1434
|
+
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1435
|
+
/* @__PURE__ */ jsxs(SelectContent, { container: overlayContainer, children: [
|
|
1436
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "__all__", children: "All" }),
|
|
1437
|
+
f.dataset?.map((d) => /* @__PURE__ */ jsx(SelectItem, { value: d.id, children: d.label }, d.id))
|
|
1438
|
+
] })
|
|
1439
|
+
]
|
|
1440
|
+
}
|
|
1441
|
+
),
|
|
1442
|
+
f.type === "BOOLEAN" && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1443
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: f.placeholder ?? "Enable" }),
|
|
1444
|
+
/* @__PURE__ */ jsx(
|
|
1445
|
+
Switch,
|
|
1417
1446
|
{
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
children: [
|
|
1421
|
-
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1422
|
-
/* @__PURE__ */ jsxs(SelectContent, { container: overlayContainer, children: [
|
|
1423
|
-
/* @__PURE__ */ jsx(SelectItem, { value: "__all__", children: "All" }),
|
|
1424
|
-
f.dataset?.map((d) => /* @__PURE__ */ jsx(SelectItem, { value: d.id, children: d.label }, d.id))
|
|
1425
|
-
] })
|
|
1426
|
-
]
|
|
1447
|
+
checked: Boolean(dataKit.filter[f.id]),
|
|
1448
|
+
onCheckedChange: (c) => dataKit.actions.setFilter(f.id, c)
|
|
1427
1449
|
}
|
|
1428
|
-
)
|
|
1429
|
-
f.type === "BOOLEAN" && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1430
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: f.placeholder ?? "Enable" }),
|
|
1431
|
-
/* @__PURE__ */ jsx(
|
|
1432
|
-
Switch,
|
|
1433
|
-
{
|
|
1434
|
-
checked: Boolean(dataKit.filter[f.id]),
|
|
1435
|
-
onCheckedChange: (c) => dataKit.actions.setFilter(f.id, c)
|
|
1436
|
-
}
|
|
1437
|
-
)
|
|
1438
|
-
] })
|
|
1439
|
-
] }, f.id)) }),
|
|
1440
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-4 flex justify-between border-t pt-3", children: [
|
|
1441
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: handleResetFilters, children: "Reset" }),
|
|
1442
|
-
/* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => setIsFilterOpen(false), children: "Done" })
|
|
1450
|
+
)
|
|
1443
1451
|
] })
|
|
1444
|
-
] })
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
dataKit.items.length,
|
|
1449
|
-
" of ",
|
|
1450
|
-
dataKit.total
|
|
1451
|
-
] }),
|
|
1452
|
-
/* @__PURE__ */ jsxs(Select, { value: String(dataKit.limit), onValueChange: (v) => dataKit.actions.setLimit(Number(v)), disabled: dataKit.state.isLoading, children: [
|
|
1453
|
-
/* @__PURE__ */ jsx(SelectTrigger, { className: "w-16", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1454
|
-
/* @__PURE__ */ jsx(SelectContent, { container: overlayContainer, children: limitOptions.map((v) => /* @__PURE__ */ jsx(SelectItem, { value: String(v), children: v }, v)) })
|
|
1452
|
+
] }, f.id)) }),
|
|
1453
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-4 flex justify-between border-t pt-3", children: [
|
|
1454
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: handleResetFilters, children: "Reset" }),
|
|
1455
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => setIsFilterOpen(false), children: "Done" })
|
|
1455
1456
|
] })
|
|
1456
1457
|
] })
|
|
1457
|
-
] }),
|
|
1458
|
+
] }) }) }),
|
|
1458
1459
|
/* @__PURE__ */ jsx("div", { className: `overflow-hidden border border-gray-200 dark:border-gray-800 ${bordered === "rounded" ? "rounded-lg" : bordered ? "" : "rounded-lg"}`, children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
1459
1460
|
/* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1460
1461
|
selectable?.enabled && /* @__PURE__ */ jsx(TableHead, { className: "w-12", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -1476,7 +1477,12 @@ var DataKitRoot = (props) => {
|
|
|
1476
1477
|
children: actionLoading ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4" })
|
|
1477
1478
|
}
|
|
1478
1479
|
) }),
|
|
1479
|
-
/* @__PURE__ */ jsx(DropdownMenuContent, { align: "start", container: overlayContainer, children: Object.entries(selectable.actions).map(
|
|
1480
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { align: "start", container: overlayContainer, children: Object.entries(selectable.actions).map(
|
|
1481
|
+
([key, action2]) => action2.type === "SEPARATOR" ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, key) : /* @__PURE__ */ jsx(DropdownMenuItem, { disabled: !!actionLoading, onSelect: () => handleSelectionAction(key), children: actionLoading === key ? "Working\u2026" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1482
|
+
action2.icon,
|
|
1483
|
+
action2.name
|
|
1484
|
+
] }) }, key)
|
|
1485
|
+
) })
|
|
1480
1486
|
] })
|
|
1481
1487
|
] }) }),
|
|
1482
1488
|
columns.map((col, idx) => /* @__PURE__ */ jsx(React2__default.Fragment, { children: col.sortable ? /* @__PURE__ */ jsx(TableHead, { ...React2__default.isValidElement(col.head) ? col.head.props : {}, children: /* @__PURE__ */ jsxs(
|
|
@@ -1484,7 +1490,7 @@ var DataKitRoot = (props) => {
|
|
|
1484
1490
|
{
|
|
1485
1491
|
variant: "ghost",
|
|
1486
1492
|
size: "sm",
|
|
1487
|
-
className: "-ml-
|
|
1493
|
+
className: "-ml-4 h-auto py-0",
|
|
1488
1494
|
onClick: () => handleSort(col.sortable.path),
|
|
1489
1495
|
children: [
|
|
1490
1496
|
React2__default.isValidElement(col.head) ? col.head.props.children : col.head,
|
|
@@ -1521,8 +1527,12 @@ var DataKitRoot = (props) => {
|
|
|
1521
1527
|
}) })
|
|
1522
1528
|
] }) }),
|
|
1523
1529
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 justify-between", children: [
|
|
1524
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1525
|
-
/* @__PURE__ */ jsxs(
|
|
1530
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1531
|
+
/* @__PURE__ */ jsxs(Select, { value: String(dataKit.limit), onValueChange: (v) => dataKit.actions.setLimit(Number(v)), disabled: dataKit.state.isLoading, children: [
|
|
1532
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "w-16", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1533
|
+
/* @__PURE__ */ jsx(SelectContent, { container: overlayContainer, children: limitOptions.map((v) => /* @__PURE__ */ jsx(SelectItem, { value: String(v), children: v }, v)) })
|
|
1534
|
+
] }),
|
|
1535
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground whitespace-nowrap", children: [
|
|
1526
1536
|
"Page ",
|
|
1527
1537
|
dataKit.page,
|
|
1528
1538
|
" of ",
|
|
@@ -1533,8 +1543,7 @@ var DataKitRoot = (props) => {
|
|
|
1533
1543
|
" selected"
|
|
1534
1544
|
] })
|
|
1535
1545
|
] }),
|
|
1536
|
-
/* @__PURE__ */ jsx("div", { className: "flex-1"
|
|
1537
|
-
/* @__PURE__ */ jsx("div", { className: "flex justify-end w-full", children: paginationType === "SIMPLE" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
1546
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: paginationType === "SIMPLE" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
1538
1547
|
/* @__PURE__ */ jsx(
|
|
1539
1548
|
Button,
|
|
1540
1549
|
{
|
|
@@ -1714,16 +1723,13 @@ var DataKitInner = (props, ref) => {
|
|
|
1714
1723
|
]
|
|
1715
1724
|
}
|
|
1716
1725
|
),
|
|
1717
|
-
f.type === "BOOLEAN" && /* @__PURE__ */
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
}
|
|
1725
|
-
)
|
|
1726
|
-
] })
|
|
1726
|
+
f.type === "BOOLEAN" && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsx(
|
|
1727
|
+
Switch,
|
|
1728
|
+
{
|
|
1729
|
+
checked: Boolean(dataKit.filter[f.id]),
|
|
1730
|
+
onCheckedChange: (c) => dataKit.actions.setFilter(f.id, c)
|
|
1731
|
+
}
|
|
1732
|
+
) })
|
|
1727
1733
|
] }, f.id)) }),
|
|
1728
1734
|
/* @__PURE__ */ jsxs("div", { className: "mt-4 flex justify-between border-t pt-3", children: [
|
|
1729
1735
|
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: handleResetFilters, children: "Reset" }),
|