@cboxdk/cbox-ui 0.11.1 → 0.12.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/README.md +30 -1
- package/dist/index.d.ts +229 -2
- package/dist/index.js +381 -5
- 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 -5
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, useRef, createElement, useLayoutEffect, useImperativeHandle } from 'react';
|
|
6
|
-
import {
|
|
5
|
+
import { createContext, forwardRef, Children, isValidElement, cloneElement, useContext, useMemo, useSyncExternalStore, useState, useId, useEffect, useCallback, useRef, 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({
|
|
@@ -1671,6 +1672,7 @@ function dragIntent({ zone, dx, dy, scrollTop, canGrow }) {
|
|
|
1671
1672
|
var EASE = "cubic-bezier(.2, .9, .25, 1)";
|
|
1672
1673
|
var DURATION = 280;
|
|
1673
1674
|
var NO_DRAG = "input, textarea, select, [contenteditable], [data-no-drag]";
|
|
1675
|
+
var GRAB_FIELD = '.cbx-sheet-grab :is(input[type="search"], input[type="text"], input:not([type]))';
|
|
1674
1676
|
function reducedMotion() {
|
|
1675
1677
|
return typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1676
1678
|
}
|
|
@@ -1731,7 +1733,7 @@ function useSheetDrag({ panel, scrim, size, onClose, enabled = true }) {
|
|
|
1731
1733
|
if (closing) return;
|
|
1732
1734
|
if (event.pointerType === "mouse" && event.button !== 0) return;
|
|
1733
1735
|
const target = event.target instanceof Element ? event.target : null;
|
|
1734
|
-
if (target === null || target.closest(NO_DRAG) !== null) return;
|
|
1736
|
+
if (target === null || target.closest(NO_DRAG) !== null && !target.matches(GRAB_FIELD)) return;
|
|
1735
1737
|
const zone = target.closest(".cbx-sheet-grab") !== null ? "grab" : "content";
|
|
1736
1738
|
gesture = { id: event.pointerId, x: event.clientX, y: event.clientY, zone, scroller: scrollerOf(target), mode: void 0, last: event.clientY, start: 0, detents: [], tracker: new VelocityTracker() };
|
|
1737
1739
|
gesture.tracker.add(event.timeStamp, event.clientY);
|
|
@@ -4300,7 +4302,7 @@ function Combobox(props) {
|
|
|
4300
4302
|
onChange: (e) => setQuery(e.target.value),
|
|
4301
4303
|
onKeyDown,
|
|
4302
4304
|
placeholder: searchPlaceholder,
|
|
4303
|
-
className: "h-8 w-full rounded-sm border-0 bg-transparent pl-7 pr-2 text-
|
|
4305
|
+
className: "h-8 w-full rounded-sm border-0 bg-transparent pl-7 pr-2 text-base outline-none placeholder:text-muted-foreground/70 md:text-[13px]",
|
|
4304
4306
|
"aria-controls": listId,
|
|
4305
4307
|
"aria-autocomplete": "list",
|
|
4306
4308
|
"aria-activedescendant": highlightIndex >= 0 ? `${listId}-${highlightIndex}` : void 0
|
|
@@ -5212,6 +5214,380 @@ function StatusPill({
|
|
|
5212
5214
|
}
|
|
5213
5215
|
);
|
|
5214
5216
|
}
|
|
5217
|
+
function Spinner({ className, label }) {
|
|
5218
|
+
return /* @__PURE__ */ jsx(
|
|
5219
|
+
"span",
|
|
5220
|
+
{
|
|
5221
|
+
className: cn("cbx-ui-spinner", className),
|
|
5222
|
+
role: label === void 0 ? void 0 : "status",
|
|
5223
|
+
"aria-hidden": label === void 0 ? true : void 0,
|
|
5224
|
+
"aria-label": label
|
|
5225
|
+
}
|
|
5226
|
+
);
|
|
5227
|
+
}
|
|
5228
|
+
function buttonClassName({ variant = "ghost", size = "md" } = {}) {
|
|
5229
|
+
return cn("cbx-ui-btn", `cbx-ui-btn--${variant}`, size !== "md" && `cbx-ui-btn--${size}`);
|
|
5230
|
+
}
|
|
5231
|
+
var Button = forwardRef(function Button2({ variant = "ghost", size = "md", icon, loading = false, asChild = false, disabled, className, children, type, ...props }, ref) {
|
|
5232
|
+
const classes = cn(buttonClassName({ variant, size }), className);
|
|
5233
|
+
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;
|
|
5234
|
+
const inactive = (disabled ?? false) || loading;
|
|
5235
|
+
if (asChild) {
|
|
5236
|
+
const child = Children.only(children);
|
|
5237
|
+
if (!isValidElement(child)) return null;
|
|
5238
|
+
const own = child.props;
|
|
5239
|
+
return cloneElement(child, {
|
|
5240
|
+
...props,
|
|
5241
|
+
ref,
|
|
5242
|
+
className: cn(classes, own.className),
|
|
5243
|
+
"aria-busy": loading || void 0,
|
|
5244
|
+
"aria-disabled": inactive || void 0,
|
|
5245
|
+
// A disabled link keeps its focus (so it can be reached and explained) but goes nowhere.
|
|
5246
|
+
onClick: (event) => {
|
|
5247
|
+
if (inactive) {
|
|
5248
|
+
event.preventDefault();
|
|
5249
|
+
return;
|
|
5250
|
+
}
|
|
5251
|
+
own.onClick?.(event);
|
|
5252
|
+
props.onClick?.(event);
|
|
5253
|
+
},
|
|
5254
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5255
|
+
glyph,
|
|
5256
|
+
own.children
|
|
5257
|
+
] })
|
|
5258
|
+
});
|
|
5259
|
+
}
|
|
5260
|
+
return /* @__PURE__ */ jsxs(
|
|
5261
|
+
"button",
|
|
5262
|
+
{
|
|
5263
|
+
ref,
|
|
5264
|
+
type: type ?? "button",
|
|
5265
|
+
className: classes,
|
|
5266
|
+
disabled: inactive,
|
|
5267
|
+
"aria-busy": loading || void 0,
|
|
5268
|
+
...props,
|
|
5269
|
+
children: [
|
|
5270
|
+
glyph,
|
|
5271
|
+
children
|
|
5272
|
+
]
|
|
5273
|
+
}
|
|
5274
|
+
);
|
|
5275
|
+
});
|
|
5276
|
+
function Checkbox({ checked, onCheckedChange, label, hint, disabled = false, required, name, value, id: statedId, className }) {
|
|
5277
|
+
const generated = useId();
|
|
5278
|
+
const id = statedId ?? generated;
|
|
5279
|
+
const hintId = `${id}-hint`;
|
|
5280
|
+
const input = useRef(null);
|
|
5281
|
+
const indeterminate = checked === "indeterminate";
|
|
5282
|
+
useEffect(() => {
|
|
5283
|
+
if (input.current !== null) input.current.indeterminate = indeterminate;
|
|
5284
|
+
}, [indeterminate]);
|
|
5285
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-check", disabled && "is-disabled", className), children: [
|
|
5286
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-check-box", children: [
|
|
5287
|
+
/* @__PURE__ */ jsx(
|
|
5288
|
+
"input",
|
|
5289
|
+
{
|
|
5290
|
+
ref: input,
|
|
5291
|
+
id,
|
|
5292
|
+
type: "checkbox",
|
|
5293
|
+
className: "cbx-ui-check-input",
|
|
5294
|
+
checked: checked === true,
|
|
5295
|
+
"aria-checked": indeterminate ? "mixed" : void 0,
|
|
5296
|
+
onChange: (event) => onCheckedChange(event.target.checked),
|
|
5297
|
+
disabled,
|
|
5298
|
+
required,
|
|
5299
|
+
name,
|
|
5300
|
+
value,
|
|
5301
|
+
"aria-describedby": hint !== void 0 ? hintId : void 0
|
|
5302
|
+
}
|
|
5303
|
+
),
|
|
5304
|
+
/* @__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" }) }),
|
|
5305
|
+
/* @__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" }) })
|
|
5306
|
+
] }),
|
|
5307
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-check-text", children: [
|
|
5308
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "cbx-ui-check-label", children: label }),
|
|
5309
|
+
hint !== void 0 && /* @__PURE__ */ jsx("span", { id: hintId, className: "cbx-ui-check-hint", children: hint })
|
|
5310
|
+
] })
|
|
5311
|
+
] });
|
|
5312
|
+
}
|
|
5313
|
+
var TABBABLE = [
|
|
5314
|
+
"a[href]",
|
|
5315
|
+
"area[href]",
|
|
5316
|
+
"button:not([disabled])",
|
|
5317
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
5318
|
+
"select:not([disabled])",
|
|
5319
|
+
"textarea:not([disabled])",
|
|
5320
|
+
"iframe",
|
|
5321
|
+
"audio[controls]",
|
|
5322
|
+
"video[controls]",
|
|
5323
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
5324
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
5325
|
+
].join(",");
|
|
5326
|
+
function tabbables(root) {
|
|
5327
|
+
const all = Array.from(root.querySelectorAll(TABBABLE)).filter((element) => element.tabIndex >= 0 && element.closest("[hidden], [inert]") === null);
|
|
5328
|
+
const checkedGroups = new Set(all.filter((element) => element instanceof HTMLInputElement && element.type === "radio" && element.checked).map((element) => element.name));
|
|
5329
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5330
|
+
return all.filter((element) => {
|
|
5331
|
+
if (!(element instanceof HTMLInputElement) || element.type !== "radio" || element.name === "") return true;
|
|
5332
|
+
if (checkedGroups.has(element.name)) return element.checked;
|
|
5333
|
+
if (seen.has(element.name)) return false;
|
|
5334
|
+
seen.add(element.name);
|
|
5335
|
+
return true;
|
|
5336
|
+
});
|
|
5337
|
+
}
|
|
5338
|
+
var DialogContext = createContext(null);
|
|
5339
|
+
function useDialogClose() {
|
|
5340
|
+
const close = useContext(DialogContext);
|
|
5341
|
+
return close ?? (() => void 0);
|
|
5342
|
+
}
|
|
5343
|
+
function DialogClose({ onClick, ...props }) {
|
|
5344
|
+
const close = useDialogClose();
|
|
5345
|
+
return /* @__PURE__ */ jsx(
|
|
5346
|
+
Button,
|
|
5347
|
+
{
|
|
5348
|
+
...props,
|
|
5349
|
+
onClick: (event) => {
|
|
5350
|
+
onClick?.(event);
|
|
5351
|
+
if (!event.defaultPrevented) close();
|
|
5352
|
+
}
|
|
5353
|
+
}
|
|
5354
|
+
);
|
|
5355
|
+
}
|
|
5356
|
+
var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
5357
|
+
function Dialog({ open, onOpenChange, title, description, footer, size = "md", dismissible = true, className, children }) {
|
|
5358
|
+
const { t } = useCboxLocalization();
|
|
5359
|
+
const id = useId();
|
|
5360
|
+
const titleId = `${id}-title`;
|
|
5361
|
+
const descriptionId = `${id}-description`;
|
|
5362
|
+
const layer = useRef(null);
|
|
5363
|
+
const panel = useRef(null);
|
|
5364
|
+
const closeButton = useRef(null);
|
|
5365
|
+
const body = useRef(null);
|
|
5366
|
+
const returnTo = useRef(null);
|
|
5367
|
+
const wasOpen = useRef(false);
|
|
5368
|
+
const pressedOnScrim = useRef(false);
|
|
5369
|
+
if (open && !wasOpen.current && typeof document !== "undefined") {
|
|
5370
|
+
const active = document.activeElement;
|
|
5371
|
+
returnTo.current = active instanceof HTMLElement && active !== document.body ? active : null;
|
|
5372
|
+
}
|
|
5373
|
+
wasOpen.current = open;
|
|
5374
|
+
const close = useCallback(() => onOpenChange(false), [onOpenChange]);
|
|
5375
|
+
useScrollLock(open);
|
|
5376
|
+
useIsoLayoutEffect2(() => {
|
|
5377
|
+
if (!open || layer.current === null) return;
|
|
5378
|
+
const own = layer.current;
|
|
5379
|
+
const made = [];
|
|
5380
|
+
for (const sibling of Array.from(document.body.children)) {
|
|
5381
|
+
if (sibling === own || !(sibling instanceof HTMLElement) || sibling.hasAttribute("inert")) continue;
|
|
5382
|
+
if (sibling.tagName === "SCRIPT" || sibling.tagName === "STYLE") continue;
|
|
5383
|
+
sibling.setAttribute("inert", "");
|
|
5384
|
+
made.push(sibling);
|
|
5385
|
+
}
|
|
5386
|
+
return () => {
|
|
5387
|
+
for (const element of made) element.removeAttribute("inert");
|
|
5388
|
+
};
|
|
5389
|
+
}, [open]);
|
|
5390
|
+
useIsoLayoutEffect2(() => {
|
|
5391
|
+
if (!open || panel.current === null) return;
|
|
5392
|
+
const root = panel.current;
|
|
5393
|
+
if (root.contains(document.activeElement)) return;
|
|
5394
|
+
const marked = root.querySelector("[data-autofocus]");
|
|
5395
|
+
const field = body.current?.querySelector('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), [role="combobox"]');
|
|
5396
|
+
(marked ?? field ?? closeButton.current ?? root).focus({ preventScroll: true });
|
|
5397
|
+
}, [open]);
|
|
5398
|
+
useEffect(() => {
|
|
5399
|
+
if (!open) return;
|
|
5400
|
+
const onFocusIn = (event) => {
|
|
5401
|
+
const root = panel.current;
|
|
5402
|
+
const target = event.target;
|
|
5403
|
+
if (root === null || !(target instanceof Node) || root.contains(target)) return;
|
|
5404
|
+
if (target instanceof Element && target.closest("[data-cbx-dialog-layer]") !== null) return;
|
|
5405
|
+
(tabbables(root)[0] ?? root).focus({ preventScroll: true });
|
|
5406
|
+
};
|
|
5407
|
+
document.addEventListener("focusin", onFocusIn);
|
|
5408
|
+
return () => document.removeEventListener("focusin", onFocusIn);
|
|
5409
|
+
}, [open]);
|
|
5410
|
+
useEffect(() => {
|
|
5411
|
+
if (!open) return;
|
|
5412
|
+
return () => {
|
|
5413
|
+
const target = returnTo.current;
|
|
5414
|
+
if (target !== null && target.isConnected) target.focus({ preventScroll: true });
|
|
5415
|
+
};
|
|
5416
|
+
}, [open]);
|
|
5417
|
+
const onKeyDown = (event) => {
|
|
5418
|
+
if (event.defaultPrevented) return;
|
|
5419
|
+
if (event.key === "Escape") {
|
|
5420
|
+
event.preventDefault();
|
|
5421
|
+
event.stopPropagation();
|
|
5422
|
+
close();
|
|
5423
|
+
return;
|
|
5424
|
+
}
|
|
5425
|
+
if (event.key !== "Tab" || panel.current === null) return;
|
|
5426
|
+
const items = tabbables(panel.current);
|
|
5427
|
+
const first = items[0];
|
|
5428
|
+
const last = items[items.length - 1];
|
|
5429
|
+
if (first === void 0 || last === void 0) {
|
|
5430
|
+
event.preventDefault();
|
|
5431
|
+
panel.current.focus({ preventScroll: true });
|
|
5432
|
+
return;
|
|
5433
|
+
}
|
|
5434
|
+
const active = document.activeElement;
|
|
5435
|
+
if (event.shiftKey && (active === first || active === panel.current)) {
|
|
5436
|
+
event.preventDefault();
|
|
5437
|
+
last.focus();
|
|
5438
|
+
} else if (!event.shiftKey && active === last) {
|
|
5439
|
+
event.preventDefault();
|
|
5440
|
+
first.focus();
|
|
5441
|
+
}
|
|
5442
|
+
};
|
|
5443
|
+
if (!open || typeof document === "undefined") return null;
|
|
5444
|
+
const onScrimDown = (event) => {
|
|
5445
|
+
pressedOnScrim.current = event.target === event.currentTarget;
|
|
5446
|
+
};
|
|
5447
|
+
const onScrimClick = (event) => {
|
|
5448
|
+
if (dismissible && pressedOnScrim.current && event.target === event.currentTarget) close();
|
|
5449
|
+
pressedOnScrim.current = false;
|
|
5450
|
+
};
|
|
5451
|
+
return createPortal(
|
|
5452
|
+
/* @__PURE__ */ jsx(DialogContext.Provider, { value: close, children: /* @__PURE__ */ jsxs("div", { ref: layer, "data-cbx-scroll-layer": "", "data-cbx-dialog-layer": "", children: [
|
|
5453
|
+
/* @__PURE__ */ jsx("div", { className: "cbx-ui-overlay", "aria-hidden": "true", onMouseDown: onScrimDown, onClick: onScrimClick }),
|
|
5454
|
+
/* @__PURE__ */ jsxs(
|
|
5455
|
+
"div",
|
|
5456
|
+
{
|
|
5457
|
+
ref: panel,
|
|
5458
|
+
role: "dialog",
|
|
5459
|
+
"aria-modal": "true",
|
|
5460
|
+
"aria-labelledby": titleId,
|
|
5461
|
+
"aria-describedby": description !== void 0 ? descriptionId : void 0,
|
|
5462
|
+
tabIndex: -1,
|
|
5463
|
+
className: cn("cbx-ui-dialog", `cbx-ui-dialog--${size}`, className),
|
|
5464
|
+
onKeyDown,
|
|
5465
|
+
children: [
|
|
5466
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-ui-dialog-head", children: [
|
|
5467
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-ui-dialog-heading", children: [
|
|
5468
|
+
/* @__PURE__ */ jsx("h2", { id: titleId, className: "cbx-ui-dialog-title", children: title }),
|
|
5469
|
+
description !== void 0 && /* @__PURE__ */ jsx("p", { id: descriptionId, className: "cbx-ui-dialog-desc", children: description })
|
|
5470
|
+
] }),
|
|
5471
|
+
/* @__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" }) }) })
|
|
5472
|
+
] }),
|
|
5473
|
+
children !== void 0 && children !== null && /* @__PURE__ */ jsx("div", { ref: body, className: "cbx-ui-dialog-body", children }),
|
|
5474
|
+
footer !== void 0 && footer !== null && /* @__PURE__ */ jsx("div", { className: "cbx-ui-dialog-foot", children: footer })
|
|
5475
|
+
]
|
|
5476
|
+
}
|
|
5477
|
+
)
|
|
5478
|
+
] }) }),
|
|
5479
|
+
document.body
|
|
5480
|
+
);
|
|
5481
|
+
}
|
|
5482
|
+
var FieldContext = createContext(null);
|
|
5483
|
+
function useFieldControl() {
|
|
5484
|
+
const field = useContext(FieldContext);
|
|
5485
|
+
if (field === null) return {};
|
|
5486
|
+
return {
|
|
5487
|
+
id: field.controlId,
|
|
5488
|
+
...field.describedBy !== void 0 ? { "aria-describedby": field.describedBy } : {},
|
|
5489
|
+
...field.invalid ? { "aria-invalid": true } : {},
|
|
5490
|
+
...field.required ? { required: true } : {}
|
|
5491
|
+
};
|
|
5492
|
+
}
|
|
5493
|
+
function Field({ label, id: statedId, labelAction, hint, error, required = false, optional = false, className, children }) {
|
|
5494
|
+
const { t } = useCboxLocalization();
|
|
5495
|
+
const generated = useId();
|
|
5496
|
+
const base = statedId ?? generated;
|
|
5497
|
+
const controlId = statedId ?? `${generated}-control`;
|
|
5498
|
+
const hintId = `${base}-hint`;
|
|
5499
|
+
const errorId = `${base}-error`;
|
|
5500
|
+
const hasError = error !== void 0 && error !== null && error !== "";
|
|
5501
|
+
const describedBy = [hint !== void 0 ? hintId : null, hasError ? errorId : null].filter(Boolean).join(" ") || void 0;
|
|
5502
|
+
const context = useMemo(() => ({ controlId, describedBy, invalid: hasError, required }), [controlId, describedBy, hasError, required]);
|
|
5503
|
+
const labelElement = /* @__PURE__ */ jsxs("label", { className: "cbx-ui-label", htmlFor: controlId, children: [
|
|
5504
|
+
label,
|
|
5505
|
+
required && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5506
|
+
" ",
|
|
5507
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-required", "aria-hidden": "true", children: "*" }),
|
|
5508
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-sr-only", children: t("(required)") })
|
|
5509
|
+
] }),
|
|
5510
|
+
optional && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5511
|
+
" ",
|
|
5512
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-optional", children: t("(optional)") })
|
|
5513
|
+
] })
|
|
5514
|
+
] });
|
|
5515
|
+
return /* @__PURE__ */ jsx(FieldContext.Provider, { value: context, children: /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-field", className), children: [
|
|
5516
|
+
labelAction !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "cbx-ui-field-head", children: [
|
|
5517
|
+
labelElement,
|
|
5518
|
+
labelAction
|
|
5519
|
+
] }) : labelElement,
|
|
5520
|
+
children,
|
|
5521
|
+
hint !== void 0 && /* @__PURE__ */ jsx("p", { id: hintId, className: "cbx-ui-hint", children: hint }),
|
|
5522
|
+
/* @__PURE__ */ jsx("p", { id: errorId, className: "cbx-ui-error", role: "alert", hidden: !hasError, children: hasError ? error : null })
|
|
5523
|
+
] }) });
|
|
5524
|
+
}
|
|
5525
|
+
var Input = forwardRef(function Input2({ scale = "md", className, ...props }, ref) {
|
|
5526
|
+
const field = useFieldControl();
|
|
5527
|
+
return /* @__PURE__ */ jsx("input", { ref, className: cn("cbx-ui-input", scale === "lg" && "cbx-ui-input--lg", className), ...field, ...props });
|
|
5528
|
+
});
|
|
5529
|
+
var Textarea = forwardRef(function Textarea2({ className, rows: rows2 = 4, ...props }, ref) {
|
|
5530
|
+
const field = useFieldControl();
|
|
5531
|
+
return /* @__PURE__ */ jsx("textarea", { ref, rows: rows2, className: cn("cbx-ui-input", className), ...field, ...props });
|
|
5532
|
+
});
|
|
5533
|
+
function RadioGroup({ value, onValueChange, options, label, labelHidden = false, name, disabled = false, required, className }) {
|
|
5534
|
+
const id = useId();
|
|
5535
|
+
const labelId = `${id}-label`;
|
|
5536
|
+
const groupName = name ?? `${id}-radio`;
|
|
5537
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-radio-group", className), children: [
|
|
5538
|
+
/* @__PURE__ */ jsx("span", { id: labelId, className: labelHidden ? "cbx-ui-sr-only" : "cbx-ui-label", children: label }),
|
|
5539
|
+
/* @__PURE__ */ jsx("div", { className: "cbx-ui-radios", role: "radiogroup", "aria-labelledby": labelId, "aria-required": required || void 0, children: options.map((option, index) => {
|
|
5540
|
+
const optionId = `${id}-${index}`;
|
|
5541
|
+
const off = disabled || option.disabled === true;
|
|
5542
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-radio", off && "is-disabled"), children: [
|
|
5543
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-radio-box", children: [
|
|
5544
|
+
/* @__PURE__ */ jsx(
|
|
5545
|
+
"input",
|
|
5546
|
+
{
|
|
5547
|
+
id: optionId,
|
|
5548
|
+
type: "radio",
|
|
5549
|
+
className: "cbx-ui-radio-input",
|
|
5550
|
+
name: groupName,
|
|
5551
|
+
value: option.value,
|
|
5552
|
+
checked: value === option.value,
|
|
5553
|
+
disabled: off,
|
|
5554
|
+
required,
|
|
5555
|
+
onChange: () => onValueChange(option.value),
|
|
5556
|
+
"aria-describedby": option.hint !== void 0 ? `${optionId}-hint` : void 0
|
|
5557
|
+
}
|
|
5558
|
+
),
|
|
5559
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-radio-dot", "aria-hidden": "true" })
|
|
5560
|
+
] }),
|
|
5561
|
+
/* @__PURE__ */ jsxs("span", { className: "cbx-ui-radio-text", children: [
|
|
5562
|
+
/* @__PURE__ */ jsx("label", { htmlFor: optionId, className: "cbx-ui-radio-label", children: option.label }),
|
|
5563
|
+
option.hint !== void 0 && /* @__PURE__ */ jsx("span", { id: `${optionId}-hint`, className: "cbx-ui-radio-hint", children: option.hint })
|
|
5564
|
+
] })
|
|
5565
|
+
] }, option.value);
|
|
5566
|
+
}) })
|
|
5567
|
+
] });
|
|
5568
|
+
}
|
|
5569
|
+
var Switch = forwardRef(function Switch2({ checked, onCheckedChange, disabled = false, name, className, ...props }, ref) {
|
|
5570
|
+
const field = useFieldControl();
|
|
5571
|
+
const { required: _required, ...wiring } = field;
|
|
5572
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5573
|
+
/* @__PURE__ */ jsx(
|
|
5574
|
+
"button",
|
|
5575
|
+
{
|
|
5576
|
+
ref,
|
|
5577
|
+
type: "button",
|
|
5578
|
+
role: "switch",
|
|
5579
|
+
"aria-checked": checked,
|
|
5580
|
+
disabled,
|
|
5581
|
+
className: cn("cbx-ui-switch", className),
|
|
5582
|
+
onClick: () => onCheckedChange(!checked),
|
|
5583
|
+
...wiring,
|
|
5584
|
+
...props,
|
|
5585
|
+
children: /* @__PURE__ */ jsx("span", { className: "cbx-ui-switch-thumb", "aria-hidden": "true" })
|
|
5586
|
+
}
|
|
5587
|
+
),
|
|
5588
|
+
name !== void 0 && checked && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: "on" })
|
|
5589
|
+
] });
|
|
5590
|
+
});
|
|
5215
5591
|
function SurfaceModal({
|
|
5216
5592
|
open,
|
|
5217
5593
|
onClose,
|
|
@@ -5703,6 +6079,6 @@ function Sparkline({ values, color = "var(--chart-1)", width = 90, height = 20 }
|
|
|
5703
6079
|
] });
|
|
5704
6080
|
}
|
|
5705
6081
|
|
|
5706
|
-
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 };
|
|
6082
|
+
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 };
|
|
5707
6083
|
//# sourceMappingURL=index.js.map
|
|
5708
6084
|
//# sourceMappingURL=index.js.map
|