@aortl/admin-react 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -1
- package/dist/AdminRoot.d.ts +2 -2
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AppShell.d.ts +1 -1
- package/dist/BrandTile.d.ts +7 -1
- package/dist/BrandTile.d.ts.map +1 -1
- package/dist/Button.d.ts +4 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Container.d.ts +3 -1
- package/dist/Container.d.ts.map +1 -1
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Drawer.d.ts.map +1 -1
- package/dist/Field.d.ts +9 -2
- package/dist/Field.d.ts.map +1 -1
- package/dist/Menu.d.ts +8 -2
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Navbar.d.ts +9 -2
- package/dist/Navbar.d.ts.map +1 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/Sidebar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/admin.scoped.css +31 -161
- package/dist/index.cjs +587 -464
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +588 -466
- package/dist/index.mjs.map +1 -1
- package/dist/useConfirm.d.ts +32 -0
- package/dist/useConfirm.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Children, Fragment as Fragment$1, createContext, createElement, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
|
|
3
|
+
import { Children, Fragment as Fragment$1, createContext, createElement, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
4
|
import { Button as Button$1 } from "@base-ui/react/button";
|
|
5
|
+
import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
|
|
6
6
|
import { Toggle } from "@base-ui/react/toggle";
|
|
7
7
|
import { Input as Input$1 } from "@base-ui/react/input";
|
|
8
8
|
import { NumberField } from "@base-ui/react/number-field";
|
|
@@ -76,30 +76,6 @@ var Accordion = Object.assign(AccordionRoot, {
|
|
|
76
76
|
*/
|
|
77
77
|
var PortalContainerContext = createContext(null);
|
|
78
78
|
//#endregion
|
|
79
|
-
//#region src/AdminRoot.tsx
|
|
80
|
-
function AdminRoot({ className, theme, systemAccent, style, ref, ...rest }) {
|
|
81
|
-
const rootStyle = systemAccent !== void 0 ? {
|
|
82
|
-
...style,
|
|
83
|
-
"--color-system-accent": systemAccent
|
|
84
|
-
} : style;
|
|
85
|
-
const portalRef = useRef(null);
|
|
86
|
-
const setRef = useCallback((node) => {
|
|
87
|
-
portalRef.current = node;
|
|
88
|
-
if (typeof ref === "function") ref(node);
|
|
89
|
-
else if (ref) ref.current = node;
|
|
90
|
-
}, [ref]);
|
|
91
|
-
return /* @__PURE__ */ jsx(PortalContainerContext.Provider, {
|
|
92
|
-
value: portalRef,
|
|
93
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
94
|
-
ref: setRef,
|
|
95
|
-
className: cn("admin-root", className),
|
|
96
|
-
style: rootStyle,
|
|
97
|
-
...rest,
|
|
98
|
-
...theme !== void 0 && { "data-theme": theme }
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
79
|
//#region src/icon.ts
|
|
104
80
|
/**
|
|
105
81
|
* Render an `IconProp`, defaulting component references to `size="1em"
|
|
@@ -115,226 +91,6 @@ function renderIcon(icon, size = "1em") {
|
|
|
115
91
|
});
|
|
116
92
|
}
|
|
117
93
|
//#endregion
|
|
118
|
-
//#region src/Alert.tsx
|
|
119
|
-
function DismissIcon() {
|
|
120
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
121
|
-
width: "1em",
|
|
122
|
-
height: "1em",
|
|
123
|
-
viewBox: "0 0 24 24",
|
|
124
|
-
fill: "none",
|
|
125
|
-
stroke: "currentColor",
|
|
126
|
-
strokeWidth: "2",
|
|
127
|
-
strokeLinecap: "round",
|
|
128
|
-
strokeLinejoin: "round",
|
|
129
|
-
"aria-hidden": "true",
|
|
130
|
-
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
function AlertRoot({ variant, icon, title, description, action, onDismiss, dismissLabel = "Dismiss", classNames, className, role, children, ...rest }) {
|
|
134
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
135
|
-
role: role ?? (variant === "danger" || variant === "warning" ? "alert" : "status"),
|
|
136
|
-
className: cn(["alert", `alert-${variant}`], className),
|
|
137
|
-
...rest,
|
|
138
|
-
children: [
|
|
139
|
-
renderIcon(icon),
|
|
140
|
-
title !== void 0 ? /* @__PURE__ */ jsx(AlertTitle, {
|
|
141
|
-
className: classNames?.title,
|
|
142
|
-
children: title
|
|
143
|
-
}) : null,
|
|
144
|
-
description !== void 0 ? /* @__PURE__ */ jsx(AlertDescription, {
|
|
145
|
-
className: classNames?.description,
|
|
146
|
-
children: description
|
|
147
|
-
}) : null,
|
|
148
|
-
children,
|
|
149
|
-
action !== void 0 ? /* @__PURE__ */ jsx(AlertAction, {
|
|
150
|
-
className: classNames?.action,
|
|
151
|
-
children: action
|
|
152
|
-
}) : null,
|
|
153
|
-
onDismiss ? /* @__PURE__ */ jsx("button", {
|
|
154
|
-
type: "button",
|
|
155
|
-
className: cn("alert-dismiss", classNames?.dismiss),
|
|
156
|
-
"aria-label": dismissLabel,
|
|
157
|
-
onClick: onDismiss,
|
|
158
|
-
children: /* @__PURE__ */ jsx(DismissIcon, {})
|
|
159
|
-
}) : null
|
|
160
|
-
]
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function AlertTitle({ className, ...rest }) {
|
|
164
|
-
return /* @__PURE__ */ jsx("strong", {
|
|
165
|
-
className: cn("alert-title", className),
|
|
166
|
-
...rest
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function AlertDescription({ className, ...rest }) {
|
|
170
|
-
return /* @__PURE__ */ jsx("p", {
|
|
171
|
-
className: cn("alert-description", className),
|
|
172
|
-
...rest
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
function AlertAction({ className, ...rest }) {
|
|
176
|
-
return /* @__PURE__ */ jsx("div", {
|
|
177
|
-
className: cn("alert-action", className),
|
|
178
|
-
...rest
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
var Alert = Object.assign(AlertRoot, {
|
|
182
|
-
Title: AlertTitle,
|
|
183
|
-
Description: AlertDescription,
|
|
184
|
-
Action: AlertAction
|
|
185
|
-
});
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/AppShell.tsx
|
|
188
|
-
var AppShellContext = createContext(null);
|
|
189
|
-
function useAppShell() {
|
|
190
|
-
return useContext(AppShellContext);
|
|
191
|
-
}
|
|
192
|
-
function AppShellRoot({ hasSidebar = false, mobileDrawerOpen, defaultMobileDrawerOpen = false, onMobileDrawerOpenChange, systemAccent, className, style, children, ...rest }) {
|
|
193
|
-
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultMobileDrawerOpen);
|
|
194
|
-
const isControlled = mobileDrawerOpen !== void 0;
|
|
195
|
-
const open = isControlled ? mobileDrawerOpen : uncontrolledOpen;
|
|
196
|
-
const value = useMemo(() => ({
|
|
197
|
-
mobileDrawerOpen: open,
|
|
198
|
-
setMobileDrawerOpen: (next) => {
|
|
199
|
-
if (!isControlled) setUncontrolledOpen(next);
|
|
200
|
-
onMobileDrawerOpenChange?.(next);
|
|
201
|
-
},
|
|
202
|
-
hasSidebar
|
|
203
|
-
}), [
|
|
204
|
-
open,
|
|
205
|
-
isControlled,
|
|
206
|
-
onMobileDrawerOpenChange,
|
|
207
|
-
hasSidebar
|
|
208
|
-
]);
|
|
209
|
-
const rootStyle = systemAccent !== void 0 ? {
|
|
210
|
-
...style,
|
|
211
|
-
"--color-system-accent": systemAccent
|
|
212
|
-
} : style;
|
|
213
|
-
return /* @__PURE__ */ jsx(AppShellContext.Provider, {
|
|
214
|
-
value,
|
|
215
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
216
|
-
className: cn(["app-shell", hasSidebar && "app-shell-with-sidebar"], className),
|
|
217
|
-
style: rootStyle,
|
|
218
|
-
...rest,
|
|
219
|
-
children
|
|
220
|
-
})
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
function AppShellMain({ className, ...rest }) {
|
|
224
|
-
return /* @__PURE__ */ jsx("main", {
|
|
225
|
-
className: cn("app-shell-main", className),
|
|
226
|
-
...rest
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
var AppShell = Object.assign(AppShellRoot, { Main: AppShellMain });
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/Badge.tsx
|
|
232
|
-
function RemoveIcon() {
|
|
233
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
234
|
-
width: "1em",
|
|
235
|
-
height: "1em",
|
|
236
|
-
viewBox: "0 0 24 24",
|
|
237
|
-
fill: "none",
|
|
238
|
-
stroke: "currentColor",
|
|
239
|
-
strokeWidth: "2",
|
|
240
|
-
strokeLinecap: "round",
|
|
241
|
-
strokeLinejoin: "round",
|
|
242
|
-
"aria-hidden": "true",
|
|
243
|
-
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
function Badge({ variant = "neutral", size = "md", icon, soft = false, onRemove, removeLabel = "Remove", className, children, ...rest }) {
|
|
247
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
248
|
-
className: cn([
|
|
249
|
-
"badge",
|
|
250
|
-
variant !== "neutral" && `badge-${variant}`,
|
|
251
|
-
size !== "md" && `badge-${size}`,
|
|
252
|
-
soft && "badge-soft"
|
|
253
|
-
], className),
|
|
254
|
-
...rest,
|
|
255
|
-
children: [
|
|
256
|
-
renderIcon(icon),
|
|
257
|
-
children,
|
|
258
|
-
onRemove ? /* @__PURE__ */ jsx("button", {
|
|
259
|
-
type: "button",
|
|
260
|
-
className: cn("badge-remove", void 0),
|
|
261
|
-
"aria-label": removeLabel,
|
|
262
|
-
onClick: onRemove,
|
|
263
|
-
children: /* @__PURE__ */ jsx(RemoveIcon, {})
|
|
264
|
-
}) : null
|
|
265
|
-
]
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/BrandTile.tsx
|
|
270
|
-
/**
|
|
271
|
-
* Brand/system mark for the navbar — monogram, icon, or shop logo. Precedence
|
|
272
|
-
* is `src` > `icon` > `monogram`. Monogram/icon tiles are `aria-hidden`; image
|
|
273
|
-
* tiles expose `alt` to assistive tech instead.
|
|
274
|
-
*/
|
|
275
|
-
function BrandTile({ variant = "solid", size = "md", monogram, icon, src, alt = "", className, children, ...rest }) {
|
|
276
|
-
const classes = cn([
|
|
277
|
-
"brand-tile",
|
|
278
|
-
variant !== "solid" && `brand-tile-${variant}`,
|
|
279
|
-
size === "lg" && "brand-tile-lg"
|
|
280
|
-
], className);
|
|
281
|
-
if (src) return /* @__PURE__ */ jsx("span", {
|
|
282
|
-
className: classes,
|
|
283
|
-
...rest,
|
|
284
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
285
|
-
src,
|
|
286
|
-
alt
|
|
287
|
-
})
|
|
288
|
-
});
|
|
289
|
-
return /* @__PURE__ */ jsx("span", {
|
|
290
|
-
className: classes,
|
|
291
|
-
"aria-hidden": true,
|
|
292
|
-
...rest,
|
|
293
|
-
children: icon ? renderIcon(icon) : children ?? monogram
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/Avatar.tsx
|
|
298
|
-
/**
|
|
299
|
-
* Image avatar with an initials fallback. Initials show until the image loads
|
|
300
|
-
* (and again, React-only, if it errors); the vanilla CSS layers the `<img>`
|
|
301
|
-
* over the initials instead.
|
|
302
|
-
*/
|
|
303
|
-
function Avatar({ src, alt, initials, size = "md", shape = "circle", className, children, ...rest }) {
|
|
304
|
-
const fallback = children ?? initials;
|
|
305
|
-
return /* @__PURE__ */ jsxs(Avatar$1.Root, {
|
|
306
|
-
className: cn([
|
|
307
|
-
"avatar",
|
|
308
|
-
size !== "md" && `avatar-${size}`,
|
|
309
|
-
shape === "square" && "avatar-square"
|
|
310
|
-
], className),
|
|
311
|
-
...rest,
|
|
312
|
-
children: [fallback !== void 0 ? /* @__PURE__ */ jsx(Avatar$1.Fallback, { children: fallback }) : null, src !== void 0 ? /* @__PURE__ */ jsx(Avatar$1.Image, {
|
|
313
|
-
src,
|
|
314
|
-
alt
|
|
315
|
-
}) : null]
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
/** Overlapping stack of avatars; later children paint on top. `max` caps the visible count. */
|
|
319
|
-
function AvatarGroup({ max, size = "md", className, children, ...rest }) {
|
|
320
|
-
const items = Children.toArray(children);
|
|
321
|
-
const overflow = max !== void 0 && items.length > max ? items.length - max : 0;
|
|
322
|
-
const visible = overflow > 0 ? items.slice(0, max) : items;
|
|
323
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
324
|
-
className: cn("avatar-group", className),
|
|
325
|
-
...rest,
|
|
326
|
-
children: [visible, overflow > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
327
|
-
className: cn([
|
|
328
|
-
"avatar",
|
|
329
|
-
size !== "md" && `avatar-${size}`,
|
|
330
|
-
"avatar-more"
|
|
331
|
-
], void 0),
|
|
332
|
-
"aria-label": `+${overflow} more`,
|
|
333
|
-
children: ["+", overflow]
|
|
334
|
-
}) : null]
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
//#endregion
|
|
338
94
|
//#region src/hotkey-parse.ts
|
|
339
95
|
var MOD_ORDER = [
|
|
340
96
|
"ctrl",
|
|
@@ -569,50 +325,561 @@ function useHotkey(keys, handler, options) {
|
|
|
569
325
|
return derived;
|
|
570
326
|
}
|
|
571
327
|
/**
|
|
572
|
-
* `useHotkey` bound to a rendered element: the chord dispatches a native
|
|
573
|
-
* `.click()`, so `onClick` fires, `type="submit"` submits, an anchor
|
|
574
|
-
* navigates. Returns `setRef` to pass as the element's ref; it latches the
|
|
575
|
-
* element and forwards `ref`.
|
|
328
|
+
* `useHotkey` bound to a rendered element: the chord dispatches a native
|
|
329
|
+
* `.click()`, so `onClick` fires, `type="submit"` submits, an anchor
|
|
330
|
+
* navigates. Returns `setRef` to pass as the element's ref; it latches the
|
|
331
|
+
* element and forwards `ref`.
|
|
332
|
+
*/
|
|
333
|
+
function useHotkeyClick(keys, ref, options) {
|
|
334
|
+
const elementRef = useRef(null);
|
|
335
|
+
const setRef = useCallback((node) => {
|
|
336
|
+
elementRef.current = node;
|
|
337
|
+
if (typeof ref === "function") ref(node);
|
|
338
|
+
else if (ref) ref.current = node;
|
|
339
|
+
}, [ref]);
|
|
340
|
+
return {
|
|
341
|
+
...useHotkey(keys, () => elementRef.current?.click(), options),
|
|
342
|
+
setRef
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/Button.tsx
|
|
347
|
+
function Button({ variant = "default", size = "md", fullWidth, loading, icon, iconTrailing, hotkey, className, type = "button", disabled, children, onClick, ref, ...rest }) {
|
|
348
|
+
const { ariaKeyShortcuts, primaryChord, setRef } = useHotkeyClick(hotkey, ref, { enabled: !disabled && !loading });
|
|
349
|
+
const iconOnly = children == null && (icon != null || iconTrailing != null);
|
|
350
|
+
return /* @__PURE__ */ jsxs(Button$1, {
|
|
351
|
+
ref: setRef,
|
|
352
|
+
onClick,
|
|
353
|
+
type,
|
|
354
|
+
disabled: disabled || loading,
|
|
355
|
+
"aria-busy": loading || void 0,
|
|
356
|
+
"aria-keyshortcuts": ariaKeyShortcuts,
|
|
357
|
+
className: cn([
|
|
358
|
+
"btn",
|
|
359
|
+
variant !== "default" && `btn-${variant}`,
|
|
360
|
+
size !== "md" && `btn-${size}`,
|
|
361
|
+
fullWidth && "btn-full-width",
|
|
362
|
+
loading && "btn-loading",
|
|
363
|
+
iconOnly && "btn-square"
|
|
364
|
+
], className),
|
|
365
|
+
...rest,
|
|
366
|
+
children: [
|
|
367
|
+
loading ? null : renderIcon(icon),
|
|
368
|
+
children,
|
|
369
|
+
renderIcon(iconTrailing),
|
|
370
|
+
primaryChord !== void 0 ? /* @__PURE__ */ jsx(Kbd, { keys: primaryChord }) : null
|
|
371
|
+
]
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/dialog-internal.ts
|
|
376
|
+
var DialogContext = createContext(null);
|
|
377
|
+
/**
|
|
378
|
+
* Drives a native `<dialog>` from a controlled `open` prop, shared by `<Dialog>`
|
|
379
|
+
* and `<Drawer>`: merges the consumer ref, calls `showModal()` / `close()` on
|
|
380
|
+
* change, and reports closes (Esc, backdrop, form submit) via `onOpenChange`.
|
|
381
|
+
* Returns `ref` for the portal container context.
|
|
382
|
+
*/
|
|
383
|
+
function useDialogElement(open, onOpenChange, consumerRef) {
|
|
384
|
+
const ref = useRef(null);
|
|
385
|
+
const onOpenChangeRef = useRef(onOpenChange);
|
|
386
|
+
onOpenChangeRef.current = onOpenChange;
|
|
387
|
+
const setRef = useCallback((node) => {
|
|
388
|
+
ref.current = node;
|
|
389
|
+
if (typeof consumerRef === "function") consumerRef(node);
|
|
390
|
+
else if (consumerRef) consumerRef.current = node;
|
|
391
|
+
}, [consumerRef]);
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
const el = ref.current;
|
|
394
|
+
if (!el || open === void 0) return;
|
|
395
|
+
if (open && !el.open) el.showModal();
|
|
396
|
+
else if (!open && el.open) el.close();
|
|
397
|
+
}, [open]);
|
|
398
|
+
useEffect(() => {
|
|
399
|
+
const el = ref.current;
|
|
400
|
+
if (!el) return;
|
|
401
|
+
const handleClose = () => onOpenChangeRef.current?.(false);
|
|
402
|
+
el.addEventListener("close", handleClose);
|
|
403
|
+
return () => el.removeEventListener("close", handleClose);
|
|
404
|
+
}, []);
|
|
405
|
+
return {
|
|
406
|
+
setRef,
|
|
407
|
+
ctx: { close: () => ref.current?.close() },
|
|
408
|
+
ref
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/Dialog.tsx
|
|
413
|
+
function DefaultCloseIcon() {
|
|
414
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
415
|
+
width: "16",
|
|
416
|
+
height: "16",
|
|
417
|
+
viewBox: "0 0 24 24",
|
|
418
|
+
fill: "none",
|
|
419
|
+
stroke: "currentColor",
|
|
420
|
+
strokeWidth: "2",
|
|
421
|
+
strokeLinecap: "round",
|
|
422
|
+
strokeLinejoin: "round",
|
|
423
|
+
"aria-hidden": "true",
|
|
424
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
/** The bare `<dialog>` primitive — for layouts the default `<Dialog>` doesn't fit. */
|
|
428
|
+
function DialogContainer({ open, onOpenChange, size = "md", closedby = "any", className, children, ref: consumerRef, ...rest }) {
|
|
429
|
+
const { setRef, ctx, ref } = useDialogElement(open, onOpenChange, consumerRef);
|
|
430
|
+
return /* @__PURE__ */ jsx(DialogContext.Provider, {
|
|
431
|
+
value: ctx,
|
|
432
|
+
children: /* @__PURE__ */ jsx(PortalContainerContext.Provider, {
|
|
433
|
+
value: ref,
|
|
434
|
+
children: /* @__PURE__ */ jsx("dialog", {
|
|
435
|
+
ref: setRef,
|
|
436
|
+
className: cn(["dialog", size !== "md" && `dialog-${size}`], className),
|
|
437
|
+
closedby,
|
|
438
|
+
...rest,
|
|
439
|
+
children
|
|
440
|
+
})
|
|
441
|
+
})
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
function DialogHeader({ className, ...rest }) {
|
|
445
|
+
return /* @__PURE__ */ jsx("div", {
|
|
446
|
+
className: cn("dialog-header", className),
|
|
447
|
+
...rest
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
function DialogTitle({ icon, className, children, ...rest }) {
|
|
451
|
+
return /* @__PURE__ */ jsxs("h2", {
|
|
452
|
+
className: cn("dialog-title", className),
|
|
453
|
+
...rest,
|
|
454
|
+
children: [renderIcon(icon), children]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
function DialogDescription({ className, ...rest }) {
|
|
458
|
+
return /* @__PURE__ */ jsx("p", {
|
|
459
|
+
className: cn("dialog-description", className),
|
|
460
|
+
...rest
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
function DialogBody({ className, ...rest }) {
|
|
464
|
+
return /* @__PURE__ */ jsx("div", {
|
|
465
|
+
className: cn("dialog-body", className),
|
|
466
|
+
...rest
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
function DialogFooter({ className, ...rest }) {
|
|
470
|
+
return /* @__PURE__ */ jsx("div", {
|
|
471
|
+
className: cn("dialog-footer", className),
|
|
472
|
+
...rest
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function DialogCloseButton({ icon, className, children, onClick, type = "button", "aria-label": ariaLabel = "Close", ...rest }) {
|
|
476
|
+
const ctx = useContext(DialogContext);
|
|
477
|
+
return /* @__PURE__ */ jsx("button", {
|
|
478
|
+
type,
|
|
479
|
+
className: cn("dialog-close", className),
|
|
480
|
+
"aria-label": ariaLabel,
|
|
481
|
+
onClick: (event) => {
|
|
482
|
+
onClick?.(event);
|
|
483
|
+
if (!event.defaultPrevented) ctx?.close();
|
|
484
|
+
},
|
|
485
|
+
...rest,
|
|
486
|
+
children: children ?? (icon !== void 0 ? renderIcon(icon) : /* @__PURE__ */ jsx(DefaultCloseIcon, {}))
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
/** Standard modal with shorthand-driven header/body/footer. For other shapes, compose `<Dialog.Container>` by hand. */
|
|
490
|
+
function DialogRoot({ icon, title, description, actions, dismissible = true, closeLabel = "Close", classNames, children, ...containerProps }) {
|
|
491
|
+
const hasTitle = title !== void 0 || icon !== void 0;
|
|
492
|
+
const showHeader = hasTitle || dismissible;
|
|
493
|
+
return /* @__PURE__ */ jsxs(DialogContainer, {
|
|
494
|
+
...containerProps,
|
|
495
|
+
children: [
|
|
496
|
+
showHeader ? /* @__PURE__ */ jsxs(DialogHeader, {
|
|
497
|
+
className: classNames?.header,
|
|
498
|
+
children: [hasTitle ? /* @__PURE__ */ jsx(DialogTitle, {
|
|
499
|
+
icon,
|
|
500
|
+
className: classNames?.title,
|
|
501
|
+
children: title
|
|
502
|
+
}) : null, dismissible ? /* @__PURE__ */ jsx(DialogCloseButton, {
|
|
503
|
+
"aria-label": closeLabel,
|
|
504
|
+
className: classNames?.close
|
|
505
|
+
}) : null]
|
|
506
|
+
}) : null,
|
|
507
|
+
description !== void 0 ? /* @__PURE__ */ jsx(DialogDescription, {
|
|
508
|
+
className: classNames?.description,
|
|
509
|
+
children: description
|
|
510
|
+
}) : null,
|
|
511
|
+
children !== void 0 ? /* @__PURE__ */ jsx(DialogBody, {
|
|
512
|
+
className: classNames?.body,
|
|
513
|
+
children
|
|
514
|
+
}) : null,
|
|
515
|
+
actions !== void 0 ? /* @__PURE__ */ jsx(DialogFooter, {
|
|
516
|
+
className: classNames?.footer,
|
|
517
|
+
children: actions
|
|
518
|
+
}) : null
|
|
519
|
+
]
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
var Dialog = Object.assign(DialogRoot, {
|
|
523
|
+
Container: DialogContainer,
|
|
524
|
+
Header: DialogHeader,
|
|
525
|
+
Title: DialogTitle,
|
|
526
|
+
Description: DialogDescription,
|
|
527
|
+
Body: DialogBody,
|
|
528
|
+
Footer: DialogFooter,
|
|
529
|
+
CloseButton: DialogCloseButton
|
|
530
|
+
});
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/useConfirm.tsx
|
|
533
|
+
var ConfirmContext = createContext(null);
|
|
534
|
+
/**
|
|
535
|
+
* Returns `confirm(options)`, an async `window.confirm`: it opens a confirmation
|
|
536
|
+
* dialog and resolves `true` on Confirm, `false` on Cancel, Esc, or when the
|
|
537
|
+
* hosting `<AdminRoot>` unmounts. Calls made while a dialog is open queue and
|
|
538
|
+
* open in call order. The function identity is stable.
|
|
539
|
+
*
|
|
540
|
+
* @throws When called outside `<AdminRoot>`, which hosts the dialog.
|
|
541
|
+
*/
|
|
542
|
+
function useConfirm() {
|
|
543
|
+
const confirm = useContext(ConfirmContext);
|
|
544
|
+
if (confirm === null) throw new Error("useConfirm() must be called inside <AdminRoot>, which hosts the dialog.");
|
|
545
|
+
return confirm;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Hosts `useConfirm()` for its subtree: queues requests FIFO and renders the
|
|
549
|
+
* head of the queue as a dialog, nothing while idle. Rendered by `<AdminRoot>`.
|
|
550
|
+
*/
|
|
551
|
+
function ConfirmHost({ children }) {
|
|
552
|
+
const [queue, setQueue] = useState([]);
|
|
553
|
+
const pending = useRef(/* @__PURE__ */ new Set());
|
|
554
|
+
const nextId = useRef(0);
|
|
555
|
+
const confirm = useCallback((options) => new Promise((resolve) => {
|
|
556
|
+
const entry = {
|
|
557
|
+
id: nextId.current++,
|
|
558
|
+
options,
|
|
559
|
+
resolve
|
|
560
|
+
};
|
|
561
|
+
pending.current.add(entry);
|
|
562
|
+
setQueue((q) => [...q, entry]);
|
|
563
|
+
}), []);
|
|
564
|
+
const settle = useCallback((entry, confirmed) => {
|
|
565
|
+
if (pending.current.delete(entry)) entry.resolve(confirmed);
|
|
566
|
+
setQueue((q) => q.filter((e) => e !== entry));
|
|
567
|
+
}, []);
|
|
568
|
+
useEffect(() => {
|
|
569
|
+
const set = pending.current;
|
|
570
|
+
return () => {
|
|
571
|
+
for (const entry of set) entry.resolve(false);
|
|
572
|
+
set.clear();
|
|
573
|
+
setQueue([]);
|
|
574
|
+
};
|
|
575
|
+
}, []);
|
|
576
|
+
const current = queue[0];
|
|
577
|
+
return /* @__PURE__ */ jsxs(ConfirmContext.Provider, {
|
|
578
|
+
value: confirm,
|
|
579
|
+
children: [children, current !== void 0 ? /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
580
|
+
options: current.options,
|
|
581
|
+
onSettle: (confirmed) => settle(current, confirmed)
|
|
582
|
+
}, current.id) : null]
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function ConfirmDialog({ options, onSettle }) {
|
|
586
|
+
const { title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", variant = "default" } = options;
|
|
587
|
+
const danger = variant === "danger";
|
|
588
|
+
const dialogRef = useRef(null);
|
|
589
|
+
const initialFocusRef = useRef(null);
|
|
590
|
+
const confirmed = useRef(false);
|
|
591
|
+
const titleId = useId();
|
|
592
|
+
const descriptionId = useId();
|
|
593
|
+
useEffect(() => {
|
|
594
|
+
initialFocusRef.current?.focus();
|
|
595
|
+
}, []);
|
|
596
|
+
const answer = (value) => {
|
|
597
|
+
confirmed.current = value;
|
|
598
|
+
dialogRef.current?.close();
|
|
599
|
+
};
|
|
600
|
+
return /* @__PURE__ */ jsxs(Dialog.Container, {
|
|
601
|
+
ref: dialogRef,
|
|
602
|
+
open: true,
|
|
603
|
+
onOpenChange: (open) => {
|
|
604
|
+
if (!open) onSettle(confirmed.current);
|
|
605
|
+
},
|
|
606
|
+
size: "sm",
|
|
607
|
+
closedby: "closerequest",
|
|
608
|
+
role: "alertdialog",
|
|
609
|
+
"aria-labelledby": titleId,
|
|
610
|
+
"aria-describedby": description !== void 0 ? descriptionId : void 0,
|
|
611
|
+
children: [
|
|
612
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: /* @__PURE__ */ jsx(Dialog.Title, {
|
|
613
|
+
id: titleId,
|
|
614
|
+
children: title
|
|
615
|
+
}) }),
|
|
616
|
+
description !== void 0 ? /* @__PURE__ */ jsx(Dialog.Description, {
|
|
617
|
+
id: descriptionId,
|
|
618
|
+
children: description
|
|
619
|
+
}) : null,
|
|
620
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { children: [/* @__PURE__ */ jsx(Button, {
|
|
621
|
+
ref: danger ? initialFocusRef : void 0,
|
|
622
|
+
variant: "ghost",
|
|
623
|
+
onClick: () => answer(false),
|
|
624
|
+
children: cancelLabel
|
|
625
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
626
|
+
ref: danger ? void 0 : initialFocusRef,
|
|
627
|
+
variant: danger ? "danger" : "primary",
|
|
628
|
+
onClick: () => answer(true),
|
|
629
|
+
children: confirmLabel
|
|
630
|
+
})] })
|
|
631
|
+
]
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/AdminRoot.tsx
|
|
636
|
+
function AdminRoot({ className, theme, systemAccent, style, ref, children, ...rest }) {
|
|
637
|
+
const rootStyle = systemAccent !== void 0 ? {
|
|
638
|
+
...style,
|
|
639
|
+
"--color-system-accent": systemAccent
|
|
640
|
+
} : style;
|
|
641
|
+
const portalRef = useRef(null);
|
|
642
|
+
const setRef = useCallback((node) => {
|
|
643
|
+
portalRef.current = node;
|
|
644
|
+
if (typeof ref === "function") ref(node);
|
|
645
|
+
else if (ref) ref.current = node;
|
|
646
|
+
}, [ref]);
|
|
647
|
+
return /* @__PURE__ */ jsx(PortalContainerContext.Provider, {
|
|
648
|
+
value: portalRef,
|
|
649
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
650
|
+
ref: setRef,
|
|
651
|
+
className: cn("admin-root", className),
|
|
652
|
+
style: rootStyle,
|
|
653
|
+
...rest,
|
|
654
|
+
...theme !== void 0 && { "data-theme": theme },
|
|
655
|
+
children: /* @__PURE__ */ jsx(ConfirmHost, { children })
|
|
656
|
+
})
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/Alert.tsx
|
|
661
|
+
function DismissIcon() {
|
|
662
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
663
|
+
width: "1em",
|
|
664
|
+
height: "1em",
|
|
665
|
+
viewBox: "0 0 24 24",
|
|
666
|
+
fill: "none",
|
|
667
|
+
stroke: "currentColor",
|
|
668
|
+
strokeWidth: "2",
|
|
669
|
+
strokeLinecap: "round",
|
|
670
|
+
strokeLinejoin: "round",
|
|
671
|
+
"aria-hidden": "true",
|
|
672
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
function AlertRoot({ variant, icon, title, description, action, onDismiss, dismissLabel = "Dismiss", classNames, className, role, children, ...rest }) {
|
|
676
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
677
|
+
role: role ?? (variant === "danger" || variant === "warning" ? "alert" : "status"),
|
|
678
|
+
className: cn(["alert", `alert-${variant}`], className),
|
|
679
|
+
...rest,
|
|
680
|
+
children: [
|
|
681
|
+
renderIcon(icon),
|
|
682
|
+
title !== void 0 ? /* @__PURE__ */ jsx(AlertTitle, {
|
|
683
|
+
className: classNames?.title,
|
|
684
|
+
children: title
|
|
685
|
+
}) : null,
|
|
686
|
+
description !== void 0 ? /* @__PURE__ */ jsx(AlertDescription, {
|
|
687
|
+
className: classNames?.description,
|
|
688
|
+
children: description
|
|
689
|
+
}) : null,
|
|
690
|
+
children,
|
|
691
|
+
action !== void 0 ? /* @__PURE__ */ jsx(AlertAction, {
|
|
692
|
+
className: classNames?.action,
|
|
693
|
+
children: action
|
|
694
|
+
}) : null,
|
|
695
|
+
onDismiss ? /* @__PURE__ */ jsx("button", {
|
|
696
|
+
type: "button",
|
|
697
|
+
className: cn("alert-dismiss", classNames?.dismiss),
|
|
698
|
+
"aria-label": dismissLabel,
|
|
699
|
+
onClick: onDismiss,
|
|
700
|
+
children: /* @__PURE__ */ jsx(DismissIcon, {})
|
|
701
|
+
}) : null
|
|
702
|
+
]
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
function AlertTitle({ className, ...rest }) {
|
|
706
|
+
return /* @__PURE__ */ jsx("strong", {
|
|
707
|
+
className: cn("alert-title", className),
|
|
708
|
+
...rest
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
function AlertDescription({ className, ...rest }) {
|
|
712
|
+
return /* @__PURE__ */ jsx("p", {
|
|
713
|
+
className: cn("alert-description", className),
|
|
714
|
+
...rest
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
function AlertAction({ className, ...rest }) {
|
|
718
|
+
return /* @__PURE__ */ jsx("div", {
|
|
719
|
+
className: cn("alert-action", className),
|
|
720
|
+
...rest
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
var Alert = Object.assign(AlertRoot, {
|
|
724
|
+
Title: AlertTitle,
|
|
725
|
+
Description: AlertDescription,
|
|
726
|
+
Action: AlertAction
|
|
727
|
+
});
|
|
728
|
+
//#endregion
|
|
729
|
+
//#region src/AppShell.tsx
|
|
730
|
+
var AppShellContext = createContext(null);
|
|
731
|
+
function useAppShell() {
|
|
732
|
+
return useContext(AppShellContext);
|
|
733
|
+
}
|
|
734
|
+
function AppShellRoot({ hasSidebar = false, mobileDrawerOpen, defaultMobileDrawerOpen = false, onMobileDrawerOpenChange, systemAccent, className, style, children, ...rest }) {
|
|
735
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultMobileDrawerOpen);
|
|
736
|
+
const isControlled = mobileDrawerOpen !== void 0;
|
|
737
|
+
const open = isControlled ? mobileDrawerOpen : uncontrolledOpen;
|
|
738
|
+
const value = useMemo(() => ({
|
|
739
|
+
mobileDrawerOpen: open,
|
|
740
|
+
setMobileDrawerOpen: (next) => {
|
|
741
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
742
|
+
onMobileDrawerOpenChange?.(next);
|
|
743
|
+
},
|
|
744
|
+
hasSidebar
|
|
745
|
+
}), [
|
|
746
|
+
open,
|
|
747
|
+
isControlled,
|
|
748
|
+
onMobileDrawerOpenChange,
|
|
749
|
+
hasSidebar
|
|
750
|
+
]);
|
|
751
|
+
const rootStyle = systemAccent !== void 0 ? {
|
|
752
|
+
...style,
|
|
753
|
+
"--color-system-accent": systemAccent
|
|
754
|
+
} : style;
|
|
755
|
+
return /* @__PURE__ */ jsx(AppShellContext.Provider, {
|
|
756
|
+
value,
|
|
757
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
758
|
+
className: cn(["app-shell", hasSidebar && "app-shell-with-sidebar"], className),
|
|
759
|
+
style: rootStyle,
|
|
760
|
+
...rest,
|
|
761
|
+
children
|
|
762
|
+
})
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
function AppShellMain({ className, ...rest }) {
|
|
766
|
+
return /* @__PURE__ */ jsx("main", {
|
|
767
|
+
className: cn("app-shell-main", className),
|
|
768
|
+
...rest
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
var AppShell = Object.assign(AppShellRoot, { Main: AppShellMain });
|
|
772
|
+
//#endregion
|
|
773
|
+
//#region src/Badge.tsx
|
|
774
|
+
function RemoveIcon() {
|
|
775
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
776
|
+
width: "1em",
|
|
777
|
+
height: "1em",
|
|
778
|
+
viewBox: "0 0 24 24",
|
|
779
|
+
fill: "none",
|
|
780
|
+
stroke: "currentColor",
|
|
781
|
+
strokeWidth: "2",
|
|
782
|
+
strokeLinecap: "round",
|
|
783
|
+
strokeLinejoin: "round",
|
|
784
|
+
"aria-hidden": "true",
|
|
785
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
function Badge({ variant = "neutral", size = "md", icon, soft = false, onRemove, removeLabel = "Remove", className, children, ...rest }) {
|
|
789
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
790
|
+
className: cn([
|
|
791
|
+
"badge",
|
|
792
|
+
variant !== "neutral" && `badge-${variant}`,
|
|
793
|
+
size !== "md" && `badge-${size}`,
|
|
794
|
+
soft && "badge-soft"
|
|
795
|
+
], className),
|
|
796
|
+
...rest,
|
|
797
|
+
children: [
|
|
798
|
+
renderIcon(icon),
|
|
799
|
+
children,
|
|
800
|
+
onRemove ? /* @__PURE__ */ jsx("button", {
|
|
801
|
+
type: "button",
|
|
802
|
+
className: cn("badge-remove", void 0),
|
|
803
|
+
"aria-label": removeLabel,
|
|
804
|
+
onClick: onRemove,
|
|
805
|
+
children: /* @__PURE__ */ jsx(RemoveIcon, {})
|
|
806
|
+
}) : null
|
|
807
|
+
]
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
//#endregion
|
|
811
|
+
//#region src/BrandTile.tsx
|
|
812
|
+
/**
|
|
813
|
+
* Brand/system mark for the navbar — monogram, icon, or shop logo. Precedence
|
|
814
|
+
* is `src` > `icon` > `monogram`. Monogram/icon tiles are `aria-hidden`; image
|
|
815
|
+
* tiles expose `alt` to assistive tech instead.
|
|
816
|
+
*/
|
|
817
|
+
function BrandTile({ variant = "solid", size = "md", monogram, icon, src, alt = "", systemAccent, className, style, children, ...rest }) {
|
|
818
|
+
const tileStyle = systemAccent !== void 0 ? {
|
|
819
|
+
...style,
|
|
820
|
+
"--color-system-accent": systemAccent
|
|
821
|
+
} : style;
|
|
822
|
+
const classes = cn([
|
|
823
|
+
"brand-tile",
|
|
824
|
+
variant !== "solid" && `brand-tile-${variant}`,
|
|
825
|
+
size === "lg" && "brand-tile-lg"
|
|
826
|
+
], className);
|
|
827
|
+
if (src) return /* @__PURE__ */ jsx("span", {
|
|
828
|
+
className: classes,
|
|
829
|
+
style: tileStyle,
|
|
830
|
+
...rest,
|
|
831
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
832
|
+
src,
|
|
833
|
+
alt
|
|
834
|
+
})
|
|
835
|
+
});
|
|
836
|
+
return /* @__PURE__ */ jsx("span", {
|
|
837
|
+
className: classes,
|
|
838
|
+
style: tileStyle,
|
|
839
|
+
"aria-hidden": true,
|
|
840
|
+
...rest,
|
|
841
|
+
children: icon ? renderIcon(icon) : children ?? monogram
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region src/Avatar.tsx
|
|
846
|
+
/**
|
|
847
|
+
* Image avatar with an initials fallback. Initials show until the image loads
|
|
848
|
+
* (and again, React-only, if it errors); the vanilla CSS layers the `<img>`
|
|
849
|
+
* over the initials instead.
|
|
576
850
|
*/
|
|
577
|
-
function
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
elementRef.current = node;
|
|
581
|
-
if (typeof ref === "function") ref(node);
|
|
582
|
-
else if (ref) ref.current = node;
|
|
583
|
-
}, [ref]);
|
|
584
|
-
return {
|
|
585
|
-
...useHotkey(keys, () => elementRef.current?.click(), options),
|
|
586
|
-
setRef
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
//#endregion
|
|
590
|
-
//#region src/Button.tsx
|
|
591
|
-
function Button({ variant = "default", size = "md", fullWidth, loading, icon, iconTrailing, hotkey, className, type = "button", disabled, children, onClick, ref, ...rest }) {
|
|
592
|
-
const { ariaKeyShortcuts, primaryChord, setRef } = useHotkeyClick(hotkey, ref, { enabled: !disabled && !loading });
|
|
593
|
-
const iconOnly = children == null && (icon != null || iconTrailing != null);
|
|
594
|
-
return /* @__PURE__ */ jsxs(Button$1, {
|
|
595
|
-
ref: setRef,
|
|
596
|
-
onClick,
|
|
597
|
-
type,
|
|
598
|
-
disabled: disabled || loading,
|
|
599
|
-
"aria-busy": loading || void 0,
|
|
600
|
-
"aria-keyshortcuts": ariaKeyShortcuts,
|
|
851
|
+
function Avatar({ src, alt, initials, size = "md", shape = "circle", className, children, ...rest }) {
|
|
852
|
+
const fallback = children ?? initials;
|
|
853
|
+
return /* @__PURE__ */ jsxs(Avatar$1.Root, {
|
|
601
854
|
className: cn([
|
|
602
|
-
"
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
fullWidth && "btn-full-width",
|
|
606
|
-
loading && "btn-loading",
|
|
607
|
-
iconOnly && "btn-square"
|
|
855
|
+
"avatar",
|
|
856
|
+
size !== "md" && `avatar-${size}`,
|
|
857
|
+
shape === "square" && "avatar-square"
|
|
608
858
|
], className),
|
|
609
859
|
...rest,
|
|
610
|
-
children: [
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
860
|
+
children: [fallback !== void 0 ? /* @__PURE__ */ jsx(Avatar$1.Fallback, { children: fallback }) : null, src !== void 0 ? /* @__PURE__ */ jsx(Avatar$1.Image, {
|
|
861
|
+
src,
|
|
862
|
+
alt
|
|
863
|
+
}) : null]
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
/** Overlapping stack of avatars; later children paint on top. `max` caps the visible count. */
|
|
867
|
+
function AvatarGroup({ max, size = "md", className, children, ...rest }) {
|
|
868
|
+
const items = Children.toArray(children);
|
|
869
|
+
const overflow = max !== void 0 && items.length > max ? items.length - max : 0;
|
|
870
|
+
const visible = overflow > 0 ? items.slice(0, max) : items;
|
|
871
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
872
|
+
className: cn("avatar-group", className),
|
|
873
|
+
...rest,
|
|
874
|
+
children: [visible, overflow > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
875
|
+
className: cn([
|
|
876
|
+
"avatar",
|
|
877
|
+
size !== "md" && `avatar-${size}`,
|
|
878
|
+
"avatar-more"
|
|
879
|
+
], void 0),
|
|
880
|
+
"aria-label": `+${overflow} more`,
|
|
881
|
+
children: ["+", overflow]
|
|
882
|
+
}) : null]
|
|
616
883
|
});
|
|
617
884
|
}
|
|
618
885
|
//#endregion
|
|
@@ -1269,6 +1536,7 @@ function SelectPopup({ className, sideOffset = 4, children, ...rest }) {
|
|
|
1269
1536
|
return /* @__PURE__ */ jsx(Select$1.Portal, {
|
|
1270
1537
|
container: portalContainer ?? void 0,
|
|
1271
1538
|
children: /* @__PURE__ */ jsx(Select$1.Positioner, {
|
|
1539
|
+
className: cn("popup-layer", void 0),
|
|
1272
1540
|
sideOffset,
|
|
1273
1541
|
alignItemWithTrigger: false,
|
|
1274
1542
|
children: /* @__PURE__ */ jsx(Select$1.Popup, {
|
|
@@ -1350,13 +1618,18 @@ var Select = Object.assign(SelectRoot, {
|
|
|
1350
1618
|
* gap between stacked sections. Place inside `<AppShell.Main>`, which has no
|
|
1351
1619
|
* padding of its own. Not the `.Container` escape hatch (`Card.Container`).
|
|
1352
1620
|
*/
|
|
1353
|
-
function Container({ size = "md", compact, className, ...rest }) {
|
|
1621
|
+
function Container({ size = "md", compact, maxWidth, className, style, ...rest }) {
|
|
1622
|
+
const rootStyle = maxWidth !== void 0 ? {
|
|
1623
|
+
...style,
|
|
1624
|
+
"--container-max": maxWidth
|
|
1625
|
+
} : style;
|
|
1354
1626
|
return /* @__PURE__ */ jsx("div", {
|
|
1355
1627
|
className: cn([
|
|
1356
1628
|
"container",
|
|
1357
1629
|
size !== "md" && `container-${size}`,
|
|
1358
1630
|
compact && "container-compact"
|
|
1359
1631
|
], className),
|
|
1632
|
+
style: rootStyle,
|
|
1360
1633
|
...rest
|
|
1361
1634
|
});
|
|
1362
1635
|
}
|
|
@@ -1770,13 +2043,14 @@ function Bar({ datum, value, label, color, className, style, ...rest }) {
|
|
|
1770
2043
|
}
|
|
1771
2044
|
/** Single-series bar chart. For hand-composed layouts use `<BarChart.Container>` + `<BarChart.Bar>`. */
|
|
1772
2045
|
function BarChartRoot({ data, max, orientation = "horizontal", size = "md", showValues, inline, variant = "info", style, "aria-label": ariaLabel, ...rest }) {
|
|
2046
|
+
const resolvedMax = computeMax(data, max);
|
|
1773
2047
|
return /* @__PURE__ */ jsx(BarChartContainer, {
|
|
1774
2048
|
orientation,
|
|
1775
2049
|
size,
|
|
1776
2050
|
showValues,
|
|
1777
2051
|
inline,
|
|
1778
2052
|
variant,
|
|
1779
|
-
style: mergeStyle({ "--chart-max":
|
|
2053
|
+
style: mergeStyle({ "--chart-max": resolvedMax }, style),
|
|
1780
2054
|
"aria-label": ariaLabel ?? buildAriaLabel("bar", data),
|
|
1781
2055
|
...rest,
|
|
1782
2056
|
children: data.map((d, i) => /* @__PURE__ */ jsx(Bar, { datum: d }, d.label ?? i))
|
|
@@ -1899,163 +2173,6 @@ var StackedBar = Object.assign(StackedBarRoot, {
|
|
|
1899
2173
|
Legend: ChartLegend
|
|
1900
2174
|
});
|
|
1901
2175
|
//#endregion
|
|
1902
|
-
//#region src/dialog-internal.ts
|
|
1903
|
-
var DialogContext = createContext(null);
|
|
1904
|
-
/**
|
|
1905
|
-
* Drives a native `<dialog>` from a controlled `open` prop, shared by `<Dialog>`
|
|
1906
|
-
* and `<Drawer>`: merges the consumer ref, calls `showModal()` / `close()` on
|
|
1907
|
-
* change, and reports closes (Esc, backdrop, form submit) via `onOpenChange`.
|
|
1908
|
-
* Returns `ref` for the portal container context.
|
|
1909
|
-
*/
|
|
1910
|
-
function useDialogElement(open, onOpenChange, consumerRef) {
|
|
1911
|
-
const ref = useRef(null);
|
|
1912
|
-
const onOpenChangeRef = useRef(onOpenChange);
|
|
1913
|
-
onOpenChangeRef.current = onOpenChange;
|
|
1914
|
-
const setRef = useCallback((node) => {
|
|
1915
|
-
ref.current = node;
|
|
1916
|
-
if (typeof consumerRef === "function") consumerRef(node);
|
|
1917
|
-
else if (consumerRef) consumerRef.current = node;
|
|
1918
|
-
}, [consumerRef]);
|
|
1919
|
-
useEffect(() => {
|
|
1920
|
-
const el = ref.current;
|
|
1921
|
-
if (!el || open === void 0) return;
|
|
1922
|
-
if (open && !el.open) el.showModal();
|
|
1923
|
-
else if (!open && el.open) el.close();
|
|
1924
|
-
}, [open]);
|
|
1925
|
-
useEffect(() => {
|
|
1926
|
-
const el = ref.current;
|
|
1927
|
-
if (!el) return;
|
|
1928
|
-
const handleClose = () => onOpenChangeRef.current?.(false);
|
|
1929
|
-
el.addEventListener("close", handleClose);
|
|
1930
|
-
return () => el.removeEventListener("close", handleClose);
|
|
1931
|
-
}, []);
|
|
1932
|
-
return {
|
|
1933
|
-
setRef,
|
|
1934
|
-
ctx: { close: () => ref.current?.close() },
|
|
1935
|
-
ref
|
|
1936
|
-
};
|
|
1937
|
-
}
|
|
1938
|
-
//#endregion
|
|
1939
|
-
//#region src/Dialog.tsx
|
|
1940
|
-
function DefaultCloseIcon() {
|
|
1941
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
1942
|
-
width: "16",
|
|
1943
|
-
height: "16",
|
|
1944
|
-
viewBox: "0 0 24 24",
|
|
1945
|
-
fill: "none",
|
|
1946
|
-
stroke: "currentColor",
|
|
1947
|
-
strokeWidth: "2",
|
|
1948
|
-
strokeLinecap: "round",
|
|
1949
|
-
strokeLinejoin: "round",
|
|
1950
|
-
"aria-hidden": "true",
|
|
1951
|
-
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
1952
|
-
});
|
|
1953
|
-
}
|
|
1954
|
-
/** The bare `<dialog>` primitive — for layouts the default `<Dialog>` doesn't fit. */
|
|
1955
|
-
function DialogContainer({ open, onOpenChange, size = "md", closedby = "any", className, children, ref: consumerRef, ...rest }) {
|
|
1956
|
-
const { setRef, ctx, ref } = useDialogElement(open, onOpenChange, consumerRef);
|
|
1957
|
-
return /* @__PURE__ */ jsx(DialogContext.Provider, {
|
|
1958
|
-
value: ctx,
|
|
1959
|
-
children: /* @__PURE__ */ jsx(PortalContainerContext.Provider, {
|
|
1960
|
-
value: ref,
|
|
1961
|
-
children: /* @__PURE__ */ jsx("dialog", {
|
|
1962
|
-
ref: setRef,
|
|
1963
|
-
className: cn(["dialog", size !== "md" && `dialog-${size}`], className),
|
|
1964
|
-
closedby,
|
|
1965
|
-
...rest,
|
|
1966
|
-
children
|
|
1967
|
-
})
|
|
1968
|
-
})
|
|
1969
|
-
});
|
|
1970
|
-
}
|
|
1971
|
-
function DialogHeader({ className, ...rest }) {
|
|
1972
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1973
|
-
className: cn("dialog-header", className),
|
|
1974
|
-
...rest
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
function DialogTitle({ icon, className, children, ...rest }) {
|
|
1978
|
-
return /* @__PURE__ */ jsxs("h2", {
|
|
1979
|
-
className: cn("dialog-title", className),
|
|
1980
|
-
...rest,
|
|
1981
|
-
children: [renderIcon(icon), children]
|
|
1982
|
-
});
|
|
1983
|
-
}
|
|
1984
|
-
function DialogDescription({ className, ...rest }) {
|
|
1985
|
-
return /* @__PURE__ */ jsx("p", {
|
|
1986
|
-
className: cn("dialog-description", className),
|
|
1987
|
-
...rest
|
|
1988
|
-
});
|
|
1989
|
-
}
|
|
1990
|
-
function DialogBody({ className, ...rest }) {
|
|
1991
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1992
|
-
className: cn("dialog-body", className),
|
|
1993
|
-
...rest
|
|
1994
|
-
});
|
|
1995
|
-
}
|
|
1996
|
-
function DialogFooter({ className, ...rest }) {
|
|
1997
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1998
|
-
className: cn("dialog-footer", className),
|
|
1999
|
-
...rest
|
|
2000
|
-
});
|
|
2001
|
-
}
|
|
2002
|
-
function DialogCloseButton({ icon, className, children, onClick, type = "button", "aria-label": ariaLabel = "Close", ...rest }) {
|
|
2003
|
-
const ctx = useContext(DialogContext);
|
|
2004
|
-
return /* @__PURE__ */ jsx("button", {
|
|
2005
|
-
type,
|
|
2006
|
-
className: cn("dialog-close", className),
|
|
2007
|
-
"aria-label": ariaLabel,
|
|
2008
|
-
onClick: (event) => {
|
|
2009
|
-
onClick?.(event);
|
|
2010
|
-
if (!event.defaultPrevented) ctx?.close();
|
|
2011
|
-
},
|
|
2012
|
-
...rest,
|
|
2013
|
-
children: children ?? (icon !== void 0 ? renderIcon(icon) : /* @__PURE__ */ jsx(DefaultCloseIcon, {}))
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
/** Standard modal with shorthand-driven header/body/footer. For other shapes, compose `<Dialog.Container>` by hand. */
|
|
2017
|
-
function DialogRoot({ icon, title, description, actions, dismissible = true, closeLabel = "Close", classNames, children, ...containerProps }) {
|
|
2018
|
-
const hasTitle = title !== void 0 || icon !== void 0;
|
|
2019
|
-
const showHeader = hasTitle || dismissible;
|
|
2020
|
-
return /* @__PURE__ */ jsxs(DialogContainer, {
|
|
2021
|
-
...containerProps,
|
|
2022
|
-
children: [
|
|
2023
|
-
showHeader ? /* @__PURE__ */ jsxs(DialogHeader, {
|
|
2024
|
-
className: classNames?.header,
|
|
2025
|
-
children: [hasTitle ? /* @__PURE__ */ jsx(DialogTitle, {
|
|
2026
|
-
icon,
|
|
2027
|
-
className: classNames?.title,
|
|
2028
|
-
children: title
|
|
2029
|
-
}) : /* @__PURE__ */ jsx("span", { className: cn("flex-1", void 0) }), dismissible ? /* @__PURE__ */ jsx(DialogCloseButton, {
|
|
2030
|
-
"aria-label": closeLabel,
|
|
2031
|
-
className: classNames?.close
|
|
2032
|
-
}) : null]
|
|
2033
|
-
}) : null,
|
|
2034
|
-
description !== void 0 ? /* @__PURE__ */ jsx(DialogDescription, {
|
|
2035
|
-
className: classNames?.description,
|
|
2036
|
-
children: description
|
|
2037
|
-
}) : null,
|
|
2038
|
-
children !== void 0 ? /* @__PURE__ */ jsx(DialogBody, {
|
|
2039
|
-
className: classNames?.body,
|
|
2040
|
-
children
|
|
2041
|
-
}) : null,
|
|
2042
|
-
actions !== void 0 ? /* @__PURE__ */ jsx(DialogFooter, {
|
|
2043
|
-
className: classNames?.footer,
|
|
2044
|
-
children: actions
|
|
2045
|
-
}) : null
|
|
2046
|
-
]
|
|
2047
|
-
});
|
|
2048
|
-
}
|
|
2049
|
-
var Dialog = Object.assign(DialogRoot, {
|
|
2050
|
-
Container: DialogContainer,
|
|
2051
|
-
Header: DialogHeader,
|
|
2052
|
-
Title: DialogTitle,
|
|
2053
|
-
Description: DialogDescription,
|
|
2054
|
-
Body: DialogBody,
|
|
2055
|
-
Footer: DialogFooter,
|
|
2056
|
-
CloseButton: DialogCloseButton
|
|
2057
|
-
});
|
|
2058
|
-
//#endregion
|
|
2059
2176
|
//#region src/Drawer.tsx
|
|
2060
2177
|
/** The bare edge-anchored `<dialog>` primitive — for layouts the default `<Drawer>` doesn't fit. */
|
|
2061
2178
|
function DrawerContainer({ open, onOpenChange, side = "end", size = "md", closedby = "any", className, children, ref: consumerRef, ...rest }) {
|
|
@@ -2092,7 +2209,7 @@ function DrawerRoot({ icon, title, description, actions, dismissible = true, clo
|
|
|
2092
2209
|
icon,
|
|
2093
2210
|
className: classNames?.title,
|
|
2094
2211
|
children: title
|
|
2095
|
-
}) :
|
|
2212
|
+
}) : null, dismissible ? /* @__PURE__ */ jsx(Dialog.CloseButton, {
|
|
2096
2213
|
"aria-label": closeLabel,
|
|
2097
2214
|
className: classNames?.close
|
|
2098
2215
|
}) : null]
|
|
@@ -2159,7 +2276,7 @@ function FieldRoot({ label, description, error, required, inline, className, cla
|
|
|
2159
2276
|
}
|
|
2160
2277
|
function FieldLabel({ className, required, ...rest }) {
|
|
2161
2278
|
return /* @__PURE__ */ jsx(Field$1.Label, {
|
|
2162
|
-
"data-required": required ? "" :
|
|
2279
|
+
"data-required": required === void 0 ? void 0 : required ? "" : "false",
|
|
2163
2280
|
className: cn("field-label", className),
|
|
2164
2281
|
...rest
|
|
2165
2282
|
});
|
|
@@ -2222,10 +2339,16 @@ function MenuRoot({ className, ...rest }) {
|
|
|
2222
2339
|
...rest
|
|
2223
2340
|
});
|
|
2224
2341
|
}
|
|
2225
|
-
function MenuTrigger({ className, ...rest }) {
|
|
2342
|
+
function MenuTrigger({ variant, size = "md", className, children, ...rest }) {
|
|
2226
2343
|
return /* @__PURE__ */ jsx("summary", {
|
|
2227
|
-
className: cn("menu-trigger",
|
|
2228
|
-
|
|
2344
|
+
className: cn(["menu-trigger", variant !== void 0 && [
|
|
2345
|
+
"btn",
|
|
2346
|
+
variant !== "default" && `btn-${variant}`,
|
|
2347
|
+
size !== "md" && `btn-${size}`,
|
|
2348
|
+
children == null && "btn-square"
|
|
2349
|
+
]], className),
|
|
2350
|
+
...rest,
|
|
2351
|
+
children
|
|
2229
2352
|
});
|
|
2230
2353
|
}
|
|
2231
2354
|
function MenuPopup({ className, role = "menu", ...rest }) {
|
|
@@ -2332,9 +2455,14 @@ var Menu = Object.assign(MenuRoot, {
|
|
|
2332
2455
|
});
|
|
2333
2456
|
//#endregion
|
|
2334
2457
|
//#region src/Navbar.tsx
|
|
2335
|
-
function NavbarRoot({ className, ...rest }) {
|
|
2458
|
+
function NavbarRoot({ systemAccent, className, style, ...rest }) {
|
|
2459
|
+
const rootStyle = systemAccent !== void 0 ? {
|
|
2460
|
+
...style,
|
|
2461
|
+
"--color-system-accent": systemAccent
|
|
2462
|
+
} : style;
|
|
2336
2463
|
return /* @__PURE__ */ jsx("header", {
|
|
2337
2464
|
className: cn("navbar", className),
|
|
2465
|
+
style: rootStyle,
|
|
2338
2466
|
...rest
|
|
2339
2467
|
});
|
|
2340
2468
|
}
|
|
@@ -2475,6 +2603,7 @@ function TooltipPopup({ size = "md", side = "top", align = "center", sideOffset
|
|
|
2475
2603
|
return /* @__PURE__ */ jsx(Tooltip$1.Portal, {
|
|
2476
2604
|
container: portalContainer ?? void 0,
|
|
2477
2605
|
children: /* @__PURE__ */ jsx(Tooltip$1.Positioner, {
|
|
2606
|
+
className: cn("popup-layer", void 0),
|
|
2478
2607
|
sideOffset,
|
|
2479
2608
|
side,
|
|
2480
2609
|
align,
|
|
@@ -2865,20 +2994,13 @@ function SidebarCollapseToggle({ label = "Toggle sidebar", className, classNames
|
|
|
2865
2994
|
return /* @__PURE__ */ jsxs("label", {
|
|
2866
2995
|
className: cn("sidebar-collapse-toggle", className),
|
|
2867
2996
|
...rest,
|
|
2868
|
-
children: [
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
}),
|
|
2876
|
-
/* @__PURE__ */ jsx("span", {
|
|
2877
|
-
className: cn("sr-only", void 0),
|
|
2878
|
-
children: label
|
|
2879
|
-
}),
|
|
2880
|
-
children
|
|
2881
|
-
]
|
|
2997
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
2998
|
+
type: "checkbox",
|
|
2999
|
+
className: cn("sidebar-toggle", classNames?.input),
|
|
3000
|
+
"aria-label": label,
|
|
3001
|
+
...isControlled ? { checked: controlledChecked } : { defaultChecked: ctx?.defaultCollapsed },
|
|
3002
|
+
onChange: (event) => ctx?.onCollapsedChange?.(event.currentTarget.checked)
|
|
3003
|
+
}), children]
|
|
2882
3004
|
});
|
|
2883
3005
|
}
|
|
2884
3006
|
var Sidebar = Object.assign(SidebarRoot, {
|
|
@@ -2896,6 +3018,6 @@ var Sidebar = Object.assign(SidebarRoot, {
|
|
|
2896
3018
|
CollapseToggle: SidebarCollapseToggle
|
|
2897
3019
|
});
|
|
2898
3020
|
//#endregion
|
|
2899
|
-
export { Accordion, AdminRoot, Alert, AppShell, Avatar, AvatarGroup, Badge, BarChart, BrandTile, Breadcrumbs, Button, ButtonGroup, Card, ChartLegend, Checkbox, CodeBlock, Container, Dialog, Donut, Drawer, Field, FileInput, Footer, Indicator, Input, InputGroup, Item, ItemGroup, Kbd, Link, Menu, Navbar, NumberInput, Pagination, PasswordInput, Progress, PropertyList, Prose, Radio, RadioGroup, SERIES, Select, Separator, Sidebar, Spinner, StackedBar, StatCard, Switch, Table, Tabs, Textarea, Timeline, ToggleButton, Tooltip, getPaginationItems, useAppShell, useHotkey };
|
|
3021
|
+
export { Accordion, AdminRoot, Alert, AppShell, Avatar, AvatarGroup, Badge, BarChart, BrandTile, Breadcrumbs, Button, ButtonGroup, Card, ChartLegend, Checkbox, CodeBlock, Container, Dialog, Donut, Drawer, Field, FileInput, Footer, Indicator, Input, InputGroup, Item, ItemGroup, Kbd, Link, Menu, Navbar, NumberInput, Pagination, PasswordInput, Progress, PropertyList, Prose, Radio, RadioGroup, SERIES, Select, Separator, Sidebar, Spinner, StackedBar, StatCard, Switch, Table, Tabs, Textarea, Timeline, ToggleButton, Tooltip, getPaginationItems, useAppShell, useConfirm, useHotkey };
|
|
2900
3022
|
|
|
2901
3023
|
//# sourceMappingURL=index.mjs.map
|