@dimaan/ui 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { forwardRef, Children, isValidElement, cloneElement, createContext, useR
3
3
  import { clsx } from 'clsx';
4
4
  import { twMerge } from 'tailwind-merge';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import { Loader2, Check, Minus, Calendar, X, ChevronLeft, ChevronRight, ChevronDown, ChevronUp, ArrowLeft, Menu, FileQuestion, ChevronsUpDown, Search, RefreshCw, Inbox, SearchX } from 'lucide-react';
6
+ import { Loader2, Check, Minus, Calendar, X, ChevronLeft, ChevronRight, Upload, File as File$1, ChevronDown, Search, ChevronUp, ArrowLeft, Menu, FileQuestion, ChevronsUpDown, Inbox, RefreshCw, SearchX } from 'lucide-react';
7
7
  import { DirectionProvider } from '@radix-ui/react-direction';
8
8
  import { Link, useLocation, useResolvedPath, useNavigate } from 'react-router-dom';
9
9
  import * as RadixPopover from '@radix-ui/react-popover';
@@ -271,7 +271,9 @@ function DashboardContent({ className, children, ...props }) {
271
271
  "main",
272
272
  {
273
273
  className: cn(
274
- "flex min-h-[calc(100vh-var(--header-height))] flex-1 flex-col gap-6 p-4 sm:p-6 lg:p-8",
274
+ // `min-w-0` keeps wide children (Table, code blocks) scrolling within
275
+ // this column instead of widening the page past 100%.
276
+ "flex min-h-[calc(100vh-var(--header-height))] min-w-0 flex-1 flex-col gap-6 p-4 sm:p-6 lg:p-8",
275
277
  className
276
278
  ),
277
279
  ...props,
@@ -337,7 +339,10 @@ function DashboardMain({ className, children, ...props }) {
337
339
  "div",
338
340
  {
339
341
  className: cn(
340
- "flex min-h-screen flex-1 flex-col transition-[margin] duration-200 ease-out",
342
+ // `min-w-0` lets this flex column shrink below its content's intrinsic
343
+ // width so wide children (e.g. a Table) scroll internally instead of
344
+ // stretching the whole layout past 100%.
345
+ "flex min-h-screen min-w-0 flex-1 flex-col transition-[margin] duration-200 ease-out",
341
346
  // On desktop, push the main column past the fixed sidebar using logical margin.
342
347
  collapsed ? "lg:ms-[var(--sidebar-width-collapsed)]" : "lg:ms-[var(--sidebar-width)]",
343
348
  className
@@ -1347,15 +1352,20 @@ var detailPageBaseClass = "flex w-full flex-col gap-6";
1347
1352
  var detailPageBodyClass = "flex flex-col gap-6";
1348
1353
  var detailPageSkeletonRowClass = "h-5 w-full animate-pulse rounded-md bg-muted";
1349
1354
  var detailPageEmptyClass = "rounded-md border border-border bg-card";
1350
- var DEFAULT_LABELS = {
1355
+ var DEFAULT_LABELS_LTR = {
1356
+ back: "Back",
1351
1357
  notFoundTitle: "Not found",
1352
1358
  notFoundDescription: "The record you\u2019re looking for does not exist or has been removed."
1353
1359
  };
1360
+ var DEFAULT_LABELS_RTL = {
1361
+ back: "\u0631\u062C\u0648\u0639",
1362
+ notFoundTitle: "\u063A\u064A\u0631 \u0645\u0648\u062C\u0648\u062F",
1363
+ notFoundDescription: "\u0627\u0644\u0633\u062C\u0644 \u0627\u0644\u0630\u064A \u062A\u0628\u062D\u062B \u0639\u0646\u0647 \u063A\u064A\u0631 \u0645\u0648\u062C\u0648\u062F \u0623\u0648 \u062A\u0645 \u062D\u0630\u0641\u0647."
1364
+ };
1354
1365
  var DEFAULT_SKELETON_ROW_COUNT = 6;
1355
1366
  function DetailPage({
1356
1367
  title,
1357
1368
  description,
1358
- back,
1359
1369
  actions,
1360
1370
  bordered = true,
1361
1371
  isLoading = false,
@@ -1367,7 +1377,10 @@ function DetailPage({
1367
1377
  className,
1368
1378
  bodyClassName
1369
1379
  }) {
1370
- const labels = { ...DEFAULT_LABELS, ...labelsProp };
1380
+ const navigate = useNavigate();
1381
+ const dir = useDirection();
1382
+ const defaults = dir === "rtl" ? DEFAULT_LABELS_RTL : DEFAULT_LABELS_LTR;
1383
+ const labels = { ...defaults, ...labelsProp };
1371
1384
  return /* @__PURE__ */ jsxs(
1372
1385
  "div",
1373
1386
  {
@@ -1381,7 +1394,7 @@ function DetailPage({
1381
1394
  {
1382
1395
  title,
1383
1396
  description,
1384
- back,
1397
+ back: { label: labels.back, onClick: () => navigate(-1) },
1385
1398
  actions,
1386
1399
  bordered
1387
1400
  }
@@ -1689,19 +1702,231 @@ function mergeRefs(...refs) {
1689
1702
  };
1690
1703
  }
1691
1704
 
1705
+ // src/components/file-upload/fileUploadVariants.ts
1706
+ var fileUploadBaseClass = "flex w-full min-w-0 flex-col gap-2";
1707
+ var fileUploadDropzoneClass = "flex cursor-pointer flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-input bg-muted/40 px-6 py-8 text-center transition-colors hover:border-ring peer-focus-visible:border-ring peer-focus-visible:ring-2 peer-focus-visible:ring-ring/40 data-[drag-active=true]:border-ring data-[drag-active=true]:bg-accent data-[invalid=true]:border-destructive data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50 data-[disabled=true]:hover:border-input";
1708
+ var fileUploadIconClass = "size-8 text-muted-foreground";
1709
+ var fileUploadPromptClass = "text-sm text-foreground";
1710
+ var fileUploadHintClass = "text-xs text-muted-foreground";
1711
+ var fileUploadFileRowClass = "flex items-center justify-between gap-2 rounded-md border border-border bg-card px-3 py-2";
1712
+ var fileUploadFileNameClass = "truncate text-sm font-medium text-foreground";
1713
+ var fileUploadFileSizeClass = "text-xs text-muted-foreground";
1714
+ var fileUploadRemoveClass = "inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:pointer-events-none disabled:opacity-50";
1715
+ var DEFAULT_MAX_SIZE_MB = 5;
1716
+ var DEFAULT_LABELS_LTR2 = {
1717
+ prompt: "Drag & drop a file or click to browse",
1718
+ remove: "Remove"
1719
+ };
1720
+ var DEFAULT_LABELS_RTL2 = {
1721
+ prompt: "\u0627\u0633\u062D\u0628 \u0648\u0623\u0641\u0644\u062A \u0645\u0644\u0641\u064B\u0627 \u0623\u0648 \u0627\u0636\u063A\u0637 \u0644\u0644\u0627\u062E\u062A\u064A\u0627\u0631",
1722
+ remove: "\u0625\u0632\u0627\u0644\u0629"
1723
+ };
1724
+ function normalizeFiles(value) {
1725
+ if (Array.isArray(value)) return value.filter((f) => f instanceof File);
1726
+ return value instanceof File ? [value] : [];
1727
+ }
1728
+ function fileKey(file) {
1729
+ return `${file.name}:${file.size}:${file.lastModified}`;
1730
+ }
1731
+ function formatBytes(bytes) {
1732
+ if (bytes < 1024) return `${bytes} B`;
1733
+ const kb = bytes / 1024;
1734
+ if (kb < 1024) return `${kb.toFixed(1)} KB`;
1735
+ return `${(kb / 1024).toFixed(1)} MB`;
1736
+ }
1737
+ function matchesAccept(file, accept) {
1738
+ if (!accept) return true;
1739
+ const tokens = accept.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
1740
+ if (tokens.length === 0 || tokens.includes("*") || tokens.includes("*/*")) return true;
1741
+ const name = file.name.toLowerCase();
1742
+ const type = file.type.toLowerCase();
1743
+ return tokens.some((token) => {
1744
+ if (token.startsWith(".")) return name.endsWith(token);
1745
+ if (token.endsWith("/*")) return type.startsWith(token.slice(0, -1));
1746
+ return type === token;
1747
+ });
1748
+ }
1749
+ var FileUploadImpl = forwardRef(
1750
+ function FileUpload(props, ref) {
1751
+ const {
1752
+ multiple = false,
1753
+ accept,
1754
+ maxSize = DEFAULT_MAX_SIZE_MB,
1755
+ disabled = false,
1756
+ required,
1757
+ name,
1758
+ id,
1759
+ onError,
1760
+ onBlur,
1761
+ labels: labelsProp,
1762
+ className,
1763
+ value,
1764
+ defaultValue,
1765
+ onValueChange,
1766
+ onChange,
1767
+ "aria-invalid": ariaInvalid,
1768
+ "aria-describedby": ariaDescribedBy,
1769
+ "aria-label": ariaLabel
1770
+ } = props;
1771
+ const dir = useDirection();
1772
+ const generatedId = useId();
1773
+ const inputId = id ?? generatedId;
1774
+ const [dragActive, setDragActive] = useState(false);
1775
+ const baseLabels = dir === "rtl" ? DEFAULT_LABELS_RTL2 : DEFAULT_LABELS_LTR2;
1776
+ const prompt = labelsProp?.prompt ?? baseLabels.prompt;
1777
+ const removeLabel = labelsProp?.remove ?? baseLabels.remove;
1778
+ const hint = labelsProp?.hint ?? (dir === "rtl" ? `\u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 ${maxSize} \u0645\u064A\u062C\u0627\u0628\u0627\u064A\u062A` : `Max ${maxSize} MB`);
1779
+ const isControlled = value !== void 0;
1780
+ const [internal, setInternal] = useState(() => normalizeFiles(defaultValue));
1781
+ const files = isControlled ? normalizeFiles(value) : internal;
1782
+ const invalid = ariaInvalid === true || ariaInvalid === "true";
1783
+ const emit = (next) => {
1784
+ if (!isControlled) setInternal(next);
1785
+ onValueChange?.(multiple ? next : next[0] ?? null);
1786
+ onChange?.(multiple ? next : next[0] ?? null);
1787
+ };
1788
+ const tooLargeMessage = (file) => dir === "rtl" ? `${file.name} \u0623\u0643\u0628\u0631 \u0645\u0646 ${maxSize} \u0645\u064A\u062C\u0627\u0628\u0627\u064A\u062A` : `${file.name} is larger than ${maxSize} MB`;
1789
+ const wrongTypeMessage = (file) => dir === "rtl" ? `${file.name} \u0644\u064A\u0633 \u0646\u0648\u0639 \u0645\u0644\u0641 \u0645\u0642\u0628\u0648\u0644` : `${file.name} is not an accepted file type`;
1790
+ const addFiles = (incoming) => {
1791
+ if (disabled) return;
1792
+ const accepted = [];
1793
+ for (const file of Array.from(incoming)) {
1794
+ if (!matchesAccept(file, accept)) {
1795
+ onError?.({ code: "file-type-rejected", message: wrongTypeMessage(file), file });
1796
+ continue;
1797
+ }
1798
+ if (maxSize && file.size > maxSize * 1024 * 1024) {
1799
+ onError?.({ code: "file-too-large", message: tooLargeMessage(file), file });
1800
+ continue;
1801
+ }
1802
+ accepted.push(file);
1803
+ }
1804
+ if (accepted.length === 0) return;
1805
+ if (!multiple) {
1806
+ const [first] = accepted;
1807
+ if (first) emit([first]);
1808
+ return;
1809
+ }
1810
+ const byKey = new Map(files.map((f) => [fileKey(f), f]));
1811
+ for (const f of accepted) byKey.set(fileKey(f), f);
1812
+ emit([...byKey.values()]);
1813
+ };
1814
+ const handleInputChange = (event) => {
1815
+ if (event.target.files) addFiles(event.target.files);
1816
+ event.target.value = "";
1817
+ };
1818
+ const handleDrag = (event) => {
1819
+ event.preventDefault();
1820
+ event.stopPropagation();
1821
+ if (disabled) return;
1822
+ if (event.type === "dragenter" || event.type === "dragover") setDragActive(true);
1823
+ else if (event.type === "dragleave") setDragActive(false);
1824
+ };
1825
+ const handleDrop = (event) => {
1826
+ event.preventDefault();
1827
+ event.stopPropagation();
1828
+ setDragActive(false);
1829
+ if (!disabled && event.dataTransfer.files) addFiles(event.dataTransfer.files);
1830
+ };
1831
+ const remove = (file) => emit(files.filter((f) => fileKey(f) !== fileKey(file)));
1832
+ const showDropzone = multiple || files.length === 0;
1833
+ return (
1834
+ // biome-ignore lint/a11y/noStaticElementInteractions: drag-and-drop is a wrapper affordance; keyboard/click access is the inner <label> + focusable <input>.
1835
+ /* @__PURE__ */ jsxs(
1836
+ "div",
1837
+ {
1838
+ ref,
1839
+ "data-slot": "file-upload",
1840
+ className: cn(fileUploadBaseClass, className),
1841
+ onDragEnter: handleDrag,
1842
+ onDragOver: handleDrag,
1843
+ onDragLeave: handleDrag,
1844
+ onDrop: handleDrop,
1845
+ children: [
1846
+ /* @__PURE__ */ jsx(
1847
+ "input",
1848
+ {
1849
+ id: inputId,
1850
+ type: "file",
1851
+ accept,
1852
+ multiple,
1853
+ name,
1854
+ required,
1855
+ disabled,
1856
+ onChange: handleInputChange,
1857
+ onBlur,
1858
+ "aria-invalid": ariaInvalid,
1859
+ "aria-describedby": ariaDescribedBy,
1860
+ "aria-label": ariaLabel,
1861
+ className: "peer sr-only"
1862
+ }
1863
+ ),
1864
+ showDropzone ? /* @__PURE__ */ jsxs(
1865
+ "label",
1866
+ {
1867
+ htmlFor: inputId,
1868
+ "data-slot": "file-upload-dropzone",
1869
+ "data-drag-active": dragActive ? "true" : void 0,
1870
+ "data-invalid": invalid ? "true" : void 0,
1871
+ "data-disabled": disabled ? "true" : void 0,
1872
+ className: fileUploadDropzoneClass,
1873
+ children: [
1874
+ /* @__PURE__ */ jsx(Upload, { "aria-hidden": "true", className: fileUploadIconClass }),
1875
+ /* @__PURE__ */ jsx("span", { className: fileUploadPromptClass, children: prompt }),
1876
+ /* @__PURE__ */ jsx("span", { className: fileUploadHintClass, children: hint })
1877
+ ]
1878
+ }
1879
+ ) : null,
1880
+ files.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-2", children: files.map((file) => /* @__PURE__ */ jsxs(
1881
+ "li",
1882
+ {
1883
+ "data-slot": "file-upload-file",
1884
+ className: fileUploadFileRowClass,
1885
+ children: [
1886
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
1887
+ /* @__PURE__ */ jsx(File$1, { "aria-hidden": "true", className: "size-5 shrink-0 text-muted-foreground" }),
1888
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1889
+ /* @__PURE__ */ jsx("p", { className: fileUploadFileNameClass, children: file.name }),
1890
+ /* @__PURE__ */ jsx("p", { className: fileUploadFileSizeClass, children: formatBytes(file.size) })
1891
+ ] })
1892
+ ] }),
1893
+ /* @__PURE__ */ jsx(
1894
+ "button",
1895
+ {
1896
+ type: "button",
1897
+ disabled,
1898
+ "aria-label": `${removeLabel}: ${file.name}`,
1899
+ "data-slot": "file-upload-remove",
1900
+ className: fileUploadRemoveClass,
1901
+ onClick: () => remove(file),
1902
+ children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "size-4" })
1903
+ }
1904
+ )
1905
+ ]
1906
+ },
1907
+ fileKey(file)
1908
+ )) }) : null
1909
+ ]
1910
+ }
1911
+ )
1912
+ );
1913
+ }
1914
+ );
1915
+ var FileUpload2 = FileUploadImpl;
1916
+
1692
1917
  // src/components/form-page/formPageVariants.ts
1693
1918
  var formPageBaseClass = "flex w-full flex-col gap-6";
1694
1919
  var formPageBodyClass = "flex-1";
1695
1920
  var formPageActionsBarClass = "sticky bottom-0 -mx-6 -mb-6 mt-6 flex items-center justify-end gap-2 border-t border-border bg-background/95 px-6 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/80";
1696
1921
  var formPageSkeletonRowClass = "h-10 w-full animate-pulse rounded-md bg-muted";
1697
1922
  var DEFAULT_SKELETON_ROW_COUNT2 = 6;
1698
- var DEFAULT_LABELS_LTR = {
1923
+ var DEFAULT_LABELS_LTR3 = {
1699
1924
  back: "Back",
1700
1925
  cancel: "Cancel",
1701
1926
  save: "Save",
1702
1927
  saving: "Saving\u2026"
1703
1928
  };
1704
- var DEFAULT_LABELS_RTL = {
1929
+ var DEFAULT_LABELS_RTL3 = {
1705
1930
  back: "\u0631\u062C\u0648\u0639",
1706
1931
  cancel: "\u0625\u0644\u063A\u0627\u0621",
1707
1932
  save: "\u062D\u0641\u0638",
@@ -1728,7 +1953,7 @@ function FormPage({
1728
1953
  const dir = useDirection();
1729
1954
  const formContext = useFormContext();
1730
1955
  const submitting = isSubmitting ?? formContext?.formState?.isSubmitting ?? false;
1731
- const defaults = dir === "rtl" ? DEFAULT_LABELS_RTL : DEFAULT_LABELS_LTR;
1956
+ const defaults = dir === "rtl" ? DEFAULT_LABELS_RTL3 : DEFAULT_LABELS_LTR3;
1732
1957
  const labels = { ...defaults, ...labelsProp };
1733
1958
  const goBack = () => navigate(-1);
1734
1959
  return /* @__PURE__ */ jsxs("div", { "data-slot": "form-page", className: cn(formPageBaseClass, className), children: [
@@ -1896,132 +2121,6 @@ function LanguageSwitcher({
1896
2121
  }
1897
2122
  );
1898
2123
  }
1899
-
1900
- // src/components/select/selectVariants.ts
1901
- var selectVariantClass = {
1902
- default: "border border-input bg-background hover:border-ring",
1903
- filled: "border border-transparent bg-muted hover:bg-muted/80",
1904
- ghost: "border border-transparent bg-transparent hover:bg-accent"
1905
- };
1906
- var selectSizeClass = {
1907
- sm: "h-8 rounded-md ps-2.5 pe-8 text-sm",
1908
- md: "h-9 rounded-md ps-3 pe-9 text-sm",
1909
- lg: "h-11 rounded-md ps-4 pe-10 text-base"
1910
- };
1911
- var selectBaseClass = "group/select relative inline-flex w-full items-center text-foreground outline-none transition-[background-color,border-color,box-shadow] focus:ring-2 focus:ring-ring/40 focus:ring-offset-1 focus:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus:ring-destructive/40 disabled:pointer-events-none disabled:opacity-50 cursor-pointer data-[placeholder]:text-muted-foreground";
1912
- var selectContentClass = "z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95";
1913
- var selectViewportClass = "p-1";
1914
- var selectItemClass = "relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 ps-8 pe-2 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
1915
- var selectItemIndicatorClass = "absolute start-2 inline-flex h-3.5 w-3.5 items-center justify-center [&_svg]:h-3.5 [&_svg]:w-3.5";
1916
- var selectGroupLabelClass = "px-2 py-1.5 text-xs font-semibold text-muted-foreground";
1917
- var selectSeparatorClass = "-mx-1 my-1 h-px bg-border";
1918
- function isGroupedOptions(options) {
1919
- const first = options[0];
1920
- return first !== void 0 && "options" in first;
1921
- }
1922
- var Select = forwardRef(function Select2({
1923
- variant = "default",
1924
- selectSize = "md",
1925
- options,
1926
- placeholder,
1927
- value,
1928
- defaultValue,
1929
- onValueChange,
1930
- onChange,
1931
- onBlur,
1932
- name,
1933
- disabled,
1934
- required,
1935
- id,
1936
- className,
1937
- "aria-invalid": ariaInvalid,
1938
- "aria-describedby": ariaDescribedBy,
1939
- "aria-label": ariaLabel,
1940
- children
1941
- }, ref) {
1942
- const generatedId = useId();
1943
- const triggerId = id ?? generatedId;
1944
- const handleValueChange = useCallback(
1945
- (next) => {
1946
- onValueChange?.(next);
1947
- if (onChange) {
1948
- const synthetic = {
1949
- target: { value: next, name },
1950
- currentTarget: { value: next, name },
1951
- type: "change"
1952
- };
1953
- onChange(synthetic);
1954
- }
1955
- },
1956
- [onValueChange, onChange, name]
1957
- );
1958
- return /* @__PURE__ */ jsxs(
1959
- RadixSelect.Root,
1960
- {
1961
- value,
1962
- defaultValue,
1963
- onValueChange: handleValueChange,
1964
- disabled,
1965
- required,
1966
- name,
1967
- children: [
1968
- /* @__PURE__ */ jsxs(
1969
- RadixSelect.Trigger,
1970
- {
1971
- ref,
1972
- id: triggerId,
1973
- "aria-label": ariaLabel,
1974
- "aria-invalid": ariaInvalid,
1975
- "aria-describedby": ariaDescribedBy,
1976
- onBlur,
1977
- "data-slot": "select-trigger",
1978
- className: cn(
1979
- selectBaseClass,
1980
- selectVariantClass[variant],
1981
- selectSizeClass[selectSize],
1982
- className
1983
- ),
1984
- children: [
1985
- /* @__PURE__ */ jsx(RadixSelect.Value, { placeholder }),
1986
- /* @__PURE__ */ jsx(RadixSelect.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "pointer-events-none absolute end-3 top-1/2 size-4 shrink-0 -translate-y-1/2 text-muted-foreground" }) })
1987
- ]
1988
- }
1989
- ),
1990
- /* @__PURE__ */ jsx(RadixSelect.Portal, { children: /* @__PURE__ */ jsxs(
1991
- RadixSelect.Content,
1992
- {
1993
- position: "popper",
1994
- sideOffset: 4,
1995
- "data-slot": "select-content",
1996
- className: selectContentClass,
1997
- children: [
1998
- /* @__PURE__ */ jsx(RadixSelect.ScrollUpButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-4" }) }),
1999
- /* @__PURE__ */ jsx(RadixSelect.Viewport, { className: selectViewportClass, children: children ?? (options ? renderOptions(options) : null) }),
2000
- /* @__PURE__ */ jsx(RadixSelect.ScrollDownButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" }) })
2001
- ]
2002
- }
2003
- ) })
2004
- ]
2005
- }
2006
- );
2007
- });
2008
- function renderOptions(options) {
2009
- if (isGroupedOptions(options)) {
2010
- const lastIndex = options.length - 1;
2011
- return options.map((group, idx) => /* @__PURE__ */ jsxs(RadixSelect.Group, { children: [
2012
- /* @__PURE__ */ jsx(RadixSelect.Label, { className: selectGroupLabelClass, children: group.label }),
2013
- group.options.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value)),
2014
- idx < lastIndex && /* @__PURE__ */ jsx(RadixSelect.Separator, { className: selectSeparatorClass })
2015
- ] }, group.label));
2016
- }
2017
- return options.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value));
2018
- }
2019
- var SelectItem = forwardRef(function SelectItem2({ className, children, ...props }, ref) {
2020
- return /* @__PURE__ */ jsxs(RadixSelect.Item, { ref, className: cn(selectItemClass, className), ...props, children: [
2021
- /* @__PURE__ */ jsx(RadixSelect.ItemIndicator, { className: selectItemIndicatorClass, children: /* @__PURE__ */ jsx(Check, {}) }),
2022
- /* @__PURE__ */ jsx(RadixSelect.ItemText, { children })
2023
- ] });
2024
- });
2025
2124
  var EN_LABELS = {
2026
2125
  rowsPerPage: "Rows per page",
2027
2126
  pageRangeOf: "of",
@@ -2145,17 +2244,17 @@ var tableSizeClass = {
2145
2244
  sm: {
2146
2245
  row: "",
2147
2246
  cell: "px-3 py-1.5 text-xs",
2148
- head: "px-3 py-2 text-xs font-medium"
2247
+ head: "whitespace-nowrap px-3 py-2 text-xs font-medium"
2149
2248
  },
2150
2249
  md: {
2151
2250
  row: "",
2152
2251
  cell: "px-4 py-2.5 text-sm",
2153
- head: "px-4 py-2.5 text-xs font-medium uppercase tracking-wide"
2252
+ head: "whitespace-nowrap px-4 py-2.5 text-xs font-medium uppercase tracking-wide"
2154
2253
  },
2155
2254
  lg: {
2156
2255
  row: "",
2157
2256
  cell: "px-5 py-3.5 text-sm",
2158
- head: "px-5 py-3 text-sm font-medium"
2257
+ head: "whitespace-nowrap px-5 py-3 text-sm font-medium"
2159
2258
  }
2160
2259
  };
2161
2260
  var tableBaseClass = "w-full caption-bottom border-collapse";
@@ -2272,7 +2371,7 @@ function Table(props) {
2272
2371
  const sizeClasses = tableSizeClass[size];
2273
2372
  const showToolbar = enableRowSelection && bulkActions !== void 0 && selected.size > 0;
2274
2373
  const skeletonCount = loadingRowCount ?? pageSize;
2275
- return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col gap-3", className), children: [
2374
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full min-w-0 flex-col gap-3", className), children: [
2276
2375
  showToolbar && /* @__PURE__ */ jsx(
2277
2376
  Toolbar,
2278
2377
  {
@@ -2305,7 +2404,9 @@ function Table(props) {
2305
2404
  "thead",
2306
2405
  {
2307
2406
  className: cn(
2308
- "bg-muted/40 text-muted-foreground",
2407
+ // Opaque (not bg-muted/40) so a sticky header fully hides the rows
2408
+ // scrolling underneath it.
2409
+ "bg-muted text-muted-foreground",
2309
2410
  maxHeight !== void 0 && "sticky top-0 z-10"
2310
2411
  ),
2311
2412
  children: /* @__PURE__ */ jsxs("tr", { children: [
@@ -2473,20 +2574,446 @@ function SortIndicator({ active, direction }) {
2473
2574
  if (!active) return /* @__PURE__ */ jsx(ChevronsUpDown, { "aria-hidden": "true", className });
2474
2575
  return direction === "asc" ? /* @__PURE__ */ jsx(ChevronUp, { "aria-hidden": "true", className }) : /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": "true", className });
2475
2576
  }
2476
- var DEFAULT_LABELS2 = {
2477
- searchPlaceholder: "Search\u2026",
2478
- searchAriaLabel: "Search",
2577
+
2578
+ // src/components/select/selectVariants.ts
2579
+ var selectVariantClass = {
2580
+ default: "border border-input bg-background hover:border-ring",
2581
+ filled: "border border-transparent bg-muted hover:bg-muted/80",
2582
+ ghost: "border border-transparent bg-transparent hover:bg-accent"
2583
+ };
2584
+ var selectSizeClass = {
2585
+ sm: "h-8 rounded-md ps-2.5 pe-8 text-sm",
2586
+ md: "h-9 rounded-md ps-3 pe-9 text-sm",
2587
+ lg: "h-11 rounded-md ps-4 pe-10 text-base"
2588
+ };
2589
+ var selectBaseClass = "group/select relative inline-flex w-full items-center text-foreground outline-none transition-[background-color,border-color,box-shadow] focus:ring-2 focus:ring-ring/40 focus:ring-offset-1 focus:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus:ring-destructive/40 disabled:pointer-events-none disabled:opacity-50 cursor-pointer data-[placeholder]:text-muted-foreground";
2590
+ var selectContentClass = "z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95";
2591
+ var selectViewportClass = "p-1";
2592
+ var selectItemClass = "relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 ps-8 pe-2 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
2593
+ var selectItemIndicatorClass = "absolute start-2 inline-flex h-3.5 w-3.5 items-center justify-center [&_svg]:h-3.5 [&_svg]:w-3.5";
2594
+ var selectGroupLabelClass = "px-2 py-1.5 text-xs font-semibold text-muted-foreground";
2595
+ var selectSeparatorClass = "-mx-1 my-1 h-px bg-border";
2596
+
2597
+ // src/components/multi-select/multiSelectVariants.ts
2598
+ var multiSelectTriggerSizeClass = {
2599
+ sm: "min-h-8 rounded-md ps-2.5 pe-8 py-1 text-sm",
2600
+ md: "min-h-9 rounded-md ps-3 pe-9 py-1 text-sm",
2601
+ lg: "min-h-11 rounded-md ps-4 pe-10 py-1.5 text-base"
2602
+ };
2603
+ var multiSelectValueRowClass = "flex min-w-0 flex-1 flex-wrap items-center gap-1";
2604
+ var multiSelectChipClass = "max-w-full gap-1 pe-1";
2605
+ var multiSelectChipRemoveClass = "inline-flex size-3.5 shrink-0 items-center justify-center rounded-sm hover:bg-foreground/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40";
2606
+ var multiSelectContentClass = "z-50 w-(--radix-popover-trigger-width) overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95";
2607
+ var multiSelectSearchRowClass = "border-b border-border p-1";
2608
+ var multiSelectListClass = "max-h-60 overflow-y-auto overflow-x-hidden p-1";
2609
+ var multiSelectOptionClass = "flex w-full cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground has-[:focus-visible]:bg-accent has-[:disabled]:pointer-events-none has-[:disabled]:opacity-50";
2610
+ var multiSelectEmptyClass = "px-2 py-6 text-center text-sm text-muted-foreground";
2611
+ var DEFAULT_LABELS_LTR4 = {
2612
+ search: "Search\u2026",
2613
+ empty: "No results"
2614
+ };
2615
+ var DEFAULT_LABELS_RTL4 = {
2616
+ search: "\u0628\u062D\u062B\u2026",
2617
+ empty: "\u0644\u0627 \u0646\u062A\u0627\u0626\u062C"
2618
+ };
2619
+ function toArray(value) {
2620
+ return Array.isArray(value) ? value : [];
2621
+ }
2622
+ var MultiSelect = forwardRef(function MultiSelect2({
2623
+ variant = "default",
2624
+ selectSize = "md",
2625
+ options,
2626
+ placeholder,
2627
+ value,
2628
+ defaultValue,
2629
+ onValueChange,
2630
+ onChange,
2631
+ onBlur,
2632
+ searchable = true,
2633
+ maxTagCount,
2634
+ labels: labelsProp,
2635
+ name,
2636
+ disabled = false,
2637
+ required,
2638
+ id,
2639
+ className,
2640
+ contentClassName,
2641
+ "aria-invalid": ariaInvalid,
2642
+ "aria-describedby": ariaDescribedBy,
2643
+ "aria-label": ariaLabel
2644
+ }, ref) {
2645
+ const dir = useDirection();
2646
+ const labels = { ...dir === "rtl" ? DEFAULT_LABELS_RTL4 : DEFAULT_LABELS_LTR4, ...labelsProp };
2647
+ const generatedId = useId();
2648
+ const triggerId = id ?? generatedId;
2649
+ const isControlled = value !== void 0;
2650
+ const [internal, setInternal] = useState(() => toArray(defaultValue));
2651
+ const selected = isControlled ? toArray(value) : internal;
2652
+ const [open, setOpen] = useState(false);
2653
+ const [query, setQuery] = useState("");
2654
+ const labelByValue = useMemo(() => new Map(options.map((o) => [o.value, o.label])), [options]);
2655
+ const filtered = useMemo(() => {
2656
+ const q = query.trim().toLowerCase();
2657
+ if (!searchable || q === "") return options;
2658
+ return options.filter((o) => o.label.toLowerCase().includes(q));
2659
+ }, [options, query, searchable]);
2660
+ const emit = (next) => {
2661
+ if (!isControlled) setInternal(next);
2662
+ onValueChange?.(next);
2663
+ onChange?.(next);
2664
+ };
2665
+ const toggle = (optionValue) => {
2666
+ emit(
2667
+ selected.includes(optionValue) ? selected.filter((v) => v !== optionValue) : [...selected, optionValue]
2668
+ );
2669
+ };
2670
+ const remove = (optionValue) => emit(selected.filter((v) => v !== optionValue));
2671
+ const openOnKeys = (event) => {
2672
+ if (disabled) return;
2673
+ if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown") {
2674
+ event.preventDefault();
2675
+ setOpen(true);
2676
+ }
2677
+ };
2678
+ const shownValues = maxTagCount !== void 0 ? selected.slice(0, maxTagCount) : selected;
2679
+ const overflowCount = selected.length - shownValues.length;
2680
+ return /* @__PURE__ */ jsxs(RadixPopover.Root, { open, onOpenChange: setOpen, children: [
2681
+ /* @__PURE__ */ jsx(RadixPopover.Anchor, { asChild: true, children: /* @__PURE__ */ jsxs(
2682
+ "div",
2683
+ {
2684
+ ref,
2685
+ id: triggerId,
2686
+ role: "button",
2687
+ tabIndex: disabled ? -1 : 0,
2688
+ "aria-haspopup": "listbox",
2689
+ "aria-expanded": open,
2690
+ "aria-disabled": disabled || void 0,
2691
+ "aria-label": ariaLabel,
2692
+ "aria-invalid": ariaInvalid,
2693
+ "aria-describedby": ariaDescribedBy,
2694
+ "data-slot": "multi-select-trigger",
2695
+ "data-state": open ? "open" : "closed",
2696
+ "data-placeholder": selected.length === 0 ? "" : void 0,
2697
+ onClick: () => !disabled && setOpen(true),
2698
+ onKeyDown: openOnKeys,
2699
+ onBlur,
2700
+ className: cn(
2701
+ selectBaseClass,
2702
+ selectVariantClass[variant],
2703
+ multiSelectTriggerSizeClass[selectSize],
2704
+ className
2705
+ ),
2706
+ children: [
2707
+ /* @__PURE__ */ jsx("span", { className: multiSelectValueRowClass, children: selected.length === 0 ? /* @__PURE__ */ jsx("span", { className: "truncate text-muted-foreground", children: placeholder }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2708
+ shownValues.map((v) => /* @__PURE__ */ jsxs(Badge, { variant: "default", size: "sm", className: multiSelectChipClass, children: [
2709
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: labelByValue.get(v) ?? v }),
2710
+ /* @__PURE__ */ jsx(
2711
+ "button",
2712
+ {
2713
+ type: "button",
2714
+ tabIndex: -1,
2715
+ "aria-label": `Remove ${labelByValue.get(v) ?? v}`,
2716
+ "data-slot": "multi-select-chip-remove",
2717
+ className: multiSelectChipRemoveClass,
2718
+ onClick: (event) => {
2719
+ event.stopPropagation();
2720
+ if (!disabled) remove(v);
2721
+ },
2722
+ children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "size-3" })
2723
+ }
2724
+ )
2725
+ ] }, v)),
2726
+ overflowCount > 0 ? /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", children: `+${overflowCount}` }) : null
2727
+ ] }) }),
2728
+ /* @__PURE__ */ jsx(ChevronDown, { className: "pointer-events-none absolute end-3 top-1/2 size-4 shrink-0 -translate-y-1/2 text-muted-foreground" }),
2729
+ name ? /* @__PURE__ */ jsx(
2730
+ "input",
2731
+ {
2732
+ type: "hidden",
2733
+ name,
2734
+ value: selected.join(","),
2735
+ required,
2736
+ readOnly: true
2737
+ }
2738
+ ) : null
2739
+ ]
2740
+ }
2741
+ ) }),
2742
+ /* @__PURE__ */ jsx(RadixPopover.Portal, { children: /* @__PURE__ */ jsxs(
2743
+ RadixPopover.Content,
2744
+ {
2745
+ align: "start",
2746
+ sideOffset: 4,
2747
+ "data-slot": "multi-select-content",
2748
+ className: cn(multiSelectContentClass, contentClassName),
2749
+ onOpenAutoFocus: (event) => {
2750
+ if (!searchable) event.preventDefault();
2751
+ },
2752
+ children: [
2753
+ searchable ? /* @__PURE__ */ jsx("div", { className: multiSelectSearchRowClass, children: /* @__PURE__ */ jsx(
2754
+ Input,
2755
+ {
2756
+ type: "search",
2757
+ inputSize: "sm",
2758
+ value: query,
2759
+ onChange: (e) => setQuery(e.target.value),
2760
+ placeholder: labels.search,
2761
+ "aria-label": labels.search,
2762
+ leadingIcon: /* @__PURE__ */ jsx(Search, { className: "size-4" })
2763
+ }
2764
+ ) }) : null,
2765
+ filtered.length === 0 ? /* @__PURE__ */ jsx("div", { className: multiSelectEmptyClass, children: labels.empty }) : /* @__PURE__ */ jsx("div", { className: multiSelectListClass, children: filtered.map((option) => {
2766
+ const isSelected = selected.includes(option.value);
2767
+ const optionId = `${triggerId}-opt-${option.value}`;
2768
+ return /* @__PURE__ */ jsxs(
2769
+ "label",
2770
+ {
2771
+ htmlFor: optionId,
2772
+ "data-slot": "multi-select-option",
2773
+ "data-selected": isSelected ? "true" : void 0,
2774
+ className: multiSelectOptionClass,
2775
+ children: [
2776
+ /* @__PURE__ */ jsx(
2777
+ Checkbox,
2778
+ {
2779
+ id: optionId,
2780
+ size: "sm",
2781
+ checked: isSelected,
2782
+ disabled: option.disabled,
2783
+ onCheckedChange: () => toggle(option.value)
2784
+ }
2785
+ ),
2786
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: option.label })
2787
+ ]
2788
+ },
2789
+ option.value
2790
+ );
2791
+ }) })
2792
+ ]
2793
+ }
2794
+ ) })
2795
+ ] });
2796
+ });
2797
+ function isGroupedOptions(options) {
2798
+ const first = options[0];
2799
+ return first !== void 0 && "options" in first;
2800
+ }
2801
+ var Select = forwardRef(function Select2({
2802
+ variant = "default",
2803
+ selectSize = "md",
2804
+ options,
2805
+ placeholder,
2806
+ value,
2807
+ defaultValue,
2808
+ onValueChange,
2809
+ onChange,
2810
+ onBlur,
2811
+ name,
2812
+ disabled,
2813
+ required,
2814
+ id,
2815
+ className,
2816
+ "aria-invalid": ariaInvalid,
2817
+ "aria-describedby": ariaDescribedBy,
2818
+ "aria-label": ariaLabel,
2819
+ children
2820
+ }, ref) {
2821
+ const generatedId = useId();
2822
+ const triggerId = id ?? generatedId;
2823
+ const handleValueChange = useCallback(
2824
+ (next) => {
2825
+ onValueChange?.(next);
2826
+ if (onChange) {
2827
+ const synthetic = {
2828
+ target: { value: next, name },
2829
+ currentTarget: { value: next, name },
2830
+ type: "change"
2831
+ };
2832
+ onChange(synthetic);
2833
+ }
2834
+ },
2835
+ [onValueChange, onChange, name]
2836
+ );
2837
+ return /* @__PURE__ */ jsxs(
2838
+ RadixSelect.Root,
2839
+ {
2840
+ value,
2841
+ defaultValue,
2842
+ onValueChange: handleValueChange,
2843
+ disabled,
2844
+ required,
2845
+ name,
2846
+ children: [
2847
+ /* @__PURE__ */ jsxs(
2848
+ RadixSelect.Trigger,
2849
+ {
2850
+ ref,
2851
+ id: triggerId,
2852
+ "aria-label": ariaLabel,
2853
+ "aria-invalid": ariaInvalid,
2854
+ "aria-describedby": ariaDescribedBy,
2855
+ onBlur,
2856
+ "data-slot": "select-trigger",
2857
+ className: cn(
2858
+ selectBaseClass,
2859
+ selectVariantClass[variant],
2860
+ selectSizeClass[selectSize],
2861
+ className
2862
+ ),
2863
+ children: [
2864
+ /* @__PURE__ */ jsx(RadixSelect.Value, { placeholder }),
2865
+ /* @__PURE__ */ jsx(RadixSelect.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "pointer-events-none absolute end-3 top-1/2 size-4 shrink-0 -translate-y-1/2 text-muted-foreground" }) })
2866
+ ]
2867
+ }
2868
+ ),
2869
+ /* @__PURE__ */ jsx(RadixSelect.Portal, { children: /* @__PURE__ */ jsxs(
2870
+ RadixSelect.Content,
2871
+ {
2872
+ position: "popper",
2873
+ sideOffset: 4,
2874
+ "data-slot": "select-content",
2875
+ className: selectContentClass,
2876
+ children: [
2877
+ /* @__PURE__ */ jsx(RadixSelect.ScrollUpButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-4" }) }),
2878
+ /* @__PURE__ */ jsx(RadixSelect.Viewport, { className: selectViewportClass, children: children ?? (options ? renderOptions(options) : null) }),
2879
+ /* @__PURE__ */ jsx(RadixSelect.ScrollDownButton, { className: "flex h-6 cursor-default items-center justify-center bg-popover text-muted-foreground", children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" }) })
2880
+ ]
2881
+ }
2882
+ ) })
2883
+ ]
2884
+ }
2885
+ );
2886
+ });
2887
+ function renderOptions(options) {
2888
+ if (isGroupedOptions(options)) {
2889
+ const lastIndex = options.length - 1;
2890
+ return options.map((group, idx) => /* @__PURE__ */ jsxs(RadixSelect.Group, { children: [
2891
+ /* @__PURE__ */ jsx(RadixSelect.Label, { className: selectGroupLabelClass, children: group.label }),
2892
+ group.options.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value)),
2893
+ idx < lastIndex && /* @__PURE__ */ jsx(RadixSelect.Separator, { className: selectSeparatorClass })
2894
+ ] }, group.label));
2895
+ }
2896
+ return options.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value));
2897
+ }
2898
+ var SelectItem = forwardRef(function SelectItem2({ className, children, ...props }, ref) {
2899
+ return /* @__PURE__ */ jsxs(RadixSelect.Item, { ref, className: cn(selectItemClass, className), ...props, children: [
2900
+ /* @__PURE__ */ jsx(RadixSelect.ItemIndicator, { className: selectItemIndicatorClass, children: /* @__PURE__ */ jsx(Check, {}) }),
2901
+ /* @__PURE__ */ jsx(RadixSelect.ItemText, { children })
2902
+ ] });
2903
+ });
2904
+
2905
+ // src/components/list-page/listPageFilters.ts
2906
+ var FILTER_SPAN_CLASS = {
2907
+ narrow: "",
2908
+ default: "",
2909
+ wide: "sm:col-span-2"
2910
+ };
2911
+ function filterDefaultValue(filter) {
2912
+ return filter.type === "select" ? filter.options[0]?.value ?? "" : "";
2913
+ }
2914
+ function hasActiveFilters(filters, values) {
2915
+ for (const filter of filters ?? []) {
2916
+ const current = values?.[filter.key];
2917
+ if (current === void 0) continue;
2918
+ const value = filter.type === "text" ? current.trim() : current;
2919
+ if (value !== filterDefaultValue(filter)) return true;
2920
+ }
2921
+ return false;
2922
+ }
2923
+ function ListPageFilterBar({
2924
+ filters,
2925
+ values,
2926
+ onChange,
2927
+ disabled = false,
2928
+ labels
2929
+ }) {
2930
+ const active = hasActiveFilters(filters, values);
2931
+ const reset = () => {
2932
+ for (const filter of filters ?? []) {
2933
+ onChange?.(filter.key, filterDefaultValue(filter));
2934
+ }
2935
+ };
2936
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "list-page-filter-bar", className: "space-y-3", children: [
2937
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3", children: filters?.map((filter) => /* @__PURE__ */ jsx(
2938
+ FilterControl,
2939
+ {
2940
+ filter,
2941
+ value: values?.[filter.key],
2942
+ onChange,
2943
+ disabled
2944
+ },
2945
+ filter.key
2946
+ )) }),
2947
+ active && !disabled ? /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: reset, children: [
2948
+ /* @__PURE__ */ jsx(RefreshCw, { className: "size-4" }),
2949
+ labels.reset
2950
+ ] }) }) : null
2951
+ ] });
2952
+ }
2953
+ function FilterControl({ filter, value, onChange, disabled }) {
2954
+ const spanClass = FILTER_SPAN_CLASS[filter.width ?? "default"];
2955
+ const ariaLabel = typeof filter.label === "string" ? filter.label : filter.key;
2956
+ switch (filter.type) {
2957
+ case "select":
2958
+ return /* @__PURE__ */ jsx(
2959
+ Select,
2960
+ {
2961
+ "aria-label": ariaLabel,
2962
+ value: value ?? filterDefaultValue(filter),
2963
+ onValueChange: (v) => onChange?.(filter.key, v),
2964
+ options: filter.options,
2965
+ className: spanClass,
2966
+ disabled
2967
+ }
2968
+ );
2969
+ case "text":
2970
+ return /* @__PURE__ */ jsx(
2971
+ Input,
2972
+ {
2973
+ type: "search",
2974
+ "aria-label": ariaLabel,
2975
+ placeholder: filter.placeholder,
2976
+ value: value ?? "",
2977
+ onChange: (e) => onChange?.(filter.key, e.target.value),
2978
+ leadingIcon: /* @__PURE__ */ jsx(Search, { className: "size-4" }),
2979
+ wrapperClassName: spanClass,
2980
+ disabled
2981
+ }
2982
+ );
2983
+ case "date":
2984
+ return /* @__PURE__ */ jsx(
2985
+ DatePicker,
2986
+ {
2987
+ "aria-label": ariaLabel,
2988
+ placeholder: filter.placeholder,
2989
+ value: value ?? "",
2990
+ onValueChange: (v) => onChange?.(filter.key, v),
2991
+ className: spanClass,
2992
+ disabled
2993
+ }
2994
+ );
2995
+ case "multiselect":
2996
+ return /* @__PURE__ */ jsx(
2997
+ MultiSelect,
2998
+ {
2999
+ "aria-label": ariaLabel,
3000
+ placeholder: filter.placeholder,
3001
+ options: filter.options,
3002
+ value: value ? value.split(",").filter(Boolean) : [],
3003
+ onValueChange: (values) => onChange?.(filter.key, values.join(",")),
3004
+ className: spanClass,
3005
+ disabled
3006
+ }
3007
+ );
3008
+ }
3009
+ }
3010
+ var DEFAULT_LABELS = {
2479
3011
  reset: "Reset filters",
2480
3012
  emptyTitle: "No results",
2481
3013
  emptyDescription: "Try clearing the search or adjusting the filters.",
2482
3014
  noDataTitle: "No data yet",
2483
3015
  noDataDescription: "Nothing has been added here so far."
2484
3016
  };
