@nexub/react 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/{chunk-C6JRJ6JW.js → chunk-22BGPRJZ.js} +1 -1
  2. package/dist/{chunk-NGQKBDHA.js → chunk-322WR6EU.js} +1 -1
  3. package/dist/{chunk-24ZFAXB2.js → chunk-3MSIO7KM.js} +29 -1
  4. package/dist/{chunk-AEBYQKLS.js → chunk-3XX45SUC.js} +62 -1
  5. package/dist/chunk-4B4XWDAH.js +1 -0
  6. package/dist/{chunk-AGYGWU6C.js → chunk-4MEV2WHD.js} +27 -6
  7. package/dist/{chunk-FLZD7HQY.js → chunk-5FWJXSXT.js} +1 -1
  8. package/dist/{chunk-NYWD5SI4.js → chunk-5GN2GFW3.js} +1 -1
  9. package/dist/{chunk-LESI7J7B.js → chunk-5NKIGEDZ.js} +1 -0
  10. package/dist/{chunk-7SXR4PGO.js → chunk-5W3AOOYS.js} +1 -1
  11. package/dist/{chunk-NZR4UGUZ.js → chunk-6U5WQERX.js} +4 -4
  12. package/dist/{chunk-NZT4TTNV.js → chunk-7BAIEYUW.js} +79 -58
  13. package/dist/{chunk-NQPGELMP.js → chunk-A4QLUIFN.js} +1 -1
  14. package/dist/{chunk-PGDXFBKT.js → chunk-BEOHZKPQ.js} +1 -1
  15. package/dist/{chunk-4UBVU53C.js → chunk-BIAYWCDE.js} +1 -1
  16. package/dist/{chunk-YNU6VRD5.js → chunk-BSKEBC2Q.js} +1 -1
  17. package/dist/chunk-BU5QD2FS.js +148 -0
  18. package/dist/{chunk-GRKCUQG4.js → chunk-DFCHCYNT.js} +4 -3
  19. package/dist/{chunk-4HQFOIZW.js → chunk-ENB7X3W4.js} +3 -3
  20. package/dist/{chunk-643EYCLL.js → chunk-ESMIBOF5.js} +1 -1
  21. package/dist/{chunk-ZMJ54TG6.js → chunk-ETWFHIAE.js} +1 -1
  22. package/dist/{chunk-JHVYI5GK.js → chunk-F7ZA2VA2.js} +1 -1
  23. package/dist/{chunk-KRCLK5O4.js → chunk-FT2S7N64.js} +1 -1
  24. package/dist/{chunk-X4BQHXLB.js → chunk-GG5HDX7J.js} +1 -1
  25. package/dist/{chunk-RM7MTOT5.js → chunk-GSA7NBEG.js} +1 -1
  26. package/dist/{chunk-MYP5ZTC3.js → chunk-HSM7RXUF.js} +3 -3
  27. package/dist/{chunk-U2ZYPPRG.js → chunk-IDIS7Z6H.js} +2 -2
  28. package/dist/{chunk-JSBNYRO4.js → chunk-JVOSMXD5.js} +2 -2
  29. package/dist/{chunk-BSL62LBX.js → chunk-KRHD7VI6.js} +1 -1
  30. package/dist/{chunk-4NFUBFYK.js → chunk-L4BSKMLK.js} +1 -1
  31. package/dist/{chunk-RATKKN3F.js → chunk-LYOU2D5N.js} +2 -2
  32. package/dist/{chunk-7VJABRKB.js → chunk-NORCPKRD.js} +1 -1
  33. package/dist/{chunk-CQWYZPPJ.js → chunk-NYORXEPS.js} +1 -1
  34. package/dist/{chunk-MLT7SA3T.js → chunk-O6J6HXVT.js} +3 -3
  35. package/dist/{chunk-NAJKIBU2.js → chunk-OS4NOWEI.js} +1 -1
  36. package/dist/{chunk-J65MK3N4.js → chunk-OTZBGMYH.js} +2 -2
  37. package/dist/{chunk-W3KO3JNZ.js → chunk-PC7YGDNL.js} +2 -2
  38. package/dist/{chunk-PREMZMLU.js → chunk-PGD246WD.js} +1 -1
  39. package/dist/{chunk-VMT7Y3AT.js → chunk-R6VLSYXK.js} +2 -2
  40. package/dist/{chunk-UTLKZPKJ.js → chunk-RSBJBQPG.js} +1 -1
  41. package/dist/{chunk-B254JXS7.js → chunk-RVWQROFK.js} +1 -1
  42. package/dist/{chunk-2I7FIU6R.js → chunk-SKIJVVBU.js} +1 -1
  43. package/dist/{chunk-SYZADSLI.js → chunk-SZNSQR2B.js} +1 -1
  44. package/dist/{chunk-ZTLALVWA.js → chunk-TSN6HYVY.js} +2 -2
  45. package/dist/{chunk-TAVVXXGO.js → chunk-UAQRQNOB.js} +2 -2
  46. package/dist/chunk-UCNA2ICU.js +28 -0
  47. package/dist/{chunk-NERAWEIQ.js → chunk-UV5O2BMW.js} +2 -2
  48. package/dist/{chunk-XDU27NRX.js → chunk-UVWQPDOV.js} +1 -1
  49. package/dist/{chunk-GWDEKW7P.js → chunk-V6CMWCJH.js} +2 -2
  50. package/dist/{chunk-VD4RFTNV.js → chunk-VF6RWEKX.js} +1 -1
  51. package/dist/{chunk-CV5ZKED7.js → chunk-W2P2WOAN.js} +1 -1
  52. package/dist/{chunk-GG54WBLA.js → chunk-WECNLNIA.js} +2 -2
  53. package/dist/{chunk-KE4YVG5Q.js → chunk-X3B2MTX6.js} +1 -1
  54. package/dist/{chunk-37L5ERUJ.js → chunk-XHLSYHAV.js} +2 -2
  55. package/dist/{chunk-RUR57JZQ.js → chunk-ZGZQZG6S.js} +1 -1
  56. package/dist/{chunk-WVBGQCYC.js → chunk-ZLW7IBXK.js} +1 -1
  57. package/dist/{chunk-TZ6KJIR4.js → chunk-ZRBLASQE.js} +1 -1
  58. package/dist/{chunk-QUNH4BFR.js → chunk-ZTI4MK3L.js} +1 -1
  59. package/dist/{chunk-7XWJCFWI.js → chunk-ZUGZRXME.js} +1 -1
  60. package/dist/components/Alert/index.js +2 -2
  61. package/dist/components/AlertDialog/index.js +4 -4
  62. package/dist/components/Amount/index.js +3 -3
  63. package/dist/components/Autocomplete/index.js +2 -2
  64. package/dist/components/AvatarGroup/index.js +2 -2
  65. package/dist/components/Banner/index.js +2 -2
  66. package/dist/components/Breadcrumb/index.js +2 -2
  67. package/dist/components/Button/index.js +2 -2
  68. package/dist/components/Chip/index.js +2 -2
  69. package/dist/components/Citation/index.js +4 -4
  70. package/dist/components/CommandPalette/index.js +3 -3
  71. package/dist/components/ContextMenu/index.js +2 -2
  72. package/dist/components/DataTable/index.js +4 -2
  73. package/dist/components/DatePicker/index.js +4 -4
  74. package/dist/components/DateRangePicker/index.js +5 -5
  75. package/dist/components/Dialog/index.js +2 -2
  76. package/dist/components/Drawer/index.js +2 -2
  77. package/dist/components/DropdownMenu/index.js +2 -2
  78. package/dist/components/ErrorState/index.js +2 -2
  79. package/dist/components/EyebrowChip/index.js +3 -3
  80. package/dist/components/FileUpload/index.js +2 -2
  81. package/dist/components/FilterChip/index.js +3 -3
  82. package/dist/components/FormField/index.js +5 -5
  83. package/dist/components/Heading/index.js +3 -3
  84. package/dist/components/HelperText/index.js +3 -3
  85. package/dist/components/HoverCard/index.js +2 -2
  86. package/dist/components/IconButton/index.js +2 -2
  87. package/dist/components/Input/index.js +2 -2
  88. package/dist/components/Kbd/index.js +1 -1
  89. package/dist/components/KeyboardShortcut/index.js +2 -2
  90. package/dist/components/Label/index.js +3 -3
  91. package/dist/components/Menubar/index.js +2 -2
  92. package/dist/components/MessageBubble/index.js +4 -4
  93. package/dist/components/MoneyInput/index.js +4 -4
  94. package/dist/components/NavigationMenu/index.js +2 -2
  95. package/dist/components/NavigationRail/index.js +2 -2
  96. package/dist/components/NexubProvider/index.js +1 -1
  97. package/dist/components/NumberInput/index.js +4 -4
  98. package/dist/components/NumberTicker/index.js +2 -2
  99. package/dist/components/PageHeader/index.js +1 -1
  100. package/dist/components/Pagination/index.js +3 -3
  101. package/dist/components/PasswordInput/index.js +4 -4
  102. package/dist/components/Popover/index.js +2 -2
  103. package/dist/components/PromptInput/index.js +4 -4
  104. package/dist/components/Rating/index.js +2 -2
  105. package/dist/components/SearchInput/index.js +4 -4
  106. package/dist/components/Select/index.js +3 -3
  107. package/dist/components/Sidebar/index.js +2 -2
  108. package/dist/components/Spinner/index.js +2 -2
  109. package/dist/components/SplitButton/index.js +5 -5
  110. package/dist/components/Table/index.js +2 -1
  111. package/dist/components/Textarea/index.js +2 -2
  112. package/dist/components/ThemeProvider/index.js +1 -1
  113. package/dist/components/ThinkingIndicator/index.js +2 -2
  114. package/dist/components/Toast/index.js +2 -2
  115. package/dist/components/TopNav/index.js +2 -2
  116. package/dist/index.d.ts +69 -6
  117. package/dist/index.js +96 -95
  118. package/package.json +6 -6
  119. package/dist/chunk-MTK3GHDQ.js +0 -25
  120. package/dist/chunk-OYCK6BRG.js +0 -89
