@dynamic-labs-sdk/droplet 1.49.1 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/components/copy-button/copy-button.d.ts +3 -1
  2. package/dist/components/copy-button/copy-button.d.ts.map +1 -1
  3. package/dist/components/copy-button/copy-button.stories.d.ts +1 -1
  4. package/dist/components/empty-state/empty-state.d.ts +3 -3
  5. package/dist/components/empty-state/empty-state.d.ts.map +1 -1
  6. package/dist/components/migration/field/field.d.ts.map +1 -1
  7. package/dist/components/status-badge/status-badge.d.ts.map +1 -1
  8. package/dist/components/tab-navigation/tab-navigation.d.ts.map +1 -1
  9. package/dist/components/toggle-card/toggle-card.d.ts +10 -0
  10. package/dist/components/toggle-card/toggle-card.d.ts.map +1 -1
  11. package/dist/components/toggle-card/toggle-card.stories.d.ts +5 -0
  12. package/dist/components/toggle-card/toggle-card.stories.d.ts.map +1 -1
  13. package/dist/components/toggle-row/toggle-row.d.ts +22 -1
  14. package/dist/components/toggle-row/toggle-row.d.ts.map +1 -1
  15. package/dist/components/toggle-row/toggle-row.stories.d.ts +10 -6
  16. package/dist/components/toggle-row/toggle-row.stories.d.ts.map +1 -1
  17. package/dist/components/ui/checkbox/checkbox.d.ts.map +1 -1
  18. package/dist/components/ui/combobox/combobox.d.ts +54 -12
  19. package/dist/components/ui/combobox/combobox.d.ts.map +1 -1
  20. package/dist/components/ui/combobox/combobox.stories.d.ts +12 -1
  21. package/dist/components/ui/combobox/combobox.stories.d.ts.map +1 -1
  22. package/dist/components/ui/data-table/create-column-helper.d.ts +20 -0
  23. package/dist/components/ui/data-table/create-column-helper.d.ts.map +1 -0
  24. package/dist/components/ui/data-table/data-table-active-filters.d.ts +37 -0
  25. package/dist/components/ui/data-table/data-table-active-filters.d.ts.map +1 -0
  26. package/dist/components/ui/data-table/data-table-column-filter.d.ts +48 -0
  27. package/dist/components/ui/data-table/data-table-column-filter.d.ts.map +1 -0
  28. package/dist/components/ui/data-table/data-table-column-visibility.d.ts +37 -0
  29. package/dist/components/ui/data-table/data-table-column-visibility.d.ts.map +1 -0
  30. package/dist/components/ui/data-table/data-table-content.d.ts +43 -0
  31. package/dist/components/ui/data-table/data-table-content.d.ts.map +1 -0
  32. package/dist/components/ui/data-table/data-table-context.d.ts +13 -0
  33. package/dist/components/ui/data-table/data-table-context.d.ts.map +1 -0
  34. package/dist/components/ui/data-table/data-table-pagination.d.ts +38 -0
  35. package/dist/components/ui/data-table/data-table-pagination.d.ts.map +1 -0
  36. package/dist/components/ui/data-table/data-table-placeholder-rows.d.ts +21 -0
  37. package/dist/components/ui/data-table/data-table-placeholder-rows.d.ts.map +1 -0
  38. package/dist/components/ui/data-table/data-table-rows.d.ts +22 -0
  39. package/dist/components/ui/data-table/data-table-rows.d.ts.map +1 -0
  40. package/dist/components/ui/data-table/data-table-search.d.ts +40 -0
  41. package/dist/components/ui/data-table/data-table-search.d.ts.map +1 -0
  42. package/dist/components/ui/data-table/data-table.d.ts +56 -0
  43. package/dist/components/ui/data-table/data-table.d.ts.map +1 -0
  44. package/dist/components/ui/data-table/data-table.stories.d.ts +32 -0
  45. package/dist/components/ui/data-table/data-table.stories.d.ts.map +1 -0
  46. package/dist/components/ui/data-table/data-table.types.d.ts +189 -0
  47. package/dist/components/ui/data-table/data-table.types.d.ts.map +1 -0
  48. package/dist/components/ui/data-table/expand-chevron.d.ts +7 -0
  49. package/dist/components/ui/data-table/expand-chevron.d.ts.map +1 -0
  50. package/dist/components/ui/data-table/get-column-label.d.ts +7 -0
  51. package/dist/components/ui/data-table/get-column-label.d.ts.map +1 -0
  52. package/dist/components/ui/data-table/get-pinned-cell-props.d.ts +15 -0
  53. package/dist/components/ui/data-table/get-pinned-cell-props.d.ts.map +1 -0
  54. package/dist/components/ui/data-table/selection-column.d.ts +24 -0
  55. package/dist/components/ui/data-table/selection-column.d.ts.map +1 -0
  56. package/dist/components/ui/data-table/use-data-table.d.ts +157 -0
  57. package/dist/components/ui/data-table/use-data-table.d.ts.map +1 -0
  58. package/dist/components/ui/field/field-control-context.d.ts +20 -0
  59. package/dist/components/ui/field/field-control-context.d.ts.map +1 -0
  60. package/dist/components/ui/field/field.d.ts +20 -4
  61. package/dist/components/ui/field/field.d.ts.map +1 -1
  62. package/dist/components/ui/field/field.stories.d.ts +18 -6
  63. package/dist/components/ui/field/field.stories.d.ts.map +1 -1
  64. package/dist/components/ui/label/label.d.ts +15 -0
  65. package/dist/components/ui/label/label.d.ts.map +1 -1
  66. package/dist/components/ui/pagination/pagination.d.ts +2 -2
  67. package/dist/components/ui/pagination/pagination.d.ts.map +1 -1
  68. package/dist/components/ui/select/select.d.ts.map +1 -1
  69. package/dist/components/ui/select/select.stories.d.ts.map +1 -1
  70. package/dist/components/ui/table/table.d.ts +7 -3
  71. package/dist/components/ui/table/table.d.ts.map +1 -1
  72. package/dist/components/ui/table/table.stories.d.ts +3 -1
  73. package/dist/components/ui/table/table.stories.d.ts.map +1 -1
  74. package/dist/components/ui/tabs/tabs.d.ts +3 -1
  75. package/dist/components/ui/tabs/tabs.d.ts.map +1 -1
  76. package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
  77. package/dist/index.cjs +1722 -247
  78. package/dist/index.cjs.map +1 -1
  79. package/dist/index.d.ts +19 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.esm.js +1714 -251
  82. package/dist/index.esm.js.map +1 -1
  83. package/dist/migration.cjs +1 -1
  84. package/dist/migration.cjs.map +1 -1
  85. package/dist/migration.esm.js +1 -1
  86. package/dist/migration.esm.js.map +1 -1
  87. package/dist/{toggle-row-PqelNVXI.esm.js → toggle-row-CeiCy3Aa.esm.js} +33 -8
  88. package/dist/toggle-row-CeiCy3Aa.esm.js.map +1 -0
  89. package/dist/{toggle-row-BBTk7_bT.cjs → toggle-row-DcV81G3w.cjs} +33 -8
  90. package/dist/toggle-row-DcV81G3w.cjs.map +1 -0
  91. package/package.json +3 -1
  92. package/src/styles/globals.css +54 -15
  93. package/dist/toggle-row-BBTk7_bT.cjs.map +0 -1
  94. package/dist/toggle-row-PqelNVXI.esm.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_toggle_row = require('./toggle-row-BBTk7_bT.cjs');
28
+ const require_toggle_row = require('./toggle-row-DcV81G3w.cjs');
29
29
  let react = require("react");
30
30
  let motion_react = require("motion/react");
31
31
  let _hugeicons_react = require("@hugeicons/react");
@@ -49,14 +49,16 @@ let _radix_ui_react_popover = require("@radix-ui/react-popover");
49
49
  _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
50
50
  let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
51
51
  let lucide_react = require("lucide-react");
52
+ let _radix_ui_react_select = require("@radix-ui/react-select");
52
53
  let _radix_ui_react_radio_group = require("@radix-ui/react-radio-group");
53
54
  _radix_ui_react_radio_group = __toESM(_radix_ui_react_radio_group);
54
55
  let _radix_ui_react_scroll_area = require("@radix-ui/react-scroll-area");
55
56
  _radix_ui_react_scroll_area = __toESM(_radix_ui_react_scroll_area);
56
- let _radix_ui_react_select = require("@radix-ui/react-select");
57
57
  let _radix_ui_react_separator = require("@radix-ui/react-separator");
58
58
  let next_themes = require("next-themes");
59
59
  let sonner = require("sonner");
60
+ let _tanstack_react_table = require("@tanstack/react-table");
61
+ let _tanstack_react_virtual = require("@tanstack/react-virtual");
60
62
  let _radix_ui_react_tabs = require("@radix-ui/react-tabs");
61
63
  _radix_ui_react_tabs = __toESM(_radix_ui_react_tabs);
62
64
  let _radix_ui_react_tooltip = require("@radix-ui/react-tooltip");
@@ -866,7 +868,8 @@ const Checkbox = ({ className, ...props }) => {
866
868
  className: "relative grid place-content-center text-current size-full",
867
869
  forceMount: true,
868
870
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
869
- className: "size-3.5 absolute inset-0 m-auto transition-[opacity,transform,filter] duration-200 motion-reduce:transition-none opacity-0 scale-[0.25] blur-[4px] group-data-[state=indeterminate]:opacity-100 group-data-[state=indeterminate]:scale-100 group-data-[state=indeterminate]:blur-none",
871
+ "aria-hidden": "true",
872
+ className: "size-3.5 text-current absolute inset-0 m-auto transition-[opacity,transform,filter] duration-200 motion-reduce:transition-none opacity-0 scale-[0.25] blur-[4px] group-data-[state=indeterminate]:opacity-100 group-data-[state=indeterminate]:scale-100 group-data-[state=indeterminate]:blur-none",
870
873
  viewBox: "0 0 24 24",
871
874
  fill: "none",
872
875
  stroke: "currentColor",
@@ -878,7 +881,8 @@ const Checkbox = ({ className, ...props }) => {
878
881
  strokeWidth: 3
879
882
  })
880
883
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
881
- className: "size-3.5 absolute inset-0 m-auto transition-[opacity,transform,filter] duration-200 motion-reduce:transition-none opacity-0 scale-[0.25] blur-[4px] group-data-[state=checked]:opacity-100 group-data-[state=checked]:scale-100 group-data-[state=checked]:blur-none",
884
+ "aria-hidden": "true",
885
+ className: "size-3.5 text-current absolute inset-0 m-auto transition-[opacity,transform,filter] duration-200 motion-reduce:transition-none opacity-0 scale-[0.25] blur-[4px] group-data-[state=checked]:opacity-100 group-data-[state=checked]:scale-100 group-data-[state=checked]:blur-none",
882
886
  viewBox: "0 0 24 24",
883
887
  fill: "none",
884
888
  stroke: "currentColor",
@@ -1110,13 +1114,37 @@ const PopoverAnchor = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.js
1110
1114
 
1111
1115
  //#endregion
1112
1116
  //#region src/components/ui/combobox/combobox.tsx
1117
+ /** cmdk value of the select-all row; never matches a real option. */
1118
+ const SELECT_ALL_VALUE = "__droplet-combobox-select-all__";
1119
+ /**
1120
+ * Decorative `Checkbox` inside a multi-select option. The option row is the
1121
+ * control: it owns focus, the click target and the checked state for
1122
+ * assistive tech, so the checkbox is hidden from them and ignores pointer
1123
+ * events to avoid a second tab stop or a second announcement.
1124
+ */
1125
+ const OptionCheckbox = ({ checked }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
1126
+ checked,
1127
+ "aria-hidden": true,
1128
+ tabIndex: -1,
1129
+ className: "pointer-events-none after:hidden in-data-[selected=true]:data-[state=unchecked]:shadow-[var(--shadow-control-hover)]"
1130
+ });
1131
+ /** Checkbox state of the select-all row: indeterminate while only some are selected. */
1132
+ const getSelectAllState = ({ selectedCount, totalCount }) => {
1133
+ if (selectedCount === 0) return false;
1134
+ if (selectedCount === totalCount) return true;
1135
+ return "indeterminate";
1136
+ };
1113
1137
  /**
1114
- * Searchable single-select Combobox.
1138
+ * Searchable Combobox, single-select by default or multi-select with `multiple`.
1139
+ *
1140
+ * Composes `Popover`, `Command` and `Checkbox` from the droplet design system.
1141
+ * The trigger is styled like `SelectTrigger` with a rotating chevron that
1142
+ * signals open/closed state.
1115
1143
  *
1116
- * Composes `Popover`, `Button`, and `Command` from the droplet design system.
1117
- * The trigger is a full-width `outline` Button with a rotating chevron that
1118
- * signals open/closed state. Selecting an item closes the popover, fires
1119
- * `onValueChange`, and shows a check mark next to the active selection.
1144
+ * - Single-select: picking an item closes the popover, fires `onValueChange`
1145
+ * and shows a check mark next to the active selection.
1146
+ * - Multi-select: each option shows a `Checkbox`, picking an item toggles it
1147
+ * and keeps the popover open, and the trigger lists the selected labels.
1120
1148
  *
1121
1149
  * @example
1122
1150
  * ```tsx
@@ -1127,18 +1155,49 @@ const PopoverAnchor = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.js
1127
1155
  * onValueChange={setChain}
1128
1156
  * placeholder="Select a chain"
1129
1157
  * />
1158
+ *
1159
+ * const [chains, setChains] = useState<string[]>([]);
1160
+ * <Combobox
1161
+ * multiple
1162
+ * options={[{ value: 'eth', label: 'Ethereum' }, { value: 'sol', label: 'Solana' }]}
1163
+ * value={chains}
1164
+ * onValueChange={setChains}
1165
+ * selectAllLabel="All chains"
1166
+ * />
1130
1167
  * ```
1131
1168
  */