2485
- var FILTER_WIDTH_CLASS = {
2486
- narrow: "w-32",
2487
- default: "w-44",
2488
- wide: "w-56"
2489
- };
2490
3017
  function ListPage({
2491
3018
  title,
2492
3019
  description,
@@ -2497,8 +3024,6 @@ function ListPage({
2497
3024
  getRowId,
2498
3025
  isLoading = false,
2499
3026
  loadingRowCount,
2500
- searchValue,
2501
- onSearchChange,
2502
3027
  filters,
2503
3028
  filterValues,
2504
3029
  onFilterChange,
@@ -2513,59 +3038,30 @@ function ListPage({
2513
3038
  labels: labelsProp,
2514
3039
  className
2515
3040
  }) {
2516
- const labels = { ...DEFAULT_LABELS2, ...labelsProp };
2517
- const showSearch = onSearchChange !== void 0;
2518
- const showFilterBar = showSearch || Boolean(filters?.length);
2519
- const hasActiveQuery = useMemo(() => {
2520
- if ((searchValue ?? "").trim() !== "") return true;
2521
- for (const f of filters ?? []) {
2522
- const current = filterValues?.[f.key];
2523
- const def = f.options[0]?.value ?? "";
2524
- if (current !== void 0 && current !== def) return true;
2525
- }
2526
- return false;
2527
- }, [searchValue, filters, filterValues]);
3041
+ const labels = { ...DEFAULT_LABELS, ...labelsProp };
3042
+ const showFilterBar = Boolean(filters?.length);
3043
+ const hasActiveQuery = useMemo(
3044
+ () => hasActiveFilters(filters, filterValues),
3045
+ [filters, filterValues]
3046
+ );
2528
3047
  const reset = () => {
2529
- onSearchChange?.("");
2530
3048
  for (const f of filters ?? []) {
2531
- const def = f.options[0]?.value ?? "";
2532
- onFilterChange?.(f.key, def);
3049
+ onFilterChange?.(f.key, filterDefaultValue(f));
2533
3050
  }
2534
3051
  };
2535
3052
  const tableMode = isLoading ? "loading" : data.length === 0 && !hasActiveQuery ? "no-data" : data.length === 0 && hasActiveQuery ? "no-results" : "rows";
2536
3053
  return /* @__PURE__ */ jsxs("div", { "data-slot": "list-page", className: cn("space-y-6", className), children: [
2537
3054
  /* @__PURE__ */ jsx(PageHeader, { title, description, bordered, actions }),
2538
- showFilterBar ? /* @__PURE__ */ jsxs("div", { "data-slot": "list-page-filter-bar", className: "flex flex-wrap items-center gap-3", children: [
2539
- showSearch ? /* @__PURE__ */ jsx(
2540
- Input,
2541
- {
2542
- type: "search",
2543
- placeholder: labels.searchPlaceholder,
2544
- "aria-label": labels.searchAriaLabel || labels.searchPlaceholder,
2545
- value: searchValue ?? "",
2546
- onChange: (e) => onSearchChange?.(e.target.value),
2547
- leadingIcon: /* @__PURE__ */ jsx(Search, {}),
2548
- wrapperClassName: "sm:max-w-xs",
2549
- disabled: isLoading
2550
- }
2551
- ) : null,
2552
- filters?.map((f) => /* @__PURE__ */ jsx(
2553
- Select,
2554
- {
2555
- "aria-label": typeof f.label === "string" ? f.label : f.key,
2556
- value: filterValues?.[f.key] ?? f.options[0]?.value ?? "",
2557
- onValueChange: (v) => onFilterChange?.(f.key, v),
2558
- options: f.options,
2559
- className: FILTER_WIDTH_CLASS[f.width ?? "default"],
2560
- disabled: isLoading
2561
- },
2562
- f.key
2563
- )),
2564
- hasActiveQuery && !isLoading ? /* @__PURE__ */ jsxs(Button, { variant: "ghost", onClick: reset, children: [
2565
- /* @__PURE__ */ jsx(RefreshCw, {}),
2566
- labels.reset
2567
- ] }) : null
2568
- ] }) : null,
3055
+ showFilterBar ? /* @__PURE__ */ jsx(
3056
+ ListPageFilterBar,
3057
+ {
3058
+ filters,
3059
+ values: filterValues,
3060
+ onChange: onFilterChange,
3061
+ disabled: isLoading,
3062
+ labels: { reset: labels.reset }
3063
+ }
3064
+ ) : null,
2569
3065
  tableMode === "loading" || tableMode === "rows" ? /* @__PURE__ */ jsx(
2570
3066
  Table,
2571
3067
  {
@@ -2985,6 +3481,6 @@ function Tooltip({
2985
3481
  );
2986
3482
  }
2987
3483
 
2988
- export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AppShell, Avatar, Badge, Button, Checkbox, ConfirmDialogProvider, DashboardContent, DashboardHeader, DashboardLayout, DashboardMain, DatePicker, DetailPage, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, EmptyState, Field, FormPage, HeaderActions, HeaderCollapseTrigger, HeaderMobileTrigger, HeaderSearch, HeaderTitle, Input, LanguageSwitcher, ListPage, PageHeader, RadioGroup, RadioGroupItem, Select, Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarNav, SidebarNavGroup, SidebarNavItem, Switch, Table, Textarea, Toaster, Tooltip, TooltipProvider, badgeBaseClass, badgeDotSizeClass, badgeSizeClass, badgeVariantClass, buttonBaseClass, buttonSizeClass, buttonVariantClass, cn, datePickerCalendarClass, datePickerCaptionClass, datePickerContentClass, datePickerDayBaseClass, datePickerDayWrapperClass, datePickerDisabledClass, datePickerMonthClass, datePickerMonthGridClass, datePickerMonthsClass, datePickerNavButtonClass, datePickerNavClass, datePickerOutsideClass, datePickerPlaceholderClass, datePickerSelectedClass, datePickerTodayClass, datePickerTriggerBaseClass, datePickerTriggerSizeClass, datePickerTriggerVariantClass, datePickerValueClass, datePickerWeekClass, datePickerWeekdayClass, datePickerWeekdaysClass, detailPageBaseClass, detailPageBodyClass, detailPageEmptyClass, detailPageSkeletonRowClass, dialogCloseButtonClass, dialogContentClass, dialogDescriptionClass, dialogFooterClass, dialogHeaderClass, dialogOverlayClass, dialogTitleClass, dropdownMenuContentClass, dropdownMenuItemBaseClass, dropdownMenuItemInsetClass, dropdownMenuItemVariantClass, dropdownMenuLabelClass, dropdownMenuSeparatorClass, dropdownMenuShortcutClass, emptyStateActionsSpacingClass, emptyStateBaseClass, emptyStateContainerSizeClass, emptyStateDescriptionSizeClass, emptyStateIconWrapperBaseClass, emptyStateIconWrapperSizeClass, emptyStateTitleSizeClass, formPageActionsBarClass, formPageBaseClass, formPageBodyClass, formPageSkeletonRowClass, inputBaseClass, inputSizeClass, inputVariantClass, pageHeaderActionsClass, pageHeaderBackClass, pageHeaderBackIconClass, pageHeaderBaseClass, pageHeaderBorderedClass, pageHeaderBreadcrumbsClass, pageHeaderDescriptionClass, pageHeaderTitleBlockClass, pageHeaderTitleClass, pageHeaderTitleRowClass, radioGroupBaseClass, radioGroupOrientationClass, radioIndicatorBaseClass, radioIndicatorDotClass, radioIndicatorSizeClass, radioItemBaseClass, radioItemSizeClass, radioLabelSizeClass, radioOptionRowClass, selectBaseClass, selectSizeClass, selectVariantClass, switchThumbBaseClass, switchThumbClass, switchTrackBaseClass, switchTrackClass, alignClass as tableAlignClass, tableBaseClass, selectedRowClass as tableSelectedRowClass, tableSizeClass, sortIconClass as tableSortIconClass, textareaBaseClass, textareaResizeClass, textareaSizeClass, textareaVariantClass, toastClassNames, tooltipArrowClass, tooltipContentClass, useConfirm, useDashboardLayout, useDirection };
3484
+ export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AppShell, Avatar, Badge, Button, Checkbox, ConfirmDialogProvider, DashboardContent, DashboardHeader, DashboardLayout, DashboardMain, DatePicker, DetailPage, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, EmptyState, Field, FileUpload2 as FileUpload, FormPage, HeaderActions, HeaderCollapseTrigger, HeaderMobileTrigger, HeaderSearch, HeaderTitle, Input, LanguageSwitcher, ListPage, MultiSelect, PageHeader, RadioGroup, RadioGroupItem, Select, Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarNav, SidebarNavGroup, SidebarNavItem, Switch, Table, Textarea, Toaster, Tooltip, TooltipProvider, badgeBaseClass, badgeDotSizeClass, badgeSizeClass, badgeVariantClass, buttonBaseClass, buttonSizeClass, buttonVariantClass, cn, datePickerCalendarClass, datePickerCaptionClass, datePickerContentClass, datePickerDayBaseClass, datePickerDayWrapperClass, datePickerDisabledClass, datePickerMonthClass, datePickerMonthGridClass, datePickerMonthsClass, datePickerNavButtonClass, datePickerNavClass, datePickerOutsideClass, datePickerPlaceholderClass, datePickerSelectedClass, datePickerTodayClass, datePickerTriggerBaseClass, datePickerTriggerSizeClass, datePickerTriggerVariantClass, datePickerValueClass, datePickerWeekClass, datePickerWeekdayClass, datePickerWeekdaysClass, detailPageBaseClass, detailPageBodyClass, detailPageEmptyClass, detailPageSkeletonRowClass, dialogCloseButtonClass, dialogContentClass, dialogDescriptionClass, dialogFooterClass, dialogHeaderClass, dialogOverlayClass, dialogTitleClass, dropdownMenuContentClass, dropdownMenuItemBaseClass, dropdownMenuItemInsetClass, dropdownMenuItemVariantClass, dropdownMenuLabelClass, dropdownMenuSeparatorClass, dropdownMenuShortcutClass, emptyStateActionsSpacingClass, emptyStateBaseClass, emptyStateContainerSizeClass, emptyStateDescriptionSizeClass, emptyStateIconWrapperBaseClass, emptyStateIconWrapperSizeClass, emptyStateTitleSizeClass, fileUploadBaseClass, fileUploadDropzoneClass, fileUploadFileNameClass, fileUploadFileRowClass, fileUploadFileSizeClass, fileUploadHintClass, fileUploadIconClass, fileUploadPromptClass, fileUploadRemoveClass, formPageActionsBarClass, formPageBaseClass, formPageBodyClass, formPageSkeletonRowClass, inputBaseClass, inputSizeClass, inputVariantClass, multiSelectChipClass, multiSelectChipRemoveClass, multiSelectContentClass, multiSelectEmptyClass, multiSelectListClass, multiSelectOptionClass, multiSelectSearchRowClass, multiSelectTriggerSizeClass, multiSelectValueRowClass, pageHeaderActionsClass, pageHeaderBackClass, pageHeaderBackIconClass, pageHeaderBaseClass, pageHeaderBorderedClass, pageHeaderBreadcrumbsClass, pageHeaderDescriptionClass, pageHeaderTitleBlockClass, pageHeaderTitleClass, pageHeaderTitleRowClass, radioGroupBaseClass, radioGroupOrientationClass, radioIndicatorBaseClass, radioIndicatorDotClass, radioIndicatorSizeClass, radioItemBaseClass, radioItemSizeClass, radioLabelSizeClass, radioOptionRowClass, selectBaseClass, selectSizeClass, selectVariantClass, switchThumbBaseClass, switchThumbClass, switchTrackBaseClass, switchTrackClass, alignClass as tableAlignClass, tableBaseClass, selectedRowClass as tableSelectedRowClass, tableSizeClass, sortIconClass as tableSortIconClass, textareaBaseClass, textareaResizeClass, textareaSizeClass, textareaVariantClass, toastClassNames, tooltipArrowClass, tooltipContentClass, useConfirm, useDashboardLayout, useDirection };
2989
3485
  //# sourceMappingURL=index.js.map
2990
3486
  //# sourceMappingURL=index.js.map