@platned/ui 0.9.6 → 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,297 +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_react16 = require("react");
39
+ var import_react = require("react");
40
40
  var import_react_router_dom2 = require("react-router-dom");
41
+ var import__ = require("./index.cjs");
42
+ var import__2 = require("./index.cjs");
41
43
 
42
- // src/lib/cn.ts
43
- var import_clsx = require("clsx");
44
- var import_tailwind_merge = require("tailwind-merge");
45
- var FONT_SIZES = [
46
- "body-micro",
47
- "body-tiny",
48
- "body-xs",
49
- "body-sm",
50
- "body",
51
- "body-lg",
52
- "heading-sm",
53
- "heading",
54
- "heading-lg",
55
- "subheading-sm",
56
- "subheading",
57
- "subheading-lg",
58
- "subtitle-sm",
59
- "subtitle",
60
- "subtitle-lg",
61
- "title-sm",
62
- "title",
63
- "title-lg",
64
- "title-hero",
65
- "scale-01",
66
- "scale-02",
67
- "scale-03",
68
- "scale-04",
69
- "scale-05",
70
- "scale-06",
71
- "scale-07",
72
- "scale-08",
73
- "scale-09",
74
- "scale-10",
75
- "scale-12"
76
- ];
77
- var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
78
- extend: {
79
- classGroups: {
80
- "font-size": [{ text: [...FONT_SIZES] }]
81
- }
82
- }
83
- });
84
- function cn(...inputs) {
85
- return twMerge((0, import_clsx.clsx)(inputs));
86
- }
87
-
88
- // src/lib/focus-ring.ts
89
- 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";
90
- var FOCUS_RING_INSET = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand";
91
-
92
- // src/lib/slot.tsx
93
- var import_react = require("react");
44
+ // src/sidebar/nav-tabs.tsx
45
+ var import_react_router_dom = require("react-router-dom");
94
46
  var import_clsx2 = __toESM(require("clsx"), 1);
95
- var Slot = (0, import_react.forwardRef)(function Slot2({ children, wrapChildren, ...slotProps }, forwardedRef) {
96
- if (!(0, import_react.isValidElement)(children)) return null;
97
- const child = children;
98
- const merged = {
99
- ...mergeProps(slotProps, child.props),
100
- ref: composeRefs(forwardedRef, getElementRef(child))
101
- };
102
- return wrapChildren ? (0, import_react.cloneElement)(child, merged, wrapChildren(child.props.children)) : (0, import_react.cloneElement)(child, merged);
103
- });
104
- function mergeProps(slotProps, childProps) {
105
- const merged = { ...slotProps };
106
- for (const key in childProps) {
107
- const slotValue = slotProps[key];
108
- const childValue = childProps[key];
109
- if (/^on[A-Z]/.test(key)) {
110
- if (typeof slotValue === "function" && typeof childValue === "function") {
111
- merged[key] = (...args) => {
112
- slotValue(...args);
113
- childValue(...args);
114
- };
115
- } else {
116
- merged[key] = childValue ?? slotValue;
117
- }
118
- } else if (key === "className") {
119
- merged[key] = (0, import_clsx2.default)(slotValue, childValue);
120
- } else if (key === "style") {
121
- merged[key] = { ...slotValue, ...childValue };
122
- } else {
123
- merged[key] = childValue;
124
- }
125
- }
126
- return merged;
127
- }
128
- function getElementRef(element) {
129
- const asRecord = element;
130
- return asRecord.props?.ref ?? asRecord.ref;
131
- }
132
- function composeRefs(...refs) {
133
- return (node) => {
134
- for (const ref of refs) {
135
- if (!ref) continue;
136
- if (typeof ref === "function") {
137
- ref(node);
138
- } else {
139
- ref.current = node;
140
- }
141
- }
142
- };
143
- }
144
-
145
- // src/components/forms/control-size.tsx
146
- var import_react2 = require("react");
147
- var import_jsx_runtime = require("react/jsx-runtime");
148
- var ControlSizeContext = (0, import_react2.createContext)(null);
149
- function useControlSize(explicit) {
150
- const inherited = (0, import_react2.useContext)(ControlSizeContext);
151
- return explicit ?? inherited ?? "md";
152
- }
153
-
154
- // src/components/forms/icon-button.tsx
155
- var import_react3 = require("react");
156
- var import_clsx3 = __toESM(require("clsx"), 1);
157
- var import_jsx_runtime2 = require("react/jsx-runtime");
158
- var variantStyles = {
159
- primary: (0, import_clsx3.default)(
160
- "bg-brand border border-brand text-brand-on-brand",
161
- "hover:bg-brand-hover",
162
- "disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
163
- "aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
164
- ),
165
- // Neutral uses secondary background (light gray) for visual weight without a text label
166
- neutral: (0, import_clsx3.default)(
167
- "bg-default-secondary border border-default text-default",
168
- // icon turns brand blue on hover (Figma spec)
169
- "hover:bg-default-secondary-hover hover:text-brand",
170
- "disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
171
- "aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
172
- ),
173
- subtle: (0, import_clsx3.default)(
174
- "bg-transparent text-neutral",
175
- // hover uses background-default-default-hover (#f5f5f5), icon turns brand blue (Figma spec)
176
- "hover:bg-default-hover hover:text-brand",
177
- // disabled needs explicit border since there is no base border
178
- "disabled:bg-disabled disabled:border disabled:border-disabled disabled:text-disabled-on-disabled",
179
- "aria-disabled:bg-disabled aria-disabled:border aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
180
- )
181
- };
182
- var sizeStyles = {
183
- lg: "size-12 rounded-2xl [&_svg]:size-5",
184
- md: "size-9 rounded-lg [&_svg]:size-5",
185
- sm: "size-6 rounded-full [&_svg]:size-4"
186
- };
187
- var IconButton = (0, import_react3.forwardRef)(function IconButton2({
188
- variant = "primary",
189
- size: sizeProp,
190
- asChild = false,
191
- type,
192
- disabled,
193
- onClick,
194
- children,
195
- className,
196
- ...props
197
- }, ref) {
198
- const size = useControlSize(sizeProp);
199
- const softDisabled = asChild && Boolean(disabled);
200
- const handleClick = (event) => {
201
- if (softDisabled) {
202
- event.preventDefault();
203
- event.stopPropagation();
204
- return;
205
- }
206
- onClick?.(event);
207
- };
208
- const rootProps = {
209
- // `cn`, so a caller's `className` beats the size's radius and the variant's colours.
210
- className: cn(
211
- "inline-flex shrink-0 items-center justify-center transition-colors",
212
- FOCUS_RING,
213
- "disabled:cursor-not-allowed aria-disabled:cursor-not-allowed",
214
- variantStyles[variant],
215
- sizeStyles[size],
216
- className
217
- ),
218
- "data-variant": variant,
219
- "data-size": size,
220
- "aria-disabled": softDisabled || void 0,
221
- onClick: handleClick,
222
- ...props
223
- };
224
- if (asChild) {
225
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Slot, { ref, tabIndex: disabled ? -1 : void 0, ...rootProps, children });
226
- }
227
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
228
- "button",
229
- {
230
- ref,
231
- type: type ?? "button",
232
- disabled,
233
- ...rootProps,
234
- children
235
- }
236
- );
237
- });
238
-
239
- // src/components/avatar/avatar.tsx
240
- var import_clsx4 = __toESM(require("clsx"), 1);
241
- var import_jsx_runtime3 = require("react/jsx-runtime");
242
- var sizeStyles2 = {
243
- lg: "size-10",
244
- md: "size-8",
245
- sm: "size-6"
246
- };
247
- var initialTextStyles = {
248
- lg: "text-body font-semibold",
249
- md: "text-body-xs font-semibold",
250
- sm: "text-body-tiny font-semibold"
251
- };
252
- function getShapeClass(shape, size) {
253
- if (shape === "circle") return "rounded-full";
254
- return size === "sm" ? "rounded" : "rounded-lg";
255
- }
256
- function Avatar(props) {
257
- const { size = "lg", shape = "circle", className } = props;
258
- const base = (0, import_clsx4.default)(
259
- "shrink-0 overflow-hidden",
260
- sizeStyles2[size],
261
- getShapeClass(shape, size),
262
- className
263
- );
264
- if (props.type === "image") {
265
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: base, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
266
- "img",
267
- {
268
- src: props.src,
269
- alt: props.alt ?? "",
270
- className: "size-full object-cover"
271
- }
272
- ) });
273
- }
274
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
275
- "div",
276
- {
277
- className: (0, import_clsx4.default)(base, "flex items-center justify-center"),
278
- style: {
279
- background: "linear-gradient(135deg, var(--color-graphic-blue) 30%, var(--color-graphic-red) 100%)"
280
- },
281
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
282
- "span",
283
- {
284
- className: (0, import_clsx4.default)(
285
- "select-none leading-none text-brand-on-brand",
286
- initialTextStyles[size]
287
- ),
288
- children: props.initial.charAt(0).toUpperCase()
289
- }
290
- )
291
- }
292
- );
293
- }
294
-
295
- // src/lib/use-controllable-state.ts
296
- var import_react4 = require("react");
297
- function useControllableState({
298
- value,
299
- defaultValue,
300
- onChange
301
- }) {
302
- const [internal, setInternal] = (0, import_react4.useState)(defaultValue);
303
- const isControlled = value !== void 0;
304
- const current = isControlled ? value : internal;
305
- const onChangeRef = (0, import_react4.useRef)(onChange);
306
- onChangeRef.current = onChange;
307
- const currentRef = (0, import_react4.useRef)(current);
308
- currentRef.current = current;
309
- const isControlledRef = (0, import_react4.useRef)(isControlled);
310
- isControlledRef.current = isControlled;
311
- const setValue = (0, import_react4.useCallback)((next) => {
312
- const resolved = typeof next === "function" ? next(currentRef.current) : next;
313
- if (resolved === currentRef.current) return;
314
- if (!isControlledRef.current) setInternal(resolved);
315
- onChangeRef.current?.(resolved);
316
- }, []);
317
- return [current, setValue];
318
- }
319
-
320
- // src/components/overlays/menu-styles.ts
321
- var import_clsx6 = __toESM(require("clsx"), 1);
322
47
 