1132
- const Combobox = ({ options, value, onValueChange, placeholder = "Select…", searchPlaceholder = "Search…", emptyText = "No results.", className, disabled = false }) => {
1169
+ const Combobox = (props) => {
1170
+ const { options, placeholder = "Select…", searchPlaceholder = "Search…", emptyText = "No results.", className, disabled = false } = props;
1133
1171
  const [open, setOpen] = (0, react.useState)(false);
1134
- const selectedLabel = options.find((opt) => opt.value === value)?.label;
1172
+ const [search, setSearch] = (0, react.useState)("");
1173
+ const selectedValues = props.multiple ? props.value : [props.value];
1174
+ const selectedOptions = options.filter((opt) => selectedValues.includes(opt.value));
1175
+ const selectedLabels = selectedOptions.map((opt) => opt.label);
1176
+ const selectedLabel = props.multiple && props.formatSelected && selectedLabels.length > 0 ? props.formatSelected(selectedLabels) : selectedLabels.join(", ") || void 0;
1177
+ const selectAllState = getSelectAllState({
1178
+ selectedCount: selectedOptions.length,
1179
+ totalCount: options.length
1180
+ });
1181
+ const showSelectAll = props.multiple && props.selectAllLabel !== void 0 && search === "";
1135
1182
  const handleSelect = (selectedValue) => {
1136
- onValueChange(selectedValue);
1137
- setOpen(false);
1183
+ if (!props.multiple) {
1184
+ props.onValueChange(selectedValue);
1185
+ handleOpenChange(false);
1186
+ return;
1187
+ }
1188
+ props.onValueChange(props.value.includes(selectedValue) ? props.value.filter((v) => v !== selectedValue) : [...props.value, selectedValue]);
1189
+ };
1190
+ const handleSelectAll = () => {
1191
+ if (!props.multiple) return;
1192
+ props.onValueChange(selectAllState === true ? [] : options.map((opt) => opt.value));
1193
+ };
1194
+ const handleOpenChange = (nextOpen) => {
1195
+ setOpen(nextOpen);
1196
+ if (!nextOpen) setSearch("");
1138
1197
  };
1139
1198
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Popover, {
1140
1199
  open,
1141
- onOpenChange: setOpen,
1200
+ onOpenChange: handleOpenChange,
1142
1201
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, {
1143
1202
  asChild: true,
1144
1203
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
@@ -1163,12 +1222,32 @@ const Combobox = ({ options, value, onValueChange, placeholder = "Select…", se
1163
1222
  sideOffset: 4,
1164
1223
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Command, {
1165
1224
  className: "rounded-[inherit]",
1166
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommandInput, { placeholder: searchPlaceholder }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CommandList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommandEmpty, { children: emptyText }), options.map((opt) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CommandItem, {
1167
- value: opt.value,
1168
- keywords: [opt.label],
1169
- onSelect: handleSelect,
1170
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckIcon, { className: require_toggle_row.cn("shrink-0", value === opt.value ? "opacity-100" : "opacity-0") }), opt.label]
1171
- }, opt.value))] })]
1225
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommandInput, {
1226
+ placeholder: searchPlaceholder,
1227
+ value: search,
1228
+ onValueChange: setSearch
1229
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CommandList, {
1230
+ "aria-multiselectable": props.multiple || void 0,
1231
+ children: [
1232
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommandEmpty, { children: emptyText }),
1233
+ showSelectAll && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CommandItem, {
1234
+ value: SELECT_ALL_VALUE,
1235
+ "aria-checked": selectAllState === "indeterminate" ? "mixed" : selectAllState,
1236
+ onSelect: handleSelectAll,
1237
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionCheckbox, { checked: selectAllState }), props.selectAllLabel]
1238
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommandSeparator, { className: "my-1" })] }),
1239
+ options.map((opt) => {
1240
+ const isSelected = selectedValues.includes(opt.value);
1241
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CommandItem, {
1242
+ value: opt.value,
1243
+ keywords: [opt.label],
1244
+ "aria-checked": props.multiple ? isSelected : void 0,
1245
+ onSelect: handleSelect,
1246
+ children: [props.multiple ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionCheckbox, { checked: isSelected }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckIcon, { className: require_toggle_row.cn("shrink-0", isSelected ? "opacity-100" : "opacity-0") }), opt.label]
1247
+ }, opt.value);
1248
+ })
1249
+ ]
1250
+ })]
1172
1251
  })
1173
1252
  })]
1174
1253
  });
@@ -1422,9 +1501,114 @@ const Icon = (props) => {
1422
1501
  });
1423
1502
  };
1424
1503
 
1504
+ //#endregion
1505
+ //#region src/components/ui/field/field-control-context.ts
1506
+ /**
1507
+ * Carries a `Field`'s control attributes to a control that renders its focusable
1508
+ * element deeper than `Field`'s direct child.
1509
+ *
1510
+ * `Field` injects `id` and the `aria-*` attributes onto its direct child. That
1511
+ * works for `Input` and `Textarea`, but `Select` renders no element of its own,
1512
+ * so `SelectTrigger` reads them from here instead.
1513
+ */
1514
+ const FieldControlContext = (0, react.createContext)(null);
1515
+
1516
+ //#endregion
1517
+ //#region src/components/ui/select/select.tsx
1518
+ const Select = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Root, {
1519
+ "data-slot": "select",
1520
+ ...props
1521
+ });
1522
+ const SelectGroup = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Group, {
1523
+ "data-slot": "select-group",
1524
+ ...props
1525
+ });
1526
+ const SelectValue = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Value, {
1527
+ "data-slot": "select-value",
1528
+ ...props
1529
+ });
1530
+ const SelectTrigger = ({ className, size = "default", children, ...props }) => {
1531
+ const fieldControlProps = (0, react.useContext)(FieldControlContext);
1532
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Trigger, {
1533
+ ...fieldControlProps,
1534
+ "data-slot": "select-trigger",
1535
+ "data-size": size,
1536
+ className: require_toggle_row.cn("data-[placeholder]:text-muted-foreground/60 [&_svg:not([class*='text-'])]:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 flex w-fit touch-manipulation items-center justify-between gap-1.5 rounded-md border-0 bg-transparent px-3 py-2 text-[13px] whitespace-nowrap shadow-[var(--shadow-input)] hover:shadow-[var(--shadow-input-hover)] transition-[color,box-shadow] duration-100 ease-out outline-none focus-visible:shadow-[0_0_0_1px_var(--ring),0_0_0_4px_var(--ring-halo,#0072EF26)] aria-invalid:shadow-[0_0_0_1px_var(--destructive)] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:text-[13px] data-[size=sm]:px-2.5 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[state=open]:[&>svg:last-of-type]:rotate-180", className),
1537
+ ...props,
1538
+ ...fieldControlProps ? { id: fieldControlProps.id } : {},
1539
+ children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Icon, {
1540
+ asChild: true,
1541
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1542
+ icon: _hugeicons_core_free_icons.ArrowDown01Icon,
1543
+ size: 16,
1544
+ className: "opacity-50 transition-transform duration-150 ease-out motion-reduce:transition-none"
1545
+ })
1546
+ })]
1547
+ });
1548
+ };
1549
+ const SelectContent = ({ className, children, position = "popper", align = "start", ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Content, {
1550
+ "data-slot": "select-content",
1551
+ className: require_toggle_row.cn("bg-popover text-popover-foreground will-change-[opacity,transform] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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 motion-reduce:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-xl border-0 shadow-[var(--shadow-elevated)]", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
1552
+ position,
1553
+ align,
1554
+ ...props,
1555
+ children: [
1556
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectScrollUpButton, {}),
1557
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Viewport, {
1558
+ className: require_toggle_row.cn("p-1", position === "popper" && "w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),
1559
+ children
1560
+ }),
1561
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectScrollDownButton, {})
1562
+ ]
1563
+ }) });
1564
+ const SelectLabel = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Label, {
1565
+ "data-slot": "select-label",
1566
+ className: require_toggle_row.cn("text-muted-foreground px-2 py-1.5 text-xs", className),
1567
+ ...props
1568
+ });
1569
+ const SelectItem = ({ className, children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Item, {
1570
+ "data-slot": "select-item",
1571
+ className: require_toggle_row.cn("data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[state=checked]:font-medium [&_svg:not([class*='text-'])]:text-muted-foreground relative 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 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
1572
+ ...props,
1573
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1574
+ "data-slot": "select-item-indicator",
1575
+ className: "absolute right-2 flex size-3.5 items-center justify-center",
1576
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1577
+ icon: _hugeicons_core_free_icons.Tick01Icon,
1578
+ size: 14
1579
+ }) })
1580
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ItemText, { children })]
1581
+ });
1582
+ const SelectSeparator = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Separator, {
1583
+ "data-slot": "select-separator",
1584
+ className: require_toggle_row.cn("bg-border pointer-events-none -mx-1 my-1 h-px", className),
1585
+ ...props
1586
+ });
1587
+ const SelectScrollUpButton = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ScrollUpButton, {
1588
+ "data-slot": "select-scroll-up-button",
1589
+ className: require_toggle_row.cn("flex cursor-default items-center justify-center py-1", className),
1590
+ ...props,
1591
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1592
+ icon: _hugeicons_core_free_icons.ArrowUp01Icon,
1593
+ size: 16,
1594
+ "aria-hidden": true
1595
+ })
1596
+ });
1597
+ const SelectScrollDownButton = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ScrollDownButton, {
1598
+ "data-slot": "select-scroll-down-button",
1599
+ className: require_toggle_row.cn("flex cursor-default items-center justify-center py-1", className),
1600
+ ...props,
1601
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1602
+ icon: _hugeicons_core_free_icons.ArrowDown01Icon,
1603
+ size: 16,
1604
+ "aria-hidden": true
1605
+ })
1606
+ });
1607
+
1425
1608
  //#endregion
1426
1609
  //#region src/components/ui/field/field.tsx
1427
- const LABEL_GAP_CLASS_NAME = "mb-[calc(var(--spacing-label-gap)-var(--spacing-field-gap))]";
1610
+ const FIELD_GAP_CLASS_NAME = "grid [--field-gap:6px] [--label-gap:10px] gap-[var(--field-gap)]";
1611
+ const LABEL_GAP_CLASS_NAME = "mb-[calc(var(--label-gap)-var(--field-gap))]";
1428
1612
  /**
1429
1613
  * A generic labeled form-field wrapper.
1430
1614
  *
@@ -1432,16 +1616,26 @@ const LABEL_GAP_CLASS_NAME = "mb-[calc(var(--spacing-label-gap)-var(--spacing-fi
1432
1616
  * an error message together with the correct `id`/`htmlFor`/`aria-describedby`
1433
1617
  * associations so callers don't have to hand-assemble these.
1434
1618
  *
1619
+ * Always wrap a form control in `Field` rather than pairing a bare `<Label>`
1620
+ * with it: `Field` owns the label-to-control gap (10px) and the gap to the
1621
+ * error (6px). Don't add helper text: the error is the only message under a
1622
+ * control.
1623
+ *
1435
1624
  * When there is exactly one child element, `Field` uses `cloneElement` to
1436
1625
  * inject:
1437
1626
  * - `id` — links the label's `htmlFor` to the control
1627
+ * - `aria-labelledby` — names group controls such as `RadioGroup`, which a
1628
+ * `<label for>` cannot name
1438
1629
  * - `aria-describedby` — references the description and/or error paragraph ids
1439
1630
  * - `aria-invalid` — `true` when `error` is present
1440
1631
  *
1632
+ * `Select` renders no element of its own, so `SelectTrigger` picks up `id`,
1633
+ * `aria-describedby` and `aria-invalid` from `Field` instead.
1634
+ *
1441
1635
  * @example
1442
1636
  * ```tsx
1443
- * <Field label="Email" description="We'll never share your email." required>
1444
- * <Input type="email" />
1637
+ * <Field label="Email" required>
1638
+ * <Input type="email" required />
1445
1639
  * </Field>
1446
1640
  *
1447
1641
  * <Field label="Email" error="Enter a valid email address.">
@@ -1450,25 +1644,39 @@ const LABEL_GAP_CLASS_NAME = "mb-[calc(var(--spacing-label-gap)-var(--spacing-fi
1450
1644
  * ```
1451
1645
  */
1452
1646
  const Field = ({ label, description, error, required, htmlFor, children, className }) => {
1647
+ const childArray = react.Children.toArray(children);
1648
+ const singleChild = childArray.length === 1 && (0, react.isValidElement)(childArray[0]) ? childArray[0] : null;
1649
+ const childId = (singleChild?.props)?.id;
1453
1650
  const generatedId = (0, react.useId)();
1454
- const controlId = htmlFor ?? generatedId;
1651
+ const controlId = (typeof childId === "string" ? childId : void 0) ?? htmlFor ?? generatedId;
1455
1652
  const descriptionId = `${controlId}-description`;
1456
1653
  const errorId = `${controlId}-error`;
1457
- const describedByParts = [];
1458
- if (description) describedByParts.push(descriptionId);
1459
- if (error) describedByParts.push(errorId);
1460
- const ariaDescribedBy = describedByParts.length > 0 ? describedByParts.join(" ") : void 0;
1461
- const childArray = react.Children.toArray(children);
1462
- const singleChild = childArray.length === 1 && (0, react.isValidElement)(childArray[0]) ? childArray[0] : null;
1654
+ const labelId = label ? `${controlId}-label` : void 0;
1655
+ const showDescription = Boolean(description) && !error;
1656
+ let ariaDescribedBy;
1657
+ if (error) ariaDescribedBy = errorId;
1658
+ else if (showDescription) ariaDescribedBy = descriptionId;
1659
+ const hasError = Boolean(error);
1660
+ const controlProps = (0, react.useMemo)(() => ({
1661
+ "aria-describedby": ariaDescribedBy,
1662
+ id: controlId,
1663
+ ...hasError ? { "aria-invalid": true } : {}
1664
+ }), [
1665
+ ariaDescribedBy,
1666
+ controlId,
1667
+ hasError
1668
+ ]);
1463
1669
  const enrichedChild = singleChild ? (0, react.cloneElement)(singleChild, {
1464
1670
  "aria-describedby": singleChild.props["aria-describedby"] ?? ariaDescribedBy,
1465
- id: singleChild.props.id ?? controlId,
1671
+ "aria-labelledby": singleChild.props["aria-labelledby"] ?? labelId,
1672
+ id: controlId,
1466
1673
  ...error ? { "aria-invalid": true } : {}
1467
1674
  }) : null;
1468
1675
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1469
- className: require_toggle_row.cn("grid gap-field-gap", className),
1676
+ className: require_toggle_row.cn(FIELD_GAP_CLASS_NAME, className),
1470
1677
  children: [
1471
1678
  label && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_toggle_row.Label, {
1679
+ id: labelId,
1472
1680
  htmlFor: controlId,
1473
1681
  "data-slot": "field-label",
1474
1682
  className: LABEL_GAP_CLASS_NAME,
@@ -1478,8 +1686,11 @@ const Field = ({ label, description, error, required, htmlFor, children, classNa
1478
1686
  children: "*"
1479
1687
  })]
1480
1688
  }),
1481
- enrichedChild ?? children,
1482
- description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1689
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldControlContext.Provider, {
1690
+ value: singleChild?.type === Select ? controlProps : null,
1691
+ children: enrichedChild ?? children
1692
+ }),
1693
+ showDescription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1483
1694
  id: descriptionId,
1484
1695
  className: "text-sm text-muted-foreground",
1485
1696
  children: description
