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