@aortl/admin-react 0.20.1 → 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 +25 -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/Sidebar.d.ts.map +1 -1
- package/dist/admin.scoped.css +28 -161
- package/dist/index.cjs +585 -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 +586 -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
|
|
@@ -1351,13 +1618,18 @@ var Select = Object.assign(SelectRoot, {
|
|
|
1351
1618
|
* gap between stacked sections. Place inside `<AppShell.Main>`, which has no
|
|
1352
1619
|
* padding of its own. Not the `.Container` escape hatch (`Card.Container`).
|
|
1353
1620
|
*/
|
|
1354
|
-
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;
|
|
1355
1626
|
return /* @__PURE__ */ jsx("div", {
|
|
1356
1627
|
className: cn([
|
|
1357
1628
|
"container",
|
|
1358
1629
|
size !== "md" && `container-${size}`,
|
|
1359
1630
|
compact && "container-compact"
|
|
1360
1631
|
], className),
|
|
1632
|
+
style: rootStyle,
|
|
1361
1633
|
...rest
|
|
1362
1634
|
});
|
|
1363
1635
|
}
|
|
@@ -1771,13 +2043,14 @@ function Bar({ datum, value, label, color, className, style, ...rest }) {
|
|
|
1771
2043
|
}
|
|
1772
2044
|
/** Single-series bar chart. For hand-composed layouts use `<BarChart.Container>` + `<BarChart.Bar>`. */
|
|
1773
2045
|
function BarChartRoot({ data, max, orientation = "horizontal", size = "md", showValues, inline, variant = "info", style, "aria-label": ariaLabel, ...rest }) {
|
|
2046
|
+
const resolvedMax = computeMax(data, max);
|
|
1774
2047
|
return /* @__PURE__ */ jsx(BarChartContainer, {
|
|
1775
2048
|
orientation,
|
|
1776
2049
|
size,
|
|
1777
2050
|
showValues,
|
|
1778
2051
|
inline,
|
|
1779
2052
|
variant,
|
|
1780
|
-
style: mergeStyle({ "--chart-max":
|
|
2053
|
+
style: mergeStyle({ "--chart-max": resolvedMax }, style),
|
|
1781
2054
|
"aria-label": ariaLabel ?? buildAriaLabel("bar", data),
|
|
1782
2055
|
...rest,
|
|
1783
2056
|
children: data.map((d, i) => /* @__PURE__ */ jsx(Bar, { datum: d }, d.label ?? i))
|
|
@@ -1900,163 +2173,6 @@ var StackedBar = Object.assign(StackedBarRoot, {
|
|
|
1900
2173
|
Legend: ChartLegend
|
|
1901
2174
|
});
|
|
1902
2175
|
//#endregion
|
|
1903
|
-
//#region src/dialog-internal.ts
|
|
1904
|
-
var DialogContext = createContext(null);
|
|
1905
|
-
/**
|
|
1906
|
-
* Drives a native `<dialog>` from a controlled `open` prop, shared by `<Dialog>`
|
|
1907
|
-
* and `<Drawer>`: merges the consumer ref, calls `showModal()` / `close()` on
|
|
1908
|
-
* change, and reports closes (Esc, backdrop, form submit) via `onOpenChange`.
|
|
1909
|
-
* Returns `ref` for the portal container context.
|
|
1910
|
-
*/
|
|
1911
|
-
function useDialogElement(open, onOpenChange, consumerRef) {
|
|
1912
|
-
const ref = useRef(null);
|
|
1913
|
-
const onOpenChangeRef = useRef(onOpenChange);
|
|
1914
|
-
onOpenChangeRef.current = onOpenChange;
|
|
1915
|
-
const setRef = useCallback((node) => {
|
|
1916
|
-
ref.current = node;
|
|
1917
|
-
if (typeof consumerRef === "function") consumerRef(node);
|
|
1918
|
-
else if (consumerRef) consumerRef.current = node;
|
|
1919
|
-
}, [consumerRef]);
|
|
1920
|
-
useEffect(() => {
|
|
1921
|
-
const el = ref.current;
|
|
1922
|
-
if (!el || open === void 0) return;
|
|
1923
|
-
if (open && !el.open) el.showModal();
|
|
1924
|
-
else if (!open && el.open) el.close();
|
|
1925
|
-
}, [open]);
|
|
1926
|
-
useEffect(() => {
|
|
1927
|
-
const el = ref.current;
|
|
1928
|
-
if (!el) return;
|
|
1929
|
-
const handleClose = () => onOpenChangeRef.current?.(false);
|
|
1930
|
-
el.addEventListener("close", handleClose);
|
|
1931
|
-
return () => el.removeEventListener("close", handleClose);
|
|
1932
|
-
}, []);
|
|
1933
|
-
return {
|
|
1934
|
-
setRef,
|
|
1935
|
-
ctx: { close: () => ref.current?.close() },
|
|
1936
|
-
ref
|
|
1937
|
-
};
|
|
1938
|
-
}
|
|
1939
|
-
//#endregion
|
|
1940
|
-
//#region src/Dialog.tsx
|
|
1941
|
-
function DefaultCloseIcon() {
|
|
1942
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
1943
|
-
width: "16",
|
|
1944
|
-
height: "16",
|
|
1945
|
-
viewBox: "0 0 24 24",
|
|
1946
|
-
fill: "none",
|
|
1947
|
-
stroke: "currentColor",
|
|
1948
|
-
strokeWidth: "2",
|
|
1949
|
-
strokeLinecap: "round",
|
|
1950
|
-
strokeLinejoin: "round",
|
|
1951
|
-
"aria-hidden": "true",
|
|
1952
|
-
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
/** The bare `<dialog>` primitive — for layouts the default `<Dialog>` doesn't fit. */
|
|
1956
|
-
function DialogContainer({ open, onOpenChange, size = "md", closedby = "any", className, children, ref: consumerRef, ...rest }) {
|
|
1957
|
-
const { setRef, ctx, ref } = useDialogElement(open, onOpenChange, consumerRef);
|
|
1958
|
-
return /* @__PURE__ */ jsx(DialogContext.Provider, {
|
|
1959
|
-
value: ctx,
|
|
1960
|
-
children: /* @__PURE__ */ jsx(PortalContainerContext.Provider, {
|
|
1961
|
-
value: ref,
|
|
1962
|
-
children: /* @__PURE__ */ jsx("dialog", {
|
|
1963
|
-
ref: setRef,
|
|
1964
|
-
className: cn(["dialog", size !== "md" && `dialog-${size}`], className),
|
|
1965
|
-
closedby,
|
|
1966
|
-
...rest,
|
|
1967
|
-
children
|
|
1968
|
-
})
|
|
1969
|
-
})
|
|
1970
|
-
});
|
|
1971
|
-
}
|
|
1972
|
-
function DialogHeader({ className, ...rest }) {
|
|
1973
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1974
|
-
className: cn("dialog-header", className),
|
|
1975
|
-
...rest
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
function DialogTitle({ icon, className, children, ...rest }) {
|
|
1979
|
-
return /* @__PURE__ */ jsxs("h2", {
|
|
1980
|
-
className: cn("dialog-title", className),
|
|
1981
|
-
...rest,
|
|
1982
|
-
children: [renderIcon(icon), children]
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
function DialogDescription({ className, ...rest }) {
|
|
1986
|
-
return /* @__PURE__ */ jsx("p", {
|
|
1987
|
-
className: cn("dialog-description", className),
|
|
1988
|
-
...rest
|
|
1989
|
-
});
|
|
1990
|
-
}
|
|
1991
|
-
function DialogBody({ className, ...rest }) {
|
|
1992
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1993
|
-
className: cn("dialog-body", className),
|
|
1994
|
-
...rest
|
|
1995
|
-
});
|
|
1996
|
-
}
|
|
1997
|
-
function DialogFooter({ className, ...rest }) {
|
|
1998
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1999
|
-
className: cn("dialog-footer", className),
|
|
2000
|
-
...rest
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
|
-
function DialogCloseButton({ icon, className, children, onClick, type = "button", "aria-label": ariaLabel = "Close", ...rest }) {
|
|
2004
|
-
const ctx = useContext(DialogContext);
|
|
2005
|
-
return /* @__PURE__ */ jsx("button", {
|
|
2006
|
-
type,
|
|
2007
|
-
className: cn("dialog-close", className),
|
|
2008
|
-
"aria-label": ariaLabel,
|
|
2009
|
-
onClick: (event) => {
|
|
2010
|
-
onClick?.(event);
|
|
2011
|
-
if (!event.defaultPrevented) ctx?.close();
|
|
2012
|
-
},
|
|
2013
|
-
...rest,
|
|
2014
|
-
children: children ?? (icon !== void 0 ? renderIcon(icon) : /* @__PURE__ */ jsx(DefaultCloseIcon, {}))
|
|
2015
|
-
});
|
|
2016
|
-
}
|
|
2017
|
-
/** Standard modal with shorthand-driven header/body/footer. For other shapes, compose `<Dialog.Container>` by hand. */
|
|
2018
|
-
function DialogRoot({ icon, title, description, actions, dismissible = true, closeLabel = "Close", classNames, children, ...containerProps }) {
|
|
2019
|
-
const hasTitle = title !== void 0 || icon !== void 0;
|
|
2020
|
-
const showHeader = hasTitle || dismissible;
|
|
2021
|
-
return /* @__PURE__ */ jsxs(DialogContainer, {
|
|
2022
|
-
...containerProps,
|
|
2023
|
-
children: [
|
|
2024
|
-
showHeader ? /* @__PURE__ */ jsxs(DialogHeader, {
|
|
2025
|
-
className: classNames?.header,
|
|
2026
|
-
children: [hasTitle ? /* @__PURE__ */ jsx(DialogTitle, {
|
|
2027
|
-
icon,
|
|
2028
|
-
className: classNames?.title,
|
|
2029
|
-
children: title
|
|
2030
|
-
}) : /* @__PURE__ */ jsx("span", { className: cn("flex-1", void 0) }), dismissible ? /* @__PURE__ */ jsx(DialogCloseButton, {
|
|
2031
|
-
"aria-label": closeLabel,
|
|
2032
|
-
className: classNames?.close
|
|
2033
|
-
}) : null]
|
|
2034
|
-
}) : null,
|
|
2035
|
-
description !== void 0 ? /* @__PURE__ */ jsx(DialogDescription, {
|
|
2036
|
-
className: classNames?.description,
|
|
2037
|
-
children: description
|
|
2038
|
-
}) : null,
|
|
2039
|
-
children !== void 0 ? /* @__PURE__ */ jsx(DialogBody, {
|
|
2040
|
-
className: classNames?.body,
|
|
2041
|
-
children
|
|
2042
|
-
}) : null,
|
|
2043
|
-
actions !== void 0 ? /* @__PURE__ */ jsx(DialogFooter, {
|
|
2044
|
-
className: classNames?.footer,
|
|
2045
|
-
children: actions
|
|
2046
|
-
}) : null
|
|
2047
|
-
]
|
|
2048
|
-
});
|
|
2049
|
-
}
|
|
2050
|
-
var Dialog = Object.assign(DialogRoot, {
|
|
2051
|
-
Container: DialogContainer,
|
|
2052
|
-
Header: DialogHeader,
|
|
2053
|
-
Title: DialogTitle,
|
|
2054
|
-
Description: DialogDescription,
|
|
2055
|
-
Body: DialogBody,
|
|
2056
|
-
Footer: DialogFooter,
|
|
2057
|
-
CloseButton: DialogCloseButton
|
|
2058
|
-
});
|
|
2059
|
-
//#endregion
|
|
2060
2176
|
//#region src/Drawer.tsx
|
|
2061
2177
|
/** The bare edge-anchored `<dialog>` primitive — for layouts the default `<Drawer>` doesn't fit. */
|
|
2062
2178
|
function DrawerContainer({ open, onOpenChange, side = "end", size = "md", closedby = "any", className, children, ref: consumerRef, ...rest }) {
|
|
@@ -2093,7 +2209,7 @@ function DrawerRoot({ icon, title, description, actions, dismissible = true, clo
|
|
|
2093
2209
|
icon,
|
|
2094
2210
|
className: classNames?.title,
|
|
2095
2211
|
children: title
|
|
2096
|
-
}) :
|
|
2212
|
+
}) : null, dismissible ? /* @__PURE__ */ jsx(Dialog.CloseButton, {
|
|
2097
2213
|
"aria-label": closeLabel,
|
|
2098
2214
|
className: classNames?.close
|
|
2099
2215
|
}) : null]
|
|
@@ -2160,7 +2276,7 @@ function FieldRoot({ label, description, error, required, inline, className, cla
|
|
|
2160
2276
|
}
|
|
2161
2277
|
function FieldLabel({ className, required, ...rest }) {
|
|
2162
2278
|
return /* @__PURE__ */ jsx(Field$1.Label, {
|
|
2163
|
-
"data-required": required ? "" :
|
|
2279
|
+
"data-required": required === void 0 ? void 0 : required ? "" : "false",
|
|
2164
2280
|
className: cn("field-label", className),
|
|
2165
2281
|
...rest
|
|
2166
2282
|
});
|
|
@@ -2223,10 +2339,16 @@ function MenuRoot({ className, ...rest }) {
|
|
|
2223
2339
|
...rest
|
|
2224
2340
|
});
|
|
2225
2341
|
}
|
|
2226
|
-
function MenuTrigger({ className, ...rest }) {
|
|
2342
|
+
function MenuTrigger({ variant, size = "md", className, children, ...rest }) {
|
|
2227
2343
|
return /* @__PURE__ */ jsx("summary", {
|
|
2228
|
-
className: cn("menu-trigger",
|
|
2229
|
-
|
|
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
|
|
2230
2352
|
});
|
|
2231
2353
|
}
|
|
2232
2354
|
function MenuPopup({ className, role = "menu", ...rest }) {
|
|
@@ -2333,9 +2455,14 @@ var Menu = Object.assign(MenuRoot, {
|
|
|
2333
2455
|
});
|
|
2334
2456
|
//#endregion
|
|
2335
2457
|
//#region src/Navbar.tsx
|
|
2336
|
-
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;
|
|
2337
2463
|
return /* @__PURE__ */ jsx("header", {
|
|
2338
2464
|
className: cn("navbar", className),
|
|
2465
|
+
style: rootStyle,
|
|
2339
2466
|
...rest
|
|
2340
2467
|
});
|
|
2341
2468
|
}
|
|
@@ -2867,20 +2994,13 @@ function SidebarCollapseToggle({ label = "Toggle sidebar", className, classNames
|
|
|
2867
2994
|
return /* @__PURE__ */ jsxs("label", {
|
|
2868
2995
|
className: cn("sidebar-collapse-toggle", className),
|
|
2869
2996
|
...rest,
|
|
2870
|
-
children: [
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
}),
|
|
2878
|
-
/* @__PURE__ */ jsx("span", {
|
|
2879
|
-
className: cn("sr-only", void 0),
|
|
2880
|
-
children: label
|
|
2881
|
-
}),
|
|
2882
|
-
children
|
|
2883
|
-
]
|
|
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]
|
|
2884
3004
|
});
|
|
2885
3005
|
}
|
|
2886
3006
|
var Sidebar = Object.assign(SidebarRoot, {
|
|
@@ -2898,6 +3018,6 @@ var Sidebar = Object.assign(SidebarRoot, {
|
|
|
2898
3018
|
CollapseToggle: SidebarCollapseToggle
|
|
2899
3019
|
});
|
|
2900
3020
|
//#endregion
|
|
2901
|
-
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 };
|
|
2902
3022
|
|
|
2903
3023
|
//# sourceMappingURL=index.mjs.map
|