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