@tangible/ui 0.2.43 → 0.2.45

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
  }
@@ -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.43",
3
- "generated": "2026-11-22T16:47:58.494Z",
2
+ "version": "0.2.45",
3
+ "generated": "2026-11-22T19:16:27.737Z",
4
4
  "components": {
5
5
  "Accordion": {
6
6
  "props": {
@@ -4453,6 +4453,12 @@
4453
4453
  "required": false,
4454
4454
  "defaultValue": "'description'",
4455
4455
  "description": "`label` when the tooltip repeats the trigger's accessible name, as on an\nicon-only button; see `TooltipType`."
4456
+ },
4457
+ "closeOnPress": {
4458
+ "type": "boolean",
4459
+ "required": false,
4460
+ "defaultValue": "true",
4461
+ "description": "Close when the trigger is pressed (pointerdown on the primary button,\nEnter or Space, or the click they produce), and stay closed until the\npointer leaves or focus leaves and comes back. That keeps a label from\nsitting over the popover, menu or drawer its trigger just opened.\n\nSet `false` when the tooltip is the press's feedback, such as a copy\nbutton whose tooltip swaps to \"Copied\". The tooltip still never opens\nwhile the trigger's popup is open (`aria-expanded=\"true\"` with\n`aria-haspopup`), whatever this is set to."
4456
4462
  }
4457
4463
  },
4458
4464
  "cssTokens": [
@@ -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[$];})();