@digdir/designsystemet-web 1.20.1 → 1.21.1
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/LICENSE +1 -1
- package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs +1 -1
- package/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs.map +1 -1
- package/dist/cjs/_vendors/invokers-polyfill/invoker.cjs +1 -1
- package/dist/cjs/_vendors/invokers-polyfill/invoker.cjs.map +1 -1
- package/dist/cjs/field/field.cjs +1 -1
- package/dist/cjs/field/field.cjs.map +1 -1
- package/dist/cjs/focusgroup/focusgroup.cjs +1 -1
- package/dist/cjs/focusgroup/focusgroup.cjs.map +1 -1
- package/dist/cjs/packages/web/package.cjs +1 -1
- package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js +1 -1
- package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js.map +1 -1
- package/dist/esm/_vendors/invokers-polyfill/invoker.js +1 -1
- package/dist/esm/_vendors/invokers-polyfill/invoker.js.map +1 -1
- package/dist/esm/field/field.js +1 -1
- package/dist/esm/field/field.js.map +1 -1
- package/dist/esm/focusgroup/focusgroup.js +1 -1
- package/dist/esm/focusgroup/focusgroup.js.map +1 -1
- package/dist/esm/packages/web/package.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +11 -14
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/package.json +8 -8
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright Digitaliseringsdirektoratet (Digdir)
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
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&&`showPopover`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(e=>CSS.escape(e)).join(`.`);return`
|
|
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||t;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&&`showPopover`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(e=>CSS.escape(e)).join(`.`);return`
|
|
2
2
|
${t?`@layer ${n} {`:``}
|
|
3
3
|
:where([popover]) {
|
|
4
4
|
position: fixed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-fn.cjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@oddbird+popover-polyfill@0.7.1_patch_hash=6227913935a153774e0e2569cb889d63767e7a5d572dbc6beeadfb2e77ed5c11/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 && \"showPopover\" 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((c) => CSS.escape(c)).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 || !root.adoptedStyleSheets) {\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 writable: 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 writable: true,\n value() {\n hidePopover(this, true, true);\n }\n },\n togglePopover: {\n enumerable: true,\n configurable: true,\n writable: 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 const owner = target.ownerDocument || target;\n hideAllPopoversUntil(owner, 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,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E,EADc,EAAO,eAAiB,EACV,GAAM,EAAI,CAE1C,GAC2B,GAAS,CAClC,EAAK,iBAAiB,QAAS,CAAuB,EACtD,EAAK,iBAAiB,UAAW,CAAS,EAC1C,EAAK,iBAAiB,cAAe,CAAwB,EAC7D,EAAK,iBAAiB,YAAa,CAAwB,CAC7D,EACA,CAAkB,QAAQ,EAC1B,EAAa,SAAU,CAAS,CAClC"}
|
|
1
|
+
{"version":3,"file":"popover-fn.cjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@oddbird+popover-polyfill@0.7.2/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 || target;\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 && // Returns true in HappyDOM\n \"showPopover\" 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) => CSS.escape(css)).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 || !root.adoptedStyleSheets) {\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 writable: 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 writable: true,\n value() {\n hidePopover(this, true, true);\n }\n },\n togglePopover: {\n enumerable: true,\n configurable: true,\n writable: 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 const owner = target.ownerDocument || target;\n hideAllPopoversUntil(owner, 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,CAC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oB,IAAW,IAAQ,UAAY,IAAQ,QAEpE,EADc,EAAO,eAAiB,EACV,GAAM,EAAI,CAE1C,GAC2B,GAAS,CAClC,EAAK,iBAAiB,QAAS,CAAuB,EACtD,EAAK,iBAAiB,UAAW,CAAS,EAC1C,EAAK,iBAAiB,cAAe,CAAwB,EAC7D,EAAK,iBAAiB,YAAa,CAAwB,CAC7D,EACA,CAAkB,QAAQ,EAC1B,EAAa,SAAU,CAAS,CAClC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(){return typeof HTMLButtonElement<`u`&&`command`in HTMLButtonElement.prototype&&`source`in((globalThis.CommandEvent||{}).prototype||{})}function t(){document.addEventListener(`
|
|
1
|
+
function e(){return typeof HTMLButtonElement<`u`&&`command`in HTMLButtonElement.prototype&&`source`in((globalThis.CommandEvent||{}).prototype||{})}function t(){document.addEventListener(`command`,e=>{e.type==`command`&&e.isTrusted&&(e.stopImmediatePropagation(),e.preventDefault())},!0);function e(e,t,n=!0){Object.defineProperty(e,t,{...Object.getOwnPropertyDescriptor(e,t),enumerable:n})}function t(e){return e&&typeof e.getRootNode==`function`?e.getRootNode():e&&e.parentNode?t(e.parentNode):e}let n=new WeakMap,r=new WeakMap;class i extends Event{constructor(e,t={}){super(e,t);let{source:i,command:a}=t;if(i!=null&&!(i instanceof Element))throw TypeError(`source must be an element`);n.set(this,i||null),r.set(this,a===void 0?``:String(a))}get[Symbol.toStringTag](){return`CommandEvent`}get source(){if(!n.has(this))throw TypeError(`illegal invocation`);let e=n.get(this);if(!(e instanceof Element))return null;let r=t(e);return r===t(this.target||document)?e:r.host}get command(){if(!r.has(this))throw TypeError(`illegal invocation`);return r.get(this)}}e(i.prototype,`source`),e(i.prototype,`command`);let a=new WeakMap;function o(e){Object.defineProperties(e.prototype,{commandForElement:{enumerable:!0,configurable:!0,set(e){if(e===null)this.removeAttribute(`commandfor`),a.delete(this);else if(e instanceof Element){this.setAttribute(`commandfor`,``);let n=t(e);t(this)===n||n===this.ownerDocument?a.set(this,e):a.delete(this)}else throw TypeError(`commandForElement must be an element or null`)},get(){if(this.localName!==`button`||this.disabled)return null;if(this.form&&this.getAttribute(`type`)!==`button`)return console.warn("Element with `commandFor` is a form participant. It should explicitly set `type=button` in order for `commandFor` to work"),null;let e=a.get(this);if(e)return e.isConnected?e:(a.delete(this),null);let n=t(this),r=this.getAttribute(`commandfor`);return(n instanceof Document||n instanceof ShadowRoot)&&r&&n.getElementById(r)||null}},command:{enumerable:!0,configurable:!0,get(){let e=this.getAttribute(`command`)||``;if(e.startsWith(`--`))return e;let t=e.toLowerCase();switch(t){case`show-modal`:case`request-close`:case`close`:case`toggle-popover`:case`hide-popover`:case`show-popover`:return t}return``},set(e){this.setAttribute(`command`,e)}}})}let s=new WeakMap;Object.defineProperties(HTMLElement.prototype,{oncommand:{enumerable:!0,configurable:!0,get(){return l.takeRecords(),s.get(this)||null},set(e){let t=s.get(this)||null;t&&this.removeEventListener(`command`,t),s.set(this,typeof e==`object`||typeof e==`function`?e:null),typeof e==`function`&&this.addEventListener(`command`,e)}}});function c(e){for(let t of e)t.oncommand=Function(`event`,t.getAttribute(`oncommand`))}let l=new MutationObserver(e=>{for(let t of e){let{target:e}=t;t.type===`childList`?c(e.querySelectorAll(`[oncommand]`)):c([e])}});l.observe(document,{subtree:!0,childList:!0,attributeFilter:[`oncommand`]}),c(document.querySelectorAll(`[oncommand]`));let u=new WeakSet;function d(e){if(u.has(e)||(u.add(e),e.defaultPrevented)||e.type!==`click`)return;let t=e.composedPath().find(e=>e.matches?.(`button[commandfor], button[command]`));if(!t)return;if(t.form&&t.getAttribute(`type`)!==`button`)throw e.preventDefault(),Error("Element with `commandFor` is a form participant. It should explicitly set `type=button` in order for `commandFor` to work. In order for it to act as a Submit button, it must not have command or commandfor attributes");if(t.hasAttribute(`command`)!==t.hasAttribute(`commandfor`)){let e=t.hasAttribute(`command`)?`command`:`commandfor`,n=t.hasAttribute(`command`)?`commandfor`:`command`;throw Error(`Element with ${e} attribute must also have a ${n} attribute to function.`)}if(t.command!==`show-popover`&&t.command!==`hide-popover`&&t.command!==`toggle-popover`&&t.command!==`show-modal`&&t.command!==`request-close`&&t.command!==`close`&&!t.command.startsWith(`--`)){console.warn(`"${t.command}" is not a valid command value. Custom commands must begin with --`);return}let n=t.commandForElement;if(!n)return;let r=new i(`command`,{command:t.command,source:t,cancelable:!0});if(n.dispatchEvent(r),r.defaultPrevented)return;let a=r.command.toLowerCase();if(n.popover){let e=!n.matches(`:popover-open`);e&&(a===`toggle-popover`||a===`show-popover`)?n.showPopover({source:t}):!e&&(a===`toggle-popover`||a===`hide-popover`)&&n.hidePopover()}else if(n.localName===`dialog`){let e=!n.hasAttribute(`open`);e&&a==`show-modal`?n.showModal():!e&&a==`close`?n.close(t.value?t.value:void 0):!e&&a==`request-close`&&(HTMLDialogElement.prototype.requestClose||(HTMLDialogElement.prototype.requestClose=function(){let e=new Event(`cancel`,{cancelable:!0});this.dispatchEvent(e),e.defaultPrevented||this.close()}),n.requestClose(t.value?t.value:void 0))}}function f(e){e.addEventListener(`click`,d,!0)}function p(e,t){let n=e.prototype.attachShadow;e.prototype.attachShadow=function(e){let r=n.call(this,e);return t(r),r};let r=e.prototype.attachInternals;e.prototype.attachInternals=function(){let e=r.call(this);return e.shadowRoot&&t(e.shadowRoot),e}}o(HTMLButtonElement),p(HTMLElement,e=>{f(e),l.observe(e,{attributeFilter:[`oncommand`]}),c(e.querySelectorAll(`[oncommand]`))}),f(document),Object.assign(globalThis,{CommandEvent:i})}exports.apply=t,exports.isSupported=e;
|
|
2
2
|
//# sourceMappingURL=invoker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoker.cjs","names":[],"sources":["../../../../../../node_modules/.pnpm/invokers-polyfill@1.0.3/node_modules/invokers-polyfill/invoker.js"],"sourcesContent":["export function isSupported() {\n return (\n typeof HTMLButtonElement !== \"undefined\" &&\n \"command\" in HTMLButtonElement.prototype &&\n \"source\" in ((globalThis.CommandEvent || {}).prototype || {})\n );\n}\n\nexport function isPolyfilled() {\n return !/native code/i.test((globalThis.CommandEvent || {}).toString());\n}\n\nexport function apply() {\n // XXX: Invoker Buttons used to dispatch 'invoke' events instead of\n // 'command' events. We should ensure to prevent 'invoke' events being\n // fired in those browsers.\n // XXX: https://bugs.chromium.org/p/chromium/issues/detail?id=1523183\n // Chrome will dispatch invoke events even with the flag disabled; so\n // we need to capture those to prevent duplicate events.\n document.addEventListener(\n \"invoke\",\n (e) => {\n if (e.type == \"invoke\" && e.isTrusted) {\n e.stopImmediatePropagation();\n e.preventDefault();\n }\n },\n true,\n );\n document.addEventListener(\n \"command\",\n (e) => {\n if (e.type == \"command\" && e.isTrusted) {\n e.stopImmediatePropagation();\n e.preventDefault();\n }\n },\n true,\n );\n\n function enumerate(obj, key, enumerable = true) {\n Object.defineProperty(obj, key, {\n ...Object.getOwnPropertyDescriptor(obj, key),\n enumerable,\n });\n }\n\n function getRootNode(node) {\n if (node && typeof node.getRootNode === \"function\") {\n return node.getRootNode();\n }\n if (node && node.parentNode) return getRootNode(node.parentNode);\n return node;\n }\n\n const commandEventSourceElements = new WeakMap();\n const commandEventActions = new WeakMap();\n\n class CommandEvent extends Event {\n constructor(type, invokeEventInit = {}) {\n super(type, invokeEventInit);\n const { source, command } = invokeEventInit;\n if (source != null && !(source instanceof Element)) {\n throw new TypeError(`source must be an element`);\n }\n commandEventSourceElements.set(this, source || null);\n commandEventActions.set(\n this,\n command !== undefined ? String(command) : \"\",\n );\n }\n\n get [Symbol.toStringTag]() {\n return \"CommandEvent\";\n }\n\n get source() {\n if (!commandEventSourceElements.has(this)) {\n throw new TypeError(\"illegal invocation\");\n }\n const source = commandEventSourceElements.get(this);\n if (!(source instanceof Element)) return null;\n const invokerRoot = getRootNode(source);\n if (invokerRoot !== getRootNode(this.target || document)) {\n return invokerRoot.host;\n }\n return source;\n }\n\n get command() {\n if (!commandEventActions.has(this)) {\n throw new TypeError(\"illegal invocation\");\n }\n return commandEventActions.get(this);\n }\n }\n enumerate(CommandEvent.prototype, \"source\");\n enumerate(CommandEvent.prototype, \"command\");\n\n const invokerAssociatedElements = new WeakMap();\n\n function applyInvokerMixin(ElementClass) {\n Object.defineProperties(ElementClass.prototype, {\n commandForElement: {\n enumerable: true,\n configurable: true,\n set(targetElement) {\n if (targetElement === null) {\n this.removeAttribute(\"commandfor\");\n invokerAssociatedElements.delete(this);\n } else if (!(targetElement instanceof Element)) {\n throw new TypeError(`commandForElement must be an element or null`);\n } else {\n this.setAttribute(\"commandfor\", \"\");\n const targetRootNode = getRootNode(targetElement);\n const thisRootNode = getRootNode(this);\n if (\n thisRootNode === targetRootNode ||\n targetRootNode === this.ownerDocument\n ) {\n invokerAssociatedElements.set(this, targetElement);\n } else {\n invokerAssociatedElements.delete(this);\n }\n }\n },\n get() {\n if (this.localName !== \"button\") {\n return null;\n }\n if (this.disabled) {\n return null;\n }\n if (this.form && this.getAttribute(\"type\") !== \"button\") {\n console.warn(\n \"Element with `commandFor` is a form participant. \" +\n \"It should explicitly set `type=button` in order for `commandFor` to work\",\n );\n return null;\n }\n const targetElement = invokerAssociatedElements.get(this);\n if (targetElement) {\n if (targetElement.isConnected) {\n return targetElement;\n } else {\n invokerAssociatedElements.delete(this);\n return null;\n }\n }\n const root = getRootNode(this);\n const idref = this.getAttribute(\"commandfor\");\n if (\n (root instanceof Document || root instanceof ShadowRoot) &&\n idref\n ) {\n return root.getElementById(idref) || null;\n }\n return null;\n },\n },\n command: {\n enumerable: true,\n configurable: true,\n get() {\n const value = this.getAttribute(\"command\") || \"\";\n if (value.startsWith(\"--\")) return value;\n const valueLower = value.toLowerCase();\n switch (valueLower) {\n case \"show-modal\":\n case \"request-close\":\n case \"close\":\n case \"toggle-popover\":\n case \"hide-popover\":\n case \"show-popover\":\n return valueLower;\n }\n return \"\";\n },\n set(value) {\n this.setAttribute(\"command\", value);\n },\n },\n });\n }\n\n const onHandlers = new WeakMap();\n Object.defineProperties(HTMLElement.prototype, {\n oncommand: {\n enumerable: true,\n configurable: true,\n get() {\n oncommandObserver.takeRecords();\n return onHandlers.get(this) || null;\n },\n set(handler) {\n const existing = onHandlers.get(this) || null;\n if (existing) {\n this.removeEventListener(\"command\", existing);\n }\n onHandlers.set(\n this,\n typeof handler === \"object\" || typeof handler === \"function\"\n ? handler\n : null,\n );\n if (typeof handler == \"function\") {\n this.addEventListener(\"command\", handler);\n }\n },\n },\n });\n function applyOnCommandHandler(els) {\n for (const el of els) {\n el.oncommand = new Function(\"event\", el.getAttribute(\"oncommand\"));\n }\n }\n const oncommandObserver = new MutationObserver((records) => {\n for (const record of records) {\n const { target } = record;\n if (record.type === \"childList\") {\n applyOnCommandHandler(target.querySelectorAll(\"[oncommand]\"));\n } else {\n applyOnCommandHandler([target]);\n }\n }\n });\n oncommandObserver.observe(document, {\n subtree: true,\n childList: true,\n attributeFilter: [\"oncommand\"],\n });\n applyOnCommandHandler(document.querySelectorAll(\"[oncommand]\"));\n\n const processedEvents = new WeakSet();\n\n function handleInvokerActivation(event) {\n if (processedEvents.has(event)) return;\n\n processedEvents.add(event);\n\n if (event.defaultPrevented) return;\n if (event.type !== \"click\") return;\n const source = event.composedPath().find((el) => el.matches?.(\"button[commandfor], button[command]\"));\n if (!source) return;\n\n if (source.form && source.getAttribute(\"type\") !== \"button\") {\n event.preventDefault();\n throw new Error(\n \"Element with `commandFor` is a form participant. \" +\n \"It should explicitly set `type=button` in order for `commandFor` to work. \" +\n \"In order for it to act as a Submit button, it must not have command or commandfor attributes\",\n );\n }\n\n if (source.hasAttribute(\"command\") !== source.hasAttribute(\"commandfor\")) {\n const attr = source.hasAttribute(\"command\") ? \"command\" : \"commandfor\";\n const missing = source.hasAttribute(\"command\") ? \"commandfor\" : \"command\";\n throw new Error(\n `Element with ${attr} attribute must also have a ${missing} attribute to function.`,\n );\n }\n\n if (\n source.command !== \"show-popover\" &&\n source.command !== \"hide-popover\" &&\n source.command !== \"toggle-popover\" &&\n source.command !== \"show-modal\" &&\n source.command !== \"request-close\" &&\n source.command !== \"close\" &&\n !source.command.startsWith(\"--\")\n ) {\n console.warn(\n `\"${source.command}\" is not a valid command value. Custom commands must begin with --`,\n );\n return;\n }\n\n const invokee = source.commandForElement;\n if (!invokee) return;\n const invokeEvent = new CommandEvent(\"command\", {\n command: source.command,\n source,\n cancelable: true,\n });\n invokee.dispatchEvent(invokeEvent);\n if (invokeEvent.defaultPrevented) return;\n\n const command = invokeEvent.command.toLowerCase();\n\n if (invokee.popover) {\n const canShow = !invokee.matches(\":popover-open\");\n const shouldShow =\n canShow && (command === \"toggle-popover\" || command === \"show-popover\");\n const shouldHide = !canShow && command === \"hide-popover\";\n\n if (shouldShow) {\n invokee.showPopover({ source });\n } else if (shouldHide) {\n invokee.hidePopover();\n }\n } else if (invokee.localName === \"dialog\") {\n const canShow = !invokee.hasAttribute(\"open\");\n\n if (canShow && command == \"show-modal\") {\n invokee.showModal();\n } else if (!canShow && command == \"close\") {\n invokee.close(source.value ? source.value : undefined);\n } else if (!canShow && command == \"request-close\") {\n // requestClose is only supported from Safari 18.4, so we polyfill it on older browsers\n if (!HTMLDialogElement.prototype.requestClose) {\n HTMLDialogElement.prototype.requestClose = function () {\n const cancelEvent = new Event(\"cancel\", { cancelable: true });\n this.dispatchEvent(cancelEvent);\n\n if (!cancelEvent.defaultPrevented) {\n this.close();\n }\n };\n }\n\n invokee.requestClose(source.value ? source.value : undefined);\n }\n }\n }\n\n function setupInvokeListeners(target) {\n target.addEventListener(\"click\", handleInvokerActivation, true);\n }\n\n function observeShadowRoots(ElementClass, callback) {\n const attachShadow = ElementClass.prototype.attachShadow;\n ElementClass.prototype.attachShadow = function (init) {\n const shadow = attachShadow.call(this, init);\n callback(shadow);\n return shadow;\n };\n const attachInternals = ElementClass.prototype.attachInternals;\n ElementClass.prototype.attachInternals = function () {\n const internals = attachInternals.call(this);\n if (internals.shadowRoot) callback(internals.shadowRoot);\n return internals;\n };\n }\n\n applyInvokerMixin(HTMLButtonElement);\n\n observeShadowRoots(HTMLElement, (shadow) => {\n setupInvokeListeners(shadow);\n oncommandObserver.observe(shadow, { attributeFilter: [\"oncommand\"] });\n applyOnCommandHandler(shadow.querySelectorAll(\"[oncommand]\"));\n });\n\n setupInvokeListeners(document);\n\n Object.assign(globalThis, { CommandEvent });\n}\n"],"x_google_ignoreList":[0],"mappings":"AAAA,SAAgB,GAAc,CAC5B,OACE,OAAO,kBAAsB,KAC7B,YAAa,kBAAkB,WAC/B,YAAc,WAAW,cAAgB,CAAC,EAAA,CAAG,WAAa,CAAC,EAE/D,CAMA,SAAgB,GAAQ,CAOtB,SAAS,iBACP,SACC,GAAM,CACD,EAAE,MAAQ,UAAY,EAAE,YAC1B,EAAE,yBAAyB,EAC3B,EAAE,eAAe,EAErB,EACA,EACF,EACA,SAAS,iBACP,UACC,GAAM,CACD,EAAE,MAAQ,WAAa,EAAE,YAC3B,EAAE,yBAAyB,EAC3B,EAAE,eAAe,EAErB,EACA,EACF,EAEA,SAAS,EAAU,EAAK,EAAK,EAAa,GAAM,CAC9C,OAAO,eAAe,EAAK,EAAK,CAC9B,GAAG,OAAO,yBAAyB,EAAK,CAAG,EAC3C,YACF,CAAC,CACH,CAEA,SAAS,EAAY,EAAM,CAKzB,OAJI,GAAQ,OAAO,EAAK,aAAgB,WAC/B,EAAK,YAAY,EAEtB,GAAQ,EAAK,WAAmB,EAAY,EAAK,UAAU,EACxD,CACT,CAEA,IAAM,EAA6B,IAAI,QACjC,EAAsB,IAAI,QAEhC,MAAM,UAAqB,KAAM,CAC/B,YAAY,EAAM,EAAkB,CAAC,EAAG,CACtC,MAAM,EAAM,CAAe,EAC3B,GAAM,CAAE,SAAQ,WAAY,EAC5B,GAAI,GAAU,MAAQ,EAAE,aAAkB,SACxC,MAAU,UAAU,2BAA2B,EAEjD,EAA2B,IAAI,KAAM,GAAU,IAAI,EACnD,EAAoB,IAClB,KACA,IAAY,IAAA,GAA8B,GAAlB,OAAO,CAAO,CACxC,CACF,CAEA,IAAK,OAAO,cAAe,C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AU,CACzC,IAAM,EAAU,CAAC,EAAQ,aAAa,MAAM,EAExC,GAAW,GAAW,aACxB,EAAQ,UAAU,EACT,CAAC,GAAW,GAAW,QAChC,EAAQ,MAAM,EAAO,MAAQ,EAAO,MAAQ,IAAA,EAAS,EAC5C,CAAC,GAAW,GAAW,kBAE3B,kBAAkB,UAAU,eAC/B,kBAAkB,UAAU,aAAe,UAAY,CACrD,IAAM,EAAc,IAAI,MAAM,SAAU,CAAE,WAAY,EAAK,CAAC,EAC5D,KAAK,cAAc,CAAW,EAEzB,EAAY,kBACf,KAAK,MAAM,CAEf,GAGF,EAAQ,aAAa,EAAO,MAAQ,EAAO,MAAQ,IAAA,EAAS,EAEhE,CACF,CAEA,SAAS,EAAqB,EAAQ,CACpC,EAAO,iBAAiB,QAAS,EAAyB,EAAI,CAChE,CAEA,SAAS,EAAmB,EAAc,EAAU,CAClD,IAAM,EAAe,EAAa,UAAU,aAC5C,EAAa,UAAU,aAAe,SAAU,EAAM,CACpD,IAAM,EAAS,EAAa,KAAK,KAAM,CAAI,EAE3C,OADA,EAAS,CAAM,EACR,CACT,EACA,IAAM,EAAkB,EAAa,UAAU,gBAC/C,EAAa,UAAU,gBAAkB,UAAY,CACnD,IAAM,EAAY,EAAgB,KAAK,IAAI,EAE3C,OADI,EAAU,YAAY,EAAS,EAAU,UAAU,EAChD,CACT,CACF,CAEA,EAAkB,iBAAiB,EAEnC,EAAmB,YAAc,GAAW,CAC1C,EAAqB,CAAM,EAC3B,EAAkB,QAAQ,EAAQ,CAAE,gBAAiB,CAAC,WAAW,CAAE,CAAC,EACpE,EAAsB,EAAO,iBAAiB,aAAa,CAAC,CAC9D,CAAC,EAED,EAAqB,QAAQ,EAE7B,OAAO,OAAO,WAAY,CAAE,cAAa,CAAC,CAC5C"}
|
|
1
|
+
{"version":3,"file":"invoker.cjs","names":[],"sources":["../../../../../../node_modules/.pnpm/invokers-polyfill@1.0.4/node_modules/invokers-polyfill/invoker.js"],"sourcesContent":["export function isSupported() {\n return (\n typeof HTMLButtonElement !== \"undefined\" &&\n \"command\" in HTMLButtonElement.prototype &&\n \"source\" in ((globalThis.CommandEvent || {}).prototype || {})\n );\n}\n\nexport function isPolyfilled() {\n return !/native code/i.test((globalThis.CommandEvent || {}).toString());\n}\n\nexport function apply() {\n document.addEventListener(\n \"command\",\n (e) => {\n if (e.type == \"command\" && e.isTrusted) {\n e.stopImmediatePropagation();\n e.preventDefault();\n }\n },\n true,\n );\n\n function enumerate(obj, key, enumerable = true) {\n Object.defineProperty(obj, key, {\n ...Object.getOwnPropertyDescriptor(obj, key),\n enumerable,\n });\n }\n\n function getRootNode(node) {\n if (node && typeof node.getRootNode === \"function\") {\n return node.getRootNode();\n }\n if (node && node.parentNode) return getRootNode(node.parentNode);\n return node;\n }\n\n const commandEventSourceElements = new WeakMap();\n const commandEventActions = new WeakMap();\n\n class CommandEvent extends Event {\n constructor(type, invokeEventInit = {}) {\n super(type, invokeEventInit);\n const { source, command } = invokeEventInit;\n if (source != null && !(source instanceof Element)) {\n throw new TypeError(`source must be an element`);\n }\n commandEventSourceElements.set(this, source || null);\n commandEventActions.set(\n this,\n command !== undefined ? String(command) : \"\",\n );\n }\n\n get [Symbol.toStringTag]() {\n return \"CommandEvent\";\n }\n\n get source() {\n if (!commandEventSourceElements.has(this)) {\n throw new TypeError(\"illegal invocation\");\n }\n const source = commandEventSourceElements.get(this);\n if (!(source instanceof Element)) return null;\n const invokerRoot = getRootNode(source);\n if (invokerRoot !== getRootNode(this.target || document)) {\n return invokerRoot.host;\n }\n return source;\n }\n\n get command() {\n if (!commandEventActions.has(this)) {\n throw new TypeError(\"illegal invocation\");\n }\n return commandEventActions.get(this);\n }\n }\n enumerate(CommandEvent.prototype, \"source\");\n enumerate(CommandEvent.prototype, \"command\");\n\n const invokerAssociatedElements = new WeakMap();\n\n function applyInvokerMixin(ElementClass) {\n Object.defineProperties(ElementClass.prototype, {\n commandForElement: {\n enumerable: true,\n configurable: true,\n set(targetElement) {\n if (targetElement === null) {\n this.removeAttribute(\"commandfor\");\n invokerAssociatedElements.delete(this);\n } else if (!(targetElement instanceof Element)) {\n throw new TypeError(`commandForElement must be an element or null`);\n } else {\n this.setAttribute(\"commandfor\", \"\");\n const targetRootNode = getRootNode(targetElement);\n const thisRootNode = getRootNode(this);\n if (\n thisRootNode === targetRootNode ||\n targetRootNode === this.ownerDocument\n ) {\n invokerAssociatedElements.set(this, targetElement);\n } else {\n invokerAssociatedElements.delete(this);\n }\n }\n },\n get() {\n if (this.localName !== \"button\") {\n return null;\n }\n if (this.disabled) {\n return null;\n }\n if (this.form && this.getAttribute(\"type\") !== \"button\") {\n console.warn(\n \"Element with `commandFor` is a form participant. \" +\n \"It should explicitly set `type=button` in order for `commandFor` to work\",\n );\n return null;\n }\n const targetElement = invokerAssociatedElements.get(this);\n if (targetElement) {\n if (targetElement.isConnected) {\n return targetElement;\n } else {\n invokerAssociatedElements.delete(this);\n return null;\n }\n }\n const root = getRootNode(this);\n const idref = this.getAttribute(\"commandfor\");\n if (\n (root instanceof Document || root instanceof ShadowRoot) &&\n idref\n ) {\n return root.getElementById(idref) || null;\n }\n return null;\n },\n },\n command: {\n enumerable: true,\n configurable: true,\n get() {\n const value = this.getAttribute(\"command\") || \"\";\n if (value.startsWith(\"--\")) return value;\n const valueLower = value.toLowerCase();\n switch (valueLower) {\n case \"show-modal\":\n case \"request-close\":\n case \"close\":\n case \"toggle-popover\":\n case \"hide-popover\":\n case \"show-popover\":\n return valueLower;\n }\n return \"\";\n },\n set(value) {\n this.setAttribute(\"command\", value);\n },\n },\n });\n }\n\n const onHandlers = new WeakMap();\n Object.defineProperties(HTMLElement.prototype, {\n oncommand: {\n enumerable: true,\n configurable: true,\n get() {\n oncommandObserver.takeRecords();\n return onHandlers.get(this) || null;\n },\n set(handler) {\n const existing = onHandlers.get(this) || null;\n if (existing) {\n this.removeEventListener(\"command\", existing);\n }\n onHandlers.set(\n this,\n typeof handler === \"object\" || typeof handler === \"function\"\n ? handler\n : null,\n );\n if (typeof handler == \"function\") {\n this.addEventListener(\"command\", handler);\n }\n },\n },\n });\n function applyOnCommandHandler(els) {\n for (const el of els) {\n el.oncommand = new Function(\"event\", el.getAttribute(\"oncommand\"));\n }\n }\n const oncommandObserver = new MutationObserver((records) => {\n for (const record of records) {\n const { target } = record;\n if (record.type === \"childList\") {\n applyOnCommandHandler(target.querySelectorAll(\"[oncommand]\"));\n } else {\n applyOnCommandHandler([target]);\n }\n }\n });\n oncommandObserver.observe(document, {\n subtree: true,\n childList: true,\n attributeFilter: [\"oncommand\"],\n });\n applyOnCommandHandler(document.querySelectorAll(\"[oncommand]\"));\n\n const processedEvents = new WeakSet();\n\n function handleInvokerActivation(event) {\n if (processedEvents.has(event)) return;\n\n processedEvents.add(event);\n\n if (event.defaultPrevented) return;\n if (event.type !== \"click\") return;\n const source = event.composedPath().find((el) => el.matches?.(\"button[commandfor], button[command]\"));\n if (!source) return;\n\n if (source.form && source.getAttribute(\"type\") !== \"button\") {\n event.preventDefault();\n throw new Error(\n \"Element with `commandFor` is a form participant. \" +\n \"It should explicitly set `type=button` in order for `commandFor` to work. \" +\n \"In order for it to act as a Submit button, it must not have command or commandfor attributes\",\n );\n }\n\n if (source.hasAttribute(\"command\") !== source.hasAttribute(\"commandfor\")) {\n const attr = source.hasAttribute(\"command\") ? \"command\" : \"commandfor\";\n const missing = source.hasAttribute(\"command\") ? \"commandfor\" : \"command\";\n throw new Error(\n `Element with ${attr} attribute must also have a ${missing} attribute to function.`,\n );\n }\n\n if (\n source.command !== \"show-popover\" &&\n source.command !== \"hide-popover\" &&\n source.command !== \"toggle-popover\" &&\n source.command !== \"show-modal\" &&\n source.command !== \"request-close\" &&\n source.command !== \"close\" &&\n !source.command.startsWith(\"--\")\n ) {\n console.warn(\n `\"${source.command}\" is not a valid command value. Custom commands must begin with --`,\n );\n return;\n }\n\n const invokee = source.commandForElement;\n if (!invokee) return;\n const invokeEvent = new CommandEvent(\"command\", {\n command: source.command,\n source,\n cancelable: true,\n });\n invokee.dispatchEvent(invokeEvent);\n if (invokeEvent.defaultPrevented) return;\n\n const command = invokeEvent.command.toLowerCase();\n\n if (invokee.popover) {\n const canShow = !invokee.matches(\":popover-open\");\n const shouldShow =\n canShow && (command === \"toggle-popover\" || command === \"show-popover\");\n const shouldHide =\n !canShow &&\n (command === \"toggle-popover\" || command === \"hide-popover\");\n\n if (shouldShow) {\n invokee.showPopover({ source });\n } else if (shouldHide) {\n invokee.hidePopover();\n }\n } else if (invokee.localName === \"dialog\") {\n const canShow = !invokee.hasAttribute(\"open\");\n\n if (canShow && command == \"show-modal\") {\n invokee.showModal();\n } else if (!canShow && command == \"close\") {\n invokee.close(source.value ? source.value : undefined);\n } else if (!canShow && command == \"request-close\") {\n // requestClose is only supported from Safari 18.4, so we polyfill it on older browsers\n if (!HTMLDialogElement.prototype.requestClose) {\n HTMLDialogElement.prototype.requestClose = function () {\n const cancelEvent = new Event(\"cancel\", { cancelable: true });\n this.dispatchEvent(cancelEvent);\n\n if (!cancelEvent.defaultPrevented) {\n this.close();\n }\n };\n }\n\n invokee.requestClose(source.value ? source.value : undefined);\n }\n }\n }\n\n function setupInvokeListeners(target) {\n target.addEventListener(\"click\", handleInvokerActivation, true);\n }\n\n function observeShadowRoots(ElementClass, callback) {\n const attachShadow = ElementClass.prototype.attachShadow;\n ElementClass.prototype.attachShadow = function (init) {\n const shadow = attachShadow.call(this, init);\n callback(shadow);\n return shadow;\n };\n const attachInternals = ElementClass.prototype.attachInternals;\n ElementClass.prototype.attachInternals = function () {\n const internals = attachInternals.call(this);\n if (internals.shadowRoot) callback(internals.shadowRoot);\n return internals;\n };\n }\n\n applyInvokerMixin(HTMLButtonElement);\n\n observeShadowRoots(HTMLElement, (shadow) => {\n setupInvokeListeners(shadow);\n oncommandObserver.observe(shadow, { attributeFilter: [\"oncommand\"] });\n applyOnCommandHandler(shadow.querySelectorAll(\"[oncommand]\"));\n });\n\n setupInvokeListeners(document);\n\n Object.assign(globalThis, { CommandEvent });\n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M,SAAU,CAAE,WAAY,EAAK,CAAC,EAC5D,KAAK,cAAc,CAAW,EAEzB,EAAY,kBACf,KAAK,MAAM,CAEf,GAGF,EAAQ,aAAa,EAAO,MAAQ,EAAO,MAAQ,IAAA,EAAS,EAEhE,CACF,CAEA,SAAS,EAAqB,EAAQ,CACpC,EAAO,iBAAiB,QAAS,EAAyB,EAAI,CAChE,CAEA,SAAS,EAAmB,EAAc,EAAU,CAClD,IAAM,EAAe,EAAa,UAAU,aAC5C,EAAa,UAAU,aAAe,SAAU,EAAM,CACpD,IAAM,EAAS,EAAa,KAAK,KAAM,CAAI,EAE3C,OADA,EAAS,CAAM,EACR,CACT,EACA,IAAM,EAAkB,EAAa,UAAU,gBAC/C,EAAa,UAAU,gBAAkB,UAAY,CACnD,IAAM,EAAY,EAAgB,KAAK,IAAI,EAE3C,OADI,EAAU,YAAY,EAAS,EAAU,UAAU,EAChD,CACT,CACF,CAEA,EAAkB,iBAAiB,EAEnC,EAAmB,YAAc,GAAW,CAC1C,EAAqB,CAAM,EAC3B,EAAkB,QAAQ,EAAQ,CAAE,gBAAiB,CAAC,WAAW,CAAE,CAAC,EACpE,EAAsB,EAAO,iBAAiB,aAAa,CAAC,CAC9D,CAAC,EAED,EAAqB,QAAQ,EAE7B,OAAO,OAAO,WAAY,CAAE,cAAa,CAAC,CAC5C"}
|
package/dist/cjs/field/field.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../utils/utils.cjs"),t=`data-field`,n=`data-limit`,r=`aria-invalid`,i=`aria-describedby`,a=`data-indeterminate`,o=`:scope > [${t}="validation"]`,s=e.isWindows()?800:200,c=n=>{let s=[],c=[],l=n._descs||[],u=!1,p=!1;n._input?.hidden&&(n._input=void 0);for(let r of n.getElementsByTagName(`*`))if(r instanceof HTMLLabelElement&&s.push(r),!r.hidden)if(f(r))n._input?.isConnected&&n._input!==r?e.warn(`Fields should only have one input element. Use <fieldset> to group multiple fields:`,n):n._input=r;else{let i=r.getAttribute(t);i===`counter`&&(n._counter=r),i===`validation`?(c.unshift(e.useId(r)),u=!0,p||=d(r)):i&&c.push(e.useId(r))}if(!n._input?.isConnected)return;let m=n._input;for(let t of s)e.attr(t,`for`,e.useId(m)||null);let h=n.closest(`fieldset`)?.querySelector(o);h&&!h?.hidden&&(u=!0,p||=d(h),c.unshift(e.useId(h)));let g=e.attr(m,a);g&&(m.indeterminate=g===`true`),(m.type===`radio`||m.type===`checkbox`)&&e.attr(n,`data-clickdelegatefor`,e.useId(m));let _=(e.attr(m,i)?.trim().split(/\s+/))?.filter(e=>!l.includes(e))||[];e.attr(m,i,[...c,..._].join(` `)||null),n._descs=c;let v=n._validation;u&&!v&&!m.hasAttribute(r)?(e.attr(m,r,p?`true`:null),n._validation=!0):!u&&v&&(e.attr(m,r,null),n._validation=void 0),n.handleEvent()},l={over:`%d tegn for mye`,under:`%d tegn igjen`},u=e.debounce((t,n)=>{document
|
|
1
|
+
const e=require("../utils/utils.cjs"),t=`data-field`,n=`data-limit`,r=`aria-invalid`,i=`aria-describedby`,a=`data-indeterminate`,o=`:scope > [${t}="validation"]`,s=e.isWindows()?800:200,c=n=>{let s=[],c=[],l=n._descs||[],u=!1,p=!1;n._input?.hidden&&(n._input=void 0);for(let r of n.getElementsByTagName(`*`))if(r instanceof HTMLLabelElement&&s.push(r),!r.hidden)if(f(r))n._input?.isConnected&&n._input!==r?e.warn(`Fields should only have one input element. Use <fieldset> to group multiple fields:`,n):n._input=r;else{let i=r.getAttribute(t);i===`counter`&&(n._counter=r),i===`validation`?(c.unshift(e.useId(r)),u=!0,p||=d(r)):i&&c.push(e.useId(r))}if(!n._input?.isConnected)return;let m=n._input;for(let t of s)e.attr(t,`for`,e.useId(m)||null);let h=n.closest(`fieldset`)?.querySelector(o);h&&!h?.hidden&&(u=!0,p||=d(h),c.unshift(e.useId(h)));let g=e.attr(m,a);g&&(m.indeterminate=g===`true`),(m.type===`radio`||m.type===`checkbox`)&&e.attr(n,`data-clickdelegatefor`,e.useId(m));let _=(e.attr(m,i)?.trim().split(/\s+/))?.filter(e=>!l.includes(e))||[];e.attr(m,i,[...c,..._].join(` `)||null),n._descs=c;let v=n._validation;u&&!v&&!m.hasAttribute(r)?(e.attr(m,r,p?`true`:null),n._validation=!0):!u&&v&&(e.attr(m,r,null),n._validation=void 0),n.handleEvent()},l={over:`%d tegn for mye`,under:`%d tegn igjen`},u=e.debounce((t,n)=>{e.isBrowser()&&document.activeElement===t&&e.announce(n)},s),d=e=>{let t=e.getAttribute(`data-color`);return!t||t===`danger`},f=e=>e instanceof HTMLElement&&`validity`in e&&!(e instanceof HTMLButtonElement)&&e.type!==`hidden`;var p=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,()=>c(this),{attributeFilter:[t,n,`hidden`,`id`,`value`,a],attributes:!0,childList:!0,subtree:!0})}handleEvent(t){let{_counter:r,_input:i}=this;if(r?.isConnected&&i){let a=(Number(e.attr(r,n))||0)-i.value.length,o=a<0?`over`:`under`,s=(e.attrOrCSS(r,`data-${o}`)||l[o])?.replace(`%d`,`${Math.abs(a)}`);s||e.warn(`Missing data-${o} on:`,r),e.attr(r,`data-label`,s),e.attr(r,`data-state`,o),e.attr(r,`data-color`,a<0?`danger`:null),e.attr(i,`aria-invalid`,a<0?`true`:null),t?.type===`input`&&s&&u(i,s)}i instanceof HTMLTextAreaElement&&(i.style.setProperty(`--_ds-field-sizing`,`auto`),i.style.setProperty(`--_ds-field-sizing`,`${i.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`,p),exports.DSFieldElement=p;
|
|
2
2
|
//# sourceMappingURL=field.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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_FIELD = 'data-field';\nconst ATTR_LIMIT = 'data-limit';\nconst ATTR_INVALID = 'aria-invalid';\nconst ATTR_DESCRIBEDBY = 'aria-describedby';\nconst ATTR_INDETERMINATE = 'data-indeterminate';\nconst SELECTOR_VALIDATION = `:scope > [${ATTR_FIELD}=\"validation\"]`;\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(ATTR_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 || isInvalidColor(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>(SELECTOR_VALIDATION);\n\n // Connect fieldset validation to inputs\n if (fieldsetValidation && !fieldsetValidation?.hidden) {\n hasValidation = true;\n invalid = invalid || isInvalidColor(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, invalid ? 'true' : null);\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 // Using document?. as this function might run after document is unmounted by tests\n if (document?.activeElement === input) announce(text); // Only announce if input is still focused\n}, COUNTER_DEBOUNCE);\n\nconst isInvalidColor = (el: Element) => {\n const color = el.getAttribute('data-color');\n return !color || color === 'danger';\n};\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 ATTR_FIELD,\n ATTR_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, ATTR_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 attr(_input, 'aria-invalid', count < 0 ? 'true' : null); // Toggle aria-invalid of textarea\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,EAAa,aACb,EAAa,aACb,EAAe,eACf,EAAmB,mBACnB,EAAqB,qBACrB,EAAsB,aAAa,EAAW,gBAC9C,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,CAAU,EACnC,IAAS,YAAW,EAAM,SAAW,GACrC,IAAS,cACX,EAAU,QAAQC,EAAAA,MAAM,CAAE,CAAC,EAC3B,EAAgB,GAChB,IAAqB,EAAe,CAAE,GAC7B,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,UAAU,CAAC,EAClB,cAA2B,CAAmB,EAG9C,GAAsB,CAAC,GAAoB,SAC7C,EAAgB,GAChB,IAAqB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AK,UAAYC,EAAAA,WAAW,SAAY,EAAoB,IAAI,EAAG,CACjE,gBAAiB,CACf,EACA,EACA,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,CAAU,CAAC,GAAK,GAC9B,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,EACxD,EAAA,KAAK,EAAQ,eAAgB,EAAQ,EAAI,OAAS,IAAI,EAGlD,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
|
+
{"version":3,"file":"field.cjs","names":["isWindows","useId","attr","debounce","isBrowser","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 isBrowser,\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_FIELD = 'data-field';\nconst ATTR_LIMIT = 'data-limit';\nconst ATTR_INVALID = 'aria-invalid';\nconst ATTR_DESCRIBEDBY = 'aria-describedby';\nconst ATTR_INDETERMINATE = 'data-indeterminate';\nconst SELECTOR_VALIDATION = `:scope > [${ATTR_FIELD}=\"validation\"]`;\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(ATTR_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 || isInvalidColor(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>(SELECTOR_VALIDATION);\n\n // Connect fieldset validation to inputs\n if (fieldsetValidation && !fieldsetValidation?.hidden) {\n hasValidation = true;\n invalid = invalid || isInvalidColor(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, invalid ? 'true' : null);\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 // Using isBrowser() to check if environment still exits and is not unmounted by tests\n if (isBrowser() && document.activeElement === input) announce(text); // Only announce if input is still focused\n}, COUNTER_DEBOUNCE);\n\nconst isInvalidColor = (el: Element) => {\n const color = el.getAttribute('data-color');\n return !color || color === 'danger';\n};\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 ATTR_FIELD,\n ATTR_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, ATTR_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 attr(_input, 'aria-invalid', count < 0 ? 'true' : null); // Toggle aria-invalid of textarea\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":"sCAuBM,EAAa,aACb,EAAa,aACb,EAAe,eACf,EAAmB,mBACnB,EAAqB,qBACrB,EAAsB,aAAa,EAAW,gBAC9C,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,CAAU,EACnC,IAAS,YAAW,EAAM,SAAW,GACrC,IAAS,cACX,EAAU,QAAQC,EAAAA,MAAM,CAAE,CAAC,EAC3B,EAAgB,GAChB,IAAqB,EAAe,CAAE,GAC7B,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,UAAU,CAAC,EAClB,cAA2B,CAAmB,EAG9C,GAAsB,CAAC,GAAoB,SAC7C,EAAgB,GAChB,IAAqB,EAAe,CAAkB,EACtD,EAAU,QAAQA,EAAAA,MAAM,CAAkB,CAAC,GAK7C,IAAM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jE,gBAAiB,CACf,EACA,EACA,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,OAAON,EAAAA,KAAK,EAAU,CAAU,CAAC,GAAK,GAC9B,EAAO,MAAM,OAC7B,EAAQ,EAAQ,EAAI,OAAS,QAC7B,GAASO,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,EACxD,EAAA,KAAK,EAAQ,eAAgB,EAAQ,EAAI,OAAS,IAAI,EAGlD,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=`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,
|
|
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){let e=s.filter(e=>e!==a);return setTimeout(x,0,e,x(e))}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
2
|
//# sourceMappingURL=focusgroup.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusgroup.cjs","names":["isBrowser","getComposedTarget","getComposedPath","on","QUICK_EVENT"],"sources":["../../../src/focusgroup/focusgroup.ts"],"sourcesContent":["import {\n attr,\n getComposedPath,\n getComposedTarget,\n isBrowser,\n on,\n onHotReload,\n QUICK_EVENT,\n} from '../utils/utils';\n\n// Intentionally not implemented:\n// - Clearing memory based on attribute changes: https://open-ui.org/components/scoped-focusgroup.explainer/#disabling-focusgroup-memory\n// - Setting ARIA roles before focus or keydown occurs (this is too performance consuming, and does not affect a11y much)\n\nconst ATTR_GROUP = 'focusgroup';\nconst PROP_GROUP = 'focusGroup';\nconst ATTR_START = `${ATTR_GROUP}start`;\nconst GROUPS = new WeakMap<Element, ReturnType<typeof parseGroup>>();\nconst ROOTS = new Map<Node, () => void>(); // ShadowRoots we listen for focus events on, since focus only triggers once on ShadowDOM due to event retargeting\nconst ROLES = {\n listbox: { block: true, wrap: false, items: 'option' },\n menu: { block: true, wrap: true, items: 'menuitem' },\n menubar: { block: false, wrap: true, items: 'menuitem' },\n radiogroup: { block: null, wrap: true, items: 'radio' },\n tablist: { block: false, wrap: true, items: 'tab' },\n toolbar: { block: false, wrap: false, items: null },\n};\nlet IS_TAB = false; // Used to check if focus event is a result of tabbing\nconst IS_CONFLICT = new Set([\n 'AUDIO',\n 'VIDEO',\n 'TEXTAREA',\n 'SELECT',\n 'date',\n 'datetime-local',\n 'email',\n 'month',\n 'number',\n 'password',\n 'range',\n 'search',\n 'tel',\n 'text',\n 'time',\n 'url',\n 'week',\n]);\n\n// Chrome has implemented camel case \"focusGroup\", but several polyfills checks both camel case and kebab case, so we support both for now\nconst IS_SUPPORTED =\n isBrowser() &&\n (ATTR_GROUP in HTMLElement.prototype || PROP_GROUP in HTMLElement.prototype);\n\nconst setIsTab = (state: boolean) => (IS_TAB = state);\nconst handleKeydown = (e: Event & Partial<KeyboardEvent>) => {\n if (e.defaultPrevented || e.altKey || e.metaKey || e.ctrlKey) return;\n\n const isTab = e.key === 'Tab';\n const isBlock = e.key === 'ArrowUp' || e.key === 'ArrowDown';\n const isArrow = isBlock || e.key === 'ArrowLeft' || e.key === 'ArrowRight';\n if (!isTab && !isArrow && e.key !== 'Home' && e.key !== 'End') return;\n if (isTab) {\n setIsTab(true);\n setTimeout(setIsTab, 100, false); // Reset after event loop so we can check if next focus event is a result of tabbing\n }\n\n const target = getComposedTarget(e) as Element | null;\n if (!target || isConflict(target)) return; // See https://open-ui.org/components/scoped-focusgroup.explainer/#key-conflict-elements\n\n let group = getGroup(getComposedPath(target));\n\n if (group?.role && group?.el === target)\n group = getGroup(getComposedPath(group.el.parentNode)); // If focus is on the group itself, check if it is nested inside another group\n if (!group?.role) return; // Ignore invalid parent groups\n\n const items = getItems(group.el, target); // Include target so we can move from tabindex=\"-1\" as according to spec\n let next = 0;\n\n if (isTab) return setTimeout(setTab, 0, items, setTab(items)); // Make sure next tab stop is outside focusgroup\n if (e.key === 'Home') next = 0;\n else if (e.key === 'End') next = items.length - 1;\n else {\n const { direction: dir, writingMode: mode } = getComputedStyle(target);\n const isFlipped = mode.startsWith('vertical');\n const isReverse = isFlipped ? mode === 'vertical-rl' : dir === 'rtl';\n const isForward = e.key === 'ArrowDown' || e.key === 'ArrowRight';\n\n const moveBlock = isBlock !== isFlipped;\n const moveForward = isForward !== (!isBlock && isReverse);\n\n if ((group.block ?? moveBlock) !== moveBlock) return; // Ignore if group direction does not match move direction\n next = items.indexOf(target) + (moveForward ? 1 : -1);\n\n if (group.wrap) next = (items.length + next) % items.length;\n else next = Math.max(0, Math.min(next, items.length - 1));\n }\n\n // Note: preventDefault() prevents native <input type=\"radio\"> elements from changing checked state with arrow keys.\n // Although this differs from native behavior, it matches focusgroup=\"radiogroup\" for <button role=\"radio\">.\n // toggle-group.ts already normalizes this for both <input type=\"radio\"> and <button role=\"radio\">,\n // meaning the following preventDefault() introduces no inconsistencies:\n if (items[next] !== target) e.preventDefault(); // Prevent scrolling if changing item\n (items[next] as HTMLElement)?.focus?.();\n};\n\nconst handleFocus = (e: Event & Partial<FocusEvent>) => {\n const target = getComposedTarget(e);\n const path = getComposedPath(target);\n\n for (const [el, off] of ROOTS) if (!path.has(el) && ROOTS.delete(el)) off(); // Remove focus listener on previous roots\n for (const el of path)\n if (el.nodeType === 11 && !ROOTS.has(el))\n ROOTS.set(el, on(el, 'focus', handleFocus, QUICK_EVENT)); // Listener will instantly dispatch since we are binding during triggering\n\n if ((e.target as Element)?.shadowRoot) return; // Avoid double handling by only processing focus events that are not already handled in a shadowRoot\n\n const group = getGroup(path);\n if (!group?.role) return;\n if (IS_TAB && !isConflict(group.focus)) {\n const segment = getSegment(getItems(group.el, null), target); // See https://open-ui.org/components/scoped-focusgroup.explainer/#focusgroup-segments\n const start =\n (group.memory && segment.includes(group.focus) && group.focus) ||\n segment.find((el) => el?.hasAttribute(ATTR_START)) ||\n segment[0];\n if (start !== target) return (start as HTMLElement)?.focus?.(); // Fix focus position if tabbing into segment\n }\n group.focus = target; // Always store focus\n};\n\nexport const getGroup = (path: Set<Node>) => {\n for (const el of path as Set<Element>) {\n if (el.nodeType !== Node.ELEMENT_NODE) continue;\n\n const key = el.getAttribute(ATTR_GROUP);\n if (key !== null) {\n let group = GROUPS.get(el);\n if (group?.key === key) return group; // Return cache if attribute is unchanged\n\n group = parseGroup(el, key);\n GROUPS.set(el, group);\n for (const item of getItems(el))\n if (item && !item.hasAttribute('role')) attr(item, 'role', group.items);\n if (!el.hasAttribute('role')) attr(el, 'role', group.role);\n return group;\n }\n if (isTopLayer(el)) return;\n }\n};\n\nconst parseGroup = (el: Element, key: string) => {\n const opts = new Set(key.toLowerCase().split(' '));\n const role = [...opts].find((t) => t in ROLES) as keyof typeof ROLES;\n const base = ROLES[role];\n const x = opts.has('inline');\n const y = opts.has('block');\n\n return {\n key,\n el,\n role,\n block: x && y ? null : y || (x ? false : base?.block),\n focus: null as Element | null,\n items: base?.items,\n memory: !opts.has('nomemory'),\n wrap: opts.has('wrap') || (opts.has('nowrap') ? false : base?.wrap),\n };\n};\n\nexport const getItems = (\n root?: Element | null,\n keep?: Element | null, // Provide Element to include, or null to keep segments (https://open-ui.org/components/scoped-focusgroup.explainer/#focusgroup-segments)\n items: (Element | null)[] = [], // Used only for recursion\n isNested = false, // Used only for recursion, to check if already inside a nested group\n) => {\n const children =\n root?.nodeName === 'SLOT'\n ? (root as HTMLSlotElement).assignedElements({ flatten: true })\n : (root?.shadowRoot || root)?.children;\n\n for (let i = 0, l = children?.length || i; children && i < l; i++) {\n const el = children[i] as HTMLElement;\n if (el.nodeName === 'SLOT') getItems(el, keep, items, isNested);\n else if (isKeyboardReachable(el) && !isTopLayer(el) && isVisible(el)) {\n const group = el.getAttribute(ATTR_GROUP);\n if (el === keep || (!isNested && group !== 'none' && isFocusable(el)))\n items.push(el);\n else if (group !== null && keep === null) items.push(null);\n else getItems(el, keep, items, isNested || group !== null);\n }\n }\n return items;\n};\n\n// Treats the null returned from getItems as a separator and returns segment containing \"item\"\nconst getSegment = <T>(acc: (T | null)[], item: T) => {\n const at = acc.indexOf(item);\n const to = acc.indexOf(null, at);\n return acc.slice(acc.lastIndexOf(null, at) + 1, to === -1 ? undefined : to);\n};\n\nconst isKeyboardReachable = (el: HTMLElement) =>\n !el.inert && !el.hidden && !(el as HTMLInputElement).disabled;\n\nconst isTopLayer = (el: Element | null) =>\n el?.nodeName === 'DIALOG' || el?.hasAttribute('popover'); // See https://open-ui.org/components/scoped-focusgroup.explainer/#top-layer-elements)\n\nconst isVisible =\n isBrowser() && typeof Element.prototype.checkVisibility === 'function'\n ? (el: HTMLElement) => el.checkVisibility()\n : (el: HTMLElement) => el.offsetParent !== null;\n\nexport const isFocusable = (el: HTMLElement) =>\n el.isContentEditable ||\n (el.tabIndex >= 0 && !(el as HTMLInputElement).disabled);\n\nexport const isConflict = (el: Node | null) =>\n (el as HTMLElement)?.isContentEditable ||\n IS_CONFLICT.has(el?.nodeName as string) ||\n (el?.nodeName === 'INPUT' && IS_CONFLICT.has((el as HTMLInputElement).type));\n\nconst setTab = (items: ReturnType<typeof getItems>, prevs?: string[]) =>\n Array.from(items, (item, index) => {\n const prev = item?.getAttribute('tabindex');\n if (item) attr(item, 'tabindex', prevs ? prevs[index] : '-1'); // Restore previous tabindex if provided\n return prev;\n });\n\nif (!IS_SUPPORTED)\n onHotReload(ATTR_GROUP, () => [\n on(document, 'keydown', handleKeydown),\n on(document, 'focus', handleFocus, QUICK_EVENT),\n () => {\n for (const [, off] of ROOTS) off(); // Cleanup listeners on ShadowRoots on hot reload\n ROOTS.clear();\n },\n ]);\n"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,WAAa,SAAW,EAAY,IAAK,EAAwB,IAAI,EAEtE,GAAU,EAAoC,IAClD,MAAM,KAAK,GAAQ,EAAM,IAAU,CACjC,IAAM,EAAO,GAAM,aAAa,UAAU,EAE1C,OADI,GAAM,EAAA,KAAK,EAAM,WAAY,EAAQ,EAAM,GAAS,IAAI,EACrD,CACT,CAAC,EAEE,GACH,EAAA,YAAY,MAAkB,CAC5BG,EAAAA,GAAG,SAAU,UAAW,CAAa,EACrCA,EAAAA,GAAG,SAAU,QAAS,EAAaC,EAAAA,WAAW,MACxC,CACJ,IAAK,GAAM,EAAG,KAAQ,EAAO,EAAI,EACjC,EAAM,MAAM,CACd,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"focusgroup.cjs","names":["isBrowser","getComposedTarget","getComposedPath","on","QUICK_EVENT"],"sources":["../../../src/focusgroup/focusgroup.ts"],"sourcesContent":["import {\n attr,\n getComposedPath,\n getComposedTarget,\n isBrowser,\n on,\n onHotReload,\n QUICK_EVENT,\n} from '../utils/utils';\n\n// Intentionally not implemented:\n// - Clearing memory based on attribute changes: https://open-ui.org/components/scoped-focusgroup.explainer/#disabling-focusgroup-memory\n// - Setting ARIA roles before focus or keydown occurs (this is too performance consuming, and does not affect a11y much)\n\nconst ATTR_GROUP = 'focusgroup';\nconst PROP_GROUP = 'focusGroup';\nconst ATTR_START = `${ATTR_GROUP}start`;\nconst GROUPS = new WeakMap<Element, ReturnType<typeof parseGroup>>();\nconst ROOTS = new Map<Node, () => void>(); // ShadowRoots we listen for focus events on, since focus only triggers once on ShadowDOM due to event retargeting\nconst ROLES = {\n listbox: { block: true, wrap: false, items: 'option' },\n menu: { block: true, wrap: true, items: 'menuitem' },\n menubar: { block: false, wrap: true, items: 'menuitem' },\n radiogroup: { block: null, wrap: true, items: 'radio' },\n tablist: { block: false, wrap: true, items: 'tab' },\n toolbar: { block: false, wrap: false, items: null },\n};\nlet IS_TAB = false; // Used to check if focus event is a result of tabbing\nconst IS_CONFLICT = new Set([\n 'AUDIO',\n 'VIDEO',\n 'TEXTAREA',\n 'SELECT',\n 'date',\n 'datetime-local',\n 'email',\n 'month',\n 'number',\n 'password',\n 'range',\n 'search',\n 'tel',\n 'text',\n 'time',\n 'url',\n 'week',\n]);\n\n// Chrome has implemented camel case \"focusGroup\", but several polyfills checks both camel case and kebab case, so we support both for now\nconst IS_SUPPORTED =\n isBrowser() &&\n (ATTR_GROUP in HTMLElement.prototype || PROP_GROUP in HTMLElement.prototype);\n\nconst setIsTab = (state: boolean) => (IS_TAB = state);\nconst handleKeydown = (e: Event & Partial<KeyboardEvent>) => {\n if (e.defaultPrevented || e.altKey || e.metaKey || e.ctrlKey) return;\n\n const isTab = e.key === 'Tab';\n const isBlock = e.key === 'ArrowUp' || e.key === 'ArrowDown';\n const isArrow = isBlock || e.key === 'ArrowLeft' || e.key === 'ArrowRight';\n if (!isTab && !isArrow && e.key !== 'Home' && e.key !== 'End') return;\n if (isTab) {\n setIsTab(true);\n setTimeout(setIsTab, 100, false); // Reset after event loop so we can check if next focus event is a result of tabbing\n }\n\n const target = getComposedTarget(e) as Element | null;\n if (!target || isConflict(target)) return; // See https://open-ui.org/components/scoped-focusgroup.explainer/#key-conflict-elements\n\n let group = getGroup(getComposedPath(target));\n\n if (group?.role && group?.el === target)\n group = getGroup(getComposedPath(group.el.parentNode)); // If focus is on the group itself, check if it is nested inside another group\n if (!group?.role) return; // Ignore invalid parent groups\n\n const items = getItems(group.el, target); // Include target so we can move from tabindex=\"-1\" as according to spec\n let next = 0;\n\n if (isTab) {\n const others = items.filter((item) => item !== target); // Keep target tabbable, as Firefox restarts sequential navigation from document start if a mouse-focused element becomes tabindex=\"-1\"\n return setTimeout(setTab, 0, others, setTab(others)); // Make sure next tab stop is outside focusgroup\n }\n if (e.key === 'Home') next = 0;\n else if (e.key === 'End') next = items.length - 1;\n else {\n const { direction: dir, writingMode: mode } = getComputedStyle(target);\n const isFlipped = mode.startsWith('vertical');\n const isReverse = isFlipped ? mode === 'vertical-rl' : dir === 'rtl';\n const isForward = e.key === 'ArrowDown' || e.key === 'ArrowRight';\n\n const moveBlock = isBlock !== isFlipped;\n const moveForward = isForward !== (!isBlock && isReverse);\n\n if ((group.block ?? moveBlock) !== moveBlock) return; // Ignore if group direction does not match move direction\n next = items.indexOf(target) + (moveForward ? 1 : -1);\n\n if (group.wrap) next = (items.length + next) % items.length;\n else next = Math.max(0, Math.min(next, items.length - 1));\n }\n\n // Note: preventDefault() prevents native <input type=\"radio\"> elements from changing checked state with arrow keys.\n // Although this differs from native behavior, it matches focusgroup=\"radiogroup\" for <button role=\"radio\">.\n // toggle-group.ts already normalizes this for both <input type=\"radio\"> and <button role=\"radio\">,\n // meaning the following preventDefault() introduces no inconsistencies:\n if (items[next] !== target) e.preventDefault(); // Prevent scrolling if changing item\n (items[next] as HTMLElement)?.focus?.();\n};\n\nconst handleFocus = (e: Event & Partial<FocusEvent>) => {\n const target = getComposedTarget(e);\n const path = getComposedPath(target);\n\n for (const [el, off] of ROOTS) if (!path.has(el) && ROOTS.delete(el)) off(); // Remove focus listener on previous roots\n for (const el of path)\n if (el.nodeType === 11 && !ROOTS.has(el))\n ROOTS.set(el, on(el, 'focus', handleFocus, QUICK_EVENT)); // Listener will instantly dispatch since we are binding during triggering\n\n if ((e.target as Element)?.shadowRoot) return; // Avoid double handling by only processing focus events that are not already handled in a shadowRoot\n\n const group = getGroup(path);\n if (!group?.role) return;\n if (IS_TAB && !isConflict(group.focus)) {\n const segment = getSegment(getItems(group.el, null), target); // See https://open-ui.org/components/scoped-focusgroup.explainer/#focusgroup-segments\n const start =\n (group.memory && segment.includes(group.focus) && group.focus) ||\n segment.find((el) => el?.hasAttribute(ATTR_START)) ||\n segment[0];\n if (start !== target) return (start as HTMLElement)?.focus?.(); // Fix focus position if tabbing into segment\n }\n group.focus = target; // Always store focus\n};\n\nexport const getGroup = (path: Set<Node>) => {\n for (const el of path as Set<Element>) {\n if (el.nodeType !== Node.ELEMENT_NODE) continue;\n\n const key = el.getAttribute(ATTR_GROUP);\n if (key !== null) {\n let group = GROUPS.get(el);\n if (group?.key === key) return group; // Return cache if attribute is unchanged\n\n group = parseGroup(el, key);\n GROUPS.set(el, group);\n for (const item of getItems(el))\n if (item && !item.hasAttribute('role')) attr(item, 'role', group.items);\n if (!el.hasAttribute('role')) attr(el, 'role', group.role);\n return group;\n }\n if (isTopLayer(el)) return;\n }\n};\n\nconst parseGroup = (el: Element, key: string) => {\n const opts = new Set(key.toLowerCase().split(' '));\n const role = [...opts].find((t) => t in ROLES) as keyof typeof ROLES;\n const base = ROLES[role];\n const x = opts.has('inline');\n const y = opts.has('block');\n\n return {\n key,\n el,\n role,\n block: x && y ? null : y || (x ? false : base?.block),\n focus: null as Element | null,\n items: base?.items,\n memory: !opts.has('nomemory'),\n wrap: opts.has('wrap') || (opts.has('nowrap') ? false : base?.wrap),\n };\n};\n\nexport const getItems = (\n root?: Element | null,\n keep?: Element | null, // Provide Element to include, or null to keep segments (https://open-ui.org/components/scoped-focusgroup.explainer/#focusgroup-segments)\n items: (Element | null)[] = [], // Used only for recursion\n isNested = false, // Used only for recursion, to check if already inside a nested group\n) => {\n const children =\n root?.nodeName === 'SLOT'\n ? (root as HTMLSlotElement).assignedElements({ flatten: true })\n : (root?.shadowRoot || root)?.children;\n\n for (let i = 0, l = children?.length || i; children && i < l; i++) {\n const el = children[i] as HTMLElement;\n if (el.nodeName === 'SLOT') getItems(el, keep, items, isNested);\n else if (isKeyboardReachable(el) && !isTopLayer(el) && isVisible(el)) {\n const group = el.getAttribute(ATTR_GROUP);\n if (el === keep || (!isNested && group !== 'none' && isFocusable(el)))\n items.push(el);\n else if (group !== null && keep === null) items.push(null);\n else getItems(el, keep, items, isNested || group !== null);\n }\n }\n return items;\n};\n\n// Treats the null returned from getItems as a separator and returns segment containing \"item\"\nconst getSegment = <T>(acc: (T | null)[], item: T) => {\n const at = acc.indexOf(item);\n const to = acc.indexOf(null, at);\n return acc.slice(acc.lastIndexOf(null, at) + 1, to === -1 ? undefined : to);\n};\n\nconst isKeyboardReachable = (el: HTMLElement) =>\n !el.inert && !el.hidden && !(el as HTMLInputElement).disabled;\n\nconst isTopLayer = (el: Element | null) =>\n el?.nodeName === 'DIALOG' || el?.hasAttribute('popover'); // See https://open-ui.org/components/scoped-focusgroup.explainer/#top-layer-elements)\n\nconst isVisible =\n isBrowser() && typeof Element.prototype.checkVisibility === 'function'\n ? (el: HTMLElement) => el.checkVisibility()\n : (el: HTMLElement) => el.offsetParent !== null;\n\nexport const isFocusable = (el: HTMLElement) =>\n el.isContentEditable ||\n (el.tabIndex >= 0 && !(el as HTMLInputElement).disabled);\n\nexport const isConflict = (el: Node | null) =>\n (el as HTMLElement)?.isContentEditable ||\n IS_CONFLICT.has(el?.nodeName as string) ||\n (el?.nodeName === 'INPUT' && IS_CONFLICT.has((el as HTMLInputElement).type));\n\nconst setTab = (items: ReturnType<typeof getItems>, prevs?: string[]) =>\n Array.from(items, (item, index) => {\n const prev = item?.getAttribute('tabindex');\n if (item) attr(item, 'tabindex', prevs ? prevs[index] : '-1'); // Restore previous tabindex if provided\n return prev;\n });\n\nif (!IS_SUPPORTED)\n onHotReload(ATTR_GROUP, () => [\n on(document, 'keydown', handleKeydown),\n on(document, 'focus', handleFocus, QUICK_EVENT),\n () => {\n for (const [, off] of ROOTS) off(); // Cleanup listeners on ShadowRoots on hot reload\n ROOTS.clear();\n },\n ]);\n"],"mappings":"sCAcM,EAAa,aAEb,EAAa,GAAG,EAAW,OAC3B,EAAS,IAAI,QACb,EAAQ,IAAI,IACZ,EAAQ,CACZ,QAAS,CAAE,MAAO,GAAM,KAAM,GAAO,MAAO,QAAS,EACrD,KAAM,CAAE,MAAO,GAAM,KAAM,GAAM,MAAO,UAAW,EACnD,QAAS,CAAE,MAAO,GAAO,KAAM,GAAM,MAAO,UAAW,EACvD,WAAY,CAAE,MAAO,KAAM,KAAM,GAAM,MAAO,OAAQ,EACtD,QAAS,CAAE,MAAO,GAAO,KAAM,GAAM,MAAO,KAAM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AAU,QAAS,EAAaC,EAAAA,WAAW,MACxC,CACJ,IAAK,GAAM,EAAG,KAAQ,EAAO,EAAI,EACjC,EAAM,MAAM,CACd,CACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"version",{enumerable:!0,get:function(){return`1.
|
|
1
|
+
Object.defineProperty(exports,"version",{enumerable:!0,get:function(){return`1.21.1`}});
|
|
2
2
|
//# sourceMappingURL=package.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
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&&`showPopover`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(e=>CSS.escape(e)).join(`.`);return`
|
|
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||t;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&&`showPopover`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(e=>CSS.escape(e)).join(`.`);return`
|
|
2
2
|
${t?`@layer ${n} {`:``}
|
|
3
3
|
:where([popover]) {
|
|
4
4
|
position: fixed;
|