@@ -3,7 +3,7 @@ import {
3
3
  disabledContainer,
4
4
  disabledText,
5
5
  pressable
6
- } from "./chunk-7SXR4PGO.js";
6
+ } from "./chunk-5W3AOOYS.js";
7
7
  import {
8
8
  glassSurfaceClass
9
9
  } from "./chunk-DEIBF3P7.js";
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import {
3
3
  toneTextClasses
4
- } from "./chunk-C6JRJ6JW.js";
4
+ } from "./chunk-22BGPRJZ.js";
5
5
  import {
6
6
  cn
7
7
  } from "./chunk-Q7G5WGYV.js";
@@ -60,7 +60,35 @@ var defaultMessages = {
60
60
  sources: "Sources",
61
61
  source: (n) => `Source ${n}`,
62
62
  jumpToLatest: "Jump to latest",
63
- conversation: "Conversation"
63
+ conversation: "Conversation",
64
+ pageOf: (page, total) => `Page ${page} of ${total}`,
65
+ previous: "Previous",
66
+ next: "Next",
67
+ search: "Search",
68
+ searchProduct: (productName) => `Search ${productName}`,
69
+ keyboardShortcut: (shortcut) => `Keyboard shortcut: ${shortcut}`,
70
+ commandKey: "Command",
71
+ controlKey: "Control",
72
+ searching: "Searching\u2026",
73
+ searchFailed: "Search failed. Try again.",
74
+ noResultsFor: (query) => `No results for \u201C${query}\u201D`,
75
+ typeToSearch: "Type to search",
76
+ switchOrganization: (name) => `${name}, switch organization`,
77
+ organizations: "Organizations",
78
+ switchToLightTheme: "Switch to light theme",
79
+ switchToDarkTheme: "Switch to dark theme",
80
+ glass: "Glass",
81
+ glassClear: "Clear",
82
+ glassBalanced: "Balanced",
83
+ glassTinted: "Tinted",
84
+ glassSolid: "Solid",
85
+ accountMenu: (name) => `Account: ${name}`,
86
+ manageAccount: "Manage your Nexub Account",
87
+ privacyPolicy: "Privacy policy",
88
+ termsOfService: "Terms of service",
89
+ signOut: "Sign out",
90
+ signingOut: "Signing out\u2026",
91
+ accountAndApps: "Account and apps"
64
92
  };
