@platned/ui 0.9.5 → 0.9.7

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/sidebar.cjs CHANGED
@@ -32,298 +32,22 @@ var sidebar_exports = {};
32
32
  __export(sidebar_exports, {
33
33
  AppSidebar: () => AppSidebar,
34
34
  NavTabs: () => NavTabs,
35
- SidebarSeparator: () => SidebarSeparator,
36
- SidebarUserCard: () => SidebarUserCard
35
+ SidebarSeparator: () => import__2.SidebarSeparator,
36
+ SidebarUserCard: () => import__2.SidebarUserCard
37
37
  });
38
38
  module.exports = __toCommonJS(sidebar_exports);
39
- var import_react10 = require("react");
39
+ var import_react = require("react");
40
40
  var import_react_router_dom2 = require("react-router-dom");
41
- var import_lucide_react3 = require("lucide-react");
42
-
43
- // src/lib/cn.ts
44
- var import_clsx = require("clsx");
45
- var import_tailwind_merge = require("tailwind-merge");
46
- var FONT_SIZES = [
47
- "body-micro",
48
- "body-tiny",
49
- "body-xs",
50
- "body-sm",
51
- "body",
52
- "body-lg",
53
- "heading-sm",
54
- "heading",
55
- "heading-lg",
56
- "subheading-sm",
57
- "subheading",
58
- "subheading-lg",
59
- "subtitle-sm",
60
- "subtitle",
61
- "subtitle-lg",
62
- "title-sm",
63
- "title",
64
- "title-lg",
65
- "title-hero",
66
- "scale-01",
67
- "scale-02",
68
- "scale-03",
69
- "scale-04",
70
- "scale-05",
71
- "scale-06",
72
- "scale-07",
73
- "scale-08",
74
- "scale-09",
75
- "scale-10",
76
- "scale-12"
77
- ];
78
- var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
79
- extend: {
80
- classGroups: {
81
- "font-size": [{ text: [...FONT_SIZES] }]
82
- }
83
- }
84
- });
85
- function cn(...inputs) {
86
- return twMerge((0, import_clsx.clsx)(inputs));
87
- }
41
+ var import__ = require("./index.cjs");
42
+ var import__2 = require("./index.cjs");
88
43
 
89
- // src/lib/focus-ring.ts
90
- var FOCUS_RING = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default";
91
- var FOCUS_RING_INSET = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand";
92
-
93
- // src/lib/slot.tsx
94
- var import_react = require("react");
44
+ // src/sidebar/nav-tabs.tsx
45
+ var import_react_router_dom = require("react-router-dom");
95
46
  var import_clsx2 = __toESM(require("clsx"), 1);
