@cboxdk/cbox-ui 0.12.1 → 0.14.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 +3 -3
- package/dist/index.d.ts +30 -21
- package/dist/index.js +757 -702
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/tokens/cbox.css +1 -0
- package/tokens/controls.css +42 -25
- package/tokens/page-tabs.css +26 -0
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ 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, forwardRef, Children, isValidElement, cloneElement, useContext, useMemo, useSyncExternalStore, useState, useId, useRef,
|
|
5
|
+
import { createContext, forwardRef, Children, isValidElement, cloneElement, useContext, useMemo, useSyncExternalStore, useState, useId, useRef, useCallback, useEffect, createElement, useLayoutEffect, useImperativeHandle } from 'react';
|
|
6
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
8
|
import { createPortal } from 'react-dom';
|
|
@@ -85,14 +85,8 @@ function useShellHelp() {
|
|
|
85
85
|
const api = useContext(ShellContext);
|
|
86
86
|
return api === null ? null : { toggleHelp: api.toggleHelp, openArticle: api.openArticle, ask: api.ask };
|
|
87
87
|
}
|
|
88
|
-
function sameTitle(a, b) {
|
|
89
|
-
const norm = (text) => text.replace(/\s+/g, " ").trim().replace(/:$/, "").toLocaleLowerCase();
|
|
90
|
-
return norm(a) !== "" && norm(a) === norm(b);
|
|
91
|
-
}
|
|
92
88
|
function useShellPageTitle() {
|
|
93
|
-
|
|
94
|
-
if (api === null || !api.mobile) return null;
|
|
95
|
-
return api.shell.nav.areas.find((area) => area.key === api.shell.nav.activeArea)?.label ?? null;
|
|
89
|
+
return null;
|
|
96
90
|
}
|
|
97
91
|
var DESKTOP_POINTER = "(hover: hover) and (pointer: fine)";
|
|
98
92
|
var HELP_DOCKED = "(min-width: 1280px)";
|
|
@@ -1384,134 +1378,6 @@ function CascadeLabel({ levels }) {
|
|
|
1384
1378
|
] })
|
|
1385
1379
|
] });
|
|
1386
1380
|
}
|
|
1387
|
-
var SHELL_ICONS = {
|
|
1388
|
-
activity: Activity,
|
|
1389
|
-
"bar-chart": BarChart3,
|
|
1390
|
-
bell: Bell,
|
|
1391
|
-
"book-open": BookOpen,
|
|
1392
|
-
boxes: Boxes,
|
|
1393
|
-
briefcase: Briefcase,
|
|
1394
|
-
building: Building2,
|
|
1395
|
-
calendar: Calendar,
|
|
1396
|
-
clock: Clock,
|
|
1397
|
-
cloud: Cloud,
|
|
1398
|
-
code: Code,
|
|
1399
|
-
"credit-card": CreditCard,
|
|
1400
|
-
database: Database,
|
|
1401
|
-
"file-text": FileText,
|
|
1402
|
-
folder: Folder,
|
|
1403
|
-
"git-branch": GitBranch,
|
|
1404
|
-
globe: Globe,
|
|
1405
|
-
"hard-drive": HardDrive,
|
|
1406
|
-
home: Home,
|
|
1407
|
-
inbox: Inbox,
|
|
1408
|
-
key: Key,
|
|
1409
|
-
"layout-dashboard": LayoutDashboard,
|
|
1410
|
-
"layout-grid": LayoutGrid,
|
|
1411
|
-
layers: Layers,
|
|
1412
|
-
"life-buoy": LifeBuoy,
|
|
1413
|
-
list: List,
|
|
1414
|
-
lock: Lock,
|
|
1415
|
-
mail: Mail,
|
|
1416
|
-
"message-square": MessageSquare,
|
|
1417
|
-
network: Network,
|
|
1418
|
-
package: Package,
|
|
1419
|
-
percent: Percent,
|
|
1420
|
-
plug: Plug,
|
|
1421
|
-
receipt: Receipt,
|
|
1422
|
-
rocket: Rocket,
|
|
1423
|
-
search: Search,
|
|
1424
|
-
send: Send,
|
|
1425
|
-
server: Server,
|
|
1426
|
-
settings: Settings,
|
|
1427
|
-
shield: Shield,
|
|
1428
|
-
"shield-check": ShieldCheck,
|
|
1429
|
-
sparkles: Sparkles,
|
|
1430
|
-
tag: Tag,
|
|
1431
|
-
timer: Timer,
|
|
1432
|
-
users: Users,
|
|
1433
|
-
wallet: Wallet,
|
|
1434
|
-
webhook: Webhook,
|
|
1435
|
-
zap: Zap
|
|
1436
|
-
};
|
|
1437
|
-
function resolveIcon(name, extra = {}) {
|
|
1438
|
-
if (name === void 0) return Circle;
|
|
1439
|
-
return extra[name] ?? SHELL_ICONS[name] ?? Circle;
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
// src/shell/help-store.ts
|
|
1443
|
-
var INITIAL_HELP_STATE = {
|
|
1444
|
-
open: false,
|
|
1445
|
-
article: null,
|
|
1446
|
-
query: "",
|
|
1447
|
-
scrollTop: 0,
|
|
1448
|
-
updates: [],
|
|
1449
|
-
updatesStatus: "idle",
|
|
1450
|
-
pendingQuestion: null,
|
|
1451
|
-
seeded: false,
|
|
1452
|
-
restored: false,
|
|
1453
|
-
updatesKey: null
|
|
1454
|
-
};
|
|
1455
|
-
function helpVisible(state, docked) {
|
|
1456
|
-
return state.open && (docked || !state.restored);
|
|
1457
|
-
}
|
|
1458
|
-
function createHelpStore(initial = {}) {
|
|
1459
|
-
let state = { ...INITIAL_HELP_STATE, ...initial };
|
|
1460
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1461
|
-
return {
|
|
1462
|
-
get: () => state,
|
|
1463
|
-
set(patch) {
|
|
1464
|
-
const next = typeof patch === "function" ? patch(state) : patch;
|
|
1465
|
-
state = { ...state, ...next };
|
|
1466
|
-
listeners.forEach((listener) => listener());
|
|
1467
|
-
},
|
|
1468
|
-
subscribe(listener) {
|
|
1469
|
-
listeners.add(listener);
|
|
1470
|
-
return () => listeners.delete(listener);
|
|
1471
|
-
}
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
var browserStore = null;
|
|
1475
|
-
function sharedHelpStore() {
|
|
1476
|
-
if (typeof window === "undefined") return createHelpStore();
|
|
1477
|
-
browserStore ??= createHelpStore();
|
|
1478
|
-
return browserStore;
|
|
1479
|
-
}
|
|
1480
|
-
function parseUpdates(body) {
|
|
1481
|
-
const rows2 = Array.isArray(body) ? body : typeof body === "object" && body !== null && Array.isArray(body.data) ? body.data : [];
|
|
1482
|
-
return rows2.flatMap((value) => {
|
|
1483
|
-
if (typeof value !== "object" || value === null) return [];
|
|
1484
|
-
const row = value;
|
|
1485
|
-
if (typeof row.id !== "string" && typeof row.id !== "number" || typeof row.title !== "string") return [];
|
|
1486
|
-
const update = {
|
|
1487
|
-
id: String(row.id),
|
|
1488
|
-
kind: row.kind === "chat" ? "chat" : "ticket",
|
|
1489
|
-
title: row.title,
|
|
1490
|
-
unread: row.unread === true || row.read === false || row.read_at === null && row.unread !== false
|
|
1491
|
-
};
|
|
1492
|
-
if (typeof row.excerpt === "string") update.excerpt = row.excerpt;
|
|
1493
|
-
const at = row.at ?? row.updated_at ?? row.created_at;
|
|
1494
|
-
if (typeof at === "string") update.at = at;
|
|
1495
|
-
const url = safeUrl(row.url);
|
|
1496
|
-
if (url !== void 0) update.url = url;
|
|
1497
|
-
return [update];
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
function parseArticles(body) {
|
|
1501
|
-
const rows2 = Array.isArray(body) ? body : typeof body === "object" && body !== null && Array.isArray(body.data) ? body.data : [];
|
|
1502
|
-
return rows2.flatMap((value) => {
|
|
1503
|
-
if (typeof value !== "object" || value === null) return [];
|
|
1504
|
-
const row = value;
|
|
1505
|
-
if (typeof row.id !== "string" && typeof row.id !== "number" || typeof row.title !== "string") return [];
|
|
1506
|
-
const article = { id: String(row.id), title: row.title };
|
|
1507
|
-
if (typeof row.excerpt === "string") article.excerpt = row.excerpt;
|
|
1508
|
-
if (typeof row.body === "string") article.body = row.body;
|
|
1509
|
-
const url = safeUrl(row.url);
|
|
1510
|
-
if (url !== void 0) article.url = url;
|
|
1511
|
-
if (typeof row.source === "string") article.source = row.source;
|
|
1512
|
-
return [article];
|
|
1513
|
-
});
|
|
1514
|
-
}
|
|
1515
1381
|
var count = 0;
|
|
1516
1382
|
var saved = null;
|
|
1517
1383
|
var startY = 0;
|
|
@@ -1798,7 +1664,14 @@ function useSheetDrag({ panel, scrim, size, onClose, enabled = true }) {
|
|
|
1798
1664
|
closing = true;
|
|
1799
1665
|
sheet.style.transform = `translateY(${Math.round(sheet.getBoundingClientRect().height + 24)}px)`;
|
|
1800
1666
|
setScrim(0);
|
|
1801
|
-
timer = setTimeout(() =>
|
|
1667
|
+
timer = setTimeout(() => {
|
|
1668
|
+
if (close.current() === false) {
|
|
1669
|
+
closing = false;
|
|
1670
|
+
sheet.style.height = `${done.start}px`;
|
|
1671
|
+
sheet.style.transform = "";
|
|
1672
|
+
setScrim(1);
|
|
1673
|
+
}
|
|
1674
|
+
}, reducedMotion() ? 0 : DURATION - 40);
|
|
1802
1675
|
return;
|
|
1803
1676
|
}
|
|
1804
1677
|
if (natural !== null && result.height === natural) {
|
|
@@ -1856,39 +1729,415 @@ function scrimHandlers(onClose) {
|
|
|
1856
1729
|
}
|
|
1857
1730
|
};
|
|
1858
1731
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1732
|
+
function Spinner({ className, label }) {
|
|
1733
|
+
return /* @__PURE__ */ jsx(
|
|
1734
|
+
"span",
|
|
1735
|
+
{
|
|
1736
|
+
className: cn("cbx-ui-spinner", className),
|
|
1737
|
+
role: label === void 0 ? void 0 : "status",
|
|
1738
|
+
"aria-hidden": label === void 0 ? true : void 0,
|
|
1739
|
+
"aria-label": label
|
|
1740
|
+
}
|
|
1741
|
+
);
|
|
1863
1742
|
}
|
|
1864
|
-
function
|
|
1865
|
-
|
|
1866
|
-
return loaded ?? sent ?? 0;
|
|
1743
|
+
function buttonClassName({ variant = "ghost", size = "md" } = {}) {
|
|
1744
|
+
return cn("cbx-ui-btn", `cbx-ui-btn--${variant}`, size !== "md" && `cbx-ui-btn--${size}`);
|
|
1867
1745
|
}
|
|
1868
|
-
function
|
|
1869
|
-
const
|
|
1870
|
-
|
|
1746
|
+
var Button = forwardRef(function Button2({ variant = "ghost", size = "md", icon, loading = false, asChild = false, disabled, className, children, type, ...props }, ref) {
|
|
1747
|
+
const classes = cn(buttonClassName({ variant, size }), className);
|
|
1748
|
+
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;
|
|
1749
|
+
const inactive = (disabled ?? false) || loading;
|
|
1750
|
+
if (asChild) {
|
|
1751
|
+
const child = Children.only(children);
|
|
1752
|
+
if (!isValidElement(child)) return null;
|
|
1753
|
+
const own = child.props;
|
|
1754
|
+
return cloneElement(child, {
|
|
1755
|
+
...props,
|
|
1756
|
+
ref,
|
|
1757
|
+
className: cn(classes, own.className),
|
|
1758
|
+
"aria-busy": loading || void 0,
|
|
1759
|
+
"aria-disabled": inactive || void 0,
|
|
1760
|
+
// A disabled link keeps its focus (so it can be reached and explained) but goes nowhere.
|
|
1761
|
+
onClick: (event) => {
|
|
1762
|
+
if (inactive) {
|
|
1763
|
+
event.preventDefault();
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
own.onClick?.(event);
|
|
1767
|
+
props.onClick?.(event);
|
|
1768
|
+
},
|
|
1769
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1770
|
+
glyph,
|
|
1771
|
+
own.children
|
|
1772
|
+
] })
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
return /* @__PURE__ */ jsxs(
|
|
1776
|
+
"button",
|
|
1777
|
+
{
|
|
1778
|
+
ref,
|
|
1779
|
+
type: type ?? "button",
|
|
1780
|
+
className: classes,
|
|
1781
|
+
disabled: inactive,
|
|
1782
|
+
"aria-busy": loading || void 0,
|
|
1783
|
+
...props,
|
|
1784
|
+
children: [
|
|
1785
|
+
glyph,
|
|
1786
|
+
children
|
|
1787
|
+
]
|
|
1788
|
+
}
|
|
1789
|
+
);
|
|
1790
|
+
});
|
|
1791
|
+
var TABBABLE = [
|
|
1792
|
+
"a[href]",
|
|
1793
|
+
"area[href]",
|
|
1794
|
+
"button:not([disabled])",
|
|
1795
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
1796
|
+
"select:not([disabled])",
|
|
1797
|
+
"textarea:not([disabled])",
|
|
1798
|
+
"iframe",
|
|
1799
|
+
"audio[controls]",
|
|
1800
|
+
"video[controls]",
|
|
1801
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
1802
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
1803
|
+
].join(",");
|
|
1804
|
+
function tabbables(root) {
|
|
1805
|
+
const all = Array.from(root.querySelectorAll(TABBABLE)).filter((element) => element.tabIndex >= 0 && element.closest("[hidden], [inert]") === null);
|
|
1806
|
+
const checkedGroups = new Set(all.filter((element) => element instanceof HTMLInputElement && element.type === "radio" && element.checked).map((element) => element.name));
|
|
1807
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1808
|
+
return all.filter((element) => {
|
|
1809
|
+
if (!(element instanceof HTMLInputElement) || element.type !== "radio" || element.name === "") return true;
|
|
1810
|
+
if (checkedGroups.has(element.name)) return element.checked;
|
|
1811
|
+
if (seen.has(element.name)) return false;
|
|
1812
|
+
seen.add(element.name);
|
|
1813
|
+
return true;
|
|
1814
|
+
});
|
|
1871
1815
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1816
|
+
var SheetContext = createContext(null);
|
|
1817
|
+
function useSheetClose() {
|
|
1818
|
+
const close = useContext(SheetContext);
|
|
1819
|
+
return close ?? (() => void 0);
|
|
1874
1820
|
}
|
|
1875
|
-
function
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1821
|
+
function SheetClose({ onClick, ...props }) {
|
|
1822
|
+
const close = useSheetClose();
|
|
1823
|
+
return /* @__PURE__ */ jsx(
|
|
1824
|
+
Button,
|
|
1825
|
+
{
|
|
1826
|
+
...props,
|
|
1827
|
+
onClick: (event) => {
|
|
1828
|
+
onClick?.(event);
|
|
1829
|
+
if (!event.defaultPrevented) close();
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
);
|
|
1881
1833
|
}
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1834
|
+
var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
1835
|
+
var NARROW = "(max-width: 767.98px)";
|
|
1836
|
+
function useNarrow() {
|
|
1837
|
+
const [narrow, setNarrow] = useState(() => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(NARROW).matches);
|
|
1838
|
+
useEffect(() => {
|
|
1839
|
+
if (typeof window.matchMedia !== "function") return;
|
|
1840
|
+
const query2 = window.matchMedia(NARROW);
|
|
1841
|
+
const update = () => setNarrow(query2.matches);
|
|
1842
|
+
update();
|
|
1843
|
+
query2.addEventListener("change", update);
|
|
1844
|
+
return () => query2.removeEventListener("change", update);
|
|
1845
|
+
}, []);
|
|
1846
|
+
return narrow;
|
|
1889
1847
|
}
|
|
1890
|
-
function
|
|
1891
|
-
|
|
1848
|
+
function Sheet({ open, onOpenChange, title, description, footer, size = "md", dismissible = true, className, children }) {
|
|
1849
|
+
const { t } = useCboxLocalization();
|
|
1850
|
+
const id = useId();
|
|
1851
|
+
const titleId = `${id}-title`;
|
|
1852
|
+
const descriptionId = `${id}-description`;
|
|
1853
|
+
const layer = useRef(null);
|
|
1854
|
+
const scrim = useRef(null);
|
|
1855
|
+
const panel = useRef(null);
|
|
1856
|
+
const closeButton = useRef(null);
|
|
1857
|
+
const body = useRef(null);
|
|
1858
|
+
const returnTo = useRef(null);
|
|
1859
|
+
const wasOpen = useRef(false);
|
|
1860
|
+
const pressedOnScrim = useRef(false);
|
|
1861
|
+
if (open && !wasOpen.current && typeof document !== "undefined") {
|
|
1862
|
+
const active = document.activeElement;
|
|
1863
|
+
returnTo.current = active instanceof HTMLElement && active !== document.body ? active : null;
|
|
1864
|
+
}
|
|
1865
|
+
wasOpen.current = open;
|
|
1866
|
+
const close = useCallback(() => onOpenChange(false), [onOpenChange]);
|
|
1867
|
+
const narrow = useNarrow();
|
|
1868
|
+
useScrollLock(open);
|
|
1869
|
+
useSheetDrag({ panel, scrim, size: "fit", onClose: dismissible ? close : () => false, enabled: open && narrow });
|
|
1870
|
+
useIsoLayoutEffect2(() => {
|
|
1871
|
+
if (!open || layer.current === null) return;
|
|
1872
|
+
const own = layer.current;
|
|
1873
|
+
const made = [];
|
|
1874
|
+
for (const sibling of Array.from(document.body.children)) {
|
|
1875
|
+
if (sibling === own || !(sibling instanceof HTMLElement) || sibling.hasAttribute("inert")) continue;
|
|
1876
|
+
if (sibling.tagName === "SCRIPT" || sibling.tagName === "STYLE") continue;
|
|
1877
|
+
sibling.setAttribute("inert", "");
|
|
1878
|
+
made.push(sibling);
|
|
1879
|
+
}
|
|
1880
|
+
return () => {
|
|
1881
|
+
for (const element of made) element.removeAttribute("inert");
|
|
1882
|
+
};
|
|
1883
|
+
}, [open]);
|
|
1884
|
+
useIsoLayoutEffect2(() => {
|
|
1885
|
+
if (!open || panel.current === null) return;
|
|
1886
|
+
const root = panel.current;
|
|
1887
|
+
if (root.contains(document.activeElement)) return;
|
|
1888
|
+
const marked = root.querySelector("[data-autofocus]");
|
|
1889
|
+
const field = body.current?.querySelector('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), [role="combobox"]');
|
|
1890
|
+
(marked ?? field ?? closeButton.current ?? root).focus({ preventScroll: true });
|
|
1891
|
+
}, [open]);
|
|
1892
|
+
useEffect(() => {
|
|
1893
|
+
if (!open) return;
|
|
1894
|
+
const onFocusIn = (event) => {
|
|
1895
|
+
const root = panel.current;
|
|
1896
|
+
const target = event.target;
|
|
1897
|
+
if (root === null || !(target instanceof Node) || root.contains(target)) return;
|
|
1898
|
+
if (target instanceof Element && target.closest("[data-cbx-dialog-layer]") !== null) return;
|
|
1899
|
+
(tabbables(root)[0] ?? root).focus({ preventScroll: true });
|
|
1900
|
+
};
|
|
1901
|
+
document.addEventListener("focusin", onFocusIn);
|
|
1902
|
+
return () => document.removeEventListener("focusin", onFocusIn);
|
|
1903
|
+
}, [open]);
|
|
1904
|
+
useEffect(() => {
|
|
1905
|
+
if (!open) return;
|
|
1906
|
+
return () => {
|
|
1907
|
+
const target = returnTo.current;
|
|
1908
|
+
if (target !== null && target.isConnected) target.focus({ preventScroll: true });
|
|
1909
|
+
};
|
|
1910
|
+
}, [open]);
|
|
1911
|
+
const onKeyDown = (event) => {
|
|
1912
|
+
if (event.defaultPrevented) return;
|
|
1913
|
+
if (event.key === "Escape") {
|
|
1914
|
+
event.preventDefault();
|
|
1915
|
+
event.stopPropagation();
|
|
1916
|
+
close();
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
if (event.key !== "Tab" || panel.current === null) return;
|
|
1920
|
+
const items = tabbables(panel.current);
|
|
1921
|
+
const first = items[0];
|
|
1922
|
+
const last = items[items.length - 1];
|
|
1923
|
+
if (first === void 0 || last === void 0) {
|
|
1924
|
+
event.preventDefault();
|
|
1925
|
+
panel.current.focus({ preventScroll: true });
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
const active = document.activeElement;
|
|
1929
|
+
if (event.shiftKey && (active === first || active === panel.current)) {
|
|
1930
|
+
event.preventDefault();
|
|
1931
|
+
last.focus();
|
|
1932
|
+
} else if (!event.shiftKey && active === last) {
|
|
1933
|
+
event.preventDefault();
|
|
1934
|
+
first.focus();
|
|
1935
|
+
}
|
|
1936
|
+
};
|
|
1937
|
+
if (!open || typeof document === "undefined") return null;
|
|
1938
|
+
const onScrimDown = (event) => {
|
|
1939
|
+
pressedOnScrim.current = event.target === event.currentTarget;
|
|
1940
|
+
};
|
|
1941
|
+
const onScrimClick = (event) => {
|
|
1942
|
+
if (dismissible && pressedOnScrim.current && event.target === event.currentTarget) close();
|
|
1943
|
+
pressedOnScrim.current = false;
|
|
1944
|
+
};
|
|
1945
|
+
return createPortal(
|
|
1946
|
+
/* @__PURE__ */ jsx(SheetContext.Provider, { value: close, children: /* @__PURE__ */ jsxs("div", { ref: layer, "data-cbx-scroll-layer": "", "data-cbx-dialog-layer": "", children: [
|
|
1947
|
+
/* @__PURE__ */ jsx("div", { ref: scrim, className: "cbx-ui-overlay", "aria-hidden": "true", onMouseDown: onScrimDown, onClick: onScrimClick }),
|
|
1948
|
+
/* @__PURE__ */ jsxs(
|
|
1949
|
+
"div",
|
|
1950
|
+
{
|
|
1951
|
+
ref: panel,
|
|
1952
|
+
role: "dialog",
|
|
1953
|
+
"aria-modal": "true",
|
|
1954
|
+
"aria-labelledby": titleId,
|
|
1955
|
+
"aria-describedby": description !== void 0 ? descriptionId : void 0,
|
|
1956
|
+
tabIndex: -1,
|
|
1957
|
+
className: cn("cbx-ui-sheet", `cbx-ui-sheet--${size}`, className),
|
|
1958
|
+
onKeyDown,
|
|
1959
|
+
children: [
|
|
1960
|
+
/* @__PURE__ */ jsx("div", { className: "cbx-ui-sheet-handle cbx-sheet-grab", "aria-hidden": "true" }),
|
|
1961
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-ui-sheet-head cbx-sheet-grab", children: [
|
|
1962
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-ui-sheet-heading", children: [
|
|
1963
|
+
/* @__PURE__ */ jsx("h2", { id: titleId, className: "cbx-ui-sheet-title", children: title }),
|
|
1964
|
+
description !== void 0 && /* @__PURE__ */ jsx("p", { id: descriptionId, className: "cbx-ui-sheet-desc", children: description })
|
|
1965
|
+
] }),
|
|
1966
|
+
/* @__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" }) }) })
|
|
1967
|
+
] }),
|
|
1968
|
+
children !== void 0 && children !== null && /* @__PURE__ */ jsx("div", { ref: body, className: "cbx-ui-sheet-body", "data-cbx-sheet-scroll": "", children }),
|
|
1969
|
+
footer !== void 0 && footer !== null && /* @__PURE__ */ jsx("div", { className: "cbx-ui-sheet-foot", children: footer })
|
|
1970
|
+
]
|
|
1971
|
+
}
|
|
1972
|
+
)
|
|
1973
|
+
] }) }),
|
|
1974
|
+
document.body
|
|
1975
|
+
);
|
|
1976
|
+
}
|
|
1977
|
+
var Dialog = Sheet;
|
|
1978
|
+
var DialogClose = SheetClose;
|
|
1979
|
+
var useDialogClose = useSheetClose;
|
|
1980
|
+
var SHELL_ICONS = {
|
|
1981
|
+
activity: Activity,
|
|
1982
|
+
"bar-chart": BarChart3,
|
|
1983
|
+
bell: Bell,
|
|
1984
|
+
"book-open": BookOpen,
|
|
1985
|
+
boxes: Boxes,
|
|
1986
|
+
briefcase: Briefcase,
|
|
1987
|
+
building: Building2,
|
|
1988
|
+
calendar: Calendar,
|
|
1989
|
+
clock: Clock,
|
|
1990
|
+
cloud: Cloud,
|
|
1991
|
+
code: Code,
|
|
1992
|
+
"credit-card": CreditCard,
|
|
1993
|
+
database: Database,
|
|
1994
|
+
"file-text": FileText,
|
|
1995
|
+
folder: Folder,
|
|
1996
|
+
"git-branch": GitBranch,
|
|
1997
|
+
globe: Globe,
|
|
1998
|
+
"hard-drive": HardDrive,
|
|
1999
|
+
home: Home,
|
|
2000
|
+
inbox: Inbox,
|
|
2001
|
+
key: Key,
|
|
2002
|
+
"layout-dashboard": LayoutDashboard,
|
|
2003
|
+
"layout-grid": LayoutGrid,
|
|
2004
|
+
layers: Layers,
|
|
2005
|
+
"life-buoy": LifeBuoy,
|
|
2006
|
+
list: List,
|
|
2007
|
+
lock: Lock,
|
|
2008
|
+
mail: Mail,
|
|
2009
|
+
"message-square": MessageSquare,
|
|
2010
|
+
network: Network,
|
|
2011
|
+
package: Package,
|
|
2012
|
+
percent: Percent,
|
|
2013
|
+
plug: Plug,
|
|
2014
|
+
receipt: Receipt,
|
|
2015
|
+
rocket: Rocket,
|
|
2016
|
+
search: Search,
|
|
2017
|
+
send: Send,
|
|
2018
|
+
server: Server,
|
|
2019
|
+
settings: Settings,
|
|
2020
|
+
shield: Shield,
|
|
2021
|
+
"shield-check": ShieldCheck,
|
|
2022
|
+
sparkles: Sparkles,
|
|
2023
|
+
tag: Tag,
|
|
2024
|
+
timer: Timer,
|
|
2025
|
+
users: Users,
|
|
2026
|
+
wallet: Wallet,
|
|
2027
|
+
webhook: Webhook,
|
|
2028
|
+
zap: Zap
|
|
2029
|
+
};
|
|
2030
|
+
function resolveIcon(name, extra = {}) {
|
|
2031
|
+
if (name === void 0) return Circle;
|
|
2032
|
+
return extra[name] ?? SHELL_ICONS[name] ?? Circle;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
// src/shell/help-store.ts
|
|
2036
|
+
var INITIAL_HELP_STATE = {
|
|
2037
|
+
open: false,
|
|
2038
|
+
article: null,
|
|
2039
|
+
query: "",
|
|
2040
|
+
scrollTop: 0,
|
|
2041
|
+
updates: [],
|
|
2042
|
+
updatesStatus: "idle",
|
|
2043
|
+
pendingQuestion: null,
|
|
2044
|
+
seeded: false,
|
|
2045
|
+
restored: false,
|
|
2046
|
+
updatesKey: null
|
|
2047
|
+
};
|
|
2048
|
+
function helpVisible(state, docked) {
|
|
2049
|
+
return state.open && (docked || !state.restored);
|
|
2050
|
+
}
|
|
2051
|
+
function createHelpStore(initial = {}) {
|
|
2052
|
+
let state = { ...INITIAL_HELP_STATE, ...initial };
|
|
2053
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2054
|
+
return {
|
|
2055
|
+
get: () => state,
|
|
2056
|
+
set(patch) {
|
|
2057
|
+
const next = typeof patch === "function" ? patch(state) : patch;
|
|
2058
|
+
state = { ...state, ...next };
|
|
2059
|
+
listeners.forEach((listener) => listener());
|
|
2060
|
+
},
|
|
2061
|
+
subscribe(listener) {
|
|
2062
|
+
listeners.add(listener);
|
|
2063
|
+
return () => listeners.delete(listener);
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
var browserStore = null;
|
|
2068
|
+
function sharedHelpStore() {
|
|
2069
|
+
if (typeof window === "undefined") return createHelpStore();
|
|
2070
|
+
browserStore ??= createHelpStore();
|
|
2071
|
+
return browserStore;
|
|
2072
|
+
}
|
|
2073
|
+
function parseUpdates(body) {
|
|
2074
|
+
const rows2 = Array.isArray(body) ? body : typeof body === "object" && body !== null && Array.isArray(body.data) ? body.data : [];
|
|
2075
|
+
return rows2.flatMap((value) => {
|
|
2076
|
+
if (typeof value !== "object" || value === null) return [];
|
|
2077
|
+
const row = value;
|
|
2078
|
+
if (typeof row.id !== "string" && typeof row.id !== "number" || typeof row.title !== "string") return [];
|
|
2079
|
+
const update = {
|
|
2080
|
+
id: String(row.id),
|
|
2081
|
+
kind: row.kind === "chat" ? "chat" : "ticket",
|
|
2082
|
+
title: row.title,
|
|
2083
|
+
unread: row.unread === true || row.read === false || row.read_at === null && row.unread !== false
|
|
2084
|
+
};
|
|
2085
|
+
if (typeof row.excerpt === "string") update.excerpt = row.excerpt;
|
|
2086
|
+
const at = row.at ?? row.updated_at ?? row.created_at;
|
|
2087
|
+
if (typeof at === "string") update.at = at;
|
|
2088
|
+
const url = safeUrl(row.url);
|
|
2089
|
+
if (url !== void 0) update.url = url;
|
|
2090
|
+
return [update];
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
function parseArticles(body) {
|
|
2094
|
+
const rows2 = Array.isArray(body) ? body : typeof body === "object" && body !== null && Array.isArray(body.data) ? body.data : [];
|
|
2095
|
+
return rows2.flatMap((value) => {
|
|
2096
|
+
if (typeof value !== "object" || value === null) return [];
|
|
2097
|
+
const row = value;
|
|
2098
|
+
if (typeof row.id !== "string" && typeof row.id !== "number" || typeof row.title !== "string") return [];
|
|
2099
|
+
const article = { id: String(row.id), title: row.title };
|
|
2100
|
+
if (typeof row.excerpt === "string") article.excerpt = row.excerpt;
|
|
2101
|
+
if (typeof row.body === "string") article.body = row.body;
|
|
2102
|
+
const url = safeUrl(row.url);
|
|
2103
|
+
if (url !== void 0) article.url = url;
|
|
2104
|
+
if (typeof row.source === "string") article.source = row.source;
|
|
2105
|
+
return [article];
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
var DEFAULT_SUPPORT_SCRIPT = "/ai-assistant/support.js";
|
|
2109
|
+
var SUPPORT_TAG = "cbox-support";
|
|
2110
|
+
function useHelpState(store, select) {
|
|
2111
|
+
return useSyncExternalStore(store.subscribe, () => select(store.get()), () => select(store.get()));
|
|
2112
|
+
}
|
|
2113
|
+
function useUnreadCount(store, sent) {
|
|
2114
|
+
const loaded = useHelpState(store, (state) => state.updatesStatus === "ready" ? state.updates.filter((update) => update.unread).length : null);
|
|
2115
|
+
return loaded ?? sent ?? 0;
|
|
2116
|
+
}
|
|
2117
|
+
function helpTopicName(shell) {
|
|
2118
|
+
const area = shell.nav.areas.find((item) => item.key === shell.nav.activeArea);
|
|
2119
|
+
return shell.page?.title ?? area?.label ?? shell.app.name;
|
|
2120
|
+
}
|
|
2121
|
+
function contextTrail(shell) {
|
|
2122
|
+
return shell.context.levels.map((level) => level.current.name).join(" / ");
|
|
2123
|
+
}
|
|
2124
|
+
function pageIntent(shell) {
|
|
2125
|
+
const intent = { context: contextTrail(shell) };
|
|
2126
|
+
if (shell.page?.route !== void 0) intent.route = shell.page.route;
|
|
2127
|
+
if (shell.page?.title !== void 0) intent.title = shell.page.title;
|
|
2128
|
+
if (typeof window !== "undefined") intent.url = window.location.pathname;
|
|
2129
|
+
return intent;
|
|
2130
|
+
}
|
|
2131
|
+
function ensureScript(src) {
|
|
2132
|
+
if (typeof document === "undefined" || customElements.get(SUPPORT_TAG) !== void 0) return;
|
|
2133
|
+
if (Array.from(document.scripts).some((script2) => script2.getAttribute("src") === src)) return;
|
|
2134
|
+
const script = document.createElement("script");
|
|
2135
|
+
script.src = src;
|
|
2136
|
+
script.defer = true;
|
|
2137
|
+
document.head.append(script);
|
|
2138
|
+
}
|
|
2139
|
+
function whenSupportReady(host, timeoutMs = 6e3) {
|
|
2140
|
+
return new Promise((resolve) => {
|
|
1892
2141
|
const started = Date.now();
|
|
1893
2142
|
const attempt = () => {
|
|
1894
2143
|
const element = host?.querySelector(SUPPORT_TAG) ?? null;
|
|
@@ -2862,10 +3111,11 @@ function CommandPalette({ onClose }) {
|
|
|
2862
3111
|
] })
|
|
2863
3112
|
] }) });
|
|
2864
3113
|
}
|
|
2865
|
-
function
|
|
3114
|
+
function Sheet2({
|
|
2866
3115
|
label,
|
|
2867
3116
|
side = "bottom",
|
|
2868
3117
|
onClose,
|
|
3118
|
+
onEscape,
|
|
2869
3119
|
children,
|
|
2870
3120
|
title,
|
|
2871
3121
|
back,
|
|
@@ -2898,7 +3148,7 @@ function Sheet({
|
|
|
2898
3148
|
onKeyDown: (event) => {
|
|
2899
3149
|
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
2900
3150
|
event.preventDefault();
|
|
2901
|
-
onClose();
|
|
3151
|
+
(onEscape ?? onClose)();
|
|
2902
3152
|
}
|
|
2903
3153
|
trapTab(event, panel.current);
|
|
2904
3154
|
},
|
|
@@ -2931,22 +3181,40 @@ function createLabel(shell, t) {
|
|
|
2931
3181
|
function CreateSheet({ onClose }) {
|
|
2932
3182
|
const { shell, t, mobile, createKey, renderCreate } = useShell();
|
|
2933
3183
|
const [stack, setStack] = useState(() => findCreatable(shell, createKey) !== void 0 ? [{ kind: "tree" }, { kind: "form", key: createKey }] : [{ kind: "tree" }]);
|
|
3184
|
+
const guards = useRef(/* @__PURE__ */ new Map());
|
|
3185
|
+
const [leaving, setLeaving] = useState(null);
|
|
2934
3186
|
const top = stack[stack.length - 1];
|
|
2935
3187
|
const below = stack.length > 1 ? stack[stack.length - 2] : null;
|
|
2936
3188
|
const environmentLevelItem = environmentLevel(shell.context.levels)?.current ?? null;
|
|
2937
3189
|
const notLive = environmentLevelItem !== null && isLive(environmentLevelItem) === false;
|
|
2938
3190
|
const name = (entry) => entry === null ? "" : entry.kind === "tree" ? t("Create") : findCreatable(shell, entry.key)?.label ?? entry.key;
|
|
2939
|
-
const pop = () =>
|
|
3191
|
+
const pop = () => {
|
|
3192
|
+
guards.current.delete(top);
|
|
3193
|
+
setStack((current) => current.length > 1 ? current.slice(0, -1) : current);
|
|
3194
|
+
if (top.kind === "form") requestAnimationFrame(() => top.returnFocus?.focus());
|
|
3195
|
+
};
|
|
3196
|
+
const leave = (scope) => {
|
|
3197
|
+
const entries = scope === "all" ? stack : [top];
|
|
3198
|
+
if (entries.some((entry) => guards.current.get(entry)?.busy)) return false;
|
|
3199
|
+
if (entries.some((entry) => guards.current.get(entry)?.dirty)) {
|
|
3200
|
+
setLeaving(scope);
|
|
3201
|
+
return false;
|
|
3202
|
+
}
|
|
3203
|
+
if (scope === "all" || below === null) onClose();
|
|
3204
|
+
else pop();
|
|
3205
|
+
return true;
|
|
3206
|
+
};
|
|
2940
3207
|
const title = top.kind === "tree" ? t("Create") : t("New {thing}", { thing: name(top).toLowerCase() });
|
|
2941
3208
|
return /* @__PURE__ */ jsxs(
|
|
2942
|
-
|
|
3209
|
+
Sheet2,
|
|
2943
3210
|
{
|
|
2944
3211
|
label: title,
|
|
2945
3212
|
side: mobile ? "bottom" : "right",
|
|
2946
3213
|
size: "tall",
|
|
2947
|
-
onClose,
|
|
3214
|
+
onClose: () => leave("all"),
|
|
3215
|
+
onEscape: () => leave("top"),
|
|
2948
3216
|
className: "cbx-create-sheet",
|
|
2949
|
-
back: below !== null ? { label: t("Back to {thing}", { thing: name(below) }), text: name(below), onBack:
|
|
3217
|
+
back: below !== null ? { label: t("Back to {thing}", { thing: name(below) }), text: name(below), onBack: () => leave("top") } : void 0,
|
|
2950
3218
|
children: [
|
|
2951
3219
|
top.kind === "tree" && /* @__PURE__ */ jsx(CreateTree, { onPick: (key) => setStack([{ kind: "tree" }, { kind: "form", key }]) }),
|
|
2952
3220
|
notLive && top.kind === "form" && /* @__PURE__ */ jsxs("p", { className: "cbx-create-env", role: "note", children: [
|
|
@@ -2965,7 +3233,8 @@ function CreateSheet({ onClose }) {
|
|
|
2965
3233
|
submitLabel: parent !== null ? t("Create and use in {thing}", { thing: parent.label.toLowerCase() }) : creatable.submitLabel ?? t("Create {thing}", { thing: creatable.label.toLowerCase() }),
|
|
2966
3234
|
createRef: (key, onCreated) => {
|
|
2967
3235
|
if (findCreatable(shell, key) === void 0) return;
|
|
2968
|
-
|
|
3236
|
+
const returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : void 0;
|
|
3237
|
+
setStack((current) => [...current.slice(0, index + 1), { kind: "form", key, onCreated, returnFocus }]);
|
|
2969
3238
|
},
|
|
2970
3239
|
done: (created) => {
|
|
2971
3240
|
if (parent === null) {
|
|
@@ -2975,12 +3244,33 @@ function CreateSheet({ onClose }) {
|
|
|
2975
3244
|
setStack((current) => current.slice(0, index));
|
|
2976
3245
|
if (created !== void 0) entry.onCreated?.(created);
|
|
2977
3246
|
},
|
|
2978
|
-
close:
|
|
3247
|
+
close: () => leave("all"),
|
|
3248
|
+
setDirty: (dirty) => guards.current.set(entry, { dirty, busy: guards.current.get(entry)?.busy ?? false }),
|
|
3249
|
+
setBusy: (busy) => guards.current.set(entry, { busy, dirty: guards.current.get(entry)?.dirty ?? false }),
|
|
2979
3250
|
environment: environmentLevelItem
|
|
2980
3251
|
};
|
|
2981
3252
|
const body = renderCreate?.(form) ?? null;
|
|
2982
3253
|
return /* @__PURE__ */ jsx("div", { className: "cbx-create-form", hidden: entry !== top, children: body ?? /* @__PURE__ */ jsx("p", { className: "cbx-list-note", children: t("{thing} cannot be created here yet.", { thing: creatable.label }) }) }, `${index}:${entry.key}`);
|
|
2983
|
-
})
|
|
3254
|
+
}),
|
|
3255
|
+
/* @__PURE__ */ jsx(
|
|
3256
|
+
Dialog,
|
|
3257
|
+
{
|
|
3258
|
+
open: leaving !== null,
|
|
3259
|
+
onOpenChange: (open) => {
|
|
3260
|
+
if (!open) setLeaving(null);
|
|
3261
|
+
},
|
|
3262
|
+
title: leaving === "all" ? t("Discard this creation flow?") : t("Discard {thing}?", { thing: name(top).toLowerCase() }),
|
|
3263
|
+
description: leaving === "all" ? t("Unsaved entries in every task will be lost.") : t("Only this task is discarded. The task underneath keeps its values."),
|
|
3264
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3265
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setLeaving(null), children: t("Keep editing") }),
|
|
3266
|
+
/* @__PURE__ */ jsx(Button, { variant: "danger", onClick: () => {
|
|
3267
|
+
if (leaving === "all" || below === null) onClose();
|
|
3268
|
+
else pop();
|
|
3269
|
+
setLeaving(null);
|
|
3270
|
+
}, children: t("Discard") })
|
|
3271
|
+
] })
|
|
3272
|
+
}
|
|
3273
|
+
)
|
|
2984
3274
|
]
|
|
2985
3275
|
}
|
|
2986
3276
|
);
|
|
@@ -3040,15 +3330,277 @@ function CreateRefField({ label, value, placeholder, thing, onChoose, onCreate }
|
|
|
3040
3330
|
] })
|
|
3041
3331
|
] });
|
|
3042
3332
|
}
|
|
3043
|
-
function CreateSubmit({ form, busy = false, disabled = false }) {
|
|
3044
|
-
const { t } = useShell();
|
|
3045
|
-
return /* @__PURE__ */ jsx("button", { type: "submit", className: "cbx-button cbx-button-primary cbx-create-submit", disabled: busy || disabled, children: busy ? t("Creating\u2026") : form.submitLabel });
|
|
3333
|
+
function CreateSubmit({ form, busy = false, disabled = false }) {
|
|
3334
|
+
const { t } = useShell();
|
|
3335
|
+
return /* @__PURE__ */ jsx("button", { type: "submit", className: "cbx-button cbx-button-primary cbx-create-submit", disabled: busy || disabled, children: busy ? t("Creating\u2026") : form.submitLabel });
|
|
3336
|
+
}
|
|
3337
|
+
function CreateForm({ onSubmit, children }) {
|
|
3338
|
+
return /* @__PURE__ */ jsx("form", { className: "cbx-cform", onSubmit: (event) => {
|
|
3339
|
+
event.preventDefault();
|
|
3340
|
+
onSubmit(event);
|
|
3341
|
+
}, children });
|
|
3342
|
+
}
|
|
3343
|
+
var DefaultLink = ({ href, className, children, "aria-current": ariaCurrent }) => /* @__PURE__ */ jsx("a", { href, className, "aria-current": ariaCurrent, children });
|
|
3344
|
+
function PageTabs({
|
|
3345
|
+
items,
|
|
3346
|
+
currentPath,
|
|
3347
|
+
LinkComponent = DefaultLink,
|
|
3348
|
+
actions,
|
|
3349
|
+
className
|
|
3350
|
+
}) {
|
|
3351
|
+
const activeHref = resolveActiveHref(items, currentPath);
|
|
3352
|
+
return /* @__PURE__ */ jsxs(
|
|
3353
|
+
"div",
|
|
3354
|
+
{
|
|
3355
|
+
"data-component": "page-tabs",
|
|
3356
|
+
className: cn(
|
|
3357
|
+
// Card-style chrome — same border, radius, bg as DataPanel
|
|
3358
|
+
// so the tab strip reads as a peer of the content panels
|
|
3359
|
+
// beneath it instead of floating on the page background.
|
|
3360
|
+
// Width matches PageShell content; no sticky positioning.
|
|
3361
|
+
"cbx-page-tabs @container/tabs min-w-0 rounded-lg border border-border bg-card",
|
|
3362
|
+
className
|
|
3363
|
+
),
|
|
3364
|
+
children: [
|
|
3365
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-page-tabs-desktop hidden items-end gap-3 px-3 @min-[56rem]/tabs:flex", children: [
|
|
3366
|
+
/* @__PURE__ */ jsx(
|
|
3367
|
+
DesktopStrip,
|
|
3368
|
+
{
|
|
3369
|
+
items,
|
|
3370
|
+
activeHref,
|
|
3371
|
+
LinkComponent
|
|
3372
|
+
}
|
|
3373
|
+
),
|
|
3374
|
+
/* @__PURE__ */ jsx("div", { className: "flex min-h-12 shrink-0 items-center gap-2", children: actions })
|
|
3375
|
+
] }),
|
|
3376
|
+
/* @__PURE__ */ jsxs("div", { className: "cbx-page-tabs-mobile flex flex-col gap-2 p-2 @min-[56rem]/tabs:hidden", children: [
|
|
3377
|
+
/* @__PURE__ */ jsx(
|
|
3378
|
+
MobileDropdown,
|
|
3379
|
+
{
|
|
3380
|
+
items,
|
|
3381
|
+
activeHref,
|
|
3382
|
+
LinkComponent
|
|
3383
|
+
}
|
|
3384
|
+
),
|
|
3385
|
+
actions !== void 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions }) : null
|
|
3386
|
+
] })
|
|
3387
|
+
]
|
|
3388
|
+
}
|
|
3389
|
+
);
|
|
3390
|
+
}
|
|
3391
|
+
function DesktopStrip({ items, activeHref, LinkComponent }) {
|
|
3392
|
+
const { t } = useCboxLocalization();
|
|
3393
|
+
return /* @__PURE__ */ jsx(
|
|
3394
|
+
"nav",
|
|
3395
|
+
{
|
|
3396
|
+
className: "flex min-h-12 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden py-1.5",
|
|
3397
|
+
"aria-label": t("Section navigation"),
|
|
3398
|
+
children: items.map((item) => {
|
|
3399
|
+
const Icon = item.icon;
|
|
3400
|
+
const active = item.href === activeHref;
|
|
3401
|
+
return /* @__PURE__ */ jsxs(
|
|
3402
|
+
LinkComponent,
|
|
3403
|
+
{
|
|
3404
|
+
href: item.href,
|
|
3405
|
+
prefetch: true,
|
|
3406
|
+
"aria-current": active ? "page" : void 0,
|
|
3407
|
+
className: cn(
|
|
3408
|
+
"inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 text-[13px] whitespace-nowrap transition-colors",
|
|
3409
|
+
active ? "bg-secondary font-semibold text-foreground shadow-sm ring-1 ring-border-strong/60" : "text-muted-foreground hover:bg-secondary/60 hover:text-foreground"
|
|
3410
|
+
),
|
|
3411
|
+
children: [
|
|
3412
|
+
Icon !== void 0 ? /* @__PURE__ */ jsx(
|
|
3413
|
+
Icon,
|
|
3414
|
+
{
|
|
3415
|
+
className: cn(
|
|
3416
|
+
"h-3.5 w-3.5 shrink-0",
|
|
3417
|
+
active ? "text-foreground" : "text-muted-foreground"
|
|
3418
|
+
),
|
|
3419
|
+
strokeWidth: 1.7
|
|
3420
|
+
}
|
|
3421
|
+
) : null,
|
|
3422
|
+
/* @__PURE__ */ jsx("span", { children: item.label }),
|
|
3423
|
+
/* @__PURE__ */ jsx(ItemTrailing, { item, active })
|
|
3424
|
+
]
|
|
3425
|
+
},
|
|
3426
|
+
item.href
|
|
3427
|
+
);
|
|
3428
|
+
})
|
|
3429
|
+
}
|
|
3430
|
+
);
|
|
3431
|
+
}
|
|
3432
|
+
function MobileDropdown({ items, activeHref, LinkComponent }) {
|
|
3433
|
+
const { t } = useCboxLocalization();
|
|
3434
|
+
const [open, setOpen] = useState(false);
|
|
3435
|
+
const ref = useRef(null);
|
|
3436
|
+
const trigger = useRef(null);
|
|
3437
|
+
const listId = useId();
|
|
3438
|
+
const active = items.find((item) => item.href === activeHref) ?? items[0];
|
|
3439
|
+
useEffect(() => setOpen(false), [activeHref]);
|
|
3440
|
+
useEffect(() => {
|
|
3441
|
+
if (!open) return;
|
|
3442
|
+
function onPointerDown(event) {
|
|
3443
|
+
if (ref.current !== null && !ref.current.contains(event.target)) {
|
|
3444
|
+
setOpen(false);
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
function onKey(event) {
|
|
3448
|
+
if (event.key === "Escape") {
|
|
3449
|
+
event.preventDefault();
|
|
3450
|
+
setOpen(false);
|
|
3451
|
+
trigger.current?.focus();
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
window.addEventListener("pointerdown", onPointerDown);
|
|
3455
|
+
window.addEventListener("keydown", onKey);
|
|
3456
|
+
return () => {
|
|
3457
|
+
window.removeEventListener("pointerdown", onPointerDown);
|
|
3458
|
+
window.removeEventListener("keydown", onKey);
|
|
3459
|
+
};
|
|
3460
|
+
}, [open]);
|
|
3461
|
+
if (active === void 0) {
|
|
3462
|
+
return null;
|
|
3463
|
+
}
|
|
3464
|
+
const ActiveIcon = active.icon;
|
|
3465
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: "cbx-page-tabs-dropdown relative", children: [
|
|
3466
|
+
/* @__PURE__ */ jsxs(
|
|
3467
|
+
"button",
|
|
3468
|
+
{
|
|
3469
|
+
ref: trigger,
|
|
3470
|
+
type: "button",
|
|
3471
|
+
onClick: () => setOpen((v) => !v),
|
|
3472
|
+
"aria-expanded": open,
|
|
3473
|
+
"aria-controls": listId,
|
|
3474
|
+
className: cn(
|
|
3475
|
+
"cbx-ui-page-tab-trigger flex w-full min-h-11 items-center justify-between gap-2 rounded-md border border-border bg-card px-3 text-left text-[13px] font-medium text-foreground transition-colors hover:border-border-strong",
|
|
3476
|
+
open && "border-border-strong ring-2 ring-ring/30"
|
|
3477
|
+
),
|
|
3478
|
+
children: [
|
|
3479
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
3480
|
+
ActiveIcon !== void 0 ? /* @__PURE__ */ jsx(
|
|
3481
|
+
ActiveIcon,
|
|
3482
|
+
{
|
|
3483
|
+
className: "h-3.5 w-3.5 shrink-0 text-muted-foreground",
|
|
3484
|
+
strokeWidth: 1.7
|
|
3485
|
+
}
|
|
3486
|
+
) : null,
|
|
3487
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: active.label }),
|
|
3488
|
+
/* @__PURE__ */ jsx(ItemTrailing, { item: active, active: true })
|
|
3489
|
+
] }),
|
|
3490
|
+
/* @__PURE__ */ jsx(Chevron, { open })
|
|
3491
|
+
]
|
|
3492
|
+
}
|
|
3493
|
+
),
|
|
3494
|
+
open ? /* @__PURE__ */ jsx(
|
|
3495
|
+
"ul",
|
|
3496
|
+
{
|
|
3497
|
+
id: listId,
|
|
3498
|
+
"aria-label": t("Section navigation"),
|
|
3499
|
+
onClick: (event) => {
|
|
3500
|
+
if (event.target.closest("a")) setOpen(false);
|
|
3501
|
+
},
|
|
3502
|
+
className: "absolute left-0 right-0 top-full z-30 mt-1 max-h-[60dvh] overflow-y-auto rounded-md border border-border bg-popover shadow-lg",
|
|
3503
|
+
children: items.map((item) => {
|
|
3504
|
+
const Icon = item.icon;
|
|
3505
|
+
const isActive = item.href === activeHref;
|
|
3506
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
3507
|
+
LinkComponent,
|
|
3508
|
+
{
|
|
3509
|
+
href: item.href,
|
|
3510
|
+
prefetch: true,
|
|
3511
|
+
"aria-current": isActive ? "page" : void 0,
|
|
3512
|
+
className: cn(
|
|
3513
|
+
"flex w-full items-center gap-2 px-3 py-2.5 text-[13px] transition-colors",
|
|
3514
|
+
isActive ? "bg-accent-soft font-semibold text-foreground" : "text-muted-foreground hover:bg-secondary hover:text-foreground"
|
|
3515
|
+
),
|
|
3516
|
+
children: [
|
|
3517
|
+
Icon !== void 0 ? /* @__PURE__ */ jsx(
|
|
3518
|
+
Icon,
|
|
3519
|
+
{
|
|
3520
|
+
className: cn(
|
|
3521
|
+
"h-3.5 w-3.5 shrink-0",
|
|
3522
|
+
isActive ? "text-foreground" : "text-muted-foreground"
|
|
3523
|
+
),
|
|
3524
|
+
strokeWidth: 1.7
|
|
3525
|
+
}
|
|
3526
|
+
) : null,
|
|
3527
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 break-words", children: item.label }),
|
|
3528
|
+
/* @__PURE__ */ jsx(
|
|
3529
|
+
ItemTrailing,
|
|
3530
|
+
{
|
|
3531
|
+
item,
|
|
3532
|
+
active: isActive
|
|
3533
|
+
}
|
|
3534
|
+
)
|
|
3535
|
+
]
|
|
3536
|
+
}
|
|
3537
|
+
) }, item.href);
|
|
3538
|
+
})
|
|
3539
|
+
}
|
|
3540
|
+
) : null
|
|
3541
|
+
] });
|
|
3542
|
+
}
|
|
3543
|
+
function ItemTrailing({
|
|
3544
|
+
item,
|
|
3545
|
+
active
|
|
3546
|
+
}) {
|
|
3547
|
+
if (item.badge !== void 0) {
|
|
3548
|
+
return /* @__PURE__ */ jsx("span", { className: "ml-1 shrink-0", children: item.badge });
|
|
3549
|
+
}
|
|
3550
|
+
if (item.count !== void 0) {
|
|
3551
|
+
return /* @__PURE__ */ jsx(
|
|
3552
|
+
"span",
|
|
3553
|
+
{
|
|
3554
|
+
className: cn(
|
|
3555
|
+
"ml-1 shrink-0 rounded-sm border px-1 text-[10px] font-semibold tracking-tight tabular-nums",
|
|
3556
|
+
active ? "border-border-strong bg-secondary text-foreground" : "border-border bg-secondary/60 text-muted-foreground"
|
|
3557
|
+
),
|
|
3558
|
+
children: item.count
|
|
3559
|
+
}
|
|
3560
|
+
);
|
|
3561
|
+
}
|
|
3562
|
+
return null;
|
|
3563
|
+
}
|
|
3564
|
+
function Chevron({ open }) {
|
|
3565
|
+
return /* @__PURE__ */ jsx(
|
|
3566
|
+
"svg",
|
|
3567
|
+
{
|
|
3568
|
+
width: "14",
|
|
3569
|
+
height: "14",
|
|
3570
|
+
viewBox: "0 0 14 14",
|
|
3571
|
+
fill: "none",
|
|
3572
|
+
stroke: "currentColor",
|
|
3573
|
+
strokeWidth: "1.6",
|
|
3574
|
+
strokeLinecap: "round",
|
|
3575
|
+
strokeLinejoin: "round",
|
|
3576
|
+
className: cn(
|
|
3577
|
+
"shrink-0 text-muted-foreground transition-transform duration-150",
|
|
3578
|
+
open && "rotate-180"
|
|
3579
|
+
),
|
|
3580
|
+
"aria-hidden": true,
|
|
3581
|
+
children: /* @__PURE__ */ jsx("path", { d: "m3.5 5.5 3.5 3.5 3.5-3.5" })
|
|
3582
|
+
}
|
|
3583
|
+
);
|
|
3584
|
+
}
|
|
3585
|
+
function pathOnly(href) {
|
|
3586
|
+
const queryIndex = href.indexOf("?");
|
|
3587
|
+
const hashIndex = href.indexOf("#");
|
|
3588
|
+
let end = href.length;
|
|
3589
|
+
if (queryIndex !== -1) end = Math.min(end, queryIndex);
|
|
3590
|
+
if (hashIndex !== -1) end = Math.min(end, hashIndex);
|
|
3591
|
+
return href.slice(0, end);
|
|
3046
3592
|
}
|
|
3047
|
-
function
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3593
|
+
function resolveActiveHref(items, currentPath) {
|
|
3594
|
+
const current = pathOnly(currentPath);
|
|
3595
|
+
const candidates = items.map((item) => {
|
|
3596
|
+
const itemPath = pathOnly(item.href);
|
|
3597
|
+
const matched = item.matchPrefix === true ? current === itemPath || current.startsWith(itemPath + "/") : current === itemPath;
|
|
3598
|
+
return matched ? item.href : null;
|
|
3599
|
+
}).filter((href) => href !== null);
|
|
3600
|
+
if (candidates.length === 0) return null;
|
|
3601
|
+
return candidates.reduce(
|
|
3602
|
+
(longest, href) => href.length > longest.length ? href : longest
|
|
3603
|
+
);
|
|
3052
3604
|
}
|
|
3053
3605
|
var MAX_TABS = 4;
|
|
3054
3606
|
function tabAreas(areas, tabs) {
|
|
@@ -3069,7 +3621,8 @@ function useUnread() {
|
|
|
3069
3621
|
return useUnreadCount(help, shell.help.unread);
|
|
3070
3622
|
}
|
|
3071
3623
|
function MobileTopBar() {
|
|
3072
|
-
const { shell, t, openContext, toggleHelp, setOverlay, openCreate, canCreate } = useShell();
|
|
3624
|
+
const { shell, t, openContext, toggleHelp, setOverlay, openCreate, canCreate, overlay } = useShell();
|
|
3625
|
+
const apps = useRef(null);
|
|
3073
3626
|
const levels = shell.context.levels;
|
|
3074
3627
|
const organization = levels[0];
|
|
3075
3628
|
const { top, main } = pillLines(levels);
|
|
@@ -3094,6 +3647,8 @@ function MobileTopBar() {
|
|
|
3094
3647
|
unread > 0 && /* @__PURE__ */ jsx("span", { className: "cbx-m-dot", "aria-hidden": "true" })
|
|
3095
3648
|
] }),
|
|
3096
3649
|
/* @__PURE__ */ jsx("button", { type: "button", className: "cbx-m-icon", onClick: () => setOverlay("palette"), "aria-label": t("Search and commands"), "aria-haspopup": "dialog", children: /* @__PURE__ */ jsx(Search, { size: 21, strokeWidth: 1.8, "aria-hidden": true }) }),
|
|
3650
|
+
/* @__PURE__ */ jsx("button", { ref: apps, type: "button", className: "cbx-m-icon", onClick: () => setOverlay(overlay === "apps" ? null : "apps"), "aria-label": t("Switch app"), "aria-haspopup": "dialog", "aria-expanded": overlay === "apps", children: /* @__PURE__ */ jsx(LayoutGrid, { size: 20, strokeWidth: 1.8, "aria-hidden": true }) }),
|
|
3651
|
+
/* @__PURE__ */ jsx(Popover, { open: overlay === "apps", anchor: apps, placement: "bottom-end", label: t("Switch app"), onClose: () => setOverlay(null), children: /* @__PURE__ */ jsx(AppGrid, {}) }),
|
|
3097
3652
|
canCreate && /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-m-icon is-primary", onClick: () => openCreate(), "aria-haspopup": "dialog", "aria-label": createLabel(shell, t), children: /* @__PURE__ */ jsx(Plus, { size: 22, strokeWidth: 2, "aria-hidden": true }) })
|
|
3098
3653
|
] });
|
|
3099
3654
|
}
|
|
@@ -3102,27 +3657,12 @@ function MobileAreaHead() {
|
|
|
3102
3657
|
const area = shell.nav.areas.find((item) => item.key === shell.nav.activeArea);
|
|
3103
3658
|
const pages = area?.pages ?? [];
|
|
3104
3659
|
const environment = notLiveEnvironment(shell.context.levels);
|
|
3105
|
-
const strip = useRef(null);
|
|
3106
|
-
useEffect(() => {
|
|
3107
|
-
const list = strip.current;
|
|
3108
|
-
const current = list?.querySelector('[aria-current="page"]');
|
|
3109
|
-
if (list === null || list === void 0 || current === null || current === void 0) return;
|
|
3110
|
-
const overflow = current.offsetLeft + current.offsetWidth - list.clientWidth;
|
|
3111
|
-
if (overflow > 0) list.scrollLeft = overflow + 32;
|
|
3112
|
-
}, [shell.nav.activePage, shell.nav.activeArea]);
|
|
3113
3660
|
return /* @__PURE__ */ jsxs("div", { className: "cbx-m-head", children: [
|
|
3114
|
-
area !== void 0 && /* @__PURE__ */ jsx("p", { className: "cbx-m-title", children: area.label }),
|
|
3115
3661
|
environment !== null && /* @__PURE__ */ jsxs("div", { className: `cbx-m-env cbx-env-${environment.tone ?? "neutral"}`, role: "status", children: [
|
|
3116
3662
|
/* @__PURE__ */ jsx(ToneSquare, { tone: environment.tone }),
|
|
3117
3663
|
/* @__PURE__ */ jsx("span", { children: t("{environment}. Not production, nothing here touches live customers.", { environment: environment.name }) })
|
|
3118
3664
|
] }),
|
|
3119
|
-
area !== void 0 && pages.length > 1 ? /* @__PURE__ */ jsx("
|
|
3120
|
-
const on = page.key === shell.nav.activePage;
|
|
3121
|
-
return /* @__PURE__ */ jsxs(Link, { href: navUrl(page), className: `cbx-m-chip ${on ? "is-on" : ""}`, "aria-current": on ? "page" : void 0, children: [
|
|
3122
|
-
page.label,
|
|
3123
|
-
page.locked === true && /* @__PURE__ */ jsx(NavPageMarks, { page })
|
|
3124
|
-
] }, page.key);
|
|
3125
|
-
}) }) : /* @__PURE__ */ jsx("div", { className: "cbx-m-chips-gap" })
|
|
3665
|
+
area !== void 0 && pages.length > 1 ? /* @__PURE__ */ jsx("div", { className: "cbx-m-section-nav", children: /* @__PURE__ */ jsx(PageTabs, { items: pages.map((page) => ({ href: navUrl(page), label: `${area.label} \xB7 ${page.label}`, badge: page.locked ? /* @__PURE__ */ jsx(NavPageMarks, { page }) : void 0 })), currentPath: navUrl(pages.find((page) => page.key === shell.nav.activePage) ?? pages[0]), LinkComponent: (props) => /* @__PURE__ */ jsx(Link, { href: props.href, className: props.className, "aria-current": props["aria-current"], children: props.children }) }) }) : /* @__PURE__ */ jsx("div", { className: "cbx-m-chips-gap" })
|
|
3126
3666
|
] });
|
|
3127
3667
|
}
|
|
3128
3668
|
function TabBar({ onMore }) {
|
|
@@ -3432,7 +3972,7 @@ function ContextSheet({ onClose }) {
|
|
|
3432
3972
|
if (environment !== void 0) {
|
|
3433
3973
|
const index = levels.indexOf(environment);
|
|
3434
3974
|
const parent = levels[index - 1];
|
|
3435
|
-
return /* @__PURE__ */ jsx(
|
|
3975
|
+
return /* @__PURE__ */ jsx(Sheet2, { label: parent !== void 0 && index > 0 ? t("{things} in {name}", { things: pluralOf(environment), name: parent.current.name }) : pluralOf(environment), size: "tall", onClose, back: { label: t("Back"), onBack: back }, children: /* @__PURE__ */ jsx(EnvironmentList, { level: environment, parent: index > 0 ? parent?.current.id : void 0, parentName: index > 0 ? parent?.current.name : void 0, onPick: (item) => switchTo(parent !== void 0 && index > 0 ? { [parent.key]: parent.current.id, [environment.key]: item.id } : { [environment.key]: item.id }) }) });
|
|
3436
3976
|
}
|
|
3437
3977
|
}
|
|
3438
3978
|
const level = levels.find((item) => item.key === step);
|
|
@@ -3440,7 +3980,7 @@ function ContextSheet({ onClose }) {
|
|
|
3440
3980
|
const index = levels.indexOf(level);
|
|
3441
3981
|
const parent = index > 0 ? levels[index - 1] : void 0;
|
|
3442
3982
|
const inner = levels[index + 1];
|
|
3443
|
-
return /* @__PURE__ */ jsx(
|
|
3983
|
+
return /* @__PURE__ */ jsx(Sheet2, { label: level.label, size: "tall", onClose, back: { label: t("Back"), onBack: back }, children: /* @__PURE__ */ jsx("div", { className: "cbx-sheet-level", children: /* @__PURE__ */ jsx(
|
|
3444
3984
|
LevelPane,
|
|
3445
3985
|
{
|
|
3446
3986
|
level,
|
|
@@ -3452,7 +3992,7 @@ function ContextSheet({ onClose }) {
|
|
|
3452
3992
|
}
|
|
3453
3993
|
) }) });
|
|
3454
3994
|
}
|
|
3455
|
-
return /* @__PURE__ */ jsx(
|
|
3995
|
+
return /* @__PURE__ */ jsx(Sheet2, { label: t("Where you work"), onClose, children: /* @__PURE__ */ jsx(ContextRoot, { onStep: setStep }) });
|
|
3456
3996
|
}
|
|
3457
3997
|
function ContextRoot({ onStep }) {
|
|
3458
3998
|
const { shell, t, switchTo } = useShell();
|
|
@@ -3536,7 +4076,7 @@ function EnvironmentList({ level, parent, parentName, onPick }) {
|
|
|
3536
4076
|
}
|
|
3537
4077
|
function AppsSheet({ onClose }) {
|
|
3538
4078
|
const { t } = useShell();
|
|
3539
|
-
return /* @__PURE__ */ jsx(
|
|
4079
|
+
return /* @__PURE__ */ jsx(Sheet2, { label: t("Switch app"), onClose, children: /* @__PURE__ */ jsx(AppGrid, { autoFocus: false }) });
|
|
3540
4080
|
}
|
|
3541
4081
|
function MobilePage({ hidden, children }) {
|
|
3542
4082
|
const box = useRef(null);
|
|
@@ -3546,7 +4086,7 @@ function MobilePage({ hidden, children }) {
|
|
|
3546
4086
|
if (page === null) return;
|
|
3547
4087
|
const mark = () => {
|
|
3548
4088
|
for (const heading of page.querySelectorAll("[data-cbx-page-title]")) {
|
|
3549
|
-
const same = title !== null
|
|
4089
|
+
const same = title !== null;
|
|
3550
4090
|
if (same !== heading.hasAttribute("data-cbx-same-title")) heading.toggleAttribute("data-cbx-same-title", same);
|
|
3551
4091
|
}
|
|
3552
4092
|
};
|
|
@@ -4287,7 +4827,7 @@ function Combobox(props) {
|
|
|
4287
4827
|
children: activeOption !== null && activeOption !== void 0 ? activeOption.label : placeholder
|
|
4288
4828
|
}
|
|
4289
4829
|
),
|
|
4290
|
-
/* @__PURE__ */ jsx(
|
|
4830
|
+
/* @__PURE__ */ jsx(Chevron2, { open })
|
|
4291
4831
|
]
|
|
4292
4832
|
}
|
|
4293
4833
|
),
|
|
@@ -4559,7 +5099,7 @@ function nextEnabledIndex(options, current, direction) {
|
|
|
4559
5099
|
}
|
|
4560
5100
|
return -1;
|
|
4561
5101
|
}
|
|
4562
|
-
function
|
|
5102
|
+
function Chevron2({ open }) {
|
|
4563
5103
|
return /* @__PURE__ */ jsx(
|
|
4564
5104
|
"svg",
|
|
4565
5105
|
{
|
|
@@ -4770,8 +5310,6 @@ function PageHeader({
|
|
|
4770
5310
|
}) {
|
|
4771
5311
|
const { t } = useCboxLocalization();
|
|
4772
5312
|
const shellHelp = useShellHelp();
|
|
4773
|
-
const shellTitle = useShellPageTitle();
|
|
4774
|
-
const duplicate = shellTitle !== null && typeof title === "string" && sameTitle(title, shellTitle);
|
|
4775
5313
|
return /* @__PURE__ */ jsxs(
|
|
4776
5314
|
"header",
|
|
4777
5315
|
{
|
|
@@ -4782,7 +5320,7 @@ function PageHeader({
|
|
|
4782
5320
|
children: [
|
|
4783
5321
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
4784
5322
|
eyebrow !== void 0 ? /* @__PURE__ */ jsx("p", { className: "text-mono text-[10px] font-semibold tracking-[0.18em] text-muted-foreground uppercase", children: eyebrow }) : null,
|
|
4785
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", "data-cbx-same-title":
|
|
5323
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", "data-cbx-same-title": void 0, children: [
|
|
4786
5324
|
/* @__PURE__ */ jsx("h1", { className: "text-2xl leading-tight font-semibold tracking-tight text-foreground", children: title }),
|
|
4787
5325
|
help && shellHelp !== null ? /* @__PURE__ */ jsx(
|
|
4788
5326
|
"button",
|
|
@@ -4816,278 +5354,23 @@ var widthClass = {
|
|
|
4816
5354
|
full: "max-w-none px-6 py-8 lg:px-10 lg:py-10",
|
|
4817
5355
|
bleed: "max-w-none p-0"
|
|
4818
5356
|
};
|
|
4819
|
-
function PageShell({
|
|
4820
|
-
children,
|
|
4821
|
-
width = "comfortable",
|
|
4822
|
-
className
|
|
4823
|
-
}) {
|
|
4824
|
-
return /* @__PURE__ */ jsx(
|
|
4825
|
-
"div",
|
|
4826
|
-
{
|
|
4827
|
-
className: cn(
|
|
4828
|
-
"mx-auto w-full space-y-6",
|
|
4829
|
-
widthClass[width],
|
|
4830
|
-
className
|
|
4831
|
-
),
|
|
4832
|
-
children
|
|
4833
|
-
}
|
|
4834
|
-
);
|
|
4835
|
-
}
|
|
4836
|
-
var DefaultLink = ({ href, className, children, "aria-current": ariaCurrent }) => /* @__PURE__ */ jsx("a", { href, className, "aria-current": ariaCurrent, children });
|
|
4837
|
-
function PageTabs({
|
|
4838
|
-
items,
|
|
4839
|
-
currentPath,
|
|
4840
|
-
LinkComponent = DefaultLink,
|
|
4841
|
-
actions,
|
|
4842
|
-
className
|
|
4843
|
-
}) {
|
|
4844
|
-
const activeHref = resolveActiveHref(items, currentPath);
|
|
4845
|
-
return /* @__PURE__ */ jsxs(
|
|
4846
|
-
"div",
|
|
4847
|
-
{
|
|
4848
|
-
"data-component": "page-tabs",
|
|
4849
|
-
className: cn(
|
|
4850
|
-
// Card-style chrome — same border, radius, bg as DataPanel
|
|
4851
|
-
// so the tab strip reads as a peer of the content panels
|
|
4852
|
-
// beneath it instead of floating on the page background.
|
|
4853
|
-
// Width matches PageShell content; no sticky positioning.
|
|
4854
|
-
"rounded-lg border border-border bg-card",
|
|
4855
|
-
className
|
|
4856
|
-
),
|
|
4857
|
-
children: [
|
|
4858
|
-
/* @__PURE__ */ jsxs("div", { className: "hidden items-end gap-3 px-3 sm:flex", children: [
|
|
4859
|
-
/* @__PURE__ */ jsx(
|
|
4860
|
-
DesktopStrip,
|
|
4861
|
-
{
|
|
4862
|
-
items,
|
|
4863
|
-
activeHref,
|
|
4864
|
-
LinkComponent
|
|
4865
|
-
}
|
|
4866
|
-
),
|
|
4867
|
-
/* @__PURE__ */ jsx("div", { className: "flex min-h-12 shrink-0 items-center gap-2", children: actions })
|
|
4868
|
-
] }),
|
|
4869
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-3 sm:hidden", children: [
|
|
4870
|
-
/* @__PURE__ */ jsx(
|
|
4871
|
-
MobileDropdown,
|
|
4872
|
-
{
|
|
4873
|
-
items,
|
|
4874
|
-
activeHref,
|
|
4875
|
-
LinkComponent
|
|
4876
|
-
}
|
|
4877
|
-
),
|
|
4878
|
-
actions !== void 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions }) : null
|
|
4879
|
-
] })
|
|
4880
|
-
]
|
|
4881
|
-
}
|
|
4882
|
-
);
|
|
4883
|
-
}
|
|
4884
|
-
function DesktopStrip({ items, activeHref, LinkComponent }) {
|
|
4885
|
-
const { t } = useCboxLocalization();
|
|
4886
|
-
return /* @__PURE__ */ jsx(
|
|
4887
|
-
"nav",
|
|
4888
|
-
{
|
|
4889
|
-
className: "flex min-h-12 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden py-1.5",
|
|
4890
|
-
role: "tablist",
|
|
4891
|
-
"aria-label": t("Section navigation"),
|
|
4892
|
-
children: items.map((item) => {
|
|
4893
|
-
const Icon = item.icon;
|
|
4894
|
-
const active = item.href === activeHref;
|
|
4895
|
-
return /* @__PURE__ */ jsxs(
|
|
4896
|
-
LinkComponent,
|
|
4897
|
-
{
|
|
4898
|
-
href: item.href,
|
|
4899
|
-
prefetch: true,
|
|
4900
|
-
"aria-current": active ? "page" : void 0,
|
|
4901
|
-
className: cn(
|
|
4902
|
-
"inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 text-[13px] whitespace-nowrap transition-colors",
|
|
4903
|
-
active ? "bg-secondary font-semibold text-foreground shadow-sm ring-1 ring-border-strong/60" : "text-muted-foreground hover:bg-secondary/60 hover:text-foreground"
|
|
4904
|
-
),
|
|
4905
|
-
children: [
|
|
4906
|
-
Icon !== void 0 ? /* @__PURE__ */ jsx(
|
|
4907
|
-
Icon,
|
|
4908
|
-
{
|
|
4909
|
-
className: cn(
|
|
4910
|
-
"h-3.5 w-3.5 shrink-0",
|
|
4911
|
-
active ? "text-foreground" : "text-muted-foreground"
|
|
4912
|
-
),
|
|
4913
|
-
strokeWidth: 1.7
|
|
4914
|
-
}
|
|
4915
|
-
) : null,
|
|
4916
|
-
/* @__PURE__ */ jsx("span", { children: item.label }),
|
|
4917
|
-
/* @__PURE__ */ jsx(ItemTrailing, { item, active })
|
|
4918
|
-
]
|
|
4919
|
-
},
|
|
4920
|
-
item.href
|
|
4921
|
-
);
|
|
4922
|
-
})
|
|
4923
|
-
}
|
|
4924
|
-
);
|
|
4925
|
-
}
|
|
4926
|
-
function MobileDropdown({ items, activeHref, LinkComponent }) {
|
|
4927
|
-
const { t } = useCboxLocalization();
|
|
4928
|
-
const [open, setOpen] = useState(false);
|
|
4929
|
-
const ref = useRef(null);
|
|
4930
|
-
const listId = useId();
|
|
4931
|
-
const active = items.find((item) => item.href === activeHref) ?? items[0];
|
|
4932
|
-
useEffect(() => {
|
|
4933
|
-
if (!open) return;
|
|
4934
|
-
function onPointerDown(event) {
|
|
4935
|
-
if (ref.current !== null && !ref.current.contains(event.target)) {
|
|
4936
|
-
setOpen(false);
|
|
4937
|
-
}
|
|
4938
|
-
}
|
|
4939
|
-
function onKey(event) {
|
|
4940
|
-
if (event.key === "Escape") setOpen(false);
|
|
4941
|
-
}
|
|
4942
|
-
window.addEventListener("pointerdown", onPointerDown);
|
|
4943
|
-
window.addEventListener("keydown", onKey);
|
|
4944
|
-
return () => {
|
|
4945
|
-
window.removeEventListener("pointerdown", onPointerDown);
|
|
4946
|
-
window.removeEventListener("keydown", onKey);
|
|
4947
|
-
};
|
|
4948
|
-
}, [open]);
|
|
4949
|
-
if (active === void 0) {
|
|
4950
|
-
return null;
|
|
4951
|
-
}
|
|
4952
|
-
const ActiveIcon = active.icon;
|
|
4953
|
-
return /* @__PURE__ */ jsxs("div", { ref, className: "relative", children: [
|
|
4954
|
-
/* @__PURE__ */ jsxs(
|
|
4955
|
-
"button",
|
|
4956
|
-
{
|
|
4957
|
-
type: "button",
|
|
4958
|
-
onClick: () => setOpen((v) => !v),
|
|
4959
|
-
"aria-expanded": open,
|
|
4960
|
-
"aria-haspopup": "listbox",
|
|
4961
|
-
"aria-controls": listId,
|
|
4962
|
-
className: cn(
|
|
4963
|
-
"flex w-full min-h-11 items-center justify-between gap-2 rounded-md border border-border bg-card px-3 text-left text-[13px] font-medium text-foreground transition-colors hover:border-border-strong",
|
|
4964
|
-
open && "border-border-strong ring-2 ring-ring/30"
|
|
4965
|
-
),
|
|
4966
|
-
children: [
|
|
4967
|
-
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
4968
|
-
ActiveIcon !== void 0 ? /* @__PURE__ */ jsx(
|
|
4969
|
-
ActiveIcon,
|
|
4970
|
-
{
|
|
4971
|
-
className: "h-3.5 w-3.5 shrink-0 text-muted-foreground",
|
|
4972
|
-
strokeWidth: 1.7
|
|
4973
|
-
}
|
|
4974
|
-
) : null,
|
|
4975
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: active.label }),
|
|
4976
|
-
/* @__PURE__ */ jsx(ItemTrailing, { item: active, active: true })
|
|
4977
|
-
] }),
|
|
4978
|
-
/* @__PURE__ */ jsx(Chevron2, { open })
|
|
4979
|
-
]
|
|
4980
|
-
}
|
|
4981
|
-
),
|
|
4982
|
-
open ? /* @__PURE__ */ jsx(
|
|
4983
|
-
"ul",
|
|
4984
|
-
{
|
|
4985
|
-
id: listId,
|
|
4986
|
-
role: "listbox",
|
|
4987
|
-
"aria-label": t("Section navigation"),
|
|
4988
|
-
className: "absolute left-0 right-0 top-full z-30 mt-1 overflow-hidden rounded-md border border-border bg-popover shadow-lg",
|
|
4989
|
-
children: items.map((item) => {
|
|
4990
|
-
const Icon = item.icon;
|
|
4991
|
-
const isActive = item.href === activeHref;
|
|
4992
|
-
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
4993
|
-
LinkComponent,
|
|
4994
|
-
{
|
|
4995
|
-
href: item.href,
|
|
4996
|
-
prefetch: true,
|
|
4997
|
-
"aria-current": isActive ? "page" : void 0,
|
|
4998
|
-
className: cn(
|
|
4999
|
-
"flex w-full items-center gap-2 px-3 py-2.5 text-[13px] transition-colors",
|
|
5000
|
-
isActive ? "bg-accent-soft font-semibold text-foreground" : "text-muted-foreground hover:bg-secondary hover:text-foreground"
|
|
5001
|
-
),
|
|
5002
|
-
children: [
|
|
5003
|
-
Icon !== void 0 ? /* @__PURE__ */ jsx(
|
|
5004
|
-
Icon,
|
|
5005
|
-
{
|
|
5006
|
-
className: cn(
|
|
5007
|
-
"h-3.5 w-3.5 shrink-0",
|
|
5008
|
-
isActive ? "text-foreground" : "text-muted-foreground"
|
|
5009
|
-
),
|
|
5010
|
-
strokeWidth: 1.7
|
|
5011
|
-
}
|
|
5012
|
-
) : null,
|
|
5013
|
-
/* @__PURE__ */ jsx("span", { className: "flex-1 truncate", children: item.label }),
|
|
5014
|
-
/* @__PURE__ */ jsx(
|
|
5015
|
-
ItemTrailing,
|
|
5016
|
-
{
|
|
5017
|
-
item,
|
|
5018
|
-
active: isActive
|
|
5019
|
-
}
|
|
5020
|
-
)
|
|
5021
|
-
]
|
|
5022
|
-
}
|
|
5023
|
-
) }, item.href);
|
|
5024
|
-
})
|
|
5025
|
-
}
|
|
5026
|
-
) : null
|
|
5027
|
-
] });
|
|
5028
|
-
}
|
|
5029
|
-
function ItemTrailing({
|
|
5030
|
-
item,
|
|
5031
|
-
active
|
|
5032
|
-
}) {
|
|
5033
|
-
if (item.badge !== void 0) {
|
|
5034
|
-
return /* @__PURE__ */ jsx("span", { className: "ml-1 shrink-0", children: item.badge });
|
|
5035
|
-
}
|
|
5036
|
-
if (item.count !== void 0) {
|
|
5037
|
-
return /* @__PURE__ */ jsx(
|
|
5038
|
-
"span",
|
|
5039
|
-
{
|
|
5040
|
-
className: cn(
|
|
5041
|
-
"ml-1 shrink-0 rounded-sm border px-1 text-[10px] font-semibold tracking-tight tabular-nums",
|
|
5042
|
-
active ? "border-border-strong bg-secondary text-foreground" : "border-border bg-secondary/60 text-muted-foreground"
|
|
5043
|
-
),
|
|
5044
|
-
children: item.count
|
|
5045
|
-
}
|
|
5046
|
-
);
|
|
5047
|
-
}
|
|
5048
|
-
return null;
|
|
5049
|
-
}
|
|
5050
|
-
function Chevron2({ open }) {
|
|
5357
|
+
function PageShell({
|
|
5358
|
+
children,
|
|
5359
|
+
width = "comfortable",
|
|
5360
|
+
className
|
|
5361
|
+
}) {
|
|
5051
5362
|
return /* @__PURE__ */ jsx(
|
|
5052
|
-
"
|
|
5363
|
+
"div",
|
|
5053
5364
|
{
|
|
5054
|
-
width: "14",
|
|
5055
|
-
height: "14",
|
|
5056
|
-
viewBox: "0 0 14 14",
|
|
5057
|
-
fill: "none",
|
|
5058
|
-
stroke: "currentColor",
|
|
5059
|
-
strokeWidth: "1.6",
|
|
5060
|
-
strokeLinecap: "round",
|
|
5061
|
-
strokeLinejoin: "round",
|
|
5062
5365
|
className: cn(
|
|
5063
|
-
"
|
|
5064
|
-
|
|
5366
|
+
"mx-auto w-full space-y-6",
|
|
5367
|
+
widthClass[width],
|
|
5368
|
+
className
|
|
5065
5369
|
),
|
|
5066
|
-
|
|
5067
|
-
children: /* @__PURE__ */ jsx("path", { d: "m3.5 5.5 3.5 3.5 3.5-3.5" })
|
|
5370
|
+
children
|
|
5068
5371
|
}
|
|
5069
5372
|
);
|
|
5070
5373
|
}
|
|
5071
|
-
function pathOnly(href) {
|
|
5072
|
-
const queryIndex = href.indexOf("?");
|
|
5073
|
-
const hashIndex = href.indexOf("#");
|
|
5074
|
-
let end = href.length;
|
|
5075
|
-
if (queryIndex !== -1) end = Math.min(end, queryIndex);
|
|
5076
|
-
if (hashIndex !== -1) end = Math.min(end, hashIndex);
|
|
5077
|
-
return href.slice(0, end);
|
|
5078
|
-
}
|
|
5079
|
-
function resolveActiveHref(items, currentPath) {
|
|
5080
|
-
const current = pathOnly(currentPath);
|
|
5081
|
-
const candidates = items.map((item) => {
|
|
5082
|
-
const itemPath = pathOnly(item.href);
|
|
5083
|
-
const matched = item.matchPrefix === true ? current === itemPath || current.startsWith(itemPath + "/") : current === itemPath;
|
|
5084
|
-
return matched ? item.href : null;
|
|
5085
|
-
}).filter((href) => href !== null);
|
|
5086
|
-
if (candidates.length === 0) return null;
|
|
5087
|
-
return candidates.reduce(
|
|
5088
|
-
(longest, href) => href.length > longest.length ? href : longest
|
|
5089
|
-
);
|
|
5090
|
-
}
|
|
5091
5374
|
var DefaultLink2 = ({ href, className, children }) => /* @__PURE__ */ jsx("a", { href, className, children });
|
|
5092
5375
|
function RowLink({
|
|
5093
5376
|
href,
|
|
@@ -5222,65 +5505,6 @@ function StatusPill({
|
|
|
5222
5505
|
}
|
|
5223
5506
|
);
|
|
5224
5507
|
}
|
|
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
5508
|
function Checkbox({ checked, onCheckedChange, label, hint, disabled = false, required, name, value, id: statedId, className }) {
|
|
5285
5509
|
const generated = useId();
|
|
5286
5510
|
const id = statedId ?? generated;
|
|
@@ -5318,175 +5542,6 @@ function Checkbox({ checked, onCheckedChange, label, hint, disabled = false, req
|
|
|
5318
5542
|
] })
|
|
5319
5543
|
] });
|
|
5320
5544
|
}
|
|
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
5545
|
var FieldContext = createContext(null);
|
|
5491
5546
|
function useFieldControl() {
|
|
5492
5547
|
const field = useContext(FieldContext);
|
|
@@ -6087,6 +6142,6 @@ function Sparkline({ values, color = "var(--chart-1)", width = 90, height = 20 }
|
|
|
6087
6142
|
] });
|
|
6088
6143
|
}
|
|
6089
6144
|
|
|
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 };
|
|
6145
|
+
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, Sheet, SheetClose, 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, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
|
|
6091
6146
|
//# sourceMappingURL=index.js.map
|
|
6092
6147
|
//# sourceMappingURL=index.js.map
|