@krak-stack/registry 0.1.29 → 0.1.31

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.
@@ -1,14 +1,14 @@
1
1
  // ../../src/components/ui/data-table.tsx
2
2
  import { useAtom, useAtomSet } from "@effect/atom-react";
3
3
  import { BrowserKeyValueStore } from "@effect/platform-browser";
4
- import { Schema } from "effect";
4
+ import { DateTime, Option, Schema } from "effect";
5
5
  import { AsyncResult, Atom } from "effect/unstable/reactivity";
6
6
  import {
7
7
  ArrowDown,
8
8
  ArrowUp,
9
9
  ChevronDown,
10
10
  ChevronRight as ChevronRight2,
11
- ChevronsUpDown as ChevronsUpDown2,
11
+ ChevronsUpDown,
12
12
  Download,
13
13
  EyeOff,
14
14
  FileJson,
@@ -16,20 +16,22 @@ import {
16
16
  GripVertical,
17
17
  LayoutGrid,
18
18
  MoreHorizontal,
19
+ Plus,
19
20
  RefreshCw,
20
21
  Rows3,
21
22
  Search,
22
23
  Settings2,
23
- X as X2
24
+ Trash2,
25
+ X
24
26
  } from "lucide-react";
25
27
  import {
26
28
  createContext,
27
29
  isValidElement,
28
- useCallback as useCallback2,
30
+ useCallback,
29
31
  useContext,
30
32
  useLayoutEffect,
31
33
  useMemo,
32
- useRef as useRef2,
34
+ useRef,
33
35
  useState
34
36
  } from "react";
35
37
  import { createPortal } from "react-dom";
@@ -1254,48 +1256,9 @@ function Pagination({
1254
1256
  });
1255
1257
  }
1256
1258
 
1257
- // ../../src/components/ui/popover.tsx
1258
- import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
1259
- import { jsx as jsx11 } from "react/jsx-runtime";
1260
- function Popover({ ...props }) {
1261
- return /* @__PURE__ */ jsx11(PopoverPrimitive.Root, {
1262
- "data-slot": "popover",
1263
- ...props
1264
- });
1265
- }
1266
- function PopoverTrigger({ ...props }) {
1267
- return /* @__PURE__ */ jsx11(PopoverPrimitive.Trigger, {
1268
- "data-slot": "popover-trigger",
1269
- ...props
1270
- });
1271
- }
1272
- function PopoverContent({
1273
- className,
1274
- align = "center",
1275
- alignOffset = 0,
1276
- side = "bottom",
1277
- sideOffset = 4,
1278
- ...props
1279
- }) {
1280
- return /* @__PURE__ */ jsx11(PopoverPrimitive.Portal, {
1281
- children: /* @__PURE__ */ jsx11(PopoverPrimitive.Positioner, {
1282
- align,
1283
- alignOffset,
1284
- side,
1285
- sideOffset,
1286
- className: "isolate z-50",
1287
- children: /* @__PURE__ */ jsx11(PopoverPrimitive.Popup, {
1288
- "data-slot": "popover-content",
1289
- className: cn("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
1290
- ...props
1291
- })
1292
- })
1293
- });
1294
- }
1295
-
1296
1259
  // ../../src/components/ui/scroll-area.tsx
1297
1260
  import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
1298
- import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
1261
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1299
1262
  function ScrollArea({
1300
1263
  className,
1301
1264
  children,
@@ -1306,13 +1269,13 @@ function ScrollArea({
1306
1269
  className: cn("relative", className),
1307
1270
  ...props,
1308
1271
  children: [
1309
- /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Viewport, {
1272
+ /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Viewport, {
1310
1273
  "data-slot": "scroll-area-viewport",
1311
1274
  className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
1312
1275
  children
1313
1276
  }),
1314
- /* @__PURE__ */ jsx12(ScrollBar, {}),
1315
- /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Corner, {})
1277
+ /* @__PURE__ */ jsx11(ScrollBar, {}),
1278
+ /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Corner, {})
1316
1279
  ]
1317
1280
  });
1318
1281
  }
