@tangible/ui 0.2.42 → 0.2.44

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.
@@ -440,15 +440,19 @@ $_typography-lineHeight: var(--#{sys.$prefix}button-line-height, 1.4);
440
440
  // Forced colors (high contrast mode)
441
441
  // ---------------------------------------------------------------------------
442
442
  @media (forced-colors: active) {
443
+ // !important throughout: the base rules set these colours !important (to
444
+ // beat WordPress), so without it none of this block ever applied. The
445
+ // colours match IconButton's, so both buttons read alike.
443
446
  .#{sys.$prefix}interface .#{sys.$prefix}button {
444
447
  forced-color-adjust: none;
445
- background-color: CanvasText;
446
- color: Canvas;
447
- border-color: CanvasText;
448
+ background-color: Canvas !important;
449
+ color: CanvasText !important;
450
+ border-color: CanvasText !important;
448
451
 
449
452
  &:is(:hover, :active) {
450
- background-color: Highlight;
451
- border-color: Highlight;
453
+ background-color: Highlight !important;
454
+ color: Canvas !important;
455
+ border-color: Highlight !important;
452
456
  }
453
457
 
454
458
  &:focus-visible {
@@ -457,16 +461,19 @@ $_typography-lineHeight: var(--#{sys.$prefix}button-line-height, 1.4);
457
461
  }
458
462
 
459
463
  &.is-style-link {
460
- background-color: transparent;
461
- color: LinkText;
462
- border-color: transparent;
464
+ background-color: transparent !important;
465
+ color: LinkText !important;
466
+ border-color: transparent !important;
463
467
  }
464
468
 
469
+ // aria-disabled too, as IconButton does: Pager's boundary buttons and
470
+ // loading Buttons are aria-disabled.
465
471
  &[disabled],
472
+ &[aria-disabled="true"],
466
473
  &.is-disabled {
467
- color: GrayText;
468
- border-color: GrayText;
469
- background-color: Canvas;
474
+ color: GrayText !important;
475
+ border-color: GrayText !important;
476
+ background-color: Canvas !important;
470
477
  }
471
478
  }
472
479
  }
@@ -9,6 +9,9 @@
9
9
  --tui-icon-button-fg-interact
10
10
  --tui-icon-button-bg-pressed
11
11
  --tui-icon-button-fg-pressed
12
+ --tui-icon-button-badge-bg
13
+ --tui-icon-button-badge-fg
14
+ --tui-icon-button-badge-ring
12
15
  */
13
16
 
14
17
  @mixin styles() {
@@ -28,6 +31,10 @@
28
31
  // --tui-icon-button-fg-interact Hover/focus/active icon color
29
32
  // --tui-icon-button-bg-pressed Toggled-on (aria-pressed) background
30
33
  // --tui-icon-button-fg-pressed Toggled-on (aria-pressed) icon color
34
+ // --tui-icon-button-badge-bg Badge fill (count or dot)
35
+ // --tui-icon-button-badge-fg Badge count text
36
+ // --tui-icon-button-badge-ring Cut-out ring around the badge; set it to
37
+ // the surface the button sits on (a header)
31
38
  //
32
39
  // To override from consuming code:
33
40
  // .my-context .tui-icon-button { --tui-icon-button-bg: hotpink; }
@@ -60,6 +67,12 @@
60
67
  // This ratio keeps icons optically balanced within the square hit target.
61
68
  $_icon-scale: 0.75;
62
69
 
70
+ // Badge count text, in px on the typography multiplier like the ladder: 11px
71
+ // is one step below its smallest (12px), which filled a 16px pill edge to
72
+ // edge; 10px for the 14px pill at xs. Structural, like the icon scale.
73
+ $_badge-font-px: 11;
74
+ $_badge-font-px-xs: 10;
75
+
63
76
  // Note: NOT using :where() here - we need real specificity to compete with
64
77
  // WordPress theme styles in plugin contexts.
65
78
  .#{sys.$prefix}interface .#{sys.$prefix}icon-button {
@@ -296,6 +309,52 @@
296
309
  }
297
310
  }
