@gerege-systems/ui 0.14.1 → 0.15.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 (34) hide show
  1. package/dist-lib/components/ui/Avatar.js +1 -0
  2. package/dist-lib/components/ui/Avatar.js.map +1 -1
  3. package/dist-lib/components/ui/DataGrid.d.ts +7 -2
  4. package/dist-lib/components/ui/DataGrid.js +66 -54
  5. package/dist-lib/components/ui/DataGrid.js.map +1 -1
  6. package/dist-lib/components/ui/DesignSystemProvider.js +25 -25
  7. package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
  8. package/dist-lib/components/ui/Dialog.d.ts +5 -1
  9. package/dist-lib/components/ui/Dialog.js +54 -57
  10. package/dist-lib/components/ui/Dialog.js.map +1 -1
  11. package/dist-lib/components/ui/ErrorState.d.ts +5 -3
  12. package/dist-lib/components/ui/ErrorState.js +1 -1
  13. package/dist-lib/components/ui/ErrorState.js.map +1 -1
  14. package/dist-lib/components/ui/FileUpload.d.ts +6 -0
  15. package/dist-lib/components/ui/FileUpload.js +60 -55
  16. package/dist-lib/components/ui/FileUpload.js.map +1 -1
  17. package/dist-lib/components/ui/MultiSelect.js +40 -39
  18. package/dist-lib/components/ui/MultiSelect.js.map +1 -1
  19. package/dist-lib/components/ui/RelativeTime.d.ts +5 -1
  20. package/dist-lib/components/ui/RelativeTime.js +23 -19
  21. package/dist-lib/components/ui/RelativeTime.js.map +1 -1
  22. package/dist-lib/components/ui/Sidebar.d.ts +3 -1
  23. package/dist-lib/components/ui/Sidebar.js +97 -97
  24. package/dist-lib/components/ui/Sidebar.js.map +1 -1
  25. package/dist-lib/components/ui/Slider.js +28 -28
  26. package/dist-lib/components/ui/Slider.js.map +1 -1
  27. package/dist-lib/lib/strings.d.ts +4 -0
  28. package/dist-lib/lib/strings.js +3 -1
  29. package/dist-lib/lib/strings.js.map +1 -1
  30. package/dist-lib/lib/strings.mn.js +3 -1
  31. package/dist-lib/lib/strings.mn.js.map +1 -1
  32. package/dist-lib/styles.css +1 -1
  33. package/dist-lib/theme.css +25 -21
  34. package/package.json +1 -1