65
93
  var NexubContext = React.createContext({
66
94
  locale: void 0,
@@ -36,6 +36,64 @@ function readGlass(key, fallback) {
36
36
  }
37
37
  return fallback;
38
38
  }
39
+ var CONTRAST_QUERY = "(prefers-contrast: more)";
40
+ function readContrast(root) {
41
+ const attr = root.getAttribute("data-contrast");
42
+ if (attr === "standard" || attr === "medium" || attr === "high") return attr;
43
+ return window.matchMedia(CONTRAST_QUERY).matches ? "high" : "standard";
44
+ }
45
+ function useSeedTheme(seed, target) {
46
+ React.useEffect(() => {
47
+ if (!seed) return;
48
+ const color = seed;
49
+ const root = document.documentElement;
50
+ const mq = window.matchMedia(CONTRAST_QUERY);
51
+ const observer = new MutationObserver(() => update());
52
+ let applied = [];
53
+ let create;
54
+ let done = false;
55
+ const clear = () => {
56
+ for (const name of applied) root.style.removeProperty(name);
57
+ applied = [];
58
+ };
59
+ const stop = () => {
60
+ done = true;
61
+ observer.disconnect();
62
+ mq.removeEventListener("change", update);
63
+ };
64
+ function update() {
65
+ if (done || !create) return;
66
+ let vars;
67
+ try {
68
+ vars = create(color, { contrast: readContrast(root), target });
69
+ } catch (error) {
70
+ console.error(error);
71
+ clear();
72
+ stop();
73
+ return;
74
+ }
75
+ clear();
76
+ for (const [name, value] of Object.entries(vars)) root.style.setProperty(name, value);
77
+ applied = Object.keys(vars);
78
+ }
79
+ observer.observe(root, { attributes: true, attributeFilter: ["data-contrast"] });
80
+ mq.addEventListener("change", update);
81
+ import("@nexub/tokens/seed").then(
82
+ (mod) => {
83
+ create = mod.createSeedTheme;
84
+ update();
85
+ },
86
+ (error) => {
87
+ console.error(error);
88
+ stop();
89
+ }
90
+ );
91
+ return () => {
92
+ stop();
93
+ clear();
94
+ };
95
+ }, [seed, target]);
96
+ }
39
97
  function writeStorage(key, value) {
40
98
  if (typeof window === "undefined") return;
41
99
  try {
@@ -48,8 +106,11 @@ function ThemeProvider({
48
106
  defaultTheme = "system",
49
107
  storageKey = "nexub-theme",
50
108
  defaultGlass = "balanced",
51
- glassStorageKey = "nexub-glass"
109
+ glassStorageKey = "nexub-glass",
110
+ seed,
111
+ seedTarget = "primary"
52
112
  }) {
113
+ useSeedTheme(seed, seedTarget);
53
114
  const [theme, setThemeState] = React.useState(defaultTheme);
54
115
  const [systemTheme, setSystemTheme] = React.useState("light");
55
116
  const [glass, setGlassState] = React.useState(defaultGlass);
@@ -0,0 +1 @@
1
+ 'use client';
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import {
3
3
  useIntlLocale
4
- } from "./chunk-24ZFAXB2.js";
4
+ } from "./chunk-3MSIO7KM.js";
5
5
  import {
6
6
  cn
7
7
  } from "./chunk-Q7G5WGYV.js";
@@ -22,6 +22,26 @@ var SHIFT = [
22
22
  "-translate-y-[90%]"
23
23
  ];
24
24
  var DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
25
+ var isDigit = (c) => c !== void 0 && /^[0-9]$/.test(c);
26
+ var RTL = /[\u0590-\u08FF\u200F\u061C\uFB1D-\uFDFF\uFE70-\uFEFF]/;
27
+ function digitRuns(items) {
28
+ const out = [];
29
+ let run = [];
30
+ const flush = () => {
31
+ if (run.length) out.push(/* @__PURE__ */ jsx("span", { dir: "ltr", children: run.map((r) => r.node) }, `run${run[run.length - 1].key}`));
32
+ run = [];
33
+ };
34
+ items.forEach((it, i) => {
35
+ const inRun = isDigit(it.char) || run.length > 0 && isDigit(items[i + 1]?.char) && /^[.,\u00A0\u202F' ]$/.test(it.char);
36
+ if (inRun) run.push(it);
37
+ else {
38
+ flush();
39
+ out.push(it.node);
40
+ }
41
+ });
42
+ flush();
43
+ return out;
44
+ }
25
45
  function Char({ char, className, enter }) {
26
46
  const [entering] = React.useState(enter);
27
47
  const motion = entering ? { "data-motion": "from-fade" } : {};
@@ -61,6 +81,11 @@ var NumberTicker = React.forwardRef(
61
81
  React.useEffect(() => {
62
82
  mounted.current = true;
63
83
  }, []);
84
+ const rendered = chars.map(({ char, className: cls }, i) => {
85
+ const key = `${chars.length - 1 - i}${isDigit(char) ? "d" : `s${char}`}`;
86
+ return { char, key, node: /* @__PURE__ */ jsx(Char, { char, className: cls, enter: mounted.current }, key) };
87
+ });
88
+ const rtlText = RTL.test(text);
64
89
  return /* @__PURE__ */ jsxs(
65
90
  "span",
66
91
  {
@@ -71,11 +96,7 @@ var NumberTicker = React.forwardRef(
71
96
  ...props,
72
97
  children: [
73
98
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: text }),
74
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: chars.map(({ char, className: cls }, i) => {
75
- const fromEnd = chars.length - 1 - i;
76
- const kind = /^[0-9]$/.test(char) ? "d" : `s${char}`;
77
- return /* @__PURE__ */ jsx(Char, { char, className: cls, enter: mounted.current }, `${fromEnd}${kind}`);
78
- }) })
99
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", dir: rtlText ? "rtl" : "ltr", children: rtlText ? digitRuns(rendered) : rendered.map((r) => r.node) })
79
100
  ]
80
101
  }
81
102
  );
@@ -12,7 +12,7 @@ var menuItem = [
12
12
  ].join(" ");
13
13
  var menuSeparator = "-mx-1.5 my-1.5 h-px bg-[var(--color-outline-variant)]";
14
14
  var menuLabel = "px-2.5 py-1.5 text-label-sm text-[var(--color-on-surface-muted)]";
15
- var scrim = "bg-[color-mix(in_srgb,var(--color-scrim,#000)_40%,transparent)]";
15
+ var scrim = "bg-[color-mix(in_srgb,var(--color-scrim)_40%,transparent)]";
16
16
 
17
17
  export {
18
18
  overlaySurface,
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import {
3
3
  useNexubMessages
4
- } from "./chunk-24ZFAXB2.js";
4
+ } from "./chunk-3MSIO7KM.js";
5
5
  import {
6
6
  cn
7
7
  } from "./chunk-Q7G5WGYV.js";
@@ -12,6 +12,7 @@ var Kbd = React.forwardRef(
12
12
  "kbd",
13
13
  {
14
14
  ref,
15
+ dir: "ltr",
15
16
  className: cn(
16
17
  "inline-flex items-center justify-center font-mono text-xs",
17
18
  "px-1.5 py-0.5 min-w-[1.5rem]",
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/utils/control.ts
4
4
  var field = [
5
- "rounded-shape-field border border-[var(--color-border-input)]",
5
+ "rounded-shape-field border border-[var(--color-outline)]",
6
6
  "bg-[var(--color-surface-container-lowest)] text-[var(--color-on-surface)]",
7
7
  "transition-[border-color,box-shadow] duration-effects-fast ease-effects-fast",
8
8
  "hover:border-[var(--color-on-surface-variant)]"
@@ -1,17 +1,17 @@
1
1
  'use client';
2
2
  import {
3
3
  useCalendarLocale
4
- } from "./chunk-MYP5ZTC3.js";
4
+ } from "./chunk-HSM7RXUF.js";
5
5
  import {
6
6
  floatingSurface
7
- } from "./chunk-FLZD7HQY.js";
7
+ } from "./chunk-5FWJXSXT.js";
8
8
  import {
9
9
  field,
10
10
  fieldFocusVisible
11
- } from "./chunk-7SXR4PGO.js";
11
+ } from "./chunk-5W3AOOYS.js";
12
12
  import {
13
13
  useNexubMessages
14
- } from "./chunk-24ZFAXB2.js";
14
+ } from "./chunk-3MSIO7KM.js";
15
15
  import {
16
16
  cn
17
17
  } from "./chunk-Q7G5WGYV.js";
@@ -1,8 +1,14 @@
1
1
  'use client';
2
+ import {
3
+ Table
4
+ } from "./chunk-BU5QD2FS.js";
2
5
  import {
3
6
  disabledContainer,
4
7
  pressable
5
- } from "./chunk-7SXR4PGO.js";
8
+ } from "./chunk-5W3AOOYS.js";
9
+ import {
10
+ useNexubMessages
11
+ } from "./chunk-3MSIO7KM.js";
6
12
  import {
7
13
  cn
8
14
  } from "./chunk-Q7G5WGYV.js";
@@ -19,20 +25,22 @@ import {
19
25
  } from "@tanstack/react-table";
20
26
  import { ArrowUp, ArrowDown, ChevronsUpDown } from "@nexub/icons";
21
27
  import { jsx, jsxs } from "react/jsx-runtime";
28
+ var alignText = {
29
+ start: "text-start",
30
+ end: "text-end",
31
+ center: "text-center"
32
+ };
33
+ var alignJustify = {
34
+ start: "justify-start",
35
+ end: "justify-end",
36
+ center: "justify-center"
37
+ };
22
38
  var pagerButton = cn(
23
39
  pressable,
24
40
  "border border-[var(--color-outline-variant)] bg-transparent px-4 py-2 min-h-[44px] text-label-lg text-[var(--color-on-surface)]",
25
41
  disabledContainer
26
42
  );
27
- var TableRoot = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "w-full overflow-auto", children: /* @__PURE__ */ jsx(
28
- "table",
29
- {
30
- ref,
31
- className: cn("w-full caption-bottom text-sm", className),
32
- ...props
33
- }
34
- ) }));
35
- TableRoot.displayName = "DataTable.TableRoot";
43
+ var TableRoot = Table.Root;
36
44
  var TableHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
