@xenosystem/elements-react 0.0.10 → 0.0.12

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.
Files changed (89) hide show
  1. package/dist/containers/Avatar.d.ts +8 -1
  2. package/dist/containers/Avatar.js +3 -3
  3. package/dist/containers/BulkActionBar.d.ts +20 -0
  4. package/dist/containers/BulkActionBar.js +8 -0
  5. package/dist/containers/DataTable.d.ts +50 -6
  6. package/dist/containers/DataTable.js +185 -11
  7. package/dist/containers/Table.d.ts +2 -2
  8. package/dist/containers/Table.js +4 -3
  9. package/dist/content/Kbd.d.ts +16 -0
  10. package/dist/content/Kbd.js +8 -0
  11. package/dist/forms/FormField.d.ts +32 -0
  12. package/dist/forms/FormField.js +26 -0
  13. package/dist/forms/NumberInput.d.ts +27 -0
  14. package/dist/forms/NumberInput.js +69 -0
  15. package/dist/forms/Select.d.ts +84 -0
  16. package/dist/forms/Select.js +243 -0
  17. package/dist/forms/Slider.d.ts +38 -0
  18. package/dist/forms/Slider.js +31 -0
  19. package/dist/index.d.ts +20 -1
  20. package/dist/index.js +20 -1
  21. package/dist/nav/Breadcrumb.d.ts +22 -0
  22. package/dist/nav/Breadcrumb.js +10 -0
  23. package/dist/nav/Pagination.d.ts +22 -0
  24. package/dist/nav/Pagination.js +35 -0
  25. package/dist/overlays/CommandPalette.d.ts +43 -0
  26. package/dist/overlays/CommandPalette.js +96 -0
  27. package/dist/overlays/Drawer.d.ts +30 -0
  28. package/dist/overlays/Drawer.js +41 -0
  29. package/dist/overlays/Popover.d.ts +27 -12
  30. package/dist/overlays/Popover.js +104 -7
  31. package/dist/overlays/ShortcutsSheet.d.ts +21 -0
  32. package/dist/overlays/ShortcutsSheet.js +7 -0
  33. package/dist/overlays/Tooltip.d.ts +21 -10
  34. package/dist/overlays/Tooltip.js +93 -9
  35. package/dist/shortcuts.d.ts +45 -0
  36. package/dist/shortcuts.js +164 -0
  37. package/dist/status/Banner.d.ts +23 -0
  38. package/dist/status/Banner.js +8 -0
  39. package/dist/status/EmptyState.d.ts +20 -0
  40. package/dist/status/EmptyState.js +9 -0
  41. package/dist/status/Skeleton.d.ts +36 -0
  42. package/dist/status/Skeleton.js +31 -0
  43. package/dist/status/Toast.d.ts +28 -0
  44. package/dist/status/Toast.js +11 -0
  45. package/dist/uiTree.d.ts +53 -0
  46. package/dist/uiTree.js +197 -0
  47. package/dist/useDialog.d.ts +3 -1
  48. package/dist/useDialog.js +37 -1
  49. package/dist/useMenu.js +31 -1
  50. package/dist/useToastQueue.d.ts +29 -0
  51. package/dist/useToastQueue.js +73 -0
  52. package/package.json +9 -3
  53. package/src/chrome-separated.css +133 -72
  54. package/src/chrome-unified.css +48 -16
  55. package/src/containers/Badges.css +52 -28
  56. package/src/containers/avatar.css +7 -2
  57. package/src/containers/bulk-action-bar.css +45 -0
  58. package/src/containers/card.css +14 -13
  59. package/src/containers/chip.css +1 -1
  60. package/src/containers/panel.css +16 -53
  61. package/src/containers/table.css +107 -1
  62. package/src/content/kbd.css +33 -0
  63. package/src/content/model-picker.css +2 -1
  64. package/src/controls.css +25 -11
  65. package/src/fonts.css +8 -2
  66. package/src/forced-colors.css +41 -0
  67. package/src/forms/form-field.css +78 -0
  68. package/src/forms/number-input.css +86 -0
  69. package/src/forms/select.css +210 -0
  70. package/src/forms/slider.css +145 -0
  71. package/src/layout-platform.css +495 -0
  72. package/src/mcp-app-platform.css +1019 -0
  73. package/src/nav/breadcrumb.css +84 -0
  74. package/src/nav/pagination.css +61 -0
  75. package/src/overlays/command-palette.css +157 -0
  76. package/src/overlays/drawer.css +79 -0
  77. package/src/overlays/menu.css +25 -16
  78. package/src/overlays/modal.css +9 -27
  79. package/src/overlays/onboarding.css +1305 -0
  80. package/src/overlays/segmented-control.css +6 -3
  81. package/src/overlays/shortcuts-sheet.css +55 -0
  82. package/src/overlays/tooltip.css +22 -4
  83. package/src/size.css +40 -0
  84. package/src/status/banner.css +83 -0
  85. package/src/status/empty-state.css +56 -0
  86. package/src/status/skeleton.css +70 -0
  87. package/src/status/toast.css +95 -0
  88. package/src/xeno-elements.css +71 -44
  89. package/src/xeno-theme.css +75 -31