@@ -1,36 +1,36 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as h, Fragment as P } from "react/jsx-runtime";
3
- import { forwardRef as j, useState as _, useContext as k, useId as T, createContext as G } from "react";
4
- import { Slot as R } from "@radix-ui/react-slot";
5
- import { ChevronsRight as D, ChevronsLeft as F, ChevronDown as L } from "../../icons/index.js";
6
- import { cn as u } from "../../lib/utils.js";
7
- import { useStrings as q } from "../../hooks/use-strings.js";
8
- import { TooltipProvider as A, Tooltip as B } from "./Tooltip.js";
9
- const y = G({ collapsed: !1 });
10
- function Z() {
2
+ import { jsx as e, jsxs as v, Fragment as j } from "react/jsx-runtime";
3
+ import { forwardRef as P, useState as T, useContext as k, useId as G, isValidElement as R, cloneElement as D, createContext as F } from "react";
4
+ import { Slot as L } from "@radix-ui/react-slot";
5
+ import { ChevronsRight as V, ChevronsLeft as q, ChevronDown as A } from "../../icons/index.js";
6
+ import { cn as f } from "../../lib/utils.js";
7
+ import { useStrings as B } from "../../hooks/use-strings.js";
8
+ import { TooltipProvider as H, Tooltip as J } from "./Tooltip.js";
9
+ const y = F({ collapsed: !1 });
10
+ function ee() {
11
11
  return k(y);
12
12
  }
13
- const E = j(function({
14
- defaultCollapsed: c = !1,
15
- collapsed: a,
16
- onCollapsedChange: l,
13
+ const K = P(function({
14
+ defaultCollapsed: d = !1,
15
+ collapsed: n,
16
+ onCollapsedChange: a,
17
17
  header: t,
18
18
  footer: i,
19
19
  className: x,
20
- children: b,
21
- "aria-label": v,
20
+ children: p,
21
+ "aria-label": h,
22
22
  ...g
23
- }, s) {
24
- const o = q(), [d, n] = _(c), r = a ?? d, p = (f) => {
25
- a === void 0 && n(f), l == null || l(f);
23
+ }, m) {
24
+ const s = B(), [l, o] = T(d), r = n ?? l, c = (u) => {
25
+ n === void 0 && o(u), a == null || a(u);
26
26
  };
27
- return /* @__PURE__ */ e(y.Provider, { value: { collapsed: r }, children: /* @__PURE__ */ h(
27
+ return /* @__PURE__ */ e(y.Provider, { value: { collapsed: r }, children: /* @__PURE__ */ v(
28
28
  "nav",
29
29
  {
30
30
  "data-slot": "sidebar",
31
- ref: s,
32
- "aria-label": v ?? o.sidebar.label,
33
- className: u(
31
+ ref: m,
32
+ "aria-label": h ?? s.sidebar.label,
33
+ className: f(
34
34
  "border-border bg-background-subtle sticky top-0 hidden h-dvh shrink-0 flex-col gap-2 border-r md:flex",
35
35
  // Deliberate motion exception: the rail's own width transitions (layout).
36
36
  // Only the rail and the main column it flanks move; no content inside reflows.
@@ -43,31 +43,31 @@ const E = j(function({
43
43
  t && /* @__PURE__ */ e(
44
44
  "div",
45
45
  {
46
- className: u(
46
+ className: f(
47
47
  "border-border flex h-14 shrink-0 items-center overflow-hidden border-b",
48
48
  r ? "justify-center px-2" : "px-3"
49
49
  ),
50
50
  children: t
51
51
  }
52
52
  ),
53
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto py-3", children: b }),
53
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto py-3", children: p }),
54
54
  i && /* @__PURE__ */ e("div", { className: "border-border border-t p-2", children: i }),
55
- /* @__PURE__ */ h(
55
+ /* @__PURE__ */ v(
56
56
  "button",
57
57
  {
58
58
  type: "button",
59
- onClick: () => p(!r),
60
- "aria-label": r ? o.sidebar.expand : o.sidebar.collapse,
59
+ onClick: () => c(!r),
60
+ "aria-label": r ? s.sidebar.expand : s.sidebar.collapse,
61
61
  "aria-expanded": !r,
62
- className: u(
62
+ className: f(
63
63
  "text-foreground-subtle mx-2 mb-2 flex h-8 items-center gap-2 rounded-md px-2",
64
64
  "hover:bg-background-muted hover:text-foreground outline-hidden",
65
65
  "focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2",
66
66
  "transition-colors duration-[var(--duration-fast)]"
67
67
  ),
68
68
  children: [
69
- r ? /* @__PURE__ */ e(D, { className: "size-4", "aria-hidden": !0 }) : /* @__PURE__ */ e(F, { className: "size-4", "aria-hidden": !0 }),
70
- !r && /* @__PURE__ */ e("span", { className: "text-xs font-medium", children: o.sidebar.collapseShort })
69
+ r ? /* @__PURE__ */ e(V, { className: "size-4", "aria-hidden": !0 }) : /* @__PURE__ */ e(q, { className: "size-4", "aria-hidden": !0 }),
70
+ !r && /* @__PURE__ */ e("span", { className: "text-xs font-medium", children: s.sidebar.collapseShort })
71
71
  ]
72
72
  }
73
73
  )
@@ -75,143 +75,143 @@ const E = j(function({
75
75
  }
76
76
  ) });
77
77
  });
78
- E.displayName = "Sidebar";
79
- function H({ label: m, className: c, children: a, ...l }) {
80
- const { collapsed: t } = k(y), i = T();
81
- return /* @__PURE__ */ h("div", { className: u("mb-3", c), ...l, children: [
82
- m && // Kept in the DOM (sr-only) while collapsed so the list stays labelled.
78
+ K.displayName = "Sidebar";
79
+ function M({ label: b, className: d, children: n, ...a }) {
80
+ const { collapsed: t } = k(y), i = G();
81
+ return /* @__PURE__ */ v("div", { className: f("mb-3", d), ...a, children: [
82
+ b && // Kept in the DOM (sr-only) while collapsed so the list stays labelled.
83
83
  /* @__PURE__ */ e(
84
84
  "div",
85
85
  {
86
86
  id: i,
87
- className: u(
87
+ className: f(
88
88
  "text-foreground-subtle px-4 pt-2 pb-1 text-xs font-medium",
89
89
  t && "sr-only"
90
90
  ),
91
- children: m
91
+ children: b
92
92
  }
93
93
  ),
94
- /* @__PURE__ */ e("ul", { "aria-labelledby": m ? i : void 0, className: "flex flex-col gap-px", children: a })
94
+ /* @__PURE__ */ e("ul", { "aria-labelledby": b ? i : void 0, className: "flex flex-col gap-px", children: n })
95
95
  ] });
96
96
  }
97
- H.displayName = "SidebarSection";
98
- const J = j(
99
- function(c, a) {
100
- const { icon: l, active: t, trailing: i, sub: x, tooltip: b, asChild: v, className: g, children: s, ...o } = c, { collapsed: d } = k(y), n = u(
97
+ M.displayName = "SidebarSection";
98
+ const Q = P(
99
+ function(d, n) {
100
+ const { icon: a, active: t, trailing: i, sub: x, tooltip: p, asChild: h, className: g, children: m, ...s } = d, { collapsed: l } = k(y), o = f(
101
101
  "flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm outline-hidden",
102
102
  "transition-colors duration-[var(--duration-fast)]",
103
103
  "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
104
104
  t ? "bg-background-muted text-foreground font-medium" : "text-foreground-muted hover:bg-background-muted hover:text-foreground",
105
- x && !d && "ml-6",
106
- d && "justify-center",
105
+ x && !l && "ml-6",
106
+ l && "justify-center",
107
107
  g
108
- ), r = typeof s == "string" ? s : void 0, p = b ?? r, f = d && !!p, z = /* @__PURE__ */ h(P, { children: [
109
- l && /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center [&_svg]:size-4", children: l }),
110
- d ? /* @__PURE__ */ e("span", { className: "sr-only", children: s }) : /* @__PURE__ */ e("span", { className: "flex-1 truncate text-left", title: r, children: s }),
111
- !d && i && /* @__PURE__ */ e("span", { className: "ml-auto", children: i })
108
+ ), r = h && R(m) ? m : null, c = r ? r.props.children : m, u = typeof c == "string" ? c : void 0, _ = p ?? u, E = l && !!_, w = /* @__PURE__ */ v(j, { children: [
109
+ a && /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center [&_svg]:size-4", children: a }),
110
+ l ? /* @__PURE__ */ e("span", { className: "sr-only", children: c }) : /* @__PURE__ */ e("span", { className: "flex-1 truncate text-left", title: u, children: c }),
111
+ !l && i && /* @__PURE__ */ e("span", { className: "ml-auto", children: i })
112
112
  ] });
113
113
  let N;
114
- if (v) {
115
- const { href: w, type: S, ...I } = o;
114
+ if (h) {
115
+ const { href: I, type: S, ...z } = s;
116
116
  N = /* @__PURE__ */ e(
117
- R,
117
+ L,
118
118
  {
119
- ref: a,
119
+ ref: n,
120
120
  "aria-current": t ? "page" : void 0,
121
- className: n,
122
- ...I,
123
- children: s && typeof s == "object" && "props" in s ? s : null
121
+ className: o,
122
+ ...z,
123
+ children: r ? D(r, void 0, w) : null
124
124
  }
125
125
  );
126
- } else if (o.href !== void 0) {
127
- const { href: w, ...S } = o;
126
+ } else if (s.href !== void 0) {
127
+ const { href: I, ...S } = s;
128
128
  N = /* @__PURE__ */ e(
129
129
  "a",
130
130
  {
131
- ref: a,
132
- href: w,
131
+ ref: n,
132
+ href: I,
133
133
  "aria-current": t ? "page" : void 0,
134
- className: n,
134
+ className: o,
135
135
  ...S,
136
- children: z
136
+ children: w
137
137
  }
138
138
  );
139
139
  } else {
140
140
  const {
141
- href: w,
141
+ href: I,
142
142
  type: S,
143
- ...I
144
- } = o;
143
+ ...z
144
+ } = s;
145
145
  N = /* @__PURE__ */ e(
146
146
  "button",
147
147
  {
148
- ref: a,
148
+ ref: n,
149
149
  type: S ?? "button",
150
150
  "aria-current": t ? "page" : void 0,
151
- className: n,
152
- ...I,
153
- children: z
151
+ className: o,
152
+ ...z,
153
+ children: w
154
154
  }
155
155
  );
156
156
  }
157
- return /* @__PURE__ */ e("li", { className: "px-2", children: f ? (
157
+ return /* @__PURE__ */ e("li", { className: "px-2", children: E ? (
158
158
  // Own provider: a collapsed rail must not crash an app that never
159
159
  // mounted <TooltipProvider>; an outer provider still wins for delays.
160
- /* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(B, { label: p, side: "right", children: N }) })
160
+ /* @__PURE__ */ e(H, { children: /* @__PURE__ */ e(J, { label: _, side: "right", children: N }) })
161
161
  ) : N });
162
162
  }
163
163
  );
164
- J.displayName = "SidebarItem";
165
- const K = j(function({
166
- icon: c,
167
- label: a,
168
- defaultOpen: l = !0,
164
+ Q.displayName = "SidebarItem";
165
+ const U = P(function({
166
+ icon: d,
167
+ label: n,
168
+ defaultOpen: a = !0,
169
169
  open: t,
170
170
  onOpenChange: i,
171
171
  className: x,
172
- children: b,
173
- ...v
172
+ children: p,
173
+ ...h
174
174
  }, g) {
175
- const { collapsed: s } = k(y), [o, d] = _(l), n = t ?? o, r = T(), p = () => {
176
- const f = !n;
177
- t === void 0 && d(f), i == null || i(f);
175
+ const { collapsed: m } = k(y), [s, l] = T(a), o = t ?? s, r = G(), c = () => {
176
+ const u = !o;
177
+ t === void 0 && l(u), i == null || i(u);
178
178
  };
179
- return s ? /* @__PURE__ */ e(P, { children: b }) : /* @__PURE__ */ h("li", { ref: g, className: x, ...v, children: [
180
- /* @__PURE__ */ h(
179
+ return m ? /* @__PURE__ */ e(j, { children: p }) : /* @__PURE__ */ v("li", { ref: g, className: x, ...h, children: [
180
+ /* @__PURE__ */ v(
181
181
  "button",
182
182
  {
183
183
  type: "button",
184
- onClick: p,
185
- "aria-controls": n ? r : void 0,
186
- "aria-expanded": n,
187
- className: u(
184
+ onClick: c,
185
+ "aria-controls": o ? r : void 0,
186
+ "aria-expanded": o,
187
+ className: f(
188
188
  "text-foreground-muted mx-2 flex h-8 w-[calc(100%-1rem)] items-center gap-2 rounded-md px-2 text-sm outline-hidden",
189
189
  "transition-colors duration-[var(--duration-fast)]",
190
190
  "hover:bg-background-muted hover:text-foreground",
191
191
  "focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2"
192
192
  ),
193
193
  children: [
194
- c && /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center [&_svg]:size-4", children: c }),
195
- /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: a }),
194
+ d && /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center [&_svg]:size-4", children: d }),
195
+ /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: n }),
196
196
  /* @__PURE__ */ e(
197
- L,
197
+ A,
198
198
  {
199
- className: u("size-3.5 transition-transform", n && "rotate-180"),
199
+ className: f("size-3.5 transition-transform", o && "rotate-180"),
200
200
  "aria-hidden": !0
201
201
  }
202
202
  )
203
203
  ]
204
204
  }
205
205
  ),
206
- n && /* @__PURE__ */ e("ul", { id: r, className: "flex flex-col gap-px", children: b })
206
+ o && /* @__PURE__ */ e("ul", { id: r, className: "flex flex-col gap-px", children: p })
207
207
  ] });
208
208
  });
209
- K.displayName = "SidebarGroup";
209
+ U.displayName = "SidebarGroup";
210
210
  export {
211
- E as Sidebar,
212
- K as SidebarGroup,
213
- J as SidebarItem,
214
- H as SidebarSection,
215
- Z as useSidebar
211
+ K as Sidebar,
212
+ U as SidebarGroup,
213
+ Q as SidebarItem,
214
+ M as SidebarSection,
215
+ ee as useSidebar
216
216
  };
217
217
  //# sourceMappingURL=Sidebar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar.js","sources":["../../../src/components/ui/Sidebar.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n forwardRef,\n useContext,\n useId,\n useState,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { ChevronDown, ChevronsLeft, ChevronsRight } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { Tooltip, TooltipProvider } from './Tooltip';\n\ninterface SidebarContextValue {\n collapsed: boolean;\n}\nconst SidebarContext = createContext<SidebarContextValue>({ collapsed: false });\n\n/** Read the parent Sidebar's collapsed state. Useful for brand/footer slots\n * that need to swap between full and compact rendering. */\nexport function useSidebar(): SidebarContextValue {\n return useContext(SidebarContext);\n}\n\nexport interface SidebarProps extends HTMLAttributes<HTMLElement> {\n /** Default state on first mount. Use `defaultCollapsed` for uncontrolled. */\n defaultCollapsed?: boolean;\n /** Controlled collapsed state. */\n collapsed?: boolean;\n /** Called when the user toggles via the rail or keyboard. */\n onCollapsedChange?: (next: boolean) => void;\n /** Header slot pinned to the top (brand, workspace switcher, etc.). */\n header?: ReactNode;\n /** Footer slot pinned to the bottom (user card, version, etc.). */\n footer?: ReactNode;\n}\n\n/**\n * App-level navigation rail. Holds `SidebarSection` → `SidebarItem` lists,\n * and optionally a `footer`. Supports collapse to icon-only on desktop.\n * Below `md` the rail is hidden — pair it with a Sheet / Drawer for mobile.\n *\n * @example\n * <Sidebar footer={<UserCard />}>\n * <SidebarSection label=\"Workspace\">\n * <SidebarItem icon={<Home />} active>Home</SidebarItem>\n * <SidebarItem icon={<Folder />}>Projects</SidebarItem>\n * </SidebarSection>\n * <SidebarSection label=\"Account\">\n * <SidebarItem icon={<Settings />}>Settings</SidebarItem>\n * </SidebarSection>\n * </Sidebar>\n *\n * @do Use 1–3 sections. More than that signals the IA needs restructuring.\n * @dont Hide critical navigation under the collapsed state — keep icons\n * always visible with tooltips.\n */\nexport const Sidebar = forwardRef<HTMLElement, SidebarProps>(function Sidebar(\n {\n defaultCollapsed = false,\n collapsed: controlled,\n onCollapsedChange,\n header,\n footer,\n className,\n children,\n 'aria-label': ariaLabel,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const [internal, setInternal] = useState(defaultCollapsed);\n const collapsed = controlled ?? internal;\n const setCollapsed = (next: boolean) => {\n if (controlled === undefined) setInternal(next);\n onCollapsedChange?.(next);\n };\n\n return (\n <SidebarContext.Provider value={{ collapsed }}>\n <nav\n data-slot=\"sidebar\"\n ref={ref}\n aria-label={ariaLabel ?? strings.sidebar.label}\n className={cn(\n 'border-border bg-background-subtle sticky top-0 hidden h-dvh shrink-0 flex-col gap-2 border-r md:flex',\n // Deliberate motion exception: the rail's own width transitions (layout).\n // Only the rail and the main column it flanks move; no content inside reflows.\n 'transition-[width] duration-[var(--duration-base)] ease-[var(--ease-out)] motion-reduce:transition-none',\n collapsed ? 'w-14' : 'w-60',\n className,\n )}\n {...props}\n >\n {header && (\n <div\n className={cn(\n 'border-border flex h-14 shrink-0 items-center overflow-hidden border-b',\n collapsed ? 'justify-center px-2' : 'px-3',\n )}\n >\n {header}\n </div>\n )}\n <div className=\"flex-1 overflow-y-auto py-3\">{children}</div>\n {footer && <div className=\"border-border border-t p-2\">{footer}</div>}\n <button\n type=\"button\"\n onClick={() => setCollapsed(!collapsed)}\n aria-label={collapsed ? strings.sidebar.expand : strings.sidebar.collapse}\n aria-expanded={!collapsed}\n className={cn(\n 'text-foreground-subtle mx-2 mb-2 flex h-8 items-center gap-2 rounded-md px-2',\n 'hover:bg-background-muted hover:text-foreground outline-hidden',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n {collapsed ? (\n <ChevronsRight className=\"size-4\" aria-hidden />\n ) : (\n <ChevronsLeft className=\"size-4\" aria-hidden />\n )}\n {!collapsed && (\n <span className=\"text-xs font-medium\">{strings.sidebar.collapseShort}</span>\n )}\n </button>\n </nav>\n </SidebarContext.Provider>\n );\n});\nSidebar.displayName = 'Sidebar';\n\nexport interface SidebarSectionProps extends HTMLAttributes<HTMLDivElement> {\n /** Visible section header. Hidden when collapsed. */\n label?: ReactNode;\n}\n\nexport function SidebarSection({ label, className, children, ...props }: SidebarSectionProps) {\n const { collapsed } = useContext(SidebarContext);\n const labelId = useId();\n return (\n <div className={cn('mb-3', className)} {...props}>\n {label && (\n // Kept in the DOM (sr-only) while collapsed so the list stays labelled.\n <div\n id={labelId}\n className={cn(\n 'text-foreground-subtle px-4 pt-2 pb-1 text-xs font-medium',\n collapsed && 'sr-only',\n )}\n >\n {label}\n </div>\n )}\n <ul aria-labelledby={label ? labelId : undefined} className=\"flex flex-col gap-px\">\n {children}\n </ul>\n </div>\n );\n}\nSidebarSection.displayName = 'SidebarSection';\n\ninterface SidebarItemBaseProps {\n /** Lucide icon shown to the left. */\n icon?: ReactNode;\n /** Mark as the current page. */\n active?: boolean;\n /** Trailing badge / counter slot. */\n trailing?: ReactNode;\n /** Render a sub-item indented under a parent. */\n sub?: boolean;\n /**\n * Tooltip text shown while the sidebar is collapsed. Defaults to `children`\n * when that is a plain string.\n */\n tooltip?: ReactNode;\n /**\n * Render the child element (router `<Link>`) instead of `<a>`/`<button>`.\n * The child receives className, aria-current and the item content.\n */\n asChild?: boolean;\n}\n\ntype SidebarItemAnchorProps = SidebarItemBaseProps &\n AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** Renders an `<a>`. Omit to render a `<button>`. */\n href: string;\n };\n\ntype SidebarItemButtonProps = SidebarItemBaseProps &\n ButtonHTMLAttributes<HTMLButtonElement> & {\n href?: undefined;\n };\n\n/** Discriminated on `href`: with it the item is an anchor, without it a button. */\nexport type SidebarItemProps = SidebarItemAnchorProps | SidebarItemButtonProps;\n\nexport const SidebarItem = forwardRef<HTMLElement, SidebarItemProps>(\n function SidebarItem(props, ref) {\n const { icon, active, trailing, sub, tooltip, asChild, className, children, ...rest } = props;\n const { collapsed } = useContext(SidebarContext);\n\n const classes = cn(\n 'flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm outline-hidden',\n 'transition-colors duration-[var(--duration-fast)]',\n 'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n active\n ? 'bg-background-muted text-foreground font-medium'\n : 'text-foreground-muted hover:bg-background-muted hover:text-foreground',\n sub && !collapsed && 'ml-6',\n collapsed && 'justify-center',\n className,\n );\n\n const labelTitle = typeof children === 'string' ? children : undefined;\n const tip = tooltip ?? labelTitle;\n // Collapsed: keep an sr-only label so the control always has a name —\n // the Tooltip only wires aria-describedby while it is open.\n const showTooltip = collapsed && !!tip;\n\n const content = (\n <>\n {icon && <span className=\"flex shrink-0 items-center [&_svg]:size-4\">{icon}</span>}\n {collapsed ? (\n <span className=\"sr-only\">{children}</span>\n ) : (\n <span className=\"flex-1 truncate text-left\" title={labelTitle}>\n {children}\n </span>\n )}\n {!collapsed && trailing && <span className=\"ml-auto\">{trailing}</span>}\n </>\n );\n\n let element: ReactNode;\n if (asChild) {\n const { href: _href, type: _type, ...slotProps } = rest as Record<string, unknown>;\n element = (\n <Slot\n ref={ref}\n aria-current={active ? 'page' : undefined}\n className={classes}\n {...(slotProps as HTMLAttributes<HTMLElement>)}\n >\n {children && typeof children === 'object' && 'props' in (children as object)\n ? children\n : null}\n </Slot>\n );\n } else if (rest.href !== undefined) {\n const { href, ...anchorProps } = rest as Omit<\n SidebarItemAnchorProps,\n keyof SidebarItemBaseProps\n >;\n element = (\n <a\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n aria-current={active ? 'page' : undefined}\n className={classes}\n {...anchorProps}\n >\n {content}\n </a>\n );\n } else {\n const {\n href: _href,\n type,\n ...buttonProps\n } = rest as Omit<SidebarItemButtonProps, keyof SidebarItemBaseProps>;\n element = (\n <button\n ref={ref as Ref<HTMLButtonElement>}\n type={type ?? 'button'}\n aria-current={active ? 'page' : undefined}\n className={classes}\n {...buttonProps}\n >\n {content}\n </button>\n );\n }\n\n return (\n <li className=\"px-2\">\n {showTooltip ? (\n // Own provider: a collapsed rail must not crash an app that never\n // mounted <TooltipProvider>; an outer provider still wins for delays.\n <TooltipProvider>\n <Tooltip label={tip} side=\"right\">\n {element}\n </Tooltip>\n </TooltipProvider>\n ) : (\n element\n )}\n </li>\n );\n },\n);\nSidebarItem.displayName = 'SidebarItem';\n\n/** Lightweight collapsible sub-section inside the sidebar. */\nexport interface SidebarGroupProps extends Omit<HTMLAttributes<HTMLLIElement>, 'children'> {\n icon?: ReactNode;\n label: ReactNode;\n /** Initial open state (uncontrolled). */\n defaultOpen?: boolean;\n /** Controlled open state. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n children: ReactNode;\n}\n\nexport const SidebarGroup = forwardRef<HTMLLIElement, SidebarGroupProps>(function SidebarGroup(\n {\n icon,\n label,\n defaultOpen = true,\n open: controlled,\n onOpenChange,\n className,\n children,\n ...props\n },\n ref,\n) {\n const { collapsed } = useContext(SidebarContext);\n const [internal, setInternal] = useState(defaultOpen);\n const open = controlled ?? internal;\n const listId = useId();\n const toggle = () => {\n const next = !open;\n if (controlled === undefined) setInternal(next);\n onOpenChange?.(next);\n };\n if (collapsed) return <>{children}</>;\n return (\n <li ref={ref} className={className} {...props}>\n <button\n type=\"button\"\n onClick={toggle}\n aria-controls={open ? listId : undefined}\n aria-expanded={open}\n className={cn(\n 'text-foreground-muted mx-2 flex h-8 w-[calc(100%-1rem)] items-center gap-2 rounded-md px-2 text-sm outline-hidden',\n 'transition-colors duration-[var(--duration-fast)]',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n )}\n >\n {icon && <span className=\"flex shrink-0 items-center [&_svg]:size-4\">{icon}</span>}\n <span className=\"flex-1 text-left\">{label}</span>\n <ChevronDown\n className={cn('size-3.5 transition-transform', open && 'rotate-180')}\n aria-hidden\n />\n </button>\n {open && (\n <ul id={listId} className=\"flex flex-col gap-px\">\n {children}\n </ul>\n )}\n </li>\n );\n});\nSidebarGroup.displayName = 'SidebarGroup';\n"],"names":["SidebarContext","createContext","useSidebar","useContext","Sidebar","forwardRef","defaultCollapsed","controlled","onCollapsedChange","header","footer","className","children","ariaLabel","props","ref","strings","useStrings","internal","setInternal","useState","collapsed","setCollapsed","next","jsxs","cn","jsx","ChevronsRight","ChevronsLeft","SidebarSection","label","labelId","useId","SidebarItem","icon","active","trailing","sub","tooltip","asChild","rest","classes","labelTitle","tip","showTooltip","content","Fragment","element","_href","_type","slotProps","Slot","href","anchorProps","type","buttonProps","TooltipProvider","Tooltip","SidebarGroup","defaultOpen","onOpenChange","open","listId","toggle","ChevronDown"],"mappings":";;;;;;;;AAuBA,MAAMA,IAAiBC,EAAmC,EAAE,WAAW,IAAO;AAIvE,SAASC,IAAkC;AAChD,SAAOC,EAAWH,CAAc;AAClC;AAmCO,MAAMI,IAAUC,EAAsC,SAC3D;AAAA,EACE,kBAAAC,IAAmB;AAAA,EACnB,WAAWC;AAAA,EACX,mBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAcC;AAAA,EACd,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAUC,EAAA,GACV,CAACC,GAAUC,CAAW,IAAIC,EAASd,CAAgB,G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GAAK;AAAA,UAC3E,gBAAAR,EAAC,QAAA,EAAK,WAAU,oBAAoB,UAAAI,GAAM;AAAA,UAC1C,gBAAAJ;AAAA,YAACsC;AAAA,YAAA;AAAA,cACC,WAAWvC,EAAG,iCAAiCoC,KAAQ,YAAY;AAAA,cACnE,eAAW;AAAA,YAAA;AAAA,UAAA;AAAA,QACb;AAAA,MAAA;AAAA,IAAA;AAAA,IAEDA,KACC,gBAAAnC,EAAC,MAAA,EAAG,IAAIoC,GAAQ,WAAU,wBACvB,UAAAlD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ,CAAC;AACD8C,EAAa,cAAc;"}
1
+ {"version":3,"file":"Sidebar.js","sources":["../../../src/components/ui/Sidebar.tsx"],"sourcesContent":["'use client';\n\nimport {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n useId,\n useState,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { ChevronDown, ChevronsLeft, ChevronsRight } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { Tooltip, TooltipProvider } from './Tooltip';\n\ninterface SidebarContextValue {\n collapsed: boolean;\n}\nconst SidebarContext = createContext<SidebarContextValue>({ collapsed: false });\n\n/** Read the parent Sidebar's collapsed state. Useful for brand/footer slots\n * that need to swap between full and compact rendering. */\nexport function useSidebar(): SidebarContextValue {\n return useContext(SidebarContext);\n}\n\nexport interface SidebarProps extends HTMLAttributes<HTMLElement> {\n /** Default state on first mount. Use `defaultCollapsed` for uncontrolled. */\n defaultCollapsed?: boolean;\n /** Controlled collapsed state. */\n collapsed?: boolean;\n /** Called when the user toggles via the rail or keyboard. */\n onCollapsedChange?: (next: boolean) => void;\n /** Header slot pinned to the top (brand, workspace switcher, etc.). */\n header?: ReactNode;\n /** Footer slot pinned to the bottom (user card, version, etc.). */\n footer?: ReactNode;\n}\n\n/**\n * App-level navigation rail. Holds `SidebarSection` → `SidebarItem` lists,\n * and optionally a `footer`. Supports collapse to icon-only on desktop.\n * Below `md` the rail is hidden — pair it with a Sheet / Drawer for mobile.\n *\n * @example\n * <Sidebar footer={<UserCard />}>\n * <SidebarSection label=\"Workspace\">\n * <SidebarItem icon={<Home />} active>Home</SidebarItem>\n * <SidebarItem icon={<Folder />}>Projects</SidebarItem>\n * </SidebarSection>\n * <SidebarSection label=\"Account\">\n * <SidebarItem icon={<Settings />}>Settings</SidebarItem>\n * </SidebarSection>\n * </Sidebar>\n *\n * @do Use 1–3 sections. More than that signals the IA needs restructuring.\n * @dont Hide critical navigation under the collapsed state — keep icons\n * always visible with tooltips.\n */\nexport const Sidebar = forwardRef<HTMLElement, SidebarProps>(function Sidebar(\n {\n defaultCollapsed = false,\n collapsed: controlled,\n onCollapsedChange,\n header,\n footer,\n className,\n children,\n 'aria-label': ariaLabel,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const [internal, setInternal] = useState(defaultCollapsed);\n const collapsed = controlled ?? internal;\n const setCollapsed = (next: boolean) => {\n if (controlled === undefined) setInternal(next);\n onCollapsedChange?.(next);\n };\n\n return (\n <SidebarContext.Provider value={{ collapsed }}>\n <nav\n data-slot=\"sidebar\"\n ref={ref}\n aria-label={ariaLabel ?? strings.sidebar.label}\n className={cn(\n 'border-border bg-background-subtle sticky top-0 hidden h-dvh shrink-0 flex-col gap-2 border-r md:flex',\n // Deliberate motion exception: the rail's own width transitions (layout).\n // Only the rail and the main column it flanks move; no content inside reflows.\n 'transition-[width] duration-[var(--duration-base)] ease-[var(--ease-out)] motion-reduce:transition-none',\n collapsed ? 'w-14' : 'w-60',\n className,\n )}\n {...props}\n >\n {header && (\n <div\n className={cn(\n 'border-border flex h-14 shrink-0 items-center overflow-hidden border-b',\n collapsed ? 'justify-center px-2' : 'px-3',\n )}\n >\n {header}\n </div>\n )}\n <div className=\"flex-1 overflow-y-auto py-3\">{children}</div>\n {footer && <div className=\"border-border border-t p-2\">{footer}</div>}\n <button\n type=\"button\"\n onClick={() => setCollapsed(!collapsed)}\n aria-label={collapsed ? strings.sidebar.expand : strings.sidebar.collapse}\n aria-expanded={!collapsed}\n className={cn(\n 'text-foreground-subtle mx-2 mb-2 flex h-8 items-center gap-2 rounded-md px-2',\n 'hover:bg-background-muted hover:text-foreground outline-hidden',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n {collapsed ? (\n <ChevronsRight className=\"size-4\" aria-hidden />\n ) : (\n <ChevronsLeft className=\"size-4\" aria-hidden />\n )}\n {!collapsed && (\n <span className=\"text-xs font-medium\">{strings.sidebar.collapseShort}</span>\n )}\n </button>\n </nav>\n </SidebarContext.Provider>\n );\n});\nSidebar.displayName = 'Sidebar';\n\nexport interface SidebarSectionProps extends HTMLAttributes<HTMLDivElement> {\n /** Visible section header. Hidden when collapsed. */\n label?: ReactNode;\n}\n\nexport function SidebarSection({ label, className, children, ...props }: SidebarSectionProps) {\n const { collapsed } = useContext(SidebarContext);\n const labelId = useId();\n return (\n <div className={cn('mb-3', className)} {...props}>\n {label && (\n // Kept in the DOM (sr-only) while collapsed so the list stays labelled.\n <div\n id={labelId}\n className={cn(\n 'text-foreground-subtle px-4 pt-2 pb-1 text-xs font-medium',\n collapsed && 'sr-only',\n )}\n >\n {label}\n </div>\n )}\n <ul aria-labelledby={label ? labelId : undefined} className=\"flex flex-col gap-px\">\n {children}\n </ul>\n </div>\n );\n}\nSidebarSection.displayName = 'SidebarSection';\n\ninterface SidebarItemBaseProps {\n /** Lucide icon shown to the left. */\n icon?: ReactNode;\n /** Mark as the current page. */\n active?: boolean;\n /** Trailing badge / counter slot. */\n trailing?: ReactNode;\n /** Render a sub-item indented under a parent. */\n sub?: boolean;\n /**\n * Tooltip text shown while the sidebar is collapsed. Defaults to `children`\n * when that is a plain string.\n */\n tooltip?: ReactNode;\n /**\n * Render the child element (router `<Link>`) instead of `<a>`/`<button>`.\n * The child receives className, aria-current and the item content — its own\n * children become the label, wrapped with `icon`, `trailing` and the\n * collapsed sr-only text exactly like a plain item.\n */\n asChild?: boolean;\n}\n\ntype SidebarItemAnchorProps = SidebarItemBaseProps &\n AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** Renders an `<a>`. Omit to render a `<button>`. */\n href: string;\n };\n\ntype SidebarItemButtonProps = SidebarItemBaseProps &\n ButtonHTMLAttributes<HTMLButtonElement> & {\n href?: undefined;\n };\n\n/** Discriminated on `href`: with it the item is an anchor, without it a button. */\nexport type SidebarItemProps = SidebarItemAnchorProps | SidebarItemButtonProps;\n\nexport const SidebarItem = forwardRef<HTMLElement, SidebarItemProps>(\n function SidebarItem(props, ref) {\n const { icon, active, trailing, sub, tooltip, asChild, className, children, ...rest } = props;\n const { collapsed } = useContext(SidebarContext);\n\n const classes = cn(\n 'flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm outline-hidden',\n 'transition-colors duration-[var(--duration-fast)]',\n 'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n active\n ? 'bg-background-muted text-foreground font-medium'\n : 'text-foreground-muted hover:bg-background-muted hover:text-foreground',\n sub && !collapsed && 'ml-6',\n collapsed && 'justify-center',\n className,\n );\n\n // asChild: the consumer's element is the control; its children are the label.\n const child = asChild && isValidElement<{ children?: ReactNode }>(children) ? children : null;\n const label = child ? child.props.children : children;\n const labelTitle = typeof label === 'string' ? label : undefined;\n const tip = tooltip ?? labelTitle;\n // Collapsed: keep an sr-only label so the control always has a name —\n // the Tooltip only wires aria-describedby while it is open.\n const showTooltip = collapsed && !!tip;\n\n const content = (\n <>\n {icon && <span className=\"flex shrink-0 items-center [&_svg]:size-4\">{icon}</span>}\n {collapsed ? (\n <span className=\"sr-only\">{label}</span>\n ) : (\n <span className=\"flex-1 truncate text-left\" title={labelTitle}>\n {label}\n </span>\n )}\n {!collapsed && trailing && <span className=\"ml-auto\">{trailing}</span>}\n </>\n );\n\n let element: ReactNode;\n if (asChild) {\n const { href: _href, type: _type, ...slotProps } = rest as Record<string, unknown>;\n element = (\n <Slot\n ref={ref}\n aria-current={active ? 'page' : undefined}\n className={classes}\n {...(slotProps as HTMLAttributes<HTMLElement>)}\n >\n {child ? cloneElement(child, undefined, content) : null}\n </Slot>\n );\n } else if (rest.href !== undefined) {\n const { href, ...anchorProps } = rest as Omit<\n SidebarItemAnchorProps,\n keyof SidebarItemBaseProps\n >;\n element = (\n <a\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n aria-current={active ? 'page' : undefined}\n className={classes}\n {...anchorProps}\n >\n {content}\n </a>\n );\n } else {\n const {\n href: _href,\n type,\n ...buttonProps\n } = rest as Omit<SidebarItemButtonProps, keyof SidebarItemBaseProps>;\n element = (\n <button\n ref={ref as Ref<HTMLButtonElement>}\n type={type ?? 'button'}\n aria-current={active ? 'page' : undefined}\n className={classes}\n {...buttonProps}\n >\n {content}\n </button>\n );\n }\n\n return (\n <li className=\"px-2\">\n {showTooltip ? (\n // Own provider: a collapsed rail must not crash an app that never\n // mounted <TooltipProvider>; an outer provider still wins for delays.\n <TooltipProvider>\n <Tooltip label={tip} side=\"right\">\n {element}\n </Tooltip>\n </TooltipProvider>\n ) : (\n element\n )}\n </li>\n );\n },\n);\nSidebarItem.displayName = 'SidebarItem';\n\n/** Lightweight collapsible sub-section inside the sidebar. */\nexport interface SidebarGroupProps extends Omit<HTMLAttributes<HTMLLIElement>, 'children'> {\n icon?: ReactNode;\n label: ReactNode;\n /** Initial open state (uncontrolled). */\n defaultOpen?: boolean;\n /** Controlled open state. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n children: ReactNode;\n}\n\nexport const SidebarGroup = forwardRef<HTMLLIElement, SidebarGroupProps>(function SidebarGroup(\n {\n icon,\n label,\n defaultOpen = true,\n open: controlled,\n onOpenChange,\n className,\n children,\n ...props\n },\n ref,\n) {\n const { collapsed } = useContext(SidebarContext);\n const [internal, setInternal] = useState(defaultOpen);\n const open = controlled ?? internal;\n const listId = useId();\n const toggle = () => {\n const next = !open;\n if (controlled === undefined) setInternal(next);\n onOpenChange?.(next);\n };\n if (collapsed) return <>{children}</>;\n return (\n <li ref={ref} className={className} {...props}>\n <button\n type=\"button\"\n onClick={toggle}\n aria-controls={open ? listId : undefined}\n aria-expanded={open}\n className={cn(\n 'text-foreground-muted mx-2 flex h-8 w-[calc(100%-1rem)] items-center gap-2 rounded-md px-2 text-sm outline-hidden',\n 'transition-colors duration-[var(--duration-fast)]',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n )}\n >\n {icon && <span className=\"flex shrink-0 items-center [&_svg]:size-4\">{icon}</span>}\n <span className=\"flex-1 text-left\">{label}</span>\n <ChevronDown\n className={cn('size-3.5 transition-transform', open && 'rotate-180')}\n aria-hidden\n />\n </button>\n {open && (\n <ul id={listId} className=\"flex flex-col gap-px\">\n {children}\n </ul>\n )}\n </li>\n );\n});\nSidebarGroup.displayName = 'SidebarGroup';\n"],"names":["SidebarContext","createContext","useSidebar","useContext","Sidebar","forwardRef","defaultCollapsed","controlled","onCollapsedChange","header","footer","className","children","ariaLabel","props","ref","strings","useStrings","internal","setInternal","useState","collapsed","setCollapsed","next","jsxs","cn","jsx","ChevronsRight","ChevronsLeft","SidebarSection","label","labelId","useId","SidebarItem","icon","active","trailing","sub","tooltip","asChild","rest","classes","child","isValidElement","labelTitle","tip","showTooltip","content","Fragment","element","_href","_type","slotProps","Slot","cloneElement","href","anchorProps","type","buttonProps","TooltipProvider","Tooltip","SidebarGroup","defaultOpen","onOpenChange","open","listId","toggle","ChevronDown"],"mappings":";;;;;;;;AAyBA,MAAMA,IAAiBC,EAAmC,EAAE,WAAW,IAAO;AAIvE,SAASC,KAAkC;AAChD,SAAOC,EAAWH,CAAc;AAClC;AAmCO,MAAMI,IAAUC,EAAsC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AAAY,EAAC,MAAA,EAAG,KAAAT,GAAU,WAAAJ,GAAuB,GAAGG,GACtC,UAAA;AAAA,IAAA,gBAAAU;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS0C;AAAA,QACT,iBAAeF,IAAOC,IAAS;AAAA,QAC/B,iBAAeD;AAAA,QACf,WAAWvC;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAGD,UAAA;AAAA,UAAAS,KAAQ,gBAAAR,EAAC,QAAA,EAAK,WAAU,6CAA6C,UAAAQ,GAAK;AAAA,UAC3E,gBAAAR,EAAC,QAAA,EAAK,WAAU,oBAAoB,UAAAI,GAAM;AAAA,UAC1C,gBAAAJ;AAAA,YAACyC;AAAA,YAAA;AAAA,cACC,WAAW1C,EAAG,iCAAiCuC,KAAQ,YAAY;AAAA,cACnE,eAAW;AAAA,YAAA;AAAA,UAAA;AAAA,QACb;AAAA,MAAA;AAAA,IAAA;AAAA,IAEDA,KACC,gBAAAtC,EAAC,MAAA,EAAG,IAAIuC,GAAQ,WAAU,wBACvB,UAAArD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ,CAAC;AACDiD,EAAa,cAAc;"}
@@ -1,53 +1,53 @@
1
1
  "use client";
2
- import { jsxs as u, jsx as s } from "react/jsx-runtime";
2
+ import { jsxs as b, jsx as i } from "react/jsx-runtime";
3
3
  import { forwardRef as k, useState as R, useId as j } from "react";
4
- import * as i from "@radix-ui/react-slider";
5
- import { cn as h } from "../../lib/utils.js";
4
+ import * as s from "@radix-ui/react-slider";
5
+ import { cn as p } from "../../lib/utils.js";
6
6
  import { useStrings as I } from "../../hooks/use-strings.js";
7
7
  const z = k(
8
8
  function({
9
9
  className: N,
10
10
  label: e,
11
- showValue: b,
12
- formatValue: o = (l) => String(l),
11
+ showValue: g,
12
+ formatValue: o = (d) => String(d),
13
13
  value: n,
14
- defaultValue: g,
14
+ defaultValue: v,
15
15
  onValueChange: a,
16
- ...v
16
+ ...l
17
17
  }, y) {
18
- const [l, S] = R(g ?? [0]), p = n !== void 0, r = p ? n : l, d = r.length > 1, c = j(), f = I(), m = typeof e == "string" ? e : void 0, w = (t) => d ? t === 0 ? f.slider.minimum : f.slider.maximum : m ?? v["aria-label"] ?? f.slider.value;
19
- return /* @__PURE__ */ u("div", { className: h("flex flex-col gap-2", N), children: [
20
- (e || b) && /* @__PURE__ */ u("div", { className: "flex items-center justify-between", children: [
21
- e && /* @__PURE__ */ s("span", { id: c, className: "text-foreground text-sm font-medium", children: e }),
22
- b && /* @__PURE__ */ s("span", { className: "tabular text-foreground-muted font-mono text-xs", children: d ? `${o(r[0])} – ${o(r[1])}` : o(r[0]) })
18
+ const [d, S] = R(v ?? [l.min ?? 0]), x = n !== void 0, t = x ? n : d, c = t.length > 1, f = j(), m = I(), u = typeof e == "string" ? e : void 0, w = (r) => c ? r === 0 ? m.slider.minimum : m.slider.maximum : u ?? l["aria-label"] ?? m.slider.value;
19
+ return /* @__PURE__ */ b("div", { className: p("flex flex-col gap-2", N), children: [
20
+ (e || g) && /* @__PURE__ */ b("div", { className: "flex items-center justify-between", children: [
21
+ e && /* @__PURE__ */ i("span", { id: f, className: "text-foreground text-sm font-medium", children: e }),
22
+ g && /* @__PURE__ */ i("span", { className: "tabular text-foreground-muted font-mono text-xs", children: c ? `${o(t[0])} – ${o(t[1])}` : o(t[0]) })
23
23
  ] }),
24
- /* @__PURE__ */ u(
25
- i.Root,
24
+ /* @__PURE__ */ b(
25
+ s.Root,
26
26
  {
27
27
  "data-slot": "slider",
28
28
  ref: y,
29
29
  value: n,
30
- defaultValue: g,
31
- onValueChange: (t) => {
32
- p || S(t), a == null || a(t);
30
+ defaultValue: v,
31
+ onValueChange: (r) => {
32
+ x || S(r), a == null || a(r);
33
33
  },
34
34
  className: "relative flex w-full touch-none items-center py-3.5 select-none",
35
- "aria-labelledby": e && !m ? c : void 0,
36
- ...v,
35
+ "aria-labelledby": e && !u ? f : void 0,
36
+ ...l,
37
37
  children: [
38
- /* @__PURE__ */ s(
39
- i.Track,
38
+ /* @__PURE__ */ i(
39
+ s.Track,
40
40
  {
41
41
  "data-slot": "slider-track",
42
42
  className: "bg-background-muted relative h-1 w-full grow overflow-hidden rounded-full",
43
- children: /* @__PURE__ */ s(i.Range, { className: "bg-accent absolute h-full" })
43
+ children: /* @__PURE__ */ i(s.Range, { className: "bg-accent absolute h-full" })
44
44
  }
45
45
  ),
46
- r.map((t, x) => /* @__PURE__ */ s(
47
- i.Thumb,
46
+ t.map((r, h) => /* @__PURE__ */ i(
47
+ s.Thumb,
48
48
  {
49
49
  "data-slot": "slider-thumb",
50
- className: h(
50
+ className: p(
51
51
  "border-accent bg-card relative block size-4 rounded-full border-2 shadow-sm",
52
52
  // 44px touch target without growing the visible thumb.
53
53
  'before:absolute before:top-1/2 before:left-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:content-[""]',
@@ -55,10 +55,10 @@ const z = k(
55
55
  "transition-transform duration-[var(--duration-fast)] ease-[var(--ease-out)]",
56
56
  "hover:scale-110 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
57
57
  ),
58
- "aria-label": w(x),
59
- "aria-labelledby": !d && e && !m ? c : void 0
58
+ "aria-label": w(h),
59
+ "aria-labelledby": !c && e && !u ? f : void 0
60
60
  },
61
- x
61
+ h
62
62
  ))
63
63
  ]
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sources":["../../../src/components/ui/Slider.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useId,\n useState,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type ReactNode,\n} from 'react';\nimport * as SliderPrimitive from '@radix-ui/react-slider';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface SliderProps extends Omit<\n ComponentPropsWithoutRef<typeof SliderPrimitive.Root>,\n 'value' | 'defaultValue'\n> {\n /**\n * Controlled value. Pass `[n]` for a single-thumb slider, `[a, b]` for a range slider.\n */\n value?: number[];\n defaultValue?: number[];\n /** Inline label rendered above the slider. */\n label?: ReactNode;\n /** Show the numeric value next to the label. */\n showValue?: boolean;\n /** Format the displayed value (e.g. `(v) => \\`${v}%\\``). */\n formatValue?: (value: number) => string;\n}\n\n/**\n * Single- or range-thumb slider. Pass one item in `value` for a single\n * thumb, two for a range.\n *\n * @example Single value\n * <Slider label=\"Volume\" showValue defaultValue={[60]} max={100} step={1} />\n *\n * @example Price range\n * <Slider label=\"Price\"\n * defaultValue={[50, 250]}\n * min={0} max={500} step={10}\n * formatValue={(v) => \\`$\\${v}\\`}\n * showValue />\n *\n * @do Use `showValue` when the absolute number matters (price, volume, weight).\n * @dont Hide the value when users will need to reason about exact thresholds.\n */\nexport const Slider = forwardRef<ComponentRef<typeof SliderPrimitive.Root>, SliderProps>(\n function Slider(\n {\n className,\n label,\n showValue,\n formatValue = (v) => String(v),\n value,\n defaultValue,\n onValueChange,\n ...props\n },\n ref,\n ) {\n // Uncontrolled sliders track their own value so `showValue` stays live.\n const [internal, setInternal] = useState<number[]>(defaultValue ?? [0]);\n const isControlled = value !== undefined;\n const currentValue = isControlled ? value : internal;\n const isRange = currentValue.length > 1;\n const labelId = useId();\n const strings = useStrings();\n // Only a string label can double as aria-label; ReactNode labels are\n // referenced by id instead.\n const stringLabel = typeof label === 'string' ? label : undefined;\n const thumbLabel = (i: number) =>\n isRange\n ? i === 0\n ? strings.slider.minimum\n : strings.slider.maximum\n : (stringLabel ?? props['aria-label'] ?? strings.slider.value);\n\n return (\n <div className={cn('flex flex-col gap-2', className)}>\n {(label || showValue) && (\n <div className=\"flex items-center justify-between\">\n {label && (\n <span id={labelId} className=\"text-foreground text-sm font-medium\">\n {label}\n </span>\n )}\n {showValue && (\n <span className=\"tabular text-foreground-muted font-mono text-xs\">\n {isRange\n ? `${formatValue(currentValue[0])} – ${formatValue(currentValue[1])}`\n : formatValue(currentValue[0])}\n </span>\n )}\n </div>\n )}\n\n <SliderPrimitive.Root\n data-slot=\"slider\"\n ref={ref}\n value={value}\n defaultValue={defaultValue}\n onValueChange={(v) => {\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n }}\n className=\"relative flex w-full touch-none items-center py-3.5 select-none\"\n aria-labelledby={label && !stringLabel ? labelId : undefined}\n {...props}\n >\n <SliderPrimitive.Track\n data-slot=\"slider-track\"\n className=\"bg-background-muted relative h-1 w-full grow overflow-hidden rounded-full\"\n >\n <SliderPrimitive.Range className=\"bg-accent absolute h-full\" />\n </SliderPrimitive.Track>\n {currentValue.map((_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n data-slot=\"slider-thumb\"\n className={cn(\n 'border-accent bg-card relative block size-4 rounded-full border-2 shadow-sm',\n // 44px touch target without growing the visible thumb.\n 'before:absolute before:top-1/2 before:left-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:content-[\"\"]',\n 'focus-visible:ring-ring focus-visible:ring-offset-background outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-transform duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'hover:scale-110 data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n )}\n aria-label={thumbLabel(i)}\n aria-labelledby={!isRange && label && !stringLabel ? labelId : undefined}\n />\n ))}\n </SliderPrimitive.Root>\n </div>\n );\n },\n);\n\nSlider.displayName = 'Slider';\n"],"names":["Slider","forwardRef","className","label","showValue","formatValue","v","value","defaultValue","onValueChange","props","ref","internal","setInternal","useState","isControlled","currentValue","isRange","labelId","useId","strings","useStrings","stringLabel","thumbLabel","i","cn","jsxs","SliderPrimitive","jsx","_"],"mappings":";;;;;;AAgDO,MAAMA,IAASC;AAAA,EACpB,SACE;AAAA,IACE,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC,IAAc,CAACC,MAAM,OAAOA,CAAC;AAAA,IAC7B,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,eAAA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;AAAA,gBAEV,UAAA,gBAAAC,EAACD,EAAgB,OAAhB,EAAsB,WAAU,4BAAA,CAA4B;AAAA,cAAA;AAAA,YAAA;AAAA,YAE9DX,EAAa,IAAI,CAACa,GAAGL,MACpB,gBAAAI;AAAA,cAACD,EAAgB;AAAA,cAAhB;AAAA,gBAEC,aAAU;AAAA,gBACV,WAAWF;AAAA,kBACT;AAAA;AAAA,kBAEA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,gBAAA;AAAA,gBAEF,cAAYF,EAAWC,CAAC;AAAA,gBACxB,mBAAiB,CAACP,KAAWd,KAAS,CAACmB,IAAcJ,IAAU;AAAA,cAAA;AAAA,cAX1DM;AAAA,YAAA,CAaR;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,GACF;AAAA,EAEJ;AACF;AAEAxB,EAAO,cAAc;"}
1
+ {"version":3,"file":"Slider.js","sources":["../../../src/components/ui/Slider.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useId,\n useState,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type ReactNode,\n} from 'react';\nimport * as SliderPrimitive from '@radix-ui/react-slider';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface SliderProps extends Omit<\n ComponentPropsWithoutRef<typeof SliderPrimitive.Root>,\n 'value' | 'defaultValue'\n> {\n /**\n * Controlled value. Pass `[n]` for a single-thumb slider, `[a, b]` for a range slider.\n */\n value?: number[];\n defaultValue?: number[];\n /** Inline label rendered above the slider. */\n label?: ReactNode;\n /** Show the numeric value next to the label. */\n showValue?: boolean;\n /** Format the displayed value (e.g. `(v) => \\`${v}%\\``). */\n formatValue?: (value: number) => string;\n}\n\n/**\n * Single- or range-thumb slider. Pass one item in `value` for a single\n * thumb, two for a range.\n *\n * @example Single value\n * <Slider label=\"Volume\" showValue defaultValue={[60]} max={100} step={1} />\n *\n * @example Price range\n * <Slider label=\"Price\"\n * defaultValue={[50, 250]}\n * min={0} max={500} step={10}\n * formatValue={(v) => \\`$\\${v}\\`}\n * showValue />\n *\n * @do Use `showValue` when the absolute number matters (price, volume, weight).\n * @dont Hide the value when users will need to reason about exact thresholds.\n */\nexport const Slider = forwardRef<ComponentRef<typeof SliderPrimitive.Root>, SliderProps>(\n function Slider(\n {\n className,\n label,\n showValue,\n formatValue = (v) => String(v),\n value,\n defaultValue,\n onValueChange,\n ...props\n },\n ref,\n ) {\n // Uncontrolled sliders track their own value so `showValue` stays live.\n // Radix starts an uncontrolled thumb at `min`, so the live value must too.\n const [internal, setInternal] = useState<number[]>(defaultValue ?? [props.min ?? 0]);\n const isControlled = value !== undefined;\n const currentValue = isControlled ? value : internal;\n const isRange = currentValue.length > 1;\n const labelId = useId();\n const strings = useStrings();\n // Only a string label can double as aria-label; ReactNode labels are\n // referenced by id instead.\n const stringLabel = typeof label === 'string' ? label : undefined;\n const thumbLabel = (i: number) =>\n isRange\n ? i === 0\n ? strings.slider.minimum\n : strings.slider.maximum\n : (stringLabel ?? props['aria-label'] ?? strings.slider.value);\n\n return (\n <div className={cn('flex flex-col gap-2', className)}>\n {(label || showValue) && (\n <div className=\"flex items-center justify-between\">\n {label && (\n <span id={labelId} className=\"text-foreground text-sm font-medium\">\n {label}\n </span>\n )}\n {showValue && (\n <span className=\"tabular text-foreground-muted font-mono text-xs\">\n {isRange\n ? `${formatValue(currentValue[0])} – ${formatValue(currentValue[1])}`\n : formatValue(currentValue[0])}\n </span>\n )}\n </div>\n )}\n\n <SliderPrimitive.Root\n data-slot=\"slider\"\n ref={ref}\n value={value}\n defaultValue={defaultValue}\n onValueChange={(v) => {\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n }}\n className=\"relative flex w-full touch-none items-center py-3.5 select-none\"\n aria-labelledby={label && !stringLabel ? labelId : undefined}\n {...props}\n >\n <SliderPrimitive.Track\n data-slot=\"slider-track\"\n className=\"bg-background-muted relative h-1 w-full grow overflow-hidden rounded-full\"\n >\n <SliderPrimitive.Range className=\"bg-accent absolute h-full\" />\n </SliderPrimitive.Track>\n {currentValue.map((_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n data-slot=\"slider-thumb\"\n className={cn(\n 'border-accent bg-card relative block size-4 rounded-full border-2 shadow-sm',\n // 44px touch target without growing the visible thumb.\n 'before:absolute before:top-1/2 before:left-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:content-[\"\"]',\n 'focus-visible:ring-ring focus-visible:ring-offset-background outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-transform duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'hover:scale-110 data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n )}\n aria-label={thumbLabel(i)}\n aria-labelledby={!isRange && label && !stringLabel ? labelId : undefined}\n />\n ))}\n </SliderPrimitive.Root>\n </div>\n );\n },\n);\n\nSlider.displayName = 'Slider';\n"],"names":["Slider","forwardRef","className","label","showValue","formatValue","v","value","defaultValue","onValueChange","props","ref","internal","setInternal","useState","isControlled","currentValue","isRange","labelId","useId","strings","useStrings","stringLabel","thumbLabel","i","cn","jsxs","SliderPrimitive","jsx","_"],"mappings":";;;;;;AAgDO,MAAMA,IAASC;AAAA,EACpB,SACE;AAAA,IACE,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC,IAAc,CAACC,MAAM,OAAOA,CAAC;AAAA,IAC7B,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,eAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,GACA;AAGA,UAAM,CAACC,GAAUC,CAAW,IAAIC,EAAmBN,KAAgB,CAACE,EAAM,OAAO,CAAC,CAAC,GAC7EK,IAAeR,MAAU,QACzBS,IAAeD,IAAeR,IAAQK,GACtCK,IAAUD,EAAa,SAAS,GAChCE,IAAUC,EAAA,GACVC,IAAUC,EAAA,GAGVC,IAAc,OAAOnB,KAAU,WAAWA,IAAQ,QAClDoB,IAAa,C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BACA;AAAA,gBAAA;AAAA,gBAEF,cAAYF,EAAWC,CAAC;AAAA,gBACxB,mBAAiB,CAACP,KAAWd,KAAS,CAACmB,IAAcJ,IAAU;AAAA,cAAA;AAAA,cAX1DM;AAAA,YAAA,CAaR;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,GACF;AAAA,EAEJ;AACF;AAEAxB,EAAO,cAAc;"}
@@ -117,6 +117,10 @@ export interface UiStrings {
117
117
  bytes: string;
118
118
  kilobytes: string;
119
119
  megabytes: string;
120
+ /** Shown under the drop zone when a file exceeds `maxSize`; `{max}` is the formatted limit. */
121
+ tooLarge: string;
122
+ /** Shown under the drop zone when a file does not match `accept`. */
123
+ wrongType: string;
120
124
  };
121
125
  input: {
122
126
  clear: string;
@@ -66,7 +66,9 @@ const l = {
66
66
  remove: "Remove {name}",
67
67
  bytes: "{n} B",
68
68
  kilobytes: "{n} KB",
69
- megabytes: "{n} MB"
69
+ megabytes: "{n} MB",
70
+ tooLarge: "File is larger than {max}.",
71
+ wrongType: "That file type is not accepted."
70
72
  },
71
73
  input: { clear: "Clear input", showPassword: "Show password", hidePassword: "Hide password" },
72
74
  slider: { minimum: "Minimum", maximum: "Maximum", value: "Value" },