@@ -1721,7 +1932,7 @@ const PaginationEllipsis = ({ className, ...props }) => /* @__PURE__ */ (0, reac
1721
1932
  /**
1722
1933
  * Pre-assembled cursor-based pagination bar.
1723
1934
  *
1724
- * Renders a Previous button, an optional center label, and a Next button.
1935
+ * Renders an optional label, such as a record range, followed by previous and next arrow buttons, aligned to the end.
1725
1936
  * Each button is disabled automatically when there is no page in that direction.
1726
1937
  * Designed for dashboard tables and lists that use cursor/keyset pagination rather
1727
1938
  * than numbered pages — which is the dominant pattern in the Redcoast design system.
@@ -1737,39 +1948,41 @@ const PaginationEllipsis = ({ className, ...props }) => /* @__PURE__ */ (0, reac
1737
1948
  * />
1738
1949
  * ```
1739
1950
  */
1740
- const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1951
+ const CursorPagination = ({ hasPrevious, hasNext, onPrevious, onNext, label, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
1952
+ "aria-label": "Pagination",
1741
1953
  "data-slot": "cursor-pagination",
1742
- className: require_toggle_row.cn("flex items-center justify-between gap-2", className),
1743
- children: [
1744
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_toggle_row.Button, {
1745
- variant: "ghost",
1746
- size: "sm",
1954
+ className: require_toggle_row.cn("flex items-center justify-end gap-3", className),
1955
+ children: [label !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1956
+ className: "text-[13px] text-muted-foreground tabular-nums",
1957
+ children: label
1958
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1959
+ className: "flex items-center gap-2",
1960
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_toggle_row.Button, {
1961
+ variant: "outline",
1962
+ size: "icon-sm",
1963
+ className: "size-8 before:-inset-1",
1747
1964
  disabled: !hasPrevious,
1748
1965
  onClick: onPrevious,
1749
1966
  "aria-label": "Go to previous page",
1750
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1967
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1751
1968
  icon: _hugeicons_core_free_icons.ArrowLeft01Icon,
1752
- size: 14,
1969
+ size: 16,
1753
1970
  "aria-hidden": "true"
1754
- }), "Previous"]
1755
- }),
1756
- label !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1757
- className: "text-sm text-muted-foreground tabular-nums",
1758
- children: label
1759
- }),
1760
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_toggle_row.Button, {
1761
- variant: "ghost",
1762
- size: "sm",
1971
+ })
1972
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_toggle_row.Button, {
1973
+ variant: "outline",
1974
+ size: "icon-sm",
1975
+ className: "size-8 before:-inset-1",
1763
1976
  disabled: !hasNext,
1764
1977
  onClick: onNext,
1765
1978
  "aria-label": "Go to next page",
1766
- children: ["Next", /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1979
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1767
1980
  icon: _hugeicons_core_free_icons.ArrowRight01Icon,
1768
- size: 14,
1981
+ size: 16,
1769
1982
  "aria-hidden": "true"
1770
- })]
1771
- })
1772
- ]
1983
+ })
1984
+ })]
1985
+ })]
1773
1986
  });
1774
1987
 
1775
1988
  //#endregion
@@ -1827,93 +2040,6 @@ const SearchInput = ({ className, placeholder = "Search...", shortcut = "⌘K",
1827
2040
  });
1828
2041
  };
1829
2042
 
1830
- //#endregion
1831
- //#region src/components/ui/select/select.tsx
1832
- const Select = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Root, {
1833
- "data-slot": "select",
1834
- ...props
1835
- });
1836
- const SelectGroup = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Group, {
1837
- "data-slot": "select-group",
1838
- ...props
1839
- });
1840
- const SelectValue = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Value, {
1841
- "data-slot": "select-value",
1842
- ...props
1843
- });
1844
- const SelectTrigger = ({ className, size = "default", children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Trigger, {
1845
- "data-slot": "select-trigger",
1846
- "data-size": size,
1847
- className: require_toggle_row.cn("data-[placeholder]:text-muted-foreground/60 [&_svg:not([class*='text-'])]:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 flex w-fit touch-manipulation items-center justify-between gap-1.5 rounded-md border-0 bg-transparent px-3 py-2 text-[13px] whitespace-nowrap shadow-[var(--shadow-input)] hover:shadow-[var(--shadow-input-hover)] transition-[color,box-shadow] duration-100 ease-out outline-none focus-visible:shadow-[0_0_0_1px_var(--ring),0_0_0_4px_var(--ring-halo,#0072EF26)] aria-invalid:shadow-[0_0_0_1px_var(--destructive)] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:text-[13px] data-[size=sm]:px-2.5 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[state=open]:[&>svg:last-of-type]:rotate-180", className),
1848
- ...props,
1849
- children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Icon, {
1850
- asChild: true,
1851
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1852
- icon: _hugeicons_core_free_icons.ArrowDown01Icon,
1853
- size: 16,
1854
- className: "opacity-50 transition-transform duration-150 ease-out motion-reduce:transition-none"
1855
- })
1856
- })]
1857
- });
1858
- const SelectContent = ({ className, children, position = "popper", align = "start", ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Content, {
1859
- "data-slot": "select-content",
1860
- className: require_toggle_row.cn("bg-popover text-popover-foreground will-change-[opacity,transform] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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 motion-reduce:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-xl border-0 shadow-[var(--shadow-elevated)]", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
1861
- position,
1862
- align,
1863
- ...props,
1864
- children: [
1865
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectScrollUpButton, {}),
1866
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Viewport, {
1867
- className: require_toggle_row.cn("p-1", position === "popper" && "w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),
1868
- children
1869
- }),
1870
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectScrollDownButton, {})
1871
- ]
1872
- }) });
1873
- const SelectLabel = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Label, {
1874
- "data-slot": "select-label",
1875
- className: require_toggle_row.cn("text-muted-foreground px-2 py-1.5 text-xs", className),
1876
- ...props
1877
- });
1878
- const SelectItem = ({ className, children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Item, {
1879
- "data-slot": "select-item",
1880
- className: require_toggle_row.cn("data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[state=checked]:font-medium [&_svg:not([class*='text-'])]:text-muted-foreground relative 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 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
1881
- ...props,
1882
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1883
- "data-slot": "select-item-indicator",
1884
- className: "absolute right-2 flex size-3.5 items-center justify-center",
1885
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1886
- icon: _hugeicons_core_free_icons.Tick01Icon,
1887
- size: 14
1888
- }) })
1889
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ItemText, { children })]
1890
- });
1891
- const SelectSeparator = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Separator, {
1892
- "data-slot": "select-separator",
1893
- className: require_toggle_row.cn("bg-border pointer-events-none -mx-1 my-1 h-px", className),
1894
- ...props
1895
- });
1896
- const SelectScrollUpButton = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ScrollUpButton, {
1897
- "data-slot": "select-scroll-up-button",
1898
- className: require_toggle_row.cn("flex cursor-default items-center justify-center py-1", className),
1899
- ...props,
1900
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1901
- icon: _hugeicons_core_free_icons.ArrowUp01Icon,
1902
- size: 16,
1903
- "aria-hidden": true
1904
- })
1905
- });
1906
- const SelectScrollDownButton = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ScrollDownButton, {
1907
- "data-slot": "select-scroll-down-button",
1908
- className: require_toggle_row.cn("flex cursor-default items-center justify-center py-1", className),
1909
- ...props,
1910
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
1911
- icon: _hugeicons_core_free_icons.ArrowDown01Icon,
1912
- size: 16,
1913
- "aria-hidden": true
1914
- })
1915
- });
1916
-
1917
2043
  //#endregion
1918
2044
  //#region src/components/ui/selectable-card/selectable-card.tsx
1919
2045
  const SelectableCard = ({ badge, className, description, icon, iconSize = 20, label, selected, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
@@ -2204,6 +2330,13 @@ const Stepper = ({ steps, currentStep, className, ...props }) => /* @__PURE__ */
2204
2330
  const SCROLLBAR_INSET = 8;
2205
2331
  /** A wider drag target lets the visible thumb stay visually quiet. */
2206
2332
  const SCROLLBAR_HIT_AREA = 12;
2333
+ /** Point several refs, function or object, at the same element. */
2334
+ const mergeRefs = (...refs) => (node) => {
2335
+ refs.forEach((ref) => {
2336
+ if (typeof ref === "function") ref(node);
2337
+ else if (ref) ref.current = node;
2338
+ });
2339
+ };
2207
2340
  /** Collect a row group's leading cells, skipping rows covered by an earlier rowSpan. */
2208
2341
  const collectSectionPinnedCells = ({ pinnedCells, section }) => {
2209
2342
  let occupiedRows = 0;
@@ -2237,8 +2370,9 @@ const measureShelfTop = ({ scrollArea, table }) => {
2237
2370
  return body ? body.getBoundingClientRect().top - scrollArea.getBoundingClientRect().top + scrollArea.scrollTop : 0;
2238
2371
  };
2239
2372
  /** Render a table in a stable tray with keyboard access only when content overflows. */
2240
- const Table = ({ className, scrollAreaProps = {}, stickyFirstColumn = false, ...props }) => {
2373
+ const Table = ({ className, fill = false, scrollAreaProps = {}, stickyFirstColumn = false, viewportRef, ...props }) => {
2241
2374
  const scrollAreaRef = (0, react.useRef)(null);
2375
+ const setViewportRef = (0, react.useMemo)(() => mergeRefs(scrollAreaRef, viewportRef), [viewportRef]);
2242
2376
  const [overflow, setOverflow] = (0, react.useState)({
2243
2377
  horizontal: false,
2244
2378
  vertical: false
@@ -2343,8 +2477,9 @@ const Table = ({ className, scrollAreaProps = {}, stickyFirstColumn = false, ...
2343
2477
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2344
2478
  "data-slot": "table-container",
2345
2479
  "data-tray": "header",
2480
+ "data-fill": fill || void 0,
2346
2481
  dir: props.dir,
2347
- className: require_toggle_row.cn("group/table relative min-w-0 w-full [--table-radius:16px] [--table-shelf-radius:calc(var(--table-radius)_-_var(--tray-inset))] rounded-[var(--table-radius)] bg-[var(--tray-chrome)] px-[var(--tray-inset)] pb-[var(--tray-inset)]", isScrollable ? "overflow-hidden" : "overflow-visible"),
2482
+ className: require_toggle_row.cn("group/table relative min-w-0 w-full overflow-hidden [container-type:inline-size] [--table-radius:16px] [--table-shelf-radius:calc(var(--table-radius)_-_var(--tray-inset))] rounded-[var(--table-radius)] bg-[var(--tray-chrome)] px-[var(--tray-inset)] pb-[var(--tray-inset)]", fill && "flex min-h-0 flex-1 flex-col"),
2348
2483
  children: [
2349
2484
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2350
2485
  "aria-hidden": "true",
@@ -2354,7 +2489,7 @@ const Table = ({ className, scrollAreaProps = {}, stickyFirstColumn = false, ...
2354
2489
  }),
2355
2490
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_scroll_area.Viewport, {
2356
2491
  ...viewportProps,
2357
- ref: scrollAreaRef,
2492
+ ref: setViewportRef,
2358
2493
  "data-slot": "table-scroll-area",
2359
2494
  "data-caption-top": topCaptionHeight > 0,
2360
2495
  "data-native-scrollbars": useNativeScrollbars,
@@ -2369,7 +2504,7 @@ const Table = ({ className, scrollAreaProps = {}, stickyFirstColumn = false, ...
2369
2504
  scrollPaddingTop: headerHeight + topCaptionHeight,
2370
2505
  ...scrollAreaStyle
2371
2506
  },
2372
- className: require_toggle_row.cn("relative min-w-0 overflow-auto overscroll-x-contain rounded-[var(--table-shelf-radius)] data-[native-scrollbars=true]:[scrollbar-width:auto] data-[native-scrollbars=true]:[&::-webkit-scrollbar]:block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ring)]", scrollAreaClassName),
2507
+ className: require_toggle_row.cn("relative min-w-0 overflow-auto overscroll-none rounded-[var(--table-shelf-radius)] data-[native-scrollbars=true]:[scrollbar-width:auto] data-[native-scrollbars=true]:[&::-webkit-scrollbar]:block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ring)]", fill && "min-h-0 flex-1", scrollAreaClassName),
2373
2508
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("table", {
2374
2509
  "data-slot": "table",
2375
2510
  "data-sticky-first-column": stickyFirstColumn || void 0,
@@ -2450,13 +2585,13 @@ const TableFooter = ({ className, ...props }) => {
2450
2585
  ...props
2451
2586
  });
2452
2587
  };
2453
- const TableRow = ({ className, ...props }) => {
2454
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
2455
- "data-slot": "table-row",
2456
- className: require_toggle_row.cn("hover:bg-[var(--overlay-hover)] data-[state=selected]:bg-[var(--overlay-selected)] data-[state=selected]:hover:bg-[var(--overlay-selected-hover)] border-b border-[var(--border-divider)] transition-[background-color] duration-100", "hover:[--table-row-overlay:var(--overlay-hover)] data-[state=selected]:[--table-row-overlay:var(--overlay-selected)] data-[state=selected]:hover:[--table-row-overlay:var(--overlay-selected-hover)]", className),
2457
- ...props
2458
- });
2459
- };
2588
+ const TableRow = (0, react.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
2589
+ ref,
2590
+ "data-slot": "table-row",
2591
+ className: require_toggle_row.cn("hover:bg-[var(--overlay-hover)] data-[state=selected]:bg-[var(--table-row-selected)] data-[state=selected]:hover:bg-[var(--table-row-selected-hover)] border-b border-[var(--border-divider)]", "hover:[--table-row-overlay:var(--overlay-hover)] data-[state=selected]:[--table-row-overlay:var(--table-row-selected)] data-[state=selected]:hover:[--table-row-overlay:var(--table-row-selected-hover)]", className),
2592
+ ...props
2593
+ }));
2594
+ TableRow.displayName = "TableRow";
2460
2595
  const TableHead = ({ className, scope, ...props }) => {
2461
2596
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2462
2597
  "data-slot": "table-head",
@@ -2481,17 +2616,1326 @@ const TableCaption = ({ className, ...props }) => {
2481
2616
  };
2482
2617
 
2483
2618
  //#endregion
2484
- //#region src/components/ui/tabs/tabs.tsx
2485
- const Tabs = ({ className, orientation = "horizontal", ...props }) => {
2486
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tabs.Root, {
2487
- "data-slot": "tabs",
2488
- "data-orientation": orientation,
2489
- orientation,
2490
- className: require_toggle_row.cn("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", className),
2491
- ...props
2619
+ //#region src/components/ui/data-table/create-column-helper.ts
2620
+ /**
2621
+ * Creates a helper that builds typed column definitions for rows of type `TData`. Its `accessor`, `display` and `group` methods infer each column's value type.
2622
+ *
2623
+ * @example
2624
+ * ```tsx
2625
+ * const columnHelper = createColumnHelper<User>();
2626
+ *
2627
+ * const columns = [
2628
+ * columnHelper.accessor('name', { header: 'Name' }),
2629
+ * columnHelper.accessor('email', { header: 'Email' }),
2630
+ * ];
2631
+ * ```
2632
+ * @returns A column helper for rows of type `TData`.
2633
+ * @see ColumnDef
2634
+ * @see useDataTable
2635
+ */
2636
+ const createColumnHelper = _tanstack_react_table.createColumnHelper;
2637
+
2638
+ //#endregion
2639
+ //#region src/components/ui/data-table/data-table-context.ts
2640
+ const DataTableContext = (0, react.createContext)(null);
2641
+ /**
2642
+ * Read the state of the nearest `DataTable`, for building custom table parts.
2643
+ * Throws when called outside a `DataTable`.
2644
+ */
2645
+ const useDataTableContext = () => {
2646
+ const context = (0, react.useContext)(DataTableContext);
2647
+ if (!context) throw new Error("DataTable parts must be used inside a DataTable");
2648
+ return context;
2649
+ };
2650
+
2651
+ //#endregion
2652
+ //#region src/components/ui/data-table/data-table.tsx
2653
+ /**
2654
+ * Root of a data table. Holds the table state for `DataTableContent`, `DataTablePagination` and the other parts.
2655
+ *
2656
+ * @example
2657
+ * ```tsx
2658
+ * const dataTable = useDataTable({ columns, data });
2659
+ *
2660
+ * <DataTable table={dataTable}>
2661
+ * <DataTableToolbar>
2662
+ * <DataTableColumnVisibility />
2663
+ * </DataTableToolbar>
2664
+ * <DataTableContent />
2665
+ * </DataTable>
2666
+ * ```
2667
+ * @returns The rendered data table root element.
2668
+ * @see useDataTable
2669
+ * @see DataTableContent
2670
+ * @see DataTableToolbar
2671
+ */
2672
+ const DataTable = ({ children, className, fill = false, table, ...props }) => {
2673
+ const contextValue = (0, react.useMemo)(() => ({
2674
+ ...table,
2675
+ fill
2676
+ }), [table, fill]);
2677
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableContext.Provider, {
2678
+ value: contextValue,
2679
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2680
+ "data-slot": "data-table",
2681
+ "data-fill": fill || void 0,
2682
+ className: require_toggle_row.cn("flex min-w-0 flex-col gap-3", fill && "min-h-0 flex-1", className),
2683
+ ...props,
2684
+ children
2685
+ })
2492
2686
  });
2493
2687
  };
2494
- const tabsListVariants = (0, class_variance_authority.cva)("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col", {
2688
+ /**
2689
+ * Row above the table for search, filters and actions.
2690
+ *
2691
+ * @example
2692
+ * ```tsx
2693
+ * <DataTableToolbar>
2694
+ * <Input placeholder="Search users" />
2695
+ * <DataTableColumnVisibility />
2696
+ * </DataTableToolbar>
2697
+ * ```
2698
+ * @returns The rendered toolbar element.
2699
+ * @see DataTable
2700
+ * @see DataTableColumnVisibility
2701
+ */
2702
+ const DataTableToolbar = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2703
+ "data-slot": "data-table-toolbar",
2704
+ className: require_toggle_row.cn("flex flex-wrap items-center gap-2", className),
2705
+ ...props
2706
+ });
2707
+
2708
+ //#endregion
2709
+ //#region src/components/ui/data-table/get-column-label.ts
2710
+ /**
2711
+ * Read a column the way users see it, so menus and handles name it: its `meta.label`, then a plain-text header, then its id.
2712
+ */
2713
+ const getColumnLabel = (column) => {
2714
+ const { header, meta } = column.columnDef;
2715
+ const fallback = typeof header === "string" ? header : column.id;
2716
+ return meta?.label ?? fallback;
2717
+ };
2718
+
2719
+ //#endregion
2720
+ //#region src/components/ui/data-table/data-table-column-filter.tsx
2721
+ const TEXT_FILTER_PLACEHOLDER = "Contains";
2722
+ const EMPTY_OPTIONS_TEXT = "No values";
2723
+ /**
2724
+ * Turn cell values into checklist options. List-valued cells count as one value each in TanStack's facets, so their items are
2725
+ * spread out first: a tags column then offers each tag rather than each combination. Empty values offer nothing to check.
2726
+ */
2727
+ const toOptions = ({ values }) => {
2728
+ const items = values.flatMap((value) => Array.isArray(value) ? value : [value]).filter((value) => value !== void 0 && value !== null && value !== "").map(String);
2729
+ return [...new Set(items)].sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
2730
+ };
2731
+ /**
2732
+ * The values a `values` filter offers: the column's `filterOptions`, else the values in the data.
2733
+ * Client filtering reads TanStack's facets, which leave out the column's own filter so unchecked values stay offered.
2734
+ * Manual filtering has no facets, so it falls back to the values in the rows currently loaded.
2735
+ * Checked values stay listed even when other filters hide every row that holds them, so they can be unchecked.
2736
+ */
2737
+ const getFilterOptions = ({ column, selected, table }) => {
2738
+ const filterOptions = column.columnDef.meta?.filterOptions;
2739
+ if (filterOptions) return filterOptions;
2740
+ return toOptions({ values: [...table.options.manualFiltering ? table.getCoreRowModel().flatRows.map((row) => row.getValue(column.id)) : [...column.getFacetedUniqueValues().keys()], ...selected] });
2741
+ };
2742
+ /** The checklist of a `values` filter. The checked values are the filter value; unchecking the last one removes the filter. */
2743
+ const DataTableValuesFilter = ({ column, filterValue }) => {
2744
+ const { table } = useDataTableContext();
2745
+ const selected = Array.isArray(filterValue) ? filterValue.map(String) : [];
2746
+ const options = getFilterOptions({
2747
+ column,
2748
+ selected,
2749
+ table
2750
+ });
2751
+ const toggle = ({ checked, option }) => {
2752
+ const next = checked ? [...selected, option] : selected.filter((value) => value !== option);
2753
+ column.setFilterValue(next.length > 0 ? next : void 0);
2754
+ };
2755
+ if (options.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2756
+ className: "text-sm text-muted-foreground",
2757
+ children: EMPTY_OPTIONS_TEXT
2758
+ });
2759
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2760
+ "data-slot": "data-table-column-filter-options",
2761
+ className: "-m-1 flex max-h-60 flex-col gap-2 overflow-y-auto p-1",
2762
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_toggle_row.Label, {
2763
+ className: "flex items-center gap-2 text-sm font-normal",
2764
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
2765
+ checked: selected.includes(option),
2766
+ onCheckedChange: (checked) => toggle({
2767
+ checked: checked === true,
2768
+ option
2769
+ })
2770
+ }), option]
2771
+ }, option))
2772
+ });
2773
+ };
2774
+ /**
2775
+ * A filter button that opens a column's filter: a text field for `meta.filter: 'text'`, or a checklist for `meta.filter: 'values'`.
2776
+ * `DataTableContent` already adds it to each filterable header; render it yourself only in a header you build without `DataTableContent`.
2777
+ * The checklist offers `meta.filterOptions`, else the values in the data. With manual filtering and no `filterOptions`,
2778
+ * it can only offer the values in the rows currently loaded, so pass `filterOptions` when the server holds more.
2779
+ *
2780
+ * @example
2781
+ * ```tsx
2782
+ * const columns: ColumnDef<User>[] = [
2783
+ * { accessorKey: 'role', header: 'Role', meta: { filter: 'values' } },
2784
+ * ];
2785
+ *
2786
+ * // In a header row you render yourself:
2787
+ * <th>
2788
+ * Role
2789
+ * <DataTableColumnFilter column={header.column} />
2790
+ * </th>
2791
+ * ```
2792
+ * @returns The rendered filter button and its popover.
2793
+ * @see DataTableContent
2794
+ * @see DataTableActiveFilters
2795
+ * @see DataTableSearch
2796
+ */
2797
+ const DataTableColumnFilter = ({ className, column }) => {
2798
+ const label = getColumnLabel(column);
2799
+ const isFiltered = column.getIsFiltered();
2800
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Popover, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, {
2801
+ asChild: true,
2802
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_toggle_row.Button, {
2803
+ "aria-label": isFiltered ? `Filter ${label}, filtered` : `Filter ${label}`,
2804
+ "data-slot": "data-table-column-filter",
2805
+ "data-filtered": isFiltered || void 0,
2806
+ size: "icon-xs",
2807
+ variant: "ghost",
2808
+ className: require_toggle_row.cn("ms-1 align-middle before:-inset-1 data-[filtered=true]:text-foreground", className),
2809
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
2810
+ icon: _hugeicons_core_free_icons.FilterIcon,
2811
+ "aria-hidden": "true"
2812
+ }), isFiltered && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2813
+ "aria-hidden": "true",
2814
+ className: "absolute end-0.5 top-0.5 size-1.5 rounded-full bg-[var(--action)]"
2815
+ })]
2816
+ })
2817
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableColumnFilterContent, { column })] });
2818
+ };
2819
+ /** The body of a column's filter popover, shared by the header filter button and the active-filter chips. */
2820
+ const DataTableColumnFilterContent = ({ column }) => {
2821
+ const label = getColumnLabel(column);
2822
+ const filterValue = column.getFilterValue();
2823
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PopoverContent, {
2824
+ "aria-label": `Filter ${label}`,
2825
+ align: "start",
2826
+ className: "flex w-56 flex-col gap-3 p-3",
2827
+ children: [column.columnDef.meta?.filter === "values" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableValuesFilter, {
2828
+ column,
2829
+ filterValue
2830
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_toggle_row.Input, {
2831
+ "aria-label": `Filter ${label}`,
2832
+ placeholder: TEXT_FILTER_PLACEHOLDER,
2833
+ value: typeof filterValue === "string" ? filterValue : "",
2834
+ onChange: (event) => column.setFilterValue(event.target.value)
2835
+ }), column.getIsFiltered() && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2836
+ "data-slot": "data-table-column-filter-footer",
2837
+ className: "-mx-3 flex justify-end border-t border-[var(--border-divider)] px-3 pt-3",
2838
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_toggle_row.Button, {
2839
+ size: "sm",
2840
+ variant: "secondary",
2841
+ onClick: () => column.setFilterValue(void 0),
2842
+ children: "Clear"
2843
+ })
2844
+ })]
2845
+ });
2846
+ };
2847
+
2848
+ //#endregion
2849
+ //#region src/components/ui/data-table/data-table-active-filters.tsx
2850
+ /** A `values` filter holds the checked values; a `text` filter holds the text. */
2851
+ const toFilterValues = (value) => Array.isArray(value) ? value.map(String) : [String(value)];
2852
+ const MAX_SHOWN_VALUES = 2;
2853
+ const CHIP_CONTROL = "inline-flex h-6 items-center rounded-[4px] outline-none transition-[color,background-color] duration-150 ease-out hover:bg-[var(--overlay-hover)] focus-visible:ring-2 focus-visible:ring-[var(--ring)]";
2854
+ const DataTableFilterChip = ({ column, label, onRemove, removeLabel, values }) => {
2855
+ const fullValue = values.join(", ");
2856
+ const hiddenCount = values.length - MAX_SHOWN_VALUES;
2857
+ const shownValue = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [values.slice(0, MAX_SHOWN_VALUES).join(", "), hiddenCount > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2858
+ className: "ms-1 text-muted-foreground",
2859
+ children: ["+", hiddenCount]
2860
+ })] });
2861
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2862
+ "data-slot": "data-table-filter-chip",
2863
+ title: hiddenCount > 0 ? fullValue : void 0,
2864
+ className: "inline-flex h-8 items-center rounded-md bg-white p-1 text-[13px] shadow-[var(--shadow-secondary)] dark:bg-input/30",
2865
+ children: [
2866
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2867
+ type: "button",
2868
+ "aria-label": removeLabel,
2869
+ onClick: onRemove,
2870
+ className: require_toggle_row.cn(CHIP_CONTROL, "w-6 justify-center text-muted-foreground/70 hover:text-foreground"),
2871
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
2872
+ icon: _hugeicons_core_free_icons.Cancel01Icon,
2873
+ size: 12,
2874
+ strokeWidth: 2,
2875
+ "aria-hidden": "true"
2876
+ })
2877
+ }),
2878
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2879
+ className: "ps-1 pe-2 text-muted-foreground",
2880
+ children: [label, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2881
+ className: "sr-only",
2882
+ children: ": "
2883
+ })]
2884
+ }),
2885
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2886
+ "aria-hidden": "true",
2887
+ className: "h-4 w-px bg-[var(--border-divider)]"
2888
+ }),
2889
+ column ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Popover, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, {
2890
+ asChild: true,
2891
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2892
+ type: "button",
2893
+ "aria-label": `Change ${label} filter: ${fullValue}`,
2894
+ className: require_toggle_row.cn(CHIP_CONTROL, "ms-1 gap-1 ps-1.5 pe-1 font-medium text-[var(--action)]"),
2895
+ children: [shownValue, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
2896
+ icon: _hugeicons_core_free_icons.ArrowDown01Icon,
2897
+ size: 14,
2898
+ "aria-hidden": "true",
2899
+ className: "opacity-60"
2900
+ })]
2901
+ })
2902
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableColumnFilterContent, { column })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2903
+ className: "ps-2 pe-1.5 font-medium text-[var(--action)]",
2904
+ children: shownValue
2905
+ })
2906
+ ]
2907
+ });
2908
+ };
2909
+ /**
2910
+ * One chip per active filter, each with a button that removes it, plus a button that clears them all.
2911
+ * The search text gets a chip too. Renders nothing while no filter is active.
2912
+ *
2913
+ * @example
2914
+ * ```tsx
2915
+ * <DataTable table={dataTable}>
2916
+ * <DataTableToolbar>
2917
+ * <DataTableSearch />
2918
+ * </DataTableToolbar>
2919
+ * <DataTableActiveFilters />
2920
+ * <DataTableContent />
2921
+ * </DataTable>
2922
+ * ```
2923
+ * @returns The rendered filter chips, or nothing when no filter is active.
2924
+ * @see DataTableColumnFilter
2925
+ * @see DataTableSearch
2926
+ * @see useDataTable
2927
+ */
2928
+ const DataTableActiveFilters = ({ className }) => {
2929
+ const { table } = useDataTableContext();
2930
+ const { columnFilters, globalFilter } = table.getState();
2931
+ const search = typeof globalFilter === "string" ? globalFilter : "";
2932
+ if (columnFilters.length === 0 && search === "") return null;
2933
+ const clearAll = () => {
2934
+ table.setColumnFilters([]);
2935
+ table.setGlobalFilter("");
2936
+ };
2937
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
2938
+ "aria-label": "Active filters",
2939
+ "data-slot": "data-table-active-filters",
2940
+ className: require_toggle_row.cn("flex min-w-0 flex-wrap items-center gap-2", className),
2941
+ children: [
2942
+ search !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableFilterChip, {
2943
+ label: "Search",
2944
+ onRemove: () => table.setGlobalFilter(""),
2945
+ removeLabel: "Remove search filter",
2946
+ values: [search]
2947
+ }),
2948
+ columnFilters.map(({ id, value }) => {
2949
+ const column = table.getAllFlatColumns().find((candidate) => candidate.id === id);
2950
+ const label = column ? getColumnLabel(column) : id;
2951
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableFilterChip, {
2952
+ column: column?.columnDef.meta?.filter ? column : void 0,
2953
+ label,
2954
+ onRemove: () => table.setColumnFilters((old) => old.filter((filter) => filter.id !== id)),
2955
+ removeLabel: `Remove ${label} filter`,
2956
+ values: toFilterValues(value)
2957
+ }, id);
2958
+ }),
2959
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_toggle_row.Button, {
2960
+ className: "text-muted-foreground hover:text-foreground",
2961
+ variant: "ghost",
2962
+ onClick: clearAll,
2963
+ children: "Clear filters"
2964
+ })
2965
+ ]
2966
+ });
2967
+ };
2968
+
2969
+ //#endregion
2970
+ //#region src/components/ui/data-table/data-table-column-visibility.tsx
2971
+ /**
2972
+ * Lets people choose which columns are shown, from a menu with a checkbox per column.
2973
+ *
2974
+ * @example
2975
+ * ```tsx
2976
+ * <DataTable table={dataTable}>
2977
+ * <DataTableToolbar>
2978
+ * <DataTableColumnVisibility label="Columns" />
2979
+ * </DataTableToolbar>
2980
+ * <DataTableContent />
2981
+ * </DataTable>
2982
+ * ```
2983
+ * @returns The rendered column picker menu.
2984
+ * @see DataTable
2985
+ * @see DataTableToolbar
2986
+ * @see useDataTable
2987
+ */
2988
+ const DataTableColumnVisibility = ({ className, label = "Columns" }) => {
2989
+ const { table } = useDataTableContext();
2990
+ const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
2991
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuTrigger, {
2992
+ asChild: true,
2993
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_toggle_row.Button, {
2994
+ "data-slot": "data-table-column-visibility",
2995
+ className,
2996
+ variant: "outline",
2997
+ children: [
2998
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
2999
+ icon: _hugeicons_core_free_icons.LayoutThreeColumnIcon,
3000
+ "aria-hidden": "true"
3001
+ }),
3002
+ label,
3003
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
3004
+ icon: _hugeicons_core_free_icons.ArrowDown01Icon,
3005
+ "aria-hidden": "true"
3006
+ })
3007
+ ]
3008
+ })
3009
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuContent, {
3010
+ align: "start",
3011
+ children: columns.map((column) => {
3012
+ const visible = column.getIsVisible();
3013
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dropdown_menu.CheckboxItem, {
3014
+ "data-slot": "data-table-column-visibility-item",
3015
+ className: "relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
3016
+ checked: visible,
3017
+ onCheckedChange: (checked) => column.toggleVisibility(checked === true),
3018
+ onSelect: (event) => event.preventDefault(),
3019
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
3020
+ checked: visible,
3021
+ tabIndex: -1,
3022
+ "aria-hidden": "true",
3023
+ className: "pointer-events-none"
3024
+ }), getColumnLabel(column)]
3025
+ }, column.id);
3026
+ })
3027
+ })] });
3028
+ };
3029
+
3030
+ //#endregion
3031
+ //#region src/components/empty-state/empty-state.tsx
3032
+ const EmptyState = ({ icon: Icon$2, title, description, action, className }) => {
3033
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3034
+ className: require_toggle_row.cn("flex flex-col items-center justify-center py-16 px-8 text-center", className),
3035
+ children: [
3036
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3037
+ className: "flex size-12 items-center justify-center rounded-xl bg-muted mb-4",
3038
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon$2, { className: "size-6 text-muted-foreground" })
3039
+ }),
3040
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3041
+ className: "text-sm font-semibold",
3042
+ children: title
3043
+ }),
3044
+ description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3045
+ className: "text-sm text-muted-foreground mt-1 max-w-sm",
3046
+ children: description
3047
+ }),
3048
+ action && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3049
+ className: "mt-4",
3050
+ children: action
3051
+ })
3052
+ ]
3053
+ });
3054
+ };
3055
+
3056
+ //#endregion
3057
+ //#region src/components/ui/data-table/data-table-placeholder-rows.tsx
3058
+ /** Varied bar widths read as real content rather than one repeated block. */
3059
+ const PLACEHOLDER_BARS = [
3060
+ "w-28",
3061
+ "w-14",
3062
+ "w-24",
3063
+ "w-36",
3064
+ "w-24",
3065
+ "w-14"
3066
+ ];
3067
+ const GHOST_ROW_COUNT = 6;
3068
+ /** Placeholder, group and detail rows are not interactive, so they must not take the row hover fill. */
3069
+ const STATIC_ROW = "hover:bg-transparent hover:[--table-row-overlay:transparent]";
3070
+ const getBarWidth = (columnIndex) => PLACEHOLDER_BARS[columnIndex % PLACEHOLDER_BARS.length];
3071
+ /** Skeleton rows shown while data loads. Only the first bar is announced, so screen readers hear "Loading" once. */
3072
+ const DataTableSkeletonRows = ({ columnCount, rowCount }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: Array.from({ length: rowCount }, (_, rowIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
3073
+ "data-slot": "data-table-skeleton-row",
3074
+ className: STATIC_ROW,
3075
+ children: Array.from({ length: columnCount }, (_$1, columnIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableCell, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Skeleton, {
3076
+ "aria-hidden": rowIndex > 0 || columnIndex > 0 || void 0,
3077
+ className: require_toggle_row.cn("h-4 max-w-full", getBarWidth(columnIndex))
3078
+ }) }, columnIndex))
3079
+ }, rowIndex)) });
3080
+ /** Ghost rows keep the table's shape behind an icon and title. */
3081
+ const DataTableEmptyRow = ({ action, columnCount, icon, title }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
3082
+ "data-slot": "data-table-empty",
3083
+ className: STATIC_ROW,
3084
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableCell, {
3085
+ colSpan: columnCount,
3086
+ className: "p-0 whitespace-normal",
3087
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3088
+ className: "grid",
3089
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3090
+ "aria-hidden": "true",
3091
+ className: "pointer-events-none col-start-1 row-start-1 select-none opacity-45 [mask-image:radial-gradient(ellipse_at_center,transparent_48%,black_88%)]",
3092
+ children: Array.from({ length: GHOST_ROW_COUNT }, (_, rowIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3093
+ "data-slot": "data-table-ghost-row",
3094
+ className: "grid items-center border-b border-[var(--border-divider)] py-3.5 last:border-b-0",
3095
+ style: { gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` },
3096
+ children: Array.from({ length: columnCount }, (_$1, columnIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3097
+ className: "px-4",
3098
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_toggle_row.cn("block h-2.5 max-w-full rounded-full bg-[var(--bg-accented)]", getBarWidth(columnIndex)) })
3099
+ }, columnIndex))
3100
+ }, rowIndex))
3101
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3102
+ className: "sticky start-0 col-start-1 row-start-1 flex w-[100cqw] items-center justify-center justify-self-start",
3103
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmptyState, {
3104
+ action,
3105
+ className: "py-0",
3106
+ icon,
3107
+ title
3108
+ })
3109
+ })]
3110
+ })
3111
+ })
3112
+ });
3113
+
3114
+ //#endregion
3115
+ //#region src/components/ui/data-table/expand-chevron.tsx
3116
+ /** A right-pointing chevron that turns to point down while its group is open. */
3117
+ const ExpandChevron = ({ isOpen }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
3118
+ icon: _hugeicons_core_free_icons.ArrowRight01Icon,
3119
+ "aria-hidden": "true",
3120
+ className: require_toggle_row.cn("transition-transform duration-150 motion-reduce:transition-none", isOpen && "rotate-90")
3121
+ });
3122
+
3123
+ //#endregion
3124
+ //#region src/components/ui/data-table/get-pinned-cell-props.ts
3125
+ /** Pinned cells need an opaque base so scrolling text cannot show through; the body overlay still follows row hover and selection. */
3126
+ const PINNED_BACKGROUND = {
3127
+ body: "bg-card bg-[image:linear-gradient(var(--table-row-overlay,transparent),var(--table-row-overlay,transparent))]",
3128
+ header: "bg-[var(--tray-chrome)]"
3129
+ };
3130
+ /** A 1px divider marks where pinned columns meet the scrolling ones. */
3131
+ const PINNED_EDGE = {
3132
+ left: "shadow-[inset_-1px_0_0_var(--border-divider)]",
3133
+ right: "shadow-[inset_1px_0_0_var(--border-divider)]"
3134
+ };
3135
+ /** Sticky position, background and edge divider for a cell in a pinned column. */
3136
+ const getPinnedCellProps = ({ column, section }) => {
3137
+ const side = column.getIsPinned();
3138
+ if (!side) return {};
3139
+ const isEdge = side === "left" ? column.getIsLastColumn("left") : column.getIsFirstColumn("right");
3140
+ return {
3141
+ className: require_toggle_row.cn("sticky z-10", PINNED_BACKGROUND[section], isEdge && PINNED_EDGE[side]),
3142
+ "data-pinned": side,
3143
+ style: side === "left" ? { insetInlineStart: column.getStart("left") } : { insetInlineEnd: column.getAfter("right") }
3144
+ };
3145
+ };
3146
+
3147
+ //#endregion
3148
+ //#region src/components/ui/data-table/selection-column.tsx
3149
+ /**
3150
+ * Id of the checkbox column added by `selectionColumn`. Use it to find that column, for example when pinning it to the start edge.
3151
+ *
3152
+ * @example
3153
+ * ```tsx
3154
+ * const columnPinning = { initial: { left: [SELECTION_COLUMN_ID] } };
3155
+ * ```
3156
+ * @see selectionColumn
3157
+ * @see useDataTable
3158
+ */
3159
+ const SELECTION_COLUMN_ID = "select";
3160
+ /** Fixed width in px; DataTableContent sizes headers from it when resizing or pinning is on. */
3161
+ const SELECTION_COLUMN_SIZE = 40;
3162
+ const getAllRowsCheckedState = (table) => {
3163
+ if (table.getIsAllPageRowsSelected()) return true;
3164
+ return table.getIsSomePageRowsSelected() ? "indeterminate" : false;
3165
+ };
3166
+ const SelectionCell = ({ row }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
3167
+ "aria-label": "Select row",
3168
+ checked: row.getIsSelected(),
3169
+ disabled: !row.getCanSelect(),
3170
+ onCheckedChange: (checked) => row.toggleSelected(checked === true)
3171
+ });
3172
+ const SelectionHeader = ({ table }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Checkbox, {
3173
+ "aria-label": "Select all rows",
3174
+ checked: getAllRowsCheckedState(table),
3175
+ onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked === true)
3176
+ });
3177
+ /**
3178
+ * A checkbox column for row selection. Put it first in `columns` and pass `selection` to `useDataTable`.
3179
+ *
3180
+ * @example
3181
+ * const columns = [selectionColumn<User>(), { accessorKey: 'name', header: 'Name' }];
3182
+ * @returns A column definition that renders a checkbox for each row and a select-all checkbox in the header.
3183
+ * @see SELECTION_COLUMN_ID
3184
+ * @see useDataTable
3185
+ */
3186
+ const selectionColumn = () => ({
3187
+ cell: SelectionCell,
3188
+ enableHiding: false,
3189
+ enableResizing: false,
3190
+ enableSorting: false,
3191
+ header: SelectionHeader,
3192
+ id: SELECTION_COLUMN_ID,
3193
+ size: SELECTION_COLUMN_SIZE
3194
+ });
3195
+
3196
+ //#endregion
3197
+ //#region src/components/ui/data-table/data-table-rows.tsx
3198
+ /** Fixed layout cells clip and truncate, so a narrowed column cannot spill into its neighbour. The checkbox column never needs it. */
3199
+ const FIXED_LAYOUT_CELL_CLASS = "overflow-hidden text-ellipsis";
3200
+ /**
3201
+ * Pins full-width row content to the visible part of a horizontally scrolling table. The single spanning cell has no
3202
+ * pinned part of its own, so without this the content scrolls off to the start. 100cqw is the tray's width, since the
3203
+ * tray is an inline-size container. The cell drops its padding and this element carries it, so the content is exactly
3204
+ * the visible width and never widens the table.
3205
+ */
3206
+ const STICKY_ROW_CONTENT = "sticky start-0 w-[100cqw] px-4 py-2.5";
3207
+ /** Shown for a group whose rows have no value in the grouped column. */
3208
+ const EMPTY_GROUP_LABEL = "None";
3209
+ /** The checkbox column holds one control, so it stays narrow and never clips. */
3210
+ const isControlColumn = (columnId) => columnId === SELECTION_COLUMN_ID;
3211
+ /** Rows inside groups step in by 1.25rem per level from the cell's own 1rem padding. */
3212
+ const getIndent = (depth) => `calc(1rem + ${depth} * 1.25rem)`;
3213
+ const getGroupLabel = ({ groupingColumnId, row }) => {
3214
+ const value = row.getGroupingValue(groupingColumnId);
3215
+ return `${value === void 0 || value === null || value === "" ? EMPTY_GROUP_LABEL : String(value)} (${row.getLeafRows().filter((leaf) => !leaf.getIsGrouped()).length})`;
3216
+ };
3217
+ const DataTableRow = ({ hasFixedLayout, row, rowRef, ...props }) => {
3218
+ const cells = row.getVisibleCells();
3219
+ const indentedCellId = row.depth > 0 ? cells.find((cell) => !isControlColumn(cell.column.id))?.id : void 0;
3220
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
3221
+ ref: rowRef,
3222
+ "data-state": row.getIsSelected() ? "selected" : void 0,
3223
+ ...props,
3224
+ children: cells.map((cell) => {
3225
+ const pinned = getPinnedCellProps({
3226
+ column: cell.column,
3227
+ section: "body"
3228
+ });
3229
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableCell, {
3230
+ "data-pinned": pinned["data-pinned"],
3231
+ className: require_toggle_row.cn(hasFixedLayout && !isControlColumn(cell.column.id) && FIXED_LAYOUT_CELL_CLASS, pinned.className),
3232
+ style: cell.id === indentedCellId ? {
3233
+ ...pinned.style,
3234
+ paddingInlineStart: getIndent(row.depth)
3235
+ } : pinned.style,
3236
+ children: (0, _tanstack_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext())
3237
+ }, cell.id);
3238
+ })
3239
+ });
3240
+ };
3241
+ /** One full-width row naming the group and how many rows it holds, with a button that opens or closes it. */
3242
+ const DataTableGroupRow = ({ columnCount, groupingColumnId, row, rowRef, ...props }) => {
3243
+ const isOpen = row.getIsExpanded();
3244
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
3245
+ ref: rowRef,
3246
+ "data-slot": "data-table-group-row",
3247
+ className: STATIC_ROW,
3248
+ ...props,
3249
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableCell, {
3250
+ colSpan: columnCount,
3251
+ className: "p-0 font-medium",
3252
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3253
+ className: STICKY_ROW_CONTENT,
3254
+ style: row.depth > 0 ? { paddingInlineStart: getIndent(row.depth) } : void 0,
3255
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
3256
+ type: "button",
3257
+ "aria-expanded": isOpen,
3258
+ onClick: row.getToggleExpandedHandler(),
3259
+ className: "-mx-1.5 inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] [&_svg]:size-3.5",
3260
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExpandChevron, { isOpen }), getGroupLabel({
3261
+ groupingColumnId,
3262
+ row
3263
+ })]
3264
+ })
3265
+ })
3266
+ })
3267
+ });
3268
+ };
3269
+ /** One table row, as a group header or a data row. Row props and `rowRef` land on its `<tr>`. */
3270
+ const DataTableBodyRow = ({ columnCount, hasFixedLayout, row, ...props }) => {
3271
+ const { groupingColumnId } = row;
3272
+ if (groupingColumnId) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableGroupRow, {
3273
+ columnCount,
3274
+ groupingColumnId,
3275
+ row,
3276
+ ...props
3277
+ });
3278
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableRow, {
3279
+ hasFixedLayout,
3280
+ row,
3281
+ ...props
3282
+ });
3283
+ };
3284
+
3285
+ //#endregion
3286
+ //#region src/components/ui/data-table/data-table-content.tsx
3287
+ const DEFAULT_EMPTY_TITLE = "No results";
3288
+ const DEFAULT_EMPTY_FILTERED_TITLE = "No matching results";
3289
+ const DEFAULT_LOADING_ROW_COUNT = 5;
3290
+ const ARIA_SORT = {
3291
+ asc: "ascending",
3292
+ desc: "descending"
3293
+ };
3294
+ const SORT_ICON = {
3295
+ asc: _hugeicons_core_free_icons.ArrowUp01Icon,
3296
+ desc: _hugeicons_core_free_icons.ArrowDown01Icon
3297
+ };
3298
+ /** Arrow keys resize in 16px steps, matching the 4px spacing grid. */
3299
+ const RESIZE_STEP = {
3300
+ ArrowLeft: -16,
3301
+ ArrowRight: 16
3302
+ };
3303
+ /** TanStack's default minimum column width. */
3304
+ const MIN_COLUMN_SIZE = 20;
3305
+ /** TanStack leaves columns unbounded; screen readers get a usable range instead. */
3306
+ const MAX_COLUMN_SIZE = 1e3;
3307
+ /** Rows rendered beyond each edge of the view when virtualization sets no overscan. */
3308
+ const DEFAULT_OVERSCAN = 8;
3309
+ const DefaultEmptyIcon = ({ className, size }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
3310
+ className,
3311
+ icon: _hugeicons_core_free_icons.Table01Icon,
3312
+ size
3313
+ });
3314
+ const getMaxColumnSize = (maxSize) => maxSize === void 0 || maxSize === Number.MAX_SAFE_INTEGER ? MAX_COLUMN_SIZE : maxSize;
3315
+ const DataTableResizeHandle = ({ header }) => {
3316
+ const { column } = header;
3317
+ const { table } = header.getContext();
3318
+ const size = column.getSize();
3319
+ const handleKeyDown = (event) => {
3320
+ const step = RESIZE_STEP[event.key];
3321
+ if (!step) return;
3322
+ event.preventDefault();
3323
+ table.setColumnSizing((sizing) => ({
3324
+ ...sizing,
3325
+ [column.id]: size + step
3326
+ }));
3327
+ };
3328
+ const resize = header.getResizeHandler();
3329
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3330
+ role: "separator",
3331
+ "aria-label": `Resize ${getColumnLabel(column)}`,
3332
+ "aria-orientation": "vertical",
3333
+ "aria-valuemax": getMaxColumnSize(column.columnDef.maxSize),
3334
+ "aria-valuemin": column.columnDef.minSize ?? MIN_COLUMN_SIZE,
3335
+ "aria-valuenow": size,
3336
+ "aria-valuetext": `${size} pixels`,
3337
+ tabIndex: 0,
3338
+ "data-slot": "data-table-resize-handle",
3339
+ "data-resizing": column.getIsResizing() || void 0,
3340
+ onDoubleClick: () => column.resetSize(),
3341
+ onKeyDown: handleKeyDown,
3342
+ onMouseDown: resize,
3343
+ onTouchStart: resize,
3344
+ className: "absolute inset-y-0 end-0 w-2 cursor-col-resize touch-none select-none outline-none after:absolute after:inset-y-2 after:end-0 after:w-px after:bg-[var(--border-divider)] after:opacity-0 hover:after:opacity-100 focus-visible:after:bg-[var(--ring)] focus-visible:after:opacity-100 data-[resizing=true]:after:opacity-100"
3345
+ });
3346
+ };
3347
+ const DataTableHeadCell = ({ header, hasFixedLayout }) => {
3348
+ const { column } = header;
3349
+ const sorted = column.getIsSorted();
3350
+ const sortIndex = column.getSortIndex();
3351
+ const isMultiSort = header.getContext().table.getState().sorting.length > 1;
3352
+ const sortPriority = sorted && isMultiSort ? sortIndex + 1 : void 0;
3353
+ const pinned = getPinnedCellProps({
3354
+ column,
3355
+ section: "header"
3356
+ });
3357
+ const content = header.isPlaceholder ? null : (0, _tanstack_react_table.flexRender)(column.columnDef.header, header.getContext());
3358
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TableHead, {
3359
+ colSpan: header.colSpan,
3360
+ "aria-sort": sorted && sortIndex === 0 ? ARIA_SORT[sorted] : void 0,
3361
+ "data-pinned": pinned["data-pinned"],
3362
+ className: require_toggle_row.cn(column.getCanResize() && "relative", isControlColumn(column.id) && "w-px", hasFixedLayout && !isControlColumn(column.id) && FIXED_LAYOUT_CELL_CLASS, pinned.className),
3363
+ style: {
3364
+ ...pinned.style,
3365
+ width: hasFixedLayout ? header.getSize() : void 0
3366
+ },
3367
+ children: [
3368
+ !header.isPlaceholder && column.getCanSort() ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
3369
+ type: "button",
3370
+ onClick: column.getToggleSortingHandler(),
3371
+ className: "-mx-1.5 inline-flex items-center gap-1 rounded-md px-1.5 py-1 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]",
3372
+ children: [
3373
+ content,
3374
+ sorted && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
3375
+ icon: SORT_ICON[sorted],
3376
+ size: 12,
3377
+ "aria-hidden": "true"
3378
+ }),
3379
+ sortPriority !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3380
+ "aria-hidden": "true",
3381
+ className: "text-[10px] tabular-nums",
3382
+ children: sortPriority
3383
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3384
+ className: "sr-only",
3385
+ children: [", sort priority ", sortPriority]
3386
+ })] })
3387
+ ]
3388
+ }) : content,
3389
+ !header.isPlaceholder && column.getCanFilter() && column.columnDef.meta?.filter && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableColumnFilter, { column }),
3390
+ column.getCanResize() && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableResizeHandle, { header })
3391
+ ]
3392
+ });
3393
+ };
3394
+ /** Holds the height of the rows virtualization leaves unrendered above or below the view. */
3395
+ const DataTableVirtualSpacer = ({ columnCount, height }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
3396
+ "aria-hidden": "true",
3397
+ "data-slot": "data-table-virtual-spacer",
3398
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
3399
+ colSpan: columnCount,
3400
+ className: "p-0",
3401
+ style: {
3402
+ borderWidth: 0,
3403
+ height
3404
+ }
3405
+ })
3406
+ });
3407
+ /**
3408
+ * The table itself: headers, rows, and the loading and empty states.
3409
+ *
3410
+ * @example
3411
+ * ```tsx
3412
+ * const dataTable = useDataTable({ columns, data, sorting: { mode: 'client' } });
3413
+ *
3414
+ * <DataTable table={dataTable}>
3415
+ * <DataTableContent emptyTitle="No users yet" />
3416
+ * </DataTable>
3417
+ * ```
3418
+ * @returns The rendered table element.
3419
+ * @see DataTable
3420
+ * @see useDataTable
3421
+ * @see DataTablePagination
3422
+ */
3423
+ const DataTableContent = ({ className, emptyFilteredTitle = DEFAULT_EMPTY_FILTERED_TITLE, emptyIcon = DefaultEmptyIcon, emptyTitle = DEFAULT_EMPTY_TITLE, loadingRowCount = DEFAULT_LOADING_ROW_COUNT, style, ...props }) => {
3424
+ const { fill, loading, table, virtualization } = useDataTableContext();
3425
+ const viewportRef = (0, react.useRef)(null);
3426
+ const hasFixedLayout = table.options.enableColumnResizing === true || table.options.enableColumnPinning === true || virtualization !== void 0;
3427
+ const columnCount = table.getVisibleLeafColumns().length;
3428
+ const { rows } = table.getRowModel();
3429
+ const headerGroups = table.getHeaderGroups();
3430
+ const headerRowCount = headerGroups.length;
3431
+ const isVirtualized = virtualization !== void 0 && !loading && rows.length > 0;
3432
+ const { estimateRowHeight = 0, overscan = DEFAULT_OVERSCAN } = virtualization ?? {};
3433
+ const getItemKey = (0, react.useCallback)((index) => rows[index].id, [rows]);
3434
+ const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
3435
+ count: isVirtualized ? rows.length : 0,
3436
+ enabled: isVirtualized,
3437
+ estimateSize: () => estimateRowHeight,
3438
+ getItemKey,
3439
+ getScrollElement: () => viewportRef.current,
3440
+ overscan
3441
+ });
3442
+ const renderVirtualRows = () => {
3443
+ const virtualRows = virtualizer.getVirtualItems();
3444
+ const firstRow = virtualRows.at(0);
3445
+ const lastRow = virtualRows.at(-1);
3446
+ const topHeight = firstRow ? firstRow.start : 0;
3447
+ const bottomHeight = lastRow ? virtualizer.getTotalSize() - lastRow.end : 0;
3448
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3449
+ topHeight > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableVirtualSpacer, {
3450
+ columnCount,
3451
+ height: topHeight
3452
+ }),
3453
+ virtualRows.map(({ index }) => {
3454
+ const row = rows[index];
3455
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableBodyRow, {
3456
+ "aria-rowindex": headerRowCount + index + 1,
3457
+ columnCount,
3458
+ "data-index": index,
3459
+ hasFixedLayout,
3460
+ row,
3461
+ rowRef: virtualizer.measureElement
3462
+ }, row.id);
3463
+ }),
3464
+ bottomHeight > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableVirtualSpacer, {
3465
+ columnCount,
3466
+ height: bottomHeight
3467
+ })
3468
+ ] });
3469
+ };
3470
+ const renderEmptyRow = () => {
3471
+ const { columnFilters, globalFilter } = table.getState();
3472
+ if (columnFilters.length === 0 && globalFilter === "") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableEmptyRow, {
3473
+ columnCount,
3474
+ icon: emptyIcon,
3475
+ title: emptyTitle
3476
+ });
3477
+ const clearFilters = () => {
3478
+ table.setColumnFilters([]);
3479
+ table.setGlobalFilter("");
3480
+ };
3481
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableEmptyRow, {
3482
+ action: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_toggle_row.Button, {
3483
+ variant: "outline",
3484
+ size: "sm",
3485
+ onClick: clearFilters,
3486
+ children: "Clear filters"
3487
+ }),
3488
+ columnCount,
3489
+ icon: emptyIcon,
3490
+ title: emptyFilteredTitle
3491
+ });
3492
+ };
3493
+ const renderBody = () => {
3494
+ if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableSkeletonRows, {
3495
+ columnCount,
3496
+ rowCount: loadingRowCount
3497
+ });
3498
+ if (rows.length === 0) return renderEmptyRow();
3499
+ if (isVirtualized) return renderVirtualRows();
3500
+ return rows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableBodyRow, {
3501
+ columnCount,
3502
+ hasFixedLayout,
3503
+ row
3504
+ }, row.id));
3505
+ };
3506
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Table, {
3507
+ fill,
3508
+ "aria-busy": loading || void 0,
3509
+ "aria-rowcount": isVirtualized ? rows.length + headerRowCount : void 0,
3510
+ className: require_toggle_row.cn(hasFixedLayout && "w-auto table-fixed", className),
3511
+ style: hasFixedLayout ? {
3512
+ minWidth: "100%",
3513
+ width: table.getTotalSize(),
3514
+ ...style
3515
+ } : style,
3516
+ ...props,
3517
+ viewportRef,
3518
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableHeader, { children: headerGroups.map((headerGroup, headerIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableRow, {
3519
+ "aria-rowindex": isVirtualized ? headerIndex + 1 : void 0,
3520
+ children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTableHeadCell, {
3521
+ header,
3522
+ hasFixedLayout
3523
+ }, header.id))
3524
+ }, headerGroup.id)) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableBody, { children: renderBody() })]
3525
+ });
3526
+ };
3527
+
3528
+ //#endregion
3529
+ //#region src/components/ui/data-table/data-table-pagination.tsx
3530
+ /**
3531
+ * Previous and next buttons beside the visible row range, for client or server pagination. Renders nothing when pagination is off.
3532
+ *
3533
+ * @example
3534
+ * ```tsx
3535
+ * const dataTable = useDataTable({
3536
+ * columns,
3537
+ * data,
3538
+ * pagination: { mode: 'client', pageSize: 25 },
3539
+ * });
3540
+ *
3541
+ * <DataTable table={dataTable}>
3542
+ * <DataTableContent />
3543
+ * <DataTablePagination />
3544
+ * </DataTable>
3545
+ * ```
3546
+ * @returns The rendered pagination controls, or `null` when pagination is off.
3547
+ * @see useDataTable
3548
+ * @see DataTable
3549
+ */
3550
+ const DataTablePagination = ({ className }) => {
3551
+ const { table } = useDataTableContext();
3552
+ if (!table.options.getPaginationRowModel && !table.options.manualPagination) return null;
3553
+ const { pageIndex, pageSize } = table.getState().pagination;
3554
+ const rowCount = table.getRowCount();
3555
+ const start = pageIndex * pageSize + 1;
3556
+ const end = Math.min((pageIndex + 1) * pageSize, rowCount);
3557
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CursorPagination, {
3558
+ className,
3559
+ hasNext: table.getCanNextPage(),
3560
+ hasPrevious: table.getCanPreviousPage(),
3561
+ label: rowCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3562
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3563
+ className: "text-foreground",
3564
+ children: [
3565
+ start,
3566
+ "–",
3567
+ end
3568
+ ]
3569
+ }),
3570
+ " ",
3571
+ "of ",
3572
+ rowCount
3573
+ ] }) : void 0,
3574
+ onNext: () => table.nextPage(),
3575
+ onPrevious: () => table.previousPage()
3576
+ });
3577
+ };
3578
+
3579
+ //#endregion
3580
+ //#region src/components/ui/data-table/data-table-search.tsx
3581
+ /**
3582
+ * A search field that matches its text across the table's columns. Needs `filtering` in `useDataTable`, and renders nothing without it.
3583
+ * With manual filtering the app receives the text as `globalFilter` and filters the data itself.
3584
+ *
3585
+ * @example
3586
+ * ```tsx
3587
+ * const dataTable = useDataTable({ columns, data, filtering: { mode: 'client' } });
3588
+ *
3589
+ * <DataTable table={dataTable}>
3590
+ * <DataTableToolbar>
3591
+ * <DataTableSearch placeholder="Search users" />
3592
+ * </DataTableToolbar>
3593
+ * <DataTableContent />
3594
+ * </DataTable>
3595
+ * ```
3596
+ * @returns The rendered search field, or nothing when filtering is off.
3597
+ * @see DataTableToolbar
3598
+ * @see DataTableActiveFilters
3599
+ * @see useDataTable
3600
+ */
3601
+ const DataTableSearch = ({ className, placeholder = "Search" }) => {
3602
+ const { table } = useDataTableContext();
3603
+ if (!table.options.enableGlobalFilter) return null;
3604
+ const { globalFilter } = table.getState();
3605
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3606
+ "data-slot": "data-table-search",
3607
+ className: require_toggle_row.cn("relative w-full max-w-64", className),
3608
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hugeicons_react.HugeiconsIcon, {
3609
+ icon: _hugeicons_core_free_icons.Search01Icon,
3610
+ size: 16,
3611
+ "aria-hidden": "true",
3612
+ className: "pointer-events-none absolute start-2 top-1/2 -translate-y-1/2 text-muted-foreground/70"
3613
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_toggle_row.Input, {
3614
+ type: "search",
3615
+ "aria-label": placeholder,
3616
+ placeholder,
3617
+ value: typeof globalFilter === "string" ? globalFilter : "",
3618
+ onChange: (event) => table.setGlobalFilter(event.target.value),
3619
+ className: "ps-8"
3620
+ })]
3621
+ });
3622
+ };
3623
+
3624
+ //#endregion
3625
+ //#region src/components/ui/data-table/use-data-table.ts
3626
+ /** Keeps the pagination state complete when the app has not turned pagination on. */
3627
+ const DEFAULT_PAGE_SIZE = 25;
3628
+ /** Columns filter only when they opt in with `meta.filter` (see `withColumnFilters`). A module constant, so the table gets the same object each render. */
3629
+ const DEFAULT_COLUMN = { enableColumnFilter: false };
3630
+ const isControlled = (feature) => feature !== void 0 && "state" in feature;
3631
+ /**
3632
+ * A table pins to one edge only, so when a change leaves columns on both edges, keep the edge that just gained a column and unpin the other.
3633
+ * When it is not only the end edge that gained, the start edge wins.
3634
+ */
3635
+ const toOneEdge = ({ next, previous }) => {
3636
+ const left = next.left ?? [];
3637
+ const right = next.right ?? [];
3638
+ if (left.length > 0 && right.length > 0) {
3639
+ const previousLeft = previous.left ?? [];
3640
+ const previousRight = previous.right ?? [];
3641
+ return right.some((id) => !previousRight.includes(id)) && left.every((id) => previousLeft.includes(id)) ? { right } : { left };
3642
+ }
3643
+ return right.length > 0 ? { right } : { left };
3644
+ };
3645
+ const getInitialState = ({ fallback, feature }) => feature && !isControlled(feature) ? feature.initial ?? fallback : fallback;
3646
+ /** The table hands over updaters; the app expects the next value, resolved against its current state. */
3647
+ const toTableFeatureState = (feature) => ({
3648
+ onChange: (updater) => feature.onChange((0, _tanstack_react_table.functionalUpdate)(updater, feature.state)),
3649
+ state: feature.state
3650
+ });
3651
+ /** Use the app's state when it owns the feature, otherwise the table's own. */
3652
+ const resolveFeatureState = ({ feature, internal, setInternal }) => isControlled(feature) ? toTableFeatureState(feature) : {
3653
+ onChange: setInternal,
3654
+ state: internal
3655
+ };
3656
+ /**
3657
+ * Matches a row when its value is one of the checked values, or, for a list value, when any item is.
3658
+ * TanStack's `arrIncludesSome` calls `includes` on the row value, which matches substrings of strings and throws on numbers.
3659
+ * Clearing every value removes the filter.
3660
+ */
3661
+ const includesSomeValue = Object.assign((row, columnId, filterValue) => {
3662
+ const value = row.getValue(columnId);
3663
+ return Array.isArray(value) ? value.some((item) => filterValue.includes(String(item))) : filterValue.includes(String(value));
3664
+ }, { autoRemove: (value) => !Array.isArray(value) || value.length === 0 });
3665
+ /**
3666
+ * Give each column with `meta.filter` a matching filter function and let it filter, recursing into column groups.
3667
+ * TanStack's `auto` filter guesses from the first row's value, so a checklist of values over string cells would get a string filter.
3668
+ */
3669
+ const withColumnFilters = (columns) => columns.map((column) => {
3670
+ const withGroups = "columns" in column && column.columns ? {
3671
+ ...column,
3672
+ columns: withColumnFilters(column.columns)
3673
+ } : column;
3674
+ const filter = column.meta?.filter;
3675
+ if (!filter) return withGroups;
3676
+ return {
3677
+ ...withGroups,
3678
+ enableColumnFilter: column.enableColumnFilter ?? true,
3679
+ filterFn: column.filterFn ?? (filter === "values" ? includesSomeValue : "includesString")
3680
+ };
3681
+ });
3682
+ /** The filters a table starts with: the app's seed for client filtering, nothing otherwise. */
3683
+ const getInitialFilters = ({ filtering }) => {
3684
+ const initial = filtering?.mode === "client" ? filtering.initial : void 0;
3685
+ return {
3686
+ columnFilters: initial?.columnFilters ?? [],
3687
+ globalFilter: initial?.globalFilter ?? ""
3688
+ };
3689
+ };
3690
+ /**
3691
+ * Filter state and change handlers for search and column filters, which share one state.
3692
+ * `onFiltersChange` runs after every change, so the caller can react to it (pagination returns to the first page).
3693
+ */
3694
+ const useFilterState = ({ filtering, onFiltersChange }) => {
3695
+ const [internalFilters, setInternalFilters] = (0, react.useState)(() => getInitialFilters({ filtering }));
3696
+ const manual = filtering?.mode === "manual" ? filtering : void 0;
3697
+ const latestManualFilters = (0, react.useRef)(void 0);
3698
+ latestManualFilters.current = manual?.state;
3699
+ const updateFilters = (updater) => {
3700
+ if (manual) {
3701
+ const next = (0, _tanstack_react_table.functionalUpdate)(updater, latestManualFilters.current ?? manual.state);
3702
+ latestManualFilters.current = next;
3703
+ manual.onChange(next);
3704
+ } else setInternalFilters(updater);
3705
+ onFiltersChange();
3706
+ };
3707
+ return {
3708
+ filterState: manual ? manual.state : internalFilters,
3709
+ handleColumnFiltersChange: (updater) => updateFilters((old) => ({
3710
+ ...old,
3711
+ columnFilters: (0, _tanstack_react_table.functionalUpdate)(updater, old.columnFilters)
3712
+ })),
3713
+ handleGlobalFilterChange: (updater) => updateFilters((old) => ({
3714
+ ...old,
3715
+ globalFilter: (0, _tanstack_react_table.functionalUpdate)(updater, old.globalFilter) ?? ""
3716
+ }))
3717
+ };
3718
+ };
3719
+ /** Pinning state where every change goes through toOneEdge, so the table and a controlled onChange only ever see one pinned edge. */
3720
+ const resolvePinningState = ({ columnPinning, internal, setInternal }) => {
3721
+ if (isControlled(columnPinning)) return {
3722
+ onChange: (updater) => columnPinning.onChange(toOneEdge({
3723
+ next: (0, _tanstack_react_table.functionalUpdate)(updater, columnPinning.state),
3724
+ previous: columnPinning.state
3725
+ })),
3726
+ state: columnPinning.state
3727
+ };
3728
+ return {
3729
+ onChange: (updater) => setInternal((old) => toOneEdge({
3730
+ next: (0, _tanstack_react_table.functionalUpdate)(updater, old),
3731
+ previous: old
3732
+ })),
3733
+ state: internal
3734
+ };
3735
+ };
3736
+ /** Row models for the features the table runs in memory; manual features leave their step to the app. */
3737
+ const getRowModels = ({ filtering, grouping, pagination, sorting }) => {
3738
+ const clientFiltering = filtering?.mode === "client";
3739
+ return {
3740
+ getExpandedRowModel: grouping ? (0, _tanstack_react_table.getExpandedRowModel)() : void 0,
3741
+ getFacetedRowModel: clientFiltering ? (0, _tanstack_react_table.getFacetedRowModel)() : void 0,
3742
+ getFacetedUniqueValues: clientFiltering ? (0, _tanstack_react_table.getFacetedUniqueValues)() : void 0,
3743
+ getFilteredRowModel: clientFiltering ? (0, _tanstack_react_table.getFilteredRowModel)() : void 0,
3744
+ getGroupedRowModel: grouping ? (0, _tanstack_react_table.getGroupedRowModel)() : void 0,
3745
+ getPaginationRowModel: pagination?.mode === "client" ? (0, _tanstack_react_table.getPaginationRowModel)() : void 0,
3746
+ getSortedRowModel: sorting?.mode === "client" ? (0, _tanstack_react_table.getSortedRowModel)() : void 0
3747
+ };
3748
+ };
3749
+ /**
3750
+ * Page resets are off (see autoResetPageIndex), so when the data shrinks the page can run past the end.
3751
+ * Clamping only when out of range keeps a fresh data array each render from looping.
3752
+ */
3753
+ const useClampedPageIndex = ({ isClientPagination, pageIndex, table }) => {
3754
+ const lastPageIndex = Math.max(0, table.getPageCount() - 1);
3755
+ (0, react.useEffect)(() => {
3756
+ if (isClientPagination && pageIndex > lastPageIndex) table.setPageIndex(lastPageIndex);
3757
+ }, [
3758
+ isClientPagination,
3759
+ lastPageIndex,
3760
+ pageIndex,
3761
+ table
3762
+ ]);
3763
+ };
3764
+ /**
3765
+ * Create the state for a `DataTable`. Each feature stays off until its option is passed.
3766
+ * Pass `{ state, onChange }` to own a feature's state, or `mode: 'manual'` for server-driven sorting and pagination.
3767
+ * `onChange` receives the next state, ready to store.
3768
+ *
3769
+ * @example
3770
+ * const dataTable = useDataTable({
3771
+ * columns,
3772
+ * data,
3773
+ * pagination: { mode: 'client', pageSize: 25 },
3774
+ * sorting: { mode: 'client' },
3775
+ * });
3776
+ *
3777
+ * <DataTable table={dataTable}>
3778
+ * <DataTableContent />
3779
+ * <DataTablePagination />
3780
+ * </DataTable>
3781
+ * @returns A table instance to pass to `DataTable` as `table`.
3782
+ * @see UseDataTableOptions
3783
+ * @see DataTable
3784
+ * @see DataTableContent
3785
+ */
3786
+ const useDataTable = ({ columnPinning, columnSizing, columnVisibility, columns, data, filtering, getRowId, grouping, loading = false, pagination, selection, sorting, virtualization }) => {
3787
+ const [internalSorting, setInternalSorting] = (0, react.useState)(sorting?.mode === "client" ? sorting.initial ?? [] : []);
3788
+ const [internalPagination, setInternalPagination] = (0, react.useState)({
3789
+ pageIndex: 0,
3790
+ pageSize: pagination?.mode === "client" ? pagination.pageSize : DEFAULT_PAGE_SIZE
3791
+ });
3792
+ const [internalSelection, setInternalSelection] = (0, react.useState)(getInitialState({
3793
+ fallback: {},
3794
+ feature: selection
3795
+ }));
3796
+ const [internalVisibility, setInternalVisibility] = (0, react.useState)(getInitialState({
3797
+ fallback: {},
3798
+ feature: columnVisibility
3799
+ }));
3800
+ const [internalPinning, setInternalPinning] = (0, react.useState)(getInitialState({
3801
+ fallback: { left: [] },
3802
+ feature: columnPinning
3803
+ }));
3804
+ const [internalSizing, setInternalSizing] = (0, react.useState)(getInitialState({
3805
+ fallback: {},
3806
+ feature: columnSizing
3807
+ }));
3808
+ const [expandedGroups, setExpandedGroups] = (0, react.useState)(true);
3809
+ const [internalGrouping, setInternalGrouping] = (0, react.useState)(getInitialState({
3810
+ fallback: [],
3811
+ feature: grouping
3812
+ }));
3813
+ const tableColumns = (0, react.useMemo)(() => withColumnFilters(columns), [columns]);
3814
+ const isClientPagination = pagination?.mode === "client";
3815
+ const handleClientSortingChange = (updater) => {
3816
+ setInternalSorting(updater);
3817
+ if (isClientPagination) setInternalPagination((old) => ({
3818
+ ...old,
3819
+ pageIndex: 0
3820
+ }));
3821
+ };
3822
+ const { filterState, handleColumnFiltersChange, handleGlobalFilterChange } = useFilterState({
3823
+ filtering,
3824
+ onFiltersChange: () => {
3825
+ if (isClientPagination) setInternalPagination((old) => ({
3826
+ ...old,
3827
+ pageIndex: 0
3828
+ }));
3829
+ }
3830
+ });
3831
+ const sortingState = sorting?.mode === "manual" ? toTableFeatureState(sorting) : {
3832
+ onChange: handleClientSortingChange,
3833
+ state: internalSorting
3834
+ };
3835
+ const paginationState = pagination?.mode === "manual" ? toTableFeatureState(pagination) : {
3836
+ onChange: setInternalPagination,
3837
+ state: internalPagination
3838
+ };
3839
+ const selectionState = resolveFeatureState({
3840
+ feature: selection,
3841
+ internal: internalSelection,
3842
+ setInternal: setInternalSelection
3843
+ });
3844
+ const visibilityState = resolveFeatureState({
3845
+ feature: columnVisibility,
3846
+ internal: internalVisibility,
3847
+ setInternal: setInternalVisibility
3848
+ });
3849
+ const pinningState = resolvePinningState({
3850
+ columnPinning,
3851
+ internal: internalPinning,
3852
+ setInternal: setInternalPinning
3853
+ });
3854
+ const sizingState = resolveFeatureState({
3855
+ feature: columnSizing,
3856
+ internal: internalSizing,
3857
+ setInternal: setInternalSizing
3858
+ });
3859
+ const groupingState = resolveFeatureState({
3860
+ feature: grouping,
3861
+ internal: internalGrouping,
3862
+ setInternal: setInternalGrouping
3863
+ });
3864
+ const table = (0, _tanstack_react_table.useReactTable)({
3865
+ autoResetExpanded: false,
3866
+ autoResetPageIndex: false,
3867
+ columnResizeMode: "onChange",
3868
+ columns: tableColumns,
3869
+ data,
3870
+ defaultColumn: DEFAULT_COLUMN,
3871
+ enableColumnFilters: filtering !== void 0,
3872
+ enableColumnPinning: columnPinning !== void 0,
3873
+ enableColumnResizing: columnSizing !== void 0,
3874
+ enableExpanding: grouping !== void 0,
3875
+ enableGlobalFilter: filtering !== void 0,
3876
+ enableGrouping: grouping !== void 0,
3877
+ enableRowSelection: selection === void 0 ? false : (row) => !row.getIsGrouped(),
3878
+ enableSorting: sorting !== void 0,
3879
+ getCoreRowModel: (0, _tanstack_react_table.getCoreRowModel)(),
3880
+ ...getRowModels({
3881
+ filtering,
3882
+ grouping,
3883
+ pagination,
3884
+ sorting
3885
+ }),
3886
+ getRowId,
3887
+ groupedColumnMode: false,
3888
+ manualFiltering: filtering?.mode === "manual",
3889
+ manualPagination: pagination?.mode === "manual",
3890
+ manualSorting: sorting?.mode === "manual",
3891
+ onColumnFiltersChange: handleColumnFiltersChange,
3892
+ onColumnPinningChange: pinningState.onChange,
3893
+ onColumnSizingChange: sizingState.onChange,
3894
+ onColumnVisibilityChange: visibilityState.onChange,
3895
+ onExpandedChange: setExpandedGroups,
3896
+ onGlobalFilterChange: handleGlobalFilterChange,
3897
+ onGroupingChange: groupingState.onChange,
3898
+ onPaginationChange: paginationState.onChange,
3899
+ onRowSelectionChange: selectionState.onChange,
3900
+ onSortingChange: sortingState.onChange,
3901
+ rowCount: pagination?.mode === "manual" ? pagination.rowCount : void 0,
3902
+ state: {
3903
+ columnFilters: filterState.columnFilters,
3904
+ columnPinning: pinningState.state,
3905
+ columnSizing: sizingState.state,
3906
+ columnVisibility: visibilityState.state,
3907
+ expanded: expandedGroups,
3908
+ globalFilter: filterState.globalFilter,
3909
+ grouping: groupingState.state,
3910
+ pagination: paginationState.state,
3911
+ rowSelection: selectionState.state,
3912
+ sorting: sortingState.state
3913
+ }
3914
+ });
3915
+ useClampedPageIndex({
3916
+ isClientPagination,
3917
+ pageIndex: paginationState.state.pageIndex,
3918
+ table
3919
+ });
3920
+ return {
3921
+ loading,
3922
+ table,
3923
+ virtualization
3924
+ };
3925
+ };
3926
+
3927
+ //#endregion
3928
+ //#region src/components/ui/tabs/tabs.tsx
3929
+ const Tabs = ({ className, orientation = "horizontal", ...props }) => {
3930
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tabs.Root, {
3931
+ "data-slot": "tabs",
3932
+ "data-orientation": orientation,
3933
+ orientation,
3934
+ className: require_toggle_row.cn("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", className),
3935
+ ...props
3936
+ });
3937
+ };
3938
+ const tabsListVariants = (0, class_variance_authority.cva)("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col", {
2495
3939
  defaultVariants: { variant: "default" },
2496
3940
  variants: { variant: {
2497
3941
  default: "bg-muted",
@@ -2499,14 +3943,14 @@ const tabsListVariants = (0, class_variance_authority.cva)("rounded-lg p-[3px] g
2499
3943
  navigation: "group-data-[orientation=horizontal]/tabs:h-auto w-full justify-start gap-5 rounded-none border-b border-border-divider bg-transparent p-0"
2500
3944
  } }
2501
3945
  });
2502
- const TabsList = ({ className, variant = "default", ...props }) => {
2503
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tabs.List, {
2504
- "data-slot": "tabs-list",
2505
- "data-variant": variant,
2506
- className: require_toggle_row.cn(tabsListVariants({ variant }), className),
2507
- ...props
2508
- });
2509
- };
3946
+ const TabsList = (0, react.forwardRef)(({ className, variant = "default", ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tabs.List, {
3947
+ ref,
3948
+ "data-slot": "tabs-list",
3949
+ "data-variant": variant,
3950
+ className: require_toggle_row.cn(tabsListVariants({ variant }), className),
3951
+ ...props
3952
+ }));
3953
+ TabsList.displayName = _radix_ui_react_tabs.List.displayName;
2510
3954
  const TabsTrigger = ({ className, ...props }) => {
2511
3955
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tabs.Trigger, {
2512
3956
  "data-slot": "tabs-trigger",
@@ -2668,11 +4112,23 @@ const Textarea = ({ className, ...props }) => {
2668
4112
  const TooltipProvider = _radix_ui_react_tooltip.Provider;
2669
4113
  const Tooltip = _radix_ui_react_tooltip.Root;
2670
4114
  const TooltipTrigger = _radix_ui_react_tooltip.Trigger;
2671
- const TooltipContent = (0, react.forwardRef)(({ className, sideOffset = 6, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tooltip.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tooltip.Content, {
4115
+ const TooltipContent = (0, react.forwardRef)(({ children, className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tooltip.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_tooltip.Content, {
2672
4116
  ref,
4117
+ "data-slot": "tooltip-content",
2673
4118
  sideOffset,
2674
- className: require_toggle_row.cn("z-50 max-w-xs overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-balance text-primary-foreground animate-in fade-in-0 zoom-in-95 duration-150 ease-out data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-100 data-[state=closed]:ease-in data-[side=bottom]:slide-in-from-top-2 data-[side=bottom]:origin-top data-[side=left]:slide-in-from-right-2 data-[side=left]:origin-right data-[side=right]:slide-in-from-left-2 data-[side=right]:origin-left data-[side=top]:slide-in-from-bottom-2 data-[side=top]:origin-bottom motion-reduce:animate-none", className),
2675
- ...props
4119
+ className: require_toggle_row.cn("z-50 max-w-xs rounded-[6px] bg-[var(--tooltip-bg)] px-2 py-1 text-xs leading-4 font-medium text-balance text-[var(--tooltip-fg)] shadow-[inset_0_1px_0_0_oklch(1_0_0/0.08)] [filter:var(--tooltip-drop)]", className),
4120
+ ...props,
4121
+ children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_tooltip.Arrow, {
4122
+ asChild: true,
4123
+ height: 5,
4124
+ width: 10,
4125
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
4126
+ "aria-hidden": "true",
4127
+ className: "-translate-y-px fill-[var(--tooltip-bg)]",
4128
+ viewBox: "0 0 10 5",
4129
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M0 0H10L5.88 4.12a1.25 1.25 0 0 1-1.76 0Z" })
4130
+ })
4131
+ })]
2676
4132
  }) }));
2677
4133
  TooltipContent.displayName = _radix_ui_react_tooltip.Content.displayName;
2678
4134
 
@@ -2729,9 +4185,10 @@ const AssetIcon = ({ symbol, size = 32, className }) => {
2729
4185
  //#endregion
2730
4186
  //#region src/components/copy-button/copy-button.tsx
2731
4187
  const TIMING = {
2732
- feedbackHold: 1500,
2733
- iconSwap: 220,
2734
- reset: 120
4188
+ errorHold: 2e3,
4189
+ iconSwap: 200,
4190
+ reset: 120,
4191
+ successHold: 1e3
2735
4192
  };
2736
4193
  const COPY_STAGE = {
2737
4194
  copied: 1,
@@ -2739,12 +4196,18 @@ const COPY_STAGE = {
2739
4196
  idle: 0
2740
4197
  };
2741
4198
  const ICON = {
4199
+ activeBlur: "blur(0px)",
2742
4200
  activeScale: 1,
2743
- inactiveScale: .72,
2744
- spring: {
2745
- bounce: 0,
2746
- type: "spring",
2747
- visualDuration: TIMING.iconSwap / 1e3
4201
+ inactiveBlur: "blur(4px)",
4202
+ inactiveScale: .25,
4203
+ transition: {
4204
+ duration: TIMING.iconSwap / 1e3,
4205
+ ease: [
4206
+ .4,
4207
+ 0,
4208
+ .2,
4209
+ 1
4210
+ ]
2748
4211
  }
2749
4212
  };
2750
4213
  const LABEL = {
@@ -2765,6 +4228,7 @@ const HIDDEN_RESET_TRANSITION = {
2765
4228
  duration: 0
2766
4229
  };
2767
4230
  const ICON_RESET_TRANSITION = {
4231
+ filter: HIDDEN_RESET_TRANSITION,
2768
4232
  opacity: RESET_TRANSITION,
2769
4233
  scale: HIDDEN_RESET_TRANSITION
2770
4234
  };
@@ -2774,12 +4238,11 @@ const LABEL_RESET_TRANSITION = {
2774
4238
  };
2775
4239
  const REDUCED_MOTION_TRANSITION = { duration: 0 };
2776
4240
  /** Copies a value and presents stable, accessible success or failure feedback. */
2777
- const CopyButton = ({ value, label, variant = "outline", size = "icon-xs", className }) => {
4241
+ const CopyButton = ({ value, ariaLabel: idleAriaLabel, label, variant = "outline", size = "icon-xs", className }) => {
2778
4242
  const [stage, setStage] = (0, react.useState)(COPY_STAGE.idle);
2779
4243
  const timeoutRef = (0, react.useRef)(null);
2780
4244
  const requestIdRef = (0, react.useRef)(0);
2781
4245
  const shouldReduceMotion = (0, motion_react.useReducedMotion)();
2782
- const animationStyle = { willChange: shouldReduceMotion ? "auto" : "transform, opacity" };
2783
4246
  (0, react.useEffect)(() => {
2784
4247
  return () => {
2785
4248
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
@@ -2788,7 +4251,7 @@ const CopyButton = ({ value, label, variant = "outline", size = "icon-xs", class
2788
4251
  const showFeedback = (nextStage) => {
2789
4252
  setStage(nextStage);
2790
4253
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
2791
- timeoutRef.current = setTimeout(() => setStage(COPY_STAGE.idle), TIMING.feedbackHold);
4254
+ timeoutRef.current = setTimeout(() => setStage(COPY_STAGE.idle), nextStage === COPY_STAGE.error ? TIMING.errorHold : TIMING.successHold);
2792
4255
  };
2793
4256
  const handleCopy = async () => {
2794
4257
  const requestId = ++requestIdRef.current;
@@ -2799,7 +4262,7 @@ const CopyButton = ({ value, label, variant = "outline", size = "icon-xs", class
2799
4262
  if (requestId === requestIdRef.current) showFeedback(COPY_STAGE.error);
2800
4263
  }
2801
4264
  };
2802
- let ariaLabel = label || "Copy to clipboard";
4265
+ let ariaLabel = idleAriaLabel || label || "Copy to clipboard";
2803
4266
  let announcement = "";
2804
4267
  if (stage === COPY_STAGE.copied) {
2805
4268
  ariaLabel = "Copied";
@@ -2808,7 +4271,7 @@ const CopyButton = ({ value, label, variant = "outline", size = "icon-xs", class
2808
4271
  ariaLabel = "Copy failed";
2809
4272
  announcement = "Copy failed";
2810
4273
  }
2811
- let iconTransition = ICON.spring;
4274
+ let iconTransition = ICON.transition;
2812
4275
  let labelTransition = LABEL.spring;
2813
4276
  if (stage === COPY_STAGE.idle) {
2814
4277
  iconTransition = ICON_RESET_TRANSITION;
@@ -2829,8 +4292,8 @@ const CopyButton = ({ value, label, variant = "outline", size = "icon-xs", class
2829
4292
  },
2830
4293
  {
2831
4294
  icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckIcon, {
2832
- size: null,
2833
- strokeWidth: 2
4295
+ className: "[&_path]:[stroke-width:var(--icon-stroke-width,1.75)]",
4296
+ size: null
2834
4297
  }),
2835
4298
  label: label ? "Copied" : void 0,
2836
4299
  stage: COPY_STAGE.copied
@@ -2860,17 +4323,18 @@ const CopyButton = ({ value, label, variant = "outline", size = "icon-xs", class
2860
4323
  className: "col-start-1 row-start-1 flex items-center gap-1.5",
2861
4324
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.motion.span, {
2862
4325
  initial: false,
4326
+ "data-slot": visualState.stage === COPY_STAGE.copied ? "copy-button-check" : void 0,
4327
+ "data-state": isActive ? "checked" : "unchecked",
2863
4328
  animate: {
4329
+ filter: isIdleVisual || isActive ? ICON.activeBlur : ICON.inactiveBlur,
2864
4330
  opacity: isActive ? 1 : 0,
2865
4331
  scale: isIdleVisual || isActive ? ICON.activeScale : ICON.inactiveScale
2866
4332
  },
2867
4333
  transition: iconTransition,
2868
- style: animationStyle,
2869
4334
  className: "flex items-center",
2870
4335
  children: visualState.icon
2871
4336
  }), visualState.label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.motion.span, {
2872
4337
  initial: false,
2873
- style: animationStyle,
2874
4338
  animate: {
2875
4339
  opacity: isActive ? 1 : 0,
2876
4340
  y: isIdleVisual || isActive ? LABEL.activeOffset : LABEL.inactiveOffset
@@ -3095,7 +4559,7 @@ const DomainList = ({ className, domains, onChange, placeholder = "https://examp
3095
4559
  children: domains.map((domain) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
3096
4560
  className: "flex items-center justify-between gap-2 rounded-md border bg-[var(--bg-bottom)] px-3 py-2 text-sm",
3097
4561
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3098
- className: "font-mono text-sm truncate",
4562
+ className: "text-sm tabular-nums truncate",
3099
4563
  children: domain
3100
4564
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3101
4565
  type: "button",
@@ -3111,32 +4575,6 @@ const DomainList = ({ className, domains, onChange, placeholder = "https://examp
3111
4575
  });
3112
4576
  };
3113
4577
 
3114
- //#endregion
3115
- //#region src/components/empty-state/empty-state.tsx
3116
- const EmptyState = ({ icon: Icon$2, title, description, action, className }) => {
3117
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3118
- className: require_toggle_row.cn("flex flex-col items-center justify-center py-16 px-8 text-center", className),
3119
- children: [
3120
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3121
- className: "flex size-12 items-center justify-center rounded-xl bg-muted mb-4",
3122
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon$2, { className: "size-6 text-muted-foreground" })
3123
- }),
3124
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3125
- className: "text-sm font-semibold",
3126
- children: title
3127
- }),
3128
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3129
- className: "text-sm text-muted-foreground mt-1 max-w-sm",
3130
- children: description
3131
- }),
3132
- action && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3133
- className: "mt-4",
3134
- children: action
3135
- })
3136
- ]
3137
- });
3138
- };
3139
-
3140
4578
  //#endregion
3141
4579
  //#region src/components/info-banner/info-banner.tsx
3142
4580
  const spring$1 = {
@@ -3428,47 +4866,40 @@ const SettingsSection = ({ title, description, children, variant = "default", cl
3428
4866
  //#region src/components/status-badge/status-badge.tsx
3429
4867
  const statusConfig = {
3430
4868
  active: {
3431
- dot: true,
3432
4869
  label: "Active",
3433
4870
  variant: "success"
3434
4871
  },
3435
4872
  blocked: {
3436
- dot: true,
3437
4873
  label: "Blocked",
3438
4874
  variant: "danger"
3439
4875
  },
3440
4876
  inactive: {
3441
- dot: true,
3442
4877
  label: "Inactive",
3443
4878
  variant: "inactive"
3444
4879
  },
3445
4880
  live: {
3446
- dot: true,
3447
4881
  label: "Live",
3448
4882
  variant: "success"
3449
4883
  },
3450
4884
  pending: {
3451
- dot: true,
3452
4885
  label: "Pending",
3453
4886
  variant: "warning"
3454
4887
  },
3455
4888
  processing: {
3456
- dot: true,
3457
4889
  label: "Processing",
3458
4890
  variant: "process"
3459
4891
  },
3460
4892
  sandbox: {
3461
- dot: true,
3462
4893
  label: "Sandbox",
3463
4894
  variant: "warning"
3464
4895
  }
3465
4896
  };
3466
4897
  const StatusBadge = ({ status, label, className }) => {
3467
4898
  const config = statusConfig[status];
3468
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Badge, {
4899
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Badge, {
3469
4900
  variant: config.variant,
3470
- className: require_toggle_row.cn("gap-1.5", className),
3471
- children: [config.dot && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "size-1.5 rounded-full bg-current opacity-70" }), label || config.label]
4901
+ className,
4902
+ children: label || config.label
3472
4903
  });
3473
4904
  };
3474
4905
 
@@ -3502,8 +4933,24 @@ const StatusBadge = ({ status, label, className }) => {
3502
4933
  const TabNavigation = ({ children, defaultValue, items, listLabel, onValueChange, value, ...props }) => {
3503
4934
  const [internalValue, setInternalValue] = (0, react.useState)(defaultValue ?? items.find((item) => !item.disabled)?.value);
3504
4935
  const selectedValue = value ?? internalValue;
3505
- const indicatorId = (0, react.useId)();
3506
4936
  const shouldReduceMotion = (0, motion_react.useReducedMotion)();
4937
+ const listRef = (0, react.useRef)(null);
4938
+ const [indicator, setIndicator] = (0, react.useState)();
4939
+ (0, react.useLayoutEffect)(() => {
4940
+ const list = listRef.current;
4941
+ if (!list) return;
4942
+ const measure = () => {
4943
+ const active = list.querySelector("[data-slot=\"tabs-trigger\"][data-state=\"active\"]");
4944
+ setIndicator(active ? {
4945
+ left: active.offsetLeft,
4946
+ width: active.offsetWidth
4947
+ } : void 0);
4948
+ };
4949
+ measure();
4950
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(measure);
4951
+ list.querySelectorAll("[data-slot=\"tabs-trigger\"]").forEach((trigger) => observer?.observe(trigger));
4952
+ return () => observer?.disconnect();
4953
+ }, [selectedValue, items]);
3507
4954
  const [prevItems, setPrevItems] = (0, react.useState)(items);
3508
4955
  if (prevItems !== items) {
3509
4956
  setPrevItems(items);
@@ -3516,27 +4963,33 @@ const TabNavigation = ({ children, defaultValue, items, listLabel, onValueChange
3516
4963
  setInternalValue(nextValue);
3517
4964
  onValueChange?.(nextValue);
3518
4965
  },
3519
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TabsList, {
4966
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TabsList, {
3520
4967
  variant: "navigation",
3521
4968
  "aria-label": listLabel,
3522
- children: items.map(({ disabled, label, value: value$1 }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TabsTrigger, {
4969
+ ref: listRef,
4970
+ className: "relative",
4971
+ children: [items.map(({ disabled, label, value: value$1 }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TabsTrigger, {
3523
4972
  value: value$1,
3524
4973
  disabled,
3525
- children: [label, selectedValue === value$1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.motion.span, {
3526
- "aria-hidden": "true",
3527
- className: "absolute inset-x-0 -bottom-px h-px bg-(--action)",
3528
- layoutId: `tab-navigation-indicator-${indicatorId}`,
3529
- transition: shouldReduceMotion ? { duration: 0 } : {
3530
- duration: .2,
3531
- ease: [
3532
- .645,
3533
- .045,
3534
- .355,
3535
- 1
3536
- ]
3537
- }
3538
- })]
3539
- }, value$1))
4974
+ children: label
4975
+ }, value$1)), indicator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.motion.span, {
4976
+ "aria-hidden": "true",
4977
+ className: "pointer-events-none absolute left-0 -bottom-px h-px bg-(--action)",
4978
+ initial: false,
4979
+ animate: {
4980
+ width: indicator.width,
4981
+ x: indicator.left
4982
+ },
4983
+ transition: shouldReduceMotion ? { duration: 0 } : {
4984
+ duration: .2,
4985
+ ease: [
4986
+ .645,
4987
+ .045,
4988
+ .355,
4989
+ 1
4990
+ ]
4991
+ }
4992
+ })]
3540
4993
  }), children]
3541
4994
  });
3542
4995
  };
@@ -3627,6 +5080,16 @@ const renderInput = (input, id) => {
3627
5080
  })
3628
5081
  });
3629
5082
  };
5083
+ /**
5084
+ * DEPRECATED. Never use in new code. Use `FlushCardStack` with a `ToggleRow`
5085
+ * header instead; put sub-options in the item's reveal.
5086
+ *
5087
+ * Kept so existing callers keep rendering while they migrate.
5088
+ *
5089
+ * @deprecated Use `FlushCardStack` + `ToggleRow`.
5090
+ * @see FlushCardStack
5091
+ * @see ToggleRow
5092
+ */
3630
5093
  const ToggleCard = ({ accordionKey, title, description, inputProps, allowExpand = true, defaultExpanded, value, onValueChange, collapsible = true, Tags, RightSideTags, notification, actionLink, customActionIcon, onCardClick: _onCardClick, children, disabled, triggerTestId, className, triggerClassName }) => {
3631
5094
  const generatedId = (0, react.useId)();
3632
5095
  const inputId = inputProps?.id ?? generatedId;
@@ -5378,6 +6841,14 @@ exports.CopyIcon = CopyIcon;
5378
6841
  exports.CursorLogo = CursorLogo;
5379
6842
  exports.CursorPagination = CursorPagination;
5380
6843
  exports.DangerZone = DangerZone;
6844
+ exports.DataTable = DataTable;
6845
+ exports.DataTableActiveFilters = DataTableActiveFilters;
6846
+ exports.DataTableColumnFilter = DataTableColumnFilter;
6847
+ exports.DataTableColumnVisibility = DataTableColumnVisibility;
6848
+ exports.DataTableContent = DataTableContent;
6849
+ exports.DataTablePagination = DataTablePagination;
6850
+ exports.DataTableSearch = DataTableSearch;
6851
+ exports.DataTableToolbar = DataTableToolbar;
5381
6852
  exports.Dialog = Dialog;
5382
6853
  exports.DialogBody = DialogBody;
5383
6854
  exports.DialogClose = DialogClose;
@@ -5446,6 +6917,7 @@ exports.RadioField = RadioField;
5446
6917
  exports.RadioGroup = RadioGroup;
5447
6918
  exports.RadioGroupItem = RadioGroupItem;
5448
6919
  exports.RefreshCWIcon = RefreshCWIcon;
6920
+ exports.SELECTION_COLUMN_ID = SELECTION_COLUMN_ID;
5449
6921
  exports.ScrollArea = ScrollArea;
5450
6922
  exports.ScrollBar = ScrollBar;
5451
6923
  exports.SearchIcon = SearchIcon;
@@ -5517,12 +6989,15 @@ exports.__toESM = __toESM;
5517
6989
  exports.badgeVariants = badgeVariants;
5518
6990
  exports.buttonVariants = require_toggle_row.buttonVariants;
5519
6991
  exports.cn = require_toggle_row.cn;
6992
+ exports.createColumnHelper = createColumnHelper;
6993
+ exports.selectionColumn = selectionColumn;
5520
6994
  Object.defineProperty(exports, 'toast', {
5521
6995
  enumerable: true,
5522
6996
  get: function () {
5523
6997
  return sonner.toast;
5524
6998
  }
5525
6999
  });
7000
+ exports.useDataTable = useDataTable;
5526
7001
  exports.useIconConfig = useIconConfig;
5527
7002
  exports.useUnsavedChanges = useUnsavedChanges;
5528
7003
  exports.wellVariants = wellVariants;