96
- var Slot = (0, import_react.forwardRef)(function Slot2({ children, wrapChildren, ...slotProps }, forwardedRef) {
97
- if (!(0, import_react.isValidElement)(children)) return null;
98
- const child = children;
99
- const merged = {
100
- ...mergeProps(slotProps, child.props),
101
- ref: composeRefs(forwardedRef, getElementRef(child))
102
- };
103
- return wrapChildren ? (0, import_react.cloneElement)(child, merged, wrapChildren(child.props.children)) : (0, import_react.cloneElement)(child, merged);
104
- });
105
- function mergeProps(slotProps, childProps) {
106
- const merged = { ...slotProps };
107
- for (const key in childProps) {
108
- const slotValue = slotProps[key];
109
- const childValue = childProps[key];
110
- if (/^on[A-Z]/.test(key)) {
111
- if (typeof slotValue === "function" && typeof childValue === "function") {
112
- merged[key] = (...args) => {
113
- slotValue(...args);
114
- childValue(...args);
115
- };
116
- } else {
117
- merged[key] = childValue ?? slotValue;
118
- }
119
- } else if (key === "className") {
120
- merged[key] = (0, import_clsx2.default)(slotValue, childValue);
121
- } else if (key === "style") {
122
- merged[key] = { ...slotValue, ...childValue };
123
- } else {
124
- merged[key] = childValue;
125
- }
126
- }
127
- return merged;
128
- }
129
- function getElementRef(element) {
130
- const asRecord = element;
131
- return asRecord.props?.ref ?? asRecord.ref;
132
- }
133
- function composeRefs(...refs) {
134
- return (node) => {
135
- for (const ref of refs) {
136
- if (!ref) continue;
137
- if (typeof ref === "function") {
138
- ref(node);
139
- } else {
140
- ref.current = node;
141
- }
142
- }
143
- };
144
- }
145
-
146
- // src/components/forms/control-size.tsx
147
- var import_react2 = require("react");
148
- var import_jsx_runtime = require("react/jsx-runtime");
149
- var ControlSizeContext = (0, import_react2.createContext)(null);
150
- function useControlSize(explicit) {
151
- const inherited = (0, import_react2.useContext)(ControlSizeContext);
152
- return explicit ?? inherited ?? "md";
153
- }
154
-
155
- // src/components/forms/icon-button.tsx
156
- var import_react3 = require("react");
157
- var import_clsx3 = __toESM(require("clsx"), 1);
158
- var import_jsx_runtime2 = require("react/jsx-runtime");
159
- var variantStyles = {
160
- primary: (0, import_clsx3.default)(
161
- "bg-brand border border-brand text-brand-on-brand",
162
- "hover:bg-brand-hover",
163
- "disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
164
- "aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
165
- ),
166
- // Neutral uses secondary background (light gray) for visual weight without a text label
167
- neutral: (0, import_clsx3.default)(
168
- "bg-default-secondary border border-default text-default",
169
- // icon turns brand blue on hover (Figma spec)
170
- "hover:bg-default-secondary-hover hover:text-brand",
171
- "disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
172
- "aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
173
- ),
174
- subtle: (0, import_clsx3.default)(
175
- "bg-transparent text-neutral",
176
- // hover uses background-default-default-hover (#f5f5f5), icon turns brand blue (Figma spec)
177
- "hover:bg-default-hover hover:text-brand",
178
- // disabled needs explicit border since there is no base border
179
- "disabled:bg-disabled disabled:border disabled:border-disabled disabled:text-disabled-on-disabled",
180
- "aria-disabled:bg-disabled aria-disabled:border aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
181
- )
182
- };
183
- var sizeStyles = {
184
- lg: "size-12 rounded-2xl [&_svg]:size-5",
185
- md: "size-9 rounded-lg [&_svg]:size-5",
186
- sm: "size-6 rounded-full [&_svg]:size-4"
187
- };
188
- var IconButton = (0, import_react3.forwardRef)(function IconButton2({
189
- variant = "primary",
190
- size: sizeProp,
191
- asChild = false,
192
- type,
193
- disabled,
194
- onClick,
195
- children,
196
- className,
197
- ...props
198
- }, ref) {
199
- const size = useControlSize(sizeProp);
200
- const softDisabled = asChild && Boolean(disabled);
201
- const handleClick = (event) => {
202
- if (softDisabled) {
203
- event.preventDefault();
204
- event.stopPropagation();
205
- return;
206
- }
207
- onClick?.(event);
208
- };
209
- const rootProps = {
210
- // `cn`, so a caller's `className` beats the size's radius and the variant's colours.
211
- className: cn(
212
- "inline-flex shrink-0 items-center justify-center transition-colors",
213
- FOCUS_RING,
214
- "disabled:cursor-not-allowed aria-disabled:cursor-not-allowed",
215
- variantStyles[variant],
216
- sizeStyles[size],
217
- className
218
- ),
219
- "data-variant": variant,
220
- "data-size": size,
221
- "aria-disabled": softDisabled || void 0,
222
- onClick: handleClick,
223
- ...props
224
- };
225
- if (asChild) {
226
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Slot, { ref, tabIndex: disabled ? -1 : void 0, ...rootProps, children });
227
- }
228
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
229
- "button",
230
- {
231
- ref,
232
- type: type ?? "button",
233
- disabled,
234
- ...rootProps,
235
- children
236
- }
237
- );
238
- });
239
-
240
- // src/components/avatar/avatar.tsx
241
- var import_clsx4 = __toESM(require("clsx"), 1);
242
- var import_jsx_runtime3 = require("react/jsx-runtime");
243
- var sizeStyles2 = {
244
- lg: "size-10",
245
- md: "size-8",
246
- sm: "size-6"
247
- };
248
- var initialTextStyles = {
249
- lg: "text-body font-semibold",
250
- md: "text-body-xs font-semibold",
251
- sm: "text-body-tiny font-semibold"
252
- };
253
- function getShapeClass(shape, size) {
254
- if (shape === "circle") return "rounded-full";
255
- return size === "sm" ? "rounded" : "rounded-lg";
256
- }
257
- function Avatar(props) {
258
- const { size = "lg", shape = "circle", className } = props;
259
- const base = (0, import_clsx4.default)(
260
- "shrink-0 overflow-hidden",
261
- sizeStyles2[size],
262
- getShapeClass(shape, size),
263
- className
264
- );
265
- if (props.type === "image") {
266
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: base, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
267
- "img",
268
- {
269
- src: props.src,
270
- alt: props.alt ?? "",
271
- className: "size-full object-cover"
272
- }
273
- ) });
274
- }
275
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
276
- "div",
277
- {
278
- className: (0, import_clsx4.default)(base, "flex items-center justify-center"),
279
- style: {
280
- background: "linear-gradient(135deg, var(--color-graphic-blue) 30%, var(--color-graphic-red) 100%)"
281
- },
282
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
283
- "span",
284
- {
285
- className: (0, import_clsx4.default)(
286
- "select-none leading-none text-brand-on-brand",
287
- initialTextStyles[size]
288
- ),
289
- children: props.initial.charAt(0).toUpperCase()
290
- }
291
- )
292
- }
293
- );
294
- }
295
-
296
- // src/lib/use-controllable-state.ts
297
- var import_react4 = require("react");
298
- function useControllableState({
299
- value,
300
- defaultValue,
301
- onChange
302
- }) {
303
- const [internal, setInternal] = (0, import_react4.useState)(defaultValue);
304
- const isControlled = value !== void 0;
305
- const current = isControlled ? value : internal;
306
- const onChangeRef = (0, import_react4.useRef)(onChange);
307
- onChangeRef.current = onChange;
308
- const currentRef = (0, import_react4.useRef)(current);
309
- currentRef.current = current;
310
- const isControlledRef = (0, import_react4.useRef)(isControlled);
311
- isControlledRef.current = isControlled;
312
- const setValue = (0, import_react4.useCallback)((next) => {
313
- const resolved = typeof next === "function" ? next(currentRef.current) : next;
314
- if (resolved === currentRef.current) return;
315
- if (!isControlledRef.current) setInternal(resolved);
316
- onChangeRef.current?.(resolved);
317
- }, []);
318
- return [current, setValue];
319
- }
320
-
321
- // src/components/overlays/menu-styles.ts
322
- var import_clsx6 = __toESM(require("clsx"), 1);
323
47
 
324
48
  // src/lib/scrollbar.ts
