@tangible/ui 0.2.32 → 0.2.34

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 (46) hide show
  1. package/components/Modal/Modal.js +6 -4
  2. package/components/Sidebar/Sidebar.js +14 -2
  3. package/components/Sidebar/types.d.ts +17 -0
  4. package/components/StepIndicator/StepIndicator.js +13 -28
  5. package/components/StepIndicator/label.d.ts +13 -0
  6. package/components/StepIndicator/label.js +29 -0
  7. package/components/StepIndicator/types.d.ts +13 -0
  8. package/components/StepIndicator/types.js +1 -0
  9. package/components/StepList/StepList.js +38 -11
  10. package/components/StepList/index.d.ts +2 -1
  11. package/components/StepList/index.js +1 -0
  12. package/components/StepList/types.d.ts +33 -1
  13. package/components/StepList/types.js +11 -1
  14. package/components/index.d.ts +4 -4
  15. package/components/index.js +2 -2
  16. package/figma-tokens.json +1 -1
  17. package/icons/cred.svg +14 -0
  18. package/icons/icons.svg +10 -10
  19. package/icons/lms.svg +46 -0
  20. package/icons/membersync.svg +24 -0
  21. package/icons/player.svg +26 -0
  22. package/icons/reaction.svg +38 -0
  23. package/icons/sprite-registry.d.ts +2 -0
  24. package/icons/sprite-registry.js +268 -0
  25. package/icons/sprite-version.d.ts +6 -0
  26. package/icons/sprite-version.js +1 -0
  27. package/icons/sprite.d.ts +53 -0
  28. package/icons/sprite.js +196 -0
  29. package/icons/sprite.php +85 -0
  30. package/icons/system.svg +120 -0
  31. package/package.json +9 -1
  32. package/skills/building-with-tui/SKILL.md +54 -5
  33. package/styles/all.css +1 -1
  34. package/styles/all.expanded.css +53 -7
  35. package/styles/all.expanded.unlayered.css +53 -7
  36. package/styles/all.unlayered.css +1 -1
  37. package/styles/components/step-indicator.scss +74 -11
  38. package/styles/components/step-list.scss +27 -1
  39. package/tui-manifest.json +23 -3
  40. package/utils/focus-trap.d.ts +1 -1
  41. package/utils/focus-trap.js +1 -1
  42. package/utils/sprite-icon.d.ts +15 -0
  43. package/utils/sprite-icon.js +66 -0
  44. package/utils/tabbable.d.ts +16 -0
  45. package/utils/tabbable.js +32 -3
  46. package/vanilla/modal.min.js +1 -1
@@ -1,6 +1,16 @@
1
1
  @use "../system" as sys;
2
2
 
3
- /* @tui-tokens: none — inherits --tui-progress-track, --tui-progress-fill */
3
+ // Attention dot geometry, relative to the circle
4
+ $_dot-size: 36%;
5
+ $_dot-offset: 20%; // how far it overhangs the top-end edge
6
+ $_dot-min-size: 6px; // floor at xs (16px circle), a visual floor, not a target
7
+ $_dot-gap: 1.5px; // surface-coloured ring separating it from the track
8
+
9
+ /* @tui-tokens
10
+ --tui-step-indicator-track
11
+ --tui-step-indicator-attention
12
+ --tui-step-indicator-surface
13
+ */
4
14
 