@@ -1321,13 +1284,13 @@ function ScrollBar({
1321
1284
  orientation = "vertical",
1322
1285
  ...props
1323
1286
  }) {
1324
- return /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Scrollbar, {
1287
+ return /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Scrollbar, {
1325
1288
  "data-slot": "scroll-area-scrollbar",
1326
1289
  "data-orientation": orientation,
1327
1290
  orientation,
1328
1291
  className: cn("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent", className),
1329
1292
  ...props,
1330
- children: /* @__PURE__ */ jsx12(ScrollAreaPrimitive.Thumb, {
1293
+ children: /* @__PURE__ */ jsx11(ScrollAreaPrimitive.Thumb, {
1331
1294
  "data-slot": "scroll-area-thumb",
1332
1295
  className: "bg-border relative flex-1 rounded-full"
1333
1296
  })
@@ -1335,12 +1298,12 @@ function ScrollBar({
1335
1298
  }
1336
1299
 
1337
1300
  // ../../src/components/ui/table.tsx
1338
- import { jsx as jsx13 } from "react/jsx-runtime";
1301
+ import { jsx as jsx12 } from "react/jsx-runtime";
1339
1302
  function Table({ className, ...props }) {
1340
- return /* @__PURE__ */ jsx13("div", {
1303
+ return /* @__PURE__ */ jsx12("div", {
1341
1304
  "data-slot": "table-container",
1342
1305
  className: "relative w-full overflow-x-auto",
1343
- children: /* @__PURE__ */ jsx13("table", {
1306
+ children: /* @__PURE__ */ jsx12("table", {
1344
1307
  "data-slot": "table",
1345
1308
  className: cn("w-full caption-bottom text-sm", className),
1346
1309
  ...props
@@ -1348,35 +1311,35 @@ function Table({ className, ...props }) {
1348
1311
  });
1349
1312
  }
1350
1313
  function TableHeader({ className, ...props }) {
1351
- return /* @__PURE__ */ jsx13("thead", {
1314
+ return /* @__PURE__ */ jsx12("thead", {
1352
1315
  "data-slot": "table-header",
1353
1316
  className: cn("[&_tr]:border-b", className),
1354
1317
  ...props
1355
1318
  });
1356
1319
  }
1357
1320
  function TableBody({ className, ...props }) {
1358
- return /* @__PURE__ */ jsx13("tbody", {
1321
+ return /* @__PURE__ */ jsx12("tbody", {
1359
1322
  "data-slot": "table-body",
1360
1323
  className: cn("[&_tr:last-child]:border-0", className),
1361
1324
  ...props
1362
1325
  });
1363
1326
  }
1364
1327
  function TableRow({ className, ...props }) {
1365
- return /* @__PURE__ */ jsx13("tr", {
1328
+ return /* @__PURE__ */ jsx12("tr", {
1366
1329
  "data-slot": "table-row",
1367
1330
  className: cn("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted", className),
1368
1331
  ...props
1369
1332
  });
1370
1333
  }
1371
1334
  function TableHead({ className, ...props }) {
1372
- return /* @__PURE__ */ jsx13("th", {
1335
+ return /* @__PURE__ */ jsx12("th", {
1373
1336
  "data-slot": "table-head",
1374
1337
  className: cn("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0", className),
1375
1338
  ...props
1376
1339
  });
1377
1340
  }
1378
1341
  function TableCell({ className, ...props }) {
1379
- return /* @__PURE__ */ jsx13("td", {
1342
+ return /* @__PURE__ */ jsx12("td", {
1380
1343
  "data-slot": "table-cell",
1381
1344
  className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0", className),
1382
1345
  ...props
@@ -1385,26 +1348,26 @@ function TableCell({ className, ...props }) {
1385
1348
 
1386
1349
  // ../../src/components/ui/tooltip.tsx
1387
1350
  import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
1388
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1351
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1389
1352
  "use client";
1390
1353
  function TooltipProvider({
1391
1354
  delay = 0,
1392
1355
  ...props
1393
1356
  }) {
1394
- return /* @__PURE__ */ jsx14(TooltipPrimitive.Provider, {
1357
+ return /* @__PURE__ */ jsx13(TooltipPrimitive.Provider, {
1395
1358
  "data-slot": "tooltip-provider",
1396
1359
  delay,
1397
1360
  ...props
1398
1361
  });
1399
1362
  }
1400
1363
  function Tooltip({ ...props }) {
1401
- return /* @__PURE__ */ jsx14(TooltipPrimitive.Root, {
1364
+ return /* @__PURE__ */ jsx13(TooltipPrimitive.Root, {
1402
1365
  "data-slot": "tooltip",
1403
1366
  ...props
1404
1367
  });
1405
1368
  }
1406
1369
  function TooltipTrigger({ ...props }) {
1407
- return /* @__PURE__ */ jsx14(TooltipPrimitive.Trigger, {
1370
+ return /* @__PURE__ */ jsx13(TooltipPrimitive.Trigger, {
1408
1371
  "data-slot": "tooltip-trigger",
1409
1372
  ...props
1410
1373
  });
@@ -1418,8 +1381,8 @@ function TooltipContent({
1418
1381
  children,
1419
1382
  ...props
1420
1383
  }) {
1421
- return /* @__PURE__ */ jsx14(TooltipPrimitive.Portal, {
1422
- children: /* @__PURE__ */ jsx14(TooltipPrimitive.Positioner, {
1384
+ return /* @__PURE__ */ jsx13(TooltipPrimitive.Portal, {
1385
+ children: /* @__PURE__ */ jsx13(TooltipPrimitive.Positioner, {
1423
1386
  align,
1424
1387
  alignOffset,
1425
1388
  side,
@@ -1431,7 +1394,7 @@ function TooltipContent({
1431
1394
  ...props,
1432
1395
  children: [
1433
1396
  children,
1434
- /* @__PURE__ */ jsx14(TooltipPrimitive.Arrow, {
1397
+ /* @__PURE__ */ jsx13(TooltipPrimitive.Arrow, {
1435
1398
  className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"
1436
1399
  })
1437
1400
  ]
@@ -1440,381 +1403,19 @@ function TooltipContent({
1440
1403
  });
1441
1404
  }
1442
1405
 
1443
- // ../../src/components/ui/virtualized-combobox.tsx
1444
- import { Combobox as ComboboxPrimitive } from "@base-ui/react";
1445
- import { useVirtualizer } from "@tanstack/react-virtual";
1446
- import { Check, ChevronsUpDown, X } from "lucide-react";
1447
- import {
1448
- useCallback,
1449
- useEffect,
1450
- useImperativeHandle,
1451
- useRef
1452
- } from "react";
1453
-
1454
- // ../../src/components/ui/input-group.tsx
1455
- import { cva as cva3 } from "class-variance-authority";
1456
- import { jsx as jsx15 } from "react/jsx-runtime";
1457
- function InputGroup({ className, ...props }) {
1458
- return /* @__PURE__ */ jsx15("div", {
1459
- "data-slot": "input-group",
1460
- role: "group",
1461
- className: cn("group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className),
1462
- ...props
1463
- });
1464
- }
1465
- var inputGroupAddonVariants = cva3("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
1466
- variants: {
1467
- align: {
1468
- "inline-start": "order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",
1469
- "inline-end": "order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",
1470
- "block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
1471
- "block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
1472
- }
1473
- },
1474
- defaultVariants: { align: "inline-start" }
1475
- });
1476
- var inputGroupButtonVariants = cva3("flex items-center gap-2 text-sm shadow-none", {
1477
- variants: {
1478
- size: {
1479
- xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
1480
- sm: "",
1481
- "icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
1482
- "icon-sm": "size-8 p-0 has-[>svg]:p-0"
1483
- }
1484
- },
1485
- defaultVariants: { size: "xs" }
1486
- });
1487
- function InputGroupInput({
1488
- className,
1489
- ...props
1490
- }) {
1491
- return /* @__PURE__ */ jsx15(Input, {
1492
- "data-slot": "input-group-control",
1493
- className: cn("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent", className),
1494
- ...props
1495
- });
1496
- }
1497
-
1498
- // ../../src/components/ui/virtualized-combobox.tsx
1499
- import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
1500
- "use client";
1501
- var messages2 = {
1502
- en: {
1503
- clear: "Clear selection",
1504
- search: "Search...",
1505
- selected: (count) => `${count} selected`,
1506
- selectMore: "Select more"
1507
- },
1508
- fr: {
1509
- clear: "Effacer la sélection",
1510
- search: "Rechercher...",
1511
- selected: (count) => `${count} sélectionnés`,
1512
- selectMore: "Sélectionner davantage"
1513
- }
1514
- };
1515
- var virtualizedComboboxMessages = (overrides) => ({
1516
- ...getLocale().startsWith("fr") ? messages2.fr : messages2.en,
1517
- ...overrides
1518
- });
1519
- var optionEquals = (item, selected) => item.value === selected.value;
1520
- var VirtualizedComboboxList = ({
1521
- emptyLabel,
1522
- groupSelections,
1523
- itemIndexRef,
1524
- messages: messageOverrides,
1525
- renderItem,
1526
- selectedValues,
1527
- virtualizerRef
1528
- }) => {
1529
- const filteredItems = ComboboxPrimitive.useFilteredItems();
1530
- const labels2 = virtualizedComboboxMessages(messageOverrides);
1531
- const itemEntries = filteredItems.map((item, index) => ({
1532
- kind: "item",
1533
- item,
1534
- index
1535
- }));
1536
- const selectedEntries = itemEntries.filter(({ item }) => selectedValues.has(item.value));
1537
- const availableEntries = itemEntries.filter(({ item }) => !selectedValues.has(item.value));
1538
- const entries = groupSelections ? [
1539
- ...selectedEntries.length > 0 ? [
1540
- {
1541
- kind: "group",
1542
- key: "selected",
1543
- label: labels2.selected(selectedValues.size)
1544
- },
1545
- ...selectedEntries
1546
- ] : [],
1547
- {
1548
- kind: "group",
1549
- key: "available",
1550
- label: labels2.selectMore
1551
- },
1552
- ...availableEntries
1553
- ] : itemEntries;
1554
- const scrollRef = useRef(null);
1555
- const virtualizer = useVirtualizer({
1556
- count: entries.length,
1557
- getScrollElement: () => scrollRef.current,
1558
- getItemKey: (index) => {
1559
- const entry = entries[index];
1560
- return entry?.kind === "group" ? `group-${entry.key}` : entry?.item.value ?? index;
1561
- },
1562
- estimateSize: () => 36,
1563
- overscan: 8
1564
- });
1565
- useEffect(() => {
1566
- itemIndexRef.current = new Map(entries.flatMap((entry, index) => entry.kind === "item" ? [[entry.index, index]] : []));
1567
- });
1568
- useImperativeHandle(virtualizerRef, () => virtualizer, [virtualizer]);
1569
- const handleScrollElementRef = useCallback((element) => {
1570
- scrollRef.current = element;
1571
- if (element)
1572
- virtualizer.measure();
1573
- }, [virtualizer]);
1574
- if (filteredItems.length === 0) {
1575
- return /* @__PURE__ */ jsx16("div", {
1576
- className: "text-muted-foreground py-6 text-center text-sm",
1577
- children: emptyLabel
1578
- });
1579
- }
1580
- return /* @__PURE__ */ jsx16(ComboboxPrimitive.List, {
1581
- className: "scroll-py-1 overflow-auto overscroll-contain p-1",
1582
- ref: handleScrollElementRef,
1583
- style: {
1584
- height: Math.min(virtualizer.getTotalSize() + 8, 288),
1585
- maxHeight: "var(--available-height)"
1586
- },
1587
- children: /* @__PURE__ */ jsx16("div", {
1588
- className: "relative w-full",
1589
- role: "presentation",
1590
- style: { height: virtualizer.getTotalSize() },
1591
- children: virtualizer.getVirtualItems().map((virtualItem) => {
1592
- const entry = entries[virtualItem.index];
1593
- if (!entry)
1594
- return null;
1595
- const style = {
1596
- height: virtualItem.size,
1597
- transform: `translateY(${virtualItem.start}px)`
1598
- };
1599
- if (entry.kind === "group") {
1600
- return /* @__PURE__ */ jsx16(ComboboxPrimitive.Group, {
1601
- className: "contents",
1602
- children: /* @__PURE__ */ jsx16(ComboboxPrimitive.GroupLabel, {
1603
- className: "text-muted-foreground absolute top-0 left-0 w-full px-2 pt-3 pb-1 text-xs",
1604
- "data-index": virtualItem.index,
1605
- ref: virtualizer.measureElement,
1606
- style,
1607
- children: entry.label
1608
- })
1609
- }, entry.key);
1610
- }
1611
- return /* @__PURE__ */ jsxs8(ComboboxPrimitive.Item, {
1612
- "aria-posinset": entry.index + 1,
1613
- "aria-setsize": filteredItems.length,
1614
- className: "data-highlighted:bg-accent data-highlighted:text-accent-foreground absolute top-0 left-0 flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50",
1615
- "data-index": virtualItem.index,
1616
- index: entry.index,
1617
- ref: virtualizer.measureElement,
1618
- style,
1619
- value: entry.item,
1620
- children: [
1621
- renderItem?.(entry.item) ?? /* @__PURE__ */ jsx16("span", {
1622
- className: "min-w-0 truncate",
1623
- children: entry.item.label
1624
- }),
1625
- /* @__PURE__ */ jsx16(ComboboxPrimitive.ItemIndicator, {
1626
- className: "absolute right-2 flex size-4 items-center justify-center",
1627
- children: /* @__PURE__ */ jsx16(Check, {})
1628
- })
1629
- ]
1630
- }, entry.item.value);
1631
- })
1632
- })
1633
- });
1634
- };
1635
- var VirtualizedComboboxContent = ({
1636
- contentClassName,
1637
- emptyLabel,
1638
- groupSelections,
1639
- itemIndexRef,
1640
- messages: messageOverrides,
1641
- renderItem,
1642
- selectedValues,
1643
- virtualizerRef
1644
- }) => {
1645
- const labels2 = virtualizedComboboxMessages(messageOverrides);
1646
- return /* @__PURE__ */ jsx16(ComboboxPrimitive.Portal, {
1647
- children: /* @__PURE__ */ jsx16(ComboboxPrimitive.Positioner, {
1648
- align: "start",
1649
- className: "isolate z-50",
1650
- side: "bottom",
1651
- sideOffset: 6,
1652
- children: /* @__PURE__ */ jsxs8(ComboboxPrimitive.Popup, {
1653
- className: cn("relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-in-95", contentClassName),
1654
- children: [
1655
- /* @__PURE__ */ jsx16("div", {
1656
- className: "min-w-0 p-1 pb-0",
1657
- children: /* @__PURE__ */ jsx16(InputGroup, {
1658
- className: "border-input/30 bg-input/30 h-8 w-full min-w-0 shadow-none",
1659
- children: /* @__PURE__ */ jsx16(ComboboxPrimitive.Input, {
1660
- placeholder: labels2.search,
1661
- render: /* @__PURE__ */ jsx16(InputGroupInput, {})
1662
- })
1663
- })
1664
- }),
1665
- /* @__PURE__ */ jsx16(VirtualizedComboboxList, {
1666
- emptyLabel,
1667
- groupSelections,
1668
- itemIndexRef,
1669
- messages: messageOverrides,
1670
- renderItem,
1671
- selectedValues,
1672
- virtualizerRef
1673
- })
1674
- ]
1675
- })
1676
- })
1677
- });
1678
- };
1679
- var defaultTrigger = (ariaLabel, ariaInvalid, disabled, label, triggerId) => /* @__PURE__ */ jsxs8(Button, {
1680
- "aria-label": ariaLabel,
1681
- "aria-invalid": ariaInvalid,
1682
- className: "w-full max-w-full min-w-0 justify-between overflow-hidden",
1683
- disabled,
1684
- id: triggerId,
1685
- type: "button",
1686
- variant: "outline",
1687
- children: [
1688
- /* @__PURE__ */ jsx16("span", {
1689
- className: "min-w-0 flex-1 truncate pr-7 text-left",
1690
- children: label
1691
- }),
1692
- /* @__PURE__ */ jsx16(ChevronsUpDown, {
1693
- className: "text-muted-foreground shrink-0 opacity-70"
1694
- })
1695
- ]
1696
- });
1697
- var defaultClear = (label) => /* @__PURE__ */ jsx16(ComboboxPrimitive.Clear, {
1698
- "aria-label": label,
1699
- className: "text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 absolute top-1/2 right-7 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-sm outline-none focus-visible:border focus-visible:ring-3",
1700
- type: "button",
1701
- children: /* @__PURE__ */ jsx16(X, {
1702
- className: "size-3.5"
1703
- })
1704
- });
1705
- var selectedLabel = (value, placeholder) => {
1706
- if (Array.isArray(value)) {
1707
- return value.length > 0 ? value.map(({ label }) => label).join(", ") : placeholder;
1708
- }
1709
- return value && "label" in value ? value.label : placeholder;
1710
- };
1711
- var useComboboxVirtualizerRef = (providedRef) => {
1712
- const localRef = useRef(null);
1713
- return providedRef ?? localRef;
1714
- };
1715
- var VirtualizedComboboxSingle = (props) => {
1716
- const virtualizerRef = useComboboxVirtualizerRef(props.virtualizerRef);
1717
- const itemIndexRef = useRef(new Map);
1718
- const labels2 = virtualizedComboboxMessages(props.messages);
1719
- return /* @__PURE__ */ jsxs8(ComboboxPrimitive.Root, {
1720
- disabled: props.disabled,
1721
- inputValue: props.searchValue,
1722
- items: [...props.items],
1723
- itemToStringLabel: (item) => item.label,
1724
- isItemEqualToValue: optionEquals,
1725
- onInputValueChange: (value) => props.onSearchValueChange?.(value),
1726
- onItemHighlighted: (_, { index, reason }) => {
1727
- if (reason === "keyboard" && index >= 0) {
1728
- virtualizerRef.current?.scrollToIndex(itemIndexRef.current.get(index) ?? index, { align: "auto" });
1729
- }
1730
- },
1731
- onOpenChange: (open) => props.onOpenChange?.(open),
1732
- onValueChange: (value) => props.onValueChange(value),
1733
- open: props.open,
1734
- value: props.value,
1735
- virtualized: true,
1736
- children: [
1737
- /* @__PURE__ */ jsxs8("div", {
1738
- className: "relative",
1739
- children: [
1740
- /* @__PURE__ */ jsx16(ComboboxPrimitive.Trigger, {
1741
- render: props.trigger ?? defaultTrigger(props.ariaLabel, props.ariaInvalid, props.disabled, selectedLabel(props.value, props.placeholder), props.triggerId)
1742
- }),
1743
- props.trigger ? null : defaultClear(labels2.clear)
1744
- ]
1745
- }),
1746
- /* @__PURE__ */ jsx16(VirtualizedComboboxContent, {
1747
- ...props,
1748
- groupSelections: false,
1749
- itemIndexRef,
1750
- selectedValues: new Set(props.value ? [props.value.value] : []),
1751
- virtualizerRef
1752
- })
1753
- ]
1754
- });
1755
- };
1756
- var VirtualizedComboboxMultiple = (props) => {
1757
- const virtualizerRef = useComboboxVirtualizerRef(props.virtualizerRef);
1758
- const itemIndexRef = useRef(new Map);
1759
- const labels2 = virtualizedComboboxMessages(props.messages);
1760
- return /* @__PURE__ */ jsxs8(ComboboxPrimitive.Root, {
1761
- disabled: props.disabled,
1762
- inputValue: props.searchValue,
1763
- items: [...props.items],
1764
- itemToStringLabel: (item) => item.label,
1765
- isItemEqualToValue: optionEquals,
1766
- multiple: true,
1767
- onInputValueChange: (value) => props.onSearchValueChange?.(value),
1768
- onItemHighlighted: (_, { index, reason }) => {
1769
- if (reason === "keyboard" && index >= 0) {
1770
- virtualizerRef.current?.scrollToIndex(itemIndexRef.current.get(index) ?? index, { align: "auto" });
1771
- }
1772
- },
1773
- onOpenChange: (open) => props.onOpenChange?.(open),
1774
- onValueChange: (value) => props.onValueChange(value),
1775
- open: props.open,
1776
- value: [...props.value],
1777
- virtualized: true,
1778
- children: [
1779
- /* @__PURE__ */ jsxs8("div", {
1780
- className: "relative",
1781
- children: [
1782
- /* @__PURE__ */ jsx16(ComboboxPrimitive.Trigger, {
1783
- render: props.trigger ?? defaultTrigger(props.ariaLabel, props.ariaInvalid, props.disabled, selectedLabel(props.value, props.placeholder), props.triggerId)
1784
- }),
1785
- props.trigger ? null : defaultClear(labels2.clear)
1786
- ]
1787
- }),
1788
- /* @__PURE__ */ jsx16(VirtualizedComboboxContent, {
1789
- ...props,
1790
- groupSelections: true,
1791
- itemIndexRef,
1792
- selectedValues: new Set(props.value.map(({ value }) => value)),
1793
- virtualizerRef
1794
- })
1795
- ]
1796
- });
1797
- };
1798
- function VirtualizedCombobox(props) {
1799
- return props.multiple ? /* @__PURE__ */ jsx16(VirtualizedComboboxMultiple, {
1800
- ...props
1801
- }) : /* @__PURE__ */ jsx16(VirtualizedComboboxSingle, {
1802
- ...props
1803
- });
1804
- }
1805
-
1806
1406
  // ../../src/components/ui/data-table.tsx
1807
- import { jsx as jsx17, jsxs as jsxs9, Fragment } from "react/jsx-runtime";
1407
+ import { jsx as jsx14, jsxs as jsxs8, Fragment } from "react/jsx-runtime";
1808
1408
  var DataTablePersistedUiStateSchema = Schema.Struct({
1809
1409
  columnVisibility: Schema.Record(Schema.String, Schema.Boolean),
1810
1410
  columnSizing: Schema.Record(Schema.String, Schema.Number),
1811
1411
  view: Schema.Literals(["table", "gallery"])
1812
1412
  }).annotate({ identifier: "DataTablePersistedUiState" });
1813
1413
  var dataTableStorageRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
1814
- var messages3 = {
1414
+ var messages2 = {
1815
1415
  en: {
1816
1416
  ...paginationMessages("en"),
1817
1417
  actions: "Actions",
1418
+ addItem: "Add item...",
1818
1419
  empty: "No results.",
1819
1420
  loading: "Loading...",
1820
1421
  filter: "Filter results...",
@@ -1833,10 +1434,11 @@ var messages3 = {
1833
1434
  sortBy: "Sort by",
1834
1435
  hideColumn: "Hide column",
1835
1436
  reorder: "Drag to reorder",
1437
+ removeItem: "Remove",
1836
1438
  moveUp: "Move up",
1837
1439
  moveDown: "Move down",
1838
1440
  resizeColumn: (column) => `Resize ${column} column`,
1839
- listOthers: (count) => count === 1 ? "and 1 other" : `and ${count} others`,
1441
+ listDetails: "View all items",
1840
1442
  selectAllRows: "Select all rows on this page",
1841
1443
  selectRow: "Select row",
1842
1444
  selected: "Selected"
@@ -1844,6 +1446,7 @@ var messages3 = {
1844
1446
  fr: {
1845
1447
  ...paginationMessages("fr"),
1846
1448
  actions: "Actions",
1449
+ addItem: "Ajouter un élément...",
1847
1450
  empty: "Aucun résultat.",
1848
1451
  loading: "Chargement...",
1849
1452
  filter: "Filtrer les résultats...",
@@ -1862,17 +1465,18 @@ var messages3 = {
1862
1465
  sortBy: "Trier par",
1863
1466
  hideColumn: "Masquer la colonne",
1864
1467
  reorder: "Glisser pour réordonner",
1468
+ removeItem: "Retirer",
1865
1469
  moveUp: "Déplacer vers le haut",
1866
1470
  moveDown: "Déplacer vers le bas",
1867
1471
  resizeColumn: (column) => `Redimensionner la colonne ${column}`,
1868
- listOthers: (count) => count === 1 ? "et 1 autre" : `et ${count} autres`,
1472
+ listDetails: "Afficher tous les éléments",
1869
1473
  selectAllRows: "Sélectionner toutes les lignes de cette page",
1870
1474
  selectRow: "Sélectionner la ligne",
1871
1475
  selected: "Sélectionnés"
1872
1476
  }
1873
1477
  };
1874
1478
  var dataTableMessages = (overrides) => ({
1875
- ...getLocale().startsWith("fr") ? messages3.fr : messages3.en,
1479
+ ...getLocale().startsWith("fr") ? messages2.fr : messages2.en,
1876
1480
  ...overrides
1877
1481
  });
1878
1482
  var DEFAULT_MIN_WIDTH = 96;
@@ -1933,18 +1537,100 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
1933
1537
  index,
1934
1538
  values: new Map(columns.map((column) => {
1935
1539
  const { colDef } = column;
1936
- const value = colDef.valueGetter ? colDef.valueGetter({ data, rowId: id, rowIndex: index, colDef }) : colDef.field ? data[colDef.field] : undefined;
1540
+ const value = colDef.valueGetter ? colDef.valueGetter({ data, rowId: id, rowIndex: index, colDef }) : colDef.type === "list" ? colDef.typeOptions.getItems(data).map((item) => item.label).join(", ") : colDef.field ? data[colDef.field] : undefined;
1937
1541
  return [column.id, value];
1938
1542
  }))
1939
1543
  };
1940
1544
  });
1941
1545
  };
1546
+ var CalendarDate = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "DataTableCalendarDate" });
1547
+ var InstantString = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/), Schema.makeFilter((value) => Schema.is(CalendarDate)(value.slice(0, 10)))).annotate({ identifier: "DataTableInstantString" });
1548
+ var DateInput = Schema.Union([
1549
+ Schema.Date,
1550
+ Schema.Int,
1551
+ CalendarDate,
1552
+ InstantString
1553
+ ]).annotate({ identifier: "DataTableDateInput" });
1554
+ var decodeDateInput = Schema.decodeUnknownOption(DateInput);
1555
+ var resolveDate = (value, type) => Option.getOrUndefined(Option.flatMap(decodeDateInput(value), (input) => {
1556
+ const calendarOnly = Schema.is(CalendarDate)(input);
1557
+ if (calendarOnly && type === "dateTime")
1558
+ return Option.none();
1559
+ return Option.map(DateTime.make(input), (instant) => ({
1560
+ instant,
1561
+ calendarOnly
1562
+ }));
1563
+ }));
1564
+ var formatDateValue = (date, column) => DateTime.format(date.instant, {
1565
+ locale: column.typeOptions?.locale ?? getLocale(),
1566
+ timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
1567
+ dateStyle: column.typeOptions?.dateStyle ?? "medium",
1568
+ timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
1569
+ hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
1570
+ });
1571
+ var dateIsoValue = (date) => date.calendarOnly ? DateTime.formatIsoDateUtc(date.instant) : DateTime.formatIso(date.instant);
1572
+ var NumberValue = Schema.Finite.annotate({
1573
+ identifier: "DataTableNumberValue"
1574
+ });
1575
+ var BooleanValue = Schema.Boolean.annotate({
1576
+ identifier: "DataTableBooleanValue"
1577
+ });
1578
+ var decodeNumberValue = Schema.decodeUnknownOption(NumberValue);
1579
+ var decodeBooleanValue = Schema.decodeUnknownOption(BooleanValue);
1580
+ var formatNumberValue = (value, options = {}) => {
1581
+ const {
1582
+ locale,
1583
+ emptyLabel: _emptyLabel,
1584
+ nulls: _nulls,
1585
+ exportFormat: _exportFormat,
1586
+ ...format
1587
+ } = options;
1588
+ return new Intl.NumberFormat(locale ?? getLocale(), format).format(value);
1589
+ };
1590
+ var booleanLabel = (value, options) => value ? options?.trueLabel : options?.falseLabel;
1591
+ var getDataTableExportValue = (row, column) => {
1592
+ const value = row.values.get(column.id);
1593
+ const colDef = column.colDef;
1594
+ if (colDef.type === "number") {
1595
+ const number = Option.getOrUndefined(decodeNumberValue(value));
1596
+ if (number === undefined)
1597
+ return null;
1598
+ return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions) : number;
1599
+ }
1600
+ if (colDef.type === "boolean") {
1601
+ const boolean = Option.getOrUndefined(decodeBooleanValue(value));
1602
+ if (boolean === undefined)
1603
+ return null;
1604
+ return colDef.typeOptions?.exportFormat === "formatted" ? booleanLabel(boolean, colDef.typeOptions) ?? String(boolean) : boolean;
1605
+ }
1606
+ if (colDef.type !== "date" && colDef.type !== "dateTime")
1607
+ return value;
1608
+ const date = resolveDate(value, colDef.type);
1609
+ if (!date)
1610
+ return null;
1611
+ return colDef.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, colDef) : dateIsoValue(date);
1612
+ };
1942
1613
  var filterDataTableRows = (rows, columns, globalFilter) => {
1943
1614
  const query = globalFilter.trim().toLocaleLowerCase();
1944
1615
  if (!query)
1945
1616
  return [...rows];
1946
1617
  const searchable = columns.filter(({ colDef }) => colDef.searchable !== false);
1947
- return rows.filter((row) => searchable.some((column) => String(row.values.get(column.id) ?? "").toLocaleLowerCase().includes(query)));
1618
+ return rows.filter((row) => searchable.some((column) => {
1619
+ const value = row.values.get(column.id);
1620
+ const colDef = column.colDef;
1621
+ let text = String(value ?? "");
1622
+ if (colDef.type === "date" || colDef.type === "dateTime") {
1623
+ const date = resolveDate(value, colDef.type);
1624
+ text = date ? `${formatDateValue(date, colDef)} ${dateIsoValue(date)}` : "";
1625
+ } else if (colDef.type === "number") {
1626
+ const number = Option.getOrUndefined(decodeNumberValue(value));
1627
+ text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions)} ${number}`;
1628
+ } else if (colDef.type === "boolean") {
1629
+ const boolean = Option.getOrUndefined(decodeBooleanValue(value));
1630
+ text = boolean === undefined ? "" : `${booleanLabel(boolean, colDef.typeOptions) ?? ""} ${boolean}`;
1631
+ }
1632
+ return text.toLocaleLowerCase().includes(query);
1633
+ }));
1948
1634
  };
1949
1635
  var sortDataTableRows = (rows, columns, sorting) => {
1950
1636
  const byId = new Map(columns.map((column) => [column.id, column]));
@@ -1955,6 +1641,35 @@ var sortDataTableRows = (rows, columns, sorting) => {
1955
1641
  continue;
1956
1642
  const leftValue = left.row.values.get(sort.id);
1957
1643
  const rightValue = right.row.values.get(sort.id);
1644
+ const colDef = column.colDef;
1645
+ if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean")) {
1646
+ const leftScalar = colDef.type === "number" ? Option.getOrUndefined(decodeNumberValue(leftValue)) : Option.getOrUndefined(Option.map(decodeBooleanValue(leftValue), Number));
1647
+ const rightScalar = colDef.type === "number" ? Option.getOrUndefined(decodeNumberValue(rightValue)) : Option.getOrUndefined(Option.map(decodeBooleanValue(rightValue), Number));
1648
+ if (leftScalar === undefined || rightScalar === undefined) {
1649
+ if (leftScalar === undefined && rightScalar === undefined)
1650
+ continue;
1651
+ const nullOrder = colDef.typeOptions?.nulls === "first" ? -1 : 1;
1652
+ return leftScalar === undefined ? nullOrder : -nullOrder;
1653
+ }
1654
+ const comparison2 = leftScalar - rightScalar;
1655
+ if (comparison2 !== 0)
1656
+ return sort.direction === "desc" ? -comparison2 : comparison2;
1657
+ continue;
1658
+ }
1659
+ if (!colDef.comparator && (colDef.type === "date" || colDef.type === "dateTime")) {
1660
+ const leftDate = resolveDate(leftValue, colDef.type);
1661
+ const rightDate = resolveDate(rightValue, colDef.type);
1662
+ if (!leftDate || !rightDate) {
1663
+ if (!leftDate && !rightDate)
1664
+ continue;
1665
+ const nullOrder = colDef.typeOptions?.nulls === "first" ? -1 : 1;
1666
+ return !leftDate ? nullOrder : -nullOrder;
1667
+ }
1668
+ const comparison2 = DateTime.toEpochMillis(leftDate.instant) - DateTime.toEpochMillis(rightDate.instant);
1669
+ if (comparison2 !== 0)
1670
+ return sort.direction === "desc" ? -comparison2 : comparison2;
1671
+ continue;
1672
+ }
1958
1673
  const comparison = column.colDef.comparator ? column.colDef.comparator(leftValue, rightValue, left.row.data, right.row.data) : Object.is(leftValue, rightValue) ? 0 : leftValue === null || leftValue === undefined ? 1 : rightValue === null || rightValue === undefined ? -1 : Schema.is(Schema.Number)(leftValue) && Schema.is(Schema.Number)(rightValue) ? leftValue - rightValue : String(leftValue).localeCompare(String(rightValue), undefined, { numeric: true, sensitivity: "base" });
1959
1674
  if (comparison !== 0)
1960
1675
  return sort.direction === "desc" ? -comparison : comparison;
@@ -2150,9 +1865,76 @@ var renderCell = (row, column) => {
2150
1865
  };
2151
1866
  const CellRenderer = column.colDef.cellRenderer;
2152
1867
  if (CellRenderer)
2153
- return /* @__PURE__ */ jsx17(CellRenderer, {
1868
+ return /* @__PURE__ */ jsx14(CellRenderer, {
2154
1869
  ...params
2155
1870
  });
1871
+ const colDef = column.colDef;
1872
+ if (colDef.type === "number") {
1873
+ if (colDef.valueFormatter)
1874
+ return colDef.valueFormatter(params);
1875
+ const number = Option.getOrUndefined(decodeNumberValue(value));
1876
+ return /* @__PURE__ */ jsx14("span", {
1877
+ className: "block text-left tabular-nums",
1878
+ children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions)
1879
+ });
1880
+ }
1881
+ if (colDef.type === "boolean") {
1882
+ if (colDef.valueFormatter)
1883
+ return colDef.valueFormatter(params);
1884
+ const boolean = Option.getOrUndefined(decodeBooleanValue(value));
1885
+ if (boolean === undefined)
1886
+ return colDef.typeOptions?.emptyLabel ?? "—";
1887
+ const options = colDef.typeOptions;
1888
+ return /* @__PURE__ */ jsx14("label", {
1889
+ "data-slot": "data-table-boolean-cell",
1890
+ className: cn("flex min-h-16 w-full items-center justify-start border border-transparent px-2 outline-none focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 focus-within:ring-inset in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0", options?.onChange && !options.disabled?.(row.data) && "cursor-pointer hover:bg-muted/50"),
1891
+ onClick: (event) => event.stopPropagation(),
1892
+ onPointerDown: (event) => event.stopPropagation(),
1893
+ children: /* @__PURE__ */ jsx14(Checkbox, {
1894
+ "aria-label": options?.getAriaLabel?.(row.data) ?? columnLabel(column),
1895
+ className: "focus-visible:ring-0 focus-visible:outline-none",
1896
+ checked: boolean,
1897
+ readOnly: !options?.onChange,
1898
+ disabled: options?.disabled?.(row.data),
1899
+ onCheckedChange: (checked) => options?.onChange?.({ value: checked, row: row.data })
1900
+ })
1901
+ });
1902
+ }
1903
+ if (colDef.type === "date" || colDef.type === "dateTime") {
1904
+ if (colDef.valueFormatter)
1905
+ return colDef.valueFormatter(params);
1906
+ const date = resolveDate(value, colDef.type);
1907
+ return date ? /* @__PURE__ */ jsx14("time", {
1908
+ dateTime: dateIsoValue(date),
1909
+ children: formatDateValue(date, colDef)
1910
+ }) : colDef.typeOptions?.emptyLabel ?? "—";
1911
+ }
1912
+ if (colDef.type === "list") {
1913
+ const config = colDef.typeOptions;
1914
+ const itemActions = config.itemActions?.map((action) => ({
1915
+ ...action,
1916
+ onClick: (item) => action.onClick({ item, row: row.data }),
1917
+ visible: (item) => action.visible?.({ item, row: row.data }) ?? true,
1918
+ disabled: (item) => action.disabled?.({ item, row: row.data }) ?? false
1919
+ }));
1920
+ if (config.getOptions) {
1921
+ return /* @__PURE__ */ jsx14(DataTableListCell, {
1922
+ ...config,
1923
+ itemActions,
1924
+ items: config.getItems(row.data),
1925
+ options: config.getOptions(row.data),
1926
+ totalCount: config.getTotalCount?.(row.data),
1927
+ onAdd: config.onAdd ? (value2) => config.onAdd?.({ value: value2, row: row.data }) : undefined,
1928
+ onRemove: config.onRemove ? (value2) => config.onRemove?.({ value: value2, row: row.data }) : undefined
1929
+ });
1930
+ }
1931
+ return /* @__PURE__ */ jsx14(DataTableListCell, {
1932
+ ...config,
1933
+ itemActions,
1934
+ items: config.getItems(row.data),
1935
+ totalCount: config.getTotalCount?.(row.data)
1936
+ });
1937
+ }
2156
1938
  return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : String(value));
2157
1939
  };
2158
1940
  var nodeText = (node) => {
@@ -2196,33 +1978,33 @@ var DataTableRowActions = ({
2196
1978
  const visible = actions.filter((action) => !action.visible || action.visible(row));
2197
1979
  if (!visible.length)
2198
1980
  return null;
2199
- return /* @__PURE__ */ jsxs9(DropdownMenu, {
1981
+ return /* @__PURE__ */ jsxs8(DropdownMenu, {
2200
1982
  children: [
2201
- /* @__PURE__ */ jsx17(DropdownMenuTrigger, {
1983
+ /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
2202
1984
  onClick: (event) => event.stopPropagation(),
2203
- render: /* @__PURE__ */ jsxs9(Button, {
1985
+ render: /* @__PURE__ */ jsxs8(Button, {
2204
1986
  className: "size-8 focus-visible:ring-inset [&_svg:not([class*='size-'])]:size-4",
2205
1987
  size: "icon",
2206
1988
  variant: "ghost",
2207
1989
  children: [
2208
- /* @__PURE__ */ jsx17("span", {
1990
+ /* @__PURE__ */ jsx14("span", {
2209
1991
  className: "sr-only",
2210
1992
  children: title
2211
1993
  }),
2212
- /* @__PURE__ */ jsx17(MoreHorizontal, {})
1994
+ /* @__PURE__ */ jsx14(MoreHorizontal, {})
2213
1995
  ]
2214
1996
  })
2215
1997
  }),
2216
- /* @__PURE__ */ jsx17(DropdownMenuContent, {
1998
+ /* @__PURE__ */ jsx14(DropdownMenuContent, {
2217
1999
  align: "end",
2218
2000
  className: "w-max",
2219
- children: /* @__PURE__ */ jsxs9(DropdownMenuGroup, {
2001
+ children: /* @__PURE__ */ jsxs8(DropdownMenuGroup, {
2220
2002
  children: [
2221
- /* @__PURE__ */ jsx17(DropdownMenuLabel, {
2003
+ /* @__PURE__ */ jsx14(DropdownMenuLabel, {
2222
2004
  children: title
2223
2005
  }),
2224
- /* @__PURE__ */ jsx17(DropdownMenuSeparator, {}),
2225
- visible.map((action) => /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2006
+ /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}),
2007
+ visible.map((action) => /* @__PURE__ */ jsxs8(DropdownMenuItem, {
2226
2008
  onClick: (event) => {
2227
2009
  event.stopPropagation();
2228
2010
  action.onClick(row);
@@ -2259,7 +2041,7 @@ var DataTableRowActionMenu = ({
2259
2041
  reorderActions.push({
2260
2042
  id: "data-table-move-up",
2261
2043
  name: store.config.labels.moveUp,
2262
- icon: /* @__PURE__ */ jsx17(ArrowUp, {}),
2044
+ icon: /* @__PURE__ */ jsx14(ArrowUp, {}),
2263
2045
  onClick: () => move(rowIndex - 1)
2264
2046
  });
2265
2047
  }
@@ -2267,12 +2049,12 @@ var DataTableRowActionMenu = ({
2267
2049
  reorderActions.push({
2268
2050
  id: "data-table-move-down",
2269
2051
  name: store.config.labels.moveDown,
2270
- icon: /* @__PURE__ */ jsx17(ArrowDown, {}),
2052
+ icon: /* @__PURE__ */ jsx14(ArrowDown, {}),
2271
2053
  onClick: () => move(rowIndex + 1)
2272
2054
  });
2273
2055
  }
2274
2056
  }
2275
- return /* @__PURE__ */ jsx17(DataTableRowActions, {
2057
+ return /* @__PURE__ */ jsx14(DataTableRowActions, {
2276
2058
  actions: [...reorderActions, ...rowActions ? rowActions.items : []],
2277
2059
  row: row.data,
2278
2060
  title: rowActions?.label ?? store.config.labels.actions
@@ -2286,23 +2068,24 @@ var DataTableToolbar = ({
2286
2068
  const model = deriveModel(store);
2287
2069
  const selectedRows = getSelectedRows(store, model);
2288
2070
  const grouping = features.grouping;
2071
+ const toolbar = features.toolbar;
2289
2072
  const bulkActions = features.selection && features.selection.bulkActions;
2290
- const hasToolbar = features.search !== false || features.sorting !== false || features.columnVisibility !== false || !!features.export || !!features.gallery || !!grouping || !!features.refresh || !!bulkActions && selectedRows.length > 0;
2073
+ const hasToolbar = !!toolbar || features.search !== false || features.sorting !== false || features.columnVisibility !== false || !!features.export || !!features.gallery || !!grouping || !!features.refresh || !!bulkActions && selectedRows.length > 0;
2291
2074
  if (!hasToolbar)
2292
2075
  return null;
2293
2076
  const update = (next) => changeState(setStore, next);
2294
2077
  const visibleBulkActions = bulkActions ? bulkActions.items.filter((action) => !action.visible || action.visible(selectedRows)) : [];
2295
2078
  const exportRows = features.export && features.export.scope === "filteredRows" ? model.filteredRows : model.pageRows;
2296
- return /* @__PURE__ */ jsxs9("div", {
2079
+ return /* @__PURE__ */ jsxs8("div", {
2297
2080
  className: "flex flex-col gap-2 pb-4",
2298
2081
  children: [
2299
- features.search !== false ? /* @__PURE__ */ jsxs9("div", {
2082
+ features.search !== false ? /* @__PURE__ */ jsxs8("div", {
2300
2083
  className: "relative min-w-0",
2301
2084
  children: [
2302
- /* @__PURE__ */ jsx17(Search, {
2085
+ /* @__PURE__ */ jsx14(Search, {
2303
2086
  className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
2304
2087
  }),
2305
- /* @__PURE__ */ jsx17(Input, {
2088
+ /* @__PURE__ */ jsx14(Input, {
2306
2089
  className: "px-9",
2307
2090
  onChange: (event) => update((state) => ({
2308
2091
  ...state,
@@ -2312,7 +2095,7 @@ var DataTableToolbar = ({
2312
2095
  placeholder: labels2.filter,
2313
2096
  value: store.state.globalFilter ?? ""
2314
2097
  }),
2315
- store.state.globalFilter ? /* @__PURE__ */ jsx17(Button, {
2098
+ store.state.globalFilter ? /* @__PURE__ */ jsx14(Button, {
2316
2099
  "aria-label": labels2.filter,
2317
2100
  className: "absolute top-1/2 right-1 size-7 -translate-y-1/2",
2318
2101
  onClick: () => update((state) => ({
@@ -2322,38 +2105,39 @@ var DataTableToolbar = ({
2322
2105
  })),
2323
2106
  size: "icon",
2324
2107
  variant: "ghost",
2325
- children: /* @__PURE__ */ jsx17(X2, {})
2108
+ children: /* @__PURE__ */ jsx14(X, {})
2326
2109
  }) : null
2327
2110
  ]
2328
2111
  }) : null,
2329
- /* @__PURE__ */ jsx17("div", {
2112
+ /* @__PURE__ */ jsx14("div", {
2330
2113
  className: "-m-1 flex overflow-x-auto p-1",
2331
- children: /* @__PURE__ */ jsxs9(Menubar, {
2114
+ children: /* @__PURE__ */ jsxs8(Menubar, {
2332
2115
  className: "h-auto w-max min-w-full justify-start bg-transparent shadow-none [&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4",
2333
2116
  children: [
2334
- visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
2117
+ toolbar && toolbar.items,
2118
+ visibleBulkActions.length ? /* @__PURE__ */ jsxs8(MenubarMenu, {
2335
2119
  children: [
2336
- /* @__PURE__ */ jsxs9(MenubarTrigger, {
2120
+ /* @__PURE__ */ jsxs8(MenubarTrigger, {
2337
2121
  className: "bg-primary text-primary-foreground hover:bg-primary/90 aria-expanded:bg-primary/90",
2338
2122
  children: [
2339
2123
  labels2.selected,
2340
- /* @__PURE__ */ jsx17(Badge, {
2124
+ /* @__PURE__ */ jsx14(Badge, {
2341
2125
  variant: "secondary",
2342
2126
  children: selectedRows.length
2343
2127
  }),
2344
- /* @__PURE__ */ jsx17(ChevronDown, {})
2128
+ /* @__PURE__ */ jsx14(ChevronDown, {})
2345
2129
  ]
2346
2130
  }),
2347
- /* @__PURE__ */ jsx17(MenubarContent, {
2131
+ /* @__PURE__ */ jsx14(MenubarContent, {
2348
2132
  align: "end",
2349
2133
  className: "w-max",
2350
- children: /* @__PURE__ */ jsxs9(MenubarGroup, {
2134
+ children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2351
2135
  children: [
2352
- /* @__PURE__ */ jsx17(MenubarLabel, {
2136
+ /* @__PURE__ */ jsx14(MenubarLabel, {
2353
2137
  children: bulkActions && bulkActions.label ? bulkActions.label : labels2.actions
2354
2138
  }),
2355
- /* @__PURE__ */ jsx17(MenubarSeparator, {}),
2356
- visibleBulkActions.map((action) => /* @__PURE__ */ jsxs9(MenubarItem, {
2139
+ /* @__PURE__ */ jsx14(MenubarSeparator, {}),
2140
+ visibleBulkActions.map((action) => /* @__PURE__ */ jsxs8(MenubarItem, {
2357
2141
  onClick: () => action.onClick(selectedRows),
2358
2142
  variant: action.variant,
2359
2143
  children: [
@@ -2366,27 +2150,27 @@ var DataTableToolbar = ({
2366
2150
  })
2367
2151
  ]
2368
2152
  }) : null,
2369
- grouping ? /* @__PURE__ */ jsxs9(MenubarMenu, {
2153
+ grouping ? /* @__PURE__ */ jsxs8(MenubarMenu, {
2370
2154
  children: [
2371
- /* @__PURE__ */ jsxs9(MenubarTrigger, {
2155
+ /* @__PURE__ */ jsxs8(MenubarTrigger, {
2372
2156
  "aria-label": labels2.groupBy,
2373
2157
  children: [
2374
- /* @__PURE__ */ jsx17(Rows3, {}),
2375
- /* @__PURE__ */ jsx17("span", {
2158
+ /* @__PURE__ */ jsx14(Rows3, {}),
2159
+ /* @__PURE__ */ jsx14("span", {
2376
2160
  className: "hidden sm:inline",
2377
2161
  children: labels2.groupBy
2378
2162
  })
2379
2163
  ]
2380
2164
  }),
2381
- /* @__PURE__ */ jsx17(MenubarContent, {
2165
+ /* @__PURE__ */ jsx14(MenubarContent, {
2382
2166
  align: "end",
2383
- children: /* @__PURE__ */ jsxs9(MenubarGroup, {
2167
+ children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2384
2168
  children: [
2385
- /* @__PURE__ */ jsx17(MenubarLabel, {
2169
+ /* @__PURE__ */ jsx14(MenubarLabel, {
2386
2170
  children: labels2.groupBy
2387
2171
  }),
2388
- /* @__PURE__ */ jsx17(MenubarSeparator, {}),
2389
- grouping.fields.map((field) => /* @__PURE__ */ jsx17(MenubarCheckboxItem, {
2172
+ /* @__PURE__ */ jsx14(MenubarSeparator, {}),
2173
+ grouping.fields.map((field) => /* @__PURE__ */ jsx14(MenubarCheckboxItem, {
2390
2174
  checked: store.state.grouping.includes(field.id),
2391
2175
  onCheckedChange: (checked) => update((state) => ({
2392
2176
  ...state,
@@ -2399,63 +2183,63 @@ var DataTableToolbar = ({
2399
2183
  })
2400
2184
  ]
2401
2185
  }) : null,
2402
- features.sorting !== false ? /* @__PURE__ */ jsx17(SortMenu, {
2186
+ features.sorting !== false ? /* @__PURE__ */ jsx14(SortMenu, {
2403
2187
  tableAtom
2404
2188
  }) : null,
2405
- features.gallery ? /* @__PURE__ */ jsx17(ViewMenu, {
2189
+ features.gallery ? /* @__PURE__ */ jsx14(ViewMenu, {
2406
2190
  tableAtom
2407
2191
  }) : null,
2408
- features.columnVisibility !== false ? /* @__PURE__ */ jsx17(ColumnMenu, {
2192
+ features.columnVisibility !== false ? /* @__PURE__ */ jsx14(ColumnMenu, {
2409
2193
  tableAtom
2410
2194
  }) : null,
2411
- features.refresh ? /* @__PURE__ */ jsx17(MenubarMenu, {
2412
- children: /* @__PURE__ */ jsxs9(MenubarTrigger, {
2195
+ features.refresh ? /* @__PURE__ */ jsx14(MenubarMenu, {
2196
+ children: /* @__PURE__ */ jsxs8(MenubarTrigger, {
2413
2197
  "aria-label": labels2.refresh,
2414
2198
  onClick: features.refresh,
2415
2199
  children: [
2416
- /* @__PURE__ */ jsx17(RefreshCw, {}),
2417
- /* @__PURE__ */ jsx17("span", {
2200
+ /* @__PURE__ */ jsx14(RefreshCw, {}),
2201
+ /* @__PURE__ */ jsx14("span", {
2418
2202
  className: "hidden sm:inline",
2419
2203
  children: labels2.refresh
2420
2204
  })
2421
2205
  ]
2422
2206
  })
2423
2207
  }) : null,
2424
- features.export ? /* @__PURE__ */ jsxs9(MenubarMenu, {
2208
+ features.export ? /* @__PURE__ */ jsxs8(MenubarMenu, {
2425
2209
  children: [
2426
- /* @__PURE__ */ jsxs9(MenubarTrigger, {
2210
+ /* @__PURE__ */ jsxs8(MenubarTrigger, {
2427
2211
  "aria-label": labels2.export,
2428
2212
  disabled: !exportRows.length,
2429
2213
  children: [
2430
- /* @__PURE__ */ jsx17(Download, {}),
2431
- /* @__PURE__ */ jsx17("span", {
2214
+ /* @__PURE__ */ jsx14(Download, {}),
2215
+ /* @__PURE__ */ jsx14("span", {
2432
2216
  className: "hidden sm:inline",
2433
2217
  children: labels2.export
2434
2218
  })
2435
2219
  ]
2436
2220
  }),
2437
- /* @__PURE__ */ jsx17(MenubarContent, {
2221
+ /* @__PURE__ */ jsx14(MenubarContent, {
2438
2222
  align: "end",
2439
- children: /* @__PURE__ */ jsxs9(MenubarGroup, {
2223
+ children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2440
2224
  children: [
2441
- /* @__PURE__ */ jsx17(MenubarLabel, {
2225
+ /* @__PURE__ */ jsx14(MenubarLabel, {
2442
2226
  children: labels2.export
2443
2227
  }),
2444
- /* @__PURE__ */ jsx17(MenubarSeparator, {}),
2445
- /* @__PURE__ */ jsxs9(MenubarItem, {
2446
- onClick: () => downloadCsv(model.visibleColumns.map(columnLabel), exportRows.map((row) => model.visibleColumns.map((column) => String(row.values.get(column.id) ?? ""))), features.export ? features.export.baseName : "table"),
2228
+ /* @__PURE__ */ jsx14(MenubarSeparator, {}),
2229
+ /* @__PURE__ */ jsxs8(MenubarItem, {
2230
+ onClick: () => downloadCsv(model.visibleColumns.map(columnLabel), exportRows.map((row) => model.visibleColumns.map((column) => String(getDataTableExportValue(row, column) ?? ""))), features.export ? features.export.baseName : "table"),
2447
2231
  children: [
2448
- /* @__PURE__ */ jsx17(FileText, {}),
2232
+ /* @__PURE__ */ jsx14(FileText, {}),
2449
2233
  labels2.exportCsv
2450
2234
  ]
2451
2235
  }),
2452
- /* @__PURE__ */ jsxs9(MenubarItem, {
2236
+ /* @__PURE__ */ jsxs8(MenubarItem, {
2453
2237
  onClick: () => downloadJson(exportRows.map((row) => Object.fromEntries(model.visibleColumns.map((column) => [
2454
2238
  column.id,
2455
- row.values.get(column.id)
2239
+ getDataTableExportValue(row, column)
2456
2240
  ]))), features.export ? features.export.baseName : "table"),
2457
2241
  children: [
2458
- /* @__PURE__ */ jsx17(FileJson, {}),
2242
+ /* @__PURE__ */ jsx14(FileJson, {}),
2459
2243
  labels2.exportJson
2460
2244
  ]
2461
2245
  })
@@ -2483,59 +2267,59 @@ var SortMenu = ({
2483
2267
  sort: [{ id, direction }],
2484
2268
  page: 0
2485
2269
  }));
2486
- return /* @__PURE__ */ jsxs9(MenubarMenu, {
2270
+ return /* @__PURE__ */ jsxs8(MenubarMenu, {
2487
2271
  children: [
2488
- /* @__PURE__ */ jsxs9(MenubarTrigger, {
2272
+ /* @__PURE__ */ jsxs8(MenubarTrigger, {
2489
2273
  "aria-label": store.config.labels.sortBy,
2490
2274
  children: [
2491
- current ? current.direction === "desc" ? /* @__PURE__ */ jsx17(ArrowDown, {}) : /* @__PURE__ */ jsx17(ArrowUp, {}) : /* @__PURE__ */ jsx17(ChevronsUpDown2, {}),
2492
- /* @__PURE__ */ jsx17("span", {
2275
+ current ? current.direction === "desc" ? /* @__PURE__ */ jsx14(ArrowDown, {}) : /* @__PURE__ */ jsx14(ArrowUp, {}) : /* @__PURE__ */ jsx14(ChevronsUpDown, {}),
2276
+ /* @__PURE__ */ jsx14("span", {
2493
2277
  className: "hidden sm:inline",
2494
2278
  children: store.config.labels.sortBy
2495
2279
  })
2496
2280
  ]
2497
2281
  }),
2498
- /* @__PURE__ */ jsx17(MenubarContent, {
2282
+ /* @__PURE__ */ jsx14(MenubarContent, {
2499
2283
  align: "end",
2500
2284
  className: "w-52",
2501
2285
  children: columns.map((column) => {
2502
2286
  const sortState = store.state.sort?.find(({ id }) => id === column.id);
2503
- return /* @__PURE__ */ jsxs9(MenubarSub, {
2287
+ return /* @__PURE__ */ jsxs8(MenubarSub, {
2504
2288
  children: [
2505
- /* @__PURE__ */ jsxs9(MenubarSubTrigger, {
2289
+ /* @__PURE__ */ jsxs8(MenubarSubTrigger, {
2506
2290
  children: [
2507
- sortState ? sortState.direction === "desc" ? /* @__PURE__ */ jsx17(ArrowDown, {}) : /* @__PURE__ */ jsx17(ArrowUp, {}) : null,
2291
+ sortState ? sortState.direction === "desc" ? /* @__PURE__ */ jsx14(ArrowDown, {}) : /* @__PURE__ */ jsx14(ArrowUp, {}) : null,
2508
2292
  columnLabel(column)
2509
2293
  ]
2510
2294
  }),
2511
- /* @__PURE__ */ jsxs9(MenubarSubContent, {
2295
+ /* @__PURE__ */ jsxs8(MenubarSubContent, {
2512
2296
  children: [
2513
- /* @__PURE__ */ jsxs9(MenubarItem, {
2297
+ /* @__PURE__ */ jsxs8(MenubarItem, {
2514
2298
  onClick: () => sort(column.id, "asc"),
2515
2299
  children: [
2516
- /* @__PURE__ */ jsx17(ArrowUp, {}),
2300
+ /* @__PURE__ */ jsx14(ArrowUp, {}),
2517
2301
  " ",
2518
2302
  store.config.labels.sortAsc
2519
2303
  ]
2520
2304
  }),
2521
- /* @__PURE__ */ jsxs9(MenubarItem, {
2305
+ /* @__PURE__ */ jsxs8(MenubarItem, {
2522
2306
  onClick: () => sort(column.id, "desc"),
2523
2307
  children: [
2524
- /* @__PURE__ */ jsx17(ArrowDown, {}),
2308
+ /* @__PURE__ */ jsx14(ArrowDown, {}),
2525
2309
  " ",
2526
2310
  store.config.labels.sortDesc
2527
2311
  ]
2528
2312
  }),
2529
- sortState ? /* @__PURE__ */ jsxs9(Fragment, {
2313
+ sortState ? /* @__PURE__ */ jsxs8(Fragment, {
2530
2314
  children: [
2531
- /* @__PURE__ */ jsx17(MenubarSeparator, {}),
2532
- /* @__PURE__ */ jsxs9(MenubarItem, {
2315
+ /* @__PURE__ */ jsx14(MenubarSeparator, {}),
2316
+ /* @__PURE__ */ jsxs8(MenubarItem, {
2533
2317
  onClick: () => changeState(setStore, (state) => ({
2534
2318
  ...state,
2535
2319
  sort: state.sort?.filter(({ id }) => id !== column.id)
2536
2320
  })),
2537
2321
  children: [
2538
- /* @__PURE__ */ jsx17(X2, {}),
2322
+ /* @__PURE__ */ jsx14(X, {}),
2539
2323
  " ",
2540
2324
  store.config.labels.sortClear
2541
2325
  ]
@@ -2555,21 +2339,21 @@ var ViewMenu = ({
2555
2339
  tableAtom
2556
2340
  }) => {
2557
2341
  const [store, setStore] = useTableAtom(tableAtom);
2558
- return /* @__PURE__ */ jsxs9(MenubarMenu, {
2342
+ return /* @__PURE__ */ jsxs8(MenubarMenu, {
2559
2343
  children: [
2560
- /* @__PURE__ */ jsxs9(MenubarTrigger, {
2344
+ /* @__PURE__ */ jsxs8(MenubarTrigger, {
2561
2345
  "aria-label": store.config.labels.view,
2562
2346
  children: [
2563
- store.state.view === "gallery" ? /* @__PURE__ */ jsx17(LayoutGrid, {}) : /* @__PURE__ */ jsx17(Rows3, {}),
2564
- /* @__PURE__ */ jsx17("span", {
2347
+ store.state.view === "gallery" ? /* @__PURE__ */ jsx14(LayoutGrid, {}) : /* @__PURE__ */ jsx14(Rows3, {}),
2348
+ /* @__PURE__ */ jsx14("span", {
2565
2349
  className: "hidden sm:inline",
2566
2350
  children: store.config.labels.view
2567
2351
  })
2568
2352
  ]
2569
2353
  }),
2570
- /* @__PURE__ */ jsx17(MenubarContent, {
2354
+ /* @__PURE__ */ jsx14(MenubarContent, {
2571
2355
  align: "end",
2572
- children: /* @__PURE__ */ jsxs9(MenubarRadioGroup, {
2356
+ children: /* @__PURE__ */ jsxs8(MenubarRadioGroup, {
2573
2357
  onValueChange: (view) => {
2574
2358
  if (view === "table" || view === "gallery") {
2575
2359
  changeState(setStore, (state) => ({ ...state, view }));
@@ -2577,18 +2361,18 @@ var ViewMenu = ({
2577
2361
  },
2578
2362
  value: store.state.view,
2579
2363
  children: [
2580
- /* @__PURE__ */ jsxs9(MenubarRadioItem, {
2364
+ /* @__PURE__ */ jsxs8(MenubarRadioItem, {
2581
2365
  value: "table",
2582
2366
  children: [
2583
- /* @__PURE__ */ jsx17(Rows3, {}),
2367
+ /* @__PURE__ */ jsx14(Rows3, {}),
2584
2368
  " ",
2585
2369
  store.config.labels.tableView
2586
2370
  ]
2587
2371
  }),
2588
- /* @__PURE__ */ jsxs9(MenubarRadioItem, {
2372
+ /* @__PURE__ */ jsxs8(MenubarRadioItem, {
2589
2373
  value: "gallery",
2590
2374
  children: [
2591
- /* @__PURE__ */ jsx17(LayoutGrid, {}),
2375
+ /* @__PURE__ */ jsx14(LayoutGrid, {}),
2592
2376
  " ",
2593
2377
  store.config.labels.galleryView
2594
2378
  ]
@@ -2606,27 +2390,27 @@ var ColumnMenu = ({
2606
2390
  const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
2607
2391
  if (!columns.length)
2608
2392
  return null;
2609
- return /* @__PURE__ */ jsxs9(MenubarMenu, {
2393
+ return /* @__PURE__ */ jsxs8(MenubarMenu, {
2610
2394
  children: [
2611
- /* @__PURE__ */ jsxs9(MenubarTrigger, {
2395
+ /* @__PURE__ */ jsxs8(MenubarTrigger, {
2612
2396
  "aria-label": store.config.labels.columns,
2613
2397
  children: [
2614
- /* @__PURE__ */ jsx17(Settings2, {}),
2615
- /* @__PURE__ */ jsx17("span", {
2398
+ /* @__PURE__ */ jsx14(Settings2, {}),
2399
+ /* @__PURE__ */ jsx14("span", {
2616
2400
  className: "hidden sm:inline",
2617
2401
  children: store.config.labels.columns
2618
2402
  })
2619
2403
  ]
2620
2404
  }),
2621
- /* @__PURE__ */ jsx17(MenubarContent, {
2405
+ /* @__PURE__ */ jsx14(MenubarContent, {
2622
2406
  align: "end",
2623
- children: /* @__PURE__ */ jsxs9(MenubarGroup, {
2407
+ children: /* @__PURE__ */ jsxs8(MenubarGroup, {
2624
2408
  children: [
2625
- /* @__PURE__ */ jsx17(MenubarLabel, {
2409
+ /* @__PURE__ */ jsx14(MenubarLabel, {
2626
2410
  children: store.config.labels.columns
2627
2411
  }),
2628
- /* @__PURE__ */ jsx17(MenubarSeparator, {}),
2629
- columns.map((column) => /* @__PURE__ */ jsx17(MenubarCheckboxItem, {
2412
+ /* @__PURE__ */ jsx14(MenubarSeparator, {}),
2413
+ columns.map((column) => /* @__PURE__ */ jsx14(MenubarCheckboxItem, {
2630
2414
  checked: store.state.columnVisibility[column.id] !== false,
2631
2415
  onCheckedChange: (visible) => changeState(setStore, (state) => ({
2632
2416
  ...state,
@@ -2648,6 +2432,7 @@ var ResizeHandle = ({
2648
2432
  }) => {
2649
2433
  const [store, setStore] = useTableAtom(tableAtom);
2650
2434
  const columnId = useRequiredId(ColumnIdContext);
2435
+ const resizeRef = useRef(null);
2651
2436
  const column = deriveModel(store).columns.find(({ id }) => id === columnId);
2652
2437
  if (!column || column.colDef.resizable === false)
2653
2438
  return null;
@@ -2659,25 +2444,32 @@ var ResizeHandle = ({
2659
2444
  }
2660
2445
  }));
2661
2446
  const onPointerDown = (event) => {
2447
+ if (event.button !== 0)
2448
+ return;
2662
2449
  event.preventDefault();
2663
2450
  event.currentTarget.setPointerCapture(event.pointerId);
2664
- event.currentTarget.dataset.startX = String(event.clientX);
2665
- event.currentTarget.dataset.startWidth = String(column.width);
2451
+ resizeRef.current = {
2452
+ pointerId: event.pointerId,
2453
+ startX: event.clientX,
2454
+ startWidth: column.width
2455
+ };
2666
2456
  };
2667
2457
  const onPointerMove = (event) => {
2668
- if (!event.currentTarget.hasPointerCapture(event.pointerId))
2458
+ const drag = resizeRef.current;
2459
+ if (!drag || drag.pointerId !== event.pointerId)
2669
2460
  return;
2670
- const startX = Number(event.currentTarget.dataset.startX);
2671
- const startWidth = Number(event.currentTarget.dataset.startWidth);
2672
- resize(startWidth + event.clientX - startX);
2461
+ resize(drag.startWidth + event.clientX - drag.startX);
2462
+ };
2463
+ const reset = () => {
2464
+ resizeRef.current = null;
2673
2465
  };
2674
- return /* @__PURE__ */ jsx17("button", {
2466
+ return /* @__PURE__ */ jsx14("button", {
2675
2467
  "aria-label": store.config.labels.resizeColumn(columnLabel(column)),
2676
2468
  "aria-orientation": "vertical",
2677
2469
  "aria-valuemax": column.colDef.maxWidth ?? DEFAULT_MAX_WIDTH,
2678
2470
  "aria-valuemin": column.colDef.minWidth ?? DEFAULT_MIN_WIDTH,
2679
2471
  "aria-valuenow": column.width,
2680
- className: "hover:bg-primary/60 absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize touch-none",
2472
+ className: "after:bg-border hover:after:bg-primary/60 focus-visible:after:bg-ring absolute inset-y-0 right-0 z-10 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-3 after:right-0 after:w-px hover:after:w-0.5 focus-visible:after:w-0.5",
2681
2473
  onDoubleClick: () => resize(column.colDef.width ?? DEFAULT_WIDTH),
2682
2474
  onKeyDown: (event) => {
2683
2475
  const delta = event.key === "ArrowLeft" ? -8 : event.key === "ArrowRight" ? 8 : 0;
@@ -2688,6 +2480,9 @@ var ResizeHandle = ({
2688
2480
  },
2689
2481
  onPointerDown,
2690
2482
  onPointerMove,
2483
+ onPointerUp: reset,
2484
+ onPointerCancel: reset,
2485
+ onLostPointerCapture: reset,
2691
2486
  role: "separator",
2692
2487
  type: "button"
2693
2488
  });
@@ -2697,7 +2492,7 @@ var DragHandle = ({
2697
2492
  }) => {
2698
2493
  const [store, setStore] = useTableAtom(tableAtom);
2699
2494
  const rowId = useRequiredId(RowIdContext);
2700
- const dragRef = useRef2(null);
2495
+ const dragRef = useRef(null);
2701
2496
  const [overlay, setOverlay] = useState(null);
2702
2497
  const reset = (element) => {
2703
2498
  clearDragPresentation(element.closest("[data-table-root]"));
@@ -2790,9 +2585,9 @@ var DragHandle = ({
2790
2585
  reordering.onReorder(reorderDataTableRows(model.rows, rowId, target.id));
2791
2586
  }
2792
2587
  };
2793
- return /* @__PURE__ */ jsxs9(Fragment, {
2588
+ return /* @__PURE__ */ jsxs8(Fragment, {
2794
2589
  children: [
2795
- /* @__PURE__ */ jsx17(Button, {
2590
+ /* @__PURE__ */ jsx14(Button, {
2796
2591
  "aria-label": store.config.features.reordering && store.config.features.reordering.handleLabel ? store.config.features.reordering.handleLabel : store.config.labels.reorder,
2797
2592
  className: "size-8 cursor-grab touch-none active:cursor-grabbing",
2798
2593
  onClick: (event) => event.stopPropagation(),
@@ -2810,9 +2605,9 @@ var DragHandle = ({
2810
2605
  onPointerUp: finish,
2811
2606
  size: "icon",
2812
2607
  variant: "ghost",
2813
- children: /* @__PURE__ */ jsx17(GripVertical, {})
2608
+ children: /* @__PURE__ */ jsx14(GripVertical, {})
2814
2609
  }),
2815
- overlay ? createPortal(/* @__PURE__ */ jsx17("div", {
2610
+ overlay ? createPortal(/* @__PURE__ */ jsx14("div", {
2816
2611
  "aria-hidden": "true",
2817
2612
  className: "bg-background pointer-events-none fixed z-[100] rounded-md border px-3 py-2 text-sm shadow-lg",
2818
2613
  style: { left: overlay.x + 12, top: overlay.y + 12 },
@@ -2842,7 +2637,7 @@ var TableDataRow = ({
2842
2637
  const selection = store.config.features.selection;
2843
2638
  const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
2844
2639
  const draggable = canDragRows(store);
2845
- return /* @__PURE__ */ jsxs9(TableRow, {
2640
+ return /* @__PURE__ */ jsxs8(TableRow, {
2846
2641
  className: cn("group/row h-16 data-[drag-source=true]:opacity-40 data-[drop-position=before]:[&>td]:border-t-2 data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-b-2 data-[drop-position=after]:[&>td]:border-primary", store.config.onRowClicked && "cursor-pointer"),
2847
2642
  "data-state": store.state.rowSelection[row.id] && "selected",
2848
2643
  "data-table-row": row.id,
@@ -2855,36 +2650,36 @@ var TableDataRow = ({
2855
2650
  },
2856
2651
  tabIndex: store.config.onRowClicked ? 0 : undefined,
2857
2652
  children: [
2858
- selection ? /* @__PURE__ */ jsx17(TableCell, {
2653
+ selection ? /* @__PURE__ */ jsx14(TableCell, {
2859
2654
  className: "w-10 pr-0",
2860
2655
  onClick: (event) => event.stopPropagation(),
2861
- children: /* @__PURE__ */ jsx17(Checkbox, {
2656
+ children: /* @__PURE__ */ jsx14(Checkbox, {
2862
2657
  "aria-label": store.config.labels.selectRow,
2863
2658
  checked: !!store.state.rowSelection[row.id],
2864
2659
  disabled: !selectable,
2865
2660
  onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked)
2866
2661
  })
2867
2662
  }) : null,
2868
- draggable ? /* @__PURE__ */ jsx17(TableCell, {
2663
+ draggable ? /* @__PURE__ */ jsx14(TableCell, {
2869
2664
  className: "w-10 pr-0",
2870
- children: /* @__PURE__ */ jsx17(DragHandle, {
2665
+ children: /* @__PURE__ */ jsx14(DragHandle, {
2871
2666
  tableAtom
2872
2667
  })
2873
2668
  }) : null,
2874
- model.visibleColumns.map((column) => /* @__PURE__ */ jsx17(TableCell, {
2875
- className: cn("min-w-24 overflow-hidden has-[[data-slot=data-table-relationship-cell]]:relative has-[[data-slot=data-table-relationship-cell]]:p-0", column.colDef.truncate ? "whitespace-nowrap" : "whitespace-normal"),
2669
+ model.visibleColumns.map((column) => /* @__PURE__ */ jsx14(TableCell, {
2670
+ className: cn("min-w-24 overflow-hidden has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:p-0 has-[[data-slot=data-table-boolean-cell]]:relative has-[[data-slot=data-table-boolean-cell]]:p-0", column.colDef.truncate ? "whitespace-nowrap" : "whitespace-normal"),
2876
2671
  style: { width: column.width },
2877
- children: /* @__PURE__ */ jsx17("div", {
2672
+ children: /* @__PURE__ */ jsx14("div", {
2878
2673
  className: cn("min-w-0", column.colDef.truncate && "truncate"),
2879
2674
  children: renderCell(row, column)
2880
2675
  })
2881
2676
  }, column.id)),
2882
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx17(TableCell, {
2677
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx14(TableCell, {
2883
2678
  className: "bg-background group-data-[state=selected]/row:bg-muted sticky right-0 z-20 w-10 min-w-10 cursor-default p-0 transition-colors group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--background))]",
2884
2679
  onClick: (event) => event.stopPropagation(),
2885
- children: /* @__PURE__ */ jsx17("div", {
2680
+ children: /* @__PURE__ */ jsx14("div", {
2886
2681
  className: "flex h-16 items-center justify-center",
2887
- children: /* @__PURE__ */ jsx17(DataTableRowActionMenu, {
2682
+ children: /* @__PURE__ */ jsx14(DataTableRowActionMenu, {
2888
2683
  tableAtom
2889
2684
  })
2890
2685
  })
@@ -2900,26 +2695,26 @@ var GroupActions = ({
2900
2695
  const visible = actions?.filter((action) => !action.visible || action.visible(groupId));
2901
2696
  if (!visible?.length)
2902
2697
  return null;
2903
- return /* @__PURE__ */ jsxs9(DropdownMenu, {
2698
+ return /* @__PURE__ */ jsxs8(DropdownMenu, {
2904
2699
  children: [
2905
- /* @__PURE__ */ jsx17(DropdownMenuTrigger, {
2700
+ /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
2906
2701
  onClick: (event) => event.stopPropagation(),
2907
- render: /* @__PURE__ */ jsxs9(Button, {
2702
+ render: /* @__PURE__ */ jsxs8(Button, {
2908
2703
  size: "icon",
2909
2704
  variant: "ghost",
2910
2705
  children: [
2911
- /* @__PURE__ */ jsx17("span", {
2706
+ /* @__PURE__ */ jsx14("span", {
2912
2707
  className: "sr-only",
2913
2708
  children: title
2914
2709
  }),
2915
- /* @__PURE__ */ jsx17(MoreHorizontal, {})
2710
+ /* @__PURE__ */ jsx14(MoreHorizontal, {})
2916
2711
  ]
2917
2712
  })
2918
2713
  }),
2919
- /* @__PURE__ */ jsx17(DropdownMenuContent, {
2714
+ /* @__PURE__ */ jsx14(DropdownMenuContent, {
2920
2715
  align: "end",
2921
- children: /* @__PURE__ */ jsx17(DropdownMenuGroup, {
2922
- children: visible.map((action) => /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2716
+ children: /* @__PURE__ */ jsx14(DropdownMenuGroup, {
2717
+ children: visible.map((action) => /* @__PURE__ */ jsxs8(DropdownMenuItem, {
2923
2718
  onClick: () => action.onClick(groupId),
2924
2719
  variant: action.variant,
2925
2720
  children: [
@@ -2950,40 +2745,40 @@ var GroupedTable = ({
2950
2745
  [section.key]: !collapsed
2951
2746
  }
2952
2747
  }));
2953
- const body = /* @__PURE__ */ jsxs9(TableBody, {
2748
+ const body = /* @__PURE__ */ jsxs8(TableBody, {
2954
2749
  className: "data-[drop-target=true]:outline-primary relative data-[drop-target=true]:z-30 data-[drop-target=true]:outline-2 data-[drop-target=true]:-outline-offset-2 data-[drop-target=true]:[&>tr]:border-transparent data-[drop-target=true]:[&>tr>td:last-child]:z-0",
2955
2750
  "data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
2956
2751
  children: [
2957
- /* @__PURE__ */ jsx17(TableRow, {
2752
+ /* @__PURE__ */ jsx14(TableRow, {
2958
2753
  className: "bg-muted/40 hover:bg-accent! cursor-pointer",
2959
2754
  onClick: toggleCollapsed,
2960
- children: /* @__PURE__ */ jsx17(TableCell, {
2755
+ children: /* @__PURE__ */ jsx14(TableCell, {
2961
2756
  colSpan: model.visibleColumns.length + extra,
2962
- children: /* @__PURE__ */ jsxs9("div", {
2757
+ children: /* @__PURE__ */ jsxs8("div", {
2963
2758
  className: "flex items-center gap-2",
2964
2759
  style: { paddingLeft: section.depth * 20 },
2965
2760
  children: [
2966
- /* @__PURE__ */ jsxs9("button", {
2761
+ /* @__PURE__ */ jsxs8("button", {
2967
2762
  "aria-expanded": !collapsed,
2968
2763
  className: "flex flex-1 cursor-pointer items-center gap-2 text-left font-medium",
2969
2764
  type: "button",
2970
2765
  children: [
2971
- collapsed ? /* @__PURE__ */ jsx17(ChevronRight2, {
2766
+ collapsed ? /* @__PURE__ */ jsx14(ChevronRight2, {
2972
2767
  className: "size-4"
2973
- }) : /* @__PURE__ */ jsx17(ChevronDown, {
2768
+ }) : /* @__PURE__ */ jsx14(ChevronDown, {
2974
2769
  className: "size-4"
2975
2770
  }),
2976
- /* @__PURE__ */ jsx17("span", {
2771
+ /* @__PURE__ */ jsx14("span", {
2977
2772
  className: "flex-1",
2978
2773
  children: section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.data)) ?? section.groupId
2979
2774
  })
2980
2775
  ]
2981
2776
  }),
2982
- /* @__PURE__ */ jsx17(Badge, {
2777
+ /* @__PURE__ */ jsx14(Badge, {
2983
2778
  variant: "secondary",
2984
2779
  children: section.rows.length
2985
2780
  }),
2986
- /* @__PURE__ */ jsx17(GroupActions, {
2781
+ /* @__PURE__ */ jsx14(GroupActions, {
2987
2782
  actions: section.field.actions,
2988
2783
  groupId: section.groupId,
2989
2784
  title: section.field.actionsLabel ?? store.config.labels.actions
@@ -2992,14 +2787,14 @@ var GroupedTable = ({
2992
2787
  })
2993
2788
  })
2994
2789
  }),
2995
- !collapsed && !section.children.length ? section.rows.length ? section.rows.map((row) => /* @__PURE__ */ jsx17(RowIdContext.Provider, {
2790
+ !collapsed && !section.children.length ? section.rows.length ? section.rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
2996
2791
  value: row.id,
2997
- children: /* @__PURE__ */ jsx17(TableDataRow, {
2792
+ children: /* @__PURE__ */ jsx14(TableDataRow, {
2998
2793
  tableAtom
2999
2794
  })
3000
2795
  }, `${section.key}:${row.id}`)) : [
3001
- /* @__PURE__ */ jsx17(TableRow, {
3002
- children: /* @__PURE__ */ jsx17(TableCell, {
2796
+ /* @__PURE__ */ jsx14(TableRow, {
2797
+ children: /* @__PURE__ */ jsx14(TableCell, {
3003
2798
  className: "text-muted-foreground h-16",
3004
2799
  colSpan: model.visibleColumns.length + extra,
3005
2800
  children: section.field.renderEmptyGroup?.(section.groupId) ?? store.config.labels.empty
@@ -3010,7 +2805,7 @@ var GroupedTable = ({
3010
2805
  }, section.key);
3011
2806
  return !collapsed && section.children.length ? [body, renderSections(section.children)] : [body];
3012
2807
  });
3013
- return /* @__PURE__ */ jsx17(Fragment, {
2808
+ return /* @__PURE__ */ jsx14(Fragment, {
3014
2809
  children: renderSections(sections)
3015
2810
  });
3016
2811
  };
@@ -3033,66 +2828,65 @@ var ColumnHeaderMenu = ({
3033
2828
  }));
3034
2829
  const label = columnLabel(column);
3035
2830
  if (!sortingEnabled && !hidingEnabled) {
3036
- return /* @__PURE__ */ jsx17("div", {
3037
- className: "truncate",
2831
+ return /* @__PURE__ */ jsx14("div", {
2832
+ className: "truncate px-2",
3038
2833
  children: column.colDef.headerName
3039
2834
  });
3040
2835
  }
3041
- return /* @__PURE__ */ jsxs9(DropdownMenu, {
2836
+ return /* @__PURE__ */ jsxs8(DropdownMenu, {
3042
2837
  children: [
3043
- /* @__PURE__ */ jsx17(DropdownMenuTrigger, {
3044
- render: /* @__PURE__ */ jsxs9(Button, {
2838
+ /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
2839
+ render: /* @__PURE__ */ jsxs8(Button, {
3045
2840
  "aria-label": label,
3046
- className: "h-8 max-w-full justify-start px-2",
3047
- size: "sm",
2841
+ className: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pr-4 focus-visible:ring-inset",
3048
2842
  variant: "ghost",
3049
2843
  children: [
3050
- /* @__PURE__ */ jsx17("span", {
2844
+ /* @__PURE__ */ jsx14("span", {
3051
2845
  className: "truncate",
3052
2846
  children: column.colDef.headerName
3053
2847
  }),
3054
- sort ? sort.direction === "desc" ? /* @__PURE__ */ jsx17(ArrowDown, {}) : /* @__PURE__ */ jsx17(ArrowUp, {}) : sortingEnabled ? /* @__PURE__ */ jsx17(ChevronsUpDown2, {}) : null
2848
+ sort ? sort.direction === "desc" ? /* @__PURE__ */ jsx14(ArrowDown, {}) : /* @__PURE__ */ jsx14(ArrowUp, {}) : null
3055
2849
  ]
3056
2850
  })
3057
2851
  }),
3058
- /* @__PURE__ */ jsx17(DropdownMenuContent, {
2852
+ /* @__PURE__ */ jsx14(DropdownMenuContent, {
3059
2853
  align: "start",
3060
2854
  className: "w-48",
3061
- children: /* @__PURE__ */ jsxs9(DropdownMenuGroup, {
2855
+ children: /* @__PURE__ */ jsxs8(DropdownMenuGroup, {
3062
2856
  children: [
3063
- sortingEnabled ? /* @__PURE__ */ jsxs9(Fragment, {
2857
+ sortingEnabled ? /* @__PURE__ */ jsxs8(Fragment, {
3064
2858
  children: [
3065
- /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2859
+ /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3066
2860
  onClick: () => setSort("asc"),
3067
2861
  children: [
3068
- /* @__PURE__ */ jsx17(ArrowUp, {}),
2862
+ /* @__PURE__ */ jsx14(ArrowUp, {}),
3069
2863
  " ",
3070
2864
  store.config.labels.sortAsc
3071
2865
  ]
3072
2866
  }),
3073
- /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2867
+ /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3074
2868
  onClick: () => setSort("desc"),
3075
2869
  children: [
3076
- /* @__PURE__ */ jsx17(ArrowDown, {}),
2870
+ /* @__PURE__ */ jsx14(ArrowDown, {}),
3077
2871
  " ",
3078
2872
  store.config.labels.sortDesc
3079
2873
  ]
3080
2874
  }),
3081
- sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2875
+ sort ? /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3082
2876
  onClick: () => update((state) => ({
3083
2877
  ...state,
3084
2878
  sort: state.sort?.filter(({ id }) => id !== column.id)
3085
2879
  })),
3086
2880
  children: [
3087
- /* @__PURE__ */ jsx17(X2, {}),
2881
+ /* @__PURE__ */ jsx14(X, {}),
3088
2882
  " ",
3089
2883
  store.config.labels.sortClear
3090
2884
  ]
3091
2885
  }) : null
3092
2886
  ]
3093
2887
  }) : null,
3094
- sortingEnabled && hidingEnabled ? /* @__PURE__ */ jsx17(DropdownMenuSeparator, {}) : null,
3095
- hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem, {
2888
+ sortingEnabled && hidingEnabled ? /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}) : null,
2889
+ hidingEnabled ? /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3096
2890
  onClick: () => update((state) => ({
3097
2891
  ...state,
3098
2892
  columnVisibility: {
@@ -3101,7 +2895,7 @@ var ColumnHeaderMenu = ({
3101
2895
  }
3102
2896
  })),
3103
2897
  children: [
3104
- /* @__PURE__ */ jsx17(EyeOff, {}),
2898
+ /* @__PURE__ */ jsx14(EyeOff, {}),
3105
2899
  " ",
3106
2900
  store.config.labels.hideColumn
3107
2901
  ]
@@ -3123,12 +2917,12 @@ var DataTableHeader = ({
3123
2917
  const selectableRows = getDataTableSelectableRows(model, grouped, selection ? selection.isRowSelectable : undefined);
3124
2918
  const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
3125
2919
  const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
3126
- return /* @__PURE__ */ jsx17(TableHeader, {
3127
- children: /* @__PURE__ */ jsxs9(TableRow, {
2920
+ return /* @__PURE__ */ jsx14(TableHeader, {
2921
+ children: /* @__PURE__ */ jsxs8(TableRow, {
3128
2922
  children: [
3129
- selection ? /* @__PURE__ */ jsx17(TableHead, {
2923
+ selection ? /* @__PURE__ */ jsx14(TableHead, {
3130
2924
  className: "w-10 pr-0",
3131
- children: /* @__PURE__ */ jsx17(Checkbox, {
2925
+ children: /* @__PURE__ */ jsx14(Checkbox, {
3132
2926
  "aria-label": store.config.labels.selectAllRows,
3133
2927
  checked: allSelected,
3134
2928
  indeterminate: someSelected && !allSelected,
@@ -3142,27 +2936,30 @@ var DataTableHeader = ({
3142
2936
  }
3143
2937
  })
3144
2938
  }) : null,
3145
- draggable ? /* @__PURE__ */ jsx17(TableHead, {
2939
+ draggable ? /* @__PURE__ */ jsx14(TableHead, {
3146
2940
  className: "w-10"
3147
2941
  }) : null,
3148
2942
  model.visibleColumns.map((column) => {
3149
- return /* @__PURE__ */ jsx17(TableHead, {
3150
- className: "relative h-12",
2943
+ const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
2944
+ return /* @__PURE__ */ jsx14(TableHead, {
2945
+ "aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
2946
+ className: "relative h-12 p-0",
2947
+ scope: "col",
3151
2948
  style: { width: column.width },
3152
- children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
2949
+ children: /* @__PURE__ */ jsxs8(ColumnIdContext.Provider, {
3153
2950
  value: column.id,
3154
2951
  children: [
3155
- /* @__PURE__ */ jsx17(ColumnHeaderMenu, {
2952
+ /* @__PURE__ */ jsx14(ColumnHeaderMenu, {
3156
2953
  tableAtom
3157
2954
  }),
3158
- /* @__PURE__ */ jsx17(ResizeHandle, {
2955
+ /* @__PURE__ */ jsx14(ResizeHandle, {
3159
2956
  tableAtom
3160
2957
  })
3161
2958
  ]
3162
2959
  })
3163
2960
  }, column.id);
3164
2961
  }),
3165
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx17(TableHead, {
2962
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx14(TableHead, {
3166
2963
  className: "w-10"
3167
2964
  }) : null
3168
2965
  ]
@@ -3178,28 +2975,28 @@ var DataTableBody = ({
3178
2975
  const rows = grouped ? model.sortedRows : model.pageRows;
3179
2976
  const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
3180
2977
  if (grouped && rows.length && !store.config.status.error) {
3181
- return /* @__PURE__ */ jsx17(GroupedTable, {
2978
+ return /* @__PURE__ */ jsx14(GroupedTable, {
3182
2979
  tableAtom
3183
2980
  });
3184
2981
  }
3185
- return /* @__PURE__ */ jsx17(TableBody, {
3186
- children: store.config.status.error || !rows.length && !store.config.status.loading ? /* @__PURE__ */ jsx17(TableRow, {
3187
- children: /* @__PURE__ */ jsx17(TableCell, {
2982
+ return /* @__PURE__ */ jsx14(TableBody, {
2983
+ children: store.config.status.error || !rows.length && !store.config.status.loading ? /* @__PURE__ */ jsx14(TableRow, {
2984
+ children: /* @__PURE__ */ jsx14(TableCell, {
3188
2985
  className: "h-24 text-center",
3189
2986
  colSpan: Math.max(colSpan, 1),
3190
2987
  children: store.config.status.error ?? store.config.status.empty ?? store.config.labels.empty
3191
2988
  })
3192
- }) : store.config.status.loading && !rows.length ? /* @__PURE__ */ jsx17(TableRow, {
3193
- children: /* @__PURE__ */ jsx17(TableCell, {
2989
+ }) : store.config.status.loading && !rows.length ? /* @__PURE__ */ jsx14(TableRow, {
2990
+ children: /* @__PURE__ */ jsx14(TableCell, {
3194
2991
  className: "h-24 text-center",
3195
2992
  colSpan: Math.max(colSpan, 1),
3196
- children: /* @__PURE__ */ jsx17(Loading, {
2993
+ children: /* @__PURE__ */ jsx14(Loading, {
3197
2994
  label: store.config.labels.loading
3198
2995
  })
3199
2996
  })
3200
- }) : rows.map((row) => /* @__PURE__ */ jsx17(RowIdContext.Provider, {
2997
+ }) : rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
3201
2998
  value: row.id,
3202
- children: /* @__PURE__ */ jsx17(TableDataRow, {
2999
+ children: /* @__PURE__ */ jsx14(TableDataRow, {
3203
3000
  tableAtom
3204
3001
  })
3205
3002
  }, row.id))
@@ -3222,7 +3019,7 @@ var GalleryCard = ({
3222
3019
  const selection = store.config.features.selection;
3223
3020
  const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
3224
3021
  const draggable = canDragRows(store);
3225
- return /* @__PURE__ */ jsx17(Card, {
3022
+ return /* @__PURE__ */ jsx14(Card, {
3226
3023
  className: cn("relative gap-3 data-[drag-source=true]:opacity-40 data-[drop-position=before]:border-t-2 data-[drop-position=before]:border-t-primary data-[drop-position=after]:border-b-2 data-[drop-position=after]:border-b-primary", store.config.onRowClicked && "cursor-pointer"),
3227
3024
  "data-table-row": row.id,
3228
3025
  onClick: () => store.config.onRowClicked?.(row.data),
@@ -3233,23 +3030,23 @@ var GalleryCard = ({
3233
3030
  }
3234
3031
  },
3235
3032
  tabIndex: store.config.onRowClicked ? 0 : undefined,
3236
- children: /* @__PURE__ */ jsxs9(CardHeader, {
3033
+ children: /* @__PURE__ */ jsxs8(CardHeader, {
3237
3034
  className: "pr-12",
3238
3035
  children: [
3239
- /* @__PURE__ */ jsxs9("div", {
3036
+ /* @__PURE__ */ jsxs8("div", {
3240
3037
  className: "flex items-center gap-2",
3241
3038
  children: [
3242
- selection ? /* @__PURE__ */ jsx17(Checkbox, {
3039
+ selection ? /* @__PURE__ */ jsx14(Checkbox, {
3243
3040
  "aria-label": store.config.labels.selectRow,
3244
3041
  checked: !!store.state.rowSelection[row.id],
3245
3042
  disabled: !selectable,
3246
3043
  onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
3247
3044
  onClick: (event) => event.stopPropagation()
3248
3045
  }) : null,
3249
- draggable ? /* @__PURE__ */ jsx17(DragHandle, {
3046
+ draggable ? /* @__PURE__ */ jsx14(DragHandle, {
3250
3047
  tableAtom
3251
3048
  }) : null,
3252
- tag ? /* @__PURE__ */ jsxs9(Badge, {
3049
+ tag ? /* @__PURE__ */ jsxs8(Badge, {
3253
3050
  variant: "secondary",
3254
3051
  children: [
3255
3052
  gallery.tagIcon,
@@ -3258,17 +3055,17 @@ var GalleryCard = ({
3258
3055
  }) : null
3259
3056
  ]
3260
3057
  }),
3261
- /* @__PURE__ */ jsx17(CardTitle, {
3058
+ /* @__PURE__ */ jsx14(CardTitle, {
3262
3059
  children: name ? renderCell(row, name) : row.id
3263
3060
  }),
3264
- description ? /* @__PURE__ */ jsx17("div", {
3061
+ description ? /* @__PURE__ */ jsx14("div", {
3265
3062
  className: "text-muted-foreground line-clamp-3 text-sm",
3266
3063
  children: renderCell(row, description)
3267
3064
  }) : null,
3268
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx17("div", {
3065
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx14("div", {
3269
3066
  className: "absolute top-4 right-4",
3270
3067
  onClick: (event) => event.stopPropagation(),
3271
- children: /* @__PURE__ */ jsx17(DataTableRowActionMenu, {
3068
+ children: /* @__PURE__ */ jsx14(DataTableRowActionMenu, {
3272
3069
  tableAtom
3273
3070
  })
3274
3071
  }) : null
@@ -3284,31 +3081,31 @@ var DataTableGallery = ({
3284
3081
  const fields = getActiveGrouping(store);
3285
3082
  const rows = fields.length ? model.sortedRows : model.pageRows;
3286
3083
  if (store.config.status.error) {
3287
- return /* @__PURE__ */ jsx17("div", {
3084
+ return /* @__PURE__ */ jsx14("div", {
3288
3085
  className: "text-destructive rounded-lg border border-dashed p-10 text-center",
3289
3086
  children: store.config.status.error
3290
3087
  });
3291
3088
  }
3292
3089
  if (store.config.status.loading && !rows.length) {
3293
- return /* @__PURE__ */ jsx17("div", {
3090
+ return /* @__PURE__ */ jsx14("div", {
3294
3091
  className: "rounded-lg border border-dashed p-10 text-center",
3295
- children: /* @__PURE__ */ jsx17(Loading, {
3092
+ children: /* @__PURE__ */ jsx14(Loading, {
3296
3093
  label: store.config.labels.loading
3297
3094
  })
3298
3095
  });
3299
3096
  }
3300
3097
  if (!rows.length) {
3301
- return /* @__PURE__ */ jsx17("div", {
3098
+ return /* @__PURE__ */ jsx14("div", {
3302
3099
  className: "text-muted-foreground rounded-lg border border-dashed p-10 text-center",
3303
3100
  children: store.config.status.empty ?? store.config.labels.empty
3304
3101
  });
3305
3102
  }
3306
3103
  if (!fields.length) {
3307
- return /* @__PURE__ */ jsx17("div", {
3104
+ return /* @__PURE__ */ jsx14("div", {
3308
3105
  className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3",
3309
- children: rows.map((row) => /* @__PURE__ */ jsx17(RowIdContext.Provider, {
3106
+ children: rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
3310
3107
  value: row.id,
3311
- children: /* @__PURE__ */ jsx17(GalleryCard, {
3108
+ children: /* @__PURE__ */ jsx14(GalleryCard, {
3312
3109
  tableAtom
3313
3110
  })
3314
3111
  }, row.id))
@@ -3324,57 +3121,57 @@ var DataTableGallery = ({
3324
3121
  [section.key]: !collapsed
3325
3122
  }
3326
3123
  }));
3327
- return /* @__PURE__ */ jsxs9("section", {
3124
+ return /* @__PURE__ */ jsxs8("section", {
3328
3125
  className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
3329
3126
  "data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
3330
3127
  children: [
3331
- /* @__PURE__ */ jsxs9("div", {
3128
+ /* @__PURE__ */ jsxs8("div", {
3332
3129
  className: "hover:bg-accent flex cursor-pointer items-center gap-2 rounded-lg border p-3 transition-colors",
3333
3130
  onClick: toggleCollapsed,
3334
3131
  children: [
3335
- /* @__PURE__ */ jsxs9("button", {
3132
+ /* @__PURE__ */ jsxs8("button", {
3336
3133
  "aria-expanded": !collapsed,
3337
3134
  className: "flex flex-1 cursor-pointer items-center gap-2 text-left font-medium",
3338
3135
  type: "button",
3339
3136
  children: [
3340
- collapsed ? /* @__PURE__ */ jsx17(ChevronRight2, {
3137
+ collapsed ? /* @__PURE__ */ jsx14(ChevronRight2, {
3341
3138
  className: "size-4"
3342
- }) : /* @__PURE__ */ jsx17(ChevronDown, {
3139
+ }) : /* @__PURE__ */ jsx14(ChevronDown, {
3343
3140
  className: "size-4"
3344
3141
  }),
3345
- /* @__PURE__ */ jsx17("span", {
3142
+ /* @__PURE__ */ jsx14("span", {
3346
3143
  className: "flex-1",
3347
3144
  children: section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.data)) ?? section.groupId
3348
3145
  }),
3349
- /* @__PURE__ */ jsx17(Badge, {
3146
+ /* @__PURE__ */ jsx14(Badge, {
3350
3147
  variant: "secondary",
3351
3148
  children: section.rows.length
3352
3149
  })
3353
3150
  ]
3354
3151
  }),
3355
- /* @__PURE__ */ jsx17(GroupActions, {
3152
+ /* @__PURE__ */ jsx14(GroupActions, {
3356
3153
  actions: section.field.actions,
3357
3154
  groupId: section.groupId,
3358
3155
  title: section.field.actionsLabel ?? store.config.labels.actions
3359
3156
  })
3360
3157
  ]
3361
3158
  }),
3362
- !collapsed ? section.children.length ? renderSections(section.children) : section.rows.length ? /* @__PURE__ */ jsx17("div", {
3159
+ !collapsed ? section.children.length ? renderSections(section.children) : section.rows.length ? /* @__PURE__ */ jsx14("div", {
3363
3160
  className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3",
3364
- children: section.rows.map((row) => /* @__PURE__ */ jsx17(RowIdContext.Provider, {
3161
+ children: section.rows.map((row) => /* @__PURE__ */ jsx14(RowIdContext.Provider, {
3365
3162
  value: row.id,
3366
- children: /* @__PURE__ */ jsx17(GalleryCard, {
3163
+ children: /* @__PURE__ */ jsx14(GalleryCard, {
3367
3164
  tableAtom
3368
3165
  })
3369
3166
  }, `${section.key}:${row.id}`))
3370
- }) : /* @__PURE__ */ jsx17("div", {
3167
+ }) : /* @__PURE__ */ jsx14("div", {
3371
3168
  className: "text-muted-foreground rounded-lg border border-dashed p-8 text-center",
3372
3169
  children: section.field.renderEmptyGroup?.(section.groupId) ?? store.config.labels.empty
3373
3170
  }) : null
3374
3171
  ]
3375
3172
  }, section.key);
3376
3173
  });
3377
- return /* @__PURE__ */ jsx17("div", {
3174
+ return /* @__PURE__ */ jsx14("div", {
3378
3175
  className: "space-y-4",
3379
3176
  children: renderSections(groupDataTableRows(rows, fields))
3380
3177
  });
@@ -3401,9 +3198,9 @@ var DataTablePagination = ({
3401
3198
  return null;
3402
3199
  const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
3403
3200
  const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
3404
- return /* @__PURE__ */ jsx17("div", {
3201
+ return /* @__PURE__ */ jsx14("div", {
3405
3202
  className: "pt-4",
3406
- children: /* @__PURE__ */ jsx17(Pagination, {
3203
+ children: /* @__PURE__ */ jsx14(Pagination, {
3407
3204
  messages: store.config.labels,
3408
3205
  onPageChange: (page) => setPagination({ page, pageSize: store.state.pageSize }),
3409
3206
  onPageSizeChange: (pageSize) => setPagination({ page: 0, pageSize }),
@@ -3421,7 +3218,7 @@ var HydratedDataTable = ({
3421
3218
  setPersistedUiState,
3422
3219
  ...props
3423
3220
  }) => {
3424
- const transientUiAtomRef = useRef2(null);
3221
+ const transientUiAtomRef = useRef(null);
3425
3222
  if (!transientUiAtomRef.current) {
3426
3223
  const grouping = props.features?.grouping;
3427
3224
  transientUiAtomRef.current = Atom.make({
@@ -3431,12 +3228,12 @@ var HydratedDataTable = ({
3431
3228
  }
3432
3229
  const [transientUiState, setTransientUiState] = useAtom(transientUiAtomRef.current);
3433
3230
  const uiState = useMemo(() => ({ ...persistedUiState, ...transientUiState }), [persistedUiState, transientUiState]);
3434
- const setUiState = useCallback2((state) => {
3231
+ const setUiState = useCallback((state) => {
3435
3232
  setPersistedUiState(persistedUiFromState(state));
3436
3233
  setTransientUiState(transientUiFromState(state));
3437
3234
  }, [setPersistedUiState, setTransientUiState]);
3438
3235
  const validatedConfig = resolveConfig(props, (state) => setUiState(state));
3439
- const atomRef = useRef2(null);
3236
+ const atomRef = useRef(null);
3440
3237
  if (!atomRef.current) {
3441
3238
  const initial = {
3442
3239
  rowData: props.rowData,
@@ -3491,24 +3288,24 @@ var HydratedDataTable = ({
3491
3288
  setUiState,
3492
3289
  uiState
3493
3290
  ]);
3494
- return /* @__PURE__ */ jsxs9("div", {
3291
+ return /* @__PURE__ */ jsxs8("div", {
3495
3292
  className: "w-full max-w-full min-w-0 rounded-md",
3496
3293
  "data-table-root": "",
3497
3294
  children: [
3498
- /* @__PURE__ */ jsx17(DataTableToolbar, {
3295
+ /* @__PURE__ */ jsx14(DataTableToolbar, {
3499
3296
  tableAtom
3500
3297
  }),
3501
- /* @__PURE__ */ jsx17(DataTableContent, {
3298
+ /* @__PURE__ */ jsx14(DataTableContent, {
3502
3299
  tableAtom
3503
3300
  }),
3504
- /* @__PURE__ */ jsx17(DataTablePagination, {
3301
+ /* @__PURE__ */ jsx14(DataTablePagination, {
3505
3302
  tableAtom
3506
3303
  })
3507
3304
  ]
3508
3305
  });
3509
3306
  };
3510
3307
  var DataTable = (props) => {
3511
- const persistedUiAtomRef = useRef2(null);
3308
+ const persistedUiAtomRef = useRef(null);
3512
3309
  if (!persistedUiAtomRef.current) {
3513
3310
  const pathname = globalThis.window?.location.pathname ?? "/";
3514
3311
  const columnIds = normalizeDataTableColumns(props.columnDefs).map(({ id }) => id).join(",");
@@ -3523,13 +3320,13 @@ var DataTable = (props) => {
3523
3320
  }
3524
3321
  const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtomRef.current);
3525
3322
  if (!AsyncResult.isSuccess(persistedUiResult) || AsyncResult.isWaiting(persistedUiResult)) {
3526
- return /* @__PURE__ */ jsx17("div", {
3323
+ return /* @__PURE__ */ jsx14("div", {
3527
3324
  "aria-busy": "true",
3528
3325
  className: "invisible w-full max-w-full min-w-0 rounded-md",
3529
3326
  "data-table-root": ""
3530
3327
  });
3531
3328
  }
3532
- return /* @__PURE__ */ jsx17(HydratedDataTable, {
3329
+ return /* @__PURE__ */ jsx14(HydratedDataTable, {
3533
3330
  ...props,
3534
3331
  persistedUiState: persistedUiResult.value,
3535
3332
  setPersistedUiState
@@ -3540,185 +3337,434 @@ var DataTableContent = ({
3540
3337
  }) => {
3541
3338
  const [store] = useTableAtom(tableAtom);
3542
3339
  if (store.config.features.gallery && store.state.view === "gallery") {
3543
- return /* @__PURE__ */ jsx17(DataTableGallery, {
3340
+ return /* @__PURE__ */ jsx14(DataTableGallery, {
3544
3341
  tableAtom
3545
3342
  });
3546
3343
  }
3547
3344
  const model = deriveModel(store);
3548
3345
  const width = getDataTableWidth(model.visibleColumns, (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0));
3549
- return /* @__PURE__ */ jsxs9(ScrollArea, {
3346
+ return /* @__PURE__ */ jsxs8(ScrollArea, {
3550
3347
  className: "max-w-full min-w-0",
3551
3348
  children: [
3552
- /* @__PURE__ */ jsxs9(Table, {
3349
+ /* @__PURE__ */ jsxs8(Table, {
3553
3350
  className: "table-fixed",
3554
3351
  style: { width: `max(100%, ${width}px)` },
3555
3352
  children: [
3556
- /* @__PURE__ */ jsx17(DataTableHeader, {
3353
+ /* @__PURE__ */ jsx14(DataTableHeader, {
3557
3354
  tableAtom
3558
3355
  }),
3559
- /* @__PURE__ */ jsx17(DataTableBody, {
3356
+ /* @__PURE__ */ jsx14(DataTableBody, {
3560
3357
  tableAtom
3561
3358
  })
3562
3359
  ]
3563
3360
  }),
3564
- /* @__PURE__ */ jsx17(ScrollBar, {
3361
+ /* @__PURE__ */ jsx14(ScrollBar, {
3565
3362
  orientation: "horizontal"
3566
3363
  })
3567
3364
  ]
3568
3365
  });
3569
3366
  };
3570
- var DataTableRelationshipCell = ({
3367
+ var DataTableListCell = (props) => {
3368
+ if (props.options && (props.onAdd || props.onRemove)) {
3369
+ return /* @__PURE__ */ jsx14(EditableDataTableListCell, {
3370
+ ...props
3371
+ });
3372
+ }
3373
+ const { actionsLabel, itemActions, ...summaryProps } = props;
3374
+ const totalCount = props.totalCount ?? props.items.length;
3375
+ const overflow = totalCount > Math.min(props.items.length, props.visibleCount ?? 3);
3376
+ if (!itemActions?.length && !overflow) {
3377
+ return /* @__PURE__ */ jsx14(DataTableListSummary, {
3378
+ ...summaryProps
3379
+ });
3380
+ }
3381
+ const menuLabel = actionsLabel ?? (itemActions?.length ? dataTableMessages().actions : dataTableMessages().listDetails);
3382
+ return /* @__PURE__ */ jsx14("div", {
3383
+ className: "grid min-h-16 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0",
3384
+ "data-slot": "data-table-list-cell",
3385
+ onClick: (event) => event.stopPropagation(),
3386
+ onPointerDown: (event) => event.stopPropagation(),
3387
+ children: /* @__PURE__ */ jsx14(DataTableListMenu, {
3388
+ actions: itemActions ?? [],
3389
+ display: props.display,
3390
+ force: overflow,
3391
+ label: menuLabel,
3392
+ items: props.items,
3393
+ trigger: /* @__PURE__ */ jsxs8(Button, {
3394
+ "aria-label": menuLabel,
3395
+ className: "h-full w-full min-w-0 justify-between rounded-none px-2 focus-visible:ring-inset",
3396
+ variant: "ghost",
3397
+ children: [
3398
+ /* @__PURE__ */ jsx14(DataTableListSummaryContent, {
3399
+ ...summaryProps,
3400
+ showMenu: false
3401
+ }),
3402
+ /* @__PURE__ */ jsx14(ChevronDown, {})
3403
+ ]
3404
+ })
3405
+ })
3406
+ });
3407
+ };
3408
+ var EditableDataTableListCell = ({
3571
3409
  emptyLabel,
3572
3410
  manageLabel,
3573
3411
  onAdd,
3574
3412
  onRemove,
3575
3413
  options,
3576
- value
3414
+ items,
3415
+ display,
3416
+ visibleCount,
3417
+ totalCount,
3418
+ actionsLabel,
3419
+ itemActions
3577
3420
  }) => {
3578
- const [selected, setSelected] = useState([...value]);
3579
- useLayoutEffect(() => setSelected([...value]), [value]);
3421
+ const [selected, setSelected] = useState([...items]);
3422
+ useLayoutEffect(() => setSelected([...items]), [items]);
3580
3423
  const selectedValues = new Set(selected.map((item) => item.value));
3581
- return /* @__PURE__ */ jsx17("div", {
3582
- "data-slot": "data-table-relationship-cell",
3583
- className: "h-full in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0",
3424
+ const available = options.filter((item) => !selectedValues.has(item.value));
3425
+ const canAdd = !!onAdd && available.length > 0;
3426
+ const selectedTotal = totalCount === undefined ? selected.length : totalCount + selected.length - items.length;
3427
+ const labels2 = dataTableMessages();
3428
+ const actions = [
3429
+ ...itemActions ?? [],
3430
+ ...onRemove ? [
3431
+ {
3432
+ id: "data-table-list-remove",
3433
+ closeOnClick: false,
3434
+ name: labels2.removeItem,
3435
+ icon: /* @__PURE__ */ jsx14(Trash2, {}),
3436
+ variant: "destructive",
3437
+ onClick: (item) => {
3438
+ if (item.value === undefined)
3439
+ return;
3440
+ onRemove(item.value);
3441
+ setSelected((current) => current.filter((candidate) => candidate.value !== item.value));
3442
+ }
3443
+ }
3444
+ ] : []
3445
+ ];
3446
+ return /* @__PURE__ */ jsx14("div", {
3447
+ "data-slot": "data-table-list-cell",
3448
+ className: "grid min-h-16 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0",
3584
3449
  onClick: (event) => event.stopPropagation(),
3585
3450
  onPointerDown: (event) => event.stopPropagation(),
3586
- children: /* @__PURE__ */ jsx17(VirtualizedCombobox, {
3587
- ariaLabel: manageLabel,
3588
- emptyLabel,
3589
- items: [...options].sort((left, right) => Number(selectedValues.has(right.value)) - Number(selectedValues.has(left.value))),
3590
- messages: { search: manageLabel },
3591
- multiple: true,
3592
- onValueChange: (next) => {
3593
- const nextValues = new Set(next.map((item) => item.value));
3594
- selected.forEach((item) => !nextValues.has(item.value) && onRemove?.(item.value));
3595
- next.forEach((item) => !selectedValues.has(item.value) && onAdd?.(item.value));
3596
- setSelected(next);
3597
- },
3598
- placeholder: emptyLabel,
3599
- trigger: /* @__PURE__ */ jsxs9(Button, {
3600
- className: "h-full min-h-16 w-full justify-between rounded-none",
3451
+ children: /* @__PURE__ */ jsx14(DataTableListMenu, {
3452
+ actions,
3453
+ addEmptyLabel: emptyLabel,
3454
+ addLabel: labels2.addItem,
3455
+ addOptions: canAdd ? available : undefined,
3456
+ addSearchLabel: manageLabel,
3457
+ display,
3458
+ force: true,
3459
+ items: selected,
3460
+ label: actionsLabel ?? manageLabel,
3461
+ onAdd: canAdd ? (item) => {
3462
+ onAdd(item.value);
3463
+ setSelected((current) => [...current, item]);
3464
+ } : undefined,
3465
+ trigger: /* @__PURE__ */ jsxs8(Button, {
3466
+ "aria-label": manageLabel,
3467
+ className: "h-full w-full min-w-0 justify-between rounded-none px-2 focus-visible:ring-inset",
3601
3468
  variant: "ghost",
3602
3469
  children: [
3603
- /* @__PURE__ */ jsx17(DataTableListSummary, {
3470
+ /* @__PURE__ */ jsx14(DataTableListSummaryContent, {
3604
3471
  emptyLabel,
3605
- expandable: false,
3606
3472
  items: selected,
3607
- variant: selected.some((item) => item.icon) ? "icon" : "text"
3473
+ display,
3474
+ showMenu: false,
3475
+ visibleCount,
3476
+ totalCount: selectedTotal
3608
3477
  }),
3609
- /* @__PURE__ */ jsx17(ChevronDown, {})
3478
+ /* @__PURE__ */ jsx14(ChevronDown, {})
3610
3479
  ]
3611
- }),
3612
- value: selected
3480
+ })
3613
3481
  })
3614
3482
  });
3615
3483
  };
3616
- var DataTableListSummary = ({
3484
+ var DataTableListMenu = ({
3485
+ actions,
3486
+ addEmptyLabel,
3487
+ addLabel,
3488
+ addOptions,
3489
+ addSearchLabel,
3490
+ className,
3491
+ display = "list",
3492
+ force = false,
3493
+ items,
3494
+ label,
3495
+ onAdd,
3496
+ trigger
3497
+ }) => {
3498
+ const entries = items.map((item) => {
3499
+ const normalized = Schema.is(Schema.String)(item) ? { label: item } : item;
3500
+ const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
3501
+ return { item: normalized, visibleActions };
3502
+ });
3503
+ const hasActions = entries.some(({ visibleActions }) => visibleActions.length);
3504
+ if (!force && !hasActions && !onAdd)
3505
+ return null;
3506
+ const resolvedLabel = label ?? (hasActions ? dataTableMessages().actions : dataTableMessages().listDetails);
3507
+ return /* @__PURE__ */ jsxs8(DropdownMenu, {
3508
+ children: [
3509
+ /* @__PURE__ */ jsx14(DropdownMenuTrigger, {
3510
+ onClick: (event) => event.stopPropagation(),
3511
+ onPointerDown: (event) => event.stopPropagation(),
3512
+ render: trigger ?? /* @__PURE__ */ jsx14(Button, {
3513
+ "aria-label": resolvedLabel,
3514
+ className: cn("size-8 shrink-0", className),
3515
+ size: "icon",
3516
+ variant: "ghost",
3517
+ children: /* @__PURE__ */ jsx14(MoreHorizontal, {})
3518
+ })
3519
+ }),
3520
+ /* @__PURE__ */ jsx14(DropdownMenuContent, {
3521
+ align: "end",
3522
+ className: "max-h-72 w-72",
3523
+ onClick: (event) => event.stopPropagation(),
3524
+ onPointerDown: (event) => event.stopPropagation(),
3525
+ children: /* @__PURE__ */ jsxs8(DropdownMenuGroup, {
3526
+ children: [
3527
+ /* @__PURE__ */ jsx14(DropdownMenuLabel, {
3528
+ children: resolvedLabel
3529
+ }),
3530
+ /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}),
3531
+ entries.map(({ item, visibleActions }, index) => visibleActions.length ? /* @__PURE__ */ jsxs8(DropdownMenuSub, {
3532
+ children: [
3533
+ /* @__PURE__ */ jsx14(DropdownMenuSubTrigger, {
3534
+ children: /* @__PURE__ */ jsx14(DataTableListEntry, {
3535
+ item,
3536
+ appearance: display === "icon" ? "detail" : "list"
3537
+ })
3538
+ }),
3539
+ /* @__PURE__ */ jsx14(DropdownMenuSubContent, {
3540
+ className: "w-max",
3541
+ children: visibleActions.map((action) => /* @__PURE__ */ jsxs8(DropdownMenuItem, {
3542
+ closeOnClick: action.closeOnClick,
3543
+ disabled: action.disabled?.(item),
3544
+ onClick: (event) => {
3545
+ event.stopPropagation();
3546
+ action.onClick(item);
3547
+ },
3548
+ variant: action.variant,
3549
+ children: [
3550
+ action.icon,
3551
+ action.name
3552
+ ]
3553
+ }, action.id ?? action.name))
3554
+ })
3555
+ ]
3556
+ }, item.value ?? `${item.label}-${index}`) : /* @__PURE__ */ jsx14("div", {
3557
+ className: "px-2 py-1.5",
3558
+ children: /* @__PURE__ */ jsx14(DataTableListEntry, {
3559
+ item,
3560
+ appearance: display === "icon" ? "detail" : "list"
3561
+ })
3562
+ }, item.value ?? `${item.label}-${index}`)),
3563
+ onAdd && addOptions?.length ? /* @__PURE__ */ jsxs8(Fragment, {
3564
+ children: [
3565
+ entries.length ? /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}) : null,
3566
+ /* @__PURE__ */ jsx14(DataTableListAddMenu, {
3567
+ emptyLabel: addEmptyLabel,
3568
+ label: addLabel ?? dataTableMessages().addItem,
3569
+ onAdd,
3570
+ options: addOptions,
3571
+ searchLabel: addSearchLabel ?? dataTableMessages().filter,
3572
+ display
3573
+ })
3574
+ ]
3575
+ }) : null
3576
+ ]
3577
+ })
3578
+ })
3579
+ ]
3580
+ });
3581
+ };
3582
+ var DataTableListAddMenu = ({
3583
+ emptyLabel,
3584
+ display,
3585
+ label,
3586
+ onAdd,
3587
+ options,
3588
+ searchLabel
3589
+ }) => {
3590
+ const [search, setSearch] = useState("");
3591
+ const focusSearch = useCallback((input) => {
3592
+ input?.focus({ preventScroll: true });
3593
+ }, []);
3594
+ const locale = getLocale();
3595
+ const normalizedSearch = search.trim().toLocaleLowerCase(locale);
3596
+ const filtered = normalizedSearch ? options.filter((item) => item.label.toLocaleLowerCase(locale).includes(normalizedSearch)) : options;
3597
+ return /* @__PURE__ */ jsxs8(DropdownMenuSub, {
3598
+ onOpenChange: (open) => {
3599
+ if (!open)
3600
+ setSearch("");
3601
+ },
3602
+ children: [
3603
+ /* @__PURE__ */ jsxs8(DropdownMenuSubTrigger, {
3604
+ children: [
3605
+ /* @__PURE__ */ jsx14(Plus, {}),
3606
+ label
3607
+ ]
3608
+ }),
3609
+ /* @__PURE__ */ jsxs8(DropdownMenuSubContent, {
3610
+ className: "w-64",
3611
+ children: [
3612
+ /* @__PURE__ */ jsxs8("div", {
3613
+ className: "relative p-1",
3614
+ children: [
3615
+ /* @__PURE__ */ jsx14(Search, {
3616
+ className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
3617
+ }),
3618
+ /* @__PURE__ */ jsx14(Input, {
3619
+ "aria-label": searchLabel,
3620
+ className: "h-8 pl-8",
3621
+ onChange: (event) => setSearch(event.target.value),
3622
+ onKeyDown: (event) => {
3623
+ if (event.key !== "Escape")
3624
+ event.stopPropagation();
3625
+ },
3626
+ placeholder: dataTableMessages().filter,
3627
+ ref: focusSearch,
3628
+ value: search
3629
+ })
3630
+ ]
3631
+ }),
3632
+ /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}),
3633
+ filtered.length ? filtered.map((item) => /* @__PURE__ */ jsx14(DropdownMenuItem, {
3634
+ closeOnClick: false,
3635
+ onClick: () => onAdd(item),
3636
+ children: /* @__PURE__ */ jsx14(DataTableListEntry, {
3637
+ item,
3638
+ appearance: display === "icon" ? "detail" : "list"
3639
+ })
3640
+ }, item.value)) : /* @__PURE__ */ jsx14("div", {
3641
+ className: "text-muted-foreground px-2 py-1.5 text-sm",
3642
+ children: emptyLabel
3643
+ })
3644
+ ]
3645
+ })
3646
+ ]
3647
+ });
3648
+ };
3649
+ var DataTableListSummaryContent = ({
3617
3650
  emptyLabel,
3618
- expandable = true,
3619
3651
  items,
3620
- overflowLabel,
3621
3652
  totalCount = items.length,
3622
- variant = "text",
3653
+ display = "list",
3654
+ showMenu,
3623
3655
  visibleCount = 3
3624
3656
  }) => {
3625
- const labels2 = dataTableMessages();
3626
3657
  const normalized = items.map((item) => Schema.is(Schema.String)(item) ? { label: item } : item);
3627
3658
  if (!normalized.length)
3628
- return /* @__PURE__ */ jsx17("span", {
3659
+ return /* @__PURE__ */ jsx14("span", {
3629
3660
  className: "text-muted-foreground",
3630
3661
  children: emptyLabel
3631
3662
  });
3632
- const visible = normalized.slice(0, visibleCount);
3663
+ const visible = normalized.slice(0, Math.max(0, visibleCount));
3633
3664
  const remaining = Math.max(totalCount - visible.length, 0);
3634
- const details = /* @__PURE__ */ jsx17(PopoverContent, {
3635
- align: "start",
3636
- className: "max-h-72 w-72 overflow-y-auto p-2",
3637
- children: normalized.map((item, index) => /* @__PURE__ */ jsxs9("div", {
3638
- className: "flex items-center gap-2 p-2",
3639
- children: [
3640
- item.icon,
3641
- item.label
3642
- ]
3643
- }, item.value ?? `${item.label}-${index}`))
3644
- });
3645
- if (variant === "icon") {
3646
- return /* @__PURE__ */ jsx17(TooltipProvider, {
3647
- children: /* @__PURE__ */ jsxs9("span", {
3665
+ if (display === "icon") {
3666
+ return /* @__PURE__ */ jsx14(TooltipProvider, {
3667
+ children: /* @__PURE__ */ jsxs8("span", {
3648
3668
  className: "flex items-center",
3649
3669
  children: [
3650
- visible.map((item) => /* @__PURE__ */ jsxs9(Tooltip, {
3651
- children: [
3652
- /* @__PURE__ */ jsx17(TooltipTrigger, {
3653
- render: /* @__PURE__ */ jsx17("span", {
3654
- "aria-label": item.label,
3655
- className: "bg-muted -ml-1 flex size-8 items-center justify-center rounded-full",
3656
- children: item.icon ?? item.label.slice(0, 2).toUpperCase()
3657
- })
3658
- }),
3659
- /* @__PURE__ */ jsx17(TooltipContent, {
3660
- children: item.label
3661
- })
3662
- ]
3663
- }, item.value ?? item.label)),
3664
- remaining && expandable ? /* @__PURE__ */ jsxs9(Popover, {
3665
- children: [
3666
- /* @__PURE__ */ jsx17(PopoverTrigger, {
3667
- render: /* @__PURE__ */ jsxs9("button", {
3668
- "aria-label": labels2.listOthers(remaining),
3669
- className: "bg-muted -ml-1 flex size-8 items-center justify-center rounded-full",
3670
- type: "button",
3671
- children: [
3672
- "+",
3673
- remaining
3674
- ]
3675
- })
3676
- }),
3677
- details
3678
- ]
3679
- }) : remaining ? /* @__PURE__ */ jsxs9("span", {
3680
- className: "bg-muted -ml-1 flex size-8 items-center justify-center rounded-full",
3670
+ visible.map((item, index) => /* @__PURE__ */ jsx14(DataTableListEntry, {
3671
+ item,
3672
+ appearance: "icon"
3673
+ }, item.value ?? `${item.label}-${index}`)),
3674
+ remaining ? /* @__PURE__ */ jsxs8("span", {
3675
+ className: "bg-secondary text-secondary-foreground -ml-1 flex size-8 items-center justify-center rounded-full",
3681
3676
  children: [
3682
3677
  "+",
3683
3678
  remaining
3684
3679
  ]
3680
+ }) : null,
3681
+ remaining && showMenu ? /* @__PURE__ */ jsx14(DataTableListMenu, {
3682
+ actions: [],
3683
+ display,
3684
+ force: true,
3685
+ items: normalized
3685
3686
  }) : null
3686
3687
  ]
3687
3688
  })
3688
3689
  });
3689
3690
  }
3690
- const summary = /* @__PURE__ */ jsxs9(Fragment, {
3691
+ return /* @__PURE__ */ jsxs8("span", {
3692
+ className: "inline-flex min-w-0 items-center gap-2 text-sm",
3691
3693
  children: [
3692
- visible.map((item) => item.label).join(", "),
3693
- remaining ? ` ${overflowLabel?.(remaining) ?? labels2.listOthers(remaining)}` : ""
3694
+ /* @__PURE__ */ jsxs8("span", {
3695
+ className: "truncate",
3696
+ children: [
3697
+ visible.map((item) => item.label).join(", "),
3698
+ remaining ? ` +${remaining}` : ""
3699
+ ]
3700
+ }),
3701
+ remaining && showMenu ? /* @__PURE__ */ jsx14(DataTableListMenu, {
3702
+ actions: [],
3703
+ display,
3704
+ force: true,
3705
+ items: normalized
3706
+ }) : null
3694
3707
  ]
3695
3708
  });
3696
- return remaining && expandable ? /* @__PURE__ */ jsxs9(Popover, {
3709
+ };
3710
+ var DataTableListSummary = (props) => /* @__PURE__ */ jsx14(DataTableListSummaryContent, {
3711
+ ...props,
3712
+ showMenu: true
3713
+ });
3714
+ var DataTableListEntry = ({
3715
+ item,
3716
+ appearance
3717
+ }) => {
3718
+ const icon = /* @__PURE__ */ jsx14("span", {
3719
+ "aria-hidden": "true",
3720
+ className: "bg-secondary text-secondary-foreground flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full",
3721
+ children: item.imageSrc ? /* @__PURE__ */ jsx14("img", {
3722
+ alt: "",
3723
+ src: item.imageSrc,
3724
+ className: "size-full object-cover"
3725
+ }) : item.icon ?? item.label.slice(0, 2).toUpperCase()
3726
+ });
3727
+ if (appearance === "list") {
3728
+ return /* @__PURE__ */ jsx14("span", {
3729
+ className: "truncate",
3730
+ children: item.label
3731
+ });
3732
+ }
3733
+ return appearance === "icon" ? /* @__PURE__ */ jsxs8(Tooltip, {
3697
3734
  children: [
3698
- /* @__PURE__ */ jsx17(PopoverTrigger, {
3699
- render: /* @__PURE__ */ jsx17("button", {
3700
- className: "text-left text-sm",
3701
- type: "button",
3702
- children: summary
3703
- })
3735
+ /* @__PURE__ */ jsx14(TooltipTrigger, {
3736
+ render: /* @__PURE__ */ jsx14("span", {
3737
+ className: "-ml-1 inline-flex rounded-full",
3738
+ "aria-label": item.label
3739
+ }),
3740
+ children: icon
3704
3741
  }),
3705
- details
3742
+ /* @__PURE__ */ jsx14(TooltipContent, {
3743
+ children: item.label
3744
+ })
3745
+ ]
3746
+ }) : /* @__PURE__ */ jsxs8("span", {
3747
+ className: "flex min-w-0 flex-1 items-center gap-2 text-left",
3748
+ children: [
3749
+ icon,
3750
+ /* @__PURE__ */ jsx14("span", {
3751
+ className: "truncate",
3752
+ children: item.label
3753
+ })
3706
3754
  ]
3707
- }) : /* @__PURE__ */ jsx17("span", {
3708
- className: "text-sm",
3709
- children: summary
3710
3755
  });
3711
3756
  };
3712
3757
  export {
3713
3758
  DataTable,
3759
+ DataTableListCell,
3714
3760
  DataTableListSummary,
3715
- DataTableRelationshipCell,
3716
3761
  DataTableRowActions,
3717
3762
  buildDataTableRows,
3718
3763
  dataTableMessages,
3719
3764
  downloadCsv,
3720
3765
  downloadJson,
3721
3766
  filterDataTableRows,
3767
+ getDataTableExportValue,
3722
3768
  getDataTableSelectableRows,
3723
3769
  getDataTableWidth,
3724
3770
  groupDataTableRows,