37
45
  "thead",
38
46
  {
@@ -42,26 +50,21 @@ var TableHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE_
42
50
  }
43
51
  ));
44
52
  TableHeader.displayName = "DataTable.TableHeader";
45
- var TableBody = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
46
- "tbody",
47
- {
48
- ref,
49
- className: cn("[&_tr:last-child]:border-0", className),
50
- ...props
51
- }
52
- ));
53
+ var TableBody = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className: cn("[&_tr:last-child]:border-0", className), ...props }));
53
54
  TableBody.displayName = "DataTable.TableBody";
54
- var TableRow = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
55
- "tr",
56
- {
57
- ref,
58
- className: cn(
59
- "border-b border-[var(--color-outline-variant)] transition-colors hover:bg-[color-mix(in_srgb,var(--color-on-surface)_8%,transparent)] data-[state=selected]:bg-[var(--color-surface-container-low)]",
60
- className
61
- ),
62
- ...props
63
- }
64
- ));
55
+ var TableRow = React.forwardRef(
56
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
57
+ "tr",
58
+ {
59
+ ref,
60
+ className: cn(
61
+ "border-b border-[var(--color-outline-variant)] transition-colors hover:bg-[color-mix(in_srgb,var(--color-on-surface)_8%,transparent)] data-[state=selected]:bg-[var(--color-surface-container-low)]",
62
+ className
63
+ ),
64
+ ...props
65
+ }
66
+ )
67
+ );
65
68
  TableRow.displayName = "DataTable.TableRow";