323
48
  // src/lib/scrollbar.ts
324
- var import_clsx5 = __toESM(require("clsx"), 1);
325
- var SCROLLBAR_CLASSES = (0, import_clsx5.default)(
49
+ var import_clsx = __toESM(require("clsx"), 1);
50
+ var SCROLLBAR_CLASSES = (0, import_clsx.default)(
326
51
  // Firefox and the standard property.
327
52
  "[scrollbar-color:var(--color-background-default-tertiary)_transparent] [scrollbar-width:thin]",
328
53
  // WebKit/Blink.
@@ -333,1571 +58,25 @@ var SCROLLBAR_CLASSES = (0, import_clsx5.default)(
333
58
  "[&::-webkit-scrollbar-corner]:bg-transparent"
334
59
  );
335
60
 
336
- // src/components/overlays/menu-styles.ts
337
- var OVERLAY_PANEL = "rounded-lg border border-default bg-default p-1 shadow-300";
338
- var OVERLAY_PANEL_MENU = (0, import_clsx6.default)(OVERLAY_PANEL, "min-w-[168px]");
339
- var OVERLAY_PANEL_SCROLL = (0, import_clsx6.default)(
340
- "max-h-[min(16rem,var(--panel-available-height,16rem))] overflow-y-auto",
341
- // A floating panel is already its own scroll container and keeps focus on the input or a
342
- // roving option, so it needs the scrollbar styling but not `ScrollArea`'s tab stop.
343
- SCROLLBAR_CLASSES
344
- );
345
- var OVERLAY_ITEM_BASE = "flex w-full cursor-pointer select-none items-start gap-2 rounded-md text-left outline-none transition-colors";
346
- var OVERLAY_ITEM_SIZE = {
347
- lg: "px-3 py-2.5 text-body",
348
- md: "px-2.5 py-2 text-body-sm",
349
- sm: "px-2 py-1.5 text-body-tiny"
350
- };
351
- function overlayItemTone(tone, disabled) {
352
- if (disabled) return "cursor-not-allowed text-disabled";
353
- return tone === "danger" ? "text-danger hover:bg-danger-tertiary focus:bg-danger-tertiary" : "text-default hover:bg-default-secondary focus:bg-default-secondary";
354
- }
355
- var OVERLAY_HEADING = "px-2.5 py-1.5 text-body-tiny font-semibold uppercase tracking-wide text-default-tertiary";
356
- var OVERLAY_SEPARATOR = "-mx-1 my-1 h-px bg-divider";
357
-
358
- // src/components/overlays/overlay.ts
359
- var import_react6 = require("react");
360
- var import_tabbable = require("tabbable");
361
-
362
- // src/components/overlays/overlay-stack.ts
363
- var import_react5 = require("react");
364
- var layers = [];
365
- var deferredEscapes = /* @__PURE__ */ new WeakSet();
366
- function deferEscapeToInnerPopup(event) {
367
- const target = event.target;
368
- const fromOpenCombobox = target instanceof Element && target.closest('[role="combobox"][aria-expanded="true"]') !== null;
369
- if (layers.length === 0 && !fromOpenCombobox) return false;
370
- deferredEscapes.add(event);
371
- event.preventDefault();
372
- return true;
373
- }
374
-
375
- // src/components/overlays/overlay.ts
376
- var OVERLAY_SCRIM = "bg-overlay";
377
-
378
- // src/components/overlays/portal.tsx
379
- var import_react7 = require("react");
380
- var import_react_dom = require("react-dom");
381
- var import_jsx_runtime4 = require("react/jsx-runtime");
382
- var PortalContainerContext = (0, import_react7.createContext)(null);
383
- function PortalContainerProvider({
384
- container,
385
- children
386
- }) {
387
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PortalContainerContext.Provider, { value: container, children });
388
- }
389
- function usePortalContainer() {
390
- return (0, import_react7.useContext)(PortalContainerContext);
391
- }
392
-
393
- // src/lib/compose-event-handlers.ts
394
- function composeEventHandlers(theirs, ours) {
395
- return (event) => {
396
- theirs?.(event);
397
- if (!event.defaultPrevented) ours(event);
398
- };
399
- }
400
-
401
- // src/components/overlays/toaster-guard.ts
402
- var TOASTER_ATTRIBUTE = "data-platned-toaster";
403
- function isInsideToaster(target) {
404
- return target instanceof Element && target.closest(`[${TOASTER_ATTRIBUTE}]`) !== null;
405
- }
406
-
407
- // src/components/overlays/tooltip.tsx
408
- var import_react8 = require("react");
409
- var import_radix_ui = require("radix-ui");
410
- var import_jsx_runtime5 = require("react/jsx-runtime");
411
- function Tooltip({
412
- children,
413
- title,
414
- body,
415
- side = "top",
416
- align = "center",
417
- openDelay = 150,
418
- open,
419
- defaultOpen,
420
- onOpenChange,
421
- association = "describedby",
422
- className
423
- }) {
424
- const container = usePortalContainer();
425
- const labelId = (0, import_react8.useId)();
426
- const labelled = association === "labelledby";
427
- const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
428
- title && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "font-semibold", children: title }),
429
- body && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: cn(title && "mt-0.5 opacity-80"), children: body })
430
- ] });
431
- 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: [
432
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
433
- import_radix_ui.Tooltip.Trigger,
434
- {
435
- asChild: true,
436
- ...labelled ? { "aria-labelledby": labelId, "aria-describedby": void 0 } : {},
437
- children
438
- }
439
- ),
440
- labelled && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { id: labelId, hidden: true, children: [
441
- title,
442
- body ? " " : null,
443
- body
444
- ] }),
445
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_radix_ui.Tooltip.Portal, { container: container ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
446
- import_radix_ui.Tooltip.Content,
447
- {
448
- side,
449
- align,
450
- sideOffset: 6,
451
- collisionPadding: 8,
452
- className: cn(
453
- "z-tooltip max-w-[260px] rounded-lg bg-neutral px-3 py-2 shadow-300",
454
- "text-body-xs text-neutral-on-neutral",
455
- className
456
- ),
457
- children: content
458
- }
459
- ) })
460
- ] }) });
461
- }
462
-
463
- // src/components/overlays/menu-core.tsx
464
- var import_react9 = require("react");
465
- var import_clsx7 = __toESM(require("clsx"), 1);
466
- var import_lucide_react = require("lucide-react");
467
- var import_jsx_runtime6 = require("react/jsx-runtime");
468
- var MENU_PANEL_CLASSES = cn("z-popover", OVERLAY_PANEL_MENU, "focus:outline-none");
469
- var ITEM_BASE = (0, import_clsx7.default)(
470
- OVERLAY_ITEM_BASE,
471
- OVERLAY_ITEM_SIZE.md,
472
- // Highlight follows Radix's `data-highlighted`, which tracks pointer and keyboard alike.
473
- // The ring marks the keyboard position on top of it: the tint alone, shared with hover,
474
- // cannot tell a keyboard user which of two tinted items has focus.
475
- FOCUS_RING_INSET,
476
- "data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled"
477
- );
478
- var ITEM_TONE = {
479
- default: "text-default data-[highlighted]:bg-default-secondary",
480
- danger: "text-danger data-[highlighted]:bg-danger-tertiary"
481
- };
482
- function stopToAncestors(event) {
483
- event.stopPropagation();
484
- }
485
- function focusMenuEdge(event, edge) {
486
- if (event.target !== event.currentTarget) return;
487
- const panel = event.currentTarget;
488
- queueMicrotask(() => {
489
- const items = panel.querySelectorAll('[role^="menuitem"]:not([data-disabled])');
490
- if (edge === "end") items[items.length - 1]?.focus();
491
- else if (document.activeElement === panel) items[0]?.focus();
492
- });
493
- }
494
- function visibleMenuItems(items) {
495
- const kept = items.filter((item) => {
496
- if (item.hidden) return false;
497
- if (item.type === "group" || item.type === "submenu") return visibleMenuItems(item.items).length > 0;
498
- return true;
499
- });
500
- return kept.filter((item, i) => {
501
- if (item.type !== "separator") return true;
502
- const prev = kept[i - 1];
503
- return i > 0 && i < kept.length - 1 && prev.type !== "separator";
504
- });
505
- }
506
- function createMenuParts(P) {
507
- const Item = (0, import_react9.forwardRef)(function MenuItem({ children, onSelect, tone = "default", disabled = false, icon, description, shortcut, textValue, className, ...rest }, ref) {
508
- const descriptionId = (0, import_react9.useId)();
509
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
510
- P.Item,
511
- {
512
- ref,
513
- disabled,
514
- textValue,
515
- onSelect,
516
- "data-tone": tone,
517
- "aria-describedby": description ? descriptionId : void 0,
518
- className: cn(ITEM_BASE, ITEM_TONE[tone], className),
519
- ...rest,
520
- children: [
521
- 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 }),
522
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "min-w-0 flex-1", children: [
523
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "block truncate", children }),
524
- description && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { id: descriptionId, className: "mt-0.5 block text-body-tiny text-default-secondary", children: description })
525
- ] }),
526
- shortcut && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary", children: shortcut })
527
- ]
528
- }
529
- );
530
- });
531
- const CheckboxItem = (0, import_react9.forwardRef)(function MenuCheckboxItem({ children, checked, onCheckedChange, disabled = false, tone = "default", shortcut, textValue, className, ...rest }, ref) {
532
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
533
- P.CheckboxItem,
534
- {
535
- ref,
536
- checked,
537
- onCheckedChange: (next) => onCheckedChange?.(next === true),
538
- onSelect: (event) => event.preventDefault(),
539
- disabled,
540
- textValue,
541
- "data-tone": tone,
542
- className: cn(ITEM_BASE, "items-center", ITEM_TONE[tone], className),
543
- ...rest,
544
- children: [
545
- /* @__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 }) }) }),
546
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children }),
547
- shortcut && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary", children: shortcut })
548
- ]
549
- }
550
- );
551
- });
552
- function RadioGroup({ children, value, onValueChange }) {
553
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.RadioGroup, { value, onValueChange, children });
554
- }
555
- const RadioItem = (0, import_react9.forwardRef)(function MenuRadioItem({ children, value, disabled = false, tone = "default", textValue, className, ...rest }, ref) {
556
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
557
- P.RadioItem,
558
- {
559
- ref,
560
- value,
561
- disabled,
562
- textValue,
563
- "data-tone": tone,
564
- className: cn(ITEM_BASE, "items-center", ITEM_TONE[tone], className),
565
- ...rest,
566
- children: [
567
- /* @__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" }) }) }),
568
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children })
569
- ]
570
- }
571
- );
572
- });
573
- const Group = (0, import_react9.forwardRef)(function MenuGroup({ children, label, className, ...rest }, ref) {
574
- const labelId = (0, import_react9.useId)();
575
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(P.Group, { ref, "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
576
- label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { id: labelId, className: OVERLAY_HEADING, children: label }),
577
- children
578
- ] });
579
- });
580
- const Label = (0, import_react9.forwardRef)(function MenuLabel({ className, ...rest }, ref) {
581
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Label, { ref, className: cn(OVERLAY_HEADING, className), ...rest });
582
- });
583
- const Separator = (0, import_react9.forwardRef)(function MenuSeparator({ className, ...rest }, ref) {
584
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Separator, { ref, className: cn(OVERLAY_SEPARATOR, className), ...rest });
585
- });
586
- const Shortcut = (0, import_react9.forwardRef)(function MenuShortcut({ className, ...rest }, ref) {
587
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref, className: cn("ml-auto pl-4 text-body-tiny text-default-tertiary", className), ...rest });
588
- });
589
- function Sub({ children, open, defaultOpen, onOpenChange }) {
590
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Sub, { open, defaultOpen, onOpenChange, children });
591
- }
592
- const SubTrigger = (0, import_react9.forwardRef)(function MenuSubTrigger({ children, icon, disabled = false, textValue, className, ...rest }, ref) {
593
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
594
- P.SubTrigger,
595
- {
596
- ref,
597
- disabled,
598
- textValue,
599
- className: cn(
600
- ITEM_BASE,
601
- "items-center",
602
- ITEM_TONE.default,
603
- "data-[state=open]:bg-default-secondary",
604
- className
605
- ),
606
- ...rest,
607
- children: [
608
- icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": true, className: "flex size-4 shrink-0 items-center justify-center", children: icon }),
609
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children }),
610
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.ChevronRightIcon, { "aria-hidden": true, className: "ml-auto size-4 shrink-0 text-default-tertiary" })
611
- ]
612
- }
613
- );
614
- });
615
- const SubContent = (0, import_react9.forwardRef)(function MenuSubContent({ className, onClick, onKeyDown, ...rest }, ref) {
616
- const container = usePortalContainer();
617
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Portal, { container: container ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
618
- P.SubContent,
619
- {
620
- ref,
621
- sideOffset: 4,
622
- collisionPadding: 8,
623
- className: cn(MENU_PANEL_CLASSES, className),
624
- onClick: (event) => {
625
- onClick?.(event);
626
- stopToAncestors(event);
627
- },
628
- onKeyDown: (event) => {
629
- onKeyDown?.(event);
630
- stopToAncestors(event);
631
- },
632
- ...rest
633
- }
634
- ) });
635
- });
636
- function Items({ items }) {
637
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: visibleMenuItems(items).map(renderItem) });
638
- }
639
- function renderItem(item) {
640
- switch (item.type) {
641
- case "checkbox":
642
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
643
- CheckboxItem,
644
- {
645
- checked: item.checked,
646
- onCheckedChange: item.onCheckedChange,
647
- disabled: item.disabled,
648
- shortcut: item.shortcut,
649
- textValue: item.textValue,
650
- children: item.label
651
- },
652
- item.id
653
- );
654
- case "radio":
655
- 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);
656
- case "group":
657
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Group, { label: item.label, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Items, { items: item.items }) }, item.id);
658
- case "submenu":
659
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Sub, { children: [
660
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SubTrigger, { icon: item.icon, disabled: item.disabled, children: item.label }),
661
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SubContent, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Items, { items: item.items }) })
662
- ] }, item.id);
663
- case "label":
664
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { children: item.label }, item.id);
665
- case "separator":
666
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Separator, {}, item.id);
667
- case "custom":
668
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react9.Fragment, { children: item.render() }, item.id);
669
- default:
670
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
671
- Item,
672
- {
673
- onSelect: item.onSelect,
674
- tone: item.tone,
675
- disabled: item.disabled,
676
- icon: item.icon,
677
- description: item.description,
678
- shortcut: item.shortcut,
679
- textValue: item.textValue,
680
- children: item.label
681
- },
682
- item.id
683
- );
684
- }
685
- }
686
- return {
687
- Items,
688
- Item,
689
- CheckboxItem,
690
- RadioGroup,
691
- RadioItem,
692
- Group,
693
- Label,
694
- Separator,
695
- Shortcut,
696
- Sub,
697
- SubTrigger,
698
- SubContent
699
- };
700
- }
701
-
702
- // src/components/overlays/drawer.tsx
703
- var import_react11 = require("react");
704
- var import_radix_ui2 = require("radix-ui");
705
- var import_lucide_react2 = require("lucide-react");
706
-
707
- // src/components/cards/scroll-area.tsx
708
- var import_react10 = require("react");
709
- var import_clsx8 = __toESM(require("clsx"), 1);
710
- var import_jsx_runtime7 = require("react/jsx-runtime");
711
- var OVERFLOW = {
712
- vertical: "overflow-y-auto overflow-x-hidden",
713
- horizontal: "overflow-x-auto overflow-y-hidden",
714
- both: "overflow-auto"
715
- };
716
- var ScrollArea = (0, import_react10.forwardRef)(function ScrollArea2({ children, axis = "vertical", label, className, ...rest }, ref) {
717
- const localRef = (0, import_react10.useRef)(null);
718
- const [overflows, setOverflows] = (0, import_react10.useState)(false);
719
- (0, import_react10.useEffect)(() => {
720
- const node = localRef.current;
721
- if (!node) return;
722
- const measure = () => {
723
- const vertical = node.scrollHeight > node.clientHeight + 1;
724
- const horizontal = node.scrollWidth > node.clientWidth + 1;
725
- setOverflows(
726
- axis === "vertical" ? vertical : axis === "horizontal" ? horizontal : vertical || horizontal
727
- );
728
- };
729
- measure();
730
- if (typeof ResizeObserver === "undefined") return;
731
- const observer = new ResizeObserver(measure);
732
- observer.observe(node);
733
- if (node.firstElementChild) observer.observe(node.firstElementChild);
734
- return () => observer.disconnect();
735
- }, [axis, children]);
736
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
737
- "div",
738
- {
739
- ref: composeRefs(localRef, ref),
740
- role: overflows && label ? "region" : void 0,
741
- "aria-label": overflows ? label : void 0,
742
- tabIndex: overflows ? 0 : void 0,
743
- "data-slot": "scroll-area",
744
- className: (0, import_clsx8.default)(
745
- OVERFLOW[axis],
746
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default",
747
- SCROLLBAR_CLASSES,
748
- className
749
- ),
750
- ...rest,
751
- children
752
- }
753
- );
754
- });
755
-
756
- // src/components/overlays/drawer.tsx
757
- var import_jsx_runtime8 = require("react/jsx-runtime");
758
- var DrawerNaming = (0, import_react11.createContext)(null);
759
- var Drawer = (0, import_react11.forwardRef)(function Drawer2({
760
- open,
761
- defaultOpen,
762
- onOpenChange,
763
- header,
764
- children,
765
- footer,
766
- footerAlign = "end",
767
- width = "w-[440px] max-w-[90vw]",
768
- side = "right",
769
- label,
770
- className,
771
- onEscapeKeyDown,
772
- onInteractOutside,
773
- initialFocus,
774
- container
775
- }, ref) {
776
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_radix_ui2.Dialog.Root, { open, defaultOpen, onOpenChange, children: [
777
- extractTrigger(children),
778
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Portal, { container: container ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
779
- DrawerPanel,
780
- {
781
- ref,
782
- side,
783
- width,
784
- label,
785
- className,
786
- onEscapeKeyDown,
787
- onInteractOutside,
788
- initialFocus,
789
- children: header !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
790
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DrawerHeader, { children: header }),
791
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DrawerBody, { label, children: withoutTrigger(children) }),
792
- footer && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DrawerFooter, { align: footerAlign, children: footer })
793
- ] }) : withoutTrigger(children)
794
- }
795
- ) })
796
- ] });
797
- });
798
- var DrawerPanel = (0, import_react11.forwardRef)(function DrawerPanel2({ side = "right", width, label, className, onEscapeKeyDown, onInteractOutside, initialFocus, children }, ref) {
799
- const [hasTitle, setHasTitle] = (0, import_react11.useState)(false);
800
- const [hasDescription, setHasDescription] = (0, import_react11.useState)(false);
801
- const [panelNode, setPanelNode] = (0, import_react11.useState)(null);
802
- const [returnFocusTo] = (0, import_react11.useState)(
803
- () => typeof document === "undefined" ? null : document.activeElement
804
- );
805
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
806
- import_radix_ui2.Dialog.Overlay,
807
- {
808
- className: cn(
809
- "fixed inset-0 z-modal flex",
810
- side === "right" ? "justify-end" : "justify-start",
811
- OVERLAY_SCRIM
812
- ),
813
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
814
- import_radix_ui2.Dialog.Content,
815
- {
816
- asChild: true,
817
- ...hasDescription ? {} : { "aria-describedby": void 0 },
818
- onOpenAutoFocus: (event) => {
819
- const target = initialFocus?.current;
820
- if (target) {
821
- event.preventDefault();
822
- target.focus();
823
- }
824
- },
825
- onCloseAutoFocus: (event) => {
826
- if (returnFocusTo?.isConnected && returnFocusTo !== document.body) {
827
- event.preventDefault();
828
- returnFocusTo.focus();
829
- }
830
- },
831
- onEscapeKeyDown: (event) => {
832
- if (!deferEscapeToInnerPopup(event)) onEscapeKeyDown?.(event);
833
- },
834
- onPointerDownOutside: (event) => {
835
- if (isInsideToaster(event.target)) {
836
- event.preventDefault();
837
- return;
838
- }
839
- const original = event.detail.originalEvent;
840
- onInteractOutside?.(original);
841
- if (original.defaultPrevented) event.preventDefault();
842
- },
843
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
844
- "div",
845
- {
846
- ref: composeRefs(ref, setPanelNode),
847
- "data-side": side,
848
- className: cn(
849
- "relative flex h-full flex-col bg-default shadow-500 focus:outline-none",
850
- width,
851
- className
852
- ),
853
- children: [
854
- !hasTitle && label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Title, { className: "sr-only", children: label }),
855
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
856
- DrawerNaming.Provider,
857
- {
858
- value: { registerTitle: setHasTitle, registerDescription: setHasDescription },
859
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PortalContainerProvider, { container: panelNode, children })
860
- }
861
- )
862
- ]
863
- }
864
- )
865
- }
866
- )
867
- }
868
- );
869
- });
870
- var DrawerTrigger = (0, import_react11.forwardRef)(
871
- function DrawerTrigger2(props, ref) {
872
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Trigger, { ref, ...props });
873
- }
874
- );
875
- DrawerTrigger.__drawerTrigger = true;
876
- var DrawerClose = (0, import_react11.forwardRef)(
877
- function DrawerClose2(props, ref) {
878
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Close, { ref, ...props });
879
- }
880
- );
881
- function isTrigger(node) {
882
- return typeof node === "object" && node !== null && "type" in node && node.type?.__drawerTrigger === true;
883
- }
884
- function extractTrigger(children) {
885
- return Array.isArray(children) ? children.filter(isTrigger) : isTrigger(children) ? children : null;
886
- }
887
- function withoutTrigger(children) {
888
- return Array.isArray(children) ? children.filter((child) => !isTrigger(child)) : isTrigger(children) ? null : children;
889
- }
890
- var DrawerHeader = (0, import_react11.forwardRef)(function DrawerHeader2({ children, showClose = true, className, ...rest }, ref) {
891
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
892
- "div",
893
- {
894
- ref,
895
- className: cn("flex items-start justify-between gap-3 border-b border-default p-6", className),
896
- ...rest,
897
- children: [
898
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "min-w-0", children }),
899
- showClose && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IconButton, { variant: "subtle", size: "sm", "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.XIcon, { size: 18, "aria-hidden": true }) }) })
900
- ]
901
- }
902
- );
903
- });
904
- var DrawerTitle = (0, import_react11.forwardRef)(function DrawerTitle2({ className, children, ...rest }, ref) {
905
- const naming = (0, import_react11.useContext)(DrawerNaming);
906
- (0, import_react11.useEffect)(() => {
907
- naming?.registerTitle(true);
908
- return () => naming?.registerTitle(false);
909
- }, [naming]);
910
- const classes = cn("text-heading-sm font-semibold text-default", className);
911
- if (!naming) {
912
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { ref, className: classes, ...rest, children });
913
- }
914
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Title, { ref, className: classes, ...rest, children });
915
- });
916
- var DrawerDescription = (0, import_react11.forwardRef)(
917
- function DrawerDescription2({ className, ...rest }, ref) {
918
- const naming = (0, import_react11.useContext)(DrawerNaming);
919
- (0, import_react11.useEffect)(() => {
920
- naming?.registerDescription(true);
921
- return () => naming?.registerDescription(false);
922
- }, [naming]);
923
- const classes = cn("mt-0.5 text-body-xs text-default-secondary", className);
924
- if (!naming) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { ref, className: classes, ...rest });
925
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Description, { ref, className: classes, ...rest });
926
- }
927
- );
928
- var DrawerBody = (0, import_react11.forwardRef)(function DrawerBody2({ children, label, className, ...rest }, ref) {
929
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
930
- ScrollArea,
931
- {
932
- ref,
933
- axis: "vertical",
934
- label: label ? `${label} content` : "Content",
935
- className: "min-h-0 flex-1",
936
- ...rest,
937
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn("space-y-6 p-6", className), children })
938
- }
939
- );
940
- });
941
- var DrawerFooter = (0, import_react11.forwardRef)(function DrawerFooter2({ align = "end", className, ...rest }, ref) {
942
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
943
- "div",
944
- {
945
- ref,
946
- "data-align": align,
947
- className: cn(
948
- "flex items-center gap-2 border-t border-default px-6 py-4",
949
- align === "between" ? "justify-between" : "justify-end",
950
- className
951
- ),
952
- ...rest
953
- }
954
- );
955
- });
956
-
957
- // src/components/overlays/dropdown-menu.tsx
958
- var import_react12 = require("react");
959
- var import_radix_ui3 = require("radix-ui");
960
- var import_lucide_react3 = require("lucide-react");
961
- var import_jsx_runtime9 = require("react/jsx-runtime");
962
- var DropdownMenuStateContext = (0, import_react12.createContext)(null);
963
- function useDropdownMenuState(part) {
964
- const value = (0, import_react12.useContext)(DropdownMenuStateContext);
965
- if (!value) throw new Error(`<${part}> must be used inside <DropdownMenu>`);
966
- return value;
967
- }
968
- function DropdownMenu({
969
- children,
970
- items,
971
- trigger,
972
- label,
973
- side,
974
- align,
975
- open: openProp,
976
- defaultOpen = false,
977
- onOpenChange,
978
- modal = false
979
- }) {
980
- const [open, setOpen] = useControllableState({
981
- value: openProp,
982
- defaultValue: defaultOpen,
983
- onChange: onOpenChange
984
- });
985
- const pendingEdge = (0, import_react12.useRef)("start");
986
- const state = (0, import_react12.useMemo)(() => ({ setOpen, pendingEdge }), [setOpen]);
987
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuStateContext.Provider, { value: state, children: items ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
988
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuTrigger, { asChild: trigger != null, label, children: trigger }),
989
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuContent, { side, align, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuItems, { items }) })
990
- ] }) : children }) });
991
- }
992
- var DropdownMenuTrigger = (0, import_react12.forwardRef)(
993
- function DropdownMenuTrigger2({ children, asChild = false, label = "Open menu", onClick, onPointerDown, onMouseDown, onKeyDown, ...rest }, ref) {
994
- const state = useDropdownMenuState("DropdownMenuTrigger");
995
- const handlers = {
996
- onClick: (event) => {
997
- onClick?.(event);
998
- stopToAncestors(event);
999
- },
1000
- onPointerDown: (event) => {
1001
- onPointerDown?.(event);
1002
- event.stopPropagation();
1003
- },
1004
- onMouseDown: (event) => {
1005
- onMouseDown?.(event);
1006
- stopToAncestors(event);
1007
- },
1008
- onKeyDown: (event) => {
1009
- onKeyDown?.(event);
1010
- if (event.defaultPrevented) return;
1011
- if (event.key === "ArrowUp") {
1012
- event.preventDefault();
1013
- state.pendingEdge.current = "end";
1014
- state.setOpen(true);
1015
- }
1016
- if (event.key === "Enter" || event.key === " ") stopToAncestors(event);
1017
- }
1018
- };
1019
- if (asChild) {
1020
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children });
1021
- }
1022
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(IconButton, { variant: "neutral", size: "sm", "aria-label": label, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.EllipsisIcon, { className: "size-4", "aria-hidden": true }) }) });
1023
- }
1024
- );
1025
- var DropdownMenuContent = (0, import_react12.forwardRef)(
1026
- function DropdownMenuContent2({
1027
- children,
1028
- side = "bottom",
1029
- align = "end",
1030
- sideOffset = 6,
1031
- container,
1032
- className,
1033
- onClick,
1034
- onKeyDown,
1035
- onFocus,
1036
- onCloseAutoFocus,
1037
- ...rest
1038
- }, ref) {
1039
- const state = useDropdownMenuState("DropdownMenuContent");
1040
- const inherited = usePortalContainer();
1041
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Portal, { container: container ?? inherited ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1042
- import_radix_ui3.DropdownMenu.Content,
1043
- {
1044
- ref,
1045
- side,
1046
- align,
1047
- sideOffset,
1048
- collisionPadding: 8,
1049
- loop: true,
1050
- className: cn(MENU_PANEL_CLASSES, className),
1051
- onCloseAutoFocus: composeEventHandlers(onCloseAutoFocus, () => {
1052
- state.pendingEdge.current = "start";
1053
- }),
1054
- onFocus: composeEventHandlers(onFocus, (event) => {
1055
- const edge = state.pendingEdge.current;
1056
- state.pendingEdge.current = "start";
1057
- focusMenuEdge(event, edge);
1058
- }),
1059
- onClick: (event) => {
1060
- onClick?.(event);
1061
- stopToAncestors(event);
1062
- },
1063
- onKeyDown: (event) => {
1064
- onKeyDown?.(event);
1065
- stopToAncestors(event);
1066
- if (event.key === "Tab") state.setOpen(false);
1067
- },
1068
- ...rest,
1069
- children
1070
- }
1071
- ) });
1072
- }
1073
- );
1074
- var parts = createMenuParts(import_radix_ui3.DropdownMenu);
1075
- var DropdownMenuItems = parts.Items;
1076
- var DropdownMenuItem = parts.Item;
1077
- var DropdownMenuCheckboxItem = parts.CheckboxItem;
1078
- var DropdownMenuRadioGroup = parts.RadioGroup;
1079
- var DropdownMenuRadioItem = parts.RadioItem;
1080
- var DropdownMenuGroup = parts.Group;
1081
- var DropdownMenuLabel = parts.Label;
1082
- var DropdownMenuSeparator = parts.Separator;
1083
- var DropdownMenuShortcut = parts.Shortcut;
1084
- var DropdownMenuSub = parts.Sub;
1085
- var DropdownMenuSubTrigger = parts.SubTrigger;
1086
- var DropdownMenuSubContent = parts.SubContent;
1087
-
1088
- // src/components/chrome/nav-item.tsx
1089
- var import_react13 = require("react");
1090
- var import_clsx9 = __toESM(require("clsx"), 1);
1091
- var import_lucide_react4 = require("lucide-react");
1092
- var import_jsx_runtime10 = require("react/jsx-runtime");
1093
- var SIZE = {
1094
- sm: { box: "h-9 gap-2 rounded-lg px-3 py-1.5", label: "text-body-xs", square: "w-9" },
1095
- md: { box: "h-11 gap-3 rounded-xl px-3.5 py-2.5", label: "text-body-sm", square: "w-11" }
1096
- };
1097
- function monogram(label) {
1098
- const words = label.split(/\s+/).filter((word) => /^[\p{L}\p{N}]/u.test(word));
1099
- const [first, second] = words;
1100
- if (!first) return Array.from(label.trim())[0]?.toUpperCase() ?? "";
1101
- if (second) return (Array.from(first)[0] + Array.from(second)[0]).toUpperCase();
1102
- const [a, b] = Array.from(first);
1103
- return a.toUpperCase() + (b ?? "").toLowerCase();
1104
- }
1105
- var STATE = {
1106
- // Figma MenuButton `state=hover`. No border change: Figma holds it at #D9D9D9 through
1107
- // hover and moves only the fill and the text.
1108
- hover: "hover:bg-brand-tertiary-hover hover:text-brand",
1109
- // Figma MenuButton `state=focussed`, which is that file's name for selected — see the
1110
- // `isActive` doc comment. Hovering the current row darkens it rather than reverting it to
1111
- // the pale hover tint, which would read as the row losing its selection under the cursor.
1112
- active: "bg-brand text-brand-on-brand hover:bg-brand-hover"
1113
- };
1114
- var VARIANT = {
1115
- card: {
1116
- // `border-transparent` holds the 1px so the icon and label do not shift outward when a
1117
- // row becomes the current one — the same trick, for the same reason, as `button.tsx`.
1118
- // `bg-brand` still paints edge to edge, since backgrounds clip to the border box.
1119
- active: (0, import_clsx9.default)("border border-transparent", STATE.active),
1120
- inactive: (0, import_clsx9.default)("border border-default bg-default text-default-secondary", STATE.hover)
1121
- },
1122
- plain: {
1123
- active: STATE.active,
1124
- inactive: (0, import_clsx9.default)("text-default-secondary", STATE.hover)
1125
- }
1126
- };
1127
- var DENSITY = {
1128
- comfortable: {
1129
- box: "h-11 gap-3 rounded-xl",
1130
- pad: "px-3.5",
1131
- square: "w-11",
1132
- active: (0, import_clsx9.default)("border border-transparent", STATE.active),
1133
- inactive: (0, import_clsx9.default)("border border-default bg-default text-default", STATE.hover),
1134
- disabled: "data-[disabled]:hover:bg-default",
1135
- // Straddles the card's corner, as in Figma.
1136
- dot: "-right-px -top-px",
1137
- railDot: "-right-px -top-px"
1138
- },
1139
- compact: {
1140
- box: "h-10 gap-3 rounded-xl",
1141
- pad: "px-3",
1142
- square: "w-10",
1143
- active: STATE.active,
1144
- inactive: (0, import_clsx9.default)("text-default", STATE.hover),
1145
- disabled: "data-[disabled]:hover:bg-transparent",
1146
- // A plain row has no corner to sit on, so the expanded dot trails the label instead.
1147
- dot: "right-2 top-1/2 -translate-y-1/2",
1148
- railDot: "right-0 top-0"
1149
- }
1150
- };
1151
- var DENSITY_DISABLED = "data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled data-[disabled]:hover:text-disabled";
1152
- var NavItem = (0, import_react13.forwardRef)(function NavItem2({
1153
- icon,
1154
- label,
1155
- isActive = false,
1156
- indicator = false,
1157
- collapsed = false,
1158
- size = "md",
1159
- variant = "card",
1160
- density,
1161
- trailing,
1162
- asChild = false,
1163
- disabled = false,
1164
- children,
1165
- className,
1166
- onClick,
1167
- ...rest
1168
- }, ref) {
1169
- const s = SIZE[size];
1170
- const v = VARIANT[variant];
1171
- const d = density ? DENSITY[density] : null;
1172
- const rootProps = {
1173
- ref,
1174
- "data-density": density,
1175
- // Only meaningful when `asChild` renders a real link — a decorative span with
1176
- // aria-current would be a lie.
1177
- "aria-current": asChild && isActive ? "page" : void 0,
1178
- // Same attribute the disclosure components and `TableRow` use, so the state is
1179
- // addressable from a consumer's CSS. `active` rather than `selected`: a nav row is where
1180
- // you *are* (`aria-current="page"`), which is a different thing from a row you have
1181
- // *picked* (`aria-selected`) — `TableRow` is the latter and says `selected`.
1182
- "data-state": isActive ? "active" : void 0,
1183
- "data-disabled": disabled || void 0,
1184
- "aria-disabled": disabled || void 0,
1185
- className: (0, import_clsx9.default)(
1186
- "relative flex items-center transition-colors",
1187
- // Unconditional: a row can also become focusable by the caller putting it inside a
1188
- // link, which is how `src/sidebar/` uses it. A ring that only appears under `asChild`
1189
- // leaves that case with no visible focus at all.
1190
- // The offset is `default-secondary`, not `default`: a nav row's home is the sidebar
1191
- // rail, and `ring-offset-default` is #FFFFFF, so a focused `plain` row drew a 1px white
1192
- // halo on the #F5F5F5 rail. The offset itself is load-bearing — in dark mode
1193
- // `ring-brand` and `bg-brand` are both #F1F7FD, so without it a focused *active* row
1194
- // would have no visible ring at its inner edge.
1195
- // It is also Figma's focus state for both densities: 1px rail-coloured gap, 3px of brand
1196
- // in all. Figma's compact focus variant draws a 0px shadow — no ring at all — which
1197
- // would fail WCAG 2.4.7, so compact keeps this ring too.
1198
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default-secondary",
1199
- d ? (0, import_clsx9.default)(
1200
- // text-left: a parent row is a <button>, which centres its text by default.
1201
- "group/nav-item text-left",
1202
- d.box,
1203
- collapsed ? (0, import_clsx9.default)("justify-center", d.square) : (0, import_clsx9.default)("w-full", d.pad),
1204
- isActive ? d.active : d.inactive,
1205
- DENSITY_DISABLED,
1206
- d.disabled
1207
- ) : (0, import_clsx9.default)(
1208
- s.box,
1209
- // Expanded rows fill the nav; a collapsed one is a centred square, not a stretched row.
1210
- collapsed ? (0, import_clsx9.default)("justify-center", s.square) : "w-full",
1211
- isActive ? v.active : v.inactive,
1212
- "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40 data-[disabled]:hover:bg-transparent data-[disabled]:hover:text-default-secondary"
1213
- ),
1214
- className
1215
- ),
1216
- ...rest,
1217
- // After the spread: a disabled row refuses the press (a router Link skips navigation when
1218
- // the event is prevented) and leaves the tab order, as a disabled control does.
1219
- ...disabled ? { tabIndex: -1 } : {},
1220
- onClick: (event) => {
1221
- if (disabled) {
1222
- event.preventDefault();
1223
- return;
1224
- }
1225
- onClick?.(event);
1226
- }
1227
- };
1228
- const content = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1229
- icon != null ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1230
- "span",
1231
- {
1232
- "aria-hidden": true,
1233
- className: (0, import_clsx9.default)(
1234
- "shrink-0",
1235
- d ? (0, import_clsx9.default)(
1236
- // Figma: a 20px glyph, icon-secondary at rest, brand under hover,
1237
- // on-brand on the current row, disabled grey on a disabled one.
1238
- "flex size-5 items-center justify-center [&_svg]:size-5",
1239
- disabled ? "text-icon-disabled" : isActive ? "text-icon-brand-on-brand" : "text-icon-default-secondary group-hover/nav-item:text-icon-brand"
1240
- ) : "[&_svg]:size-4"
1241
- ),
1242
- children: icon
1243
- }
1244
- ) : (
1245
- // Icons are optional, but the collapsed rail hides the label — so a row with neither
1246
- // renders as an empty box. Through 0.5.0 that is exactly what a nav without icons
1247
- // collapsed to, the docs site's own 36-row sidebar included. The monogram is
1248
- // decorative in the same way the icon is: the `sr-only` label below still names the
1249
- // row.
1250
- collapsed && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1251
- "span",
1252
- {
1253
- "aria-hidden": true,
1254
- className: "flex h-4 min-w-4 shrink-0 items-center justify-center text-body-tiny font-semibold leading-none tracking-tight",
1255
- children: monogram(label)
1256
- }
1257
- )
1258
- ),
1259
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1260
- "span",
1261
- {
1262
- className: (0, import_clsx9.default)(
1263
- "min-w-0 truncate font-regular",
1264
- d ? "text-body" : (0, import_clsx9.default)("leading-snug", s.label),
1265
- collapsed ? "sr-only" : "flex-1"
1266
- ),
1267
- children: label
1268
- }
1269
- ),
1270
- trailing != null && !collapsed && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-hidden": true, className: "flex shrink-0 items-center [&_svg]:size-4", children: trailing }),
1271
- indicator && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1272
- "span",
1273
- {
1274
- role: "status",
1275
- "aria-label": "Unread",
1276
- className: (0, import_clsx9.default)(
1277
- "absolute size-2 rounded-full bg-danger",
1278
- d ? collapsed ? d.railDot : d.dot : "-right-px -top-px"
1279
- )
1280
- }
1281
- )
1282
- ] });
1283
- if (asChild) {
1284
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { wrapChildren: () => content, ...rootProps, children });
1285
- }
1286
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ...rootProps, children: content });
1287
- });
1288
- var SUB_HEIGHT = { comfortable: "h-11", compact: "h-10" };
1289
- var NavSubItem = (0, import_react13.forwardRef)(function NavSubItem2({
1290
- label,
1291
- isActive = false,
1292
- disabled = false,
1293
- last = false,
1294
- density = "comfortable",
1295
- asChild = false,
1296
- children,
1297
- className,
1298
- onClick,
1299
- ...rest
1300
- }, ref) {
1301
- const rootProps = {
1302
- ref,
1303
- "aria-current": asChild && isActive ? "page" : void 0,
1304
- "data-state": isActive ? "active" : void 0,
1305
- "data-disabled": disabled || void 0,
1306
- "aria-disabled": disabled || void 0,
1307
- className: (0, import_clsx9.default)(
1308
- "relative flex w-full items-center gap-3 rounded-md pl-4 pr-3 transition-colors",
1309
- // Figma's focus variant is a 1px brand border on the hover tint. The transparent
1310
- // border holds the 1px at rest so the label does not move when focus arrives.
1311
- "border border-transparent focus-visible:border-brand focus-visible:bg-brand-secondary focus-visible:text-brand focus-visible:outline-none",
1312
- SUB_HEIGHT[density],
1313
- isActive ? "bg-brand text-brand-on-brand" : "text-default-secondary hover:bg-brand-secondary hover:text-brand",
1314
- "data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled data-[disabled]:hover:bg-transparent data-[disabled]:hover:text-disabled",
1315
- className
1316
- ),
1317
- ...rest,
1318
- ...disabled ? { tabIndex: -1 } : {},
1319
- onClick: (event) => {
1320
- if (disabled) {
1321
- event.preventDefault();
1322
- return;
1323
- }
1324
- onClick?.(event);
1325
- }
1326
- };
1327
- const content = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1328
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NestIndicator, { last }),
1329
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "min-w-0 flex-1 truncate text-body font-regular", children: label })
1330
- ] });
1331
- if (asChild) {
1332
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { wrapChildren: () => content, ...rootProps, children });
1333
- }
1334
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ...rootProps, children: content });
1335
- });
1336
- function NestIndicator({ last }) {
1337
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { "aria-hidden": true, className: "relative w-4 shrink-0 self-stretch", children: [
1338
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1339
- "span",
1340
- {
1341
- className: (0, import_clsx9.default)(
1342
- "absolute left-1/2 top-0 w-px -translate-x-1/2 bg-[var(--prim-stone-400)]",
1343
- last ? "h-1/2" : "h-full"
1344
- )
1345
- }
1346
- ),
1347
- last && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "absolute left-1/2 right-0 top-1/2 h-px bg-[var(--prim-stone-400)]" })
1348
- ] });
1349
- }
1350
- var NavGroupHeader = (0, import_react13.forwardRef)(function NavGroupHeader2({ title, open, onOpenChange, controls, action, className, ...rest }, ref) {
1351
- const collapsible = open !== void 0 && onOpenChange !== void 0;
1352
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref, className: (0, import_clsx9.default)("flex items-center gap-2 pl-2.5", className), ...rest, children: [
1353
- collapsible && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1354
- "button",
1355
- {
1356
- type: "button",
1357
- "aria-expanded": open,
1358
- "aria-controls": controls,
1359
- "aria-label": `${open ? "Collapse" : "Expand"} ${title}`,
1360
- onClick: () => onOpenChange(!open),
1361
- className: (0, import_clsx9.default)(
1362
- "flex shrink-0 items-center justify-center rounded-full p-1 text-icon-default-secondary transition-colors",
1363
- "hover:bg-brand-tertiary-hover hover:text-icon-brand",
1364
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default-secondary"
1365
- ),
1366
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1367
- import_lucide_react4.ChevronDownIcon,
1368
- {
1369
- "aria-hidden": true,
1370
- className: (0, import_clsx9.default)(
1371
- "size-4 transition-transform motion-reduce:transition-none",
1372
- !open && "-rotate-90"
1373
- )
1374
- }
1375
- )
1376
- }
1377
- ),
1378
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "min-w-0 flex-1 truncate text-body font-regular text-neutral-tertiary", children: title }),
1379
- action != null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex shrink-0 items-center", children: action })
1380
- ] });
1381
- });
1382
-
1383
- // src/components/chrome/sidebar.tsx
1384
- var import_react15 = require("react");
1385
- var import_radix_ui4 = require("radix-ui");
1386
- var import_lucide_react5 = require("lucide-react");
1387
- var import_clsx10 = __toESM(require("clsx"), 1);
1388
-
1389
- // src/lib/use-media-query.ts
1390
- var import_react14 = require("react");
1391
- function useMediaQuery(query) {
1392
- const subscribe = (0, import_react14.useCallback)(
1393
- (onChange) => {
1394
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") return () => {
1395
- };
1396
- const list = window.matchMedia(query);
1397
- list.addEventListener("change", onChange);
1398
- return () => list.removeEventListener("change", onChange);
1399
- },
1400
- [query]
1401
- );
1402
- const getSnapshot = () => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : false;
1403
- return (0, import_react14.useSyncExternalStore)(subscribe, getSnapshot, () => false);
1404
- }
1405
-
1406
- // src/components/chrome/sidebar.tsx
1407
- var import_jsx_runtime11 = require("react/jsx-runtime");
1408
- var MOBILE_QUERY = "(max-width: 767.98px)";
1409
- var SidebarContext = (0, import_react15.createContext)(null);
1410
- function useSidebar() {
1411
- const value = (0, import_react15.useContext)(SidebarContext);
1412
- if (!value) throw new Error("useSidebar must be used inside <SidebarProvider>");
1413
- return value;
1414
- }
1415
- function readStored(key) {
1416
- try {
1417
- const value = window.localStorage.getItem(key);
1418
- return value === "true" ? true : value === "false" ? false : null;
1419
- } catch {
1420
- return null;
1421
- }
1422
- }
1423
- function writeStored(key, value) {
1424
- try {
1425
- window.localStorage.setItem(key, String(value));
1426
- } catch {
1427
- }
1428
- }
1429
- function SidebarProvider({
1430
- children,
1431
- collapsed: collapsedProp,
1432
- defaultCollapsed = false,
1433
- onCollapsedChange,
1434
- storageKey,
1435
- mobileOpen: mobileOpenProp,
1436
- defaultMobileOpen = false,
1437
- onMobileOpenChange
1438
- }) {
1439
- const [collapsed, setCollapsedState] = useControllableState({
1440
- value: collapsedProp,
1441
- defaultValue: defaultCollapsed,
1442
- onChange: onCollapsedChange
1443
- });
1444
- const [mobileOpen, setMobileOpen] = useControllableState({
1445
- value: mobileOpenProp,
1446
- defaultValue: defaultMobileOpen,
1447
- onChange: onMobileOpenChange
1448
- });
1449
- const isMobile = useMediaQuery(MOBILE_QUERY);
1450
- (0, import_react15.useEffect)(() => {
1451
- if (!storageKey) return;
1452
- const stored = readStored(storageKey);
1453
- if (stored !== null) setCollapsedState(stored);
1454
- }, [storageKey, setCollapsedState]);
1455
- const setCollapsed = (0, import_react15.useCallback)(
1456
- (next) => {
1457
- if (storageKey) writeStored(storageKey, next);
1458
- setCollapsedState(next);
1459
- },
1460
- [storageKey, setCollapsedState]
1461
- );
1462
- const value = (0, import_react15.useMemo)(
1463
- () => ({
1464
- collapsed,
1465
- setCollapsed,
1466
- toggleCollapsed: () => setCollapsed(!collapsed),
1467
- mobileOpen,
1468
- setMobileOpen,
1469
- isMobile
1470
- }),
1471
- [collapsed, setCollapsed, mobileOpen, setMobileOpen, isMobile]
1472
- );
1473
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarContext.Provider, { value, children });
1474
- }
1475
- var DefaultLink = (0, import_react15.forwardRef)(function DefaultLink2({ children, ...rest }, ref) {
1476
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { ref, ...rest, children });
1477
- });
1478
- var Row = (0, import_react15.createContext)(null);
1479
- function useRow() {
1480
- const value = (0, import_react15.useContext)(Row);
1481
- if (!value) throw new Error("Sidebar rows must be rendered by <Sidebar>");
1482
- return value;
1483
- }
1484
- function Sidebar(props) {
1485
- const outer = (0, import_react15.useContext)(SidebarContext);
1486
- if (outer) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRoot, { ...props, context: outer, ownsState: false });
1487
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1488
- SidebarProvider,
1489
- {
1490
- collapsed: props.collapsed,
1491
- defaultCollapsed: props.defaultCollapsed,
1492
- onCollapsedChange: props.onCollapsedChange,
1493
- storageKey: props.storageKey,
1494
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarFromContext, { ...props })
1495
- }
1496
- );
1497
- }
1498
- function SidebarFromContext(props) {
1499
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRoot, { ...props, context: useSidebar(), ownsState: true });
1500
- }
1501
- function SidebarRoot({
1502
- groups,
1503
- footerNav,
1504
- brand,
1505
- footer,
1506
- density: densityProp,
1507
- collapsible = true,
1508
- collapsed: collapsedProp,
1509
- onCollapsedChange,
1510
- onToggle,
1511
- currentPath,
1512
- currentHash,
1513
- linkComponent = DefaultLink,
1514
- onNavigate,
1515
- label = "Primary",
1516
- variant,
1517
- width = "w-80",
1518
- collapsedWidth,
1519
- className,
1520
- context,
1521
- ownsState
1522
- }) {
1523
- const density = densityProp ?? (variant === "plain" ? "compact" : "comfortable");
1524
- const asideId = (0, import_react15.useId)();
1525
- const { isMobile, setMobileOpen } = context;
1526
- const collapsed = !isMobile && collapsible && (collapsedProp ?? context.collapsed);
1527
- const showToggle = collapsible && !isMobile && (collapsedProp === void 0 || onToggle != null || onCollapsedChange != null);
1528
- const toggle = () => {
1529
- const next = !collapsed;
1530
- onToggle?.();
1531
- if (!ownsState) onCollapsedChange?.(next);
1532
- context.setCollapsed(next);
1533
- };
1534
- const hashTargets = (0, import_react15.useMemo)(
1535
- () => new Set(
1536
- [...groups.flatMap((group) => group.items), ...footerNav ?? []].flatMap((item) => [item, ...item.children ?? []]).map((item) => item.to).filter((to) => to?.includes("#") ?? false)
1537
- ),
1538
- [groups, footerNav]
1539
- );
1540
- const row = (0, import_react15.useMemo)(
1541
- () => ({
1542
- density,
1543
- collapsed,
1544
- path: currentPath,
1545
- hash: currentHash,
1546
- hashTargets,
1547
- Link: linkComponent,
1548
- onNavigate: () => {
1549
- if (isMobile) setMobileOpen(false);
1550
- onNavigate?.();
1551
- }
1552
- }),
1553
- [density, collapsed, currentPath, currentHash, hashTargets, linkComponent, isMobile, setMobileOpen, onNavigate]
1554
- );
1555
- const state = { collapsed, density };
1556
- const comfortable = density === "comfortable";
1557
- const panel = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1558
- "aside",
1559
- {
1560
- id: asideId,
1561
- "aria-label": label,
1562
- "data-density": density,
1563
- "data-collapsed": collapsed || void 0,
1564
- className: cn(
1565
- "relative flex h-full shrink-0 flex-col justify-between bg-default-secondary py-2",
1566
- "transition-[width] duration-200 motion-reduce:transition-none",
1567
- isMobile ? "w-full" : (0, import_clsx10.default)(
1568
- "rounded-xl border-r border-default",
1569
- collapsed ? collapsedWidth ?? (comfortable ? "w-20" : "w-[72px]") : width
1570
- ),
1571
- className
1572
- ),
1573
- children: [
1574
- showToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1575
- "button",
1576
- {
1577
- type: "button",
1578
- "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
1579
- "aria-expanded": !collapsed,
1580
- "aria-controls": asideId,
1581
- onClick: toggle,
1582
- className: cn(
1583
- "absolute -right-3 top-5 z-raised flex size-6 items-center justify-center rounded-full",
1584
- "border border-default bg-default text-default-secondary",
1585
- // Not `hover:bg-default-hover` — that is #F5F5F5, exactly the rail colour, and
1586
- // this button straddles the rail edge, so half of it dissolved into the rail on
1587
- // hover. Same hover vocabulary as the rows instead.
1588
- "shadow-100 transition-colors hover:bg-brand-tertiary-hover hover:text-brand",
1589
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default"
1590
- ),
1591
- children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.ChevronRightIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.ChevronLeftIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true })
1592
- }
1593
- ),
1594
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-h-0 flex-1 flex-col gap-1 pb-3", children: [
1595
- brand && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1596
- "div",
1597
- {
1598
- className: cn(
1599
- "flex shrink-0 items-center overflow-hidden p-4",
1600
- collapsed ? "justify-center" : "gap-2.5"
1601
- ),
1602
- children: typeof brand === "function" ? brand(state) : brand
1603
- }
1604
- ),
1605
- /* @__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)(Row.Provider, { value: row, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { "aria-label": "Main", className: cn("flex flex-col px-4", comfortable ? "gap-4 pt-2" : "gap-2"), children: groups.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarGroupView, { group }, group.id ?? group.title ?? `group-${index}`)) }) }) })
1606
- ] }),
1607
- (Boolean(footerNav?.length) || footer != null) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex shrink-0 flex-col", children: [
1608
- footerNav && footerNav.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Row.Provider, { value: row, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1609
- "nav",
1610
- {
1611
- "aria-label": "Secondary",
1612
- className: cn("flex flex-col px-4 pt-2", comfortable && "gap-1", collapsed && "items-center"),
1613
- children: footerNav.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRow, { item }, itemKey(item)))
1614
- }
1615
- ) }),
1616
- typeof footer === "function" ? footer(state) : footer
1617
- ] })
1618
- ]
1619
- }
1620
- );
1621
- if (isMobile) {
1622
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1623
- Drawer,
1624
- {
1625
- side: "left",
1626
- open: context.mobileOpen,
1627
- onOpenChange: setMobileOpen,
1628
- label,
1629
- width: "w-80 max-w-[85vw]",
1630
- className: "bg-default-secondary",
1631
- children: panel
1632
- }
1633
- );
1634
- }
1635
- return panel;
1636
- }
1637
- function itemKey(item) {
1638
- return item.id ?? item.to ?? item.href ?? item.label;
1639
- }
1640
- function SidebarGroupView({ group }) {
1641
- const { density, collapsed } = useRow();
1642
- const [open, setOpen] = (0, import_react15.useState)(group.defaultOpen ?? true);
1643
- const regionId = (0, import_react15.useId)();
1644
- const foldable = Boolean(group.collapsible && group.title) && !collapsed;
1645
- const comfortable = density === "comfortable";
1646
- return (
1647
- // Figma "Menu Container": 8px above and below; 12px (comfortable) or 8px (compact)
1648
- // between the heading and the rows; rows 4px apart when comfortable, touching when compact.
1649
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("flex flex-col py-2", comfortable ? "gap-3" : "gap-2"), children: [
1650
- group.title && (collapsed ? (
1651
- // No room in the rail, but still the only thing naming the run of icons below.
1652
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "sr-only", children: group.title })
1653
- ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1654
- NavGroupHeader,
1655
- {
1656
- title: group.title,
1657
- action: group.action,
1658
- ...foldable ? { open, onOpenChange: setOpen, controls: regionId } : {}
1659
- }
1660
- )),
1661
- (!foldable || open) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { id: regionId, className: cn("flex flex-col", comfortable && "gap-1", collapsed && "items-center"), children: group.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRow, { item }, itemKey(item))) })
1662
- ] })
1663
- );
1664
- }
1665
- function isRowActive(item, row) {
1666
- if (item.isActive !== void 0) return item.isActive;
1667
- if (!item.to || row.path === void 0) return false;
1668
- const [path, hash] = item.to.split("#");
1669
- const pathMatches = item.end ? row.path === path : row.path === path || row.path.startsWith(`${path.replace(/\/$/, "")}/`);
1670
- if (!pathMatches) return false;
1671
- if (hash !== void 0) return row.hash === `#${hash}`;
1672
- return !row.hashTargets.has(`${row.path}${row.hash ?? ""}`);
1673
- }
1674
- function SidebarRow({ item }) {
1675
- const row = useRow();
1676
- if (item.children?.length) {
1677
- return row.collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RailParent, { item }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParentRow, { item });
1678
- }
1679
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LeafRow, { item });
1680
- }
1681
- function navigateHandler(row) {
1682
- return (event) => {
1683
- if (!event.defaultPrevented) row.onNavigate();
1684
- };
1685
- }
1686
- function LeafRow({ item }) {
1687
- const row = useRow();
1688
- const active = isRowActive(item, row);
1689
- const common = {
1690
- icon: item.icon,
1691
- label: item.label,
1692
- isActive: active,
1693
- indicator: item.indicator,
1694
- disabled: item.disabled,
1695
- collapsed: row.collapsed,
1696
- density: row.density
1697
- };
1698
- let element;
1699
- if (item.href) {
1700
- element = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href: item.href, target: "_blank", rel: "noreferrer" }) });
1701
- } else if (item.to) {
1702
- const { Link: Link2 } = row;
1703
- element = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link2, { href: item.to }) });
1704
- } else {
1705
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavItem, { ...common });
1706
- }
1707
- if (!row.collapsed) return element;
1708
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: item.label, side: "right", children: element });
1709
- }
1710
- function ParentRow({ item }) {
1711
- const row = useRow();
1712
- const children = item.children ?? [];
1713
- const childActive = children.some((child) => isRowActive(child, row));
1714
- const [open, setOpen] = (0, import_react15.useState)(item.defaultOpen ?? childActive);
1715
- const regionId = (0, import_react15.useId)();
1716
- (0, import_react15.useEffect)(() => {
1717
- if (childActive) setOpen(true);
1718
- }, [childActive]);
1719
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1720
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1721
- NavItem,
1722
- {
1723
- asChild: true,
1724
- icon: item.icon,
1725
- label: item.label,
1726
- isActive: !open && childActive,
1727
- indicator: item.indicator,
1728
- disabled: item.disabled,
1729
- density: row.density,
1730
- trailing: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1731
- import_lucide_react5.ChevronDownIcon,
1732
- {
1733
- className: cn(
1734
- "text-icon-default-secondary transition-transform motion-reduce:transition-none",
1735
- !open && "-rotate-90"
1736
- )
1737
- }
1738
- ),
1739
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", "aria-expanded": open, "aria-controls": regionId, onClick: () => setOpen(!open) })
1740
- }
1741
- ),
1742
- open && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { id: regionId, className: "flex flex-col", children: children.map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SubRow, { item: child, last: index === children.length - 1 }, itemKey(child))) })
1743
- ] });
1744
- }
1745
- function SubRow({ item, last }) {
1746
- const row = useRow();
1747
- const common = {
1748
- label: item.label,
1749
- isActive: isRowActive(item, row),
1750
- disabled: item.disabled,
1751
- last,
1752
- density: row.density
1753
- };
1754
- if (item.href) {
1755
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavSubItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href: item.href, target: "_blank", rel: "noreferrer" }) });
1756
- }
1757
- if (item.to) {
1758
- const { Link: Link2 } = row;
1759
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavSubItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link2, { href: item.to }) });
1760
- }
1761
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavSubItem, { ...common });
1762
- }
1763
- var FLYOUT_ITEM = (0, import_clsx10.default)(OVERLAY_ITEM_BASE, OVERLAY_ITEM_SIZE.md, "no-underline");
1764
- function RailParent({ item }) {
1765
- const row = useRow();
1766
- const children = item.children ?? [];
1767
- const childActive = children.some((child) => isRowActive(child, row));
1768
- const { Link: Link2 } = row;
1769
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1770
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: item.label, side: "right", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1771
- NavItem,
1772
- {
1773
- asChild: true,
1774
- icon: item.icon,
1775
- label: item.label,
1776
- isActive: childActive,
1777
- indicator: item.indicator,
1778
- disabled: item.disabled,
1779
- collapsed: true,
1780
- density: row.density,
1781
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button" })
1782
- }
1783
- ) }) }),
1784
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenuContent, { side: "right", align: "start", children: [
1785
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuLabel, { children: item.label }),
1786
- children.map((child) => {
1787
- const active = isRowActive(child, row);
1788
- const className = cn(
1789
- FLYOUT_ITEM,
1790
- overlayItemTone("default", Boolean(child.disabled)),
1791
- active && "bg-brand text-brand-on-brand hover:bg-brand-hover focus:bg-brand-hover"
1792
- );
1793
- if (!child.to && !child.href) {
1794
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuItem, { disabled: child.disabled, children: child.label }, itemKey(child));
1795
- }
1796
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1797
- import_radix_ui4.DropdownMenu.Item,
1798
- {
1799
- asChild: true,
1800
- disabled: child.disabled,
1801
- className,
1802
- onSelect: () => row.onNavigate(),
1803
- children: child.href ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href: child.href, target: "_blank", rel: "noreferrer", children: child.label }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link2, { href: child.to, "aria-current": active ? "page" : void 0, children: child.label })
1804
- },
1805
- itemKey(child)
1806
- );
1807
- })
1808
- ] })
1809
- ] });
1810
- }
1811
- var SidebarTrigger = (0, import_react15.forwardRef)(function SidebarTrigger2({ "aria-label": ariaLabel = "Open navigation", className, onClick, variant = "subtle", ...rest }, ref) {
1812
- const { mobileOpen, setMobileOpen } = useSidebar();
1813
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1814
- IconButton,
1815
- {
1816
- ref,
1817
- "aria-label": ariaLabel,
1818
- "aria-expanded": mobileOpen,
1819
- "aria-haspopup": "dialog",
1820
- variant,
1821
- className: cn("md:hidden", className),
1822
- onClick: (event) => {
1823
- onClick?.(event);
1824
- if (!event.defaultPrevented) setMobileOpen(!mobileOpen);
1825
- },
1826
- ...rest,
1827
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.MenuIcon, { className: "size-5", "aria-hidden": true })
1828
- }
1829
- );
1830
- });
1831
- function SidebarSeparator({ className, ...rest }) {
1832
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { "aria-hidden": true, className: cn("mx-1 h-px shrink-0 bg-divider", className), ...rest });
1833
- }
1834
- function SidebarUserCard({
1835
- name,
1836
- role,
1837
- onLogout,
1838
- collapsed = false,
1839
- menu,
1840
- className
1841
- }) {
1842
- const initial = name.trim().charAt(0);
1843
- const items = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1844
- menu,
1845
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuItem, { icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.LogOutIcon, { className: "size-3.5", "aria-hidden": true }), onSelect: onLogout, children: "Sign out" })
1846
- ] });
1847
- if (collapsed) {
1848
- return (
1849
- // Figma collapsed user card: the avatar alone, 24px above and 16px below.
1850
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: cn("flex shrink-0 items-center justify-center px-4 pb-4 pt-6", className), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1851
- /* @__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" }) }) }),
1852
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "right", align: "end", children: items })
1853
- ] }) })
1854
- );
1855
- }
1856
- return (
1857
- // Figma: 16px padding, plus 4px more above and below the row inside it.
1858
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("flex shrink-0 items-center gap-2.5 px-4 py-5", className), children: [
1859
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Avatar, { initial, size: "lg", shape: "circle" }),
1860
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
1861
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-sm font-semibold leading-snug text-default", children: name }),
1862
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-tiny font-regular leading-none text-default-secondary", children: role })
1863
- ] }),
1864
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1865
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1866
- "button",
1867
- {
1868
- type: "button",
1869
- "aria-label": `${name} \u2014 user options`,
1870
- 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",
1871
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.EllipsisVerticalIcon, { className: "size-5", "aria-hidden": true })
1872
- }
1873
- ) }),
1874
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "top", align: "end", children: items })
1875
- ] })
1876
- ] })
1877
- );
1878
- }
1879
-
1880
61
  // src/sidebar/nav-tabs.tsx
1881
- var import_react_router_dom = require("react-router-dom");
1882
- var import_clsx11 = __toESM(require("clsx"), 1);
1883
- var import_jsx_runtime12 = require("react/jsx-runtime");
62
+ var import_jsx_runtime = require("react/jsx-runtime");
1884
63
  function NavTabs({ items, className }) {
1885
64
  return (
1886
65
  // The links inside are the tab stops.
1887
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
66
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1888
67
  "div",
1889
68
  {
1890
- className: (0, import_clsx11.default)(
69
+ className: (0, import_clsx2.default)(
1891
70
  "flex gap-6 overflow-x-auto border-b border-default",
1892
71
  SCROLLBAR_CLASSES,
1893
72
  className
1894
73
  ),
1895
- children: items.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
74
+ children: items.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1896
75
  import_react_router_dom.NavLink,
1897
76
  {
1898
77
  to: tab.to,
1899
78
  end: tab.end,
1900
- className: ({ isActive }) => (0, import_clsx11.default)(
79
+ className: ({ isActive }) => (0, import_clsx2.default)(
1901
80
  "shrink-0 whitespace-nowrap border-b-2 pb-3 text-body-sm transition-colors",
1902
81
  isActive ? "border-brand-emphasis font-semibold text-brand-emphasis" : "border-transparent font-medium text-default-secondary hover:text-default"
1903
82
  ),
@@ -1911,13 +90,13 @@ function NavTabs({ items, className }) {
1911
90
  }
1912
91
 
1913
92
  // src/sidebar/index.tsx
1914
- var import_jsx_runtime13 = require("react/jsx-runtime");
1915
- var RouterLink = (0, import_react16.forwardRef)(function RouterLink2({ href, ...rest }, ref) {
1916
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_router_dom2.Link, { ref, to: href, ...rest });
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 });
1917
96
  });
1918
97
  function AppSidebar(props) {
1919
98
  const location = (0, import_react_router_dom2.useLocation)();
1920
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Sidebar, { ...props, currentPath: location.pathname, currentHash: location.hash, linkComponent: RouterLink });
99
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import__.Sidebar, { ...props, currentPath: location.pathname, currentHash: location.hash, linkComponent: RouterLink });
1921
100
  }
1922
101
  // Annotate the CommonJS export names for ESM import in node:
1923
102
  0 && (module.exports = {