325
- var import_clsx5 = __toESM(require("clsx"), 1);
326
- var SCROLLBAR_CLASSES = (0, import_clsx5.default)(
49
+ var import_clsx = __toESM(require("clsx"), 1);
50
+ var SCROLLBAR_CLASSES = (0, import_clsx.default)(
327
51
  // Firefox and the standard property.
328
52
  "[scrollbar-color:var(--color-background-default-tertiary)_transparent] [scrollbar-width:thin]",
329
53
  // WebKit/Blink.
@@ -334,674 +58,25 @@ var SCROLLBAR_CLASSES = (0, import_clsx5.default)(
334
58
  "[&::-webkit-scrollbar-corner]:bg-transparent"
335
59
  );
336
60
 
337
- // src/components/overlays/menu-styles.ts
338
- var OVERLAY_PANEL = "rounded-lg border border-default bg-default p-1 shadow-300";
339
- var OVERLAY_PANEL_MENU = (0, import_clsx6.default)(OVERLAY_PANEL, "min-w-[168px]");
340
- var OVERLAY_PANEL_SCROLL = (0, import_clsx6.default)(
341
- "max-h-[min(16rem,var(--panel-available-height,16rem))] overflow-y-auto",
342
- // A floating panel is already its own scroll container and keeps focus on the input or a
343
- // roving option, so it needs the scrollbar styling but not `ScrollArea`'s tab stop.
344
- SCROLLBAR_CLASSES
345
- );
346
- var OVERLAY_ITEM_BASE = "flex w-full cursor-pointer select-none items-start gap-2 rounded-md text-left outline-none transition-colors";
347
- var OVERLAY_ITEM_SIZE = {
348
- lg: "px-3 py-2.5 text-body",
349
- md: "px-2.5 py-2 text-body-sm",
350
- sm: "px-2 py-1.5 text-body-tiny"
351
- };
352
- var OVERLAY_HEADING = "px-2.5 py-1.5 text-body-tiny font-semibold uppercase tracking-wide text-default-tertiary";
353
- var OVERLAY_SEPARATOR = "-mx-1 my-1 h-px bg-divider";
354
-
355
- // src/components/overlays/portal.tsx
356
- var import_react5 = require("react");
357
- var import_react_dom = require("react-dom");
358
- var import_jsx_runtime4 = require("react/jsx-runtime");
359
- var PortalContainerContext = (0, import_react5.createContext)(null);
360
- function usePortalContainer() {
361
- return (0, import_react5.useContext)(PortalContainerContext);
362
- }
363
-
364
- // src/lib/compose-event-handlers.ts
365
- function composeEventHandlers(theirs, ours) {
366
- return (event) => {
367
- theirs?.(event);
368
- if (!event.defaultPrevented) ours(event);
369
- };
370
- }
371
-
372
- // src/components/overlays/tooltip.tsx
373
- var import_react6 = require("react");
374
- var import_radix_ui = require("radix-ui");
375
- var import_jsx_runtime5 = require("react/jsx-runtime");
376
- function Tooltip({
377
- children,
378
- title,
379
- body,
380
- side = "top",
381
- align = "center",
382
- openDelay = 150,
383
- open,
384
- defaultOpen,
385
- onOpenChange,
386
- association = "describedby",
387
- className
388
- }) {
389
- const container = usePortalContainer();
390
- const labelId = (0, import_react6.useId)();
391
- const labelled = association === "labelledby";
392
- const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
393
- title && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "font-semibold", children: title }),
394
- body && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: cn(title && "mt-0.5 opacity-80"), children: body })
395
- ] });
396
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_radix_ui.Tooltip.Provider, { delayDuration: openDelay, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_radix_ui.Tooltip.Root, { open, defaultOpen, onOpenChange, children: [
397
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
398
- import_radix_ui.Tooltip.Trigger,
399
- {
400
- asChild: true,
401
- ...labelled ? { "aria-labelledby": labelId, "aria-describedby": void 0 } : {},
402
- children
403
- }
404
- ),
405
- labelled && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { id: labelId, hidden: true, children: [
406
- title,
407
- body ? " " : null,
408
- body
409
- ] }),
410
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_radix_ui.Tooltip.Portal, { container: container ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
411
- import_radix_ui.Tooltip.Content,
412
- {
413
- side,
414
- align,
415
- sideOffset: 6,
416
- collisionPadding: 8,
417
- className: cn(
418
- "z-tooltip max-w-[260px] rounded-lg bg-neutral px-3 py-2 shadow-300",
419
- "text-body-xs text-neutral-on-neutral",
420
- className
421
- ),
422
- children: content
423
- }
424
- ) })
425
- ] }) });
426
- }
427
-
428
- // src/components/overlays/menu-core.tsx
429
- var import_react7 = require("react");
430
- var import_clsx7 = __toESM(require("clsx"), 1);
431
- var import_lucide_react = require("lucide-react");
432
- var import_jsx_runtime6 = require("react/jsx-runtime");
433
- var MENU_PANEL_CLASSES = cn("z-popover", OVERLAY_PANEL_MENU, "focus:outline-none");
434
- var ITEM_BASE = (0, import_clsx7.default)(
435
- OVERLAY_ITEM_BASE,
436
- OVERLAY_ITEM_SIZE.md,
437
- // Highlight follows Radix's `data-highlighted`, which tracks pointer and keyboard alike.
438
- // The ring marks the keyboard position on top of it: the tint alone, shared with hover,
439
- // cannot tell a keyboard user which of two tinted items has focus.
440
- FOCUS_RING_INSET,
441
- "data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled"
442
- );
443
- var ITEM_TONE = {
444
- default: "text-default data-[highlighted]:bg-default-secondary",
445
- danger: "text-danger data-[highlighted]:bg-danger-tertiary"
446
- };
447
- function stopToAncestors(event) {
448
- event.stopPropagation();
449
- }
450
- function focusMenuEdge(event, edge) {
451
- if (event.target !== event.currentTarget) return;
452
- const panel = event.currentTarget;
453
- queueMicrotask(() => {
454
- const items = panel.querySelectorAll('[role^="menuitem"]:not([data-disabled])');
455
- if (edge === "end") items[items.length - 1]?.focus();
456
- else if (document.activeElement === panel) items[0]?.focus();
457
- });
458
- }
459
- function visibleMenuItems(items) {
460
- const kept = items.filter((item) => {
461
- if (item.hidden) return false;
462
- if (item.type === "group" || item.type === "submenu") return visibleMenuItems(item.items).length > 0;
463
- return true;
464
- });
465
- return kept.filter((item, i) => {
466
- if (item.type !== "separator") return true;
467
- const prev = kept[i - 1];
468
- return i > 0 && i < kept.length - 1 && prev.type !== "separator";
469
- });
470
- }
471
- function createMenuParts(P) {
472
- const Item = (0, import_react7.forwardRef)(function MenuItem({ children, onSelect, tone = "default", disabled = false, icon, description, shortcut, textValue, className, ...rest }, ref) {
473
- const descriptionId = (0, import_react7.useId)();
474
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
475
- P.Item,
476
- {
477
- ref,
478
- disabled,
479
- textValue,
480
- onSelect,
481
- "data-tone": tone,
482
- "aria-describedby": description ? descriptionId : void 0,
483
- className: cn(ITEM_BASE, ITEM_TONE[tone], className),
484
- ...rest,
485
- children: [
486
- icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": true, className: "mt-0.5 flex size-4 shrink-0 items-center justify-center", children: icon }),
487
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "min-w-0 flex-1", children: [
488
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "block truncate", children }),
489
- description && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { id: descriptionId, className: "mt-0.5 block text-body-tiny text-default-secondary", children: description })
490
- ] }),
491
- shortcut && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary", children: shortcut })
492
- ]
493
- }
494
- );
495
- });
496
- const CheckboxItem = (0, import_react7.forwardRef)(function MenuCheckboxItem({ children, checked, onCheckedChange, disabled = false, tone = "default", shortcut, textValue, className, ...rest }, ref) {
497
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
498
- P.CheckboxItem,
499
- {
500
- ref,
501
- checked,
502
- onCheckedChange: (next) => onCheckedChange?.(next === true),
503
- onSelect: (event) => event.preventDefault(),
504
- disabled,
505
- textValue,
506
- "data-tone": tone,
507
- className: cn(ITEM_BASE, "items-center", ITEM_TONE[tone], className),
508
- ...rest,
509
- children: [
510
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": true, className: "flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.CheckIcon, { className: "size-3.5", strokeWidth: 3 }) }) }),
511
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children }),
512
- shortcut && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary", children: shortcut })
513
- ]
514
- }
515
- );
516
- });
517
- function RadioGroup({ children, value, onValueChange }) {
518
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.RadioGroup, { value, onValueChange, children });
519
- }
520
- const RadioItem = (0, import_react7.forwardRef)(function MenuRadioItem({ children, value, disabled = false, tone = "default", textValue, className, ...rest }, ref) {
521
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
522
- P.RadioItem,
523
- {
524
- ref,
525
- value,
526
- disabled,
527
- textValue,
528
- "data-tone": tone,
529
- className: cn(ITEM_BASE, "items-center", ITEM_TONE[tone], className),
530
- ...rest,
531
- children: [
532
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": true, className: "flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "block size-1.5 rounded-full bg-current" }) }) }),
533
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children })
534
- ]
535
- }
536
- );
537
- });
538
- const Group = (0, import_react7.forwardRef)(function MenuGroup({ children, label, className, ...rest }, ref) {
539
- const labelId = (0, import_react7.useId)();
540
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(P.Group, { ref, "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
541
- label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { id: labelId, className: OVERLAY_HEADING, children: label }),
542
- children
543
- ] });
544
- });
545
- const Label = (0, import_react7.forwardRef)(function MenuLabel({ className, ...rest }, ref) {
546
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Label, { ref, className: cn(OVERLAY_HEADING, className), ...rest });
547
- });
548
- const Separator = (0, import_react7.forwardRef)(function MenuSeparator({ className, ...rest }, ref) {
549
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Separator, { ref, className: cn(OVERLAY_SEPARATOR, className), ...rest });
550
- });
551
- const Shortcut = (0, import_react7.forwardRef)(function MenuShortcut({ className, ...rest }, ref) {
552
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref, className: cn("ml-auto pl-4 text-body-tiny text-default-tertiary", className), ...rest });
553
- });
554
- function Sub({ children, open, defaultOpen, onOpenChange }) {
555
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Sub, { open, defaultOpen, onOpenChange, children });
556
- }
557
- const SubTrigger = (0, import_react7.forwardRef)(function MenuSubTrigger({ children, icon, disabled = false, textValue, className, ...rest }, ref) {
558
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
559
- P.SubTrigger,
560
- {
561
- ref,
562
- disabled,
563
- textValue,
564
- className: cn(
565
- ITEM_BASE,
566
- "items-center",
567
- ITEM_TONE.default,
568
- "data-[state=open]:bg-default-secondary",
569
- className
570
- ),
571
- ...rest,
572
- children: [
573
- icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": true, className: "flex size-4 shrink-0 items-center justify-center", children: icon }),
574
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children }),
575
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.ChevronRightIcon, { "aria-hidden": true, className: "ml-auto size-4 shrink-0 text-default-tertiary" })
576
- ]
577
- }
578
- );
579
- });
580
- const SubContent = (0, import_react7.forwardRef)(function MenuSubContent({ className, onClick, onKeyDown, ...rest }, ref) {
581
- const container = usePortalContainer();
582
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Portal, { container: container ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
583
- P.SubContent,
584
- {
585
- ref,
586
- sideOffset: 4,
587
- collisionPadding: 8,
588
- className: cn(MENU_PANEL_CLASSES, className),
589
- onClick: (event) => {
590
- onClick?.(event);
591
- stopToAncestors(event);
592
- },
593
- onKeyDown: (event) => {
594
- onKeyDown?.(event);
595
- stopToAncestors(event);
596
- },
597
- ...rest
598
- }
599
- ) });
600
- });
601
- function Items({ items }) {
602
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: visibleMenuItems(items).map(renderItem) });
603
- }
604
- function renderItem(item) {
605
- switch (item.type) {
606
- case "checkbox":
607
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
608
- CheckboxItem,
609
- {
610
- checked: item.checked,
611
- onCheckedChange: item.onCheckedChange,
612
- disabled: item.disabled,
613
- shortcut: item.shortcut,
614
- textValue: item.textValue,
615
- children: item.label
616
- },
617
- item.id
618
- );
619
- case "radio":
620
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RadioGroup, { value: item.value, onValueChange: item.onValueChange, children: item.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RadioItem, { value: option.value, disabled: option.disabled, children: option.label }, option.value)) }, item.id);
621
- case "group":
622
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Group, { label: item.label, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Items, { items: item.items }) }, item.id);
623
- case "submenu":
624
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Sub, { children: [
625
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SubTrigger, { icon: item.icon, disabled: item.disabled, children: item.label }),
626
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SubContent, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Items, { items: item.items }) })
627
- ] }, item.id);
628
- case "label":
629
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { children: item.label }, item.id);
630
- case "separator":
631
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Separator, {}, item.id);
632
- case "custom":
633
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: item.render() }, item.id);
634
- default:
635
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
636
- Item,
637
- {
638
- onSelect: item.onSelect,
639
- tone: item.tone,
640
- disabled: item.disabled,
641
- icon: item.icon,
642
- description: item.description,
643
- shortcut: item.shortcut,
644
- textValue: item.textValue,
645
- children: item.label
646
- },
647
- item.id
648
- );
649
- }
650
- }
651
- return {
652
- Items,
653
- Item,
654
- CheckboxItem,
655
- RadioGroup,
656
- RadioItem,
657
- Group,
658
- Label,
659
- Separator,
660
- Shortcut,
661
- Sub,
662
- SubTrigger,
663
- SubContent
664
- };
665
- }
666
-
667
- // src/components/cards/scroll-area.tsx
668
- var import_react8 = require("react");
669
- var import_clsx8 = __toESM(require("clsx"), 1);
670
- var import_jsx_runtime7 = require("react/jsx-runtime");
671
- var OVERFLOW = {
672
- vertical: "overflow-y-auto overflow-x-hidden",
673
- horizontal: "overflow-x-auto overflow-y-hidden",
674
- both: "overflow-auto"
675
- };
676
- var ScrollArea = (0, import_react8.forwardRef)(function ScrollArea2({ children, axis = "vertical", label, className, ...rest }, ref) {
677
- const localRef = (0, import_react8.useRef)(null);
678
- const [overflows, setOverflows] = (0, import_react8.useState)(false);
679
- (0, import_react8.useEffect)(() => {
680
- const node = localRef.current;
681
- if (!node) return;
682
- const measure = () => {
683
- const vertical = node.scrollHeight > node.clientHeight + 1;
684
- const horizontal = node.scrollWidth > node.clientWidth + 1;
685
- setOverflows(
686
- axis === "vertical" ? vertical : axis === "horizontal" ? horizontal : vertical || horizontal
687
- );
688
- };
689
- measure();
690
- if (typeof ResizeObserver === "undefined") return;
691
- const observer = new ResizeObserver(measure);
692
- observer.observe(node);
693
- if (node.firstElementChild) observer.observe(node.firstElementChild);
694
- return () => observer.disconnect();
695
- }, [axis, children]);
696
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
697
- "div",
698
- {
699
- ref: composeRefs(localRef, ref),
700
- role: overflows && label ? "region" : void 0,
701
- "aria-label": overflows ? label : void 0,
702
- tabIndex: overflows ? 0 : void 0,
703
- "data-slot": "scroll-area",
704
- className: (0, import_clsx8.default)(
705
- OVERFLOW[axis],
706
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default",
707
- SCROLLBAR_CLASSES,
708
- className
709
- ),
710
- ...rest,
711
- children
712
- }
713
- );
714
- });
715
-
716
- // src/components/overlays/dropdown-menu.tsx
717
- var import_react9 = require("react");
718
- var import_radix_ui2 = require("radix-ui");
719
- var import_lucide_react2 = require("lucide-react");
720
- var import_jsx_runtime8 = require("react/jsx-runtime");
721
- var DropdownMenuStateContext = (0, import_react9.createContext)(null);
722
- function useDropdownMenuState(part) {
723
- const value = (0, import_react9.useContext)(DropdownMenuStateContext);
724
- if (!value) throw new Error(`<${part}> must be used inside <DropdownMenu>`);
725
- return value;
726
- }
727
- function DropdownMenu({
728
- children,
729
- items,
730
- trigger,
731
- label,
732
- side,
733
- align,
734
- open: openProp,
735
- defaultOpen = false,
736
- onOpenChange,
737
- modal = false
738
- }) {
739
- const [open, setOpen] = useControllableState({
740
- value: openProp,
741
- defaultValue: defaultOpen,
742
- onChange: onOpenChange
743
- });
744
- const pendingEdge = (0, import_react9.useRef)("start");
745
- const state = (0, import_react9.useMemo)(() => ({ setOpen, pendingEdge }), [setOpen]);
746
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuStateContext.Provider, { value: state, children: items ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
747
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuTrigger, { asChild: trigger != null, label, children: trigger }),
748
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuContent, { side, align, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuItems, { items }) })
749
- ] }) : children }) });
750
- }
751
- var DropdownMenuTrigger = (0, import_react9.forwardRef)(
752
- function DropdownMenuTrigger2({ children, asChild = false, label = "Open menu", onClick, onPointerDown, onMouseDown, onKeyDown, ...rest }, ref) {
753
- const state = useDropdownMenuState("DropdownMenuTrigger");
754
- const handlers = {
755
- onClick: (event) => {
756
- onClick?.(event);
757
- stopToAncestors(event);
758
- },
759
- onPointerDown: (event) => {
760
- onPointerDown?.(event);
761
- event.stopPropagation();
762
- },
763
- onMouseDown: (event) => {
764
- onMouseDown?.(event);
765
- stopToAncestors(event);
766
- },
767
- onKeyDown: (event) => {
768
- onKeyDown?.(event);
769
- if (event.defaultPrevented) return;
770
- if (event.key === "ArrowUp") {
771
- event.preventDefault();
772
- state.pendingEdge.current = "end";
773
- state.setOpen(true);
774
- }
775
- if (event.key === "Enter" || event.key === " ") stopToAncestors(event);
776
- }
777
- };
778
- if (asChild) {
779
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children });
780
- }
781
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IconButton, { variant: "neutral", size: "sm", "aria-label": label, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.EllipsisIcon, { className: "size-4", "aria-hidden": true }) }) });
782
- }
783
- );
784
- var DropdownMenuContent = (0, import_react9.forwardRef)(
785
- function DropdownMenuContent2({
786
- children,
787
- side = "bottom",
788
- align = "end",
789
- sideOffset = 6,
790
- container,
791
- className,
792
- onClick,
793
- onKeyDown,
794
- onFocus,
795
- onCloseAutoFocus,
796
- ...rest
797
- }, ref) {
798
- const state = useDropdownMenuState("DropdownMenuContent");
799
- const inherited = usePortalContainer();
800
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Portal, { container: container ?? inherited ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
801
- import_radix_ui2.DropdownMenu.Content,
802
- {
803
- ref,
804
- side,
805
- align,
806
- sideOffset,
807
- collisionPadding: 8,
808
- loop: true,
809
- className: cn(MENU_PANEL_CLASSES, className),
810
- onCloseAutoFocus: composeEventHandlers(onCloseAutoFocus, () => {
811
- state.pendingEdge.current = "start";
812
- }),
813
- onFocus: composeEventHandlers(onFocus, (event) => {
814
- const edge = state.pendingEdge.current;
815
- state.pendingEdge.current = "start";
816
- focusMenuEdge(event, edge);
817
- }),
818
- onClick: (event) => {
819
- onClick?.(event);
820
- stopToAncestors(event);
821
- },
822
- onKeyDown: (event) => {
823
- onKeyDown?.(event);
824
- stopToAncestors(event);
825
- if (event.key === "Tab") state.setOpen(false);
826
- },
827
- ...rest,
828
- children
829
- }
830
- ) });
831
- }
832
- );
833
- var parts = createMenuParts(import_radix_ui2.DropdownMenu);
834
- var DropdownMenuItems = parts.Items;
835
- var DropdownMenuItem = parts.Item;
836
- var DropdownMenuCheckboxItem = parts.CheckboxItem;
837
- var DropdownMenuRadioGroup = parts.RadioGroup;
838
- var DropdownMenuRadioItem = parts.RadioItem;
839
- var DropdownMenuGroup = parts.Group;
840
- var DropdownMenuLabel = parts.Label;
841
- var DropdownMenuSeparator = parts.Separator;
842
- var DropdownMenuShortcut = parts.Shortcut;
843
- var DropdownMenuSub = parts.Sub;
844
- var DropdownMenuSubTrigger = parts.SubTrigger;
845
- var DropdownMenuSubContent = parts.SubContent;
846
-
847
- // src/components/chrome/nav-item.tsx
848
- var import_clsx9 = __toESM(require("clsx"), 1);
849
- var import_jsx_runtime9 = require("react/jsx-runtime");
850
- var SIZE = {
851
- sm: { box: "h-9 gap-2 rounded-lg px-3 py-1.5", label: "text-body-xs", square: "w-9" },
852
- md: { box: "h-11 gap-3 rounded-xl px-3.5 py-2.5", label: "text-body-sm", square: "w-11" }
853
- };
854
- function monogram(label) {
855
- const words = label.split(/\s+/).filter((word) => /^[\p{L}\p{N}]/u.test(word));
856
- const [first, second] = words;
857
- if (!first) return Array.from(label.trim())[0]?.toUpperCase() ?? "";
858
- if (second) return (Array.from(first)[0] + Array.from(second)[0]).toUpperCase();
859
- const [a, b] = Array.from(first);
860
- return a.toUpperCase() + (b ?? "").toLowerCase();
861
- }
862
- var STATE = {
863
- // Figma MenuButton `state=hover`. No border change: Figma holds it at #D9D9D9 through
864
- // hover and moves only the fill and the text.
865
- hover: "hover:bg-brand-tertiary-hover hover:text-brand",
866
- // Figma MenuButton `state=focussed`, which is that file's name for selected — see the
867
- // `isActive` doc comment. Hovering the current row darkens it rather than reverting it to
868
- // the pale hover tint, which would read as the row losing its selection under the cursor.
869
- active: "bg-brand text-brand-on-brand hover:bg-brand-hover"
870
- };
871
- var VARIANT = {
872
- card: {
873
- // `border-transparent` holds the 1px so the icon and label do not shift outward when a
874
- // row becomes the current one — the same trick, for the same reason, as `button.tsx`.
875
- // `bg-brand` still paints edge to edge, since backgrounds clip to the border box.
876
- active: (0, import_clsx9.default)("border border-transparent", STATE.active),
877
- inactive: (0, import_clsx9.default)("border border-default bg-default text-default-secondary", STATE.hover)
878
- },
879
- plain: {
880
- active: STATE.active,
881
- inactive: (0, import_clsx9.default)("text-default-secondary", STATE.hover)
882
- }
883
- };
884
- function NavItem({
885
- icon,
886
- label,
887
- isActive = false,
888
- indicator = false,
889
- collapsed = false,
890
- size = "md",
891
- variant = "card",
892
- asChild = false,
893
- disabled = false,
894
- children,
895
- className,
896
- onClick,
897
- ...rest
898
- }) {
899
- const s = SIZE[size];
900
- const v = VARIANT[variant];
901
- const rootProps = {
902
- // Only meaningful when `asChild` renders a real link — a decorative span with
903
- // aria-current would be a lie.
904
- "aria-current": asChild && isActive ? "page" : void 0,
905
- // Same attribute the disclosure components and `TableRow` use, so the state is
906
- // addressable from a consumer's CSS. `active` rather than `selected`: a nav row is where
907
- // you *are* (`aria-current="page"`), which is a different thing from a row you have
908
- // *picked* (`aria-selected`) — `TableRow` is the latter and says `selected`.
909
- "data-state": isActive ? "active" : void 0,
910
- "data-disabled": disabled || void 0,
911
- "aria-disabled": disabled || void 0,
912
- className: (0, import_clsx9.default)(
913
- "relative flex items-center transition-colors",
914
- // Unconditional: a row can also become focusable by the caller putting it inside a
915
- // link, which is how `src/sidebar/` uses it. A ring that only appears under `asChild`
916
- // leaves that case with no visible focus at all.
917
- // The offset is `default-secondary`, not `default`: a nav row's home is the sidebar
918
- // rail, and `ring-offset-default` is #FFFFFF, so a focused `plain` row drew a 1px white
919
- // halo on the #F5F5F5 rail. The offset itself is load-bearing — in dark mode
920
- // `ring-brand` and `bg-brand` are both #F1F7FD, so without it a focused *active* row
921
- // would have no visible ring at its inner edge.
922
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default-secondary",
923
- s.box,
924
- // Expanded rows fill the nav; a collapsed one is a centred square, not a stretched row.
925
- collapsed ? (0, import_clsx9.default)("justify-center", s.square) : "w-full",
926
- isActive ? v.active : v.inactive,
927
- "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40 data-[disabled]:hover:bg-transparent data-[disabled]:hover:text-default-secondary",
928
- className
929
- ),
930
- ...rest,
931
- // After the spread: a disabled row refuses the press (a router Link skips navigation when
932
- // the event is prevented) and leaves the tab order, as a disabled control does.
933
- ...disabled ? { tabIndex: -1 } : {},
934
- onClick: (event) => {
935
- if (disabled) {
936
- event.preventDefault();
937
- return;
938
- }
939
- onClick?.(event);
940
- }
941
- };
942
- const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
943
- icon != null ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": true, className: "shrink-0 [&_svg]:size-4", children: icon }) : (
944
- // Icons are optional, but the collapsed rail hides the label — so a row with neither
945
- // renders as an empty box. Through 0.5.0 that is exactly what a nav without icons
946
- // collapsed to, the docs site's own 36-row sidebar included. The monogram is
947
- // decorative in the same way the icon is: the `sr-only` label below still names the
948
- // row.
949
- collapsed && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
950
- "span",
951
- {
952
- "aria-hidden": true,
953
- className: "flex h-4 min-w-4 shrink-0 items-center justify-center text-body-tiny font-semibold leading-none tracking-tight",
954
- children: monogram(label)
955
- }
956
- )
957
- ),
958
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
959
- "span",
960
- {
961
- className: (0, import_clsx9.default)(
962
- "min-w-0 truncate font-regular leading-snug",
963
- s.label,
964
- collapsed ? "sr-only" : "flex-1"
965
- ),
966
- children: label
967
- }
968
- ),
969
- indicator && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
970
- "span",
971
- {
972
- role: "status",
973
- "aria-label": "Unread",
974
- className: "absolute -right-px -top-px size-2 rounded-full bg-danger"
975
- }
976
- )
977
- ] });
978
- if (asChild) {
979
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { wrapChildren: () => content, ...rootProps, children });
980
- }
981
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ...rootProps, children: content });
982
- }
983
-
984
61
  // src/sidebar/nav-tabs.tsx