5
15
  @mixin styles() {
6
16
  // ==========================================================================
@@ -18,12 +28,29 @@
18
28
  // This component is tightly coupled to Progress circle mode internals.
19
29
  // Changes to Progress may require updates here.
20
30
  //
31
+ // ### Component API tokens:
32
+ // --tui-step-indicator-track Ring track colour (then --tui-progress-track,
33
+ // then the control border)
34
+ // --tui-step-indicator-attention Attention dot colour (default: warning base)
35
+ // --tui-step-indicator-surface What the indicator sits on (default: color-bg),
36
+ // painted as a gap around the dot so it reads
37
+ // apart from the ring
38
+ //
21
39
  // ### Inherits from Progress:
22
- // --tui-progress-track Ring track color
23
40
  // --tui-progress-fill Ring fill color
41
+ // --tui-progress-track Ring track color, below --tui-step-indicator-track
42
+ //
43
+ // ### Hand-offs from a host (StepList), private, read below the public tokens
44
+ // for the track and above them for the surface:
45
+ // --_indicator-track A darker track where the row paints a fill
46
+ // --_indicator-surface The row's own fill, for the dot's gap
24
47
  //
25
48
  // ### Manipulates Progress:
26
- // - Sets --tui-progress-track per status (locked uses border color)
49
+ // - Sets Progress's internal --_track. A not-started step is only its
50
+ // track, so it needs 3:1 (SC 1.4.11); Progress's own default, color-fill,
51
+ // measures about 1.2:1. Written to the internal rather than to
52
+ // --tui-progress-track, which would have to read itself (a cycle) to
53
+ // keep a consumer's value in the chain.
27
54
  // - Overrides label font-size to fit icons
28
55
  // - Uses variant="solid" for complete state (removes hollow centre)
29
56
  //
@@ -31,6 +58,15 @@
31
58
 
32
59
  :where(.#{sys.$prefix}interface) .#{sys.$prefix}step-indicator {
33
60
  display: inline-flex;
61
+ position: relative;
62
+
63
+ // Out-specifies Progress's own (0,1,0) declaration of --_track.
64
+ .#{sys.$prefix}progress {
65
+ --_track: var(
66
+ --#{sys.$prefix}step-indicator-track,
67
+ var(--_indicator-track, var(--#{sys.$prefix}progress-track, var(--#{sys.$prefix}color-border-control)))
68
+ );
69
+ }
34
70
 
35
71
  // Size overrides — StepIndicator uses fixed pixel sizes
36
72
  // rather than Progress's em-based scaling
@@ -54,12 +90,10 @@
54
90
  // Static icon states: hide the progress fill, show only track
55
91
  // Note: complete handles its own background (solid green), so not included here
56
92
  // Note: in-progress with custom icon should still show progress fill
57
- &.is-status-locked.has-icon,
58
- &.is-status-not-started.has-icon {
59
- // Token Bridging: uniform circle = fill matches track. Progress's
60
- // conic-gradient reads --tui-progress-fill, so setting it here needs
61
- // no !important arms race with Progress's own declaration.
62
- --#{sys.$prefix}progress-fill: var(--#{sys.$prefix}progress-track, var(--#{sys.$prefix}color-border));
93
+ &.is-status-locked.has-icon .#{sys.$prefix}progress,
94
+ &.is-status-not-started.has-icon .#{sys.$prefix}progress {
95
+ // Uniform circle: fill matches track
96
+ --_fill: var(--_track);
63
97
  }
64
98
 
65
99
  // Center the icon properly within the progress circle
@@ -108,11 +142,40 @@
108
142
  }
109
143
 
110
144
  &.is-status-locked {
111
- --#{sys.$prefix}progress-track: var(--#{sys.$prefix}color-border);
112
-
113
145
  .#{sys.$prefix}icon {
114
146
  color: var(--#{sys.$prefix}color-fg-muted);
115
147
  }
116
148
  }
149
+
150
+ // -------------------------------------------------------------------------
151
+ // Attention: a dot on the ring's top-end edge. Its presence is the cue (no
152
+ // colour-only meaning), and warning-base clears 3:1 on the page in both
153
+ // modes. The name carries it for AT; the dot is aria-hidden.
154
+ // -------------------------------------------------------------------------
155
+ &__attention {
156
+ position: absolute;
157
+ inset-block-start: 0;
158
+ inset-inline-end: 0;
159
+ inline-size: $_dot-size;
160
+ aspect-ratio: 1;
161
+ min-inline-size: $_dot-min-size;
162
+ border-radius: 50%;
163
+ background-color: var(--#{sys.$prefix}step-indicator-attention, var(--#{sys.$prefix}theme-warning-base));
164
+ box-shadow: 0 0 0 $_dot-gap var(--_indicator-surface, var(--#{sys.$prefix}step-indicator-surface, var(--#{sys.$prefix}color-bg)));
165
+ translate: $_dot-offset (-$_dot-offset);
166
+ pointer-events: none;
167
+
168
+ // Forced colours strip the fill and the shadow, leaving a bite out of
169
+ // the ring. Keep a text-coloured dot with a canvas gap.
170
+ @media (forced-colors: active) {
171
+ forced-color-adjust: none;
172
+ background-color: CanvasText;
173
+ box-shadow: 0 0 0 $_dot-gap Canvas;
174
+ }
175
+ }
176
+
177
+ &:dir(rtl) .#{sys.$prefix}step-indicator__attention {
178
+ translate: (-$_dot-offset) (-$_dot-offset);
179
+ }
117
180
  }
118
181
  }
@@ -82,8 +82,14 @@
82
82
  transition-duration: var(--#{sys.$prefix}motion-duration);
83
83
  transition-timing-function: var(--#{sys.$prefix}motion-timing);
84
84
 
85
- &:hover:not([aria-disabled="true"]):not(:disabled) {
85
+ // Rows that paint a fill hand two private values to the StepIndicator:
86
+ // the fill itself, so the attention dot's gap matches the row, and on the
87
+ // current row a darker track (control-border measures 2.87:1 on the light
88
+ // current fill; fg-muted measures 3.99:1). A consumer's
89
+ // --tui-step-indicator-track still wins over the hand-off.
90
+ &:hover:not([aria-disabled="true"]):not(:disabled):not(.is-static) {
86
91
  background-color: var(--_hover-bg);
92
+ --_indicator-surface: var(--_hover-bg);
87
93
  }
88
94
 
89
95
  &:focus-visible {
@@ -97,6 +103,25 @@
97
103
  &[aria-current] {
98
104
  background-color: var(--_current-bg);
99
105
  border-left-color: var(--_current-border);
106
+ --_indicator-surface: var(--_current-bg);
107
+ --_indicator-track: var(--#{sys.$prefix}color-fg-muted);
108
+ }
109
+
110
+ // Forced colours repaint the transparent accent border on every row, so
111
+ // the current row stopped standing out. Rest rows match the canvas; the
112
+ // current row takes Highlight.
113
+ @media (forced-colors: active) {
114
+ border-left-color: Canvas;
115
+
116
+ &.is-current,
117
+ &[aria-current] {
118
+ border-left-color: Highlight;
119
+ }
120
+ }
121
+
122
+ // Status-only row (no href, no onSelect): nothing to activate
123
+ &.is-static {
124
+ cursor: default;
100
125
  }
101
126
 
102
127
  // Disabled styling
@@ -113,6 +138,7 @@
113
138
  // ---------------------------------------------------------------------------
114
139
 
115
140
  :where(.#{sys.$prefix}interface) .#{sys.$prefix}steplist__indicator {
141
+ display: flex;
116
142
  flex-shrink: 0;
117
143
  margin-top: 0.325em; // Slight offset to align with text baseline
118
144
  }
package/tui-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.32",
3
- "generated": "2026-10-25T18:59:01.108Z",
2
+ "version": "0.2.34",
3
+ "generated": "2026-10-26T16:33:48.776Z",
4
4
  "components": {
5
5
  "Accordion": {
6
6
  "props": {
@@ -3399,6 +3399,11 @@
3399
3399
  "type": "() => void",
3400
3400
  "required": true,
3401
3401
  "description": "Callback to close the drawer. Required when `drawer={true}`.\nCalled when ESC is pressed or backdrop is clicked.\nOmitting this in drawer mode means the user cannot dismiss the overlay,\nwhich is a WCAG 2.1.1 (Keyboard) failure."
3402
+ },
3403
+ "initialFocusSelector": {
3404
+ "type": "string",
3405
+ "required": false,
3406
+ "description": "CSS selector, matched inside the drawer when it opens, for the element\nthat takes focus: say, the current lesson in a long outline, so keyboard\nand screen reader users start where they are. Escape still closes and the\nclose button is a Shift+Tab away. Don't point it at a destructive action.\n\nThe target must be able to take focus (a control, a link, or anything\nwith `tabindex`, -1 included) and be rendered at open. Otherwise a dev\nwarning fires and focus goes to the default: an element marked\n`data-autofocus`, else the first control. It's read once, when the drawer\nopens; changing it while open doesn't move focus.\n\nSame prop as `Modal`'s, but the default differs: Modal skips its own close\nbutton, while a drawer has none, so its first control is often your\nHeader's close button. That's what this prop is for."
3402
3407
  }
3403
3408
  },
3404
3409
  "cssTokens": [
@@ -3545,6 +3550,12 @@
3545
3550
  "defaultValue": "false",
3546
3551
  "description": "Show percentage text in center (only visible for in-progress status)."
3547
3552
  },
3553
+ "attention": {
3554
+ "type": "boolean",
3555
+ "required": false,
3556
+ "defaultValue": "false",
3557
+ "description": "Flag the step as needing attention (its inputs changed, it's stale, it\nneeds review). Adds a warning dot and appends \"needs attention\" to the\naccessible name via `labels.withAttention`.\n\nSeparate from `status` on purpose: a complete step can still need\nattention."
3558
+ },
3548
3559
  "label": {
3549
3560
  "type": "string",
3550
3561
  "required": false,
@@ -3561,7 +3572,11 @@
3561
3572
  "description": "Override default English strings for i18n.\nCovers status display names and the aria-label template."
3562
3573
  }
3563
3574
  },
3564
- "cssTokens": [],
3575
+ "cssTokens": [
3576
+ "--tui-step-indicator-track",
3577
+ "--tui-step-indicator-attention",
3578
+ "--tui-step-indicator-surface"
3579
+ ],
3565
3580
  "story": {
3566
3581
  "title": "Primitives/StepIndicator",
3567
3582
  "tags": [
@@ -3591,6 +3606,11 @@
3591
3606
  "required": false,
3592
3607
  "description": "Value of the currently active step.\nThe matching StepList.Item will receive `aria-current` and current styling."
3593
3608
  },
3609
+ "labels": {
3610
+ "type": "StepListLabels",
3611
+ "required": false,
3612
+ "description": "Override the strings each item announces after its label\n(\"Complete\", \"needs attention\", \"current step\")."
3613
+ },
3594
3614
  "children": {
3595
3615
  "type": "ReactNode",
3596
3616
  "required": true,
@@ -1,4 +1,4 @@
1
- export { FOCUSABLE_SELECTOR, isTabbable, getTabbable, getInitialFocus } from './tabbable';
1
+ export { FOCUSABLE_SELECTOR, isTabbable, isFocusTarget, findFocusTarget, getTabbable, getInitialFocus } from './tabbable';
2
2
  /**
3
3
  * Options for the focus trap hook.
4
4
  */
@@ -1,6 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import { getTabbable } from './tabbable.js';
3
- export { FOCUSABLE_SELECTOR, isTabbable, getTabbable, getInitialFocus } from './tabbable.js';
3
+ export { FOCUSABLE_SELECTOR, isTabbable, isFocusTarget, findFocusTarget, getTabbable, getInitialFocus } from './tabbable.js';
4
4
  /**
5
5
  * Traps focus within a container element.
6
6
  * Tab and Shift+Tab cycle through focusable elements inside the container.
@@ -0,0 +1,15 @@
1
+ import { type ComponentType, type SVGProps } from 'react';
2
+ type IconComponent = ComponentType<SVGProps<SVGSVGElement>>;
3
+ /**
4
+ * An icon that references a sprite symbol: what every entry of the generated
5
+ * sprite registry is. Lives in utils, which the package doesn't expose, so it
6
+ * stays internal.
7
+ *
8
+ * In development (Vite's `import.meta.env.DEV`), once the document's sprites
9
+ * have settled it checks the symbol exists, marking the `<svg>` with
10
+ * `data-tui-icon-missing="<name>"` (the registry name, as `Icon` does) and
11
+ * warning once per name. A sprite inserted later re-runs the check and clears
12
+ * the mark.
13
+ */
14
+ export declare function spriteIcon(id: string, viewBox: string, name: string): IconComponent;
15
+ export {};
@@ -0,0 +1,66 @@
1
+ import { createElement, useEffect, useRef } from 'react';
2
+ import { isDev } from './is-dev.js';
3
+ import { composeRefs } from './compose-refs.js';
4
+ import { SPRITE_EVENT, spritesSettled } from '../icons/sprite.js';
5
+ const warned = new Set();
6
+ /**
7
+ * An icon that references a sprite symbol: what every entry of the generated
8
+ * sprite registry is. Lives in utils, which the package doesn't expose, so it
9
+ * stays internal.
10
+ *
11
+ * In development (Vite's `import.meta.env.DEV`), once the document's sprites
12
+ * have settled it checks the symbol exists, marking the `<svg>` with
13
+ * `data-tui-icon-missing="<name>"` (the registry name, as `Icon` does) and
14
+ * warning once per name. A sprite inserted later re-runs the check and clears
15
+ * the mark.
16
+ */
17
+ export function spriteIcon(id, viewBox, name) {
18
+ function SpriteIcon(props) {
19
+ const own = useRef(null);
20
+ useEffect(() => {
21
+ if (!isDev())
22
+ return;
23
+ const svg = own.current;
24
+ if (!svg)
25
+ return;
26
+ const doc = svg.ownerDocument;
27
+ let live = true;
28
+ const check = () => {
29
+ if (!live)
30
+ return false;
31
+ const found = !!doc.getElementById(id);
32
+ if (found)
33
+ svg.removeAttribute('data-tui-icon-missing');
34
+ else
35
+ svg.setAttribute('data-tui-icon-missing', name);
36
+ return found;
37
+ };
38
+ void spritesSettled(doc).then(() => {
39
+ if (check() || !live || warned.has(name))
40
+ return;
41
+ warned.add(name);
42
+ console.warn(`[Icon] "${name}" has no sprite symbol (#${id}) in the page. Print the sprite on the ` +
43
+ `server (icons/sprite.php) or call injectIconSprite() with the "${name.split('/')[0]}" set.`);
44
+ });
45
+ doc.addEventListener(SPRITE_EVENT, check);
46
+ return () => {
47
+ live = false;
48
+ doc.removeEventListener(SPRITE_EVENT, check);
49
+ };
50
+ }, []);
51
+ // React 19 passes a consumer's ref as a prop; keep it alongside ours.
52
+ // (React 18's types also allow a string ref, which a function component never receives.)
53
+ const ref = props.ref ? composeRefs(own, props.ref) : own;
54
+ return createElement('svg', {
55
+ xmlns: 'http://www.w3.org/2000/svg',
56
+ viewBox,
57
+ width: '1em',
58
+ height: '1em',
59
+ fill: 'currentColor',
60
+ ...props,
61
+ ref,
62
+ }, createElement('use', { href: `#${id}` }));
63
+ }
64
+ SpriteIcon.displayName = `SpriteIcon(${name})`;
65
+ return SpriteIcon;
66
+ }
@@ -11,6 +11,22 @@ export declare const FOCUSABLE_SELECTOR: string;
11
11
  * edge lets Tab walk straight out of the dialog, so filter them here.
12
12
  */
13
13
  export declare function isTabbable(el: HTMLElement, container?: HTMLElement): boolean;
14
+ /**
15
+ * Whether `el` can take focus programmatically: a focusable element, or one
16
+ * with any `tabindex` (including -1), that isn't disabled, inert or hidden.
17
+ * For an explicitly named initial-focus target, where `.focus()` on anything
18
+ * else silently does nothing and leaves focus outside the dialog.
19
+ */
20
+ export declare function isFocusTarget(el: HTMLElement, container?: HTMLElement): boolean;
21
+ /**
22
+ * The element `selector` names inside `container`, if it can take focus.
23
+ * Otherwise `null` and why, for a dev warning. A malformed selector doesn't
24
+ * throw: it would do so mid-effect and leave the dialog without focus.
25
+ */
26
+ export declare function findFocusTarget(container: HTMLElement, selector: string): {
27
+ target: HTMLElement | null;
28
+ problem?: string;
29
+ };
14
30
  /** The focusable elements in `container` that can actually take focus, in DOM order. */
15
31
  export declare function getTabbable(container: HTMLElement): HTMLElement[];
16
32
  /**
package/utils/tabbable.js CHANGED
@@ -43,6 +43,35 @@ export function isTabbable(el, container) {
43
43
  }
44
44
  return true;
45
45
  }
46
+ /**
47
+ * Whether `el` can take focus programmatically: a focusable element, or one
48
+ * with any `tabindex` (including -1), that isn't disabled, inert or hidden.
49
+ * For an explicitly named initial-focus target, where `.focus()` on anything
50
+ * else silently does nothing and leaves focus outside the dialog.
51
+ */
52
+ export function isFocusTarget(el, container) {
53
+ return (el.matches(FOCUSABLE_SELECTOR) || el.hasAttribute('tabindex')) && isTabbable(el, container);
54
+ }
55
+ /**
56
+ * The element `selector` names inside `container`, if it can take focus.
57
+ * Otherwise `null` and why, for a dev warning. A malformed selector doesn't
58
+ * throw: it would do so mid-effect and leave the dialog without focus.
59
+ */
60
+ export function findFocusTarget(container, selector) {
61
+ let match;
62
+ try {
63
+ match = container.querySelector(selector);
64
+ }
65
+ catch {
66
+ return { target: null, problem: 'is not a valid selector' };
67
+ }
68
+ if (!match)
69
+ return { target: null, problem: 'did not match any element' };
70
+ if (!isFocusTarget(match, container)) {
71
+ return { target: null, problem: 'matched an element that cannot take focus' };
72
+ }
73
+ return { target: match };
74
+ }
46
75
  /** The focusable elements in `container` that can actually take focus, in DOM order. */
47
76
  export function getTabbable(container) {
48
77
  return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter((n) => isTabbable(n, container));
@@ -60,9 +89,9 @@ export function getTabbable(container) {
60
89
  */
61
90
  export function getInitialFocus(container, preferredSelector, { lastResort } = {}) {
62
91
  if (preferredSelector) {
63
- const preferred = container.querySelector(preferredSelector);
64
- if (preferred)
65
- return preferred;
92
+ const { target } = findFocusTarget(container, preferredSelector);
93
+ if (target)
94
+ return target;
66
95
  }
67
96
  // [data-autofocus] first, then DOM order, skipping anything that can't take focus.
68
97
  const tabbable = getTabbable(container);
@@ -1 +1 @@
1
- (()=>{var j=Object.defineProperty;var z=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})};var D={};z(D,{MODAL_CLOSE_EVENT:()=>V,MODAL_OPEN_EVENT:()=>L,close:()=>p,init:()=>H,open:()=>X});var K=["[data-autofocus]","a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function h(e,t){if(e.matches(":disabled")||e.closest("[inert]"))return!1;if(typeof e.checkVisibility=="function")return e.checkVisibility({visibilityProperty:!0});for(let n=e;n&&n!==t;n=n.parentElement){if(n.hidden)return!1;let o=getComputedStyle(n);if(o.display==="none"||n===e&&o.visibility==="hidden")return!1}return!0}function x(e){return Array.from(e.querySelectorAll(K)).filter(t=>h(t,e))}var $="tui-modal-open",b="tuiScrollLock";function C(){return Number(document.body.dataset[b]??0)||0}function k(){document.body.dataset[b]=String(C()+1),document.body.classList.add($)}function w(){let e=C()-1;if(e>0){document.body.dataset[b]=String(e);return}delete document.body.dataset[b],document.body.classList.remove($)}var g="data-tui-modal-open",u="data-tui-modal-close",Y="data-tui-modal-backdrop",M="data-tui-modal-src",_="data-tui-modal-restore-focus",J=".tui-modal__close",Q=":scope > .tui-modal__dialog",Z="iframe, object, embed, audio, video",ee=1e3,L="tui-modal-open",V="tui-modal-close",f=new WeakMap,m=new WeakMap,O=new WeakSet,y=null,E=null,P=0;function s(e){console.warn(`[TUI modal] ${e}`)}function c(e){let t=e.getAttribute("data-state");return t==="open"||t==="closing"}function T(e){return e.querySelector(Q)}function N(e){return e.matches(":disabled")||e.closest('[aria-disabled="true"]')!==null}function G(e){if(typeof e!="string")return e;let t=document.getElementById(e);return t instanceof HTMLDialogElement?t:(s(t?`#${e} is a <${t.tagName.toLowerCase()}>, not a <dialog>. The modal must be a <dialog> element.`:`No element with id "${e}".`),null)}function B(e){return e.split(/\s+/).filter(t=>t&&!document.getElementById(t))}function te(e){if(O.has(e))return;O.add(e);let t=`<dialog id="${e.id}">`,n=e.getAttribute("aria-labelledby"),o=e.getAttribute("aria-describedby");if(n){let r=B(n);r.length&&s(`${t} has aria-labelledby="${n}", but nothing has the id ${r.map(a=>`"${a}"`).join(", ")}, so the dialog has no name. Give the heading that id.`)}else e.hasAttribute("aria-label")||s(`${t} has no accessible name. Point aria-labelledby at its visible heading (WCAG 4.1.2).`);o&&B(o).length&&s(`${t} has aria-describedby="${o}", but not every id in it exists.`),e.getAttribute("role")==="alertdialog"&&!o&&s(`${t} is role="alertdialog" without aria-describedby. Point it at the message, or screen readers announce the heading and nothing about what is being confirmed.`),T(e)||s(`${t} has no .tui-modal__dialog box as its child. The box is the visible dialog; without it the backdrop can't be told apart and backdrop clicks are ignored.`),e.querySelector(`[${u}], form[method="dialog"]`)||Array.from(document.querySelectorAll(`[${u}]`)).some(r=>r.getAttribute(u)===e.id)||s(`${t} has no close control. Touch screen-reader users have no Escape key; add a button with ${u}.`)}function ne(e){let t=e.getAttribute(Y);return t==="dismiss"?!0:t==="static"?!1:e.getAttribute("role")!=="alertdialog"}function R(e){let t=getComputedStyle(e),n=r=>{let a=parseFloat(r);return Number.isNaN(a)?0:r.trim().endsWith("ms")?a:a*1e3},o=t.transitionDuration.split(","),i=t.transitionDelay.split(",");return Math.max(0,...o.map((r,a)=>n(r)+n(i[a%i.length]??"")))}function oe(e){let t=T(e),n=Math.min(ee,Math.max(R(e),t?R(t):0));return n>0?new Promise(o=>setTimeout(o,n)):Promise.resolve()}function ie(e){let t=e.querySelector("[autofocus], [data-autofocus]");if(t&&h(t,e))return t;let n=x(e).filter(o=>!o.matches(Z));return n.find(o=>!o.matches(J))??n[0]??e}function X(e,t){let n=G(e);if(!n)return!1;if(n.getAttribute("data-state")==="closing")return m.delete(n),t&&f.set(n,t),n.setAttribute("data-state","open"),v(n,L,{opener:f.get(n)??null}),!0;if(n.open&&c(n))return!0;c(n)&&A(n),n.open&&(s(`<dialog id="${n.id}"> was already open, not as a modal. Drop the open attribute from the markup.`),n.close()),te(n);try{n.showModal()}catch(l){return s(`<dialog id="${n.id}"> couldn't open: ${l.message}`),!1}k();let o=document.activeElement,i=t??(o instanceof HTMLElement&&o!==document.body?o:null);f.set(n,i);for(let l of n.querySelectorAll(`[${M}]`))l.hasAttribute("src")||l.setAttribute("src",l.getAttribute(M)??"");let r=T(n)??n,a=ie(r);return a===r&&!r.hasAttribute("tabindex")&&(r.tabIndex=-1),a.focus(),n.offsetWidth,n.setAttribute("data-state","open"),v(n,L,{opener:i}),!0}function p(e){let t=G(e);if(!t?.open)return Promise.resolve();if(!c(t))return t.close(),Promise.resolve();let n=m.get(t);if(n)return n;t.setAttribute("data-state","closing");let o=oe(t).then(()=>{m.get(t)===o&&(t.close(),A(t))});return m.set(t,o),o}function v(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}function A(e){if(!c(e))return;e.setAttribute("data-state","closed"),m.delete(e);for(let n of e.querySelectorAll("audio, video"))n.paused||n.pause();for(let n of e.querySelectorAll(`[${M}][src]`)){n.removeAttribute("src");let o=n.parentNode,i=n.nextSibling;n.remove(),o?.insertBefore(n,i)}w();let t=f.get(e)??null;f.delete(e),re(e,t),v(e,V,{opener:t,returnValue:e.returnValue})}function re(e,t){let n=e.getAttribute(_),o=[n?document.getElementById(n):null,t,...Array.from(document.querySelectorAll(`[${g}]`)).filter(i=>i.getAttribute(g)===e.id)];for(let i of o)if(!(!i?.isConnected||i===document.body)&&(i.focus(),document.activeElement===i))return;!t&&!n||s(`Focus had nowhere to return when <dialog id="${e.id}"> closed: its trigger is gone or can't take focus, so focus fell to <body> (WCAG 2.4.3). Set ${_}="<id>" on the dialog to name an element that will still be there.`)}function ae(e){return e.matches('a[href], input[type="submit"]')?!0:e instanceof HTMLButtonElement&&e.type==="submit"&&e.form!==null}function I(e){y=e.target,E=null}function q(e){E=e.target}function U(e){let t=y,n=E;y=E=null;let o=e.target;if(!(o instanceof Element))return;let i=o.closest(`[${g}]`);if(i){if(N(i))return;e.preventDefault(),X(i.getAttribute(g)??"",i);return}let r=o.closest(`[${u}]`);if(r){if(N(r))return;let l=r.getAttribute(u)||r.closest("dialog");if(!l){s(`A [${u}] control is outside any <dialog>. Give it the dialog's id as its value.`);return}ae(r)||e.preventDefault(),p(l);return}o instanceof HTMLDialogElement&&c(o)&&t===o&&n===o&&T(o)!==null&&ne(o)&&!se(o,e)&&p(o)}function se(e,t){let{clientWidth:n,clientHeight:o}=e;return n>0&&t.offsetX>=n||o>0&&t.offsetY>=o}function W(e){let t=e.target;!(t instanceof HTMLDialogElement)||!c(t)||e.cancelable&&(e.preventDefault(),p(t))}function F(e){let t=e.target;t instanceof HTMLDialogElement&&!t.open&&A(t)}function H(){P++===0&&(document.addEventListener("pointerdown",I,!0),document.addEventListener("pointerup",q,!0),document.addEventListener("click",U),document.addEventListener("cancel",W,!0),document.addEventListener("close",F,!0));let e=!1;return()=>{e||(e=!0,!(--P>0)&&(document.removeEventListener("pointerdown",I,!0),document.removeEventListener("pointerup",q,!0),document.removeEventListener("click",U),document.removeEventListener("cancel",W,!0),document.removeEventListener("close",F,!0)))}}var S=Symbol.for("tangible-ui/vanilla/modal"),d=globalThis;d[S]||(d[S]=D,H());d.TangibleUI=d.TangibleUI||{};d.TangibleUI.modal=d[S];})();
1
+ (()=>{var j=Object.defineProperty;var z=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})};var D={};z(D,{MODAL_CLOSE_EVENT:()=>V,MODAL_OPEN_EVENT:()=>L,close:()=>p,init:()=>H,open:()=>X});var K=["[data-autofocus]","a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function h(e,t){if(e.matches(":disabled")||e.closest("[inert]"))return!1;if(typeof e.checkVisibility=="function")return e.checkVisibility({visibilityProperty:!0});for(let n=e;n&&n!==t;n=n.parentElement){if(n.hidden)return!1;let o=getComputedStyle(n);if(o.display==="none"||n===e&&o.visibility==="hidden")return!1}return!0}function x(e){return Array.from(e.querySelectorAll(K)).filter(t=>h(t,e))}var $="tui-modal-open",b="tuiScrollLock";function k(){return Number(document.body.dataset[b]??0)||0}function C(){document.body.dataset[b]=String(k()+1),document.body.classList.add($)}function w(){let e=k()-1;if(e>0){document.body.dataset[b]=String(e);return}delete document.body.dataset[b],document.body.classList.remove($)}var g="data-tui-modal-open",u="data-tui-modal-close",Y="data-tui-modal-backdrop",M="data-tui-modal-src",_="data-tui-modal-restore-focus",J=".tui-modal__close",Q=":scope > .tui-modal__dialog",Z="iframe, object, embed, audio, video",ee=1e3,L="tui-modal-open",V="tui-modal-close",m=new WeakMap,f=new WeakMap,O=new WeakSet,y=null,E=null,P=0;function l(e){console.warn(`[TUI modal] ${e}`)}function c(e){let t=e.getAttribute("data-state");return t==="open"||t==="closing"}function T(e){return e.querySelector(Q)}function N(e){return e.matches(":disabled")||e.closest('[aria-disabled="true"]')!==null}function G(e){if(typeof e!="string")return e;let t=document.getElementById(e);return t instanceof HTMLDialogElement?t:(l(t?`#${e} is a <${t.tagName.toLowerCase()}>, not a <dialog>. The modal must be a <dialog> element.`:`No element with id "${e}".`),null)}function B(e){return e.split(/\s+/).filter(t=>t&&!document.getElementById(t))}function te(e){if(O.has(e))return;O.add(e);let t=`<dialog id="${e.id}">`,n=e.getAttribute("aria-labelledby"),o=e.getAttribute("aria-describedby");if(n){let r=B(n);r.length&&l(`${t} has aria-labelledby="${n}", but nothing has the id ${r.map(a=>`"${a}"`).join(", ")}, so the dialog has no name. Give the heading that id.`)}else e.hasAttribute("aria-label")||l(`${t} has no accessible name. Point aria-labelledby at its visible heading (WCAG 4.1.2).`);o&&B(o).length&&l(`${t} has aria-describedby="${o}", but not every id in it exists.`),e.getAttribute("role")==="alertdialog"&&!o&&l(`${t} is role="alertdialog" without aria-describedby. Point it at the message, or screen readers announce the heading and nothing about what is being confirmed.`),T(e)||l(`${t} has no .tui-modal__dialog box as its child. The box is the visible dialog; without it the backdrop can't be told apart and backdrop clicks are ignored.`),e.querySelector(`[${u}], form[method="dialog"]`)||Array.from(document.querySelectorAll(`[${u}]`)).some(r=>r.getAttribute(u)===e.id)||l(`${t} has no close control. Touch screen-reader users have no Escape key; add a button with ${u}.`)}function ne(e){let t=e.getAttribute(Y);return t==="dismiss"?!0:t==="static"?!1:e.getAttribute("role")!=="alertdialog"}function R(e){let t=getComputedStyle(e),n=r=>{let a=parseFloat(r);return Number.isNaN(a)?0:r.trim().endsWith("ms")?a:a*1e3},o=t.transitionDuration.split(","),i=t.transitionDelay.split(",");return Math.max(0,...o.map((r,a)=>n(r)+n(i[a%i.length]??"")))}function oe(e){let t=T(e),n=Math.min(ee,Math.max(R(e),t?R(t):0));return n>0?new Promise(o=>setTimeout(o,n)):Promise.resolve()}function ie(e){let t=e.querySelector("[autofocus], [data-autofocus]");if(t&&h(t,e))return t;let n=x(e).filter(o=>!o.matches(Z));return n.find(o=>!o.matches(J))??n[0]??e}function X(e,t){let n=G(e);if(!n)return!1;if(n.getAttribute("data-state")==="closing")return f.delete(n),t&&m.set(n,t),n.setAttribute("data-state","open"),v(n,L,{opener:m.get(n)??null}),!0;if(n.open&&c(n))return!0;c(n)&&A(n),n.open&&(l(`<dialog id="${n.id}"> was already open, not as a modal. Drop the open attribute from the markup.`),n.close()),te(n);try{n.showModal()}catch(s){return l(`<dialog id="${n.id}"> couldn't open: ${s.message}`),!1}C();let o=document.activeElement,i=t??(o instanceof HTMLElement&&o!==document.body?o:null);m.set(n,i);for(let s of n.querySelectorAll(`[${M}]`))s.hasAttribute("src")||s.setAttribute("src",s.getAttribute(M)??"");let r=T(n)??n,a=ie(r);return a===r&&!r.hasAttribute("tabindex")&&(r.tabIndex=-1),a.focus(),n.offsetWidth,n.setAttribute("data-state","open"),v(n,L,{opener:i}),!0}function p(e){let t=G(e);if(!t?.open)return Promise.resolve();if(!c(t))return t.close(),Promise.resolve();let n=f.get(t);if(n)return n;t.setAttribute("data-state","closing");let o=oe(t).then(()=>{f.get(t)===o&&(t.close(),A(t))});return f.set(t,o),o}function v(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}function A(e){if(!c(e))return;e.setAttribute("data-state","closed"),f.delete(e);for(let n of e.querySelectorAll("audio, video"))n.paused||n.pause();for(let n of e.querySelectorAll(`[${M}][src]`)){n.removeAttribute("src");let o=n.parentNode,i=n.nextSibling;n.remove(),o?.insertBefore(n,i)}w();let t=m.get(e)??null;m.delete(e),re(e,t),v(e,V,{opener:t,returnValue:e.returnValue})}function re(e,t){let n=e.getAttribute(_),o=[n?document.getElementById(n):null,t,...Array.from(document.querySelectorAll(`[${g}]`)).filter(i=>i.getAttribute(g)===e.id)];for(let i of o)if(!(!i?.isConnected||i===document.body)&&(i.focus(),document.activeElement===i))return;!t&&!n||l(`Focus had nowhere to return when <dialog id="${e.id}"> closed: its trigger is gone or can't take focus, so focus fell to <body> (WCAG 2.4.3). Set ${_}="<id>" on the dialog to name an element that will still be there.`)}function ae(e){return e.matches('a[href], input[type="submit"]')?!0:e instanceof HTMLButtonElement&&e.type==="submit"&&e.form!==null}function I(e){y=e.target,E=null}function q(e){E=e.target}function F(e){let t=y,n=E;y=E=null;let o=e.target;if(!(o instanceof Element))return;let i=o.closest(`[${g}]`);if(i){if(N(i))return;e.preventDefault(),X(i.getAttribute(g)??"",i);return}let r=o.closest(`[${u}]`);if(r){if(N(r))return;let s=r.getAttribute(u)||r.closest("dialog");if(!s){l(`A [${u}] control is outside any <dialog>. Give it the dialog's id as its value.`);return}ae(r)||e.preventDefault(),p(s);return}o instanceof HTMLDialogElement&&c(o)&&t===o&&n===o&&T(o)!==null&&ne(o)&&!le(o,e)&&p(o)}function le(e,t){let{clientWidth:n,clientHeight:o}=e;return n>0&&t.offsetX>=n||o>0&&t.offsetY>=o}function U(e){let t=e.target;!(t instanceof HTMLDialogElement)||!c(t)||e.cancelable&&(e.preventDefault(),p(t))}function W(e){let t=e.target;t instanceof HTMLDialogElement&&!t.open&&A(t)}function H(){P++===0&&(document.addEventListener("pointerdown",I,!0),document.addEventListener("pointerup",q,!0),document.addEventListener("click",F),document.addEventListener("cancel",U,!0),document.addEventListener("close",W,!0));let e=!1;return()=>{e||(e=!0,!(--P>0)&&(document.removeEventListener("pointerdown",I,!0),document.removeEventListener("pointerup",q,!0),document.removeEventListener("click",F),document.removeEventListener("cancel",U,!0),document.removeEventListener("close",W,!0)))}}var S=Symbol.for("tangible-ui/vanilla/modal"),d=globalThis;d[S]||(d[S]=D,H());d.TangibleUI=d.TangibleUI||{};d.TangibleUI.modal=d[S];})();