66
69
  var TableHead = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
67
70
  "th",
@@ -93,9 +96,14 @@ function DataTable({
93
96
  enableSorting = false,
94
97
  enableRowSelection = false,
95
98
  pagination,
99
+ caption,
100
+ captionHidden = false,
96
101
  className,
102
+ "aria-label": ariaLabel,
103
+ "aria-labelledby": ariaLabelledBy,
97
104
  ...props
98
105
  }) {
106
+ const messages = useNexubMessages();
99
107
  const [sorting, setSorting] = React.useState([]);
100
108
  const [rowSelection, setRowSelection] = React.useState({});
101
109
  const [paginationState, setPaginationState] = React.useState({
@@ -125,30 +133,46 @@ function DataTable({
125
133
  manualPagination: false
126
134
  });
127
135
  return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4", className), ...props, children: [
128
- /* @__PURE__ */ jsxs(TableRoot, { children: [
129
- /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(
130
- TableHead,
131
- {
132
- "aria-sort": enableSorting && header.column.getCanSort() ? header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : "none" : void 0,
133
- children: header.isPlaceholder ? null : enableSorting && header.column.getCanSort() ? /* @__PURE__ */ jsxs(
134
- "button",
135
- {
136
- onClick: header.column.getToggleSortingHandler(),
137
- className: "inline-flex items-center gap-1 hover:text-[var(--color-on-surface)]",
138
- children: [
139
- flexRender(header.column.columnDef.header, header.getContext()),
140
- header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { size: "xs", "aria-hidden": "true" }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { size: "xs", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronsUpDown, { size: "xs", className: "opacity-40", "aria-hidden": "true" })
141
- ]
142
- }
143
- ) : flexRender(header.column.columnDef.header, header.getContext())
144
- },
145
- header.id
146
- )) }, headerGroup.id)) }),
136
+ /* @__PURE__ */ jsxs(TableRoot, { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children: [
137
+ caption != null && /* @__PURE__ */ jsx(Table.Caption, { className: cn(captionHidden && "sr-only"), children: caption }),
138
+ /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: headerGroup.headers.map((header) => {
139
+ const align = header.column.columnDef.meta?.align ?? "start";
140
+ return /* @__PURE__ */ jsx(
141
+ TableHead,
142
+ {
143
+ className: alignText[align],
144
+ "aria-sort": enableSorting && header.column.getCanSort() ? header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : "none" : void 0,
145
+ children: header.isPlaceholder ? null : enableSorting && header.column.getCanSort() ? /* @__PURE__ */ jsxs(
146
+ "button",
147
+ {
148
+ type: "button",
149
+ onClick: header.column.getToggleSortingHandler(),
150
+ className: cn(
151
+ "flex w-full items-center gap-1 hover:text-[var(--color-on-surface)]",
152
+ alignJustify[align]
153
+ ),
154
+ children: [
155
+ flexRender(header.column.columnDef.header, header.getContext()),
156
+ header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { size: "xs", "aria-hidden": "true" }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { size: "xs", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronsUpDown, { size: "xs", className: "opacity-40", "aria-hidden": "true" })
157
+ ]
158
+ }
159
+ ) : flexRender(header.column.columnDef.header, header.getContext())
160
+ },
161
+ header.id
162
+ );
163
+ }) }, headerGroup.id)) }),
147
164
  /* @__PURE__ */ jsx(TableBody, { children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(
148
165
  TableRow,
149
166
  {
150
167
  "data-state": enableRowSelection && row.getIsSelected() ? "selected" : void 0,
151
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
168
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
169
+ TableCell,
170
+ {
171
+ className: alignText[cell.column.columnDef.meta?.align ?? "start"],
172
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
173
+ },
174
+ cell.id
175
+ ))
152
176
  },
153
177
  row.id
154
178
  )) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(
@@ -156,34 +180,31 @@ function DataTable({
156
180
  {
157
181
  colSpan: columns.length,
158
182
  className: "h-24 text-center text-[var(--color-on-surface-muted)]",
159
- children: "No results."
183
+ children: messages.noResults
160
184
  }
161
185
  ) }) })
