@cboxdk/cbox-ui 0.11.2 → 0.12.1
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/README.md +30 -1
- package/dist/index.d.ts +229 -2
- package/dist/index.js +387 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/tokens/cbox.css +7 -0
- package/tokens/controls.css +289 -0
- package/tokens/shell.css +10 -6
package/dist/index.js
CHANGED
|
@@ -2,9 +2,10 @@ import { cn } from './chunk-QJ4T7RR2.js';
|
|
|
2
2
|
export { cn, niceTicks, timeTicks } from './chunk-QJ4T7RR2.js';
|
|
3
3
|
import { defineCboxAppSwitcher, subscribeKnownAppCatalog, readKnownAppCatalog, secureIconUrl, initials, parseAppCatalog, signInTarget, rememberAppCatalog } from './chunk-AJCYF7SS.js';
|
|
4
4
|
export { authorizeHref, parseAppCatalog, readKnownAppCatalog, rememberAppCatalog, secureIconUrl, signInTarget } from './chunk-AJCYF7SS.js';
|
|
5
|
-
import { createContext, useContext, useMemo, useSyncExternalStore, useState, useId, useEffect, useCallback,
|
|
6
|
-
import {
|
|
5
|
+
import { createContext, forwardRef, Children, isValidElement, cloneElement, useContext, useMemo, useSyncExternalStore, useState, useId, useRef, useEffect, useCallback, createElement, useLayoutEffect, useImperativeHandle } from 'react';
|
|
6
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
7
7
|
import { Zap, Webhook, Wallet, Users, Timer, Tag, Sparkles, ShieldCheck, Shield, Settings, Server, Send, Search, Rocket, Receipt, Plug, Percent, Package, Network, MessageSquare, Mail, Lock, List, LifeBuoy, Layers, LayoutGrid, LayoutDashboard, Key, Inbox, Home, HardDrive, Globe, GitBranch, Folder, FileText, Database, CreditCard, Code, Cloud, Clock, Calendar, Building2, Briefcase, Boxes, BookOpen, Bell, BarChart3, Activity, ChevronDown, Plus, PinOff, Pin, PanelLeftOpen, PanelLeftClose, ChevronsUpDown, CircleHelp, ArrowLeftRight, CornerDownLeft, ArrowRight, MoreHorizontal, ChevronLeft, X, ArrowUpRight, ArrowUp, CircleAlert, UserRound, Ticket, ChevronRight, ArrowLeft, Circle, Monitor, Sun, Moon, LogOut, Check } from 'lucide-react';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
8
9
|
|
|
9
10
|
var CboxIdContext = createContext(null);
|
|
10
11
|
function CboxIdProvider({
|
|
@@ -3645,8 +3646,16 @@ function CboxShell({ shell, children, navigate = defaultNavigate, LinkComponent
|
|
|
3645
3646
|
const [moreView, setMoreView] = useMoreView();
|
|
3646
3647
|
if (!store.get().seeded) store.set({ open: shell.preferences.helpOpen, restored: shell.preferences.helpOpen, seeded: true });
|
|
3647
3648
|
const serverPreferences = JSON.stringify(shell.preferences);
|
|
3649
|
+
const lastServer = useRef(serverPreferences);
|
|
3648
3650
|
useEffect(() => {
|
|
3649
|
-
|
|
3651
|
+
if (lastServer.current === serverPreferences) return;
|
|
3652
|
+
const before = JSON.parse(lastServer.current);
|
|
3653
|
+
const after = JSON.parse(serverPreferences);
|
|
3654
|
+
lastServer.current = serverPreferences;
|
|
3655
|
+
const changed = Object.keys({ ...before, ...after }).filter((key) => JSON.stringify(before[key]) !== JSON.stringify(after[key]));
|
|
3656
|
+
if (changed.length === 0) return;
|
|
3657
|
+
setPreferences((current) => ({ ...current, ...Object.fromEntries(changed.map((key) => [key, after[key]])) }));
|
|
3658
|
+
if (changed.includes("theme")) applyTheme(after.theme);
|
|
3650
3659
|
}, [serverPreferences]);
|
|
3651
3660
|
const setPreference = useCallback(
|
|
3652
3661
|
(key, value) => {
|
|
@@ -5213,6 +5222,380 @@ function StatusPill({
|
|
|
5213
5222
|
}
|
|
5214
5223
|
);
|
|
5215
5224
|
}
|
|
5225
|
+
function Spinner({ className, label }) {
|
|
5226
|
+
return /* @__PURE__ */ jsx(
|
|
5227
|
+
"span",
|
|
5228
|
+
{
|
|
5229
|
+
className: cn("cbx-ui-spinner", className),
|
|
5230
|
+
role: label === void 0 ? void 0 : "status",
|
|
5231
|
+
"aria-hidden": label === void 0 ? true : void 0,
|
|
5232
|
+
"aria-label": label
|
|
5233
|
+
}
|
|
5234
|
+
);
|
|
5235
|
+
}
|
|
5236
|
+
function buttonClassName({ variant = "ghost", size = "md" } = {}) {
|
|
5237
|
+
return cn("cbx-ui-btn", `cbx-ui-btn--${variant}`, size !== "md" && `cbx-ui-btn--${size}`);
|
|
5238
|
+
}
|
|
5239
|
+
var Button = forwardRef(function Button2({ variant = "ghost", size = "md", icon, loading = false, asChild = false, disabled, className, children, type, ...props }, ref) {
|
|
5240
|
+
const classes = cn(buttonClassName({ variant, size }), className);
|
|
5241
|
+
const glyph = loading ? /* @__PURE__ */ jsx(Spinner, {}) : icon !== void 0 && icon !== null ? /* @__PURE__ */ jsx("span", { className: "cbx-ui-btn-glyph", "aria-hidden": "true", children: icon }) : null;
|
|
5242
|
+
const inactive = (disabled ?? false) || loading;
|
|
5243
|
+
if (asChild) {
|
|
5244
|
+
const child = Children.only(children);
|
|
5245
|
+
if (!isValidElement(child)) return null;
|
|
5246
|
+
const own = child.props;
|
|
5247
|
+
return cloneElement(child, {
|
|
5248
|
+
...props,
|
|
5249
|
+
ref,
|
|
5250
|
+
className: cn(classes, own.className),
|
|
5251
|
+
"aria-busy": loading || void 0,
|
|
5252
|
+
"aria-disabled": inactive || void 0,
|
|
5253
|
+
// A disabled link keeps its focus (so it can be reached and explained) but goes nowhere.
|
|
5254
|
+
onClick: (event) => {
|
|
5255
|
+
if (inactive) {
|
|
5256
|
+
event.preventDefault();
|
|
5257
|
+
return;
|
|
5258
|
+
}
|
|
5259
|
+
own.onClick?.(event);
|
|
5260
|
+
props.onClick?.(event);
|
|
5261
|
+
},
|
|
5262
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5263
|
+
glyph,
|
|
5264
|
+
own.children
|
|
5265
|
+
] })
|
|
5266
|
+
});
|
|
5267
|
+
}
|
|
5268
|
+
return /* @__PURE__ */ jsxs(
|
|
5269
|
+
"button",
|
|
5270
|
+
{
|
|
5271
|
+
ref,
|
|
5272
|
+
type: type ?? "button",
|
|
5273
|
+
className: classes,
|
|
5274
|
+
disabled: inactive,
|
|
5275
|
+
"aria-busy": loading || void 0,
|
|
5276
|
+
...props,
|
|
5277
|
+
children: [
|
|
5278
|
+
glyph,
|
|
5279
|
+
children
|
|
5280
|
+
]
|
|
5281
|
+
}
|
|
5282
|
+
);
|
|
5283
|
+
});
|
|
5284
|
+
function Checkbox({ checked, onCheckedChange, label, hint, disabled = false, required, name, value, id: statedId, className }) {
|
|
5285
|
+
const generated = useId();
|
|
5286
|
+
const id = statedId ?? generated;
|
|
5287
|
+
const hintId = `${id}-hint`;
|
|
5288
|
+
const input = useRef(null);
|
|
5289
|
+
const indeterminate = checked === "indeterminate";
|
|
5290
|
+
useEffect(() => {
|
|
5291
|
+
if (input.current !== null) input.current.indeterminate = indeterminate;
|
|
5292
|
+
}, [indeterminate]);
|
|
5293
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-check", disabled && "is-disabled", className), children: [
|
|
5294
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-check-box", children: [
|
|
5295
|
+
/* @__PURE__ */ jsx(
|
|
5296
|
+
"input",
|
|
5297
|
+
{
|
|
5298
|
+
ref: input,
|
|
5299
|
+
id,
|
|
5300
|
+
type: "checkbox",
|
|
5301
|
+
className: "cbx-ui-check-input",
|
|
5302
|
+
checked: checked === true,
|
|
5303
|
+
"aria-checked": indeterminate ? "mixed" : void 0,
|
|
5304
|
+
onChange: (event) => onCheckedChange(event.target.checked),
|
|
5305
|
+
disabled,
|
|
5306
|
+
required,
|
|
5307
|
+
name,
|
|
5308
|
+
value,
|
|
5309
|
+
"aria-describedby": hint !== void 0 ? hintId : void 0
|
|
5310
|
+
}
|
|
5311
|
+
),
|
|
5312
|
+
/* @__PURE__ */ jsx("svg", { className: "cbx-ui-check-mark cbx-ui-check-mark--check", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2.5 6.2 4.9 8.5 9.5 3.6", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
5313
|
+
/* @__PURE__ */ jsx("svg", { className: "cbx-ui-check-mark cbx-ui-check-mark--minus", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M3 6h6", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" }) })
|
|
5314
|
+
] }),
|
|
5315
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-check-text", children: [
|
|
5316
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "cbx-ui-check-label", children: label }),
|
|
5317
|
+
hint !== void 0 && /* @__PURE__ */ jsx("span", { id: hintId, className: "cbx-ui-check-hint", children: hint })
|
|
5318
|
+
] })
|
|
5319
|
+
] });
|
|
5320
|
+
}
|
|
5321
|
+
var TABBABLE = [
|
|
5322
|
+
"a[href]",
|
|
5323
|
+
"area[href]",
|
|
5324
|
+
"button:not([disabled])",
|
|
5325
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
5326
|
+
"select:not([disabled])",
|
|
5327
|
+
"textarea:not([disabled])",
|
|
5328
|
+
"iframe",
|
|
5329
|
+
"audio[controls]",
|
|
5330
|
+
"video[controls]",
|
|
5331
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
5332
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
5333
|
+
].join(",");
|
|
5334
|
+
function tabbables(root) {
|
|
5335
|
+
const all = Array.from(root.querySelectorAll(TABBABLE)).filter((element) => element.tabIndex >= 0 && element.closest("[hidden], [inert]") === null);
|
|
5336
|
+
const checkedGroups = new Set(all.filter((element) => element instanceof HTMLInputElement && element.type === "radio" && element.checked).map((element) => element.name));
|
|
5337
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5338
|
+
return all.filter((element) => {
|
|
5339
|
+
if (!(element instanceof HTMLInputElement) || element.type !== "radio" || element.name === "") return true;
|
|
5340
|
+
if (checkedGroups.has(element.name)) return element.checked;
|
|
5341
|
+
if (seen.has(element.name)) return false;
|
|
5342
|
+
seen.add(element.name);
|
|
5343
|
+
return true;
|
|
5344
|
+
});
|
|
5345
|
+
}
|
|
5346
|
+
var DialogContext = createContext(null);
|
|
5347
|
+
function useDialogClose() {
|
|
5348
|
+
const close = useContext(DialogContext);
|
|
5349
|
+
return close ?? (() => void 0);
|
|
5350
|
+
}
|
|
5351
|
+
function DialogClose({ onClick, ...props }) {
|
|
5352
|
+
const close = useDialogClose();
|
|
5353
|
+
return /* @__PURE__ */ jsx(
|
|
5354
|
+
Button,
|
|
5355
|
+
{
|
|
5356
|
+
...props,
|
|
5357
|
+
onClick: (event) => {
|
|
5358
|
+
onClick?.(event);
|
|
5359
|
+
if (!event.defaultPrevented) close();
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5362
|
+
);
|
|
5363
|
+
}
|
|
5364
|
+
var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
5365
|
+
function Dialog({ open, onOpenChange, title, description, footer, size = "md", dismissible = true, className, children }) {
|
|
5366
|
+
const { t } = useCboxLocalization();
|
|
5367
|
+
const id = useId();
|
|
5368
|
+
const titleId = `${id}-title`;
|
|
5369
|
+
const descriptionId = `${id}-description`;
|
|
5370
|
+
const layer = useRef(null);
|
|
5371
|
+
const panel = useRef(null);
|
|
5372
|
+
const closeButton = useRef(null);
|
|
5373
|
+
const body = useRef(null);
|
|
5374
|
+
const returnTo = useRef(null);
|
|
5375
|
+
const wasOpen = useRef(false);
|
|
5376
|
+
const pressedOnScrim = useRef(false);
|
|
5377
|
+
if (open && !wasOpen.current && typeof document !== "undefined") {
|
|
5378
|
+
const active = document.activeElement;
|
|
5379
|
+
returnTo.current = active instanceof HTMLElement && active !== document.body ? active : null;
|
|
5380
|
+
}
|
|
5381
|
+
wasOpen.current = open;
|
|
5382
|
+
const close = useCallback(() => onOpenChange(false), [onOpenChange]);
|
|
5383
|
+
useScrollLock(open);
|
|
5384
|
+
useIsoLayoutEffect2(() => {
|
|
5385
|
+
if (!open || layer.current === null) return;
|
|
5386
|
+
const own = layer.current;
|
|
5387
|
+
const made = [];
|
|
5388
|
+
for (const sibling of Array.from(document.body.children)) {
|
|
5389
|
+
if (sibling === own || !(sibling instanceof HTMLElement) || sibling.hasAttribute("inert")) continue;
|
|
5390
|
+
if (sibling.tagName === "SCRIPT" || sibling.tagName === "STYLE") continue;
|
|
5391
|
+
sibling.setAttribute("inert", "");
|
|
5392
|
+
made.push(sibling);
|
|
5393
|
+
}
|
|
5394
|
+
return () => {
|
|
5395
|
+
for (const element of made) element.removeAttribute("inert");
|
|
5396
|
+
};
|
|
5397
|
+
}, [open]);
|
|
5398
|
+
useIsoLayoutEffect2(() => {
|
|
5399
|
+
if (!open || panel.current === null) return;
|
|
5400
|
+
const root = panel.current;
|
|
5401
|
+
if (root.contains(document.activeElement)) return;
|
|
5402
|
+
const marked = root.querySelector("[data-autofocus]");
|
|
5403
|
+
const field = body.current?.querySelector('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), [role="combobox"]');
|
|
5404
|
+
(marked ?? field ?? closeButton.current ?? root).focus({ preventScroll: true });
|
|
5405
|
+
}, [open]);
|
|
5406
|
+
useEffect(() => {
|
|
5407
|
+
if (!open) return;
|
|
5408
|
+
const onFocusIn = (event) => {
|
|
5409
|
+
const root = panel.current;
|
|
5410
|
+
const target = event.target;
|
|
5411
|
+
if (root === null || !(target instanceof Node) || root.contains(target)) return;
|
|
5412
|
+
if (target instanceof Element && target.closest("[data-cbx-dialog-layer]") !== null) return;
|
|
5413
|
+
(tabbables(root)[0] ?? root).focus({ preventScroll: true });
|
|
5414
|
+
};
|
|
5415
|
+
document.addEventListener("focusin", onFocusIn);
|
|
5416
|
+
return () => document.removeEventListener("focusin", onFocusIn);
|
|
5417
|
+
}, [open]);
|
|
5418
|
+
useEffect(() => {
|
|
5419
|
+
if (!open) return;
|
|
5420
|
+
return () => {
|
|
5421
|
+
const target = returnTo.current;
|
|
5422
|
+
if (target !== null && target.isConnected) target.focus({ preventScroll: true });
|
|
5423
|
+
};
|
|
5424
|
+
}, [open]);
|
|
5425
|
+
const onKeyDown = (event) => {
|
|
5426
|
+
if (event.defaultPrevented) return;
|
|
5427
|
+
if (event.key === "Escape") {
|
|
5428
|
+
event.preventDefault();
|
|
5429
|
+
event.stopPropagation();
|
|
5430
|
+
close();
|
|
5431
|
+
return;
|
|
5432
|
+
}
|
|
5433
|
+
if (event.key !== "Tab" || panel.current === null) return;
|
|
5434
|
+
const items = tabbables(panel.current);
|
|
5435
|
+
const first = items[0];
|
|
5436
|
+
const last = items[items.length - 1];
|
|
5437
|
+
if (first === void 0 || last === void 0) {
|
|
5438
|
+
event.preventDefault();
|
|
5439
|
+
panel.current.focus({ preventScroll: true });
|
|
5440
|
+
return;
|
|
5441
|
+
}
|
|
5442
|
+
const active = document.activeElement;
|
|
5443
|
+
if (event.shiftKey && (active === first || active === panel.current)) {
|
|
5444
|
+
event.preventDefault();
|
|
5445
|
+
last.focus();
|
|
5446
|
+
} else if (!event.shiftKey && active === last) {
|
|
5447
|
+
event.preventDefault();
|
|
5448
|
+
first.focus();
|
|
5449
|
+
}
|
|
5450
|
+
};
|
|
5451
|
+
if (!open || typeof document === "undefined") return null;
|
|
5452
|
+
const onScrimDown = (event) => {
|
|
5453
|
+
pressedOnScrim.current = event.target === event.currentTarget;
|
|
5454
|
+
};
|
|
5455
|
+
const onScrimClick = (event) => {
|
|
5456
|
+
if (dismissible && pressedOnScrim.current && event.target === event.currentTarget) close();
|
|
5457
|
+
pressedOnScrim.current = false;
|
|
5458
|
+
};
|
|
5459
|
+
return createPortal(
|
|
5460
|
+
/* @__PURE__ */ jsx(DialogContext.Provider, { value: close, children: /* @__PURE__ */ jsxs("div", { ref: layer, "data-cbx-scroll-layer": "", "data-cbx-dialog-layer": "", children: [
|
|
5461
|
+
/* @__PURE__ */ jsx("div", { className: "cbx-ui-overlay", "aria-hidden": "true", onMouseDown: onScrimDown, onClick: onScrimClick }),
|
|
5462
|
+
/* @__PURE__ */ jsxs(
|
|
5463
|
+
"div",
|
|
5464
|
+
{
|
|
5465
|
+
ref: panel,
|
|
5466
|
+
role: "dialog",
|
|
5467
|
+
"aria-modal": "true",
|
|
5468
|
+
"aria-labelledby": titleId,
|
|
5469
|
+
"aria-describedby": description !== void 0 ? descriptionId : void 0,
|
|
5470
|
+
tabIndex: -1,
|
|
5471
|
+
className: cn("cbx-ui-dialog", `cbx-ui-dialog--${size}`, className),
|
|
5472
|
+
onKeyDown,
|
|
5473
|
+
children: [
|
|
5474
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-ui-dialog-head", children: [
|
|
5475
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-ui-dialog-heading", children: [
|
|
5476
|
+
/* @__PURE__ */ jsx("h2", { id: titleId, className: "cbx-ui-dialog-title", children: title }),
|
|
5477
|
+
description !== void 0 && /* @__PURE__ */ jsx("p", { id: descriptionId, className: "cbx-ui-dialog-desc", children: description })
|
|
5478
|
+
] }),
|
|
5479
|
+
/* @__PURE__ */ jsx("button", { ref: closeButton, type: "button", className: "cbx-ui-iconbtn", "aria-label": t("Close"), onClick: close, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) })
|
|
5480
|
+
] }),
|
|
5481
|
+
children !== void 0 && children !== null && /* @__PURE__ */ jsx("div", { ref: body, className: "cbx-ui-dialog-body", children }),
|
|
5482
|
+
footer !== void 0 && footer !== null && /* @__PURE__ */ jsx("div", { className: "cbx-ui-dialog-foot", children: footer })
|
|
5483
|
+
]
|
|
5484
|
+
}
|
|
5485
|
+
)
|
|
5486
|
+
] }) }),
|
|
5487
|
+
document.body
|
|
5488
|
+
);
|
|
5489
|
+
}
|
|
5490
|
+
var FieldContext = createContext(null);
|
|
5491
|
+
function useFieldControl() {
|
|
5492
|
+
const field = useContext(FieldContext);
|
|
5493
|
+
if (field === null) return {};
|
|
5494
|
+
return {
|
|
5495
|
+
id: field.controlId,
|
|
5496
|
+
...field.describedBy !== void 0 ? { "aria-describedby": field.describedBy } : {},
|
|
5497
|
+
...field.invalid ? { "aria-invalid": true } : {},
|
|
5498
|
+
...field.required ? { required: true } : {}
|
|
5499
|
+
};
|
|
5500
|
+
}
|
|
5501
|
+
function Field({ label, id: statedId, labelAction, hint, error, required = false, optional = false, className, children }) {
|
|
5502
|
+
const { t } = useCboxLocalization();
|
|
5503
|
+
const generated = useId();
|
|
5504
|
+
const base = statedId ?? generated;
|
|
5505
|
+
const controlId = statedId ?? `${generated}-control`;
|
|
5506
|
+
const hintId = `${base}-hint`;
|
|
5507
|
+
const errorId = `${base}-error`;
|
|
5508
|
+
const hasError = error !== void 0 && error !== null && error !== "";
|
|
5509
|
+
const describedBy = [hint !== void 0 ? hintId : null, hasError ? errorId : null].filter(Boolean).join(" ") || void 0;
|
|
5510
|
+
const context = useMemo(() => ({ controlId, describedBy, invalid: hasError, required }), [controlId, describedBy, hasError, required]);
|
|
5511
|
+
const labelElement = /* @__PURE__ */ jsxs("label", { className: "cbx-ui-label", htmlFor: controlId, children: [
|
|
5512
|
+
label,
|
|
5513
|
+
required && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5514
|
+
" ",
|
|
5515
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-required", "aria-hidden": "true", children: "*" }),
|
|
5516
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-sr-only", children: t("(required)") })
|
|
5517
|
+
] }),
|
|
5518
|
+
optional && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5519
|
+
" ",
|
|
5520
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-optional", children: t("(optional)") })
|
|
5521
|
+
] })
|
|
5522
|
+
] });
|
|
5523
|
+
return /* @__PURE__ */ jsx(FieldContext.Provider, { value: context, children: /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-field", className), children: [
|
|
5524
|
+
labelAction !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "cbx-ui-field-head", children: [
|
|
5525
|
+
labelElement,
|
|
5526
|
+
labelAction
|
|
5527
|
+
] }) : labelElement,
|
|
5528
|
+
children,
|
|
5529
|
+
hint !== void 0 && /* @__PURE__ */ jsx("p", { id: hintId, className: "cbx-ui-hint", children: hint }),
|
|
5530
|
+
/* @__PURE__ */ jsx("p", { id: errorId, className: "cbx-ui-error", role: "alert", hidden: !hasError, children: hasError ? error : null })
|
|
5531
|
+
] }) });
|
|
5532
|
+
}
|
|
5533
|
+
var Input = forwardRef(function Input2({ scale = "md", className, ...props }, ref) {
|
|
5534
|
+
const field = useFieldControl();
|
|
5535
|
+
return /* @__PURE__ */ jsx("input", { ref, className: cn("cbx-ui-input", scale === "lg" && "cbx-ui-input--lg", className), ...field, ...props });
|
|
5536
|
+
});
|
|
5537
|
+
var Textarea = forwardRef(function Textarea2({ className, rows: rows2 = 4, ...props }, ref) {
|
|
5538
|
+
const field = useFieldControl();
|
|
5539
|
+
return /* @__PURE__ */ jsx("textarea", { ref, rows: rows2, className: cn("cbx-ui-input", className), ...field, ...props });
|
|
5540
|
+
});
|
|
5541
|
+
function RadioGroup({ value, onValueChange, options, label, labelHidden = false, name, disabled = false, required, className }) {
|
|
5542
|
+
const id = useId();
|
|
5543
|
+
const labelId = `${id}-label`;
|
|
5544
|
+
const groupName = name ?? `${id}-radio`;
|
|
5545
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-radio-group", className), children: [
|
|
5546
|
+
/* @__PURE__ */ jsx("span", { id: labelId, className: labelHidden ? "cbx-ui-sr-only" : "cbx-ui-label", children: label }),
|
|
5547
|
+
/* @__PURE__ */ jsx("div", { className: "cbx-ui-radios", role: "radiogroup", "aria-labelledby": labelId, "aria-required": required || void 0, children: options.map((option, index) => {
|
|
5548
|
+
const optionId = `${id}-${index}`;
|
|
5549
|
+
const off = disabled || option.disabled === true;
|
|
5550
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-radio", off && "is-disabled"), children: [
|
|
5551
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-radio-box", children: [
|
|
5552
|
+
/* @__PURE__ */ jsx(
|
|
5553
|
+
"input",
|
|
5554
|
+
{
|
|
5555
|
+
id: optionId,
|
|
5556
|
+
type: "radio",
|
|
5557
|
+
className: "cbx-ui-radio-input",
|
|
5558
|
+
name: groupName,
|
|
5559
|
+
value: option.value,
|
|
5560
|
+
checked: value === option.value,
|
|
5561
|
+
disabled: off,
|
|
5562
|
+
required,
|
|
5563
|
+
onChange: () => onValueChange(option.value),
|
|
5564
|
+
"aria-describedby": option.hint !== void 0 ? `${optionId}-hint` : void 0
|
|
5565
|
+
}
|
|
5566
|
+
),
|
|
5567
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-radio-dot", "aria-hidden": "true" })
|
|
5568
|
+
] }),
|
|
5569
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-radio-text", children: [
|
|
5570
|
+
/* @__PURE__ */ jsx("label", { htmlFor: optionId, className: "cbx-ui-radio-label", children: option.label }),
|
|
5571
|
+
option.hint !== void 0 && /* @__PURE__ */ jsx("span", { id: `${optionId}-hint`, className: "cbx-ui-radio-hint", children: option.hint })
|
|
5572
|
+
] })
|
|
5573
|
+
] }, option.value);
|
|
5574
|
+
}) })
|
|
5575
|
+
] });
|
|
5576
|
+
}
|
|
5577
|
+
var Switch = forwardRef(function Switch2({ checked, onCheckedChange, disabled = false, name, className, ...props }, ref) {
|
|
5578
|
+
const field = useFieldControl();
|
|
5579
|
+
const { required: _required, ...wiring } = field;
|
|
5580
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5581
|
+
/* @__PURE__ */ jsx(
|
|
5582
|
+
"button",
|
|
5583
|
+
{
|
|
5584
|
+
ref,
|
|
5585
|
+
type: "button",
|
|
5586
|
+
role: "switch",
|
|
5587
|
+
"aria-checked": checked,
|
|
5588
|
+
disabled,
|
|
5589
|
+
className: cn("cbx-ui-switch", className),
|
|
5590
|
+
onClick: () => onCheckedChange(!checked),
|
|
5591
|
+
...wiring,
|
|
5592
|
+
...props,
|
|
5593
|
+
children: /* @__PURE__ */ jsx("span", { className: "cbx-ui-switch-thumb", "aria-hidden": "true" })
|
|
5594
|
+
}
|
|
5595
|
+
),
|
|
5596
|
+
name !== void 0 && checked && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: "on" })
|
|
5597
|
+
] });
|
|
5598
|
+
});
|
|
5216
5599
|
function SurfaceModal({
|
|
5217
5600
|
open,
|
|
5218
5601
|
onClose,
|
|
@@ -5704,6 +6087,6 @@ function Sparkline({ values, color = "var(--chart-1)", width = 90, height = 20 }
|
|
|
5704
6087
|
] });
|
|
5705
6088
|
}
|
|
5706
6089
|
|
|
5707
|
-
export { APP_HUES, AppContent, AppShell, CHART_PALETTE, CboxAppCatalog, CboxAppIcon, CboxBrand, CboxIdProvider, CboxLocalizationProvider, CboxServiceMark, CboxShell, CboxSurfaces, Combobox, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, EmptyState, Heading, KeyValue, KeyValueList, PageHeader, PageShell, PageTabs, PanelBody, RowLink, SHELL_ICONS, SectionHeader, Sparkline, StatTile, StatusPill, applyTheme, buildUrlSearch, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useKnownAppCatalog, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
|
|
6090
|
+
export { APP_HUES, AppContent, AppShell, Button, CHART_PALETTE, CboxAppCatalog, CboxAppIcon, CboxBrand, CboxIdProvider, CboxLocalizationProvider, CboxServiceMark, CboxShell, CboxSurfaces, Checkbox, Combobox, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, Dialog, DialogClose, EmptyState, Field, Heading, Input, KeyValue, KeyValueList, PageHeader, PageShell, PageTabs, PanelBody, RadioGroup, RowLink, SHELL_ICONS, SectionHeader, Sparkline, Spinner, StatTile, StatusPill, Switch, Textarea, applyTheme, buildUrlSearch, buttonClassName, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
|
|
5708
6091
|
//# sourceMappingURL=index.js.map
|
|
5709
6092
|
//# sourceMappingURL=index.js.map
|