298
311
 
312
+ // Badge: a count or dot on the icon's top-end corner. aria-hidden; the
313
+ // button's name carries the meaning (see badge.ts). Its start edge is
314
+ // pinned just past the icon's centre, so it tracks the icon at every size
315
+ // and a wide count ("99+") grows outward, away from the glyph. It
316
+ // overhangs the button's end edge, so it sits above later siblings
317
+ // (z-index) and takes clicks for its button (no pointer-events: none).
318
+ // It keeps full strength while loading: the count is still true.
319
+ &__badge {
320
+ --_badge-bg: var(--#{sys.$prefix}icon-button-badge-bg, var(--#{sys.$prefix}theme-primary-base));
321
+ --_badge-fg: var(--#{sys.$prefix}icon-button-badge-fg, var(--#{sys.$prefix}theme-primary-on-base));
322
+ --_badge-ring: var(--#{sys.$prefix}icon-button-badge-ring, var(--#{sys.$prefix}color-bg));
323
+ --_badge-h: 1rem;
324
+ --_icon-inset: calc(var(--_size) * #{(1 - $_icon-scale) * 0.5});
325
+ position: absolute;
326
+ z-index: 1;
327
+ inset-block-start: calc(var(--_icon-inset) - var(--_badge-h) / 3);
328
+ inset-inline-start: calc(50% + var(--_size) * #{$_icon-scale * 0.1});
329
+ box-sizing: border-box;
330
+ min-inline-size: var(--_badge-h);
331
+ block-size: var(--_badge-h);
332
+ padding-inline: var(--#{sys.$prefix}spacing-xxs);
333
+ display: inline-flex;
334
+ align-items: center;
335
+ justify-content: center;
336
+ border-radius: var(--#{sys.$prefix}radius-full);
337
+ background-color: var(--_badge-bg);
338
+ color: var(--_badge-fg);
339
+ box-shadow: 0 0 0 2px var(--_badge-ring);
340
+ font-size: calc(#{$_badge-font-px} * var(--#{sys.$prefix}typography-size-multiplier, calc(1rem / 16)));
341
+ font-weight: var(--#{sys.$prefix}typography-weight-semibold, 600);
342
+ font-variant-numeric: tabular-nums;
343
+ line-height: 1;
344
+ white-space: nowrap;
345
+
346
+ &.is-dot {
347
+ --_badge-h: 0.5rem;
348
+ padding: 0;
349
+ }
350
+ }
351
+
352
+ // xs: a 16px pill would cover most of an 18px glyph. Step the count down.
353
+ &.is-size-xs .#{sys.$prefix}icon-button__badge:not(.is-dot) {
354
+ --_badge-h: 0.875rem;
355
+ font-size: calc(#{$_badge-font-px-xs} * var(--#{sys.$prefix}typography-size-multiplier, calc(1rem / 16)));
356
+ }
357
+
299
358
  &__spinner {
300
359
  position: absolute;
301
360
  width: 1em;
@@ -316,24 +375,37 @@
316
375
  // Forced colors (high contrast mode)
317
376
  // ---------------------------------------------------------------------------
318
377
  @media (forced-colors: active) {
319
- .#{sys.$prefix}icon-button {
378
+ // Full specificity (0,2,0)+: the base rules are .tui-interface .tui-icon-button,
379
+ // and a bare class here lost to them, so these colours never applied.
380
+ .#{sys.$prefix}interface .#{sys.$prefix}icon-button {
320
381
  forced-color-adjust: none;
321
382
  background-color: Canvas;
322
383
  color: CanvasText;
323
384
  border-color: CanvasText;
324
385
  }
325
386
 
326
- .#{sys.$prefix}icon-button:is(:hover, :active) {
387
+ .#{sys.$prefix}interface .#{sys.$prefix}icon-button:is(:hover, :active) {
327
388
  background-color: Highlight;
328
389
  color: Canvas;
329
390
  }
330
391
 
331
- .#{sys.$prefix}icon-button:focus-visible {
392
+ // CanvasText, not Highlight: hover paints the button Highlight, and a
393
+ // Highlight badge would vanish into it.
394
+ // Forced colours drop box-shadow, so the cut-out ring is an outline here.
395
+ .#{sys.$prefix}interface .#{sys.$prefix}icon-button__badge {
396
+ forced-color-adjust: none;
397
+ background-color: CanvasText;
398
+ color: Canvas;
399
+ box-shadow: none;
400
+ outline: 2px solid Canvas;
401
+ }
402
+
403
+ .#{sys.$prefix}interface .#{sys.$prefix}icon-button:focus-visible {
332
404
  outline: 2px solid Highlight;
333
405
  outline-offset: 2px;
334
406
  }
335
407
 
336
- .#{sys.$prefix}icon-button:is(:disabled, [aria-disabled="true"]) {
408
+ .#{sys.$prefix}interface .#{sys.$prefix}icon-button:is(:disabled, [aria-disabled="true"]) {
337
409
  color: GrayText;
338
410
  border-color: GrayText;
339
411
  background-color: Canvas;
@@ -396,8 +396,19 @@
396
396
  }
397
397
  }
398
398
 
399
- // Body scroll locking helper
399
+ // Body scroll locking helper (src/utils/scroll-lock.ts). The padding fills
400
+ // the gutter the hidden scrollbar leaves, on the side it was on, so the
401
+ // page doesn't shift. Keyed to the lock class: whoever removes the class
402
+ // removes the padding. !important so a host's body padding can't undo it.
400
403
  .#{sys.$prefix}modal-open {
401
404
  overflow: hidden;
405
+
406
+ &.#{sys.$prefix}scroll-lock-pad-right {
407
+ padding-right: var(--#{sys.$prefix}scroll-lock-pad) !important;
408
+ }
409
+
410
+ &.#{sys.$prefix}scroll-lock-pad-left {
411
+ padding-left: var(--#{sys.$prefix}scroll-lock-pad) !important;
412
+ }
402
413
  }
403
414
  }
@@ -61,11 +61,21 @@
61
61
 
62
62
  &__bulkActions {
63
63
  display: flex;
64
+ flex-wrap: wrap;
64
65
  align-items: center;
65
66
  gap: var(--#{sys.$prefix}spacing-sm);
66
67
  padding-inline: var(--_padding);
67
68
  padding-block: var(--_padding);
68
69
  }
70
+
71
+ // The consumer's actions and Clear, spaced like any button row. Without
72
+ // its own flex the wrapper stacked its buttons flush against each other.
73
+ &__bulkActions__actions {
74
+ display: flex;
75
+ flex-wrap: wrap;
76
+ align-items: center;
77
+ gap: var(--#{sys.$prefix}spacing-xs);
78
+ }
69
79
  // Selection checkboxes
70
80
  input[type="checkbox"] {
71
81
  accent-color: var(--#{sys.$prefix}theme-primary-base);
package/tui-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.42",
3
- "generated": "2026-11-22T06:36:44.530Z",
2
+ "version": "0.2.44",
3
+ "generated": "2026-11-22T18:07:46.946Z",
4
4
  "components": {
5
5
  "Accordion": {
6
6
  "props": {
@@ -1650,8 +1650,8 @@
1650
1650
  "loadingLabel": {
1651
1651
  "type": "string",
1652
1652
  "required": false,
1653
- "defaultValue": "`${label}, loading` (English)",
1654
- "description": "Accessible label override during loading state. For i18n support."
1653
+ "defaultValue": "`${name}, loading` (English), where `name` includes any badge",
1654
+ "description": "Accessible label override during loading state. For i18n support. It\nis the whole busy name: include the badge count yourself if it matters."
1655
1655
  },
1656
1656
  "labels": {
1657
1657
  "type": "IconButtonLabels",
@@ -1675,6 +1675,23 @@
1675
1675
  "defaultValue": "'top'",
1676
1676
  "description": "Tooltip placement side."
1677
1677
  },
1678
+ "badge": {
1679
+ "type": "number",
1680
+ "required": false,
1681
+ "description": "A count on the button's corner: unread notifications, items in a cart.\nAbove `badgeMax` it shows \"99+\". `0`, a negative or a non-number shows\nnothing, so `badge={items.length}` needs no guard.\n\nThe count is part of the button's name, not only its look: \"Notifications,\n5 new\" (`labels.badgeCount`). The full count is spoken even when the badge\nis capped. Anything that replaces the name replaces the count with it: an\n`aria-label` or `aria-labelledby` (a dev warning fires), and\n`loadingLabel`, which is the whole busy name.\n\nA change of count is NOT announced: the name changes silently on a button\nthe user isn't on. If people need to know about an arrival right away,\ntell them with your own status message (a Toast).\n\nThe badge overhangs the button's end edge (a \"99+\" by about 10px at `sm`)\nand paints above later siblings, so leave a gap after a badged button.\nIts colour doesn't follow `theme`: it is `--tui-icon-button-badge-bg`\n(primary by default) on every button. Set `--tui-icon-button-badge-ring`\nto the surface the button sits on (a header) so its cut-out blends in.\n@example badge={unreadCount}"
1682
+ },
1683
+ "badgeDot": {
1684
+ "type": "boolean",
1685
+ "required": false,
1686
+ "defaultValue": "false",
1687
+ "description": "Show the badge as a dot instead of a number: \"there's something new\"\nwithout a count, or a quieter look for one. With a `badge` count as well,\nthe dot still speaks the count in the name."
1688
+ },
1689
+ "badgeMax": {
1690
+ "type": "number",
1691
+ "required": false,
1692
+ "defaultValue": "99",
1693
+ "description": "The largest count the badge shows; above it, the badge reads \"99+\". At\n`xs`, consider 9: a wide count overhangs a small button a long way.\nWhole numbers of 1 or more."
1694
+ },
1678
1695
  "shape": {
1679
1696
  "type": "\"square\" | \"circle\"",
1680
1697
  "required": false,
@@ -1731,7 +1748,10 @@
1731
1748
  "--tui-icon-button-bg-interact",
1732
1749
  "--tui-icon-button-fg-interact",
1733
1750
  "--tui-icon-button-bg-pressed",
1734
- "--tui-icon-button-fg-pressed"
1751
+ "--tui-icon-button-fg-pressed",
1752
+ "--tui-icon-button-badge-bg",
1753
+ "--tui-icon-button-badge-fg",
1754
+ "--tui-icon-button-badge-ring"
1735
1755
  ],
1736
1756
  "story": {
1737
1757
  "title": "Primitives/IconButton",
@@ -3,23 +3,69 @@
3
3
  // Blocks or L&L markup (vanilla) share a page. The count lives on <body>, not
4
4
  // in module scope, because each vanilla script is its own bundle with its own
5
5
  // copy of this module. The lock lifts only when the last holder releases it.
6
+ //
7
+ // Hiding overflow removes a classic scrollbar, so the page would widen under
8
+ // the dialog and anything centred or end-aligned would jump. The lock pads
9
+ // the body on the side the scrollbar was on, by exactly the width gained:
10
+ // measured, so overlay scrollbars and a reserved gutter (scrollbar-gutter:
11
+ // stable) get nothing. The side is measured too, not read from `dir`: it
12
+ // follows the root's direction, and browsers differ.
13
+ //
14
+ // The padding is a stylesheet rule keyed to the lock class (Modal's styles,
15
+ // which the vanilla sheet includes), fed by custom properties set here. So an
16
+ // older TUI bundle that only knows to remove the class still takes the
17
+ // padding with it, and `!important` in a layer beats a host's body padding.
18
+ // While locked, `--tui-scroll-lock-gutter-left` / `-right` on <body> carry the
19
+ // width for hosts to shift their own fixed bars by.
6
20
  const CLASS = 'tui-modal-open';
7
21
  const COUNT = 'tuiScrollLock'; // data-tui-scroll-lock
22
+ const PAD = '--tui-scroll-lock-pad';
23
+ const GUTTER = '--tui-scroll-lock-gutter';
24
+ const SIDES = ['left', 'right'];
8
25
  function count() {
9
26
  return Number(document.body.dataset[COUNT] ?? 0) || 0;
10
27
  }
28
+ /** Undoes the padding: on the last unlock, and before a first lock, in case an older bundle left it. */
29
+ function clearPadding(body) {
30
+ body.style.removeProperty(PAD);
31
+ for (const side of SIDES) {
32
+ body.classList.remove(`tui-scroll-lock-pad-${side}`);
33
+ body.style.removeProperty(`${GUTTER}-${side}`);
34
+ }
35
+ }
11
36
  /** Locks body scroll. Pair every call with one `unlockScroll()`. */
12
37
  export function lockScroll() {
13
- document.body.dataset[COUNT] = String(count() + 1);
14
- document.body.classList.add(CLASS);
38
+ const body = document.body;
39
+ const first = count() === 0;
40
+ body.dataset[COUNT] = String(count() + 1);
41
+ if (!first)
42
+ return;
43
+ clearPadding(body);
44
+ const root = document.documentElement;
45
+ const width = root.clientWidth;
46
+ const left = body.getBoundingClientRect().left;
47
+ body.classList.add(CLASS);
48
+ // clientWidth is a whole number, so at a fractional zoom this can be 1px off
49
+ const gained = root.clientWidth - width;
50
+ if (gained <= 0)
51
+ return;
52
+ // A scrollbar on the left held the page's start edge in; without it, the
53
+ // body moves left.
54
+ const side = body.getBoundingClientRect().left < left ? 'left' : 'right';
55
+ const own = parseFloat(getComputedStyle(body)[side === 'left' ? 'paddingLeft' : 'paddingRight']) || 0;
56
+ body.style.setProperty(PAD, `${own + gained}px`);
57
+ body.style.setProperty(`${GUTTER}-${side}`, `${gained}px`);
58
+ body.classList.add(`tui-scroll-lock-pad-${side}`);
15
59
  }
16
60
  /** Releases one lock; scroll returns when none are left. */
17
61
  export function unlockScroll() {
62
+ const body = document.body;
18
63
  const next = count() - 1;
19
64
  if (next > 0) {
20
- document.body.dataset[COUNT] = String(next);
65
+ body.dataset[COUNT] = String(next);
21
66
  return;
22
67
  }
23
- delete document.body.dataset[COUNT];
24
- document.body.classList.remove(CLASS);
68
+ delete body.dataset[COUNT];
69
+ body.classList.remove(CLASS);
70
+ clearPadding(body);
25
71
  }
@@ -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 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];})();
1
+ (()=>{var Y=Object.defineProperty;var J=(t,e)=>{for(var n in e)Y(t,n,{get:e[n],enumerable:!0})};var D={};J(D,{MODAL_CLOSE_EVENT:()=>j,MODAL_OPEN_EVENT:()=>y,close:()=>p,init:()=>S,open:()=>K});var Q=["[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(t,e){if(t.matches(":disabled")||t.closest("[inert]"))return!1;if(typeof t.checkVisibility=="function")return t.checkVisibility({visibilityProperty:!0});for(let n=t;n&&n!==e;n=n.parentElement){if(n.hidden)return!1;let o=getComputedStyle(n);if(o.display==="none"||n===t&&o.visibility==="hidden")return!1}return!0}function x(t){return Array.from(t.querySelectorAll(Q)).filter(e=>h(e,t))}var k="tui-modal-open",g="tuiScrollLock",C="--tui-scroll-lock-pad",w="--tui-scroll-lock-gutter",Z=["left","right"];function L(){return Number(document.body.dataset[g]??0)||0}function P(t){t.style.removeProperty(C);for(let e of Z)t.classList.remove(`tui-scroll-lock-pad-${e}`),t.style.removeProperty(`${w}-${e}`)}function _(){let t=document.body,e=L()===0;if(t.dataset[g]=String(L()+1),!e)return;P(t);let n=document.documentElement,o=n.clientWidth,r=t.getBoundingClientRect().left;t.classList.add(k);let i=n.clientWidth-o;if(i<=0)return;let l=t.getBoundingClientRect().left<r?"left":"right",a=parseFloat(getComputedStyle(t)[l==="left"?"paddingLeft":"paddingRight"])||0;t.style.setProperty(C,`${a+i}px`),t.style.setProperty(`${w}-${l}`,`${i}px`),t.classList.add(`tui-scroll-lock-pad-${l}`)}function O(){let t=document.body,e=L()-1;if(e>0){t.dataset[g]=String(e);return}delete t.dataset[g],t.classList.remove(k),P(t)}var b="data-tui-modal-open",c="data-tui-modal-close",tt="data-tui-modal-backdrop",M="data-tui-modal-src",R="data-tui-modal-restore-focus",et=".tui-modal__close",nt=":scope > .tui-modal__dialog",ot="iframe, object, embed, audio, video",it=1e3,y="tui-modal-open",j="tui-modal-close",m=new WeakMap,f=new WeakMap,B=new WeakSet,v=null,E=null,N=0;function s(t){console.warn(`[TUI modal] ${t}`)}function u(t){let e=t.getAttribute("data-state");return e==="open"||e==="closing"}function T(t){return t.querySelector(nt)}function I(t){return t.matches(":disabled")||t.closest('[aria-disabled="true"]')!==null}function z(t){if(typeof t!="string")return t;let e=document.getElementById(t);return e instanceof HTMLDialogElement?e:(s(e?`#${t} is a <${e.tagName.toLowerCase()}>, not a <dialog>. The modal must be a <dialog> element.`:`No element with id "${t}".`),null)}function q(t){return t.split(/\s+/).filter(e=>e&&!document.getElementById(e))}function rt(t){if(B.has(t))return;B.add(t);let e=`<dialog id="${t.id}">`,n=t.getAttribute("aria-labelledby"),o=t.getAttribute("aria-describedby");if(n){let i=q(n);i.length&&s(`${e} has aria-labelledby="${n}", but nothing has the id ${i.map(l=>`"${l}"`).join(", ")}, so the dialog has no name. Give the heading that id.`)}else t.hasAttribute("aria-label")||s(`${e} has no accessible name. Point aria-labelledby at its visible heading (WCAG 4.1.2).`);o&&q(o).length&&s(`${e} has aria-describedby="${o}", but not every id in it exists.`),t.getAttribute("role")==="alertdialog"&&!o&&s(`${e} 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(t)||s(`${e} 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.`),t.querySelector(`[${c}], form[method="dialog"]`)||Array.from(document.querySelectorAll(`[${c}]`)).some(i=>i.getAttribute(c)===t.id)||s(`${e} has no close control. Touch screen-reader users have no Escape key; add a button with ${c}.`)}function lt(t){let e=t.getAttribute(tt);return e==="dismiss"?!0:e==="static"?!1:t.getAttribute("role")!=="alertdialog"}function F(t){let e=getComputedStyle(t),n=i=>{let l=parseFloat(i);return Number.isNaN(l)?0:i.trim().endsWith("ms")?l:l*1e3},o=e.transitionDuration.split(","),r=e.transitionDelay.split(",");return Math.max(0,...o.map((i,l)=>n(i)+n(r[l%r.length]??"")))}function st(t){let e=T(t),n=Math.min(it,Math.max(F(t),e?F(e):0));return n>0?new Promise(o=>setTimeout(o,n)):Promise.resolve()}function at(t){let e=t.querySelector("[autofocus], [data-autofocus]");if(e&&h(e,t))return e;let n=x(t).filter(o=>!o.matches(ot));return n.find(o=>!o.matches(et))??n[0]??t}function K(t,e){let n=z(t);if(!n)return!1;if(n.getAttribute("data-state")==="closing")return f.delete(n),e&&m.set(n,e),n.setAttribute("data-state","open"),A(n,y,{opener:m.get(n)??null}),!0;if(n.open&&u(n))return!0;u(n)&&H(n),n.open&&(s(`<dialog id="${n.id}"> was already open, not as a modal. Drop the open attribute from the markup.`),n.close()),rt(n);try{n.showModal()}catch(a){return s(`<dialog id="${n.id}"> couldn't open: ${a.message}`),!1}_();let o=document.activeElement,r=e??(o instanceof HTMLElement&&o!==document.body?o:null);m.set(n,r);for(let a of n.querySelectorAll(`[${M}]`))a.hasAttribute("src")||a.setAttribute("src",a.getAttribute(M)??"");let i=T(n)??n,l=at(i);return l===i&&!i.hasAttribute("tabindex")&&(i.tabIndex=-1),l.focus(),n.offsetWidth,n.setAttribute("data-state","open"),A(n,y,{opener:r}),!0}function p(t){let e=z(t);if(!e?.open)return Promise.resolve();if(!u(e))return e.close(),Promise.resolve();let n=f.get(e);if(n)return n;e.setAttribute("data-state","closing");let o=st(e).then(()=>{f.get(e)===o&&(e.close(),H(e))});return f.set(e,o),o}function A(t,e,n){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:n}))}function H(t){if(!u(t))return;t.setAttribute("data-state","closed"),f.delete(t);for(let n of t.querySelectorAll("audio, video"))n.paused||n.pause();for(let n of t.querySelectorAll(`[${M}][src]`)){n.removeAttribute("src");let o=n.parentNode,r=n.nextSibling;n.remove(),o?.insertBefore(n,r)}O();let e=m.get(t)??null;m.delete(t),ct(t,e),A(t,j,{opener:e,returnValue:t.returnValue})}function ct(t,e){let n=t.getAttribute(R),o=[n?document.getElementById(n):null,e,...Array.from(document.querySelectorAll(`[${b}]`)).filter(r=>r.getAttribute(b)===t.id)];for(let r of o)if(!(!r?.isConnected||r===document.body)&&(r.focus(),document.activeElement===r))return;!e&&!n||s(`Focus had nowhere to return when <dialog id="${t.id}"> closed: its trigger is gone or can't take focus, so focus fell to <body> (WCAG 2.4.3). Set ${R}="<id>" on the dialog to name an element that will still be there.`)}function ut(t){return t.matches('a[href], input[type="submit"]')?!0:t instanceof HTMLButtonElement&&t.type==="submit"&&t.form!==null}function W(t){v=t.target,E=null}function U(t){E=t.target}function V(t){let e=v,n=E;v=E=null;let o=t.target;if(!(o instanceof Element))return;let r=o.closest(`[${b}]`);if(r){if(I(r))return;t.preventDefault(),K(r.getAttribute(b)??"",r);return}let i=o.closest(`[${c}]`);if(i){if(I(i))return;let a=i.getAttribute(c)||i.closest("dialog");if(!a){s(`A [${c}] control is outside any <dialog>. Give it the dialog's id as its value.`);return}ut(i)||t.preventDefault(),p(a);return}o instanceof HTMLDialogElement&&u(o)&&e===o&&n===o&&T(o)!==null&&lt(o)&&!dt(o,t)&&p(o)}function dt(t,e){let{clientWidth:n,clientHeight:o}=t;return n>0&&e.offsetX>=n||o>0&&e.offsetY>=o}function G(t){let e=t.target;!(e instanceof HTMLDialogElement)||!u(e)||t.cancelable&&(t.preventDefault(),p(e))}function X(t){let e=t.target;e instanceof HTMLDialogElement&&!e.open&&H(e)}function S(){N++===0&&(document.addEventListener("pointerdown",W,!0),document.addEventListener("pointerup",U,!0),document.addEventListener("click",V),document.addEventListener("cancel",G,!0),document.addEventListener("close",X,!0));let t=!1;return()=>{t||(t=!0,!(--N>0)&&(document.removeEventListener("pointerdown",W,!0),document.removeEventListener("pointerup",U,!0),document.removeEventListener("click",V),document.removeEventListener("cancel",G,!0),document.removeEventListener("close",X,!0)))}}var $=Symbol.for("tangible-ui/vanilla/modal"),d=globalThis;d[$]||(d[$]=D,S());d.TangibleUI=d.TangibleUI||{};d.TangibleUI.modal=d[$];})();