985
- var import_react_router_dom = require("react-router-dom");
986
- var import_clsx10 = __toESM(require("clsx"), 1);
987
- var import_jsx_runtime10 = require("react/jsx-runtime");
62
+ var import_jsx_runtime = require("react/jsx-runtime");
988
63
  function NavTabs({ items, className }) {
989
64
  return (
990
65
  // The links inside are the tab stops.
991
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
66
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
992
67
  "div",
993
68
  {
994
- className: (0, import_clsx10.default)(
69
+ className: (0, import_clsx2.default)(
995
70
  "flex gap-6 overflow-x-auto border-b border-default",
996
71
  SCROLLBAR_CLASSES,
997
72
  className
998
73
  ),
999
- children: items.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
74
+ children: items.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1000
75
  import_react_router_dom.NavLink,
1001
76
  {
1002
77
  to: tab.to,
1003
78
  end: tab.end,
1004
- className: ({ isActive }) => (0, import_clsx10.default)(
79
+ className: ({ isActive }) => (0, import_clsx2.default)(
1005
80
  "shrink-0 whitespace-nowrap border-b-2 pb-3 text-body-sm transition-colors",
1006
81
  isActive ? "border-brand-emphasis font-semibold text-brand-emphasis" : "border-transparent font-medium text-default-secondary hover:text-default"
1007
82
  ),
@@ -1015,226 +90,13 @@ function NavTabs({ items, className }) {
1015
90
  }
1016
91
 
1017
92
  // src/sidebar/index.tsx
1018
- var import_jsx_runtime11 = require("react/jsx-runtime");
1019
- function AppSidebar({
1020
- groups,
1021
- footerNav,
1022
- brand,
1023
- footer,
1024
- collapsible = true,
1025
- collapsed: collapsedProp = false,
1026
- onToggle,
1027
- size = "md",
1028
- variant = "card",
1029
- width = "w-80",
1030
- collapsedWidth = "w-20",
1031
- className
1032
- }) {
1033
- const collapsed = collapsible && collapsedProp;
1034
- const hashTargets = (0, import_react10.useMemo)(
1035
- () => new Set(
1036
- [...groups.flatMap((group) => group.items), ...footerNav ?? []].map((item) => item.to).filter((to) => to.includes("#"))
1037
- ),
1038
- [groups, footerNav]
1039
- );
1040
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HashTargets.Provider, { value: hashTargets, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1041
- "aside",
1042
- {
1043
- className: cn(
1044
- "relative flex h-full shrink-0 flex-col py-2 transition-all duration-200 motion-reduce:transition-none",
1045
- "rounded-xl border-r border-default bg-default-secondary",
1046
- collapsed ? collapsedWidth : width,
1047
- className
1048
- ),
1049
- children: [
1050
- collapsible && onToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1051
- "button",
1052
- {
1053
- type: "button",
1054
- "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
1055
- "aria-expanded": !collapsed,
1056
- onClick: onToggle,
1057
- className: cn(
1058
- "absolute -right-3 top-5 z-raised flex size-6 items-center justify-center rounded-full",
1059
- "border border-default bg-default text-default-secondary",
1060
- // Not `hover:bg-default-hover` — that is #F5F5F5, exactly the rail colour, and
1061
- // this button straddles the rail edge, so half of it dissolved into the rail on
1062
- // hover. Same hover vocabulary as the rows instead.
1063
- "shadow-100 transition-colors hover:bg-brand-tertiary-hover hover:text-brand",
1064
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default"
1065
- ),
1066
- children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.ChevronRightIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.ChevronLeftIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true })
1067
- }
1068
- ),
1069
- brand && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1070
- "div",
1071
- {
1072
- className: cn(
1073
- "flex shrink-0 items-center overflow-hidden p-4",
1074
- collapsed ? "justify-center" : "gap-2.5"
1075
- ),
1076
- children: typeof brand === "function" ? brand({ collapsed }) : brand
1077
- }
1078
- ),
1079
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ScrollArea, { axis: "vertical", label: "Sidebar navigation", className: "min-h-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { className: "flex flex-col gap-4 px-4 pb-3 pt-2", children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1080
- SidebarGroup,
1081
- {
1082
- group,
1083
- showSeparator: groupIndex > 0,
1084
- collapsed,
1085
- size,
1086
- variant
1087
- },
1088
- group.title ?? `group-${groupIndex}`
1089
- )) }) }),
1090
- (footerNav?.length || footer) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex shrink-0 flex-col", children: [
1091
- footerNav && footerNav.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { className: "flex flex-col gap-3 px-4 pt-2", children: footerNav.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1092
- SidebarLink,
1093
- {
1094
- item,
1095
- collapsed,
1096
- size,
1097
- variant
1098
- },
1099
- item.to
1100
- )) }),
1101
- footer
1102
- ] })
1103
- ]
1104
- }
1105
- ) });
1106
- }
1107
- function SidebarGroup({
1108
- group,
1109
- showSeparator,
1110
- collapsed,
1111
- size,
1112
- variant
1113
- }) {
1114
- return (
1115
- // 12px between rows, per the design — the rows read as separate pills rather than a
1116
- // stack. Through 0.5.0 this was `gap-1`, which packed them into a near-continuous block.
1117
- // The same gap spaces the separator and the heading, so neither needs a margin of its own.
1118
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-3", children: [
1119
- showSeparator && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarSeparator, {}),
1120
- group.title && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1121
- "p",
1122
- {
1123
- className: cn(
1124
- "text-body-tiny font-semibold uppercase tracking-wider text-neutral-tertiary",
1125
- // Flush with the rows rather than inset a further 12px — the heading lines up
1126
- // with the left edge of the pills below it, not with their labels.
1127
- // `sr-only` is out of flow, so a collapsed group's heading costs no gap.
1128
- collapsed ? "sr-only" : "px-0"
1129
- ),
1130
- children: group.title
1131
- }
1132
- ),
1133
- group.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1134
- SidebarLink,
1135
- {
1136
- item,
1137
- collapsed,
1138
- size,
1139
- variant
1140
- },
1141
- item.to
1142
- ))
1143
- ] })
1144
- );
1145
- }
1146
- var HashTargets = (0, import_react10.createContext)(/* @__PURE__ */ new Set());
1147
- function useRowActive(item) {
93
+ var import_jsx_runtime2 = require("react/jsx-runtime");
94
+ var RouterLink = (0, import_react.forwardRef)(function RouterLink2({ href, ...rest }, ref) {
95
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_router_dom2.Link, { ref, to: href, ...rest });
96
+ });
97
+ function AppSidebar(props) {
1148
98
  const location = (0, import_react_router_dom2.useLocation)();
1149
- const hashTargets = (0, import_react10.useContext)(HashTargets);
1150
- const [path, hash] = item.to.split("#");
1151
- const pathMatches = item.end ? location.pathname === path : location.pathname === path || location.pathname.startsWith(`${path.replace(/\/$/, "")}/`);
1152
- if (!pathMatches) return false;
1153
- if (hash !== void 0) return location.hash === `#${hash}`;
1154
- return !hashTargets.has(`${location.pathname}${location.hash}`);
1155
- }
1156
- function SidebarLink({
1157
- item,
1158
- collapsed,
1159
- size,
1160
- variant
1161
- }) {
1162
- const active = useRowActive(item);
1163
- const link = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1164
- import_react_router_dom2.Link,
1165
- {
1166
- to: item.to,
1167
- "aria-current": active ? "page" : void 0,
1168
- "aria-disabled": item.disabled || void 0,
1169
- tabIndex: item.disabled ? -1 : void 0,
1170
- onClick: item.disabled ? (event) => event.preventDefault() : void 0,
1171
- className: cn("block w-full no-underline", collapsed && "flex justify-center"),
1172
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1173
- NavItem,
1174
- {
1175
- icon: item.icon,
1176
- label: item.label,
1177
- isActive: active,
1178
- indicator: item.indicator,
1179
- disabled: item.disabled,
1180
- collapsed,
1181
- size,
1182
- variant
1183
- }
1184
- )
1185
- }
1186
- );
1187
- if (!collapsed) return link;
1188
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: item.label, side: "right", children: link });
1189
- }
1190
- function SidebarSeparator({ className, ...rest }) {
1191
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { "aria-hidden": true, className: cn("mx-1 h-px shrink-0 bg-divider", className), ...rest });
1192
- }
1193
- function SidebarUserCard({
1194
- name,
1195
- role,
1196
- onLogout,
1197
- collapsed = false,
1198
- menu,
1199
- className
1200
- }) {
1201
- const initial = name.trim().charAt(0);
1202
- const items = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1203
- menu,
1204
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1205
- DropdownMenuItem,
1206
- {
1207
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.LogOutIcon, { className: "size-3.5", "aria-hidden": true }),
1208
- onSelect: onLogout,
1209
- children: "Sign out"
1210
- }
1211
- )
1212
- ] });
1213
- if (collapsed) {
1214
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: cn("flex shrink-0 items-center justify-center p-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1215
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", "aria-label": `${name} \u2014 user options`, className: "rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Avatar, { initial, size: "lg", shape: "circle" }) }) }),
1216
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "right", align: "end", children: items })
1217
- ] }) });
1218
- }
1219
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("flex shrink-0 items-center gap-2.5 p-4", className), children: [
1220
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Avatar, { initial, size: "lg", shape: "circle" }),
1221
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
1222
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-sm font-semibold leading-snug text-default", children: name }),
1223
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-tiny font-regular leading-none text-default-secondary", children: role })
1224
- ] }),
1225
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1226
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1227
- "button",
1228
- {
1229
- type: "button",
1230
- "aria-label": `${name} \u2014 user options`,
1231
- className: "flex size-6 shrink-0 items-center justify-center rounded-md text-default-secondary transition-colors hover:bg-brand-tertiary-hover hover:text-brand",
1232
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.EllipsisVerticalIcon, { className: "size-5", "aria-hidden": true })
1233
- }
1234
- ) }),
1235
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "top", align: "end", children: items })
1236
- ] })
1237
- ] });
99
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import__.Sidebar, { ...props, currentPath: location.pathname, currentHash: location.hash, linkComponent: RouterLink });
1238
100
  }
1239
101
  // Annotate the CommonJS export names for ESM import in node:
1240
102
  0 && (module.exports = {