162
186
  ] }),
163
187
  pagination && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 text-sm text-[var(--color-on-surface-muted)]", children: [
164
- /* @__PURE__ */ jsxs("span", { children: [
165
- "Page ",
166
- table.getState().pagination.pageIndex + 1,
167
- " of ",
168
- table.getPageCount()
169
- ] }),
188
+ /* @__PURE__ */ jsx("span", { children: messages.pageOf(table.getState().pagination.pageIndex + 1, table.getPageCount()) }),
170
189
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
171
190
  /* @__PURE__ */ jsx(
172
191
  "button",
173
192
  {
193
+ type: "button",
174
194
  onClick: () => table.previousPage(),
175
195
  disabled: !table.getCanPreviousPage(),
176
196
  className: pagerButton,
177
- children: "Previous"
197
+ children: messages.previous
178
198
  }
179
199
  ),
180
200
  /* @__PURE__ */ jsx(
181
201
  "button",
182
202
  {
203
+ type: "button",
183
204
  onClick: () => table.nextPage(),
184
205
  disabled: !table.getCanNextPage(),
185
206
  className: pagerButton,
186
- children: "Next"
207
+ children: messages.next
187
208
  }
188
209
  )
189
210
  ] })
@@ -5,7 +5,7 @@ import {
5
5
  menuItem,
6
6
  menuLabel,
7
7
  menuSeparator
8
- } from "./chunk-FLZD7HQY.js";
8
+ } from "./chunk-5FWJXSXT.js";
9
9
  import {
10
10
  cn
11
11
  } from "./chunk-Q7G5WGYV.js";
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import {
3
3
  floatingSurface
4
- } from "./chunk-FLZD7HQY.js";
4
+ } from "./chunk-5FWJXSXT.js";
5
5
  import {
6
6
  cn
7
7
  } from "./chunk-Q7G5WGYV.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-JLUCMNVS.js";
