@upbound/monarch-blocks 0.4.1 → 0.6.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.
@@ -99,7 +99,15 @@ function CellContextualFilter({
99
99
  );
100
100
  }
101
101
  return /* @__PURE__ */ jsxs(ContextMenuContent, { children: [
102
- /* @__PURE__ */ jsx(ContextMenuItem, { disabled, onClick: (event) => event.stopPropagation(), onSelect: handleSelect, children: "Filter by this value" }),
102
+ /* @__PURE__ */ jsx(
103
+ ContextMenuItem,
104
+ {
105
+ disabled,
106
+ onClick: (event) => event.stopPropagation(),
107
+ onSelect: handleSelect,
108
+ children: "Filter by this value"
109
+ }
110
+ ),
103
111
  contextualMenuActions.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
104
112
  /* @__PURE__ */ jsx(ContextMenuSeparator, {}),
105
113
  contextualMenuActions.map(renderAction)
@@ -152,6 +160,9 @@ var twMerge = extendTailwindMerge({
152
160
  function cn(...inputs) {
153
161
  return twMerge(clsx(inputs));
154
162
  }
163
+ function sortBy(items, getKey) {
164
+ return [...items].sort((a, b) => getKey(a).localeCompare(getKey(b)));
165
+ }
155
166
 
156
167
  // src/lib/data-table/utils.ts
157
168
  var TO_EACH_SIDE = 2;
@@ -214,6 +225,14 @@ function isFilterOnlyColumn(column) {
214
225
  var _a;
215
226
  return ((_a = column.columnDef.meta) == null ? void 0 : _a.filterOnly) === true;
216
227
  }
228
+ function hasFilterableColumns(columns) {
229
+ return columns.some(
230
+ (column) => {
231
+ var _a;
232
+ return !isFilterOnlyColumn(column) && column.getCanFilter() && !!((_a = column.columnDef.meta) == null ? void 0 : _a.filter);
233
+ }
234
+ );
235
+ }
217
236
  function getTableState({
218
237
  error,
219
238
  loading,
@@ -447,6 +466,7 @@ function ColumnOptions({
447
466
  import { Button as Button2 } from "@upbound/monarch-core";
448
467
  import { DropdownMenu as DropdownMenu2, DropdownMenuContent as DropdownMenuContent2, DropdownMenuItem as DropdownMenuItem2, DropdownMenuTrigger as DropdownMenuTrigger2 } from "@upbound/monarch-core";
449
468
  import { Icon as Icon2 } from "@upbound/monarch-core";
469
+ import { Link } from "@upbound/monarch-core";
450
470
 
451
471
  // src/relative-time.tsx
452
472
  import * as React2 from "react";
@@ -592,8 +612,25 @@ function RowActions({
592
612
  contentClassName
593
613
  }) {
594
614
  return /* @__PURE__ */ jsxs3(DropdownMenu2, { children: [
595
- /* @__PURE__ */ jsx4(DropdownMenuTrigger2, { asChild: true, children: /* @__PURE__ */ jsx4(Button2, { variant: "ghost", size: "icon-xs", "aria-label": "Row actions", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx4(Icon2, { name: "ellipsis-vertical", size: "sm" }) }) }),
596
- /* @__PURE__ */ jsx4(DropdownMenuContent2, { align, className: contentClassName, onClick: (event) => event.stopPropagation(), children })
615
+ /* @__PURE__ */ jsx4(DropdownMenuTrigger2, { asChild: true, children: /* @__PURE__ */ jsx4(
616
+ Button2,
617
+ {
618
+ variant: "ghost",
619
+ size: "icon-xs",
620
+ "aria-label": "Row actions",
621
+ onClick: (e) => e.stopPropagation(),
622
+ children: /* @__PURE__ */ jsx4(Icon2, { name: "ellipsis-vertical", size: "sm" })
623
+ }
624
+ ) }),
625
+ /* @__PURE__ */ jsx4(
626
+ DropdownMenuContent2,
627
+ {
628
+ align,
629
+ className: contentClassName,
630
+ onClick: (event) => event.stopPropagation(),
631
+ children
632
+ }
633
+ )
597
634
  ] });
598
635
  }
599
636
  function RowActionItem({
@@ -662,7 +699,7 @@ function getExpandColumnDefinition(options) {
662
699
  function DataTableValueCell({ content, title, className, href, onClick }) {
663
700
  const baseClassName = cn("text-body truncate", className);
664
701
  if (href) {
665
- return /* @__PURE__ */ jsx4("p", { className: baseClassName, children: /* @__PURE__ */ jsx4("a", { href, title, className: "underline hover:no-underline", onClick, children: content }) });
702
+ return /* @__PURE__ */ jsx4("p", { className: baseClassName, children: /* @__PURE__ */ jsx4(Link, { href, title, onClick, children: content }) });
666
703
  }
667
704
  if (title) {
668
705
  return /* @__PURE__ */ jsxs3(Tooltip, { children: [
@@ -689,7 +726,7 @@ function TimestampCell({ timestamp }) {
689
726
  }
690
727
 
691
728
  // src/data-table/data-table.tsx
692
- import * as React8 from "react";
729
+ import * as React9 from "react";
693
730
  import {
694
731
  getCoreRowModel,
695
732
  getExpandedRowModel,
@@ -1718,6 +1755,7 @@ function CelFilterBar({
1718
1755
  (_a = onCompileResultChangeRef.current) == null ? void 0 : _a.call(onCompileResultChangeRef, __spreadProps(__spreadValues({}, displayResult), { isEmitReady }));
1719
1756
  }, [displayResult, isEmitReady]);
1720
1757
  const conditions = tree.root.children.filter(isCelFilterCondition);
1758
+ const containerRef = React3.useRef(null);
1721
1759
  function handleAddFilter(columnId) {
1722
1760
  const condition = createDefaultCondition({ schema, columnId });
1723
1761
  onChange(appendCondition(tree, condition));
@@ -1732,8 +1770,8 @@ function CelFilterBar({
1732
1770
  onChange({ root: __spreadProps(__spreadValues({}, tree.root), { children: [] }) });
1733
1771
  editor.clearSuppress();
1734
1772
  }
1735
- return /* @__PURE__ */ jsxs4("div", { "data-slot": "cel-filter-bar", className: cn("flex flex-wrap items-center gap-2", className), children: [
1736
- /* @__PURE__ */ jsx5(CelAddFilterButton, { schema, conditions, onSelect: handleAddFilter }),
1773
+ return /* @__PURE__ */ jsxs4("div", { "data-slot": "cel-filter-bar", className: cn("flex flex-wrap items-center gap-2", className), ref: containerRef, children: [
1774
+ /* @__PURE__ */ jsx5(CelAddFilterButton, { schema, conditions, onSelect: handleAddFilter, container: containerRef }),
1737
1775
  conditions.map((condition) => {
1738
1776
  const columnDef = resolveColumnDefinition(condition, schema);
1739
1777
  if (!columnDef) return null;
@@ -1748,7 +1786,8 @@ function CelFilterBar({
1748
1786
  controller: editor.getController(condition.id),
1749
1787
  issues: displayResult.issues.filter((issue) => issue.nodeId === condition.id),
1750
1788
  onRemove: () => handleRemove(condition.id),
1751
- onRestrictedOptionSelect
1789
+ onRestrictedOptionSelect,
1790
+ container: containerRef
1752
1791
  },
1753
1792
  condition.id
1754
1793
  );
@@ -1759,7 +1798,8 @@ function CelFilterBar({
1759
1798
  function CelAddFilterButton({
1760
1799
  schema,
1761
1800
  conditions,
1762
- onSelect
1801
+ onSelect,
1802
+ container
1763
1803
  }) {
1764
1804
  var _a, _b;
1765
1805
  const usedSingleInstanceColumnIds = new Set(
@@ -1775,7 +1815,10 @@ function CelAddFilterButton({
1775
1815
  list.push(column);
1776
1816
  groupMap.set(key, list);
1777
1817
  }
1778
- const groups = Array.from(groupMap.entries()).map(([value, items]) => ({ value, items }));
1818
+ const groups = sortBy(
1819
+ Array.from(groupMap.entries()).map(([value, items]) => ({ value, items: sortBy(items, (item) => item.title) })),
1820
+ (group) => group.value
1821
+ );
1779
1822
  return /* @__PURE__ */ jsxs4(
1780
1823
  Combobox,
1781
1824
  {
@@ -1790,7 +1833,7 @@ function CelAddFilterButton({
1790
1833
  /* @__PURE__ */ jsx5(Icon3, { name: "plus", "data-icon": "inline-start" }),
1791
1834
  "Add filter"
1792
1835
  ] }),
1793
- /* @__PURE__ */ jsxs4(ComboboxContent, { align: "start", className: "w-64", children: [
1836
+ /* @__PURE__ */ jsxs4(ComboboxContent, { container, align: "start", className: "w-64", children: [
1794
1837
  /* @__PURE__ */ jsx5(ComboboxInput, { showTrigger: false, placeholder: "Search filters\u2026" }),
1795
1838
  /* @__PURE__ */ jsx5(ComboboxEmpty, { children: "No filters found." }),
1796
1839
  /* @__PURE__ */ jsx5(ComboboxList, { children: (group) => /* @__PURE__ */ jsxs4(ComboboxGroup, { items: group.items, children: [
@@ -1854,7 +1897,8 @@ function CelFilterPill({
1854
1897
  controller,
1855
1898
  issues,
1856
1899
  onRemove,
1857
- onRestrictedOptionSelect
1900
+ onRestrictedOptionSelect,
1901
+ container
1858
1902
  }) {
1859
1903
  var _a;
1860
1904
  const shape = (_a = resolveFilterShape(condition, schema)) != null ? _a : columnDef.filterType;
@@ -1871,7 +1915,8 @@ function CelFilterPill({
1871
1915
  controller,
1872
1916
  issues,
1873
1917
  onRemove,
1874
- onRestrictedOptionSelect
1918
+ onRestrictedOptionSelect,
1919
+ container
1875
1920
  }
1876
1921
  );
1877
1922
  }
@@ -1886,7 +1931,8 @@ function CelFilterPill({
1886
1931
  controller,
1887
1932
  issues,
1888
1933
  onRemove,
1889
- onRestrictedOptionSelect
1934
+ onRestrictedOptionSelect,
1935
+ container
1890
1936
  }
1891
1937
  );
1892
1938
  }
@@ -1996,10 +2042,11 @@ function CelCheckboxComboboxPill({
1996
2042
  controller,
1997
2043
  issues,
1998
2044
  onRemove,
1999
- onRestrictedOptionSelect
2045
+ onRestrictedOptionSelect,
2046
+ container
2000
2047
  }) {
2001
2048
  var _a;
2002
- const options = (_a = columnDef.options) != null ? _a : [];
2049
+ const options = sortBy((_a = columnDef.options) != null ? _a : [], (o) => o.label);
2003
2050
  const value = isCheckboxCelValue(condition.value) ? condition.value : [];
2004
2051
  const selected = options.filter((option) => value.includes(option.value));
2005
2052
  const allowedOperators = getAllowedOperators(columnDef);
@@ -2055,7 +2102,7 @@ function CelCheckboxComboboxPill({
2055
2102
  ),
2056
2103
  /* @__PURE__ */ jsx5(Button3, { variant: "outline", size: "icon", "aria-label": `Remove ${columnDef.title} filter`, onClick: onRemove, children: /* @__PURE__ */ jsx5(Icon3, { name: "xmark" }) })
2057
2104
  ] }),
2058
- /* @__PURE__ */ jsxs4(ComboboxContent, { className: "min-w-64", collisionAvoidance: { side: "none", align: "shift" }, children: [
2105
+ /* @__PURE__ */ jsxs4(ComboboxContent, { container, className: "min-w-64", collisionAvoidance: { side: "none", align: "shift" }, children: [
2059
2106
  /* @__PURE__ */ jsx5(ComboboxInput, { showTrigger: false, placeholder: `Search ${columnDef.title.toLowerCase()}\u2026` }),
2060
2107
  selected.length > 0 && /* @__PURE__ */ jsxs4(Fragment3, { children: [
2061
2108
  /* @__PURE__ */ jsxs4(ComboboxSelectedChips, { children: [
@@ -2084,10 +2131,11 @@ function CelRadioComboboxPill({
2084
2131
  controller,
2085
2132
  issues,
2086
2133
  onRemove,
2087
- onRestrictedOptionSelect
2134
+ onRestrictedOptionSelect,
2135
+ container
2088
2136
  }) {
2089
2137
  var _a, _b;
2090
- const options = (_a = columnDef.options) != null ? _a : [];
2138
+ const options = sortBy((_a = columnDef.options) != null ? _a : [], (o) => o.label);
2091
2139
  const value = typeof condition.value === "string" ? condition.value : "";
2092
2140
  const selected = (_b = options.find((option) => option.value === value)) != null ? _b : null;
2093
2141
  const allowedOperators = getAllowedOperators(columnDef);
@@ -2139,7 +2187,7 @@ function CelRadioComboboxPill({
2139
2187
  ),
2140
2188
  /* @__PURE__ */ jsx5(Button3, { variant: "outline", size: "icon", "aria-label": `Remove ${columnDef.title} filter`, onClick: onRemove, children: /* @__PURE__ */ jsx5(Icon3, { name: "xmark" }) })
2141
2189
  ] }),
2142
- /* @__PURE__ */ jsxs4(ComboboxContent, { className: "min-w-64", collisionAvoidance: { side: "none", align: "shift" }, children: [
2190
+ /* @__PURE__ */ jsxs4(ComboboxContent, { container, className: "min-w-64", collisionAvoidance: { side: "none", align: "shift" }, children: [
2143
2191
  /* @__PURE__ */ jsx5(ComboboxInput, { showTrigger: false, placeholder: `Search ${columnDef.title.toLowerCase()}\u2026` }),
2144
2192
  /* @__PURE__ */ jsxs4(ComboboxEmpty, { children: [
2145
2193
  "No ",
@@ -2341,7 +2389,7 @@ function CelDateValueEditor({
2341
2389
  }
2342
2390
 
2343
2391
  // src/data-table/data-table.tsx
2344
- import { Icon as Icon8 } from "@upbound/monarch-core";
2392
+ import { Icon as Icon9 } from "@upbound/monarch-core";
2345
2393
  import { InputGroup as InputGroup2, InputGroupAddon as InputGroupAddon2, InputGroupInput as InputGroupInput2 } from "@upbound/monarch-core";
2346
2394
 
2347
2395
  // src/lib/data-table/contextual-filters.ts
@@ -2939,6 +2987,18 @@ function useGridLayout({
2939
2987
  };
2940
2988
  }
2941
2989
 
2990
+ // src/hooks/use-filter-visibility.ts
2991
+ import * as React5 from "react";
2992
+ function useFilterVisibility(filterVisibility) {
2993
+ var _a, _b, _c;
2994
+ const config = typeof filterVisibility === "object" ? filterVisibility : void 0;
2995
+ const [innerVisible, setInnerVisible] = React5.useState((_a = config == null ? void 0 : config.defaultVisible) != null ? _a : false);
2996
+ const showFilterToggle = filterVisibility !== false;
2997
+ const filterRowVisible = (_b = config == null ? void 0 : config.visible) != null ? _b : innerVisible;
2998
+ const setFilterRowVisible = (_c = config == null ? void 0 : config.onVisibleChange) != null ? _c : setInnerVisible;
2999
+ return { showFilterToggle, filterRowVisible, setFilterRowVisible };
3000
+ }
3001
+
2942
3002
  // src/data-table/empty-view.tsx
2943
3003
  import { Alert, AlertDescription } from "@upbound/monarch-core";
2944
3004
  import { Button as Button4 } from "@upbound/monarch-core";
@@ -2991,9 +3051,34 @@ function DataTableEmptyView({
2991
3051
  ] }) });
2992
3052
  }
2993
3053
 
3054
+ // src/data-table/filter-toggle.tsx
3055
+ import { Icon as Icon5, Toggle } from "@upbound/monarch-core";
3056
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
3057
+ function FilterToggle({ pressed, onPressedChange, count }) {
3058
+ return /* @__PURE__ */ jsxs6(
3059
+ Toggle,
3060
+ {
3061
+ variant: "outline",
3062
+ pressed,
3063
+ onPressedChange,
3064
+ "aria-label": "Toggle filters",
3065
+ className: "shrink-0 gap-1.5",
3066
+ children: [
3067
+ /* @__PURE__ */ jsx7(Icon5, { name: "filter", "data-icon": "inline-start" }),
3068
+ "Filter",
3069
+ !!count && /* @__PURE__ */ jsxs6("span", { className: "tabular-nums", children: [
3070
+ "(",
3071
+ count,
3072
+ ")"
3073
+ ] })
3074
+ ]
3075
+ }
3076
+ );
3077
+ }
3078
+
2994
3079
  // src/data-table/pagination.tsx
2995
3080
  import { Button as Button5 } from "@upbound/monarch-core";
2996
- import { Icon as Icon5 } from "@upbound/monarch-core";
3081
+ import { Icon as Icon6 } from "@upbound/monarch-core";
2997
3082
  import { Label as Label2 } from "@upbound/monarch-core";
2998
3083
  import {
2999
3084
  Pagination,
@@ -3004,7 +3089,7 @@ import {
3004
3089
  } from "@upbound/monarch-core";
3005
3090
  import { Select as Select2, SelectContent as SelectContent2, SelectGroup as SelectGroup2, SelectItem as SelectItem2, SelectTrigger as SelectTrigger2, SelectValue as SelectValue2 } from "@upbound/monarch-core";
3006
3091
  import { Tooltip as Tooltip2, TooltipContent as TooltipContent2, TooltipTrigger as TooltipTrigger2 } from "@upbound/monarch-core";
3007
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
3092
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3008
3093
  var DEFAULT_PAGINATION_CONFIG = {
3009
3094
  summary: true,
3010
3095
  arrows: true,
@@ -3043,36 +3128,36 @@ function DataTablePagination({
3043
3128
  const currentPage = pageIndex + 1;
3044
3129
  const mounted = useMounted();
3045
3130
  const locale = mounted ? void 0 : "en-US";
3046
- return /* @__PURE__ */ jsxs6("div", { "data-testid": "table-footer", className: "flex items-center justify-between px-2 pt-4", children: [
3047
- resolved.summary ? /* @__PURE__ */ jsxs6("div", { className: "text-body text-muted-foreground", "data-testid": "table-pagination-summary", children: [
3131
+ return /* @__PURE__ */ jsxs7("div", { "data-testid": "table-footer", className: "flex items-center justify-between px-2 pt-4", children: [
3132
+ resolved.summary ? /* @__PURE__ */ jsxs7("div", { className: "text-body text-muted-foreground", "data-testid": "table-pagination-summary", children: [
3048
3133
  "Showing ",
3049
- /* @__PURE__ */ jsx7("span", { className: "text-foreground font-medium", children: itemStart.toLocaleString(locale) }),
3134
+ /* @__PURE__ */ jsx8("span", { className: "text-foreground font-medium", children: itemStart.toLocaleString(locale) }),
3050
3135
  " to",
3051
3136
  " ",
3052
- /* @__PURE__ */ jsx7("span", { className: "text-foreground font-medium", children: itemEnd.toLocaleString(locale) }),
3137
+ /* @__PURE__ */ jsx8("span", { className: "text-foreground font-medium", children: itemEnd.toLocaleString(locale) }),
3053
3138
  " of",
3054
3139
  " ",
3055
- /* @__PURE__ */ jsxs6("span", { className: "text-foreground font-medium", children: [
3140
+ /* @__PURE__ */ jsxs7("span", { className: "text-foreground font-medium", children: [
3056
3141
  rowCount.toLocaleString(locale),
3057
3142
  !isRowCountExact && "+"
3058
3143
  ] }),
3059
3144
  " ",
3060
3145
  "results",
3061
- !isRowCountExact && /* @__PURE__ */ jsxs6(Tooltip2, { children: [
3062
- /* @__PURE__ */ jsx7(TooltipTrigger2, { className: "ml-1 align-middle", children: /* @__PURE__ */ jsx7(Icon5, { name: "circle-info", size: "sm" }) }),
3063
- /* @__PURE__ */ jsx7(TooltipContent2, { children: "Add filters or refine your search to reduce the result set." })
3146
+ !isRowCountExact && /* @__PURE__ */ jsxs7(Tooltip2, { children: [
3147
+ /* @__PURE__ */ jsx8(TooltipTrigger2, { className: "ml-1 align-middle", children: /* @__PURE__ */ jsx8(Icon6, { name: "circle-info", size: "sm" }) }),
3148
+ /* @__PURE__ */ jsx8(TooltipContent2, { children: "Add filters or refine your search to reduce the result set." })
3064
3149
  ] })
3065
- ] }) : /* @__PURE__ */ jsx7("div", {}),
3066
- /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-4", children: [
3067
- resolved.pageSizeSelector && /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
3068
- /* @__PURE__ */ jsx7(Label2, { htmlFor: PAGE_SIZE_SELECT_ID, className: "font-semibold", children: "Rows per page" }),
3069
- /* @__PURE__ */ jsxs6(Select2, { value: String(effectivePageSize), onValueChange: (value) => onPageSizeChange(Number(value)), children: [
3070
- /* @__PURE__ */ jsx7(SelectTrigger2, { id: PAGE_SIZE_SELECT_ID, size: "sm", className: "w-18", "data-testid": "table-page-size-select", children: /* @__PURE__ */ jsx7(SelectValue2, {}) }),
3071
- /* @__PURE__ */ jsx7(SelectContent2, { align: "end", children: /* @__PURE__ */ jsx7(SelectGroup2, { children: normalizedPageSizeOptions.map((option) => /* @__PURE__ */ jsx7(SelectItem2, { value: String(option), children: option }, option)) }) })
3150
+ ] }) : /* @__PURE__ */ jsx8("div", {}),
3151
+ /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-4", children: [
3152
+ resolved.pageSizeSelector && /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
3153
+ /* @__PURE__ */ jsx8(Label2, { htmlFor: PAGE_SIZE_SELECT_ID, className: "font-semibold", children: "Rows per page" }),
3154
+ /* @__PURE__ */ jsxs7(Select2, { value: String(effectivePageSize), onValueChange: (value) => onPageSizeChange(Number(value)), children: [
3155
+ /* @__PURE__ */ jsx8(SelectTrigger2, { id: PAGE_SIZE_SELECT_ID, size: "sm", className: "w-18", "data-testid": "table-page-size-select", children: /* @__PURE__ */ jsx8(SelectValue2, {}) }),
3156
+ /* @__PURE__ */ jsx8(SelectContent2, { align: "end", children: /* @__PURE__ */ jsx8(SelectGroup2, { children: normalizedPageSizeOptions.map((option) => /* @__PURE__ */ jsx8(SelectItem2, { value: String(option), children: option }, option)) }) })
3072
3157
  ] })
3073
3158
  ] }),
3074
- pageCount > 1 && (resolved.arrows || resolved.numbers) && /* @__PURE__ */ jsx7(Pagination, { className: "mx-0 w-auto justify-end", children: /* @__PURE__ */ jsxs6(PaginationContent, { children: [
3075
- resolved.arrows && /* @__PURE__ */ jsx7(PaginationItem, { children: /* @__PURE__ */ jsx7(
3159
+ pageCount > 1 && (resolved.arrows || resolved.numbers) && /* @__PURE__ */ jsx8(Pagination, { className: "mx-0 w-auto justify-end", children: /* @__PURE__ */ jsxs7(PaginationContent, { children: [
3160
+ resolved.arrows && /* @__PURE__ */ jsx8(PaginationItem, { children: /* @__PURE__ */ jsx8(
3076
3161
  Button5,
3077
3162
  {
3078
3163
  variant: "outline",
@@ -3080,10 +3165,10 @@ function DataTablePagination({
3080
3165
  "aria-label": "Go to first page",
3081
3166
  disabled: currentPage <= 1,
3082
3167
  onClick: () => onPageChange(1),
3083
- children: /* @__PURE__ */ jsx7(Icon5, { name: "chevrons-left", className: "cn-rtl-flip" })
3168
+ children: /* @__PURE__ */ jsx8(Icon6, { name: "chevrons-left", className: "cn-rtl-flip" })
3084
3169
  }
3085
3170
  ) }),
3086
- resolved.arrows && /* @__PURE__ */ jsx7(PaginationItem, { children: /* @__PURE__ */ jsx7(
3171
+ resolved.arrows && /* @__PURE__ */ jsx8(PaginationItem, { children: /* @__PURE__ */ jsx8(
3087
3172
  Button5,
3088
3173
  {
3089
3174
  variant: "outline",
@@ -3091,14 +3176,15 @@ function DataTablePagination({
3091
3176
  "aria-label": "Go to previous page",
3092
3177
  disabled: currentPage <= 1,
3093
3178
  onClick: () => onPageChange(currentPage - 1),
3094
- children: /* @__PURE__ */ jsx7(Icon5, { name: "chevron-left", className: "cn-rtl-flip" })
3179
+ children: /* @__PURE__ */ jsx8(Icon6, { name: "chevron-left", className: "cn-rtl-flip" })
3095
3180
  }
3096
3181
  ) }),
3097
3182
  resolved.numbers && visiblePages.map(
3098
- (page, index) => page === void 0 ? /* @__PURE__ */ jsx7(PaginationItem, { children: /* @__PURE__ */ jsx7(PaginationEllipsis, {}) }, `ellipsis-${index}`) : /* @__PURE__ */ jsx7(PaginationItem, { children: /* @__PURE__ */ jsx7(
3183
+ (page, index) => page === void 0 ? /* @__PURE__ */ jsx8(PaginationItem, { children: /* @__PURE__ */ jsx8(PaginationEllipsis, {}) }, `ellipsis-${index}`) : /* @__PURE__ */ jsx8(PaginationItem, { children: /* @__PURE__ */ jsx8(
3099
3184
  PaginationLink,
3100
3185
  {
3101
3186
  href: "#",
3187
+ size: "icon",
3102
3188
  isActive: page === currentPage,
3103
3189
  onClick: (e) => {
3104
3190
  e.preventDefault();
@@ -3108,7 +3194,7 @@ function DataTablePagination({
3108
3194
  }
3109
3195
  ) }, page)
3110
3196
  ),
3111
- resolved.arrows && /* @__PURE__ */ jsx7(PaginationItem, { children: /* @__PURE__ */ jsx7(
3197
+ resolved.arrows && /* @__PURE__ */ jsx8(PaginationItem, { children: /* @__PURE__ */ jsx8(
3112
3198
  Button5,
3113
3199
  {
3114
3200
  variant: "outline",
@@ -3116,10 +3202,10 @@ function DataTablePagination({
3116
3202
  "aria-label": "Go to next page",
3117
3203
  disabled: currentPage >= pageCount,
3118
3204
  onClick: () => onPageChange(currentPage + 1),
3119
- children: /* @__PURE__ */ jsx7(Icon5, { name: "chevron-right", className: "cn-rtl-flip" })
3205
+ children: /* @__PURE__ */ jsx8(Icon6, { name: "chevron-right", className: "cn-rtl-flip" })
3120
3206
  }
3121
3207
  ) }),
3122
- resolved.arrows && /* @__PURE__ */ jsx7(PaginationItem, { children: /* @__PURE__ */ jsx7(
3208
+ resolved.arrows && /* @__PURE__ */ jsx8(PaginationItem, { children: /* @__PURE__ */ jsx8(
3123
3209
  Button5,
3124
3210
  {
3125
3211
  variant: "outline",
@@ -3127,7 +3213,7 @@ function DataTablePagination({
3127
3213
  "aria-label": "Go to last page",
3128
3214
  disabled: currentPage >= pageCount,
3129
3215
  onClick: () => onPageChange(pageCount),
3130
- children: /* @__PURE__ */ jsx7(Icon5, { name: "chevrons-right", className: "cn-rtl-flip" })
3216
+ children: /* @__PURE__ */ jsx8(Icon6, { name: "chevrons-right", className: "cn-rtl-flip" })
3131
3217
  }
3132
3218
  ) })
3133
3219
  ] }) })
@@ -3136,7 +3222,7 @@ function DataTablePagination({
3136
3222
  }
3137
3223
 
3138
3224
  // src/data-table/table-primitives.tsx
3139
- import * as React5 from "react";
3225
+ import * as React6 from "react";
3140
3226
  import {
3141
3227
  flexRender as flexRender2
3142
3228
  } from "@tanstack/react-table";
@@ -3148,7 +3234,7 @@ import {
3148
3234
  DropdownMenuSeparator,
3149
3235
  DropdownMenuTrigger as DropdownMenuTrigger3
3150
3236
  } from "@upbound/monarch-core";
3151
- import { Icon as Icon6 } from "@upbound/monarch-core";
3237
+ import { Icon as Icon7 } from "@upbound/monarch-core";
3152
3238
  import { Skeleton } from "@upbound/monarch-core";
3153
3239
  import {
3154
3240
  Table as BaseTable,
@@ -3159,7 +3245,7 @@ import {
3159
3245
  TableRow as BaseTableRow
3160
3246
  } from "@upbound/monarch-core";
3161
3247
  import { Tooltip as Tooltip3, TooltipContent as TooltipContent3, TooltipTrigger as TooltipTrigger3 } from "@upbound/monarch-core";
3162
- import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3248
+ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
3163
3249
  var HEADER_SURFACE_BG = "bg-[color-mix(in_oklch,var(--muted)_50%,var(--card))]";
3164
3250
  var TABLE_HEAD_CLASSES = "text-body-sm text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap has-[[role=checkbox]]:pr-0";
3165
3251
  var TABLE_CELL_CLASSES = "px-4 py-2 align-middle whitespace-nowrap has-[[role=checkbox]]:pr-0";
@@ -3173,7 +3259,7 @@ function DataTableRoot({
3173
3259
  children
3174
3260
  }) {
3175
3261
  if (layout === "grid") {
3176
- return /* @__PURE__ */ jsx8(
3262
+ return /* @__PURE__ */ jsx9(
3177
3263
  "div",
3178
3264
  {
3179
3265
  ref: gridRootRef,
@@ -3184,7 +3270,7 @@ function DataTableRoot({
3184
3270
  }
3185
3271
  );
3186
3272
  }
3187
- return /* @__PURE__ */ jsx8(BaseTable, { className, style, children });
3273
+ return /* @__PURE__ */ jsx9(BaseTable, { className, style, children });
3188
3274
  }
3189
3275
  function getColumnPinningProps(column, surface = "body") {
3190
3276
  const isPinned = column.getIsPinned();
@@ -3207,8 +3293,8 @@ function getColumnPinningProps(column, surface = "body") {
3207
3293
  }
3208
3294
  function DataTableSortIcon({ sortOrder }) {
3209
3295
  if (!sortOrder) return null;
3210
- return /* @__PURE__ */ jsx8(
3211
- Icon6,
3296
+ return /* @__PURE__ */ jsx9(
3297
+ Icon7,
3212
3298
  {
3213
3299
  name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
3214
3300
  size: "xs",
@@ -3227,57 +3313,57 @@ function ColumnActionsMenuItems({
3227
3313
  const canResize = header.column.getCanResize();
3228
3314
  const canHide = header.column.getCanHide();
3229
3315
  const canPin = !isGrid && header.column.getCanPin();
3230
- return /* @__PURE__ */ jsxs7(DropdownMenuContent3, { align: "start", className: "w-45", children: [
3231
- canSort && /* @__PURE__ */ jsxs7(Fragment5, { children: [
3232
- /* @__PURE__ */ jsxs7(
3316
+ return /* @__PURE__ */ jsxs8(DropdownMenuContent3, { align: "start", className: "w-45", children: [
3317
+ canSort && /* @__PURE__ */ jsxs8(Fragment5, { children: [
3318
+ /* @__PURE__ */ jsxs8(
3233
3319
  DropdownMenuItem3,
3234
3320
  {
3235
3321
  disabled: header.column.getIsSorted() === "asc",
3236
3322
  onClick: () => header.column.toggleSorting(false),
3237
3323
  children: [
3238
- /* @__PURE__ */ jsx8(Icon6, { name: "arrow-up" }),
3324
+ /* @__PURE__ */ jsx9(Icon7, { name: "arrow-up" }),
3239
3325
  "Sort ascending"
3240
3326
  ]
3241
3327
  }
3242
3328
  ),
3243
- /* @__PURE__ */ jsxs7(
3329
+ /* @__PURE__ */ jsxs8(
3244
3330
  DropdownMenuItem3,
3245
3331
  {
3246
3332
  disabled: header.column.getIsSorted() === "desc",
3247
3333
  onClick: () => header.column.toggleSorting(true),
3248
3334
  children: [
3249
- /* @__PURE__ */ jsx8(Icon6, { name: "arrow-down" }),
3335
+ /* @__PURE__ */ jsx9(Icon7, { name: "arrow-down" }),
3250
3336
  "Sort descending"
3251
3337
  ]
3252
3338
  }
3253
3339
  ),
3254
- !!header.column.getIsSorted() && /* @__PURE__ */ jsxs7(DropdownMenuItem3, { onClick: () => header.column.clearSorting(), children: [
3255
- /* @__PURE__ */ jsx8(Icon6, { name: "xmark" }),
3340
+ !!header.column.getIsSorted() && /* @__PURE__ */ jsxs8(DropdownMenuItem3, { onClick: () => header.column.clearSorting(), children: [
3341
+ /* @__PURE__ */ jsx9(Icon7, { name: "xmark" }),
3256
3342
  "Remove sorting"
3257
3343
  ] })
3258
3344
  ] }),
3259
- canResize && /* @__PURE__ */ jsxs7(Fragment5, { children: [
3260
- canSort && /* @__PURE__ */ jsx8(DropdownMenuSeparator, {}),
3261
- !isGrid && /* @__PURE__ */ jsxs7(DropdownMenuItem3, { onClick: () => onAutosizeColumn(header.column.id), children: [
3262
- /* @__PURE__ */ jsx8(Icon6, { name: "arrows-left-right" }),
3345
+ canResize && /* @__PURE__ */ jsxs8(Fragment5, { children: [
3346
+ canSort && /* @__PURE__ */ jsx9(DropdownMenuSeparator, {}),
3347
+ !isGrid && /* @__PURE__ */ jsxs8(DropdownMenuItem3, { onClick: () => onAutosizeColumn(header.column.id), children: [
3348
+ /* @__PURE__ */ jsx9(Icon7, { name: "arrows-left-right" }),
3263
3349
  "Autosize column"
3264
3350
  ] }),
3265
- /* @__PURE__ */ jsxs7(DropdownMenuItem3, { onClick: () => onAutosizeAll(), children: [
3266
- /* @__PURE__ */ jsx8(Icon6, { name: "table-columns" }),
3351
+ /* @__PURE__ */ jsxs8(DropdownMenuItem3, { onClick: () => onAutosizeAll(), children: [
3352
+ /* @__PURE__ */ jsx9(Icon7, { name: "table-columns" }),
3267
3353
  isGrid ? "Reset all columns" : "Autosize all columns"
3268
3354
  ] })
3269
3355
  ] }),
3270
- (canHide || canPin) && /* @__PURE__ */ jsxs7(Fragment5, { children: [
3271
- (canSort || canResize) && /* @__PURE__ */ jsx8(DropdownMenuSeparator, {}),
3272
- canHide && /* @__PURE__ */ jsxs7(DropdownMenuItem3, { onClick: () => header.column.toggleVisibility(), children: [
3273
- /* @__PURE__ */ jsx8(Icon6, { name: "eye-slash" }),
3356
+ (canHide || canPin) && /* @__PURE__ */ jsxs8(Fragment5, { children: [
3357
+ (canSort || canResize) && /* @__PURE__ */ jsx9(DropdownMenuSeparator, {}),
3358
+ canHide && /* @__PURE__ */ jsxs8(DropdownMenuItem3, { onClick: () => header.column.toggleVisibility(), children: [
3359
+ /* @__PURE__ */ jsx9(Icon7, { name: "eye-slash" }),
3274
3360
  "Hide column"
3275
3361
  ] }),
3276
- canPin && (header.column.getIsPinned() ? /* @__PURE__ */ jsxs7(DropdownMenuItem3, { onClick: () => header.column.pin(false), children: [
3277
- /* @__PURE__ */ jsx8(Icon6, { name: "thumbtack" }),
3362
+ canPin && (header.column.getIsPinned() ? /* @__PURE__ */ jsxs8(DropdownMenuItem3, { onClick: () => header.column.pin(false), children: [
3363
+ /* @__PURE__ */ jsx9(Icon7, { name: "thumbtack" }),
3278
3364
  "Unpin column"
3279
- ] }) : /* @__PURE__ */ jsxs7(DropdownMenuItem3, { onClick: () => header.column.pin("left"), children: [
3280
- /* @__PURE__ */ jsx8(Icon6, { name: "thumbtack" }),
3365
+ ] }) : /* @__PURE__ */ jsxs8(DropdownMenuItem3, { onClick: () => header.column.pin("left"), children: [
3366
+ /* @__PURE__ */ jsx9(Icon7, { name: "thumbtack" }),
3281
3367
  "Pin column"
3282
3368
  ] }))
3283
3369
  ] })
@@ -3297,7 +3383,7 @@ function HeaderCellContent({
3297
3383
  const resizeHandler = header.getResizeHandler();
3298
3384
  const headerTitle = typeof header.column.columnDef.header === "string" ? header.column.columnDef.header : "";
3299
3385
  const sorted = header.column.getIsSorted();
3300
- const labelButton = /* @__PURE__ */ jsxs7(
3386
+ const labelButton = /* @__PURE__ */ jsxs8(
3301
3387
  "button",
3302
3388
  {
3303
3389
  type: "button",
@@ -3308,10 +3394,10 @@ function HeaderCellContent({
3308
3394
  shouldShowActionsMenu ? "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50 cursor-pointer" : "cursor-default"
3309
3395
  ),
3310
3396
  children: [
3311
- /* @__PURE__ */ jsx8(DataTableSortIcon, { sortOrder: sorted }),
3312
- /* @__PURE__ */ jsx8("span", { className: "min-w-0 truncate", children: flexRender2(header.column.columnDef.header, header.getContext()) }),
3313
- shouldShowActionsMenu && /* @__PURE__ */ jsx8(
3314
- Icon6,
3397
+ /* @__PURE__ */ jsx9(DataTableSortIcon, { sortOrder: sorted }),
3398
+ /* @__PURE__ */ jsx9("span", { className: "min-w-0 truncate", children: flexRender2(header.column.columnDef.header, header.getContext()) }),
3399
+ shouldShowActionsMenu && /* @__PURE__ */ jsx9(
3400
+ Icon7,
3315
3401
  {
3316
3402
  size: "sm",
3317
3403
  name: "ellipsis",
@@ -3321,9 +3407,9 @@ function HeaderCellContent({
3321
3407
  ]
3322
3408
  }
3323
3409
  );
3324
- const label = shouldShowActionsMenu ? /* @__PURE__ */ jsxs7(DropdownMenu3, { children: [
3325
- /* @__PURE__ */ jsx8(DropdownMenuTrigger3, { asChild: true, children: labelButton }),
3326
- /* @__PURE__ */ jsx8(
3410
+ const label = shouldShowActionsMenu ? /* @__PURE__ */ jsxs8(DropdownMenu3, { children: [
3411
+ /* @__PURE__ */ jsx9(DropdownMenuTrigger3, { asChild: true, children: labelButton }),
3412
+ /* @__PURE__ */ jsx9(
3327
3413
  ColumnActionsMenuItems,
3328
3414
  {
3329
3415
  header,
@@ -3333,12 +3419,12 @@ function HeaderCellContent({
3333
3419
  }
3334
3420
  )
3335
3421
  ] }) : labelButton;
3336
- return /* @__PURE__ */ jsxs7(Fragment5, { children: [
3337
- /* @__PURE__ */ jsx8("div", { className: "flex min-w-0 items-center gap-1", children: /* @__PURE__ */ jsx8("div", { className: "min-w-0 flex-1", children: !isActionColumn && !isGroupedColumn && (headerTitle ? /* @__PURE__ */ jsxs7(Tooltip3, { children: [
3338
- /* @__PURE__ */ jsx8(TooltipTrigger3, { asChild: true, children: label }),
3339
- /* @__PURE__ */ jsx8(TooltipContent3, { children: headerTitle })
3422
+ return /* @__PURE__ */ jsxs8(Fragment5, { children: [
3423
+ /* @__PURE__ */ jsx9("div", { className: "flex min-w-0 flex-1 items-center gap-1", children: /* @__PURE__ */ jsx9("div", { className: "min-w-0 flex-1", children: !isActionColumn && !isGroupedColumn && (headerTitle ? /* @__PURE__ */ jsxs8(Tooltip3, { children: [
3424
+ /* @__PURE__ */ jsx9(TooltipTrigger3, { asChild: true, children: label }),
3425
+ /* @__PURE__ */ jsx9(TooltipContent3, { children: headerTitle })
3340
3426
  ] }) : label) }) }),
3341
- canResize && /* @__PURE__ */ jsx8(
3427
+ canResize && /* @__PURE__ */ jsx9(
3342
3428
  "button",
3343
3429
  {
3344
3430
  type: "button",
@@ -3354,7 +3440,7 @@ function HeaderCellContent({
3354
3440
  ] });
3355
3441
  }
3356
3442
  var DEFAULT_STICKY_HEADER_OFFSET_PX = 0;
3357
- var DEFAULT_STICKY_HEADER_ROW_HEIGHT_PX = 48;
3443
+ var DEFAULT_STICKY_HEADER_ROW_HEIGHT_PX = 40;
3358
3444
  function DataTableHeader({
3359
3445
  headerGroups,
3360
3446
  onAutosizeAll,
@@ -3382,7 +3468,7 @@ function DataTableHeader({
3382
3468
  const stickyTopPx = stickyHeader ? stickyHeaderOffset + headerGroupIndex * stickyHeaderRowHeight : void 0;
3383
3469
  const isPinned = !isGrid && header.column.getIsPinned();
3384
3470
  const pinning = isGrid ? { className: "", style: {} } : getColumnPinningProps(header.column, "header");
3385
- const content = /* @__PURE__ */ jsx8(
3471
+ const content = /* @__PURE__ */ jsx9(
3386
3472
  HeaderCellContent,
3387
3473
  {
3388
3474
  header,
@@ -3403,11 +3489,11 @@ function DataTableHeader({
3403
3489
  isPinned && "z-30"
3404
3490
  );
3405
3491
  if (isGrid) {
3406
- return /* @__PURE__ */ jsx8(
3492
+ return /* @__PURE__ */ jsx9(
3407
3493
  "div",
3408
3494
  {
3409
3495
  role: "columnheader",
3410
- className: cn(TABLE_HEAD_CLASSES, cellClassName, "h-auto py-1.5 whitespace-normal"),
3496
+ className: cn(TABLE_HEAD_CLASSES, cellClassName, "flex items-center whitespace-normal"),
3411
3497
  style: __spreadValues({
3412
3498
  minWidth: header.column.columnDef.minSize
3413
3499
  }, stickyTopPx !== void 0 ? { top: stickyTopPx } : {}),
@@ -3416,10 +3502,10 @@ function DataTableHeader({
3416
3502
  header.id
3417
3503
  );
3418
3504
  }
3419
- return /* @__PURE__ */ jsx8(
3505
+ return /* @__PURE__ */ jsx9(
3420
3506
  BaseTableHead,
3421
3507
  {
3422
- className: cn(cellClassName, "h-auto py-1.5 whitespace-normal"),
3508
+ className: cn(cellClassName, "whitespace-normal"),
3423
3509
  style: __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, pinning.style), {
3424
3510
  minWidth: header.column.columnDef.minSize,
3425
3511
  maxWidth: header.column.columnDef.maxSize
@@ -3431,19 +3517,19 @@ function DataTableHeader({
3431
3517
  });
3432
3518
  };
3433
3519
  if (isGrid) {
3434
- return /* @__PURE__ */ jsx8(
3520
+ return /* @__PURE__ */ jsx9(
3435
3521
  "div",
3436
3522
  {
3437
3523
  role: "rowgroup",
3438
3524
  className: cn("col-span-full grid grid-cols-subgrid", HEADER_SURFACE_BG, !!stickyHeader && "sticky z-20"),
3439
3525
  style: stickyHeader ? { top: stickyHeaderOffset } : void 0,
3440
- children: headerGroups.map((headerGroup, headerGroupIndex) => /* @__PURE__ */ jsx8("div", { role: "row", className: "col-span-full grid grid-cols-subgrid border-b", children: renderHeaders(headerGroup, headerGroupIndex) }, headerGroup.id))
3526
+ children: headerGroups.map((headerGroup, headerGroupIndex) => /* @__PURE__ */ jsx9("div", { role: "row", className: "col-span-full grid grid-cols-subgrid border-b", children: renderHeaders(headerGroup, headerGroupIndex) }, headerGroup.id))
3441
3527
  }
3442
3528
  );
3443
3529
  }
3444
- return /* @__PURE__ */ jsx8(BaseTableHeader, { children: headerGroups.map((headerGroup, headerGroupIndex) => /* @__PURE__ */ jsx8(BaseTableRow, { children: renderHeaders(headerGroup, headerGroupIndex) }, headerGroup.id)) });
3530
+ return /* @__PURE__ */ jsx9(BaseTableHeader, { children: headerGroups.map((headerGroup, headerGroupIndex) => /* @__PURE__ */ jsx9(BaseTableRow, { children: renderHeaders(headerGroup, headerGroupIndex) }, headerGroup.id)) });
3445
3531
  }
3446
- var DataTableRow = React5.forwardRef(
3532
+ var DataTableRow = React6.forwardRef(
3447
3533
  (_a, ref) => {
3448
3534
  var _b = _a, { hoverable, disabled, className, layout = "auto" } = _b, props = __objRest(_b, ["hoverable", "disabled", "className", "layout"]);
3449
3535
  const classes = cn(
@@ -3453,7 +3539,7 @@ var DataTableRow = React5.forwardRef(
3453
3539
  className
3454
3540
  );
3455
3541
  if (layout === "grid") {
3456
- return /* @__PURE__ */ jsx8(
3542
+ return /* @__PURE__ */ jsx9(
3457
3543
  "div",
3458
3544
  __spreadValues({
3459
3545
  ref,
@@ -3462,7 +3548,7 @@ var DataTableRow = React5.forwardRef(
3462
3548
  }, props)
3463
3549
  );
3464
3550
  }
3465
- return /* @__PURE__ */ jsx8(BaseTableRow, __spreadValues({ ref, className: classes }, props));
3551
+ return /* @__PURE__ */ jsx9(BaseTableRow, __spreadValues({ ref, className: classes }, props));
3466
3552
  }
3467
3553
  );
3468
3554
  DataTableRow.displayName = "DataTableRow";
@@ -3493,7 +3579,7 @@ function DataTableCell({
3493
3579
  isPinned && "z-10",
3494
3580
  className
3495
3581
  );
3496
- const cellElement = isGrid ? /* @__PURE__ */ jsx8(
3582
+ const cellElement = isGrid ? /* @__PURE__ */ jsx9(
3497
3583
  "div",
3498
3584
  {
3499
3585
  role: "cell",
@@ -3501,7 +3587,7 @@ function DataTableCell({
3501
3587
  style: { minWidth: cell.column.columnDef.minSize },
3502
3588
  children: content
3503
3589
  }
3504
- ) : /* @__PURE__ */ jsx8(
3590
+ ) : /* @__PURE__ */ jsx9(
3505
3591
  BaseTableCell,
3506
3592
  {
3507
3593
  className: cellClassName,
@@ -3513,9 +3599,9 @@ function DataTableCell({
3513
3599
  }
3514
3600
  );
3515
3601
  if (!shouldShowContextualMenu || !onContextCell) return cellElement;
3516
- return /* @__PURE__ */ jsxs7(ContextMenu, { children: [
3517
- /* @__PURE__ */ jsx8(ContextMenuTrigger, { asChild: true, children: cellElement }),
3518
- /* @__PURE__ */ jsx8(
3602
+ return /* @__PURE__ */ jsxs8(ContextMenu, { children: [
3603
+ /* @__PURE__ */ jsx9(ContextMenuTrigger, { asChild: true, children: cellElement }),
3604
+ /* @__PURE__ */ jsx9(
3519
3605
  CellContextualFilter,
3520
3606
  {
3521
3607
  filter: contextualFilter,
@@ -3534,7 +3620,7 @@ function DataTableGroupRow({
3534
3620
  layout = "auto"
3535
3621
  }) {
3536
3622
  if (layout === "grid") {
3537
- return /* @__PURE__ */ jsx8("div", { role: "row", className: "bg-muted/50 hover:bg-muted/50 col-span-full grid grid-cols-subgrid", children: /* @__PURE__ */ jsx8(
3623
+ return /* @__PURE__ */ jsx9("div", { role: "row", className: "bg-muted/50 hover:bg-muted/50 col-span-full grid grid-cols-subgrid", children: /* @__PURE__ */ jsx9(
3538
3624
  "div",
3539
3625
  {
3540
3626
  role: "cell",
@@ -3544,7 +3630,7 @@ function DataTableGroupRow({
3544
3630
  }
3545
3631
  ) });
3546
3632
  }
3547
- return /* @__PURE__ */ jsx8(BaseTableRow, { className: "bg-muted/50 hover:bg-muted/50", children: /* @__PURE__ */ jsx8(BaseTableCell, { colSpan, className: "text-foreground border-b font-semibold whitespace-nowrap", children: groupLabel }) });
3633
+ return /* @__PURE__ */ jsx9(BaseTableRow, { className: "bg-muted/50 hover:bg-muted/50", children: /* @__PURE__ */ jsx9(BaseTableCell, { colSpan, className: "text-foreground border-b font-semibold whitespace-nowrap", children: groupLabel }) });
3548
3634
  }
3549
3635
  function DataTableSkeletonBody({
3550
3636
  rowCount = 10,
@@ -3553,32 +3639,32 @@ function DataTableSkeletonBody({
3553
3639
  layout = "auto"
3554
3640
  }) {
3555
3641
  const isGrid = layout === "grid";
3556
- const rows = Array.from({ length: rowCount }).map((_, rowIndex) => /* @__PURE__ */ jsx8(DataTableRow, { layout, children: columns.map(
3642
+ const rows = Array.from({ length: rowCount }).map((_, rowIndex) => /* @__PURE__ */ jsx9(DataTableRow, { layout, children: columns.map(
3557
3643
  (col) => {
3558
3644
  var _a, _b;
3559
- return isGrid ? /* @__PURE__ */ jsx8(
3645
+ return isGrid ? /* @__PURE__ */ jsx9(
3560
3646
  "div",
3561
3647
  {
3562
3648
  role: "cell",
3563
3649
  className: cn(TABLE_CELL_CLASSES, "flex items-center overflow-hidden"),
3564
3650
  style: { minWidth: col.minSize },
3565
- children: (_a = renderCell == null ? void 0 : renderCell(col.id)) != null ? _a : /* @__PURE__ */ jsx8(Skeleton, { className: "h-4 w-full" })
3651
+ children: (_a = renderCell == null ? void 0 : renderCell(col.id)) != null ? _a : /* @__PURE__ */ jsx9(Skeleton, { className: "h-4 w-full" })
3566
3652
  },
3567
3653
  `skeleton-col-${col.id}-row-${rowIndex}`
3568
- ) : /* @__PURE__ */ jsx8(
3654
+ ) : /* @__PURE__ */ jsx9(
3569
3655
  BaseTableCell,
3570
3656
  {
3571
3657
  style: { width: col.size, minWidth: col.minSize, maxWidth: col.maxSize },
3572
- children: (_b = renderCell == null ? void 0 : renderCell(col.id)) != null ? _b : /* @__PURE__ */ jsx8(Skeleton, { className: "h-4 w-full" })
3658
+ children: (_b = renderCell == null ? void 0 : renderCell(col.id)) != null ? _b : /* @__PURE__ */ jsx9(Skeleton, { className: "h-4 w-full" })
3573
3659
  },
3574
3660
  `skeleton-col-${col.id}-row-${rowIndex}`
3575
3661
  );
3576
3662
  }
3577
3663
  ) }, `skeleton-row-${rowIndex}`));
3578
3664
  if (isGrid) {
3579
- return /* @__PURE__ */ jsx8("div", { role: "rowgroup", className: "col-span-full grid grid-cols-subgrid", "data-testid": "table-skeleton-loader", children: rows });
3665
+ return /* @__PURE__ */ jsx9("div", { role: "rowgroup", className: "col-span-full grid grid-cols-subgrid", "data-testid": "table-skeleton-loader", children: rows });
3580
3666
  }
3581
- return /* @__PURE__ */ jsx8(BaseTableBody, { "data-testid": "table-skeleton-loader", children: rows });
3667
+ return /* @__PURE__ */ jsx9(BaseTableBody, { "data-testid": "table-skeleton-loader", children: rows });
3582
3668
  }
3583
3669
  function DataTableExpandedRow({
3584
3670
  colSpan,
@@ -3588,9 +3674,9 @@ function DataTableExpandedRow({
3588
3674
  }) {
3589
3675
  if (!show) return null;
3590
3676
  if (layout === "grid") {
3591
- return /* @__PURE__ */ jsx8("div", { role: "row", className: "col-span-full grid grid-cols-subgrid", children: /* @__PURE__ */ jsx8("div", { role: "cell", style: { gridColumn: `span ${colSpan}` }, className: "bg-card p-0 align-top whitespace-normal", children }) });
3677
+ return /* @__PURE__ */ jsx9("div", { role: "row", className: "col-span-full grid grid-cols-subgrid", children: /* @__PURE__ */ jsx9("div", { role: "cell", style: { gridColumn: `span ${colSpan}` }, className: "bg-card p-0 align-top whitespace-normal", children }) });
3592
3678
  }
3593
- return /* @__PURE__ */ jsx8(BaseTableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx8(BaseTableCell, { colSpan, className: "bg-card p-0 align-top whitespace-normal", children }) });
3679
+ return /* @__PURE__ */ jsx9(BaseTableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx9(BaseTableCell, { colSpan, className: "bg-card p-0 align-top whitespace-normal", children }) });
3594
3680
  }
3595
3681
  function DataTableBody({
3596
3682
  tableRows,
@@ -3616,7 +3702,7 @@ function DataTableBody({
3616
3702
  minSize: c.columnDef.minSize,
3617
3703
  maxSize: c.columnDef.maxSize
3618
3704
  }));
3619
- return /* @__PURE__ */ jsx8(
3705
+ return /* @__PURE__ */ jsx9(
3620
3706
  DataTableSkeletonBody,
3621
3707
  {
3622
3708
  columns: skeletonColumns,
@@ -3630,17 +3716,17 @@ function DataTableBody({
3630
3716
  var _a, _b, _c, _d;
3631
3717
  if ((_a = row.getIsGrouped) == null ? void 0 : _a.call(row)) {
3632
3718
  const groupLabel = (_c = row.groupingValue) != null ? _c : row.groupingColumnId ? (_b = row.getGroupingValue) == null ? void 0 : _b.call(row, row.groupingColumnId) : void 0;
3633
- return /* @__PURE__ */ jsx8(DataTableGroupRow, { groupLabel: String(groupLabel != null ? groupLabel : ""), colSpan, layout }, row.id);
3719
+ return /* @__PURE__ */ jsx9(DataTableGroupRow, { groupLabel: String(groupLabel != null ? groupLabel : ""), colSpan, layout }, row.id);
3634
3720
  }
3635
3721
  const isExpanded = !!(renderExpandedRow && ((_d = row.getIsExpanded) == null ? void 0 : _d.call(row)));
3636
3722
  const expandedRow = renderExpandedRow ? renderExpandedRow(row.original) : null;
3637
- return /* @__PURE__ */ jsxs7(React5.Fragment, { children: [
3638
- /* @__PURE__ */ jsx8(
3723
+ return /* @__PURE__ */ jsxs8(React6.Fragment, { children: [
3724
+ /* @__PURE__ */ jsx9(
3639
3725
  DataTableRow,
3640
3726
  __spreadProps(__spreadValues({}, onRowRender ? onRowRender(row.original) : {}), {
3641
3727
  "data-expanded": isExpanded || void 0,
3642
3728
  layout,
3643
- children: row.getVisibleCells().filter((cell) => !isFilterOnlyColumn(cell.column)).map((cell) => /* @__PURE__ */ jsx8(
3729
+ children: row.getVisibleCells().filter((cell) => !isFilterOnlyColumn(cell.column)).map((cell) => /* @__PURE__ */ jsx9(
3644
3730
  DataTableCell,
3645
3731
  {
3646
3732
  cell,
@@ -3654,21 +3740,21 @@ function DataTableBody({
3654
3740
  ))
3655
3741
  })
3656
3742
  ),
3657
- /* @__PURE__ */ jsx8(DataTableExpandedRow, { colSpan, show: isExpanded, layout, children: expandedRow })
3743
+ /* @__PURE__ */ jsx9(DataTableExpandedRow, { colSpan, show: isExpanded, layout, children: expandedRow })
3658
3744
  ] }, row.id);
3659
3745
  });
3660
3746
  if (isGrid) {
3661
- return /* @__PURE__ */ jsx8("div", { role: "rowgroup", className: "col-span-full grid grid-cols-subgrid", children: rows });
3747
+ return /* @__PURE__ */ jsx9("div", { role: "rowgroup", className: "col-span-full grid grid-cols-subgrid", children: rows });
3662
3748
  }
3663
- return /* @__PURE__ */ jsx8(BaseTableBody, { children: rows });
3749
+ return /* @__PURE__ */ jsx9(BaseTableBody, { children: rows });
3664
3750
  }
3665
3751
 
3666
3752
  // src/data-table/view-filter.tsx
3667
- import * as React7 from "react";
3753
+ import * as React8 from "react";
3668
3754
 
3669
3755
  // src/filter-bar/filter-bar.tsx
3670
- import * as React6 from "react";
3671
- import { Icon as Icon7 } from "@upbound/monarch-core";
3756
+ import * as React7 from "react";
3757
+ import { Icon as Icon8 } from "@upbound/monarch-core";
3672
3758
  import { Badge as Badge2 } from "@upbound/monarch-core";
3673
3759
  import { Button as Button6 } from "@upbound/monarch-core";
3674
3760
  import { ButtonGroup as ButtonGroup2, ButtonGroupText as ButtonGroupText2 } from "@upbound/monarch-core";
@@ -3691,7 +3777,6 @@ import {
3691
3777
  DropdownMenu as DropdownMenu4,
3692
3778
  DropdownMenuCheckboxItem as DropdownMenuCheckboxItem2,
3693
3779
  DropdownMenuContent as DropdownMenuContent4,
3694
- DropdownMenuItem as DropdownMenuItem4,
3695
3780
  DropdownMenuRadioGroup,
3696
3781
  DropdownMenuRadioItem,
3697
3782
  DropdownMenuTrigger as DropdownMenuTrigger4
@@ -3699,7 +3784,7 @@ import {
3699
3784
  import { Input as Input2 } from "@upbound/monarch-core";
3700
3785
  import { Label as Label3 } from "@upbound/monarch-core";
3701
3786
  import { Popover as Popover2, PopoverContent as PopoverContent2, PopoverTrigger as PopoverTrigger2 } from "@upbound/monarch-core";
3702
- import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
3787
+ import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
3703
3788
  function asCheckboxValue(value) {
3704
3789
  return Array.isArray(value) ? value : [];
3705
3790
  }
@@ -3733,6 +3818,17 @@ function applyTimeToDate(date, time) {
3733
3818
  function formatDateLabel(date) {
3734
3819
  return date.toLocaleDateString(void 0, { month: "short", day: "numeric" });
3735
3820
  }
3821
+ function composeRefs(...refs) {
3822
+ return (node) => {
3823
+ for (const ref of refs) {
3824
+ if (typeof ref === "function") ref(node);
3825
+ else if (ref) ref.current = node;
3826
+ }
3827
+ };
3828
+ }
3829
+ function hasOrder(filter) {
3830
+ return typeof filter.order === "number";
3831
+ }
3736
3832
  function FilterBar(_a) {
3737
3833
  var _b = _a, {
3738
3834
  filters,
@@ -3741,7 +3837,8 @@ function FilterBar(_a) {
3741
3837
  onRemoveFilter,
3742
3838
  onChangeFilter,
3743
3839
  className,
3744
- children
3840
+ children,
3841
+ ref
3745
3842
  } = _b, props = __objRest(_b, [
3746
3843
  "filters",
3747
3844
  "activeFilters",
@@ -3749,48 +3846,60 @@ function FilterBar(_a) {
3749
3846
  "onRemoveFilter",
3750
3847
  "onChangeFilter",
3751
3848
  "className",
3752
- "children"
3849
+ "children",
3850
+ "ref"
3753
3851
  ]);
3754
3852
  const usedKeys = new Set(activeFilters.map((f) => f.key));
3755
- const availableFilters = filters.filter((f) => !usedKeys.has(f.key));
3853
+ const remainingFilters = filters.filter((f) => !usedKeys.has(f.key));
3854
+ const availableFilters = filters.some(hasOrder) ? remainingFilters : sortBy(remainingFilters, (f) => f.label);
3756
3855
  const shouldShowFilters = availableFilters.length > 0 || activeFilters.length > 0;
3757
- const [pendingOpenKey, setPendingOpenKey] = React6.useState(null);
3856
+ const [pendingOpenKey, setPendingOpenKey] = React7.useState(null);
3758
3857
  function handleAddFilter(key) {
3759
3858
  onAddFilter(key);
3760
3859
  setPendingOpenKey(key);
3761
3860
  }
3762
- return /* @__PURE__ */ jsxs8(
3861
+ const containerRef = React7.useRef(null);
3862
+ return /* @__PURE__ */ jsxs9(
3763
3863
  "div",
3764
3864
  __spreadProps(__spreadValues({
3765
3865
  "data-slot": "filter-bar",
3766
3866
  "data-visible-filters": shouldShowFilters,
3767
- className: cn("flex flex-wrap items-center gap-2", className)
3867
+ className: cn("flex flex-wrap items-center gap-2", className),
3868
+ ref: composeRefs(containerRef, ref)
3768
3869
  }, props), {
3769
3870
  children: [
3770
- availableFilters.length > 0 && /* @__PURE__ */ jsxs8(DropdownMenu4, { children: [
3771
- /* @__PURE__ */ jsx9(DropdownMenuTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs8(Button6, { variant: "outline", children: [
3772
- /* @__PURE__ */ jsx9(Icon7, { name: "plus", "data-icon": "inline-start" }),
3773
- "Add filter"
3774
- ] }) }),
3775
- /* @__PURE__ */ jsx9(
3776
- DropdownMenuContent4,
3777
- {
3778
- align: "start",
3779
- className: "w-48",
3780
- onCloseAutoFocus: (e) => e.preventDefault(),
3781
- children: availableFilters.map((filter) => /* @__PURE__ */ jsx9(DropdownMenuItem4, { onSelect: () => handleAddFilter(filter.key), children: filter.label }, filter.key))
3782
- }
3783
- )
3784
- ] }),
3871
+ availableFilters.length > 0 && /* @__PURE__ */ jsxs9(
3872
+ Combobox2,
3873
+ {
3874
+ items: availableFilters,
3875
+ itemToStringValue: (item) => item.label,
3876
+ itemToStringLabel: (item) => item.label,
3877
+ onValueChange: (filter) => {
3878
+ if (filter) handleAddFilter(filter.key);
3879
+ },
3880
+ children: [
3881
+ /* @__PURE__ */ jsxs9(ComboboxTrigger2, { "aria-label": "Add filter", render: /* @__PURE__ */ jsx10(Button6, { variant: "outline" }), children: [
3882
+ /* @__PURE__ */ jsx10(Icon8, { name: "plus", "data-icon": "inline-start" }),
3883
+ "Add filter"
3884
+ ] }),
3885
+ /* @__PURE__ */ jsxs9(ComboboxContent2, { container: containerRef, align: "start", className: "w-48", children: [
3886
+ /* @__PURE__ */ jsx10(ComboboxInput2, { showTrigger: false, placeholder: "Search filters\u2026" }),
3887
+ /* @__PURE__ */ jsx10(ComboboxEmpty2, { children: "No filters found." }),
3888
+ /* @__PURE__ */ jsx10(ComboboxList2, { children: (filter) => /* @__PURE__ */ jsx10(ComboboxItem2, { value: filter, children: filter.label }, filter.key) })
3889
+ ] })
3890
+ ]
3891
+ }
3892
+ ),
3785
3893
  activeFilters.map((active) => {
3786
3894
  const definition = filters.find((f) => f.key === active.key);
3787
3895
  if (!definition) return null;
3788
- return /* @__PURE__ */ jsx9(
3896
+ return /* @__PURE__ */ jsx10(
3789
3897
  FilterChip,
3790
3898
  {
3791
3899
  definition,
3792
3900
  value: active.value,
3793
3901
  autoOpen: active.key === pendingOpenKey,
3902
+ container: containerRef,
3794
3903
  onChangeValue: (value) => onChangeFilter(active.key, value),
3795
3904
  onRemove: () => onRemoveFilter(active.key)
3796
3905
  },
@@ -3802,34 +3911,36 @@ function FilterBar(_a) {
3802
3911
  })
3803
3912
  );
3804
3913
  }
3805
- function FilterChip({ definition, value, autoOpen, onChangeValue, onRemove }) {
3914
+ function FilterChip({ definition, value, autoOpen, container, onChangeValue, onRemove }) {
3806
3915
  var _a;
3807
3916
  const type = (_a = definition.type) != null ? _a : "checkbox";
3808
3917
  switch (type) {
3809
3918
  case "checkbox":
3810
- return /* @__PURE__ */ jsx9(
3919
+ return /* @__PURE__ */ jsx10(
3811
3920
  CheckboxFilterChip,
3812
3921
  {
3813
3922
  definition,
3814
3923
  value,
3815
3924
  autoOpen,
3925
+ container,
3816
3926
  onChangeValue,
3817
3927
  onRemove
3818
3928
  }
3819
3929
  );
3820
3930
  case "radio":
3821
- return /* @__PURE__ */ jsx9(
3931
+ return /* @__PURE__ */ jsx10(
3822
3932
  RadioFilterChip,
3823
3933
  {
3824
3934
  definition,
3825
3935
  value,
3826
3936
  autoOpen,
3937
+ container,
3827
3938
  onChangeValue,
3828
3939
  onRemove
3829
3940
  }
3830
3941
  );
3831
3942
  case "text":
3832
- return /* @__PURE__ */ jsx9(
3943
+ return /* @__PURE__ */ jsx10(
3833
3944
  TextFilterChip,
3834
3945
  {
3835
3946
  definition,
@@ -3840,7 +3951,7 @@ function FilterChip({ definition, value, autoOpen, onChangeValue, onRemove }) {
3840
3951
  }
3841
3952
  );
3842
3953
  case "multiText":
3843
- return /* @__PURE__ */ jsx9(
3954
+ return /* @__PURE__ */ jsx10(
3844
3955
  MultiTextFilterChip,
3845
3956
  {
3846
3957
  definition,
@@ -3851,7 +3962,7 @@ function FilterChip({ definition, value, autoOpen, onChangeValue, onRemove }) {
3851
3962
  }
3852
3963
  );
3853
3964
  case "date":
3854
- return /* @__PURE__ */ jsx9(
3965
+ return /* @__PURE__ */ jsx10(
3855
3966
  DateFilterChip,
3856
3967
  {
3857
3968
  definition,
@@ -3864,26 +3975,28 @@ function FilterChip({ definition, value, autoOpen, onChangeValue, onRemove }) {
3864
3975
  }
3865
3976
  }
3866
3977
  function FilterChipRemoveButton({ label, onRemove }) {
3867
- return /* @__PURE__ */ jsx9(Button6, { variant: "outline", size: "icon", "aria-label": `Remove ${label} filter`, onClick: onRemove, children: /* @__PURE__ */ jsx9(Icon7, { name: "xmark" }) });
3978
+ return /* @__PURE__ */ jsx10(Button6, { variant: "outline", size: "icon", "aria-label": `Remove ${label} filter`, onClick: onRemove, children: /* @__PURE__ */ jsx10(Icon8, { name: "xmark" }) });
3868
3979
  }
3869
3980
  function CheckboxFilterChip({
3870
3981
  definition,
3871
3982
  value,
3872
3983
  autoOpen,
3984
+ container,
3873
3985
  onChangeValue,
3874
3986
  onRemove
3875
3987
  }) {
3876
3988
  var _a, _b;
3877
- const { label, options, searchable = false } = definition;
3989
+ const { label, searchable = false } = definition;
3990
+ const options = sortBy(definition.options, (o) => o.label);
3878
3991
  const values = asCheckboxValue(value);
3879
3992
  const displayLabel = values.length === 0 ? "Any" : values.length === 1 ? (_b = (_a = options.find((o) => o.value === values[0])) == null ? void 0 : _a.label) != null ? _b : values[0] : `${values.length} selected`;
3880
3993
  function toggle(optionValue) {
3881
3994
  const next = values.includes(optionValue) ? values.filter((v) => v !== optionValue) : [...values, optionValue];
3882
3995
  onChangeValue(next);
3883
3996
  }
3884
- return /* @__PURE__ */ jsxs8(ButtonGroup2, { children: [
3885
- /* @__PURE__ */ jsx9(ButtonGroupText2, { children: label }),
3886
- searchable ? /* @__PURE__ */ jsxs8(
3997
+ return /* @__PURE__ */ jsxs9(ButtonGroup2, { children: [
3998
+ /* @__PURE__ */ jsx10(ButtonGroupText2, { children: label }),
3999
+ searchable ? /* @__PURE__ */ jsxs9(
3887
4000
  Combobox2,
3888
4001
  {
3889
4002
  items: options,
@@ -3893,40 +4006,48 @@ function CheckboxFilterChip({
3893
4006
  value: options.filter((o) => values.includes(o.value)),
3894
4007
  onValueChange: (selected) => onChangeValue(selected.map((s) => s.value)),
3895
4008
  children: [
3896
- /* @__PURE__ */ jsx9(
4009
+ /* @__PURE__ */ jsx10(
3897
4010
  ComboboxTrigger2,
3898
4011
  {
3899
- render: /* @__PURE__ */ jsx9(Button6, { variant: "outline", className: "gap-1 font-normal [&>svg:last-child]:size-(--icon-sm)" }),
3900
- children: /* @__PURE__ */ jsx9("span", { className: values.length === 0 ? "text-muted-foreground" : "", children: displayLabel })
4012
+ render: /* @__PURE__ */ jsx10(Button6, { variant: "outline", className: "gap-1 font-normal [&>svg:last-child]:size-(--icon-sm)" }),
4013
+ children: /* @__PURE__ */ jsx10("span", { className: values.length === 0 ? "text-muted-foreground" : "", children: displayLabel })
3901
4014
  }
3902
4015
  ),
3903
- /* @__PURE__ */ jsxs8(ComboboxContent2, { className: "min-w-64", collisionAvoidance: { side: "none", align: "shift" }, children: [
3904
- /* @__PURE__ */ jsx9(ComboboxInput2, { showTrigger: false, placeholder: `Search ${label.toLowerCase()}\u2026` }),
3905
- values.length > 0 && /* @__PURE__ */ jsxs8(Fragment6, { children: [
3906
- /* @__PURE__ */ jsxs8(ComboboxSelectedChips2, { children: [
3907
- /* @__PURE__ */ jsx9(ComboboxValue2, { children: (selected) => /* @__PURE__ */ jsx9(Fragment6, { children: selected.map((item) => /* @__PURE__ */ jsx9(ComboboxChip2, { children: item.label }, item.value)) }) }),
3908
- /* @__PURE__ */ jsx9(ComboboxClearAll2, { onClick: () => onChangeValue([]) })
3909
- ] }),
3910
- /* @__PURE__ */ jsx9(ComboboxSeparator2, {})
3911
- ] }),
3912
- /* @__PURE__ */ jsxs8(ComboboxEmpty2, { children: [
3913
- "No ",
3914
- label.toLowerCase(),
3915
- " found."
3916
- ] }),
3917
- /* @__PURE__ */ jsx9(ComboboxList2, { children: (item) => /* @__PURE__ */ jsxs8(ComboboxItem2, { value: item, children: [
3918
- item.icon,
3919
- item.label
3920
- ] }, item.value) })
3921
- ] })
4016
+ /* @__PURE__ */ jsxs9(
4017
+ ComboboxContent2,
4018
+ {
4019
+ container,
4020
+ className: "min-w-64",
4021
+ collisionAvoidance: { side: "none", align: "shift" },
4022
+ children: [
4023
+ /* @__PURE__ */ jsx10(ComboboxInput2, { showTrigger: false, placeholder: `Search ${label.toLowerCase()}\u2026` }),
4024
+ values.length > 0 && /* @__PURE__ */ jsxs9(Fragment6, { children: [
4025
+ /* @__PURE__ */ jsxs9(ComboboxSelectedChips2, { children: [
4026
+ /* @__PURE__ */ jsx10(ComboboxValue2, { children: (selected) => /* @__PURE__ */ jsx10(Fragment6, { children: selected.map((item) => /* @__PURE__ */ jsx10(ComboboxChip2, { children: item.label }, item.value)) }) }),
4027
+ /* @__PURE__ */ jsx10(ComboboxClearAll2, { onClick: () => onChangeValue([]) })
4028
+ ] }),
4029
+ /* @__PURE__ */ jsx10(ComboboxSeparator2, {})
4030
+ ] }),
4031
+ /* @__PURE__ */ jsxs9(ComboboxEmpty2, { children: [
4032
+ "No ",
4033
+ label.toLowerCase(),
4034
+ " found."
4035
+ ] }),
4036
+ /* @__PURE__ */ jsx10(ComboboxList2, { children: (item) => /* @__PURE__ */ jsxs9(ComboboxItem2, { value: item, children: [
4037
+ item.icon,
4038
+ item.label
4039
+ ] }, item.value) })
4040
+ ]
4041
+ }
4042
+ )
3922
4043
  ]
3923
4044
  }
3924
- ) : /* @__PURE__ */ jsxs8(DropdownMenu4, { defaultOpen: autoOpen, children: [
3925
- /* @__PURE__ */ jsx9(DropdownMenuTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs8(Button6, { variant: "outline", className: "gap-1 font-normal", children: [
3926
- /* @__PURE__ */ jsx9("span", { className: values.length === 0 ? "text-muted-foreground" : "", children: displayLabel }),
3927
- /* @__PURE__ */ jsx9(Icon7, { name: "chevron-down", size: "sm", className: "text-muted-foreground" })
4045
+ ) : /* @__PURE__ */ jsxs9(DropdownMenu4, { defaultOpen: autoOpen, children: [
4046
+ /* @__PURE__ */ jsx10(DropdownMenuTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs9(Button6, { variant: "outline", className: "gap-1 font-normal", children: [
4047
+ /* @__PURE__ */ jsx10("span", { className: values.length === 0 ? "text-muted-foreground" : "", children: displayLabel }),
4048
+ /* @__PURE__ */ jsx10(Icon8, { name: "chevron-down", size: "sm", className: "text-muted-foreground" })
3928
4049
  ] }) }),
3929
- /* @__PURE__ */ jsx9(DropdownMenuContent4, { align: "start", className: "w-48", children: options.map((opt) => /* @__PURE__ */ jsxs8(
4050
+ /* @__PURE__ */ jsx10(DropdownMenuContent4, { align: "start", className: "w-48", children: options.map((opt) => /* @__PURE__ */ jsxs9(
3930
4051
  DropdownMenuCheckboxItem2,
3931
4052
  {
3932
4053
  checked: values.includes(opt.value),
@@ -3939,24 +4060,26 @@ function CheckboxFilterChip({
3939
4060
  opt.value
3940
4061
  )) })
3941
4062
  ] }),
3942
- /* @__PURE__ */ jsx9(FilterChipRemoveButton, { label, onRemove })
4063
+ /* @__PURE__ */ jsx10(FilterChipRemoveButton, { label, onRemove })
3943
4064
  ] });
3944
4065
  }
3945
4066
  function RadioFilterChip({
3946
4067
  definition,
3947
4068
  value,
3948
4069
  autoOpen,
4070
+ container,
3949
4071
  onChangeValue,
3950
4072
  onRemove
3951
4073
  }) {
3952
4074
  var _a, _b, _c;
3953
- const { label, options, searchable = false } = definition;
4075
+ const { label, searchable = false } = definition;
4076
+ const options = sortBy(definition.options, (o) => o.label);
3954
4077
  const selectedValue = asRadioValue(value);
3955
4078
  const displayLabel = selectedValue ? (_b = (_a = options.find((o) => o.value === selectedValue)) == null ? void 0 : _a.label) != null ? _b : selectedValue : "Any";
3956
4079
  const selected = (_c = options.find((o) => o.value === selectedValue)) != null ? _c : null;
3957
- return /* @__PURE__ */ jsxs8(ButtonGroup2, { children: [
3958
- /* @__PURE__ */ jsx9(ButtonGroupText2, { children: label }),
3959
- searchable ? /* @__PURE__ */ jsxs8(
4080
+ return /* @__PURE__ */ jsxs9(ButtonGroup2, { children: [
4081
+ /* @__PURE__ */ jsx10(ButtonGroupText2, { children: label }),
4082
+ searchable ? /* @__PURE__ */ jsxs9(
3960
4083
  Combobox2,
3961
4084
  {
3962
4085
  items: options,
@@ -3968,38 +4091,46 @@ function RadioFilterChip({
3968
4091
  return onChangeValue((_a2 = next == null ? void 0 : next.value) != null ? _a2 : "");
3969
4092
  },
3970
4093
  children: [
3971
- /* @__PURE__ */ jsx9(
4094
+ /* @__PURE__ */ jsx10(
3972
4095
  ComboboxTrigger2,
3973
4096
  {
3974
- render: /* @__PURE__ */ jsx9(Button6, { variant: "outline", className: "gap-1 font-normal [&>svg:last-child]:size-(--icon-sm)" }),
3975
- children: /* @__PURE__ */ jsx9("span", { className: selectedValue ? "" : "text-muted-foreground", children: displayLabel })
4097
+ render: /* @__PURE__ */ jsx10(Button6, { variant: "outline", className: "gap-1 font-normal [&>svg:last-child]:size-(--icon-sm)" }),
4098
+ children: /* @__PURE__ */ jsx10("span", { className: selectedValue ? "" : "text-muted-foreground", children: displayLabel })
3976
4099
  }
3977
4100
  ),
3978
- /* @__PURE__ */ jsxs8(ComboboxContent2, { className: "min-w-64", collisionAvoidance: { side: "none", align: "shift" }, children: [
3979
- /* @__PURE__ */ jsx9(ComboboxInput2, { showTrigger: false, placeholder: `Search ${label.toLowerCase()}\u2026` }),
3980
- /* @__PURE__ */ jsxs8(ComboboxEmpty2, { children: [
3981
- "No ",
3982
- label.toLowerCase(),
3983
- " found."
3984
- ] }),
3985
- /* @__PURE__ */ jsx9(ComboboxList2, { children: (item) => /* @__PURE__ */ jsxs8(ComboboxItem2, { value: item, children: [
3986
- item.icon,
3987
- item.label
3988
- ] }, item.value) })
3989
- ] })
4101
+ /* @__PURE__ */ jsxs9(
4102
+ ComboboxContent2,
4103
+ {
4104
+ container,
4105
+ className: "min-w-64",
4106
+ collisionAvoidance: { side: "none", align: "shift" },
4107
+ children: [
4108
+ /* @__PURE__ */ jsx10(ComboboxInput2, { showTrigger: false, placeholder: `Search ${label.toLowerCase()}\u2026` }),
4109
+ /* @__PURE__ */ jsxs9(ComboboxEmpty2, { children: [
4110
+ "No ",
4111
+ label.toLowerCase(),
4112
+ " found."
4113
+ ] }),
4114
+ /* @__PURE__ */ jsx10(ComboboxList2, { children: (item) => /* @__PURE__ */ jsxs9(ComboboxItem2, { value: item, children: [
4115
+ item.icon,
4116
+ item.label
4117
+ ] }, item.value) })
4118
+ ]
4119
+ }
4120
+ )
3990
4121
  ]
3991
4122
  }
3992
- ) : /* @__PURE__ */ jsxs8(DropdownMenu4, { defaultOpen: autoOpen, children: [
3993
- /* @__PURE__ */ jsx9(DropdownMenuTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs8(Button6, { variant: "outline", className: "gap-1 font-normal", children: [
3994
- /* @__PURE__ */ jsx9("span", { className: selectedValue ? "" : "text-muted-foreground", children: displayLabel }),
3995
- /* @__PURE__ */ jsx9(Icon7, { name: "chevron-down", size: "sm", className: "text-muted-foreground" })
4123
+ ) : /* @__PURE__ */ jsxs9(DropdownMenu4, { defaultOpen: autoOpen, children: [
4124
+ /* @__PURE__ */ jsx10(DropdownMenuTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs9(Button6, { variant: "outline", className: "gap-1 font-normal", children: [
4125
+ /* @__PURE__ */ jsx10("span", { className: selectedValue ? "" : "text-muted-foreground", children: displayLabel }),
4126
+ /* @__PURE__ */ jsx10(Icon8, { name: "chevron-down", size: "sm", className: "text-muted-foreground" })
3996
4127
  ] }) }),
3997
- /* @__PURE__ */ jsx9(DropdownMenuContent4, { align: "start", className: "w-48", children: /* @__PURE__ */ jsx9(DropdownMenuRadioGroup, { value: selectedValue, onValueChange: onChangeValue, children: options.map((opt) => /* @__PURE__ */ jsxs8(DropdownMenuRadioItem, { value: opt.value, children: [
4128
+ /* @__PURE__ */ jsx10(DropdownMenuContent4, { align: "start", className: "w-48", children: /* @__PURE__ */ jsx10(DropdownMenuRadioGroup, { value: selectedValue, onValueChange: onChangeValue, children: options.map((opt) => /* @__PURE__ */ jsxs9(DropdownMenuRadioItem, { value: opt.value, children: [
3998
4129
  opt.icon,
3999
4130
  opt.label
4000
4131
  ] }, opt.value)) }) })
4001
4132
  ] }),
4002
- /* @__PURE__ */ jsx9(FilterChipRemoveButton, { label, onRemove })
4133
+ /* @__PURE__ */ jsx10(FilterChipRemoveButton, { label, onRemove })
4003
4134
  ] });
4004
4135
  }
4005
4136
  function TextFilterChip({
@@ -4011,12 +4142,12 @@ function TextFilterChip({
4011
4142
  }) {
4012
4143
  const { label, placeholder } = definition;
4013
4144
  const text = asTextValue(value);
4014
- const [open, setOpen] = React6.useState(!!autoOpen);
4015
- return /* @__PURE__ */ jsxs8(ButtonGroup2, { children: [
4016
- /* @__PURE__ */ jsx9(ButtonGroupText2, { children: label }),
4017
- /* @__PURE__ */ jsxs8(Popover2, { open, onOpenChange: setOpen, children: [
4018
- /* @__PURE__ */ jsx9(PopoverTrigger2, { asChild: true, children: /* @__PURE__ */ jsx9(Button6, { variant: "outline", className: "gap-1 font-normal", children: /* @__PURE__ */ jsx9("span", { className: text ? "" : "text-muted-foreground", children: text || "Any" }) }) }),
4019
- /* @__PURE__ */ jsx9(PopoverContent2, { align: "start", children: /* @__PURE__ */ jsx9(
4145
+ const [open, setOpen] = React7.useState(!!autoOpen);
4146
+ return /* @__PURE__ */ jsxs9(ButtonGroup2, { children: [
4147
+ /* @__PURE__ */ jsx10(ButtonGroupText2, { children: label }),
4148
+ /* @__PURE__ */ jsxs9(Popover2, { open, onOpenChange: setOpen, children: [
4149
+ /* @__PURE__ */ jsx10(PopoverTrigger2, { asChild: true, children: /* @__PURE__ */ jsx10(Button6, { variant: "outline", className: "gap-1 font-normal", children: /* @__PURE__ */ jsx10("span", { className: text ? "" : "text-muted-foreground", children: text || "Any" }) }) }),
4150
+ /* @__PURE__ */ jsx10(PopoverContent2, { align: "start", children: /* @__PURE__ */ jsx10(
4020
4151
  Input2,
4021
4152
  {
4022
4153
  autoFocus: true,
@@ -4029,7 +4160,7 @@ function TextFilterChip({
4029
4160
  }
4030
4161
  ) })
4031
4162
  ] }),
4032
- /* @__PURE__ */ jsx9(FilterChipRemoveButton, { label, onRemove })
4163
+ /* @__PURE__ */ jsx10(FilterChipRemoveButton, { label, onRemove })
4033
4164
  ] });
4034
4165
  }
4035
4166
  function MultiTextFilterChip({
@@ -4041,7 +4172,7 @@ function MultiTextFilterChip({
4041
4172
  }) {
4042
4173
  const { label, placeholder } = definition;
4043
4174
  const tokens = asMultiTextValue(value);
4044
- const [draft, setDraft] = React6.useState("");
4175
+ const [draft, setDraft] = React7.useState("");
4045
4176
  const displayLabel = tokens.length === 0 ? "Any" : tokens.length === 1 ? tokens[0] : `${tokens.length} values`;
4046
4177
  function addToken() {
4047
4178
  const token = draft.trim();
@@ -4055,25 +4186,25 @@ function MultiTextFilterChip({
4055
4186
  function removeToken(token) {
4056
4187
  onChangeValue(tokens.filter((t) => t !== token));
4057
4188
  }
4058
- return /* @__PURE__ */ jsxs8(ButtonGroup2, { children: [
4059
- /* @__PURE__ */ jsx9(ButtonGroupText2, { children: label }),
4060
- /* @__PURE__ */ jsxs8(Popover2, { defaultOpen: autoOpen, children: [
4061
- /* @__PURE__ */ jsx9(PopoverTrigger2, { asChild: true, children: /* @__PURE__ */ jsx9(Button6, { variant: "outline", className: "gap-1 font-normal", children: /* @__PURE__ */ jsx9("span", { className: tokens.length === 0 ? "text-muted-foreground" : "", children: displayLabel }) }) }),
4062
- /* @__PURE__ */ jsx9(PopoverContent2, { align: "start", children: /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-2", children: [
4063
- tokens.length > 0 && /* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-1", children: tokens.map((token) => /* @__PURE__ */ jsxs8(Badge2, { variant: "secondary", className: "gap-1", children: [
4189
+ return /* @__PURE__ */ jsxs9(ButtonGroup2, { children: [
4190
+ /* @__PURE__ */ jsx10(ButtonGroupText2, { children: label }),
4191
+ /* @__PURE__ */ jsxs9(Popover2, { defaultOpen: autoOpen, children: [
4192
+ /* @__PURE__ */ jsx10(PopoverTrigger2, { asChild: true, children: /* @__PURE__ */ jsx10(Button6, { variant: "outline", className: "gap-1 font-normal", children: /* @__PURE__ */ jsx10("span", { className: tokens.length === 0 ? "text-muted-foreground" : "", children: displayLabel }) }) }),
4193
+ /* @__PURE__ */ jsx10(PopoverContent2, { align: "start", children: /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-2", children: [
4194
+ tokens.length > 0 && /* @__PURE__ */ jsx10("div", { className: "flex flex-wrap gap-1", children: tokens.map((token) => /* @__PURE__ */ jsxs9(Badge2, { variant: "secondary", className: "gap-1", children: [
4064
4195
  token,
4065
- /* @__PURE__ */ jsx9(
4196
+ /* @__PURE__ */ jsx10(
4066
4197
  "button",
4067
4198
  {
4068
4199
  type: "button",
4069
4200
  "aria-label": `Remove ${token}`,
4070
4201
  onClick: () => removeToken(token),
4071
4202
  className: "cursor-pointer",
4072
- children: /* @__PURE__ */ jsx9(Icon7, { name: "xmark", size: "xs" })
4203
+ children: /* @__PURE__ */ jsx10(Icon8, { name: "xmark", size: "xs" })
4073
4204
  }
4074
4205
  )
4075
4206
  ] }, token)) }),
4076
- /* @__PURE__ */ jsx9(
4207
+ /* @__PURE__ */ jsx10(
4077
4208
  Input2,
4078
4209
  {
4079
4210
  autoFocus: true,
@@ -4092,7 +4223,7 @@ function MultiTextFilterChip({
4092
4223
  )
4093
4224
  ] }) })
4094
4225
  ] }),
4095
- /* @__PURE__ */ jsx9(FilterChipRemoveButton, { label, onRemove })
4226
+ /* @__PURE__ */ jsx10(FilterChipRemoveButton, { label, onRemove })
4096
4227
  ] });
4097
4228
  }
4098
4229
  function DateFilterChip({
@@ -4122,12 +4253,12 @@ function DateFilterChip({
4122
4253
  if (!endDate) return;
4123
4254
  onChangeValue({ startDate, endDate: applyTimeToDate(endDate, time) });
4124
4255
  }
4125
- return /* @__PURE__ */ jsxs8(ButtonGroup2, { children: [
4126
- /* @__PURE__ */ jsx9(ButtonGroupText2, { children: label }),
4127
- /* @__PURE__ */ jsxs8(Popover2, { defaultOpen: autoOpen, children: [
4128
- /* @__PURE__ */ jsx9(PopoverTrigger2, { asChild: true, children: /* @__PURE__ */ jsx9(Button6, { variant: "outline", className: "gap-1 font-normal", children: /* @__PURE__ */ jsx9("span", { className: startDate ? "" : "text-muted-foreground", children: displayLabel }) }) }),
4129
- /* @__PURE__ */ jsx9(PopoverContent2, { align: "start", className: "w-fit", children: /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-2", children: [
4130
- /* @__PURE__ */ jsx9(
4256
+ return /* @__PURE__ */ jsxs9(ButtonGroup2, { children: [
4257
+ /* @__PURE__ */ jsx10(ButtonGroupText2, { children: label }),
4258
+ /* @__PURE__ */ jsxs9(Popover2, { defaultOpen: autoOpen, children: [
4259
+ /* @__PURE__ */ jsx10(PopoverTrigger2, { asChild: true, children: /* @__PURE__ */ jsx10(Button6, { variant: "outline", className: "gap-1 font-normal", children: /* @__PURE__ */ jsx10("span", { className: startDate ? "" : "text-muted-foreground", children: displayLabel }) }) }),
4260
+ /* @__PURE__ */ jsx10(PopoverContent2, { align: "start", className: "w-fit", children: /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-2", children: [
4261
+ /* @__PURE__ */ jsx10(
4131
4262
  Calendar2,
4132
4263
  {
4133
4264
  mode: "range",
@@ -4135,9 +4266,9 @@ function DateFilterChip({
4135
4266
  onSelect: pickRange
4136
4267
  }
4137
4268
  ),
4138
- showTimeInputs && /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-2", children: [
4139
- /* @__PURE__ */ jsxs8("div", { className: "flex w-full items-center gap-2", children: [
4140
- /* @__PURE__ */ jsx9(
4269
+ showTimeInputs && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-2", children: [
4270
+ /* @__PURE__ */ jsxs9("div", { className: "flex w-full items-center gap-2", children: [
4271
+ /* @__PURE__ */ jsx10(
4141
4272
  Label3,
4142
4273
  {
4143
4274
  htmlFor: `${definition.key}-start-time`,
@@ -4145,7 +4276,7 @@ function DateFilterChip({
4145
4276
  children: "Start"
4146
4277
  }
4147
4278
  ),
4148
- /* @__PURE__ */ jsx9(
4279
+ /* @__PURE__ */ jsx10(
4149
4280
  Input2,
4150
4281
  {
4151
4282
  id: `${definition.key}-start-time`,
@@ -4157,8 +4288,8 @@ function DateFilterChip({
4157
4288
  }
4158
4289
  )
4159
4290
  ] }),
4160
- /* @__PURE__ */ jsxs8("div", { className: "flex w-full items-center gap-2", children: [
4161
- /* @__PURE__ */ jsx9(
4291
+ /* @__PURE__ */ jsxs9("div", { className: "flex w-full items-center gap-2", children: [
4292
+ /* @__PURE__ */ jsx10(
4162
4293
  Label3,
4163
4294
  {
4164
4295
  htmlFor: `${definition.key}-end-time`,
@@ -4166,7 +4297,7 @@ function DateFilterChip({
4166
4297
  children: "End"
4167
4298
  }
4168
4299
  ),
4169
- /* @__PURE__ */ jsx9(
4300
+ /* @__PURE__ */ jsx10(
4170
4301
  Input2,
4171
4302
  {
4172
4303
  id: `${definition.key}-end-time`,
@@ -4181,7 +4312,7 @@ function DateFilterChip({
4181
4312
  ] })
4182
4313
  ] }) })
4183
4314
  ] }),
4184
- /* @__PURE__ */ jsx9(FilterChipRemoveButton, { label, onRemove })
4315
+ /* @__PURE__ */ jsx10(FilterChipRemoveButton, { label, onRemove })
4185
4316
  ] });
4186
4317
  }
4187
4318
 
@@ -4192,26 +4323,26 @@ var isCheckboxColumnFilter = (definition) => definition.type === "checkbox";
4192
4323
  var isMultiTextColumnFilter = (definition) => definition.type === "multiText";
4193
4324
 
4194
4325
  // src/data-table/view-filter.tsx
4195
- import { jsx as jsx10 } from "react/jsx-runtime";
4326
+ import { jsx as jsx11 } from "react/jsx-runtime";
4196
4327
  function toFilterOption(opt) {
4197
4328
  return typeof opt === "string" ? { value: opt, label: opt } : { value: opt.value, label: opt.label };
4198
4329
  }
4199
4330
  function toFilterBarDefinition(key, filter) {
4200
- var _a, _b, _c;
4201
- const base = { key, label: filter.title, order: (_a = filter.order) != null ? _a : 0 };
4331
+ var _a, _b;
4332
+ const base = { key, label: filter.title, order: filter.order };
4202
4333
  if (isCheckboxColumnFilter(filter)) {
4203
4334
  const options = "options" in filter && filter.options ? filter.options : [];
4204
4335
  return __spreadProps(__spreadValues({}, base), {
4205
4336
  type: "checkbox",
4206
4337
  options: options.map(toFilterOption),
4207
- searchable: (_b = filter.searchable) != null ? _b : true
4338
+ searchable: (_a = filter.searchable) != null ? _a : true
4208
4339
  });
4209
4340
  }
4210
4341
  if (isRadioColumnFilter(filter)) {
4211
4342
  return __spreadProps(__spreadValues({}, base), {
4212
4343
  type: "radio",
4213
4344
  options: filter.options.map(toFilterOption),
4214
- searchable: (_c = filter.searchable) != null ? _c : true
4345
+ searchable: (_b = filter.searchable) != null ? _b : true
4215
4346
  });
4216
4347
  }
4217
4348
  if (isDateRangeColumnFilter(filter)) {
@@ -4235,7 +4366,7 @@ function ViewFilter({
4235
4366
  onColumnFiltersChange,
4236
4367
  className
4237
4368
  }) {
4238
- const filterableColumns = React7.useMemo(
4369
+ const filterableColumns = React8.useMemo(
4239
4370
  () => columns.filter((column) => !isFilterOnlyColumn(column) && column.getCanFilter()).flatMap((column) => {
4240
4371
  var _a;
4241
4372
  const filter = (_a = column.columnDef.meta) == null ? void 0 : _a.filter;
@@ -4243,19 +4374,24 @@ function ViewFilter({
4243
4374
  }),
4244
4375
  [columns]
4245
4376
  );
4246
- const filterDefinitions = React7.useMemo(
4247
- () => filterableColumns.map(({ key, filter }) => toFilterBarDefinition(key, filter)).sort((a, b) => a.order - b.order),
4377
+ const filterDefinitions = React8.useMemo(
4378
+ () => filterableColumns.map(({ key, filter }) => toFilterBarDefinition(key, filter)).sort((a, b) => {
4379
+ if (a.order == null && b.order == null) return 0;
4380
+ if (a.order == null) return 1;
4381
+ if (b.order == null) return -1;
4382
+ return a.order - b.order;
4383
+ }),
4248
4384
  [filterableColumns]
4249
4385
  );
4250
- const emptyValueByKey = React7.useMemo(
4386
+ const emptyValueByKey = React8.useMemo(
4251
4387
  () => new Map(filterableColumns.map(({ key, filter }) => [key, emptyValueFor(filter)])),
4252
4388
  [filterableColumns]
4253
4389
  );
4254
- const activeFilters = React7.useMemo(
4390
+ const activeFilters = React8.useMemo(
4255
4391
  () => columnFilters.map((filter) => ({ key: filter.id, value: filter.value })),
4256
4392
  [columnFilters]
4257
4393
  );
4258
- return /* @__PURE__ */ jsx10(
4394
+ return /* @__PURE__ */ jsx11(
4259
4395
  FilterBar,
4260
4396
  {
4261
4397
  className,
@@ -4269,10 +4405,10 @@ function ViewFilter({
4269
4405
  }
4270
4406
 
4271
4407
  // src/section-header.tsx
4272
- import { jsx as jsx11 } from "react/jsx-runtime";
4408
+ import { jsx as jsx12 } from "react/jsx-runtime";
4273
4409
  function SectionHeader(_a) {
4274
4410
  var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
4275
- return /* @__PURE__ */ jsx11(
4411
+ return /* @__PURE__ */ jsx12(
4276
4412
  "div",
4277
4413
  __spreadProps(__spreadValues({
4278
4414
  "data-slot": "section-header",
@@ -4284,19 +4420,19 @@ function SectionHeader(_a) {
4284
4420
  }
4285
4421
  function SectionHeaderContent(_a) {
4286
4422
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
4287
- return /* @__PURE__ */ jsx11("div", __spreadValues({ "data-slot": "section-header-content", className: cn("flex flex-col gap-1", className) }, props));
4423
+ return /* @__PURE__ */ jsx12("div", __spreadValues({ "data-slot": "section-header-content", className: cn("flex flex-col gap-1", className) }, props));
4288
4424
  }
4289
4425
  function SectionHeaderTitle(_a) {
4290
4426
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
4291
- return /* @__PURE__ */ jsx11("h2", __spreadValues({ "data-slot": "section-header-title", className: cn("text-h3 text-foreground", className) }, props));
4427
+ return /* @__PURE__ */ jsx12("h2", __spreadValues({ "data-slot": "section-header-title", className: cn("text-h3 text-foreground", className) }, props));
4292
4428
  }
4293
4429
  function SectionHeaderDescription(_a) {
4294
4430
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
4295
- return /* @__PURE__ */ jsx11("p", __spreadValues({ "data-slot": "section-header-description", className: cn("text-body text-muted-foreground", className) }, props));
4431
+ return /* @__PURE__ */ jsx12("p", __spreadValues({ "data-slot": "section-header-description", className: cn("text-body text-muted-foreground", className) }, props));
4296
4432
  }
4297
4433
 
4298
4434
  // src/data-table/data-table.tsx
4299
- import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
4435
+ import { Fragment as Fragment7, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
4300
4436
  var DEFAULT_PAGE_SIZE = 20;
4301
4437
  function DataTable({
4302
4438
  id,
@@ -4347,23 +4483,24 @@ function DataTable({
4347
4483
  initialColumnSizing,
4348
4484
  onColumnSizingPersist,
4349
4485
  stickyHeader = false,
4350
- celFilterConfig
4486
+ celFilterConfig,
4487
+ filterVisibility
4351
4488
  }) {
4352
4489
  var _a, _b, _c, _d, _e, _f;
4353
4490
  const isGrid = layout === "grid";
4354
- const tableBodyScrollRef = React8.useRef(null);
4355
- const [innerGlobalFilter, setInnerGlobalFilter] = React8.useState("");
4356
- const [innerColumnOrdering, setInnerColumnOrdering] = React8.useState([]);
4357
- const [innerColumnFilters, setInnerColumnFilters] = React8.useState([]);
4358
- const [innerSorting, setInnerSorting] = React8.useState(((_a = config.state) == null ? void 0 : _a.sorting) || []);
4359
- const [innerColumnPinning, setInnerColumnPinning] = React8.useState({ left: [], right: [] });
4360
- const [innerPagination, setInnerPagination] = React8.useState({
4491
+ const tableBodyScrollRef = React9.useRef(null);
4492
+ const [innerGlobalFilter, setInnerGlobalFilter] = React9.useState("");
4493
+ const [innerColumnOrdering, setInnerColumnOrdering] = React9.useState([]);
4494
+ const [innerColumnFilters, setInnerColumnFilters] = React9.useState([]);
4495
+ const [innerSorting, setInnerSorting] = React9.useState(((_a = config.state) == null ? void 0 : _a.sorting) || []);
4496
+ const [innerColumnPinning, setInnerColumnPinning] = React9.useState({ left: [], right: [] });
4497
+ const [innerPagination, setInnerPagination] = React9.useState({
4361
4498
  pageIndex: ((_c = (_b = config.state) == null ? void 0 : _b.pagination) == null ? void 0 : _c.pageIndex) || 0,
4362
4499
  pageSize: ((_e = (_d = config.state) == null ? void 0 : _d.pagination) == null ? void 0 : _e.pageSize) || DEFAULT_PAGE_SIZE
4363
4500
  });
4364
- const [innerGrouping, setInnerGrouping] = React8.useState([]);
4365
- const [innerColumnVisibility, setInnerColumnVisibility] = React8.useState({});
4366
- const [innerExpanded, setInnerExpanded] = React8.useState({});
4501
+ const [innerGrouping, setInnerGrouping] = React9.useState([]);
4502
+ const [innerColumnVisibility, setInnerColumnVisibility] = React9.useState({});
4503
+ const [innerExpanded, setInnerExpanded] = React9.useState({});
4367
4504
  const {
4368
4505
  columnSizing,
4369
4506
  handleColumnSizingChange,
@@ -4375,6 +4512,11 @@ function DataTable({
4375
4512
  onColumnSizingPersist,
4376
4513
  maxSize: isGrid ? RESIZE_MAX_UNBOUNDED : void 0
4377
4514
  });
4515
+ const {
4516
+ showFilterToggle: filterToggleRequested,
4517
+ filterRowVisible,
4518
+ setFilterRowVisible
4519
+ } = useFilterVisibility(filterVisibility);
4378
4520
  const globalFilter = parentGlobalFilter != null ? parentGlobalFilter : innerGlobalFilter;
4379
4521
  const applyGlobalFilter = parentSetGlobalFilter != null ? parentSetGlobalFilter : setInnerGlobalFilter;
4380
4522
  const columnFilters = parentColumnFilters || innerColumnFilters;
@@ -4382,25 +4524,25 @@ function DataTable({
4382
4524
  const pagination = parentPagination || innerPagination;
4383
4525
  const setPagination = parentSetPagination != null ? parentSetPagination : setInnerPagination;
4384
4526
  const shouldDisablePagination = paginationConfig === false;
4385
- const resetPageIndexOnFilterChange = React8.useCallback(() => {
4527
+ const resetPageIndexOnFilterChange = React9.useCallback(() => {
4386
4528
  if (!serverSidePagination || pagination.pageIndex === 0) return;
4387
4529
  setPagination((prev) => __spreadProps(__spreadValues({}, prev), { pageIndex: 0 }));
4388
4530
  }, [serverSidePagination, pagination.pageIndex, setPagination]);
4389
- const setGlobalFilter = React8.useCallback(
4531
+ const setGlobalFilter = React9.useCallback(
4390
4532
  (value) => {
4391
4533
  applyGlobalFilter(value);
4392
4534
  resetPageIndexOnFilterChange();
4393
4535
  },
4394
4536
  [applyGlobalFilter, resetPageIndexOnFilterChange]
4395
4537
  );
4396
- const setColumnFilters = React8.useCallback(
4538
+ const setColumnFilters = React9.useCallback(
4397
4539
  (value) => {
4398
4540
  applyColumnFilters(value);
4399
4541
  resetPageIndexOnFilterChange();
4400
4542
  },
4401
4543
  [applyColumnFilters, resetPageIndexOnFilterChange]
4402
4544
  );
4403
- React8.useLayoutEffect(() => {
4545
+ React9.useLayoutEffect(() => {
4404
4546
  var _a2;
4405
4547
  if (shouldDisablePagination) return;
4406
4548
  (_a2 = tableBodyScrollRef.current) == null ? void 0 : _a2.scrollTo({ top: 0 });
@@ -4482,7 +4624,9 @@ function DataTable({
4482
4624
  const flatColumns = table.getAllFlatColumns();
4483
4625
  const displayableColumns = flatColumns.filter((col) => !isFilterOnlyColumn(col));
4484
4626
  const orderedVisibleColumns = table.getVisibleLeafColumns().filter((col) => !isFilterOnlyColumn(col));
4485
- const [gridMeasuredMins, setGridMeasuredMins] = React8.useState({});
4627
+ const hasFilters = !!celFilterConfig || hasFilterableColumns(flatColumns);
4628
+ const showFilterToggle = filterToggleRequested && !disableFilters && hasFilters;
4629
+ const [gridMeasuredMins, setGridMeasuredMins] = React9.useState({});
4486
4630
  const { gridTemplateColumns, gridRootRef, handleAutosizeAll, handleAutosizeColumn, handleResetColumnSize } = useGridLayout({
4487
4631
  layout,
4488
4632
  table,
@@ -4496,7 +4640,7 @@ function DataTable({
4496
4640
  rawHandleAutosizeColumn,
4497
4641
  rawHandleResetColumnSize
4498
4642
  });
4499
- const handleContextCell = React8.useCallback(
4643
+ const handleContextCell = React9.useCallback(
4500
4644
  (filter, cell) => {
4501
4645
  var _a2, _b2;
4502
4646
  if (celFilterConfig == null ? void 0 : celFilterConfig.onContextualFilter) {
@@ -4513,13 +4657,13 @@ function DataTable({
4513
4657
  },
4514
4658
  [celFilterConfig, onContextCell, setColumnFilters, table]
4515
4659
  );
4516
- const handleContextSearch = React8.useCallback(
4660
+ const handleContextSearch = React9.useCallback(
4517
4661
  (searchTerm) => {
4518
4662
  setGlobalFilter(searchTerm);
4519
4663
  },
4520
4664
  [setGlobalFilter]
4521
4665
  );
4522
- const totalTableWidth = React8.useMemo(() => {
4666
+ const totalTableWidth = React9.useMemo(() => {
4523
4667
  if (isGrid) return 0;
4524
4668
  const firstGroup = headerGroups[0];
4525
4669
  if (!firstGroup) return 0;
@@ -4543,12 +4687,12 @@ function DataTable({
4543
4687
  }
4544
4688
  setGlobalFilter("");
4545
4689
  };
4546
- React8.useEffect(() => {
4690
+ React9.useEffect(() => {
4547
4691
  if (parentGlobalFilter !== void 0) {
4548
4692
  setInnerGlobalFilter(parentGlobalFilter);
4549
4693
  }
4550
4694
  }, [parentGlobalFilter]);
4551
- React8.useEffect(() => {
4695
+ React9.useEffect(() => {
4552
4696
  if (disableColumnReordering) return;
4553
4697
  const allColumnIds = flatColumns.map((col) => col.id);
4554
4698
  const normalizedColumnOrdering = normalizeColumnOrdering(columnOrdering, allColumnIds);
@@ -4558,9 +4702,9 @@ function DataTable({
4558
4702
  }, [columnOrdering, disableColumnReordering, flatColumns, setColumnOrdering]);
4559
4703
  const showViewHeader = !!title || !!Actions;
4560
4704
  const showColumnOptions = !disableColumnReordering || !disableColumnVisibility;
4561
- const toolbarSearch = !disableSearch && /* @__PURE__ */ jsxs9(InputGroup2, { className: "w-70", children: [
4562
- /* @__PURE__ */ jsx12(InputGroupAddon2, { align: "inline-start", children: /* @__PURE__ */ jsx12(Icon8, { name: "magnifying-glass" }) }),
4563
- /* @__PURE__ */ jsx12(
4705
+ const toolbarSearch = !disableSearch && /* @__PURE__ */ jsxs10(InputGroup2, { className: "w-70", children: [
4706
+ /* @__PURE__ */ jsx13(InputGroupAddon2, { align: "inline-start", children: /* @__PURE__ */ jsx13(Icon9, { name: "magnifying-glass" }) }),
4707
+ /* @__PURE__ */ jsx13(
4564
4708
  InputGroupInput2,
4565
4709
  {
4566
4710
  "aria-label": "Search",
@@ -4571,7 +4715,7 @@ function DataTable({
4571
4715
  }
4572
4716
  )
4573
4717
  ] });
4574
- const toolbarColumns = !!showColumnOptions && /* @__PURE__ */ jsx12(
4718
+ const toolbarColumns = !!showColumnOptions && /* @__PURE__ */ jsx13(
4575
4719
  ColumnOptions,
4576
4720
  {
4577
4721
  columns: flatColumns,
@@ -4580,7 +4724,7 @@ function DataTable({
4580
4724
  disableColumnOrdering: disableColumnReordering
4581
4725
  }
4582
4726
  );
4583
- return /* @__PURE__ */ jsxs9(
4727
+ return /* @__PURE__ */ jsxs10(
4584
4728
  "div",
4585
4729
  {
4586
4730
  id: `table-${id}`,
@@ -4591,18 +4735,19 @@ function DataTable({
4591
4735
  className
4592
4736
  ),
4593
4737
  children: [
4594
- showViewHeader && /* @__PURE__ */ jsx12(SectionHeader, { className: "mb-4 flex w-full gap-2", children: /* @__PURE__ */ jsxs9(SectionHeaderContent, { children: [
4595
- !!title && /* @__PURE__ */ jsx12(SectionHeaderTitle, { children: title }),
4596
- !!description && /* @__PURE__ */ jsx12(SectionHeaderDescription, { children: description })
4738
+ showViewHeader && /* @__PURE__ */ jsx13(SectionHeader, { className: "mb-4 flex w-full gap-2", children: /* @__PURE__ */ jsxs10(SectionHeaderContent, { children: [
4739
+ !!title && /* @__PURE__ */ jsx13(SectionHeaderTitle, { children: title }),
4740
+ !!description && /* @__PURE__ */ jsx13(SectionHeaderDescription, { children: description })
4597
4741
  ] }) }),
4598
- /* @__PURE__ */ jsxs9("div", { className: "mb-4 flex flex-row gap-2", children: [
4742
+ /* @__PURE__ */ jsxs10("div", { className: "mb-4 flex flex-row gap-2", children: [
4599
4743
  toolbarSearch,
4600
- /* @__PURE__ */ jsxs9("div", { className: "ml-auto flex items-center gap-2", children: [
4601
- !!Actions && /* @__PURE__ */ jsx12(Actions, { state: tableState }),
4744
+ /* @__PURE__ */ jsxs10("div", { className: "ml-auto flex items-center gap-2", children: [
4745
+ showFilterToggle && /* @__PURE__ */ jsx13(FilterToggle, { pressed: filterRowVisible, onPressedChange: setFilterRowVisible, count: filterCount }),
4746
+ !!Actions && /* @__PURE__ */ jsx13(Actions, { state: tableState }),
4602
4747
  toolbarColumns
4603
4748
  ] })
4604
4749
  ] }),
4605
- !disableFilters && /* @__PURE__ */ jsx12("div", { className: "flex w-full", children: celFilterConfig ? /* @__PURE__ */ jsx12("div", { className: cn("mr-2 mb-4 min-w-0 flex-1", celFilterClassName), children: /* @__PURE__ */ jsx12(
4750
+ !disableFilters && (!showFilterToggle || filterRowVisible) && /* @__PURE__ */ jsx13("div", { className: "flex w-full", children: celFilterConfig ? /* @__PURE__ */ jsx13("div", { className: cn("mr-2 mb-4 min-w-0 flex-1", celFilterClassName), children: /* @__PURE__ */ jsx13(
4606
4751
  CelFilterBar,
4607
4752
  {
4608
4753
  schema: celFilterConfig.schema,
@@ -4612,7 +4757,7 @@ function DataTable({
4612
4757
  onRestrictedOptionSelect: celFilterConfig.onRestrictedOptionSelect,
4613
4758
  showClearButton: celFilterConfig.showClearButton
4614
4759
  }
4615
- ) }) : /* @__PURE__ */ jsx12(
4760
+ ) }) : /* @__PURE__ */ jsx13(
4616
4761
  ViewFilter,
4617
4762
  {
4618
4763
  columns: flatColumns,
@@ -4621,8 +4766,8 @@ function DataTable({
4621
4766
  className: "data-[visible-filters=true]:mb-4"
4622
4767
  }
4623
4768
  ) }),
4624
- shouldRenderTableContent ? /* @__PURE__ */ jsxs9(Fragment7, { children: [
4625
- /* @__PURE__ */ jsx12("div", { className: "flex min-h-0 flex-1 flex-col", "data-testid": "table-main", children: /* @__PURE__ */ jsx12(
4769
+ shouldRenderTableContent ? /* @__PURE__ */ jsxs10(Fragment7, { children: [
4770
+ /* @__PURE__ */ jsx13("div", { className: "flex min-h-0 flex-1 flex-col", "data-testid": "table-main", children: /* @__PURE__ */ jsx13(
4626
4771
  "div",
4627
4772
  {
4628
4773
  ref: tableBodyScrollRef,
@@ -4630,7 +4775,7 @@ function DataTable({
4630
4775
  "min-h-0 flex-1 overflow-auto rounded-lg border **:data-[slot=table-container]:overflow-visible",
4631
4776
  !!stickyHeader && "max-h-[calc(100svh-250px)]"
4632
4777
  ),
4633
- children: /* @__PURE__ */ jsxs9(
4778
+ children: /* @__PURE__ */ jsxs10(
4634
4779
  DataTableRoot,
4635
4780
  {
4636
4781
  layout,
@@ -4638,7 +4783,7 @@ function DataTable({
4638
4783
  gridRootRef,
4639
4784
  style: isGrid ? { width: "100%" } : totalTableWidth > 0 ? { width: `max(100%, ${totalTableWidth}px)`, minWidth: "100%" } : { width: "100%" },
4640
4785
  children: [
4641
- /* @__PURE__ */ jsx12(
4786
+ /* @__PURE__ */ jsx13(
4642
4787
  DataTableHeader,
4643
4788
  {
4644
4789
  headerGroups,
@@ -4649,7 +4794,7 @@ function DataTable({
4649
4794
  layout
4650
4795
  }
4651
4796
  ),
4652
- /* @__PURE__ */ jsx12(
4797
+ /* @__PURE__ */ jsx13(
4653
4798
  DataTableBody,
4654
4799
  {
4655
4800
  tableRows,
@@ -4671,7 +4816,7 @@ function DataTable({
4671
4816
  )
4672
4817
  }
4673
4818
  ) }),
4674
- !shouldDisablePagination && !!pagination && /* @__PURE__ */ jsx12(
4819
+ !shouldDisablePagination && !!pagination && /* @__PURE__ */ jsx13(
4675
4820
  DataTablePagination,
4676
4821
  {
4677
4822
  rowCount,
@@ -4683,7 +4828,7 @@ function DataTable({
4683
4828
  onPageSizeChange: (nextPageSize) => setPagination((prev) => __spreadProps(__spreadValues({}, prev || pagination), { pageIndex: 0, pageSize: nextPageSize }))
4684
4829
  }
4685
4830
  )
4686
- ] }) : /* @__PURE__ */ jsx12(
4831
+ ] }) : /* @__PURE__ */ jsx13(
4687
4832
  DataTableEmptyView,
4688
4833
  {
4689
4834
  emptyView,