@@ -0,0 +1,45 @@
1
+ import type { CommandPaletteItem } from './overlays/CommandPalette.js';
2
+ import type { ShortcutSection } from './overlays/ShortcutsSheet.js';
3
+ /**
4
+ * Unified Keyboard-Shortcut Registry — single source of truth for global keyboard chords
5
+ * (`mod+k`, `?`, `mod+j`) and Linear-style two-key sequences (`g o`, `g s`), plus deterministic
6
+ * collision detection and zero-drift derivation of `ShortcutsSheet` sections & `CommandPalette` items.
7
+ */
8
+ export interface ShortcutBinding {
9
+ readonly id: string;
10
+ /** Canonical chord (`mod+k`, `?`, `shift+d`) or space-separated sequence (`g o`, `g s`). */
11
+ readonly chord: string;
12
+ readonly label: string;
13
+ readonly group: string;
14
+ /** Optional keywords for CommandPalette fuzzy filtering. */
15
+ readonly keywords?: readonly string[];
16
+ /** Allow firing even when focus is inside an input/textarea (default `true` for `mod+` chords, `false` otherwise). */
17
+ readonly allowInInputs?: boolean;
18
+ readonly disabled?: boolean;
19
+ readonly onTrigger: () => void;
20
+ }
21
+ export interface ShortcutCollision {
22
+ readonly chord: string;
23
+ readonly ids: readonly string[];
24
+ }
25
+ /** Convert a canonical chord string (`mod+k`, `g s`) into display keycaps (`['⌘', 'K']`, `['G', 'S']`). */
26
+ export declare function formatShortcutKeys(chord: string): readonly string[];
27
+ /** Detect duplicate chords or sequence-prefix conflicts across all registered bindings. */
28
+ export declare function detectShortcutCollisions(bindings: readonly ShortcutBinding[]): readonly ShortcutCollision[];
29
+ /** Derive `ShortcutsSheet` sections directly from the live shortcut registry (zero drift). */
30
+ export declare function toShortcutSections(bindings: readonly ShortcutBinding[]): readonly ShortcutSection[];
31
+ /** Derive `CommandPalette` items directly from the live shortcut registry (zero drift). */
32
+ export declare function toCommandItems(bindings: readonly ShortcutBinding[]): readonly CommandPaletteItem[];
33
+ export interface UseShortcutRegistryResult {
34
+ readonly sections: readonly ShortcutSection[];
35
+ readonly commandItems: readonly CommandPaletteItem[];
36
+ readonly collisions: readonly ShortcutCollision[];
37
+ }
38
+ /**
39
+ * Bind a unified set of keyboard shortcuts on `window` (supporting chords and 2-key sequences)
40
+ * and return derived `ShortcutsSheet` sections, `CommandPalette` items, and any detected collisions.
41
+ */
42
+ export declare function useShortcutRegistry(bindings: readonly ShortcutBinding[], options?: {
43
+ readonly enabled?: boolean;
44
+ readonly sequenceTimeoutMs?: number;
45
+ }): UseShortcutRegistryResult;
@@ -0,0 +1,164 @@
1
+ import { useEffect, useMemo, useRef } from 'react';
2
+ const MOD_KEYS = new Set(['mod', 'ctrl', 'meta', 'alt', 'shift']);
3
+ const normalizeChord = (raw) => raw
4
+ .trim()
5
+ .toLowerCase()
6
+ .split(/\s+/)
7
+ .map((step) => {
8
+ const parts = step.split('+').filter(Boolean);
9
+ const mods = parts.filter((p) => MOD_KEYS.has(p)).sort();
10
+ const key = parts.find((p) => !MOD_KEYS.has(p)) ?? '';
11
+ return [...mods, key].filter(Boolean).join('+');
12
+ })
13
+ .join(' ');
14
+ /** Convert a canonical chord string (`mod+k`, `g s`) into display keycaps (`['⌘', 'K']`, `['G', 'S']`). */
15
+ export function formatShortcutKeys(chord) {
16
+ const norm = normalizeChord(chord);
17
+ return norm.split(' ').flatMap((step) => step.split('+').map((part) => {
18
+ if (part === 'mod' || part === 'meta')
19
+ return '⌘';
20
+ if (part === 'ctrl')
21
+ return 'Ctrl';
22
+ if (part === 'alt')
23
+ return '⌥';
24
+ if (part === 'shift')
25
+ return '⇧';
26
+ if (part === 'enter')
27
+ return '↵';
28
+ if (part === 'escape' || part === 'esc')
29
+ return 'Esc';
30
+ if (part === 'backspace')
31
+ return '⌫';
32
+ return part.length === 1 ? part.toUpperCase() : part;
33
+ }));
34
+ }
35
+ /** Detect duplicate chords or sequence-prefix conflicts across all registered bindings. */
36
+ export function detectShortcutCollisions(bindings) {
37
+ const byChord = new Map();
38
+ for (const b of bindings) {
39
+ if (b.disabled)
40
+ continue;
41
+ const key = normalizeChord(b.chord);
42
+ const list = byChord.get(key) ?? [];
43
+ list.push(b.id);
44
+ byChord.set(key, list);
45
+ }
46
+ const collisions = [];
47
+ for (const [chord, ids] of byChord) {
48
+ if (ids.length > 1)
49
+ collisions.push({ chord, ids });
50
+ }
51
+ return collisions;
52
+ }
53
+ /** Derive `ShortcutsSheet` sections directly from the live shortcut registry (zero drift). */
54
+ export function toShortcutSections(bindings) {
55
+ const grouped = new Map();
56
+ for (const b of bindings) {
57
+ if (b.disabled)
58
+ continue;
59
+ const list = grouped.get(b.group) ?? [];
60
+ list.push({ label: b.label, keys: formatShortcutKeys(b.chord) });
61
+ grouped.set(b.group, list);
62
+ }
63
+ return Array.from(grouped.entries()).map(([title, items]) => ({ title, items }));
64
+ }
65
+ /** Derive `CommandPalette` items directly from the live shortcut registry (zero drift). */
66
+ export function toCommandItems(bindings) {
67
+ return bindings
68
+ .filter((b) => !b.disabled)
69
+ .map((b) => ({
70
+ id: b.id,
71
+ label: b.label,
72
+ group: b.group,
73
+ shortcut: formatShortcutKeys(b.chord),
74
+ ...(b.keywords ? { keywords: b.keywords } : {}),
75
+ onSelect: b.onTrigger,
76
+ }));
77
+ }
78
+ function isEditableTarget(target) {
79
+ if (!(target instanceof HTMLElement))
80
+ return false;
81
+ const tag = target.tagName;
82
+ return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || target.isContentEditable;
83
+ }
84
+ function eventToStep(e) {
85
+ const mods = [];
86
+ if (e.altKey)
87
+ mods.push('alt');
88
+ if (e.metaKey || e.ctrlKey)
89
+ mods.push('mod');
90
+ if (e.shiftKey && e.key.length > 1)
91
+ mods.push('shift');
92
+ const key = e.key.toLowerCase();
93
+ return [...mods.sort(), key].join('+');
94
+ }
95
+ /**
96
+ * Bind a unified set of keyboard shortcuts on `window` (supporting chords and 2-key sequences)
97
+ * and return derived `ShortcutsSheet` sections, `CommandPalette` items, and any detected collisions.
98
+ */
99
+ export function useShortcutRegistry(bindings, options = {}) {
100
+ const enabled = options.enabled ?? true;
101
+ const sequenceTimeoutMs = options.sequenceTimeoutMs ?? 750;
102
+ const bindingsRef = useRef(bindings);
103
+ bindingsRef.current = bindings;
104
+ useEffect(() => {
105
+ if (!enabled || typeof window === 'undefined')
106
+ return;
107
+ let prefix = null;
108
+ let timer = null;
109
+ const clearPrefix = () => {
110
+ prefix = null;
111
+ if (timer !== null) {
112
+ clearTimeout(timer);
113
+ timer = null;
114
+ }
115
+ };
116
+ const onKeyDown = (e) => {
117
+ const step = eventToStep(e);
118
+ const editable = isEditableTarget(e.target);
119
+ const list = bindingsRef.current;
120
+ // 1. Check active 2-key sequence completion first
121
+ if (prefix !== null) {
122
+ const combo = `${prefix} ${step}`;
123
+ const seqMatch = list.find((b) => !b.disabled && normalizeChord(b.chord) === combo);
124
+ if (seqMatch) {
125
+ e.preventDefault();
126
+ clearPrefix();
127
+ seqMatch.onTrigger();
128
+ return;
129
+ }
130
+ clearPrefix();
131
+ }
132
+ // 2. Check if this key starts a 2-key sequence (only outside text inputs)
133
+ if (!editable && list.some((b) => !b.disabled && normalizeChord(b.chord).startsWith(`${step} `))) {
134
+ prefix = step;
135
+ timer = setTimeout(clearPrefix, sequenceTimeoutMs);
136
+ return;
137
+ }
138
+ // 3. Check single-step chord match
139
+ const match = list.find((b) => {
140
+ if (b.disabled)
141
+ return false;
142
+ const norm = normalizeChord(b.chord);
143
+ if (norm !== step)
144
+ return false;
145
+ const allowInInputs = b.allowInInputs ?? norm.includes('mod+');
146
+ return !editable || allowInInputs;
147
+ });
148
+ if (match) {
149
+ e.preventDefault();
150
+ match.onTrigger();
151
+ }
152
+ };
153
+ window.addEventListener('keydown', onKeyDown);
154
+ return () => {
155
+ clearPrefix();
156
+ window.removeEventListener('keydown', onKeyDown);
157
+ };
158
+ }, [enabled, sequenceTimeoutMs]);
159
+ return useMemo(() => ({
160
+ sections: toShortcutSections(bindings),
161
+ commandItems: toCommandItems(bindings),
162
+ collisions: detectShortcutCollisions(bindings),
163
+ }), [bindings]);
164
+ }
@@ -0,0 +1,23 @@
1
+ import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * `<Banner>` — full-width 32px system/connection/runner status strip under an app header
4
+ * (Creator `degraded` / `offline` connection banner, Corpus runner status strip).
5
+ *
6
+ * Uses a 7px square tone indicator, soft semantic background (`--xeno-warn-soft`,
7
+ * `--xeno-danger-soft`, `--xeno-ok-soft`, `--xeno-info-soft`), and optional trailing action /
8
+ * dismiss button.
9
+ */
10
+ export type BannerTone = 'neutral' | 'info' | 'ok' | 'warn' | 'danger';
11
+ export interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
12
+ /** Semantic tone. Default `'info'`. */
13
+ readonly tone?: BannerTone;
14
+ /** Main status message. */
15
+ readonly children: ReactNode;
16
+ /** Optional trailing action (e.g. a compact "Retry now" button). */
17
+ readonly action?: ReactNode;
18
+ /** When supplied, renders a trailing dismiss button. */
19
+ readonly onDismiss?: () => void;
20
+ /** Accessible label for the dismiss button. */
21
+ readonly dismissLabel?: string;
22
+ }
23
+ export declare function Banner({ tone, children, action, onDismiss, dismissLabel, className, role, ...rest }: BannerProps): ReactElement;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconButton } from '../controls/IconButton.js';
3
+ import { cx } from '../controls/util.js';
4
+ import X from '@xenosystem/elements/elements/x';
5
+ export function Banner({ tone = 'info', children, action, onDismiss, dismissLabel = 'Dismiss banner', className, role, ...rest }) {
6
+ const liveRole = role ?? (tone === 'danger' || tone === 'warn' ? 'alert' : 'status');
7
+ return (_jsxs("div", { className: cx('xeno-banner', className), "data-tone": tone, role: liveRole, ...rest, children: [_jsx("span", { className: "xeno-banner-dot", "aria-hidden": "true" }), _jsx("div", { className: "xeno-banner-body", children: children }), action ? _jsx("div", { className: "xeno-banner-action", children: action }) : null, onDismiss ? (_jsx(IconButton, { icon: X, size: "xs", variant: "ghost", "aria-label": dismissLabel, className: "xeno-banner-dismiss", onClick: onDismiss })) : null] }));
8
+ }
@@ -0,0 +1,20 @@
1
+ import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ export interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
3
+ /** Optional leading icon mark. */
4
+ readonly icon?: ReactNode;
5
+ /** Concise empty-state headline. */
6
+ readonly title: ReactNode;
7
+ /** Optional explanatory copy below the title. */
8
+ readonly description?: ReactNode;
9
+ /** Primary recovery CTA button. */
10
+ readonly action?: ReactNode;
11
+ /** Optional secondary action link or ghost button. */
12
+ readonly secondaryAction?: ReactNode;
13
+ /** Tighter padding for embedded panels and cards. */
14
+ readonly compact?: boolean;
15
+ }
16
+ /**
17
+ * `<EmptyState>` — calm, structured empty/zero-data surface shared across tables, lists,
18
+ * search results, and consoles.
19
+ */
20
+ export declare function EmptyState({ icon, title, description, action, secondaryAction, compact, className, ...rest }: EmptyStateProps): ReactElement;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '../controls/util.js';
3
+ /**
4
+ * `<EmptyState>` — calm, structured empty/zero-data surface shared across tables, lists,
5
+ * search results, and consoles.
6
+ */
7
+ export function EmptyState({ icon, title, description, action, secondaryAction, compact = false, className, ...rest }) {
8
+ return (_jsxs("div", { className: cx('xeno-empty-state', className), "data-compact": compact ? 'true' : undefined, ...rest, children: [icon != null ? (_jsx("div", { className: "xeno-empty-state-icon", "aria-hidden": "true", children: icon })) : null, _jsx("h3", { className: "xeno-empty-state-title", children: title }), description != null ? _jsx("p", { className: "xeno-empty-state-desc", children: description }) : null, action != null || secondaryAction != null ? (_jsxs("div", { className: "xeno-empty-state-actions", children: [action, secondaryAction] })) : null] }));
9
+ }
@@ -0,0 +1,36 @@
1
+ import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ export interface SkeletonProps extends HTMLAttributes<HTMLSpanElement> {
3
+ /** Explicit CSS width (e.g. `'100%'`, `140`). */
4
+ readonly width?: number | string;
5
+ /** Explicit CSS height (e.g. `14`, `'2rem'`). Defaults to `'1em'`. */
6
+ readonly height?: number | string;
7
+ /** Corner radius override (defaults to `--xeno-radius-sm`, never circles). */
8
+ readonly radius?: number | string;
9
+ /** When > 1, renders a vertical stack of `lines` bones with the last line at 72% width. */
10
+ readonly lines?: number;
11
+ /** Vertical gap between multi-line bones in px. Defaults to `6`. */
12
+ readonly gap?: number;
13
+ /** Disables subtle pulse animation when true. */
14
+ readonly static?: boolean;
15
+ }
16
+ /**
17
+ * `<Skeleton>` — zero-layout-shift bone primitive drawn strictly from `--xeno-*` tokens.
18
+ * Honors `prefers-reduced-motion` and uses rectangular token radii (zero circles).
19
+ */
20
+ export declare function Skeleton({ width, height, radius, lines, gap, static: isStatic, className, style, ...rest }: SkeletonProps): ReactElement;
21
+ export interface SkeletonContainerProps extends HTMLAttributes<HTMLDivElement> {
22
+ /** When true, displays the bone geometry in-place with zero bounding-box shift. */
23
+ readonly loading: boolean;
24
+ /** Accessible status text announced while loading. Defaults to `'Loading'`. */
25
+ readonly loadingLabel?: string;
26
+ /** Optional custom bone overlay; when omitted, mirrors the exact child footprint. */
27
+ readonly skeleton?: ReactNode;
28
+ /** Real content rendered when loaded (and used to lock exact dimensions when loading). */
29
+ readonly children: ReactNode;
30
+ }
31
+ /**
32
+ * `<SkeletonContainer>` — guarantees mathematically `0px` Cumulative Layout Shift (CLS)
33
+ * by locking both the loaded content and its skeleton bone into the same `grid-area: 1/1`
34
+ * footprint so arriving data replaces the placeholder in-place with zero reflow.
35
+ */
36
+ export declare function SkeletonContainer({ loading, loadingLabel, skeleton, children, className, ...rest }: SkeletonContainerProps): ReactElement;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '../controls/util.js';
3
+ const toDim = (v) => v === undefined ? undefined : typeof v === 'number' ? `${v}px` : v;
4
+ /**
5
+ * `<Skeleton>` — zero-layout-shift bone primitive drawn strictly from `--xeno-*` tokens.
6
+ * Honors `prefers-reduced-motion` and uses rectangular token radii (zero circles).
7
+ */
8
+ export function Skeleton({ width, height, radius, lines = 1, gap = 6, static: isStatic = false, className, style, ...rest }) {
9
+ const boneStyle = {
10
+ ...(width !== undefined ? { width: toDim(width) } : {}),
11
+ ...(height !== undefined ? { height: toDim(height) } : {}),
12
+ ...(radius !== undefined ? { borderRadius: toDim(radius) } : {}),
13
+ ...style,
14
+ };
15
+ if (lines > 1) {
16
+ return (_jsx("span", { className: cx('xeno-skeleton-stack', className), style: { gap: `${gap}px`, ...(width !== undefined ? { width: toDim(width) } : {}) }, "aria-hidden": "true", ...rest, children: Array.from({ length: lines }, (_, idx) => (_jsx("span", { className: "xeno-skeleton", "data-static": isStatic ? 'true' : undefined, style: {
17
+ height: toDim(height) ?? '1em',
18
+ width: idx === lines - 1 ? '72%' : '100%',
19
+ ...(radius !== undefined ? { borderRadius: toDim(radius) } : {}),
20
+ } }, idx))) }));
21
+ }
22
+ return (_jsx("span", { className: cx('xeno-skeleton', className), "data-static": isStatic ? 'true' : undefined, style: boneStyle, "aria-hidden": "true", ...rest }));
23
+ }
24
+ /**
25
+ * `<SkeletonContainer>` — guarantees mathematically `0px` Cumulative Layout Shift (CLS)
26
+ * by locking both the loaded content and its skeleton bone into the same `grid-area: 1/1`
27
+ * footprint so arriving data replaces the placeholder in-place with zero reflow.
28
+ */
29
+ export function SkeletonContainer({ loading, loadingLabel = 'Loading', skeleton, children, className, ...rest }) {
30
+ return (_jsxs("div", { className: cx('xeno-skeleton-container', className), "data-loading": loading ? 'true' : 'false', "aria-busy": loading || undefined, "aria-label": loading ? loadingLabel : undefined, ...rest, children: [_jsx("div", { className: "xeno-skeleton-layer xeno-skeleton-content", "aria-hidden": loading || undefined, children: children }), loading ? (_jsx("div", { className: "xeno-skeleton-layer xeno-skeleton-overlay", "aria-hidden": "true", children: skeleton ?? _jsx(Skeleton, { width: "100%", height: "100%" }) })) : null] }));
31
+ }
@@ -0,0 +1,28 @@
1
+ import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * `<Toast>` & `<ToastStack>` — floating confirmation and error notifications measured from
4
+ * Corpus, Creator, Desktop Shell and Workshop (`--xeno-pop` shadow, 6px radius, 7px square status
5
+ * mark, optional action and dismiss control).
6
+ */
7
+ export type ToastTone = 'neutral' | 'info' | 'ok' | 'warn' | 'danger';
8
+ export interface ToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children'> {
9
+ /** Semantic tone. Default `'neutral'`. */
10
+ readonly tone?: ToastTone;
11
+ /** Primary short message (or title when `description` is also set). */
12
+ readonly title: ReactNode;
13
+ /** Optional secondary detail line. */
14
+ readonly description?: ReactNode;
15
+ /** Optional inline action button (e.g. "Undo", "View"). */
16
+ readonly action?: ReactNode;
17
+ /** When provided, shows a close button. */
18
+ readonly onDismiss?: () => void;
19
+ /** Accessible label for the close button. */
20
+ readonly dismissLabel?: string;
21
+ }
22
+ export declare function Toast({ tone, title, description, action, onDismiss, dismissLabel, className, role, ...rest }: ToastProps): ReactElement;
23
+ export interface ToastStackProps extends HTMLAttributes<HTMLDivElement> {
24
+ /** Corner placement. Default `'bottom-right'`. */
25
+ readonly placement?: 'bottom-right' | 'bottom-center' | 'top-right';
26
+ readonly children?: ReactNode;
27
+ }
28
+ export declare function ToastStack({ placement, children, className, ...rest }: ToastStackProps): ReactElement;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconButton } from '../controls/IconButton.js';
3
+ import { cx } from '../controls/util.js';
4
+ import X from '@xenosystem/elements/elements/x';
5
+ export function Toast({ tone = 'neutral', title, description, action, onDismiss, dismissLabel = 'Dismiss notification', className, role, ...rest }) {
6
+ const liveRole = role ?? (tone === 'danger' ? 'alert' : 'status');
7
+ return (_jsxs("div", { className: cx('xeno-toast', className), "data-tone": tone, role: liveRole, ...rest, children: [_jsx("span", { className: "xeno-toast-dot", "aria-hidden": "true" }), _jsxs("div", { className: "xeno-toast-copy", children: [_jsx("div", { className: "xeno-toast-title", children: title }), description ? _jsx("div", { className: "xeno-toast-desc", children: description }) : null] }), action ? _jsx("div", { className: "xeno-toast-action", children: action }) : null, onDismiss ? (_jsx(IconButton, { icon: X, size: "xs", variant: "ghost", "aria-label": dismissLabel, className: "xeno-toast-dismiss", onClick: onDismiss })) : null] }));
8
+ }
9
+ export function ToastStack({ placement = 'bottom-right', children, className, ...rest }) {
10
+ return (_jsx("div", { className: cx('xeno-toast-stack', className), "data-placement": placement, "aria-live": "polite", "aria-relevant": "additions text", ...rest, children: children }));
11
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Self-Describing Live Runtime UI Tree (`window.__XENO_UI_TREE__`).
3
+ *
4
+ * Gives `/apptest`, `xeno-use`, and XENO agents a deterministic, zero-selector semantic view of
5
+ * every visible XENO control, menu, panel, table, and state on the page — the Web/Electron
6
+ * counterpart to Unreal's `XenoUseBridge`.
7
+ */
8
+ export interface XenoUiRect {
9
+ readonly x: number;
10
+ readonly y: number;
11
+ readonly width: number;
12
+ readonly height: number;
13
+ }
14
+ export interface XenoUiNode {
15
+ readonly id: string;
16
+ readonly unit: string;
17
+ readonly role: string;
18
+ readonly label: string;
19
+ readonly disabled: boolean;
20
+ readonly selected?: boolean | 'mixed';
21
+ readonly expanded?: boolean;
22
+ readonly sort?: string;
23
+ readonly tone?: string;
24
+ readonly rect: XenoUiRect;
25
+ readonly actions: readonly ('click' | 'focus')[];
26
+ }
27
+ export interface XenoUiTreeSnapshot {
28
+ readonly version: 1;
29
+ readonly capturedAt: string;
30
+ readonly theme: string;
31
+ readonly chrome: string;
32
+ readonly density: string;
33
+ readonly viewport: {
34
+ readonly width: number;
35
+ readonly height: number;
36
+ };
37
+ readonly nodeCount: number;
38
+ readonly nodes: readonly XenoUiNode[];
39
+ }
40
+ export interface XenoUiBridge {
41
+ readonly snapshot: () => XenoUiTreeSnapshot;
42
+ readonly findByLabel: (query: string) => readonly XenoUiNode[];
43
+ readonly findByUnit: (unit: string) => readonly XenoUiNode[];
44
+ readonly click: (nodeId: string) => boolean;
45
+ readonly focus: (nodeId: string) => boolean;
46
+ }
47
+ /** Capture a deterministic semantic UI tree snapshot from `root` (defaults to `document.body`). */
48
+ export declare function snapshotXenoUiTree(root?: HTMLElement | null): XenoUiTreeSnapshot;
49
+ /**
50
+ * Mount `window.__XENO_UI_TREE__` for live agent & `/apptest` introspection and action dispatch.
51
+ * Returns an uninstall cleanup function.
52
+ */
53
+ export declare function installXenoUiTree(root?: HTMLElement | null): () => void;
package/dist/uiTree.js ADDED
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Self-Describing Live Runtime UI Tree (`window.__XENO_UI_TREE__`).
3
+ *
4
+ * Gives `/apptest`, `xeno-use`, and XENO agents a deterministic, zero-selector semantic view of
5
+ * every visible XENO control, menu, panel, table, and state on the page — the Web/Electron
6
+ * counterpart to Unreal's `XenoUseBridge`.
7
+ */
8
+ const INTERACTIVE_SELECTOR = [
9
+ 'button',
10
+ 'a[href]',
11
+ 'input',
12
+ 'textarea',
13
+ 'select',
14
+ '[role="button"]',
15
+ '[role="menuitem"]',
16
+ '[role="menuitemcheckbox"]',
17
+ '[role="tab"]',
18
+ '[role="radio"]',
19
+ '[role="checkbox"]',
20
+ '[role="switch"]',
21
+ '[role="option"]',
22
+ '[role="dialog"]',
23
+ '[role="menu"]',
24
+ '[role="status"]',
25
+ '[role="alert"]',
26
+ '.xeno-panel',
27
+ '.xeno-card',
28
+ '.xeno-table',
29
+ '.xc-inspector-pane',
30
+ '.xc-nav-rail',
31
+ ].join(', ');
32
+ function inferUnit(el) {
33
+ const explicit = el.getAttribute('data-xeno-unit');
34
+ if (explicit)
35
+ return explicit;
36
+ for (const cls of Array.from(el.classList)) {
37
+ if ((cls.startsWith('xeno-') || cls.startsWith('xc-')) && !cls.includes('--')) {
38
+ return cls;
39
+ }
40
+ }
41
+ return el.getAttribute('role') ?? el.tagName.toLowerCase();
42
+ }
43
+ function inferLabel(el) {
44
+ const aria = el.getAttribute('aria-label');
45
+ if (aria)
46
+ return aria.trim();
47
+ const labelledBy = el.getAttribute('aria-labelledby');
48
+ if (labelledBy) {
49
+ const text = labelledBy
50
+ .split(/\s+/)
51
+ .map((id) => document.getElementById(id)?.textContent?.trim() ?? '')
52
+ .filter(Boolean)
53
+ .join(' ');
54
+ if (text)
55
+ return text;
56
+ }
57
+ if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
58
+ return (el.placeholder || el.name || el.value || '').trim();
59
+ }
60
+ const title = el.getAttribute('title');
61
+ if (title)
62
+ return title.trim();
63
+ return (el.textContent ?? '').replace(/\s+/g, ' ').trim().slice(0, 120);
64
+ }
65
+ function isVisible(el) {
66
+ if (el.hidden || el.getAttribute('aria-hidden') === 'true')
67
+ return false;
68
+ const style = typeof window !== 'undefined' ? window.getComputedStyle(el) : null;
69
+ if (style && (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0')) {
70
+ return false;
71
+ }
72
+ return true;
73
+ }
74
+ /** Capture a deterministic semantic UI tree snapshot from `root` (defaults to `document.body`). */
75
+ export function snapshotXenoUiTree(root) {
76
+ const container = root ?? (typeof document !== 'undefined' ? document.body : null);
77
+ const scopeEl = container?.querySelector('.xeno') ?? (container?.closest('.xeno') ?? null);
78
+ const chromeEl = scopeEl?.closest('[data-chrome]') ?? container?.querySelector('[data-chrome]');
79
+ const densityEl = scopeEl?.closest('[data-density]') ?? container?.querySelector('[data-density]');
80
+ const nodes = [];
81
+ if (container) {
82
+ const seen = new Set();
83
+ const els = Array.from(container.querySelectorAll(INTERACTIVE_SELECTOR));
84
+ let idx = 0;
85
+ for (const el of els) {
86
+ if (seen.has(el) || !isVisible(el))
87
+ continue;
88
+ seen.add(el);
89
+ const r = el.getBoundingClientRect();
90
+ const role = el.getAttribute('role') ?? el.tagName.toLowerCase();
91
+ const label = inferLabel(el);
92
+ const unit = inferUnit(el);
93
+ const id = el.getAttribute('data-xeno-node-id') ?? el.getAttribute('data-testid') ?? `${unit}#${++idx}`;
94
+ el.setAttribute('data-xeno-node-id', id);
95
+ const ariaSelected = el.getAttribute('aria-selected') ?? el.getAttribute('aria-checked') ?? el.getAttribute('aria-current');
96
+ const selected = ariaSelected === 'mixed'
97
+ ? 'mixed'
98
+ : ariaSelected === 'true' || ariaSelected === 'page' || el.getAttribute('data-selection') === 'on'
99
+ ? true
100
+ : ariaSelected === 'false' || el.getAttribute('data-selection') === 'off'
101
+ ? false
102
+ : undefined;
103
+ const ariaExpanded = el.getAttribute('aria-expanded');
104
+ const expanded = ariaExpanded === 'true' ? true : ariaExpanded === 'false' ? false : undefined;
105
+ const sort = el.getAttribute('aria-sort') ?? undefined;
106
+ const tone = el.getAttribute('data-tone') ?? undefined;
107
+ const disabled = el.disabled === true ||
108
+ el.getAttribute('aria-disabled') === 'true' ||
109
+ el.getAttribute('data-availability') === 'disabled';
110
+ const isActionable = el.tagName === 'BUTTON' ||
111
+ el.tagName === 'A' ||
112
+ el.tagName === 'INPUT' ||
113
+ el.tagName === 'SELECT' ||
114
+ el.tagName === 'TEXTAREA' ||
115
+ role === 'menuitem' ||
116
+ role === 'tab' ||
117
+ role === 'radio' ||
118
+ role === 'checkbox' ||
119
+ role === 'switch' ||
120
+ role === 'button';
121
+ nodes.push({
122
+ id,
123
+ unit,
124
+ role,
125
+ label,
126
+ disabled,
127
+ ...(selected !== undefined ? { selected } : {}),
128
+ ...(expanded !== undefined ? { expanded } : {}),
129
+ ...(sort ? { sort } : {}),
130
+ ...(tone ? { tone } : {}),
131
+ rect: {
132
+ x: Math.round(r.left),
133
+ y: Math.round(r.top),
134
+ width: Math.round(r.width),
135
+ height: Math.round(r.height),
136
+ },
137
+ actions: isActionable && !disabled ? ['click', 'focus'] : ['focus'],
138
+ });
139
+ }
140
+ }
141
+ return {
142
+ version: 1,
143
+ capturedAt: new Date().toISOString(),
144
+ theme: scopeEl?.getAttribute('data-theme') ?? 'dark',
145
+ chrome: chromeEl?.getAttribute('data-chrome') ?? 'separated',
146
+ density: densityEl?.getAttribute('data-density') ?? 'default',
147
+ viewport: {
148
+ width: typeof window !== 'undefined' ? window.innerWidth : 0,
149
+ height: typeof window !== 'undefined' ? window.innerHeight : 0,
150
+ },
151
+ nodeCount: nodes.length,
152
+ nodes,
153
+ };
154
+ }
155
+ /**
156
+ * Mount `window.__XENO_UI_TREE__` for live agent & `/apptest` introspection and action dispatch.
157
+ * Returns an uninstall cleanup function.
158
+ */
159
+ export function installXenoUiTree(root) {
160
+ if (typeof window === 'undefined')
161
+ return () => { };
162
+ const targetRoot = () => root ?? document.body;
163
+ const escapeAttr = (v) => typeof CSS !== 'undefined' && typeof CSS.escape === 'function' ? CSS.escape(v) : v.replace(/["\\]/g, '\\$&');
164
+ const bridge = {
165
+ snapshot: () => snapshotXenoUiTree(targetRoot()),
166
+ findByLabel: (query) => {
167
+ const q = query.trim().toLowerCase();
168
+ return snapshotXenoUiTree(targetRoot()).nodes.filter((n) => n.label.toLowerCase().includes(q));
169
+ },
170
+ findByUnit: (unit) => {
171
+ const q = unit.trim().toLowerCase();
172
+ return snapshotXenoUiTree(targetRoot()).nodes.filter((n) => n.unit.toLowerCase().includes(q));
173
+ },
174
+ click: (nodeId) => {
175
+ snapshotXenoUiTree(targetRoot());
176
+ const el = document.querySelector(`[data-xeno-node-id="${escapeAttr(nodeId)}"]`);
177
+ if (!el)
178
+ return false;
179
+ el.click();
180
+ return true;
181
+ },
182
+ focus: (nodeId) => {
183
+ snapshotXenoUiTree(targetRoot());
184
+ const el = document.querySelector(`[data-xeno-node-id="${escapeAttr(nodeId)}"]`);
185
+ if (!el)
186
+ return false;
187
+ el.focus();
188
+ return true;
189
+ },
190
+ };
191
+ window.__XENO_UI_TREE__ = bridge;
192
+ return () => {
193
+ const win = window;
194
+ if (win.__XENO_UI_TREE__ === bridge)
195
+ delete win.__XENO_UI_TREE__;
196
+ };
197
+ }
@@ -29,6 +29,8 @@ export interface UseDialogOptions<T extends HTMLElement> {
29
29
  readonly panelRef?: MutableRefObject<T | null>;
30
30
  /** Lock the page scroll behind the dialog. Default `true`. */
31
31
  readonly lockScroll?: boolean;
32
+ /** Mark background siblings outside the dialog `inert` while open (WAI-ARIA APG). Default `true`. */
33
+ readonly inertBackground?: boolean;
32
34
  }
33
35
  export interface UseDialogResult<T extends HTMLElement> {
34
36
  /** The dialog panel. `panelProps` already carries it. */
@@ -42,4 +44,4 @@ export interface UseDialogResult<T extends HTMLElement> {
42
44
  readonly onKeyDown: (e: ReactKeyboardEvent<T>) => void;
43
45
  };
44
46
  }
45
- export declare function useDialog<T extends HTMLElement = HTMLDivElement>({ open, onClose, panelRef: providedRef, lockScroll, }: UseDialogOptions<T>): UseDialogResult<T>;
47
+ export declare function useDialog<T extends HTMLElement = HTMLDivElement>({ open, onClose, panelRef: providedRef, lockScroll, inertBackground, }: UseDialogOptions<T>): UseDialogResult<T>;