5
5
  import {
6
6
  useNexubMessages
7
- } from "./chunk-24ZFAXB2.js";
7
+ } from "./chunk-3MSIO7KM.js";
8
8
  import {
9
9
  cn
10
10
  } from "./chunk-Q7G5WGYV.js";
@@ -3,7 +3,7 @@ import {
3
3
  field,
4
4
  fieldFocusVisible,
5
5
  fieldInvalid
6
- } from "./chunk-7SXR4PGO.js";
6
+ } from "./chunk-5W3AOOYS.js";
7
7
  import {
8
8
  cn
9
9
  } from "./chunk-Q7G5WGYV.js";
@@ -0,0 +1,148 @@
1
+ 'use client';
2
+ import {
3
+ cn
4
+ } from "./chunk-Q7G5WGYV.js";
5
+
6
+ // src/components/Table/Table.tsx
7
+ import * as React from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var CaptionIdContext = React.createContext(void 0);
10
+ var Root = React.forwardRef(
11
+ ({ className, scrollLabel, ...props }, ref) => {
12
+ const wrapperRef = React.useRef(null);
13
+ const tableRef = React.useRef(null);
14
+ const captionId = React.useId();
15
+ const [overflow, setOverflow] = React.useState(null);
16
+ React.useEffect(() => {
17
+ const wrapper = wrapperRef.current;
18
+ if (!wrapper) return;
19
+ const measure = () => {
20
+ if (wrapper.scrollWidth > wrapper.clientWidth) {
21
+ const id = tableRef.current?.caption?.id || null;
22
+ setOverflow((prev) => prev && prev.captionId === id ? prev : { captionId: id });
23
+ } else {
24
+ setOverflow(null);
25
+ }
26
+ };
27
+ measure();
28
+ if (typeof ResizeObserver === "undefined") return;
29
+ const ro = new ResizeObserver(measure);
30
+ ro.observe(wrapper);
31
+ if (tableRef.current) ro.observe(tableRef.current);
32
+ return () => ro.disconnect();
33
+ }, []);
34
+ const setRefs = (el) => {
35
+ tableRef.current = el;
36
+ if (typeof ref === "function") ref(el);
37
+ else if (ref) ref.current = el;
38
+ };
39
+ const label = scrollLabel ?? props["aria-label"];
40
+ const labelledBy = label ? void 0 : props["aria-labelledby"] ?? overflow?.captionId ?? void 0;
41
+ const named = Boolean(label || labelledBy);
42
+ return /* @__PURE__ */ jsx(CaptionIdContext.Provider, { value: captionId, children: /* @__PURE__ */ jsx(
43
+ "div",
44
+ {
45
+ ref: wrapperRef,
46
+ className: "relative w-full overflow-auto",
47
+ ...overflow ? {
48
+ tabIndex: 0,
49
+ ...named ? { role: "region", "aria-label": label, "aria-labelledby": labelledBy } : {}
50
+ } : {},
51
+ children: /* @__PURE__ */ jsx(
52
+ "table",
53
+ {
54
+ ref: setRefs,
55
+ className: cn("w-full caption-bottom text-sm tabular-nums", className),
56
+ ...props
57
+ }
58
+ )
59
+ }
60
+ ) });
61
+ }
62
+ );
63
+ Root.displayName = "Table.Root";
64
+ var Header = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
65
+ Header.displayName = "Table.Header";
66
+ var Body = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className: cn("[&_tr:last-child]:border-0", className), ...props }));
67
+ Body.displayName = "Table.Body";
68
+ var TableFooter = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
69
+ "tfoot",
70
+ {
71
+ ref,
72
+ className: cn(
73
+ "border-t bg-[var(--color-surface-container-low)] font-medium [&>tr]:last:border-b-0",
74
+ className
75
+ ),
76
+ ...props
77
+ }
78
+ ));
79
+ TableFooter.displayName = "Table.Footer";
80
+ var Row = React.forwardRef(
81
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
82
+ "tr",
83
+ {
84
+ ref,
85
+ className: cn(
86
+ "border-b border-[var(--color-outline-variant)] transition-colors hover:bg-[color-mix(in_srgb,var(--color-surface-container-low)_50%,transparent)] data-[state=selected]:bg-[var(--color-surface-container-low)]",
87
+ className
88
+ ),
89
+ ...props
90
+ }
91
+ )
92
+ );
93
+ Row.displayName = "Table.Row";
94
+ var Head = React.forwardRef(
95
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
96
+ "th",
97
+ {
98
+ ref,
99
+ className: cn(
100
+ "h-10 px-4 text-start align-middle font-medium text-[var(--color-on-surface-muted)] [&:has([role=checkbox])]:pe-0 [&>[role=checkbox]]:translate-y-[2px]",
101
+ className
102
+ ),
103
+ ...props
104
+ }
105
+ )
106
+ );
107
+ Head.displayName = "Table.Head";
108
+ var Cell = React.forwardRef(
109
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
110
+ "td",
111
+ {
112
+ ref,
113
+ className: cn(
114
+ "p-4 align-middle [&:has([role=checkbox])]:pe-0 [&>[role=checkbox]]:translate-y-[2px]",
115
+ className
116
+ ),
117
+ ...props
118
+ }
119
+ )
120
+ );
121
+ Cell.displayName = "Table.Cell";
122
+ var Caption = React.forwardRef(({ className, id, ...props }, ref) => {
123
+ const contextId = React.useContext(CaptionIdContext);
124
+ return /* @__PURE__ */ jsx(
125
+ "caption",
126
+ {
127
+ ref,
128
+ id: id ?? contextId,
129
+ className: cn("mt-4 text-sm text-[var(--color-on-surface-muted)]", className),
130
+ ...props
131
+ }
132
+ );
133
+ });
134
+ Caption.displayName = "Table.Caption";
135
+ var Table = {
136
+ Root,
137
+ Header,
138
+ Body,
139
+ Footer: TableFooter,
140
+ Row,
141
+ Head,
142
+ Cell,
143
+ Caption
144
+ };
145
+
146
+ export {
147
+ Table
148
+ };