@digdir/designsystemet-web 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -15
- package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs +4 -4
- package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/cjs/breadcrumbs/breadcrumbs.cjs +1 -1
- package/dist/cjs/breadcrumbs/breadcrumbs.cjs.map +1 -1
- package/dist/cjs/clickdelegatefor/clickdelegatefor.cjs +1 -1
- package/dist/cjs/clickdelegatefor/clickdelegatefor.cjs.map +1 -1
- package/dist/cjs/dialog/dialog.cjs +1 -1
- package/dist/cjs/dialog/dialog.cjs.map +1 -1
- package/dist/cjs/error-summary/error-summary.cjs +1 -2
- package/dist/cjs/error-summary/error-summary.cjs.map +1 -1
- package/dist/cjs/field/field.cjs +1 -1
- package/dist/cjs/field/field.cjs.map +1 -1
- package/dist/cjs/fieldset/fieldset.cjs +1 -1
- package/dist/cjs/fieldset/fieldset.cjs.map +1 -1
- package/dist/cjs/focusgroup/focusgroup.cjs +2 -0
- package/dist/cjs/focusgroup/focusgroup.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/invokers/invokers.cjs.map +1 -1
- package/dist/cjs/packages/web/package.cjs +2 -0
- package/dist/cjs/packages/web/package.cjs.map +1 -0
- package/dist/cjs/pagination/pagination.cjs +1 -1
- package/dist/cjs/pagination/pagination.cjs.map +1 -1
- package/dist/cjs/popover/popover.cjs +1 -1
- package/dist/cjs/popover/popover.cjs.map +1 -1
- package/dist/cjs/readonly/readonly.cjs +1 -1
- package/dist/cjs/readonly/readonly.cjs.map +1 -1
- package/dist/cjs/suggestion/suggestion.cjs +1 -1
- package/dist/cjs/suggestion/suggestion.cjs.map +1 -1
- package/dist/cjs/toggle-group/toggle-group.cjs +1 -1
- package/dist/cjs/toggle-group/toggle-group.cjs.map +1 -1
- package/dist/cjs/tooltip/tooltip.cjs +1 -1
- package/dist/cjs/tooltip/tooltip.cjs.map +1 -1
- package/dist/cjs/utils/utils.cjs +1 -1
- package/dist/cjs/utils/utils.cjs.map +1 -1
- package/dist/custom-elements.json +189 -4
- package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js +4 -4
- package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js.map +1 -1
- package/dist/esm/breadcrumbs/breadcrumbs.js +1 -1
- package/dist/esm/breadcrumbs/breadcrumbs.js.map +1 -1
- package/dist/esm/clickdelegatefor/clickdelegatefor.js +1 -1
- package/dist/esm/clickdelegatefor/clickdelegatefor.js.map +1 -1
- package/dist/esm/dialog/dialog.js +1 -1
- package/dist/esm/dialog/dialog.js.map +1 -1
- package/dist/esm/error-summary/error-summary.js +1 -2
- package/dist/esm/error-summary/error-summary.js.map +1 -1
- package/dist/esm/field/field.js +1 -1
- package/dist/esm/field/field.js.map +1 -1
- package/dist/esm/fieldset/fieldset.js +1 -1
- package/dist/esm/fieldset/fieldset.js.map +1 -1
- package/dist/esm/focusgroup/focusgroup.js +2 -0
- package/dist/esm/focusgroup/focusgroup.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/invokers/invokers.js.map +1 -1
- package/dist/esm/packages/web/package.js +2 -0
- package/dist/esm/packages/web/package.js.map +1 -0
- package/dist/esm/pagination/pagination.js +1 -1
- package/dist/esm/pagination/pagination.js.map +1 -1
- package/dist/esm/popover/popover.js +1 -1
- package/dist/esm/popover/popover.js.map +1 -1
- package/dist/esm/readonly/readonly.js +1 -1
- package/dist/esm/readonly/readonly.js.map +1 -1
- package/dist/esm/suggestion/suggestion.js +1 -1
- package/dist/esm/suggestion/suggestion.js.map +1 -1
- package/dist/esm/toggle-group/toggle-group.js +1 -1
- package/dist/esm/toggle-group/toggle-group.js.map +1 -1
- package/dist/esm/tooltip/tooltip.js +1 -1
- package/dist/esm/tooltip/tooltip.js.map +1 -1
- package/dist/esm/utils/utils.js +1 -1
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/index.d.ts +18 -22
- package/dist/index.js +636 -263
- package/dist/umd/index.js +16 -11
- package/dist/umd/index.js.map +1 -1
- package/package.json +15 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
- [`readonly`](#readonly)
|
|
24
24
|
- [`<ds-suggestion>`](#ds-suggestion)
|
|
25
25
|
- [`<ds-tabs>`](#ds-tabs)
|
|
26
|
-
- [`
|
|
26
|
+
- [`focusgroup` (polyfill)](#focusgroup)
|
|
27
27
|
- [`data-tooltip`](#data-tooltip)
|
|
28
28
|
|
|
29
29
|
|
|
@@ -298,24 +298,22 @@ Extends `u-tabs` from u-elements. See documentation for [u-tabs](https://u-eleme
|
|
|
298
298
|
</ds-tabs>
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
-
## `
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
An observer will look for `data-toggle-group` and add proper arrow navigation plus Enter-key support.
|
|
301
|
+
## `focusgroup`
|
|
302
|
+
`focusgroup` is polyfilled [according to upcoming specification](https://open-ui.org/components/scoped-focusgroup.explainer/).
|
|
305
303
|
|
|
306
304
|
```html
|
|
307
|
-
<fieldset class="ds-toggle-group"
|
|
308
|
-
<label>
|
|
309
|
-
<input type="radio" name="alignment
|
|
310
|
-
Left
|
|
305
|
+
<fieldset class="ds-toggle-group" focusgroup="radiogroup" aria-label="Tekstjustering" data-variant="secondary">
|
|
306
|
+
<label class="ds-button">
|
|
307
|
+
<input type="radio" name="alignment" value="left" checked />
|
|
308
|
+
Left
|
|
311
309
|
</label>
|
|
312
|
-
<label>
|
|
313
|
-
<input type="radio" name="alignment
|
|
314
|
-
Center
|
|
310
|
+
<label class="ds-button">
|
|
311
|
+
<input type="radio" name="alignment" value="center" />
|
|
312
|
+
Center
|
|
315
313
|
</label>
|
|
316
|
-
<label>
|
|
317
|
-
<input type="radio" name="alignment
|
|
318
|
-
Right
|
|
314
|
+
<label class="ds-button">
|
|
315
|
+
<input type="radio" name="alignment" value="right" />
|
|
316
|
+
Right
|
|
319
317
|
</label>
|
|
320
318
|
</fieldset>
|
|
321
319
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var e=class extends Event{oldState;newState;constructor(e,{
|
|
2
|
-
${
|
|
1
|
+
var e=class extends Event{oldState;newState;constructor(e,t={}){let n=Object.assign({},t);delete n.oldState,delete n.newState,super(e,n),this.oldState=String(t.oldState||``),this.newState=String(t.newState||``)}},t=new WeakMap;function n(n,r,i){t.set(n,setTimeout(()=>{t.has(n)&&n.dispatchEvent(new e(`toggle`,{cancelable:!1,oldState:r,newState:i}))},0))}var r=globalThis.ShadowRoot||function(){},i=globalThis.HTMLDialogElement||function(){},a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap;function l(e){return c.get(e)||`hidden`}var u=new WeakMap;function d(e){return[...e].pop()}function f(e){let t=e.popoverTargetElement;if(!(t instanceof HTMLElement))return;let n=l(t);(e.popoverTargetAction!==`show`||n!==`showing`)&&(e.popoverTargetAction!==`hide`||n!==`hidden`)&&(n===`showing`?D(t,!0,!0):p(t,!1)&&(u.set(t,e),E(t)))}function p(e,t){return!(e.popover!==`auto`&&e.popover!==`manual`&&e.popover!==`hint`||!e.isConnected||t&&l(e)!==`showing`||!t&&l(e)!==`hidden`||e instanceof i&&e.hasAttribute(`open`)||document.fullscreenElement===e)}function m(e){if(!e)return 0;let t=o.get(document)||new Set,n=s.get(document)||new Set;return n.has(e)?[...n].indexOf(e)+t.size+1:t.has(e)?[...t].indexOf(e)+1:0}function h(e){let t=y(e),n=b(e);return m(t)>m(n)?t:n}function g(e){let t,n=s.get(e)||new Set,r=o.get(e)||new Set,i=n.size>0?n:r.size>0?r:null;return i?(t=d(i),t.isConnected?t:(i.delete(t),g(e))):null}function _(e){for(let t of e||[])if(!t.isConnected)e.delete(t);else return t;return null}function v(e){return typeof e.getRootNode==`function`?e.getRootNode():e.parentNode?v(e.parentNode):e}function y(e){for(;e;){if(e instanceof HTMLElement&&e.popover===`auto`&&c.get(e)===`showing`)return e;if(e=e instanceof Element&&e.assignedSlot||e.parentElement||v(e),e instanceof r&&(e=e.host),e instanceof Document)return}}function b(e){for(;e;){let t=e.popoverTargetElement;if(t instanceof HTMLElement)return t;if(e=e.parentElement||v(e),e instanceof r&&(e=e.host),e instanceof Document)return}}function x(e,t){let n=new Map,r=0;for(let e of t||[])n.set(e,r),r+=1;n.set(e,r),r+=1;let i=null;function a(t){if(!t)return;let r=!1,a=null;for(;!r;){if(a=y(t)||null,a===null||!n.has(a))return;(e.popover===`hint`||a.popover===`auto`)&&(r=!0),r||(t=a.parentElement)}let o=n.get(a)??null;(i===null||n.get(i)<o)&&(i=a)}return a(e.parentElement||v(e)),i}function S(e){return e.hidden||e instanceof r||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement||e instanceof HTMLFieldSetElement)&&e.disabled||e instanceof HTMLInputElement&&e.type===`hidden`||e instanceof HTMLAnchorElement&&e.href===``?!1:typeof e.tabIndex==`number`&&e.tabIndex!==-1}function C(e){if(e.shadowRoot&&e.shadowRoot.delegatesFocus!==!0)return null;let t=e;t.shadowRoot&&(t=t.shadowRoot);let n=t.querySelector(`[autofocus]`);if(n)return n;{let e=t.querySelectorAll(`slot`);for(let t of e){let e=t.assignedElements({flatten:!0});for(let t of e)if(t.hasAttribute(`autofocus`))return t;else if(n=t.querySelector(`[autofocus]`),n)return n}}let r=e.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),i=r.currentNode;for(;i;){if(S(i))return i;i=r.nextNode()}}function w(e){var t;(t=C(e))==null||t.focus()}var T=new WeakMap;function E(t){if(!p(t,!1))return;let r=t.ownerDocument;if(!t.dispatchEvent(new e(`beforetoggle`,{cancelable:!0,oldState:`closed`,newState:`open`}))||!p(t,!1))return;let i=!1,l=t.popover,d=null,f=x(t,o.get(r)||new Set),m=x(t,s.get(r)||new Set);if(l===`auto`&&(k(s.get(r)||new Set,i,!0),j(f||r,i,!0),d=`auto`),l===`hint`&&(m?(j(m,i,!0),d=`hint`):(k(s.get(r)||new Set,i,!0),f?(j(f,i,!0),d=`auto`):d=`hint`)),l===`auto`||l===`hint`){if(l!==t.popover||!p(t,!1))return;g(r)||(i=!0),d===`auto`?(o.has(r)||o.set(r,new Set),o.get(r).add(t)):d===`hint`&&(s.has(r)||s.set(r,new Set),s.get(r).add(t))}T.delete(t);let h=r.activeElement;t.classList.add(`:popover-open`),c.set(t,`showing`),a.has(r)||a.set(r,new Set),a.get(r).add(t),F(u.get(t),!0),w(t),i&&h&&t.popover===`auto`&&T.set(t,h),n(t,`closed`,`open`)}function D(t,r=!1,i=!1){var l,f;if(!p(t,!0))return;let m=t.ownerDocument;if([`auto`,`hint`].includes(t.popover)&&(j(t,r,i),!p(t,!0)))return;let h=o.get(m)||new Set,g=h.has(t)&&d(h)===t;if(F(u.get(t),!1),u.delete(t),i&&(t.dispatchEvent(new e(`beforetoggle`,{oldState:`open`,newState:`closed`})),g&&d(h)!==t&&j(t,r,i),!p(t,!0)))return;(l=a.get(m))==null||l.delete(t),h.delete(t),(f=s.get(m))==null||f.delete(t),t.classList.remove(`:popover-open`),c.set(t,`hidden`),i&&n(t,`open`,`closed`);let _=T.get(t);_&&(T.delete(t),r&&_.focus())}function O(e,t=!1,n=!1){let r=g(e);for(;r;)D(r,t,n),r=g(e)}function k(e,t=!1,n=!1){let r=_(e);for(;r;)D(r,t,n),r=_(e)}function A(e,t,n,r){let i=!1,a=!1;for(;i||!a;){a=!0;let o=null,s=!1;for(let n of t)if(n===e)s=!0;else if(s){o=n;break}if(!o)return;for(;l(o)===`showing`&&t.size;)D(d(t),n,r);t.has(e)&&d(t)!==e&&(i=!0),i&&(r=!1)}}function j(e,t,n){let r=e.ownerDocument||e;if(e instanceof Document)return O(r,t,n);if(s.get(r)?.has(e)){A(e,s.get(r),t,n);return}k(s.get(r)||new Set,t,n),o.get(r)?.has(e)&&A(e,o.get(r),t,n)}var M=new WeakMap;function N(e){if(!e.isTrusted)return;let t=e.composedPath()[0];if(!t)return;let n=t.ownerDocument;if(!g(n))return;let r=h(t);if(r&&e.type===`pointerdown`)M.set(n,r);else if(e.type===`pointerup`){let e=M.get(n)===r;M.delete(n),e&&j(r||n,!1,!0)}}var P=new WeakMap;function F(e,t=!1){if(!e)return;P.has(e)||P.set(e,e.getAttribute(`aria-expanded`));let n=e.popoverTargetElement;if(n instanceof HTMLElement&&n.popover===`auto`)e.setAttribute(`aria-expanded`,String(t));else{let t=P.get(e);t?e.setAttribute(`aria-expanded`,t):e.removeAttribute(`aria-expanded`)}}var I=globalThis.ShadowRoot||function(){},L=`popover-polyfill`;function R(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype==`object`&&`popover`in HTMLElement.prototype}function z(){return!!(document.body?.showPopover&&!/native code/i.test(document.body.showPopover.toString()))}function B(e,t,n){let r=e[t];Object.defineProperty(e,t,{value(e){return r.call(this,n(e))}})}var V=/(^|[^\\]):popover-open\b/g;function H(){return typeof globalThis.CSSLayerBlockRule==`function`}function U(e){let t=H(),n=(e??window.POPOVER_POLYFILL_OPTIONS?.layerName??L).split(`.`).map(CSS.escape).join(`.`);return`
|
|
2
|
+
${t?`@layer ${n} {`:``}
|
|
3
3
|
:where([popover]) {
|
|
4
4
|
position: fixed;
|
|
5
5
|
z-index: 2147483647;
|
|
@@ -59,6 +59,6 @@ ${e?`@layer popover-polyfill {`:``}
|
|
|
59
59
|
bottom: 0;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
${
|
|
63
|
-
`}var
|
|
62
|
+
${t?`}`:``}
|
|
63
|
+
`}var W=null;function G(e,t){let n=U(t);if(W===null)try{W=new CSSStyleSheet,W.replaceSync(n)}catch{W=!1}if(W===!1){let t=document.createElement(`style`);t.textContent=n,e instanceof Document?e.head.prepend(t):e.prepend(t)}else e.adoptedStyleSheets=[W,...e.adoptedStyleSheets]}function K(t){if(typeof window>`u`)return;let n=t?.layerName;window.ToggleEvent=window.ToggleEvent||e;function r(e){return e?.includes(`:popover-open`)&&(e=e.replace(V,`$1.\\:popover-open`)),e}B(Document.prototype,`querySelector`,r),B(Document.prototype,`querySelectorAll`,r),B(Element.prototype,`querySelector`,r),B(Element.prototype,`querySelectorAll`,r),B(Element.prototype,`matches`,r),B(Element.prototype,`closest`,r),B(DocumentFragment.prototype,`querySelectorAll`,r),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){if(!this.hasAttribute(`popover`))return null;let e=(this.getAttribute(`popover`)||``).toLowerCase();return e===``||e==`auto`?`auto`:e==`hint`?`hint`:`manual`},set(e){e===null?this.removeAttribute(`popover`):this.setAttribute(`popover`,e)}},showPopover:{enumerable:!0,configurable:!0,value(e={}){E(this)}},hidePopover:{enumerable:!0,configurable:!0,value(){D(this,!0,!0)}},togglePopover:{enumerable:!0,configurable:!0,value(e={}){return typeof e==`boolean`&&(e={force:e}),c.get(this)===`showing`&&e.force===void 0||e.force===!1?D(this,!0,!0):(e.force===void 0||e.force===!0)&&E(this),c.get(this)===`showing`}}});let i=Element.prototype.attachShadow;i&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(e){let t=i.call(this,e);return G(t,n),t}}});let a=HTMLElement.prototype.attachInternals;a&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){let e=a.call(this);return e.shadowRoot&&G(e.shadowRoot,n),e}}});let o=new WeakMap;function s(e){Object.defineProperties(e.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(e){if(e===null)this.removeAttribute(`popovertarget`),o.delete(this);else if(e instanceof Element)this.setAttribute(`popovertarget`,``),o.set(this,e);else throw TypeError(`popoverTargetElement must be an element or null`)},get(){if(this.localName!==`button`&&this.localName!==`input`||this.localName===`input`&&this.type!==`reset`&&this.type!==`image`&&this.type!==`button`||this.disabled||this.form&&this.type===`submit`)return null;let e=o.get(this);if(e&&e.isConnected)return e;if(e&&!e.isConnected)return o.delete(this),null;let t=v(this),n=this.getAttribute(`popovertarget`);return(t instanceof Document||t instanceof I)&&n&&t.getElementById(n)||null}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){let e=(this.getAttribute(`popovertargetaction`)||``).toLowerCase();return e===`show`||e===`hide`?e:`toggle`},set(e){this.setAttribute(`popovertargetaction`,e)}}})}s(HTMLButtonElement),s(HTMLInputElement);let l=e=>{if(e.defaultPrevented)return;let t=e.composedPath(),n=t[0];if(!(n instanceof Element)||n?.shadowRoot)return;let r=v(n);if(!(r instanceof I||r instanceof Document))return;let i=t.find(e=>e.matches?.call(e,`[popovertargetaction],[popovertarget]`));if(i){f(i),e.preventDefault();return}},u=e=>{let t=e.key,n=e.target;!e.defaultPrevented&&n&&(t===`Escape`||t===`Esc`)&&j(n.ownerDocument,!0,!0)};(e=>{e.addEventListener(`click`,l),e.addEventListener(`keydown`,u),e.addEventListener(`pointerdown`,N),e.addEventListener(`pointerup`,N)})(document),G(document,n)}exports.apply=K,exports.injectStyles=G,exports.isPolyfilled=z,exports.isSupported=R;
|
|
64
64
|
//# sourceMappingURL=popover-fn.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-fn.cjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@oddbird+popover-polyfill@0.6.1/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js"],"sourcesContent":["// src/events.ts\nvar ToggleEvent = class extends Event {\n oldState;\n newState;\n constructor(type, { oldState = \"\", newState = \"\", ...init } = {}) {\n super(type, init);\n this.oldState = String(oldState || \"\");\n this.newState = String(newState || \"\");\n }\n};\nvar popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();\nfunction queuePopoverToggleEventTask(element, oldState, newState) {\n popoverToggleTaskQueue.set(\n element,\n setTimeout(() => {\n if (!popoverToggleTaskQueue.has(element)) return;\n element.dispatchEvent(\n new ToggleEvent(\"toggle\", {\n cancelable: false,\n oldState,\n newState\n })\n );\n }, 0)\n );\n}\n\n// src/popover-helpers.ts\nvar ShadowRoot = globalThis.ShadowRoot || function() {\n};\nvar HTMLDialogElement = globalThis.HTMLDialogElement || function() {\n};\nvar topLayerElements = /* @__PURE__ */ new WeakMap();\nvar autoPopoverList = /* @__PURE__ */ new WeakMap();\nvar hintPopoverList = /* @__PURE__ */ new WeakMap();\nvar visibilityState = /* @__PURE__ */ new WeakMap();\nfunction getPopoverVisibilityState(popover) {\n return visibilityState.get(popover) || \"hidden\";\n}\nvar popoverInvoker = /* @__PURE__ */ new WeakMap();\nfunction lastSetElement(set) {\n return [...set].pop();\n}\nfunction popoverTargetAttributeActivationBehavior(element) {\n const popover = element.popoverTargetElement;\n if (!(popover instanceof HTMLElement)) {\n return;\n }\n const visibility = getPopoverVisibilityState(popover);\n if (element.popoverTargetAction === \"show\" && visibility === \"showing\") {\n return;\n }\n if (element.popoverTargetAction === \"hide\" && visibility === \"hidden\") return;\n if (visibility === \"showing\") {\n hidePopover(popover, true, true);\n } else if (checkPopoverValidity(popover, false)) {\n popoverInvoker.set(popover, element);\n showPopover(popover);\n }\n}\nfunction checkPopoverValidity(element, expectedToBeShowing) {\n if (element.popover !== \"auto\" && element.popover !== \"manual\" && element.popover !== \"hint\") {\n return false;\n }\n if (!element.isConnected) return false;\n if (expectedToBeShowing && getPopoverVisibilityState(element) !== \"showing\") {\n return false;\n }\n if (!expectedToBeShowing && getPopoverVisibilityState(element) !== \"hidden\") {\n return false;\n }\n if (element instanceof HTMLDialogElement && element.hasAttribute(\"open\")) {\n return false;\n }\n if (document.fullscreenElement === element) return false;\n return true;\n}\nfunction getStackPosition(popover) {\n if (!popover) return 0;\n const autoPopovers = autoPopoverList.get(document) || /* @__PURE__ */ new Set();\n const hintPopovers = hintPopoverList.get(document) || /* @__PURE__ */ new Set();\n if (hintPopovers.has(popover)) {\n return [...hintPopovers].indexOf(popover) + autoPopovers.size + 1;\n }\n if (autoPopovers.has(popover)) {\n return [...autoPopovers].indexOf(popover) + 1;\n }\n return 0;\n}\nfunction topMostClickedPopover(target) {\n const clickedPopover = nearestInclusiveOpenPopover(target);\n const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);\n if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {\n return clickedPopover;\n }\n return invokerPopover;\n}\nfunction topmostAutoOrHintPopover(document2) {\n let topmostPopover;\n const hintPopovers = hintPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopovers = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const usedStack = hintPopovers.size > 0 ? hintPopovers : autoPopovers.size > 0 ? autoPopovers : null;\n if (usedStack) {\n topmostPopover = lastSetElement(usedStack);\n if (!topmostPopover.isConnected) {\n usedStack.delete(topmostPopover);\n return topmostAutoOrHintPopover(document2);\n }\n return topmostPopover;\n }\n return null;\n}\nfunction topMostPopoverInList(list) {\n for (const popover of list || []) {\n if (!popover.isConnected) {\n list.delete(popover);\n } else {\n return popover;\n }\n }\n return null;\n}\nfunction getRootNode(node) {\n if (typeof node.getRootNode === \"function\") {\n return node.getRootNode();\n }\n if (node.parentNode) return getRootNode(node.parentNode);\n return node;\n}\nfunction nearestInclusiveOpenPopover(node) {\n while (node) {\n if (node instanceof HTMLElement && node.popover === \"auto\" && visibilityState.get(node) === \"showing\") {\n return node;\n }\n node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction nearestInclusiveTargetPopoverForInvoker(node) {\n while (node) {\n const nodePopover = node.popoverTargetElement;\n if (nodePopover instanceof HTMLElement) return nodePopover;\n node = node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction topMostPopoverAncestor(newPopover, list) {\n const popoverPositions = /* @__PURE__ */ new Map();\n let i = 0;\n for (const popover of list || []) {\n popoverPositions.set(popover, i);\n i += 1;\n }\n popoverPositions.set(newPopover, i);\n i += 1;\n let topMostPopoverAncestor2 = null;\n function checkAncestor(candidate) {\n if (!candidate) return;\n let okNesting = false;\n let candidateAncestor = null;\n let candidatePosition = null;\n while (!okNesting) {\n candidateAncestor = nearestInclusiveOpenPopover(candidate) || null;\n if (candidateAncestor === null) return;\n if (!popoverPositions.has(candidateAncestor)) return;\n if (newPopover.popover === \"hint\" || candidateAncestor.popover === \"auto\") {\n okNesting = true;\n }\n if (!okNesting) {\n candidate = candidateAncestor.parentElement;\n }\n }\n candidatePosition = popoverPositions.get(candidateAncestor);\n if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {\n topMostPopoverAncestor2 = candidateAncestor;\n }\n }\n checkAncestor(newPopover.parentElement || getRootNode(newPopover));\n return topMostPopoverAncestor2;\n}\nfunction isFocusable(focusTarget) {\n if (focusTarget.hidden || focusTarget instanceof ShadowRoot) return false;\n if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {\n if (focusTarget.disabled) return false;\n }\n if (focusTarget instanceof HTMLInputElement && focusTarget.type === \"hidden\") {\n return false;\n }\n if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === \"\") {\n return false;\n }\n return typeof focusTarget.tabIndex === \"number\" && focusTarget.tabIndex !== -1;\n}\nfunction focusDelegate(focusTarget) {\n if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {\n return null;\n }\n let whereToLook = focusTarget;\n if (whereToLook.shadowRoot) {\n whereToLook = whereToLook.shadowRoot;\n }\n let autoFocusDelegate = whereToLook.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n } else {\n const slots = whereToLook.querySelectorAll(\"slot\");\n for (const slot of slots) {\n const assignedElements = slot.assignedElements({ flatten: true });\n for (const el of assignedElements) {\n if (el.hasAttribute(\"autofocus\")) {\n return el;\n } else {\n autoFocusDelegate = el.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n }\n }\n }\n }\n }\n const walker = focusTarget.ownerDocument.createTreeWalker(\n whereToLook,\n NodeFilter.SHOW_ELEMENT\n );\n let descendant = walker.currentNode;\n while (descendant) {\n if (isFocusable(descendant)) {\n return descendant;\n }\n descendant = walker.nextNode();\n }\n}\nfunction popoverFocusingSteps(subject) {\n var _a;\n (_a = focusDelegate(subject)) == null ? void 0 : _a.focus();\n}\nvar previouslyFocusedElements = /* @__PURE__ */ new WeakMap();\nfunction showPopover(element) {\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n const document2 = element.ownerDocument;\n if (!element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n cancelable: true,\n oldState: \"closed\",\n newState: \"open\"\n })\n )) {\n return;\n }\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n let shouldRestoreFocus = false;\n const originalType = element.popover;\n let stackToAppendTo = null;\n const autoAncestor = topMostPopoverAncestor(\n element,\n autoPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n const hintAncestor = topMostPopoverAncestor(\n element,\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n if (originalType === \"auto\") {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n const ancestor = autoAncestor || document2;\n hideAllPopoversUntil(ancestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n }\n if (originalType === \"hint\") {\n if (hintAncestor) {\n hideAllPopoversUntil(hintAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"hint\";\n } else {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n if (autoAncestor) {\n hideAllPopoversUntil(autoAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n } else {\n stackToAppendTo = \"hint\";\n }\n }\n }\n if (originalType === \"auto\" || originalType === \"hint\") {\n if (originalType !== element.popover || !checkPopoverValidity(element, false)) {\n return;\n }\n if (!topmostAutoOrHintPopover(document2)) {\n shouldRestoreFocus = true;\n }\n if (stackToAppendTo === \"auto\") {\n if (!autoPopoverList.has(document2)) {\n autoPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n autoPopoverList.get(document2).add(element);\n } else if (stackToAppendTo === \"hint\") {\n if (!hintPopoverList.has(document2)) {\n hintPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n hintPopoverList.get(document2).add(element);\n }\n }\n previouslyFocusedElements.delete(element);\n const originallyFocusedElement = document2.activeElement;\n element.classList.add(\":popover-open\");\n visibilityState.set(element, \"showing\");\n if (!topLayerElements.has(document2)) {\n topLayerElements.set(document2, /* @__PURE__ */ new Set());\n }\n topLayerElements.get(document2).add(element);\n setInvokerAriaExpanded(popoverInvoker.get(element), true);\n popoverFocusingSteps(element);\n if (shouldRestoreFocus && originallyFocusedElement && element.popover === \"auto\") {\n previouslyFocusedElements.set(element, originallyFocusedElement);\n }\n queuePopoverToggleEventTask(element, \"closed\", \"open\");\n}\nfunction hidePopover(element, focusPreviousElement = false, fireEvents = false) {\n var _a, _b;\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n const document2 = element.ownerDocument;\n if ([\"auto\", \"hint\"].includes(element.popover)) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n const autoList = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopoverListContainsElement = autoList.has(element) && lastSetElement(autoList) === element;\n setInvokerAriaExpanded(popoverInvoker.get(element), false);\n popoverInvoker.delete(element);\n if (fireEvents) {\n element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n oldState: \"open\",\n newState: \"closed\"\n })\n );\n if (autoPopoverListContainsElement && lastSetElement(autoList) !== element) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n }\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n (_a = topLayerElements.get(document2)) == null ? void 0 : _a.delete(element);\n autoList.delete(element);\n (_b = hintPopoverList.get(document2)) == null ? void 0 : _b.delete(element);\n element.classList.remove(\":popover-open\");\n visibilityState.set(element, \"hidden\");\n if (fireEvents) {\n queuePopoverToggleEventTask(element, \"open\", \"closed\");\n }\n const previouslyFocusedElement = previouslyFocusedElements.get(element);\n if (previouslyFocusedElement) {\n previouslyFocusedElements.delete(element);\n if (focusPreviousElement) {\n previouslyFocusedElement.focus();\n }\n }\n}\nfunction closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {\n let popover = topmostAutoOrHintPopover(document2);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topmostAutoOrHintPopover(document2);\n }\n}\nfunction closeAllOpenPopoversInList(list, focusPreviousElement = false, fireEvents = false) {\n let popover = topMostPopoverInList(list);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topMostPopoverInList(list);\n }\n}\nfunction hidePopoverStackUntil(endpoint, set, focusPreviousElement, fireEvents) {\n let repeatingHide = false;\n let hasRunOnce = false;\n while (repeatingHide || !hasRunOnce) {\n hasRunOnce = true;\n let lastToHide = null;\n let foundEndpoint = false;\n for (const popover of set) {\n if (popover === endpoint) {\n foundEndpoint = true;\n } else if (foundEndpoint) {\n lastToHide = popover;\n break;\n }\n }\n if (!lastToHide) return;\n while (getPopoverVisibilityState(lastToHide) === \"showing\" && set.size) {\n hidePopover(lastSetElement(set), focusPreviousElement, fireEvents);\n }\n if (set.has(endpoint) && lastSetElement(set) !== endpoint) {\n repeatingHide = true;\n }\n if (repeatingHide) {\n fireEvents = false;\n }\n }\n}\nfunction hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {\n var _a, _b;\n const document2 = endpoint.ownerDocument || endpoint;\n if (endpoint instanceof Document) {\n return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);\n }\n if ((_a = hintPopoverList.get(document2)) == null ? void 0 : _a.has(endpoint)) {\n hidePopoverStackUntil(\n endpoint,\n hintPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n return;\n }\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n focusPreviousElement,\n fireEvents\n );\n if (!((_b = autoPopoverList.get(document2)) == null ? void 0 : _b.has(endpoint))) {\n return;\n }\n hidePopoverStackUntil(\n endpoint,\n autoPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n}\nvar popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();\nfunction lightDismissOpenPopovers(event) {\n if (!event.isTrusted) return;\n const target = event.composedPath()[0];\n if (!target) return;\n const document2 = target.ownerDocument;\n const topMostPopover = topmostAutoOrHintPopover(document2);\n if (!topMostPopover) return;\n const ancestor = topMostClickedPopover(target);\n if (ancestor && event.type === \"pointerdown\") {\n popoverPointerDownTargets.set(document2, ancestor);\n } else if (event.type === \"pointerup\") {\n const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;\n popoverPointerDownTargets.delete(document2);\n if (sameTarget) {\n hideAllPopoversUntil(ancestor || document2, false, true);\n }\n }\n}\nvar initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();\nfunction setInvokerAriaExpanded(el, force = false) {\n if (!el) return;\n if (!initialAriaExpandedValue.has(el)) {\n initialAriaExpandedValue.set(el, el.getAttribute(\"aria-expanded\"));\n }\n const popover = el.popoverTargetElement;\n if (popover instanceof HTMLElement && popover.popover === \"auto\") {\n el.setAttribute(\"aria-expanded\", String(force));\n } else {\n const initialValue = initialAriaExpandedValue.get(el);\n if (!initialValue) {\n el.removeAttribute(\"aria-expanded\");\n } else {\n el.setAttribute(\"aria-expanded\", initialValue);\n }\n }\n}\n\n// src/popover.ts\nvar ShadowRoot2 = globalThis.ShadowRoot || function() {\n};\nfunction isSupported() {\n return typeof HTMLElement !== \"undefined\" && typeof HTMLElement.prototype === \"object\" && \"popover\" in HTMLElement.prototype;\n}\nfunction isHintSupported() {\n const el = document.createElement(\"div\");\n el.setAttribute(\"popover\", \"hint\");\n return el.popover === \"hint\";\n}\nfunction isPolyfilled() {\n var _a;\n return Boolean(\n ((_a = document.body) == null ? void 0 : _a.showPopover) && !/native code/i.test(document.body.showPopover.toString())\n );\n}\nfunction patchSelectorFn(object, name, mapper) {\n const original = object[name];\n Object.defineProperty(object, name, {\n value(selector) {\n return original.call(this, mapper(selector));\n }\n });\n}\nvar nonEscapedPopoverSelector = /(^|[^\\\\]):popover-open\\b/g;\nfunction hasLayerSupport() {\n return typeof globalThis.CSSLayerBlockRule === \"function\";\n}\nfunction getStyles() {\n const useLayer = hasLayerSupport();\n return `\n${useLayer ? \"@layer popover-polyfill {\" : \"\"}\n :where([popover]) {\n position: fixed;\n z-index: 2147483647;\n inset: 0;\n padding: 0.25em;\n width: fit-content;\n height: fit-content;\n border-width: initial;\n border-color: initial;\n border-image: initial;\n border-style: solid;\n background-color: canvas;\n color: canvastext;\n overflow: auto;\n margin: auto;\n }\n\n :where([popover]:not(.\\\\:popover-open)) {\n display: none;\n }\n\n :where(dialog[popover].\\\\:popover-open) {\n display: block;\n }\n\n :where(dialog[popover][open]) {\n display: revert;\n }\n\n :where([anchor].\\\\:popover-open) {\n inset: auto;\n }\n\n :where([anchor]:popover-open) {\n inset: auto;\n }\n\n @supports not (background-color: canvas) {\n :where([popover]) {\n background-color: white;\n color: black;\n }\n }\n\n @supports (width: -moz-fit-content) {\n :where([popover]) {\n width: -moz-fit-content;\n height: -moz-fit-content;\n }\n }\n\n @supports not (inset: 0) {\n :where([popover]) {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n }\n${useLayer ? \"}\" : \"\"}\n`;\n}\nvar popoverStyleSheet = null;\nfunction injectStyles(root) {\n const styles = getStyles();\n if (popoverStyleSheet === null) {\n try {\n popoverStyleSheet = new CSSStyleSheet();\n popoverStyleSheet.replaceSync(styles);\n } catch {\n popoverStyleSheet = false;\n }\n }\n if (popoverStyleSheet === false) {\n const sheet = document.createElement(\"style\");\n sheet.textContent = styles;\n if (root instanceof Document) {\n root.head.prepend(sheet);\n } else {\n root.prepend(sheet);\n }\n } else {\n root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];\n }\n}\nfunction apply() {\n if (typeof window === \"undefined\") return;\n window.ToggleEvent = window.ToggleEvent || ToggleEvent;\n function rewriteSelector(selector) {\n if (selector == null ? void 0 : selector.includes(\":popover-open\")) {\n selector = selector.replace(\n nonEscapedPopoverSelector,\n \"$1.\\\\:popover-open\"\n );\n }\n return selector;\n }\n patchSelectorFn(Document.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Document.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"matches\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"closest\", rewriteSelector);\n patchSelectorFn(\n DocumentFragment.prototype,\n \"querySelectorAll\",\n rewriteSelector\n );\n Object.defineProperties(HTMLElement.prototype, {\n popover: {\n enumerable: true,\n configurable: true,\n get() {\n if (!this.hasAttribute(\"popover\")) return null;\n const value = (this.getAttribute(\"popover\") || \"\").toLowerCase();\n if (value === \"\" || value == \"auto\") return \"auto\";\n if (value == \"hint\") return \"hint\";\n return \"manual\";\n },\n set(value) {\n if (value === null) {\n this.removeAttribute(\"popover\");\n } else {\n this.setAttribute(\"popover\", value);\n }\n }\n },\n showPopover: {\n enumerable: true,\n configurable: true,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n value(options = {}) {\n showPopover(this);\n }\n },\n hidePopover: {\n enumerable: true,\n configurable: true,\n value() {\n hidePopover(this, true, true);\n }\n },\n togglePopover: {\n enumerable: true,\n configurable: true,\n value(options = {}) {\n if (typeof options === \"boolean\") {\n options = { force: options };\n }\n if (visibilityState.get(this) === \"showing\" && options.force === void 0 || options.force === false) {\n hidePopover(this, true, true);\n } else if (options.force === void 0 || options.force === true) {\n showPopover(this);\n }\n return visibilityState.get(this) === \"showing\";\n }\n }\n });\n const originalAttachShadow = Element.prototype.attachShadow;\n if (originalAttachShadow) {\n Object.defineProperties(Element.prototype, {\n attachShadow: {\n enumerable: true,\n configurable: true,\n writable: true,\n value(options) {\n const shadowRoot = originalAttachShadow.call(this, options);\n injectStyles(shadowRoot);\n return shadowRoot;\n }\n }\n });\n }\n const originalAttachInternals = HTMLElement.prototype.attachInternals;\n if (originalAttachInternals) {\n Object.defineProperties(HTMLElement.prototype, {\n attachInternals: {\n enumerable: true,\n configurable: true,\n writable: true,\n value() {\n const internals = originalAttachInternals.call(this);\n if (internals.shadowRoot) {\n injectStyles(internals.shadowRoot);\n }\n return internals;\n }\n }\n });\n }\n const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();\n function applyPopoverInvokerElementMixin(ElementClass) {\n Object.defineProperties(ElementClass.prototype, {\n popoverTargetElement: {\n enumerable: true,\n configurable: true,\n set(targetElement) {\n if (targetElement === null) {\n this.removeAttribute(\"popovertarget\");\n popoverTargetAssociatedElements.delete(this);\n } else if (!(targetElement instanceof Element)) {\n throw new TypeError(\n `popoverTargetElement must be an element or null`\n );\n } else {\n this.setAttribute(\"popovertarget\", \"\");\n popoverTargetAssociatedElements.set(this, targetElement);\n }\n },\n get() {\n if (this.localName !== \"button\" && this.localName !== \"input\") {\n return null;\n }\n if (this.localName === \"input\" && this.type !== \"reset\" && this.type !== \"image\" && this.type !== \"button\") {\n return null;\n }\n if (this.disabled) {\n return null;\n }\n if (this.form && this.type === \"submit\") {\n return null;\n }\n const targetElement = popoverTargetAssociatedElements.get(this);\n if (targetElement && targetElement.isConnected) {\n return targetElement;\n } else if (targetElement && !targetElement.isConnected) {\n popoverTargetAssociatedElements.delete(this);\n return null;\n }\n const root = getRootNode(this);\n const idref = this.getAttribute(\"popovertarget\");\n if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {\n return root.getElementById(idref) || null;\n }\n return null;\n }\n },\n popoverTargetAction: {\n enumerable: true,\n configurable: true,\n get() {\n const value = (this.getAttribute(\"popovertargetaction\") || \"\").toLowerCase();\n if (value === \"show\" || value === \"hide\") return value;\n return \"toggle\";\n },\n set(value) {\n this.setAttribute(\"popovertargetaction\", value);\n }\n }\n });\n }\n applyPopoverInvokerElementMixin(HTMLButtonElement);\n applyPopoverInvokerElementMixin(HTMLInputElement);\n const handleInvokerActivation = (event) => {\n if (event.defaultPrevented) {\n return;\n }\n const composedPath = event.composedPath();\n const target = composedPath[0];\n if (!(target instanceof Element) || (target == null ? void 0 : target.shadowRoot)) {\n return;\n }\n const root = getRootNode(target);\n if (!(root instanceof ShadowRoot2 || root instanceof Document)) {\n return;\n }\n const invoker = composedPath.find(\n (el) => {\n var _a;\n return (_a = el.matches) == null ? void 0 : _a.call(el, \"[popovertargetaction],[popovertarget]\");\n }\n );\n if (invoker) {\n popoverTargetAttributeActivationBehavior(invoker);\n event.preventDefault();\n return;\n }\n };\n const onKeydown = (event) => {\n const key = event.key;\n const target = event.target;\n if (!event.defaultPrevented && target && (key === \"Escape\" || key === \"Esc\")) {\n hideAllPopoversUntil(target.ownerDocument, true, true);\n }\n };\n const addEventListeners = (root) => {\n root.addEventListener(\"click\", handleInvokerActivation);\n root.addEventListener(\"keydown\", onKeydown);\n root.addEventListener(\"pointerdown\", lightDismissOpenPopovers);\n root.addEventListener(\"pointerup\", lightDismissOpenPopovers);\n };\n addEventListeners(document);\n injectStyles(document);\n}\nexport {\n apply,\n injectStyles,\n isHintSupported,\n isPolyfilled,\n isSupported\n};\n//# sourceMappingURL=popover-fn.js.map\n"],"x_google_ignoreList":[0],"m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iB,YAAa,CAAwB,CAC7D,EACA,CAAkB,QAAQ,EAC1B,EAAa,QAAQ,CACvB"}
|
|
1
|
+
{"version":3,"file":"popover-fn.cjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@oddbird+popover-polyfill@0.7.1/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js"],"sourcesContent":["// src/events.ts\nvar ToggleEvent = class extends Event {\n oldState;\n newState;\n constructor(type, init = {}) {\n const eventInit = Object.assign({}, init);\n delete eventInit.oldState;\n delete eventInit.newState;\n super(type, eventInit);\n this.oldState = String(init.oldState || \"\");\n this.newState = String(init.newState || \"\");\n }\n};\nvar popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();\nfunction queuePopoverToggleEventTask(element, oldState, newState) {\n popoverToggleTaskQueue.set(\n element,\n setTimeout(() => {\n if (!popoverToggleTaskQueue.has(element)) return;\n element.dispatchEvent(\n new ToggleEvent(\"toggle\", {\n cancelable: false,\n oldState,\n newState\n })\n );\n }, 0)\n );\n}\n\n// src/popover-helpers.ts\nvar ShadowRoot = globalThis.ShadowRoot || function() {\n};\nvar HTMLDialogElement = globalThis.HTMLDialogElement || function() {\n};\nvar topLayerElements = /* @__PURE__ */ new WeakMap();\nvar autoPopoverList = /* @__PURE__ */ new WeakMap();\nvar hintPopoverList = /* @__PURE__ */ new WeakMap();\nvar visibilityState = /* @__PURE__ */ new WeakMap();\nfunction getPopoverVisibilityState(popover) {\n return visibilityState.get(popover) || \"hidden\";\n}\nvar popoverInvoker = /* @__PURE__ */ new WeakMap();\nfunction lastSetElement(set) {\n return [...set].pop();\n}\nfunction popoverTargetAttributeActivationBehavior(element) {\n const popover = element.popoverTargetElement;\n if (!(popover instanceof HTMLElement)) {\n return;\n }\n const visibility = getPopoverVisibilityState(popover);\n if (element.popoverTargetAction === \"show\" && visibility === \"showing\") {\n return;\n }\n if (element.popoverTargetAction === \"hide\" && visibility === \"hidden\") return;\n if (visibility === \"showing\") {\n hidePopover(popover, true, true);\n } else if (checkPopoverValidity(popover, false)) {\n popoverInvoker.set(popover, element);\n showPopover(popover);\n }\n}\nfunction checkPopoverValidity(element, expectedToBeShowing) {\n if (element.popover !== \"auto\" && element.popover !== \"manual\" && element.popover !== \"hint\") {\n return false;\n }\n if (!element.isConnected) return false;\n if (expectedToBeShowing && getPopoverVisibilityState(element) !== \"showing\") {\n return false;\n }\n if (!expectedToBeShowing && getPopoverVisibilityState(element) !== \"hidden\") {\n return false;\n }\n if (element instanceof HTMLDialogElement && element.hasAttribute(\"open\")) {\n return false;\n }\n if (document.fullscreenElement === element) return false;\n return true;\n}\nfunction getStackPosition(popover) {\n if (!popover) return 0;\n const autoPopovers = autoPopoverList.get(document) || /* @__PURE__ */ new Set();\n const hintPopovers = hintPopoverList.get(document) || /* @__PURE__ */ new Set();\n if (hintPopovers.has(popover)) {\n return [...hintPopovers].indexOf(popover) + autoPopovers.size + 1;\n }\n if (autoPopovers.has(popover)) {\n return [...autoPopovers].indexOf(popover) + 1;\n }\n return 0;\n}\nfunction topMostClickedPopover(target) {\n const clickedPopover = nearestInclusiveOpenPopover(target);\n const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);\n if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {\n return clickedPopover;\n }\n return invokerPopover;\n}\nfunction topmostAutoOrHintPopover(document2) {\n let topmostPopover;\n const hintPopovers = hintPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopovers = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const usedStack = hintPopovers.size > 0 ? hintPopovers : autoPopovers.size > 0 ? autoPopovers : null;\n if (usedStack) {\n topmostPopover = lastSetElement(usedStack);\n if (!topmostPopover.isConnected) {\n usedStack.delete(topmostPopover);\n return topmostAutoOrHintPopover(document2);\n }\n return topmostPopover;\n }\n return null;\n}\nfunction topMostPopoverInList(list) {\n for (const popover of list || []) {\n if (!popover.isConnected) {\n list.delete(popover);\n } else {\n return popover;\n }\n }\n return null;\n}\nfunction getRootNode(node) {\n if (typeof node.getRootNode === \"function\") {\n return node.getRootNode();\n }\n if (node.parentNode) return getRootNode(node.parentNode);\n return node;\n}\nfunction nearestInclusiveOpenPopover(node) {\n while (node) {\n if (node instanceof HTMLElement && node.popover === \"auto\" && visibilityState.get(node) === \"showing\") {\n return node;\n }\n node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction nearestInclusiveTargetPopoverForInvoker(node) {\n while (node) {\n const nodePopover = node.popoverTargetElement;\n if (nodePopover instanceof HTMLElement) return nodePopover;\n node = node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction topMostPopoverAncestor(newPopover, list) {\n const popoverPositions = /* @__PURE__ */ new Map();\n let i = 0;\n for (const popover of list || []) {\n popoverPositions.set(popover, i);\n i += 1;\n }\n popoverPositions.set(newPopover, i);\n i += 1;\n let topMostPopoverAncestor2 = null;\n function checkAncestor(candidate) {\n if (!candidate) return;\n let okNesting = false;\n let candidateAncestor = null;\n while (!okNesting) {\n candidateAncestor = nearestInclusiveOpenPopover(candidate) || null;\n if (candidateAncestor === null) return;\n if (!popoverPositions.has(candidateAncestor)) return;\n if (newPopover.popover === \"hint\" || candidateAncestor.popover === \"auto\") {\n okNesting = true;\n }\n if (!okNesting) {\n candidate = candidateAncestor.parentElement;\n }\n }\n const candidatePosition = popoverPositions.get(candidateAncestor) ?? null;\n if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {\n topMostPopoverAncestor2 = candidateAncestor;\n }\n }\n checkAncestor(newPopover.parentElement || getRootNode(newPopover));\n return topMostPopoverAncestor2;\n}\nfunction isFocusable(focusTarget) {\n if (focusTarget.hidden || focusTarget instanceof ShadowRoot) return false;\n if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {\n if (focusTarget.disabled) return false;\n }\n if (focusTarget instanceof HTMLInputElement && focusTarget.type === \"hidden\") {\n return false;\n }\n if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === \"\") {\n return false;\n }\n return typeof focusTarget.tabIndex === \"number\" && focusTarget.tabIndex !== -1;\n}\nfunction focusDelegate(focusTarget) {\n if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {\n return null;\n }\n let whereToLook = focusTarget;\n if (whereToLook.shadowRoot) {\n whereToLook = whereToLook.shadowRoot;\n }\n let autoFocusDelegate = whereToLook.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n } else {\n const slots = whereToLook.querySelectorAll(\"slot\");\n for (const slot of slots) {\n const assignedElements = slot.assignedElements({ flatten: true });\n for (const el of assignedElements) {\n if (el.hasAttribute(\"autofocus\")) {\n return el;\n } else {\n autoFocusDelegate = el.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n }\n }\n }\n }\n }\n const walker = focusTarget.ownerDocument.createTreeWalker(\n whereToLook,\n NodeFilter.SHOW_ELEMENT\n );\n let descendant = walker.currentNode;\n while (descendant) {\n if (isFocusable(descendant)) {\n return descendant;\n }\n descendant = walker.nextNode();\n }\n}\nfunction popoverFocusingSteps(subject) {\n var _a;\n (_a = focusDelegate(subject)) == null ? void 0 : _a.focus();\n}\nvar previouslyFocusedElements = /* @__PURE__ */ new WeakMap();\nfunction showPopover(element) {\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n const document2 = element.ownerDocument;\n if (!element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n cancelable: true,\n oldState: \"closed\",\n newState: \"open\"\n })\n )) {\n return;\n }\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n let shouldRestoreFocus = false;\n const originalType = element.popover;\n let stackToAppendTo = null;\n const autoAncestor = topMostPopoverAncestor(\n element,\n autoPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n const hintAncestor = topMostPopoverAncestor(\n element,\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n if (originalType === \"auto\") {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n const ancestor = autoAncestor || document2;\n hideAllPopoversUntil(ancestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n }\n if (originalType === \"hint\") {\n if (hintAncestor) {\n hideAllPopoversUntil(hintAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"hint\";\n } else {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n if (autoAncestor) {\n hideAllPopoversUntil(autoAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n } else {\n stackToAppendTo = \"hint\";\n }\n }\n }\n if (originalType === \"auto\" || originalType === \"hint\") {\n if (originalType !== element.popover || !checkPopoverValidity(element, false)) {\n return;\n }\n if (!topmostAutoOrHintPopover(document2)) {\n shouldRestoreFocus = true;\n }\n if (stackToAppendTo === \"auto\") {\n if (!autoPopoverList.has(document2)) {\n autoPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n autoPopoverList.get(document2).add(element);\n } else if (stackToAppendTo === \"hint\") {\n if (!hintPopoverList.has(document2)) {\n hintPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n hintPopoverList.get(document2).add(element);\n }\n }\n previouslyFocusedElements.delete(element);\n const originallyFocusedElement = document2.activeElement;\n element.classList.add(\":popover-open\");\n visibilityState.set(element, \"showing\");\n if (!topLayerElements.has(document2)) {\n topLayerElements.set(document2, /* @__PURE__ */ new Set());\n }\n topLayerElements.get(document2).add(element);\n setInvokerAriaExpanded(popoverInvoker.get(element), true);\n popoverFocusingSteps(element);\n if (shouldRestoreFocus && originallyFocusedElement && element.popover === \"auto\") {\n previouslyFocusedElements.set(element, originallyFocusedElement);\n }\n queuePopoverToggleEventTask(element, \"closed\", \"open\");\n}\nfunction hidePopover(element, focusPreviousElement = false, fireEvents = false) {\n var _a, _b;\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n const document2 = element.ownerDocument;\n if ([\"auto\", \"hint\"].includes(element.popover)) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n const autoList = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopoverListContainsElement = autoList.has(element) && lastSetElement(autoList) === element;\n setInvokerAriaExpanded(popoverInvoker.get(element), false);\n popoverInvoker.delete(element);\n if (fireEvents) {\n element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n oldState: \"open\",\n newState: \"closed\"\n })\n );\n if (autoPopoverListContainsElement && lastSetElement(autoList) !== element) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n }\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n (_a = topLayerElements.get(document2)) == null ? void 0 : _a.delete(element);\n autoList.delete(element);\n (_b = hintPopoverList.get(document2)) == null ? void 0 : _b.delete(element);\n element.classList.remove(\":popover-open\");\n visibilityState.set(element, \"hidden\");\n if (fireEvents) {\n queuePopoverToggleEventTask(element, \"open\", \"closed\");\n }\n const previouslyFocusedElement = previouslyFocusedElements.get(element);\n if (previouslyFocusedElement) {\n previouslyFocusedElements.delete(element);\n if (focusPreviousElement) {\n previouslyFocusedElement.focus();\n }\n }\n}\nfunction closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {\n let popover = topmostAutoOrHintPopover(document2);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topmostAutoOrHintPopover(document2);\n }\n}\nfunction closeAllOpenPopoversInList(list, focusPreviousElement = false, fireEvents = false) {\n let popover = topMostPopoverInList(list);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topMostPopoverInList(list);\n }\n}\nfunction hidePopoverStackUntil(endpoint, set, focusPreviousElement, fireEvents) {\n let repeatingHide = false;\n let hasRunOnce = false;\n while (repeatingHide || !hasRunOnce) {\n hasRunOnce = true;\n let lastToHide = null;\n let foundEndpoint = false;\n for (const popover of set) {\n if (popover === endpoint) {\n foundEndpoint = true;\n } else if (foundEndpoint) {\n lastToHide = popover;\n break;\n }\n }\n if (!lastToHide) return;\n while (getPopoverVisibilityState(lastToHide) === \"showing\" && set.size) {\n hidePopover(lastSetElement(set), focusPreviousElement, fireEvents);\n }\n if (set.has(endpoint) && lastSetElement(set) !== endpoint) {\n repeatingHide = true;\n }\n if (repeatingHide) {\n fireEvents = false;\n }\n }\n}\nfunction hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {\n var _a, _b;\n const document2 = endpoint.ownerDocument || endpoint;\n if (endpoint instanceof Document) {\n return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);\n }\n if ((_a = hintPopoverList.get(document2)) == null ? void 0 : _a.has(endpoint)) {\n hidePopoverStackUntil(\n endpoint,\n hintPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n return;\n }\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n focusPreviousElement,\n fireEvents\n );\n if (!((_b = autoPopoverList.get(document2)) == null ? void 0 : _b.has(endpoint))) {\n return;\n }\n hidePopoverStackUntil(\n endpoint,\n autoPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n}\nvar popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();\nfunction lightDismissOpenPopovers(event) {\n if (!event.isTrusted) return;\n const target = event.composedPath()[0];\n if (!target) return;\n const document2 = target.ownerDocument;\n const topMostPopover = topmostAutoOrHintPopover(document2);\n if (!topMostPopover) return;\n const ancestor = topMostClickedPopover(target);\n if (ancestor && event.type === \"pointerdown\") {\n popoverPointerDownTargets.set(document2, ancestor);\n } else if (event.type === \"pointerup\") {\n const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;\n popoverPointerDownTargets.delete(document2);\n if (sameTarget) {\n hideAllPopoversUntil(ancestor || document2, false, true);\n }\n }\n}\nvar initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();\nfunction setInvokerAriaExpanded(el, force = false) {\n if (!el) return;\n if (!initialAriaExpandedValue.has(el)) {\n initialAriaExpandedValue.set(el, el.getAttribute(\"aria-expanded\"));\n }\n const popover = el.popoverTargetElement;\n if (popover instanceof HTMLElement && popover.popover === \"auto\") {\n el.setAttribute(\"aria-expanded\", String(force));\n } else {\n const initialValue = initialAriaExpandedValue.get(el);\n if (!initialValue) {\n el.removeAttribute(\"aria-expanded\");\n } else {\n el.setAttribute(\"aria-expanded\", initialValue);\n }\n }\n}\n\n// src/popover.ts\nvar ShadowRoot2 = globalThis.ShadowRoot || function() {\n};\nvar DEFAULT_LAYER_NAME = \"popover-polyfill\";\nfunction isSupported() {\n return typeof HTMLElement !== \"undefined\" && typeof HTMLElement.prototype === \"object\" && \"popover\" in HTMLElement.prototype;\n}\nfunction isHintSupported() {\n const el = document.createElement(\"div\");\n el.setAttribute(\"popover\", \"hint\");\n return el.popover === \"hint\";\n}\nfunction isPolyfilled() {\n var _a;\n return Boolean(\n ((_a = document.body) == null ? void 0 : _a.showPopover) && !/native code/i.test(document.body.showPopover.toString())\n );\n}\nfunction patchSelectorFn(object, name, mapper) {\n const original = object[name];\n Object.defineProperty(object, name, {\n value(selector) {\n return original.call(this, mapper(selector));\n }\n });\n}\nvar nonEscapedPopoverSelector = /(^|[^\\\\]):popover-open\\b/g;\nfunction hasLayerSupport() {\n return typeof globalThis.CSSLayerBlockRule === \"function\";\n}\nfunction getStyles(layerName) {\n var _a;\n const useLayer = hasLayerSupport();\n const layerNameEscaped = (layerName ?? ((_a = window.POPOVER_POLYFILL_OPTIONS) == null ? void 0 : _a.layerName) ?? DEFAULT_LAYER_NAME).split(\".\").map(CSS.escape).join(\".\");\n return `\n${useLayer ? `@layer ${layerNameEscaped} {` : \"\"}\n :where([popover]) {\n position: fixed;\n z-index: 2147483647;\n inset: 0;\n padding: 0.25em;\n width: fit-content;\n height: fit-content;\n border-width: initial;\n border-color: initial;\n border-image: initial;\n border-style: solid;\n background-color: canvas;\n color: canvastext;\n overflow: auto;\n margin: auto;\n }\n\n :where([popover]:not(.\\\\:popover-open)) {\n display: none;\n }\n\n :where(dialog[popover].\\\\:popover-open) {\n display: block;\n }\n\n :where(dialog[popover][open]) {\n display: revert;\n }\n\n :where([anchor].\\\\:popover-open) {\n inset: auto;\n }\n\n :where([anchor]:popover-open) {\n inset: auto;\n }\n\n @supports not (background-color: canvas) {\n :where([popover]) {\n background-color: white;\n color: black;\n }\n }\n\n @supports (width: -moz-fit-content) {\n :where([popover]) {\n width: -moz-fit-content;\n height: -moz-fit-content;\n }\n }\n\n @supports not (inset: 0) {\n :where([popover]) {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n }\n${useLayer ? \"}\" : \"\"}\n`;\n}\nvar popoverStyleSheet = null;\nfunction injectStyles(root, layerName) {\n const styles = getStyles(layerName);\n if (popoverStyleSheet === null) {\n try {\n popoverStyleSheet = new CSSStyleSheet();\n popoverStyleSheet.replaceSync(styles);\n } catch {\n popoverStyleSheet = false;\n }\n }\n if (popoverStyleSheet === false) {\n const sheet = document.createElement(\"style\");\n sheet.textContent = styles;\n if (root instanceof Document) {\n root.head.prepend(sheet);\n } else {\n root.prepend(sheet);\n }\n } else {\n root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];\n }\n}\nfunction apply(opts) {\n if (typeof window === \"undefined\") return;\n const layerName = opts == null ? void 0 : opts.layerName;\n window.ToggleEvent = window.ToggleEvent || ToggleEvent;\n function rewriteSelector(selector) {\n if (selector == null ? void 0 : selector.includes(\":popover-open\")) {\n selector = selector.replace(\n nonEscapedPopoverSelector,\n \"$1.\\\\:popover-open\"\n );\n }\n return selector;\n }\n patchSelectorFn(Document.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Document.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"matches\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"closest\", rewriteSelector);\n patchSelectorFn(\n DocumentFragment.prototype,\n \"querySelectorAll\",\n rewriteSelector\n );\n Object.defineProperties(HTMLElement.prototype, {\n popover: {\n enumerable: true,\n configurable: true,\n get() {\n if (!this.hasAttribute(\"popover\")) return null;\n const value = (this.getAttribute(\"popover\") || \"\").toLowerCase();\n if (value === \"\" || value == \"auto\") return \"auto\";\n if (value == \"hint\") return \"hint\";\n return \"manual\";\n },\n set(value) {\n if (value === null) {\n this.removeAttribute(\"popover\");\n } else {\n this.setAttribute(\"popover\", value);\n }\n }\n },\n showPopover: {\n enumerable: true,\n configurable: true,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n value(options = {}) {\n showPopover(this);\n }\n },\n hidePopover: {\n enumerable: true,\n configurable: true,\n value() {\n hidePopover(this, true, true);\n }\n },\n togglePopover: {\n enumerable: true,\n configurable: true,\n value(options = {}) {\n if (typeof options === \"boolean\") {\n options = { force: options };\n }\n if (visibilityState.get(this) === \"showing\" && options.force === void 0 || options.force === false) {\n hidePopover(this, true, true);\n } else if (options.force === void 0 || options.force === true) {\n showPopover(this);\n }\n return visibilityState.get(this) === \"showing\";\n }\n }\n });\n const originalAttachShadow = Element.prototype.attachShadow;\n if (originalAttachShadow) {\n Object.defineProperties(Element.prototype, {\n attachShadow: {\n enumerable: true,\n configurable: true,\n writable: true,\n value(options) {\n const shadowRoot = originalAttachShadow.call(this, options);\n injectStyles(shadowRoot, layerName);\n return shadowRoot;\n }\n }\n });\n }\n const originalAttachInternals = HTMLElement.prototype.attachInternals;\n if (originalAttachInternals) {\n Object.defineProperties(HTMLElement.prototype, {\n attachInternals: {\n enumerable: true,\n configurable: true,\n writable: true,\n value() {\n const internals = originalAttachInternals.call(this);\n if (internals.shadowRoot) {\n injectStyles(internals.shadowRoot, layerName);\n }\n return internals;\n }\n }\n });\n }\n const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();\n function applyPopoverInvokerElementMixin(ElementClass) {\n Object.defineProperties(ElementClass.prototype, {\n popoverTargetElement: {\n enumerable: true,\n configurable: true,\n set(targetElement) {\n if (targetElement === null) {\n this.removeAttribute(\"popovertarget\");\n popoverTargetAssociatedElements.delete(this);\n } else if (!(targetElement instanceof Element)) {\n throw new TypeError(\n `popoverTargetElement must be an element or null`\n );\n } else {\n this.setAttribute(\"popovertarget\", \"\");\n popoverTargetAssociatedElements.set(this, targetElement);\n }\n },\n get() {\n if (this.localName !== \"button\" && this.localName !== \"input\") {\n return null;\n }\n if (this.localName === \"input\" && this.type !== \"reset\" && this.type !== \"image\" && this.type !== \"button\") {\n return null;\n }\n if (this.disabled) {\n return null;\n }\n if (this.form && this.type === \"submit\") {\n return null;\n }\n const targetElement = popoverTargetAssociatedElements.get(this);\n if (targetElement && targetElement.isConnected) {\n return targetElement;\n } else if (targetElement && !targetElement.isConnected) {\n popoverTargetAssociatedElements.delete(this);\n return null;\n }\n const root = getRootNode(this);\n const idref = this.getAttribute(\"popovertarget\");\n if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {\n return root.getElementById(idref) || null;\n }\n return null;\n }\n },\n popoverTargetAction: {\n enumerable: true,\n configurable: true,\n get() {\n const value = (this.getAttribute(\"popovertargetaction\") || \"\").toLowerCase();\n if (value === \"show\" || value === \"hide\") return value;\n return \"toggle\";\n },\n set(value) {\n this.setAttribute(\"popovertargetaction\", value);\n }\n }\n });\n }\n applyPopoverInvokerElementMixin(HTMLButtonElement);\n applyPopoverInvokerElementMixin(HTMLInputElement);\n const handleInvokerActivation = (event) => {\n if (event.defaultPrevented) {\n return;\n }\n const composedPath = event.composedPath();\n const target = composedPath[0];\n if (!(target instanceof Element) || (target == null ? void 0 : target.shadowRoot)) {\n return;\n }\n const root = getRootNode(target);\n if (!(root instanceof ShadowRoot2 || root instanceof Document)) {\n return;\n }\n const invoker = composedPath.find(\n (el) => {\n var _a;\n return (_a = el.matches) == null ? void 0 : _a.call(el, \"[popovertargetaction],[popovertarget]\");\n }\n );\n if (invoker) {\n popoverTargetAttributeActivationBehavior(invoker);\n event.preventDefault();\n return;\n }\n };\n const onKeydown = (event) => {\n const key = event.key;\n const target = event.target;\n if (!event.defaultPrevented && target && (key === \"Escape\" || key === \"Esc\")) {\n hideAllPopoversUntil(target.ownerDocument, true, true);\n }\n };\n const addEventListeners = (root) => {\n root.addEventListener(\"click\", handleInvokerActivation);\n root.addEventListener(\"keydown\", onKeydown);\n root.addEventListener(\"pointerdown\", lightDismissOpenPopovers);\n root.addEventListener(\"pointerup\", lightDismissOpenPopovers);\n };\n addEventListeners(document);\n injectStyles(document, layerName);\n}\nexport {\n apply,\n injectStyles,\n isHintSupported,\n isPolyfilled,\n isSupported\n};\n//# sourceMappingURL=popover-fn.js.map\n"],"x_google_ignoreList":[0],"mappings":"AACA,IAAI,EAAc,cAAc,KAAM,CACpC,SACA,SACA,YAAY,EAAM,EAAO,CAAC,EAAG,CAC3B,IAAM,EAAY,OAAO,OAAO,CAAC,EAAG,CAAI,EACxC,OAAO,EAAU,SACjB,OAAO,EAAU,SACjB,MAAM,EAAM,CAAS,EACrB,KAAK,SAAW,OAAO,EAAK,UAAY,EAAE,EAC1C,KAAK,SAAW,OAAO,EAAK,UAAY,EAAE,CAC5C,CACF,EACI,EAAyC,IAAI,QACjD,SAAS,EAA4B,EAAS,EAAU,EAAU,CAChE,EAAuB,IACrB,EACA,eAAiB,CACV,EAAuB,IAAI,CAAO,GACvC,EAAQ,cACN,IAAI,EAAY,SAAU,CACxB,WAAY,GACZ,WACA,UACF,CAAC,CACH,CACF,EAAG,CAAC,CACN,CACF,CAGA,IAAI,EAAa,WAAW,YAAc,UAAW,CACrD,EACI,EAAoB,WAAW,mBAAqB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.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));exports.__toESM=s;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../utils/utils.cjs")
|
|
1
|
+
const e=require("../utils/utils.cjs");var t=class extends e.DSElement{_items;_label={key:e.ARIA_LABEL,value:null};_unresize;_unmutate;static get observedAttributes(){return[e.ARIA_LABEL,e.ARIA_LABELLEDBY]}connectedCallback(){let t=e.debounce(()=>n(this),100);this._items=this.getElementsByTagName(`a`),this._unresize=e.on(window,`resize`,t),this._unmutate=e.onMutation(this,n,{childList:!0,subtree:!0})}attributeChangedCallback(){this._unmutate&&n(this)}disconnectedCallback(){this._unresize?.(),this._unmutate?.(),this._unresize=this._unmutate=this._items=void 0}};const n=t=>{let n=t._items?.[t._items.length-1],r=n?.parentElement===t?null:n,i=!r?.offsetHeight;e.attr(t,`role`,i?null:`navigation`);for(let n of t._items||[])e.attr(n,`aria-current`,n===r?`page`:null);let a=e.attrOrCSS(t,e.ARIA_LABEL)?.trim(),o=e.attr(t,e.ARIA_LABELLEDBY)?.trim(),s=a||o;s&&(t._label.value=s),s&&(t._label.key=o?e.ARIA_LABELLEDBY:e.ARIA_LABEL);let c=i?null:t._label.value;s!==c&&(e.attr(t,e.ARIA_LABELLEDBY,null),e.attr(t,e.ARIA_LABEL,null),e.attr(t,t._label.key,c))};e.customElements.define(`ds-breadcrumbs`,t),exports.DSBreadcrumbsElement=t;
|
|
2
2
|
//# sourceMappingURL=breadcrumbs.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.cjs","names":["DSElement","
|
|
1
|
+
{"version":3,"file":"breadcrumbs.cjs","names":["DSElement","ARIA_LABEL","ARIA_LABELLEDBY","debounce","on","onMutation","attrOrCSS","attr","customElements"],"sources":["../../../src/breadcrumbs/breadcrumbs.ts"],"sourcesContent":["import {\n ARIA_LABEL,\n ARIA_LABELLEDBY,\n attr,\n attrOrCSS,\n customElements,\n DSElement,\n debounce,\n on,\n onMutation,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-breadcrumbs': DSBreadcrumbsElement;\n }\n}\n\nexport class DSBreadcrumbsElement extends DSElement {\n _items?: HTMLCollectionOf<HTMLAnchorElement>; // Using underscore instead of private fields for backwards compatibility\n _label = { key: ARIA_LABEL, value: null as string | null };\n _unresize?: () => void;\n _unmutate?: () => void;\n\n static get observedAttributes() {\n return [ARIA_LABEL, ARIA_LABELLEDBY]; // Using ES2015 syntax for backwards compatibility\n }\n connectedCallback() {\n const resize = debounce(() => render(this), 100);\n this._items = this.getElementsByTagName('a'); // Speed up by caching HTMLCollection\n this._unresize = on(window, 'resize', resize);\n this._unmutate = onMutation(this, render, {\n childList: true,\n subtree: true,\n });\n }\n attributeChangedCallback() {\n if (this._unmutate) render(this); // Ensure we do not run unless connected, and keep cached label if aria-label/aria-labelledby is removed\n }\n disconnectedCallback() {\n this._unresize?.();\n this._unmutate?.();\n this._unresize = this._unmutate = this._items = undefined;\n }\n}\n\nconst render = (self: DSBreadcrumbsElement) => {\n const lastItem = self._items?.[self._items.length - 1];\n const lastItemInList = lastItem?.parentElement === self ? null : lastItem;\n const isListHidden = !lastItemInList?.offsetHeight;\n\n attr(self, 'role', isListHidden ? null : 'navigation'); // Remove role if no visible breadcrumb list items\n for (const item of self._items || [])\n attr(item, 'aria-current', item === lastItemInList ? 'page' : null);\n\n // Get current label attributes\n const label = attrOrCSS(self, ARIA_LABEL)?.trim();\n const labelledby = attr(self, ARIA_LABELLEDBY)?.trim();\n const prevLabel = label || labelledby; // Prefer aria-label over aria-labelledby as this is also most browsers default if both are defined\n\n // Update, but keep cached label if aria-label/aria-labelledby is removed\n if (prevLabel) self._label.value = prevLabel;\n if (prevLabel) self._label.key = labelledby ? ARIA_LABELLEDBY : ARIA_LABEL;\n const nextLabel = isListHidden ? null : self._label.value;\n\n // Update label attributes, but only if needed to prevent infinite attributeChangedCallback loop\n if (prevLabel !== nextLabel) {\n attr(self, ARIA_LABELLEDBY, null); // Reset aria-attributes before setting new\n attr(self, ARIA_LABEL, null);\n attr(self, self._label.key, nextLabel); // Setup new attribute\n }\n};\n\ncustomElements.define('ds-breadcrumbs', DSBreadcrumbsElement);\n"],"mappings":"sCAkBA,IAAa,EAAb,cAA0CA,EAAAA,SAAU,CAClD,OACA,OAAS,CAAE,IAAKC,EAAAA,WAAY,MAAO,IAAsB,EACzD,UACA,UAEA,WAAW,oBAAqB,CAC9B,MAAO,CAACA,EAAAA,WAAYC,EAAAA,eAAe,CACrC,CACA,mBAAoB,CAClB,IAAM,EAASC,EAAAA,aAAe,EAAO,IAAI,EAAG,GAAG,EAC/C,KAAK,OAAS,KAAK,qBAAqB,GAAG,EAC3C,KAAK,UAAYC,EAAAA,GAAG,OAAQ,SAAU,CAAM,EAC5C,KAAK,UAAYC,EAAAA,WAAW,KAAM,EAAQ,CACxC,UAAW,GACX,QAAS,EACX,CAAC,CACH,CACA,0BAA2B,CACrB,KAAK,WAAW,EAAO,IAAI,CACjC,CACA,sBAAuB,CACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAY,KAAK,UAAY,KAAK,OAAS,IAAA,EAClD,CACF,EAEA,MAAM,EAAU,GAA+B,CAC7C,IAAM,EAAW,EAAK,SAAS,EAAK,OAAO,OAAS,GAC9C,EAAiB,GAAU,gBAAkB,EAAO,KAAO,EAC3D,EAAe,CAAC,GAAgB,aAEtC,EAAA,KAAK,EAAM,OAAQ,EAAe,KAAO,YAAY,EACrD,IAAK,IAAM,KAAQ,EAAK,QAAU,CAAC,EACjC,EAAA,KAAK,EAAM,eAAgB,IAAS,EAAiB,OAAS,IAAI,EAGpE,IAAM,EAAQC,EAAAA,UAAU,EAAML,EAAAA,UAAU,CAAC,EAAE,KAAK,EAC1C,EAAaM,EAAAA,KAAK,EAAML,EAAAA,eAAe,CAAC,EAAE,KAAK,EAC/C,EAAY,GAAS,EAGvB,IAAW,EAAK,OAAO,MAAQ,GAC/B,IAAW,EAAK,OAAO,IAAM,EAAaA,EAAAA,gBAAkBD,EAAAA,YAChE,IAAM,EAAY,EAAe,KAAO,EAAK,OAAO,MAGhD,IAAc,IAChB,EAAA,KAAK,EAAMC,EAAAA,gBAAiB,IAAI,EAChC,EAAA,KAAK,EAAMD,EAAAA,WAAY,IAAI,EAC3B,EAAA,KAAK,EAAM,EAAK,OAAO,IAAK,CAAS,EAEzC,EAEAO,EAAAA,eAAe,OAAO,iBAAkB,CAAoB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../utils/utils.cjs"),t=`:click-delegate-hover`,n
|
|
1
|
+
const e=require("../utils/utils.cjs"),t=`:click-delegate-hover`,n=new Set([`A`,`BUTTON`,`DETAILS`,`DIALOG`,`INPUT`,`LABEL`,`SELECT`,`TEXTAREA`]),r=t=>{let n=t.button===1||t.metaKey||t.ctrlKey,r=e.getComposedTarget(t),i=t.button<2&&s(t);if(!(!i||i.contains(r))){if(n&&i instanceof HTMLAnchorElement)return window.open(i.href,void 0,i.rel);t.stopImmediatePropagation(),i.nodeName!==`LABEL`&&i.click()}};let i,a;const o=n=>{let r=e.getComposedTarget(n);if(!r||r===a)return;a=r;let o=s(n);i!==o&&(i&&i.classList.remove(t),o&&o.classList.add(t),i=o)},s=t=>{let n;for(let r of t.composedPath()){if(r.nodeType!==1)continue;r.nodeName===`LABEL`&&(r=r.control||r);let t=r.getAttribute(`data-clickdelegatefor`);if(t){let i=e.getRoot(r).getElementById(t);return i&&!(n&&n!==i)&&!i.disabled&&!i.readOnly?i:void 0}!n&&c(r)&&(n=r)}},c=t=>t.isContentEditable||t.popover||n.has(t.nodeName)||e.attr(t,`role`)===`button`;e.onHotReload(`clickdelegatefor`,()=>[e.on(window,`click auxclick`,r,!0),e.on(document,`mousemove`,o,e.QUICK_EVENT)]);
|
|
2
2
|
//# sourceMappingURL=clickdelegatefor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickdelegatefor.cjs","names":["onHotReload","on","QUICK_EVENT"],"sources":["../../../src/clickdelegatefor/clickdelegatefor.ts"],"sourcesContent":["// Adding support for click deletagtion, following\n// https://open-ui.org/components/link-area-delegation-explainer/\n// and https://github.com/openui/open-ui/issues/1104#issuecomment-3151387080\nimport {
|
|
1
|
+
{"version":3,"file":"clickdelegatefor.cjs","names":["getComposedTarget","getRoot","attr","onHotReload","on","QUICK_EVENT"],"sources":["../../../src/clickdelegatefor/clickdelegatefor.ts"],"sourcesContent":["// Adding support for click deletagtion, following\n// https://open-ui.org/components/link-area-delegation-explainer/\n// and https://github.com/openui/open-ui/issues/1104#issuecomment-3151387080\nimport {\n attr,\n getComposedTarget,\n getRoot,\n on,\n onHotReload,\n QUICK_EVENT,\n} from '../utils/utils';\n\nconst ATTR_CLICKDELEGATEFOR = 'data-clickdelegatefor';\nconst CLASS_HOVER = ':click-delegate-hover';\nconst SKIP = new Set([\n 'A',\n 'BUTTON',\n 'DETAILS',\n 'DIALOG',\n 'INPUT',\n 'LABEL',\n 'SELECT',\n 'TEXTAREA',\n]); // Ignore interactive elements, and elements that create a new \"context\" or \"scope\"\n\nconst handleClickDelegateFor = (event: MouseEvent) => {\n const isNewTab = event.button === 1 || event.metaKey || event.ctrlKey; // Middle click or cmd/ctrl + click should open in new tab\n const target = getComposedTarget(event);\n const delegateTarget = event.button < 2 && getDelegateTarget(event); // Only accept left or middle clicks\n\n if (!delegateTarget || delegateTarget.contains(target)) return; // Only proxy event if delegated target isn't part of the original target\n if (isNewTab && delegateTarget instanceof HTMLAnchorElement)\n return window.open(delegateTarget.href, undefined, delegateTarget.rel); // If middle click or cmd/ctrl click on link, open in new tab\n event.stopImmediatePropagation(); // We'll trigger a new click event anyway, so prevent actions on this one\n if (delegateTarget.nodeName !== 'LABEL') delegateTarget.click(); // Forward click to the clickable element (labels forwards click natively though)\n};\n\nlet HOVER: Element | undefined;\nlet TARGET: EventTarget; // Used to speed up mouseover handling\nconst handleMouseMove = (event: Event) => {\n const target = getComposedTarget(event);\n if (!target || target === TARGET) return; // Same target, no need to check delegate target again\n TARGET = target;\n const delegateTarget = getDelegateTarget(event);\n if (HOVER === delegateTarget) return; // No change\n if (HOVER) HOVER.classList.remove(CLASS_HOVER);\n if (delegateTarget) delegateTarget.classList.add(CLASS_HOVER);\n HOVER = delegateTarget;\n};\n\nconst getDelegateTarget = (event: Event) => {\n let interactive: Element | undefined;\n for (let el of event.composedPath() as HTMLElement[]) {\n if (el.nodeType !== 1) continue; // Only check elements\n if (el.nodeName === 'LABEL') el = (el as HTMLLabelElement).control || el; // If label, return the associated control\n const id = el.getAttribute(ATTR_CLICKDELEGATEFOR);\n if (id) {\n const to = getRoot(el).getElementById(id) as HTMLInputElement;\n const hasInteractive = interactive && interactive !== to;\n const isClickable = to && !hasInteractive && !to.disabled && !to.readOnly;\n return isClickable ? to : undefined; // Only return if target is not disabled or readonly\n }\n if (!interactive && isInteractive(el)) interactive = el;\n }\n};\n\nconst isInteractive = (el: HTMLElement) =>\n el.isContentEditable ||\n el.popover ||\n SKIP.has(el.nodeName) ||\n attr(el, 'role') === 'button';\n\nonHotReload('clickdelegatefor', () => [\n on(window, 'click auxclick', handleClickDelegateFor as EventListener, true), // Use capture to ensure we run before other click listeners\n on(document, 'mousemove', handleMouseMove, QUICK_EVENT), // Use passive for better performance\n]);\n"],"mappings":"sCAaM,EAAc,wBACd,EAAO,IAAI,IAAI,CACnB,IACA,SACA,UACA,SACA,QACA,QACA,SACA,UACF,CAAC,EAEK,EAA0B,GAAsB,CACpD,IAAM,EAAW,EAAM,SAAW,GAAK,EAAM,SAAW,EAAM,QACxD,EAASA,EAAAA,kBAAkB,CAAK,EAChC,EAAiB,EAAM,OAAS,GAAK,EAAkB,CAAK,EAE9D,MAAC,GAAkB,EAAe,SAAS,CAAM,GACrD,IAAI,GAAY,aAA0B,kBACxC,OAAO,OAAO,KAAK,EAAe,KAAM,IAAA,GAAW,EAAe,GAAG,EACvE,EAAM,yBAAyB,EAC3B,EAAe,WAAa,SAAS,EAAe,MAAM,CAFS,CAGzE,EAEA,IAAI,EACA,EACJ,MAAM,EAAmB,GAAiB,CACxC,IAAM,EAASA,EAAAA,kBAAkB,CAAK,EACtC,GAAI,CAAC,GAAU,IAAW,EAAQ,OAClC,EAAS,EACT,IAAM,EAAiB,EAAkB,CAAK,EAC1C,IAAU,IACV,GAAO,EAAM,UAAU,OAAO,CAAW,EACzC,GAAgB,EAAe,UAAU,IAAI,CAAW,EAC5D,EAAQ,EACV,EAEM,EAAqB,GAAiB,CAC1C,IAAI,EACJ,IAAK,IAAI,KAAM,EAAM,aAAa,EAAoB,CACpD,GAAI,EAAG,WAAa,EAAG,SACnB,EAAG,WAAa,UAAS,EAAM,EAAwB,SAAW,GACtE,IAAM,EAAK,EAAG,aAAa,uBAAqB,EAChD,GAAI,EAAI,CACN,IAAM,EAAKC,EAAAA,QAAQ,CAAE,CAAC,CAAC,eAAe,CAAE,EAGxC,OADoB,GAAM,EADH,GAAe,IAAgB,IACT,CAAC,EAAG,UAAY,CAAC,EAAG,SAC5C,EAAK,IAAA,EAC5B,CACI,CAAC,GAAe,EAAc,CAAE,IAAG,EAAc,EACvD,CACF,EAEM,EAAiB,GACrB,EAAG,mBACH,EAAG,SACH,EAAK,IAAI,EAAG,QAAQ,GACpBC,EAAAA,KAAK,EAAI,MAAM,IAAM,SAEvBC,EAAAA,YAAY,uBAA0B,CACpCC,EAAAA,GAAG,OAAQ,iBAAkB,EAAyC,EAAI,EAC1EA,EAAAA,GAAG,SAAU,YAAa,EAAiBC,EAAAA,WAAW,CACxD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../utils/utils.cjs");let t=!1;const n=
|
|
1
|
+
const e=require("../utils/utils.cjs");let t=!1;const n=n=>{let{type:i,clientX:a=0,clientY:o=0}=n,s=e.getComposedTarget(n);if(s&&i===`pointerdown`)for(let n of e.getComposedPath(s)){if(n.nodeName!==`DIALOG`)continue;let e=n.getBoundingClientRect();t=e.top<=o&&o<=e.bottom&&e.left<=a&&a<=e.right;return}else{let n=s?.nodeName===`DIALOG`&&!t&&e.attr(s,`closedby`)===`any`;t=!1,n&&setTimeout(r,0,s)}},r=e=>e.open&&e.close(),i=`--show-non-modal`,a=t=>{for(let n of t.composedPath()){let t=n.nodeType===1&&e.attr(n,`command`);if(t===`show-modal`||t===i)return e.attr(n,`aria-haspopup`,`dialog`)}},o=({command:e,target:t})=>e===i&&t instanceof HTMLDialogElement&&t.show();e.onHotReload(`dialog`,()=>[e.on(document,`command`,o,e.QUICK_EVENT),e.on(document,`focus`,a,e.QUICK_EVENT),e.on(document,`pointerdown pointerup`,n,e.QUICK_EVENT)]);
|
|
2
2
|
//# sourceMappingURL=dialog.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.cjs","names":["
|
|
1
|
+
{"version":3,"file":"dialog.cjs","names":["getComposedTarget","getComposedPath","attr","onHotReload","on","QUICK_EVENT"],"sources":["../../../src/dialog/dialog.ts"],"sourcesContent":["import {\n attr,\n getComposedPath,\n getComposedTarget,\n on,\n onHotReload,\n QUICK_EVENT,\n} from '../utils/utils';\n\n// Polyfill closedby functionaliy in Safari\n// Also in Safari 26.2 where `closedBy` property is supported natively,\n// but no corresponding functionality/behavior is implemented.\nlet DOWN_INSIDE = false; // Prevent close if selecting text inside dialog\nconst handleClosedbyAny = (event: Event) => {\n const { type, clientX: x = 0, clientY: y = 0 } = event as MouseEvent;\n const el = getComposedTarget(event);\n if (el && type === 'pointerdown') {\n for (const dialog of getComposedPath(el)) {\n if (dialog.nodeName !== 'DIALOG') continue;\n const r = (dialog as Element).getBoundingClientRect();\n DOWN_INSIDE = r.top <= y && y <= r.bottom && r.left <= x && x <= r.right;\n return; // Stop traversing once we find a dialog\n }\n } else {\n const isDialog = el?.nodeName === 'DIALOG'; // Faster than el instanceof HTMLDialogElement\n const isClose = isDialog && !DOWN_INSIDE && attr(el, 'closedby') === 'any';\n\n DOWN_INSIDE = false; // Reset on every pointerup\n if (isClose) setTimeout(close, 0, el); // Close if browser did not do it\n }\n};\n\nconst close = (dialog: HTMLDialogElement) => dialog.open && dialog.close();\n\n// Ensure buttons that trigger a modeal dialog has aria-haspopup=\"dialog\" for better screen reader experience\nconst MODAL = 'show-modal';\nconst NON_MODAL = '--show-non-modal';\nconst handleAriaAttributes = (event: Event) => {\n for (const el of event.composedPath() as Element[]) {\n const command = el.nodeType === 1 && attr(el, 'command');\n if (command === MODAL || command === NON_MODAL)\n return attr(el, 'aria-haspopup', 'dialog');\n }\n};\n\nconst handleCommand = ({ command, target }: Event & { command?: string }) =>\n command === NON_MODAL && target instanceof HTMLDialogElement && target.show();\n\nonHotReload('dialog', () => [\n on(document, 'command', handleCommand, QUICK_EVENT),\n on(document, 'focus', handleAriaAttributes, QUICK_EVENT),\n on(document, 'pointerdown pointerup', handleClosedbyAny, QUICK_EVENT),\n]);\n"],"mappings":"sCAYA,IAAI,EAAc,GAClB,MAAM,EAAqB,GAAiB,CAC1C,GAAM,CAAE,OAAM,QAAS,EAAI,EAAG,QAAS,EAAI,GAAM,EAC3C,EAAKA,EAAAA,kBAAkB,CAAK,EAClC,GAAI,GAAM,IAAS,cACjB,IAAK,IAAM,KAAUC,EAAAA,gBAAgB,CAAE,EAAG,CACxC,GAAI,EAAO,WAAa,SAAU,SAClC,IAAM,EAAK,EAAmB,sBAAsB,EACpD,EAAc,EAAE,KAAO,GAAK,GAAK,EAAE,QAAU,EAAE,MAAQ,GAAK,GAAK,EAAE,MACnE,MACF,KACK,CAEL,IAAM,EADW,GAAI,WAAa,UACN,CAAC,GAAeC,EAAAA,KAAK,EAAI,UAAU,IAAM,MAErE,EAAc,GACV,GAAS,WAAW,EAAO,EAAG,CAAE,CACtC,CACF,EAEM,EAAS,GAA8B,EAAO,MAAQ,EAAO,MAAM,EAInE,EAAY,mBACZ,EAAwB,GAAiB,CAC7C,IAAK,IAAM,KAAM,EAAM,aAAa,EAAgB,CAClD,IAAM,EAAU,EAAG,WAAa,GAAKA,EAAAA,KAAK,EAAI,SAAS,EACvD,GAAI,IAAY,cAAS,IAAY,EACnC,OAAOA,EAAAA,KAAK,EAAI,gBAAiB,QAAQ,CAC7C,CACF,EAEM,GAAiB,CAAE,UAAS,YAChC,IAAY,GAAa,aAAkB,mBAAqB,EAAO,KAAK,EAE9EC,EAAAA,YAAY,aAAgB,CAC1BC,EAAAA,GAAG,SAAU,UAAW,EAAeC,EAAAA,WAAW,EAClDD,EAAAA,GAAG,SAAU,QAAS,EAAsBC,EAAAA,WAAW,EACvDD,EAAAA,GAAG,SAAU,wBAAyB,EAAmBC,EAAAA,WAAW,CACtE,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
const e=require("../utils/utils.cjs");var t=class extends e.DSElement{_unmutate;connectedCallback(){e.on(this,`animationend`,this,e.QUICK_EVENT),e.attr(this,`role`,`group`),e.attr(this,`tabindex`,`-1`),this._unmutate=e.onMutation(this,n,{childList:!0,subtree:!0}),this.focus()}handleEvent({target:e}){e===this&&this.focus()}disconnectedCallback(){e.off(this,`animationend`,this,e.QUICK_EVENT),this._unmutate?.(),this._unmutate=void 0}};const n=t=>{let n=e.attr(t
|
|
2
|
-
Add a heading (h2–h6), or set aria-label or aria-labelledby to provide an accessible name for screen readers.`)};e.customElements.define(`ds-error-summary`,t),exports.DSErrorSummaryElement=t;
|
|
1
|
+
const e=require("../utils/utils.cjs");var t=class extends e.DSElement{_unmutate;connectedCallback(){e.on(this,`animationend`,this,e.QUICK_EVENT),e.attr(this,`role`,`group`),e.attr(this,`tabindex`,`-1`),this._unmutate=e.onMutation(this,n,{childList:!0,subtree:!0}),this.focus()}handleEvent({target:e}){e===this&&this.focus()}disconnectedCallback(){e.off(this,`animationend`,this,e.QUICK_EVENT),this._unmutate?.(),this._unmutate=void 0}};const n=t=>{let n=e.attr(t,e.ARIA_LABEL)?.trim(),r=e.attr(t,e.ARIA_LABELLEDBY)?.trim(),i=t.querySelector(`h2,h3,h4,h5,h6`);i&&!n&&!r&&e.attr(t,e.ARIA_LABELLEDBY,e.useId(i)),!i&&!n&&!r&&e.warn(`Missing accessible name on:`,t,`\nAdd a heading (h2–h6), or set ${e.ARIA_LABEL} or ${e.ARIA_LABELLEDBY} to provide an accessible name for screen readers.`)};e.customElements.define(`ds-error-summary`,t),exports.DSErrorSummaryElement=t;
|
|
3
2
|
//# sourceMappingURL=error-summary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-summary.cjs","names":["DSElement","QUICK_EVENT","onMutation","attr","useId","customElements"],"sources":["../../../src/error-summary/error-summary.ts"],"sourcesContent":["import {\n attr,\n customElements,\n DSElement,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-error-summary': DSErrorSummaryElement;\n }\n}\n\nexport class DSErrorSummaryElement extends DSElement {\n _unmutate?: () => void; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n on(this, 'animationend', this, QUICK_EVENT); // Using animationend to detect when element is visible\n attr(this, 'role', 'group');\n attr(this, 'tabindex', '-1');\n this._unmutate = onMutation(this, render, {\n childList: true,\n subtree: true,\n });\n this.focus();\n }\n handleEvent({ target }: Event) {\n if (target === this) this.focus(); // Ignore if animation event was triggered by child\n }\n disconnectedCallback() {\n off(this, 'animationend', this, QUICK_EVENT);\n this._unmutate?.();\n this._unmutate = undefined;\n }\n}\n\nconst render = (self: DSErrorSummaryElement) => {\n const label = attr(self,
|
|
1
|
+
{"version":3,"file":"error-summary.cjs","names":["DSElement","QUICK_EVENT","onMutation","attr","ARIA_LABEL","ARIA_LABELLEDBY","useId","customElements"],"sources":["../../../src/error-summary/error-summary.ts"],"sourcesContent":["import {\n ARIA_LABEL,\n ARIA_LABELLEDBY,\n attr,\n customElements,\n DSElement,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-error-summary': DSErrorSummaryElement;\n }\n}\n\nexport class DSErrorSummaryElement extends DSElement {\n _unmutate?: () => void; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n on(this, 'animationend', this, QUICK_EVENT); // Using animationend to detect when element is visible\n attr(this, 'role', 'group');\n attr(this, 'tabindex', '-1');\n this._unmutate = onMutation(this, render, {\n childList: true,\n subtree: true,\n });\n this.focus();\n }\n handleEvent({ target }: Event) {\n if (target === this) this.focus(); // Ignore if animation event was triggered by child\n }\n disconnectedCallback() {\n off(this, 'animationend', this, QUICK_EVENT);\n this._unmutate?.();\n this._unmutate = undefined;\n }\n}\n\nconst render = (self: DSErrorSummaryElement) => {\n const label = attr(self, ARIA_LABEL)?.trim();\n const labelledBy = attr(self, ARIA_LABELLEDBY)?.trim();\n const heading = self.querySelector('h2,h3,h4,h5,h6');\n if (heading && !label && !labelledBy) {\n attr(self, ARIA_LABELLEDBY, useId(heading));\n }\n if (!heading && !label && !labelledBy) {\n warn(\n 'Missing accessible name on:',\n self,\n `\\nAdd a heading (h2–h6), or set ${ARIA_LABEL} or ${ARIA_LABELLEDBY} to provide an accessible name for screen readers.`,\n );\n }\n};\n\ncustomElements.define('ds-error-summary', DSErrorSummaryElement);\n"],"mappings":"sCAoBA,IAAa,EAAb,cAA2CA,EAAAA,SAAU,CACnD,UAEA,mBAAoB,CAClB,EAAA,GAAG,KAAM,eAAgB,KAAMC,EAAAA,WAAW,EAC1C,EAAA,KAAK,KAAM,OAAQ,OAAO,EAC1B,EAAA,KAAK,KAAM,WAAY,IAAI,EAC3B,KAAK,UAAYC,EAAAA,WAAW,KAAM,EAAQ,CACxC,UAAW,GACX,QAAS,EACX,CAAC,EACD,KAAK,MAAM,CACb,CACA,YAAY,CAAE,UAAiB,CACzB,IAAW,MAAM,KAAK,MAAM,CAClC,CACA,sBAAuB,CACrB,EAAA,IAAI,KAAM,eAAgB,KAAMD,EAAAA,WAAW,EAC3C,KAAK,YAAY,EACjB,KAAK,UAAY,IAAA,EACnB,CACF,EAEA,MAAM,EAAU,GAAgC,CAC9C,IAAM,EAAQE,EAAAA,KAAK,EAAMC,EAAAA,UAAU,CAAC,EAAE,KAAK,EACrC,EAAaD,EAAAA,KAAK,EAAME,EAAAA,eAAe,CAAC,EAAE,KAAK,EAC/C,EAAU,EAAK,cAAc,gBAAgB,EAC/C,GAAW,CAAC,GAAS,CAAC,GACxB,EAAA,KAAK,EAAMA,EAAAA,gBAAiBC,EAAAA,MAAM,CAAO,CAAC,EAExC,CAAC,GAAW,CAAC,GAAS,CAAC,GACzB,EAAA,KACE,8BACA,EACA,mCAAmCF,EAAAA,WAAW,MAAMC,EAAAA,gBAAgB,mDACtE,CAEJ,EAEAE,EAAAA,eAAe,OAAO,mBAAoB,CAAqB"}
|
package/dist/cjs/field/field.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../utils/utils.cjs"),t=`aria-invalid`,n=`aria-describedby`,r=`data-indeterminate`,i=e.isWindows()?800:200,a=
|
|
1
|
+
const e=require("../utils/utils.cjs"),t=`aria-invalid`,n=`aria-describedby`,r=`data-indeterminate`,i=e.isWindows()?800:200,a=i=>{let a=[],o=[],s=i._descs||[],u=!1,d=!1;i._input?.hidden&&(i._input=void 0);for(let t of i.getElementsByTagName(`*`))if(t instanceof HTMLLabelElement&&a.push(t),!t.hidden)if(l(t))i._input?.isConnected&&i._input!==t?e.warn(`Fields should only have one input element. Use <fieldset> to group multiple fields:`,i):i._input=t;else{let n=t.getAttribute(`data-field`);n===`counter`&&(i._counter=t),n===`validation`?(o.unshift(e.useId(t)),u=!0,d||=c(t)):n&&o.push(e.useId(t))}if(!i._input?.isConnected)return;let f=i._input;for(let t of a)e.attr(t,`for`,e.useId(f)||null);let p=i.closest(`fieldset`)?.querySelector(`:scope > [data-field="validation"]`);p&&!p?.hidden&&(u=!0,d||=c(p),o.unshift(e.useId(p)));let m=e.attr(f,r);m&&(f.indeterminate=m===`true`),(f.type===`radio`||f.type===`checkbox`)&&e.attr(i,`data-clickdelegatefor`,e.useId(f));let h=(e.attr(f,n)?.trim().split(/\s+/))?.filter(e=>!s.includes(e))||[];e.attr(f,n,[...o,...h].join(` `)||null),i._descs=o;let g=i._validation;u&&!g&&!f.hasAttribute(t)?(e.attr(f,t,`true`),i._validation=!0):!u&&g&&(e.attr(f,t,null),i._validation=void 0),i.handleEvent()},o={over:`%d tegn for mye`,under:`%d tegn igjen`},s=e.debounce((t,n)=>{document.activeElement===t&&e.announce(n)},i),c=e=>e.getAttribute(`data-color`)!==`success`,l=e=>e instanceof HTMLElement&&`validity`in e&&!(e instanceof HTMLButtonElement)&&e.type!==`hidden`;var u=class extends e.DSElement{_counter;_descs;_input;_validation;_unevents;_unmutate;connectedCallback(){this._unevents=e.on(this,`input`,this,e.QUICK_EVENT),this._unmutate=e.onMutation(this,()=>a(this),{attributeFilter:[`data-field`,`data-limit`,`hidden`,`id`,`value`,r],attributes:!0,childList:!0,subtree:!0})}handleEvent(t){let{_counter:n,_input:r}=this;if(n?.isConnected&&r){let i=(Number(e.attr(n,`data-limit`))||0)-r.value.length,a=i<0?`over`:`under`,c=(e.attrOrCSS(n,`data-${a}`)||o[a])?.replace(`%d`,`${Math.abs(i)}`);c||e.warn(`Missing data-${a} on:`,n),e.attr(n,`data-label`,c),e.attr(n,`data-state`,a),e.attr(n,`data-color`,i<0?`danger`:null),t?.type===`input`&&c&&s(r,c)}r instanceof HTMLTextAreaElement&&(r.style.setProperty(`--_ds-field-sizing`,`auto`),r.style.setProperty(`--_ds-field-sizing`,`${r.scrollHeight}px`))}disconnectedCallback(){this._unevents?.(),this._unmutate?.(),this._unevents=this._unmutate=void 0,this._input=this._counter=this._descs=this._validation=void 0}};e.customElements.define(`ds-field`,u),exports.DSFieldElement=u;
|
|
2
2
|
//# sourceMappingURL=field.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.cjs","names":["isWindows","useId","attr","attrOrCSS","debounce","DSElement","customElements","onHotReload","on","QUICK_EVENT","onMutation"],"sources":["../../../src/field/field.ts"],"sourcesContent":["import {\n announce,\n attr,\n attrOrCSS,\n customElements,\n DSElement,\n debounce,\n isWindows,\n on,\n onHotReload,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\n// TODO: Document that Validation must be hidden with \"hidden\" attribute (or completely removed from DOM), not display: none\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-field': DSFieldElement;\n }\n}\n\nconst ATTR_INVALID = 'aria-invalid';\nconst ATTR_DESCRIBEDBY = 'aria-describedby';\nconst ATTR_INDETERMINATE = 'data-indeterminate';\nconst COUNTER_DEBOUNCE = isWindows() ? 800 : 200; // Longer debounce on Windows due to NVDA performance\nconst COUNTS = new WeakMap<HTMLInputElement, Element>(); // Using WeakMap so removed inputs/counts does not cause memory leaks\nconst FIELDS = new Map<DSFieldElement, string[]>(); // Map of Field and its describedby IDs so we can identify the ones we add/remove\nconst VALIDATIONS = new WeakSet<HTMLInputElement>(); // Used to ensure we only take control of aria-invalid if the current is or has been a validation element\nconst WARNING_MULTIPLE_INPUTS = `Fields should only have one input element. Use <fieldset> to group multiple fields:`;\n\nconst handleFieldMutations = (_doc: Node, records: MutationRecord[] = []) => {\n for (const { target } of records) {\n const isFieldset = target instanceof HTMLFieldSetElement;\n for (const [field] of FIELDS)\n if (isFieldset ? target.contains(field) : field.contains(target))\n handleFieldMutation(field);\n }\n};\n\nconst handleFieldMutation = (field: DSFieldElement) => {\n const labels: HTMLLabelElement[] = [];\n const nextDescs: string[] = []; // Keep track of descriptions we are adding in this mutation\n const prevDescs = FIELDS.get(field) || []; // Retrieve previously managed IDs for this field\n let input: HTMLInputElement | undefined;\n let counter: Element | undefined;\n let hasValidation = false;\n let invalid = false;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n if ((el as HTMLElement).hidden) continue; // Skip hidden elements except labels\n if (isInputLike(el)) {\n if (input) warn(WARNING_MULTIPLE_INPUTS, field);\n else input = el; // Only register if visible input\n } else {\n const type = el.getAttribute('data-field'); // Using getAttribute instead of attr for best performance\n if (type === 'counter') counter = el;\n if (type === 'validation') {\n nextDescs.unshift(useId(el));\n hasValidation = true;\n invalid = invalid || isInvalid(el);\n } else if (type) nextDescs.push(useId(el)); // Adds both counter and descriptions\n }\n }\n\n if (!input) return; // Do not warn about missing input as virtual DOM libraries might give false positives\n if (counter) COUNTS.set(input, counter);\n for (const label of labels) attr(label, 'for', useId(input));\n\n const fieldsetValidation = field\n .closest('fieldset')\n ?.querySelector<HTMLElement>(':scope > [data-field=\"validation\"]');\n\n // Connect fieldset validation to inputs\n if (fieldsetValidation && !fieldsetValidation?.hidden) {\n hasValidation = true;\n invalid = invalid || isInvalid(fieldsetValidation);\n nextDescs.unshift(useId(fieldsetValidation));\n }\n\n // Add support for data-indeterminate attribute as this normally can only be set by javascript\n const indeterminate = attr(input, ATTR_INDETERMINATE);\n if (indeterminate) input.indeterminate = indeterminate === 'true';\n\n // Expand click area to ds-field if radio/checkbox\n const isBoolish = input.type === 'radio' || input.type === 'checkbox';\n if (isBoolish) attr(field, 'data-clickdelegatefor', useId(input));\n\n // Setup aria-describedby, but repsect existing ids in aria-describedby\n const describedby = attr(input, ATTR_DESCRIBEDBY)?.trim().split(/\\s+/);\n const keep = describedby?.filter((id) => !prevDescs.includes(id)) || []; // Find non-ds-field-managed aria-describedby IDs\n attr(input, ATTR_DESCRIBEDBY, [...nextDescs, ...keep].join(' ') || null);\n FIELDS.set(field, nextDescs);\n\n // Only manage aria-invalid when field has validation elements, and aria-invalid does not already exist\n const hadValidation = VALIDATIONS.has(input);\n if (hasValidation && !hadValidation && !input.hasAttribute(ATTR_INVALID)) {\n attr(input, ATTR_INVALID, 'true');\n VALIDATIONS.add(input);\n } else if (!hasValidation && hadValidation) {\n attr(input, ATTR_INVALID, null); // Remove aria-invalid\n VALIDATIONS.delete(input);\n }\n\n handleFieldInput(input); // Update counter and textarea sizing\n};\n\n// Used as fallback in tests when CSS is not loaded\nconst TEXTS = {\n over: '%d tegn for mye',\n under: '%d tegn igjen',\n};\n\nconst handleFieldInput = (e: Event | Element) => {\n const input = ((e as Event).target || e) as HTMLInputElement;\n const counter = COUNTS.get(input);\n\n if (counter?.isConnected) {\n const limit = Number(attr(counter, 'data-limit')) || 0;\n const count = limit - input.value.length;\n const state = count < 0 ? 'over' : 'under';\n const label = (\n attrOrCSS(counter, `data-${state}`) || TEXTS[state]\n )?.replace('%d', `${Math.abs(count)}`);\n\n attr(counter, 'data-label', label); // Using attribute to prevent hydation errors, not using aria-label to make axe tests happy\n attr(counter, 'data-state', state);\n attr(counter, 'data-color', count < 0 ? 'danger' : null);\n\n // Only update live region when user is actually typing\n if ((e as Event).type === 'input' && label)\n debouncedCounterLiveRegion(input, label); // Debounce live region to avoid NVDA interupting announcing typed text\n }\n if (input instanceof HTMLTextAreaElement) {\n input.style.setProperty('--_ds-field-sizing', 'auto');\n input.style.setProperty('--_ds-field-sizing', `${input.scrollHeight}px`);\n }\n};\n\nconst debouncedCounterLiveRegion = debounce((input: Element, text: string) => {\n if (document.activeElement === input) announce(text); // Only announce if input is still focused\n}, COUNTER_DEBOUNCE);\n\nconst isInvalid = (el: Element) => el.getAttribute('data-color') !== 'success';\nconst isInputLike = (el: unknown): el is HTMLInputElement =>\n el instanceof HTMLElement &&\n 'validity' in el && // Adds support for custom elements implemeted with attachInternals()\n !(el instanceof HTMLButtonElement) && // But skip <button> elements\n (el as HTMLInputElement).type !== 'hidden'; // And skip input type=\"hidden\"\n\n// Custom element is used to performantly keep track of fields on the page\nexport class DSFieldElement extends DSElement {\n connectedCallback() {\n FIELDS.set(this, []); // Register field\n handleFieldMutation(this); // Initial setup\n }\n disconnectedCallback() {\n FIELDS.delete(this);\n }\n}\n\ncustomElements.define('ds-field', DSFieldElement);\n\nonHotReload('field', () => [\n on(document, 'input', handleFieldInput, QUICK_EVENT),\n onMutation(document, handleFieldMutations, {\n attributeFilter: [\n 'data-field',\n 'data-limit',\n 'hidden', // Needed to check validation visibility\n 'id', // Needed to sync label \"for\" when ID of input/selec/textarea changes\n 'value', // Needed to detect changes in controlled React inputs as they do not trigger input events\n ATTR_INDETERMINATE,\n ],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"sCAuBM,EAAe,eACf,EAAmB,mBACnB,EAAqB,qBACrB,EAAmBA,EAAAA,UAAU,EAAI,IAAM,IACvC,EAAS,IAAI,QACb,EAAS,IAAI,IACb,EAAc,IAAI,QAGlB,GAAwB,EAAY,EAA4B,CAAC,IAAM,CAC3E,IAAK,GAAM,CAAE,YAAY,EAAS,CAChC,IAAM,EAAa,aAAkB,oBACrC,IAAK,GAAM,CAAC,KAAU,GAChB,EAAa,EAAO,SAAS,CAAK,EAAI,EAAM,SAAS,CAAM,IAC7D,EAAoB,CAAK,CAC/B,CACF,EAEM,EAAuB,GAA0B,CACrD,IAAM,EAA6B,CAAC,EAC9B,EAAsB,CAAC,EACvB,EAAY,EAAO,IAAI,CAAK,GAAK,CAAC,EACpC,EACA,EACA,EAAgB,G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CAC1B,CACA,sBAAuB,CACrB,EAAO,OAAO,IAAI,CACpB,CACF,EAEAC,EAAAA,eAAe,OAAO,WAAY,CAAc,EAEhDC,EAAAA,YAAY,YAAe,CACzBC,EAAAA,GAAG,SAAU,QAAS,EAAkBC,EAAAA,WAAW,EACnDC,EAAAA,WAAW,SAAU,EAAsB,CACzC,gBAAiB,CACf,aACA,aACA,SACA,KACA,QACA,CACF,EACA,WAAY,GACZ,UAAW,GACX,QAAS,EACX,CAAC,CACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"field.cjs","names":["isWindows","useId","attr","debounce","DSElement","on","QUICK_EVENT","onMutation","attrOrCSS","customElements"],"sources":["../../../src/field/field.ts"],"sourcesContent":["import {\n announce,\n attr,\n attrOrCSS,\n customElements,\n DSElement,\n debounce,\n isWindows,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\n// TODO: Document that Validation must be hidden with \"hidden\" attribute (or completely removed from DOM), not display: none\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-field': DSFieldElement;\n }\n}\n\nconst ATTR_INVALID = 'aria-invalid';\nconst ATTR_DESCRIBEDBY = 'aria-describedby';\nconst ATTR_INDETERMINATE = 'data-indeterminate';\nconst COUNTER_DEBOUNCE = isWindows() ? 800 : 200; // Longer debounce on Windows due to NVDA performance\nconst WARNING_MULTIPLE_INPUTS = `Fields should only have one input element. Use <fieldset> to group multiple fields:`;\n\nconst handleFieldMutation = (field: DSFieldElement) => {\n const labels: HTMLLabelElement[] = [];\n const nextDescs: string[] = []; // Keep track of descriptions we are adding in this mutation\n const prevDescs = field._descs || []; // Retrieve previously managed IDs for this field\n let hasValidation = false;\n let invalid = false;\n\n if (field._input?.hidden) field._input = undefined; // Reset input if it has been hidden\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n if ((el as HTMLElement).hidden) continue; // Skip hidden elements except labels\n if (isInputLike(el)) {\n if (field._input?.isConnected && field._input !== el)\n warn(WARNING_MULTIPLE_INPUTS, field);\n else field._input = el; // Only register if visible input\n } else {\n const type = el.getAttribute('data-field'); // Using getAttribute instead of attr for best performance\n if (type === 'counter') field._counter = el;\n if (type === 'validation') {\n nextDescs.unshift(useId(el));\n hasValidation = true;\n invalid = invalid || isInvalid(el);\n } else if (type) nextDescs.push(useId(el)); // Adds both counter and descriptions\n }\n }\n\n if (!field._input?.isConnected) return; // Do not warn about missing input as virtual DOM libraries might give false positives\n\n const input = field._input;\n for (const label of labels) attr(label, 'for', useId(input) || null);\n\n const fieldsetValidation = field\n .closest('fieldset')\n ?.querySelector<HTMLElement>(':scope > [data-field=\"validation\"]');\n\n // Connect fieldset validation to inputs\n if (fieldsetValidation && !fieldsetValidation?.hidden) {\n hasValidation = true;\n invalid = invalid || isInvalid(fieldsetValidation);\n nextDescs.unshift(useId(fieldsetValidation));\n }\n\n // Add support for data-indeterminate attribute as this normally can only be set by javascript\n\n const indeterminate = attr(input, ATTR_INDETERMINATE);\n if (indeterminate) input.indeterminate = indeterminate === 'true';\n\n // Expand click area to ds-field if radio/checkbox\n const isBoolish = input.type === 'radio' || input.type === 'checkbox';\n if (isBoolish) attr(field, 'data-clickdelegatefor', useId(input));\n\n // Setup aria-describedby, but repsect existing ids in aria-describedby\n const describedby = attr(input, ATTR_DESCRIBEDBY)?.trim().split(/\\s+/);\n const keep = describedby?.filter((id) => !prevDescs.includes(id)) || []; // Find non-ds-field-managed aria-describedby IDs\n attr(input, ATTR_DESCRIBEDBY, [...nextDescs, ...keep].join(' ') || null);\n field._descs = nextDescs;\n\n // Only manage aria-invalid when field has validation elements, and aria-invalid does not already exist\n const hadValidation = field._validation;\n if (hasValidation && !hadValidation && !input.hasAttribute(ATTR_INVALID)) {\n attr(input, ATTR_INVALID, 'true');\n field._validation = true;\n } else if (!hasValidation && hadValidation) {\n attr(input, ATTR_INVALID, null); // Remove aria-invalid\n field._validation = undefined;\n }\n\n field.handleEvent(); // Update counter and textarea sizing\n};\n\n// Used as fallback in tests when CSS is not loaded\nconst TEXTS = {\n over: '%d tegn for mye',\n under: '%d tegn igjen',\n};\n\nconst debouncedCounterLiveRegion = debounce((input: Element, text: string) => {\n if (document.activeElement === input) announce(text); // Only announce if input is still focused\n}, COUNTER_DEBOUNCE);\n\nconst isInvalid = (el: Element) => el.getAttribute('data-color') !== 'success';\nconst isInputLike = (el: unknown): el is HTMLInputElement =>\n el instanceof HTMLElement &&\n 'validity' in el && // Adds support for custom elements implemeted with attachInternals()\n !(el instanceof HTMLButtonElement) && // But skip <button> elements\n (el as HTMLInputElement).type !== 'hidden'; // And skip input type=\"hidden\"\n\n// Custom element is used to performantly keep track of fields on the page\nexport class DSFieldElement extends DSElement {\n _counter?: Element; // Using underscore instead of private fields for backwards compatibility\n _descs?: string[];\n _input?: HTMLInputElement;\n _validation?: boolean;\n _unevents?: () => void;\n _unmutate?: () => void;\n\n connectedCallback() {\n this._unevents = on(this, 'input', this, QUICK_EVENT);\n this._unmutate = onMutation(this, () => handleFieldMutation(this), {\n attributeFilter: [\n 'data-field',\n 'data-limit',\n 'hidden', // Needed to check validation visibility\n 'id', // Needed to sync label \"for\" when ID of input/selec/textarea changes\n 'value', // Needed to detect changes in controlled React inputs as they do not trigger input events\n ATTR_INDETERMINATE,\n ],\n attributes: true,\n childList: true,\n subtree: true,\n });\n }\n handleEvent(event?: Event) {\n const { _counter, _input } = this;\n\n if (_counter?.isConnected && _input) {\n const limit = Number(attr(_counter, 'data-limit')) || 0;\n const count = limit - _input.value.length;\n const state = count < 0 ? 'over' : 'under';\n const label = (attrOrCSS(_counter, `data-${state}`) || TEXTS[state]) // Browser translation tools will not pick up dynamic text anyway, so no need to use aria-labelledby here\n ?.replace('%d', `${Math.abs(count)}`);\n\n if (!label) warn(`Missing data-${state} on:`, _counter);\n attr(_counter, 'data-label', label); // Using attribute to prevent hydration errors, not using aria-label to make axe tests happy\n attr(_counter, 'data-state', state);\n attr(_counter, 'data-color', count < 0 ? 'danger' : null);\n\n // Only update live region when user is actually typing\n if (event?.type === 'input' && label)\n debouncedCounterLiveRegion(_input, label); // Debounce live region to avoid NVDA interupting announcing typed text\n }\n if (_input instanceof HTMLTextAreaElement) {\n _input.style.setProperty('--_ds-field-sizing', 'auto');\n _input.style.setProperty(\n '--_ds-field-sizing',\n `${_input.scrollHeight}px`,\n );\n }\n }\n disconnectedCallback() {\n this._unevents?.();\n this._unmutate?.();\n this._unevents = this._unmutate = undefined;\n this._input = this._counter = this._descs = this._validation = undefined;\n }\n}\n\ncustomElements.define('ds-field', DSFieldElement);\n"],"mappings":"sCAsBM,EAAe,eACf,EAAmB,mBACnB,EAAqB,qBACrB,EAAmBA,EAAAA,UAAU,EAAI,IAAM,IAGvC,EAAuB,GAA0B,CACrD,IAAM,EAA6B,CAAC,EAC9B,EAAsB,CAAC,EACvB,EAAY,EAAM,QAAU,CAAC,EAC/B,EAAgB,GAChB,EAAU,GAEV,EAAM,QAAQ,SAAQ,EAAM,OAAS,IAAA,IAEzC,IAAK,IAAM,KAAM,EAAM,qBAAqB,GAAG,EAC7C,GAAI,aAAc,kBAAkB,EAAO,KAAK,CAAE,EAC7C,GAAmB,OACxB,GAAI,EAAY,CAAE,EACZ,EAAM,QAAQ,aAAe,EAAM,SAAW,EAChD,EAAA,KAAK,sFAAyB,CAAK,EAChC,EAAM,OAAS,MACf,CACL,IAAM,EAAO,EAAG,aAAa,YAAY,EACrC,IAAS,YAAW,EAAM,SAAW,GACrC,IAAS,cACX,EAAU,QAAQC,EAAAA,MAAM,CAAE,CAAC,EAC3B,EAAgB,GAChB,IAAqB,EAAU,CAAE,GACxB,GAAM,EAAU,KAAKA,EAAAA,MAAM,CAAE,CAAC,CAC3C,CAGF,GAAI,CAAC,EAAM,QAAQ,YAAa,OAEhC,IAAM,EAAQ,EAAM,OACpB,IAAK,IAAM,KAAS,EAAQ,EAAA,KAAK,EAAO,MAAOA,EAAAA,MAAM,CAAK,GAAK,IAAI,EAEnE,IAAM,EAAqB,EACxB,QAAQ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AMC,EAAAA,WAAW,EACpD,KAAK,UAAYC,EAAAA,WAAW,SAAY,EAAoB,IAAI,EAAG,CACjE,gBAAiB,CACf,aACA,aACA,SACA,KACA,QACA,CACF,EACA,WAAY,GACZ,UAAW,GACX,QAAS,EACX,CAAC,CACH,CACA,YAAY,EAAe,CACzB,GAAM,CAAE,WAAU,UAAW,KAE7B,GAAI,GAAU,aAAe,EAAQ,CAEnC,IAAM,GADQ,OAAOL,EAAAA,KAAK,EAAU,YAAY,CAAC,GAAK,GAChC,EAAO,MAAM,OAC7B,EAAQ,EAAQ,EAAI,OAAS,QAC7B,GAASM,EAAAA,UAAU,EAAU,QAAQ,GAAO,GAAK,EAAM,GAAA,EACzD,QAAQ,KAAM,GAAG,KAAK,IAAI,CAAK,GAAG,EAEjC,GAAO,EAAA,KAAK,gBAAgB,EAAM,MAAO,CAAQ,EACtD,EAAA,KAAK,EAAU,aAAc,CAAK,EAClC,EAAA,KAAK,EAAU,aAAc,CAAK,EAClC,EAAA,KAAK,EAAU,aAAc,EAAQ,EAAI,SAAW,IAAI,EAGpD,GAAO,OAAS,SAAW,GAC7B,EAA2B,EAAQ,CAAK,CAC5C,CACI,aAAkB,sBACpB,EAAO,MAAM,YAAY,qBAAsB,MAAM,EACrD,EAAO,MAAM,YACX,qBACA,GAAG,EAAO,aAAa,GACzB,EAEJ,CACA,sBAAuB,CACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAY,KAAK,UAAY,IAAA,GAClC,KAAK,OAAS,KAAK,SAAW,KAAK,OAAS,KAAK,YAAc,IAAA,EACjE,CACF,EAEAC,EAAAA,eAAe,OAAO,WAAY,CAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../utils/utils.cjs"),t=e.isBrowser()?document.getElementsByTagName(`fieldset`):[],n=()=>{for(let n of t)n.hasAttribute(`aria-labelledby`)
|
|
1
|
+
const e=require("../utils/utils.cjs"),t=e.isBrowser()?document.getElementsByTagName(`fieldset`):[],n=()=>{for(let n of t){if(n.hasAttribute(`aria-labelledby`))continue;let t=`${e.useId(n.querySelector(`legend`))} ${e.useId(n.querySelector(`:scope > :is([data-field="description"],legend + p)`))}`;e.attr(n,e.ARIA_LABELLEDBY,t.trim()||null)}};e.onHotReload(`fieldset`,()=>[e.onMutation(document,n,{childList:!0,subtree:!0})]);
|
|
2
2
|
//# sourceMappingURL=fieldset.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldset.cjs","names":["isBrowser","useId","onHotReload","onMutation"],"sources":["../../../src/fieldset/fieldset.ts"],"sourcesContent":["import {\n attr,\n isBrowser,\n onHotReload,\n onMutation,\n useId,\n} from '../utils/utils';\n\nconst FIELDSETS = isBrowser() ? document.getElementsByTagName('fieldset') : [];\n\n// NOTE:\n// <fieldset> descriptions should be accessible to screen reader users. However, using aria-describedby\n// on <fieldset> causes all child <input> elements to inherit the same description, resulting in redundant and confusing announcements.\n// To avoid this, we use aria-labelledby to reference both the legend and the description.\n// aria-labelledby is only announced when screen readers enter the fieldset, not when navigating its child elements.\n// This means the accessible name of <fieldset> includes both the legend and description, which may differ from some test expectations,\n// but as of March 2026, this approach provides the best user experience across assistive technologies.\n// This approach is also verified by the chief of accessibility at NRK and the accessibility expert at NAV\nconst handleFieldsetMutations = () => {\n for (const el of FIELDSETS) {\n if (el.hasAttribute(
|
|
1
|
+
{"version":3,"file":"fieldset.cjs","names":["isBrowser","useId","ARIA_LABELLEDBY","onHotReload","onMutation"],"sources":["../../../src/fieldset/fieldset.ts"],"sourcesContent":["import {\n ARIA_LABELLEDBY,\n attr,\n isBrowser,\n onHotReload,\n onMutation,\n useId,\n} from '../utils/utils';\n\nconst FIELDSETS = isBrowser() ? document.getElementsByTagName('fieldset') : [];\n\n// NOTE:\n// <fieldset> descriptions should be accessible to screen reader users. However, using aria-describedby\n// on <fieldset> causes all child <input> elements to inherit the same description, resulting in redundant and confusing announcements.\n// To avoid this, we use aria-labelledby to reference both the legend and the description.\n// aria-labelledby is only announced when screen readers enter the fieldset, not when navigating its child elements.\n// This means the accessible name of <fieldset> includes both the legend and description, which may differ from some test expectations,\n// but as of March 2026, this approach provides the best user experience across assistive technologies.\n// This approach is also verified by the chief of accessibility at NRK and the accessibility expert at NAV\nconst handleFieldsetMutations = () => {\n for (const el of FIELDSETS) {\n if (el.hasAttribute(ARIA_LABELLEDBY)) continue; // Speed up by skipping labelled fieldsets\n const labelledby = `${useId(el.querySelector('legend'))} ${useId(el.querySelector(':scope > :is([data-field=\"description\"],legend + p)'))}`;\n attr(el, ARIA_LABELLEDBY, labelledby.trim() || null);\n }\n};\n\nonHotReload('fieldset', () => [\n onMutation(document, handleFieldsetMutations, {\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"sCASM,EAAYA,EAAAA,UAAU,EAAI,SAAS,qBAAqB,UAAU,EAAI,CAAC,EAUvE,MAAgC,CACpC,IAAK,IAAM,KAAM,EAAW,CAC1B,GAAI,EAAG,aAAA,iBAA4B,EAAG,SACtC,IAAM,EAAa,GAAGC,EAAAA,MAAM,EAAG,cAAc,QAAQ,CAAC,EAAE,GAAGA,EAAAA,MAAM,EAAG,cAAc,qDAAqD,CAAC,IACxI,EAAA,KAAK,EAAIC,EAAAA,gBAAiB,EAAW,KAAK,GAAK,IAAI,CACrD,CACF,EAEAC,EAAAA,YAAY,eAAkB,CAC5BC,EAAAA,WAAW,SAAU,EAAyB,CAC5C,UAAW,GACX,QAAS,EACX,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../utils/utils.cjs"),t=`focusgroup`,n=`${t}start`,r=new WeakMap,i=new Map,a={listbox:{block:!0,wrap:!1,items:`option`},menu:{block:!0,wrap:!0,items:`menuitem`},menubar:{block:!1,wrap:!0,items:`menuitem`},radiogroup:{block:null,wrap:!0,items:`radio`},tablist:{block:!1,wrap:!0,items:`tab`},toolbar:{block:!1,wrap:!1,items:null}};let o=!1;const s=new Set([`AUDIO`,`VIDEO`,`TEXTAREA`,`SELECT`,`date`,`datetime-local`,`email`,`month`,`number`,`password`,`range`,`search`,`tel`,`text`,`time`,`url`,`week`]),c=e.isBrowser()&&(t in HTMLElement.prototype||`focusGroup`in HTMLElement.prototype),l=e=>o=e,u=t=>{if(t.defaultPrevented||t.altKey||t.metaKey||t.ctrlKey)return;let n=t.key===`Tab`,r=t.key===`ArrowUp`||t.key===`ArrowDown`,i=r||t.key===`ArrowLeft`||t.key===`ArrowRight`;if(!n&&!i&&t.key!==`Home`&&t.key!==`End`)return;n&&(l(!0),setTimeout(l,100,!1));let a=e.getComposedTarget(t);if(!a||b(a))return;let o=f(e.getComposedPath(a));if(o?.role&&o?.el===a&&(o=f(e.getComposedPath(o.el.parentNode))),!o?.role)return;let s=m(o.el,a),c=0;if(n)return setTimeout(x,0,s,x(s));if(t.key===`Home`)c=0;else if(t.key===`End`)c=s.length-1;else{let{direction:e,writingMode:n}=getComputedStyle(a),i=n.startsWith(`vertical`),l=i?n===`vertical-rl`:e===`rtl`,u=t.key===`ArrowDown`||t.key===`ArrowRight`,d=r!==i,f=u!==(!r&&l);if((o.block??d)!==d)return;c=s.indexOf(a)+(f?1:-1),c=o.wrap?(s.length+c)%s.length:Math.max(0,Math.min(c,s.length-1))}s[c]!==a&&t.preventDefault(),s[c]?.focus?.()},d=t=>{let r=e.getComposedTarget(t),a=e.getComposedPath(r);for(let[e,t]of i)!a.has(e)&&i.delete(e)&&t();for(let t of a)t.nodeType===11&&!i.has(t)&&i.set(t,e.on(t,`focus`,d,e.QUICK_EVENT));if(t.target?.shadowRoot)return;let s=f(a);if(s?.role){if(o&&!b(s.focus)){let e=h(m(s.el,null),r),t=s.memory&&e.includes(s.focus)&&s.focus||e.find(e=>e?.hasAttribute(n))||e[0];if(t!==r)return t?.focus?.()}s.focus=r}},f=n=>{for(let i of n){if(i.nodeType!==Node.ELEMENT_NODE)continue;let n=i.getAttribute(t);if(n!==null){let t=r.get(i);if(t?.key===n)return t;t=p(i,n),r.set(i,t);for(let n of m(i))n&&!n.hasAttribute(`role`)&&e.attr(n,`role`,t.items);return i.hasAttribute(`role`)||e.attr(i,`role`,t.role),t}if(_(i))return}},p=(e,t)=>{let n=new Set(t.toLowerCase().split(` `)),r=[...n].find(e=>e in a),i=a[r],o=n.has(`inline`),s=n.has(`block`);return{key:t,el:e,role:r,block:o&&s?null:s||!o&&i?.block,focus:null,items:i?.items,memory:!n.has(`nomemory`),wrap:n.has(`wrap`)||!n.has(`nowrap`)&&i?.wrap}},m=(e,n,r=[],i=!1)=>{let a=e?.nodeName===`SLOT`?e.assignedElements({flatten:!0}):(e?.shadowRoot||e)?.children;for(let e=0,o=a?.length||e;a&&e<o;e++){let o=a[e];if(o.nodeName===`SLOT`)m(o,n,r,i);else if(g(o)&&!_(o)&&v(o)){let e=o.getAttribute(t);o===n||!i&&e!==`none`&&y(o)?r.push(o):e!==null&&n===null?r.push(null):m(o,n,r,i||e!==null)}}return r},h=(e,t)=>{let n=e.indexOf(t),r=e.indexOf(null,n);return e.slice(e.lastIndexOf(null,n)+1,r===-1?void 0:r)},g=e=>!e.inert&&!e.hidden&&!e.disabled,_=e=>e?.nodeName===`DIALOG`||e?.hasAttribute(`popover`),v=e.isBrowser()&&typeof Element.prototype.checkVisibility==`function`?e=>e.checkVisibility():e=>e.offsetParent!==null,y=e=>e.isContentEditable||e.tabIndex>=0&&!e.disabled,b=e=>e?.isContentEditable||s.has(e?.nodeName)||e?.nodeName===`INPUT`&&s.has(e.type),x=(t,n)=>Array.from(t,(t,r)=>{let i=t?.getAttribute(`tabindex`);return t&&e.attr(t,`tabindex`,n?n[r]:`-1`),i});c||e.onHotReload(t,()=>[e.on(document,`keydown`,u),e.on(document,`focus`,d,e.QUICK_EVENT),()=>{for(let[,e]of i)e();i.clear()}]),exports.getGroup=f,exports.getItems=m,exports.isConflict=b,exports.isFocusable=y;
|
|
2
|
+
//# sourceMappingURL=focusgroup.cjs.map
|