@digdir/designsystemet-web 1.16.0 → 1.16.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/dist/cjs/_vendors/@oddbird/popover-polyfill/dist/popover-fn.cjs.map +1 -1
- package/dist/cjs/_vendors/invokers-polyfill/invoker.cjs.map +1 -1
- package/dist/cjs/breadcrumbs/breadcrumbs.cjs +1 -1
- package/dist/cjs/clickdelegatefor/clickdelegatefor.cjs +1 -1
- package/dist/cjs/clickdelegatefor/clickdelegatefor.cjs.map +1 -1
- package/dist/cjs/details/details.cjs +1 -1
- package/dist/cjs/dialog/dialog.cjs +1 -1
- package/dist/cjs/dialog/dialog.cjs.map +1 -1
- package/dist/cjs/error-summary/error-summary.cjs +1 -1
- package/dist/cjs/error-summary/error-summary.cjs.map +1 -1
- package/dist/cjs/field/field.cjs +1 -1
- package/dist/cjs/field/field.cjs.map +1 -1
- package/dist/cjs/fieldset/fieldset.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/invokers/invokers.cjs +1 -1
- package/dist/cjs/pagination/pagination.cjs +1 -1
- package/dist/cjs/pagination/pagination.cjs.map +1 -1
- package/dist/cjs/popover/popover.cjs +1 -1
- package/dist/cjs/popover/popover.cjs.map +1 -1
- package/dist/cjs/readonly/readonly.cjs +1 -1
- package/dist/cjs/readonly/readonly.cjs.map +1 -1
- package/dist/cjs/suggestion/suggestion.cjs +1 -1
- package/dist/cjs/suggestion/suggestion.cjs.map +1 -1
- package/dist/cjs/tabs/tabs.cjs +1 -1
- package/dist/cjs/toggle-group/toggle-group.cjs +1 -1
- package/dist/cjs/toggle-group/toggle-group.cjs.map +1 -1
- package/dist/cjs/tooltip/tooltip.cjs +1 -1
- package/dist/cjs/utils/utils.cjs.map +1 -1
- package/dist/custom-elements.json +2 -2
- package/dist/esm/_vendors/@oddbird/popover-polyfill/dist/popover-fn.js.map +1 -1
- package/dist/esm/_vendors/invokers-polyfill/invoker.js.map +1 -1
- package/dist/esm/clickdelegatefor/clickdelegatefor.js.map +1 -1
- package/dist/esm/dialog/dialog.js.map +1 -1
- package/dist/esm/error-summary/error-summary.js.map +1 -1
- package/dist/esm/field/field.js.map +1 -1
- package/dist/esm/pagination/pagination.js.map +1 -1
- package/dist/esm/popover/popover.js.map +1 -1
- package/dist/esm/readonly/readonly.js.map +1 -1
- package/dist/esm/toggle-group/toggle-group.js.map +1 -1
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(
|
|
1
|
+
const e=require("../utils/utils.cjs"),t=t=>(t instanceof HTMLSelectElement||t instanceof HTMLInputElement)&&(t.hasAttribute(`readonly`)||e.attr(t,`aria-readonly`)===`true`),n=n=>{if(n.key!==`Tab`&&t(n.target)){let t=n.key?.startsWith(`Arrow`),r=n.altKey||n.ctrlKey||n.metaKey;if((t||!r)&&n.preventDefault(),t&&e.attr(n.target,`type`)===`radio`){let e=document.querySelectorAll(`input[name="${n.target.name}"]`),t=n.key?.match(/Arrow(Right|Down)/)?1:-1;e[(e.length+[...e].indexOf(n.target)+t)%e.length]?.focus()}}},r=e=>{let n=e.target?.closest?.(`label`)?.control||e.target;t(n)&&(e.preventDefault(),n.focus())},i=e=>{e.target instanceof HTMLSelectElement&&t(e.target)&&e.preventDefault()};e.onHotReload(`readonly`,()=>[e.on(document,`keydown`,n),e.on(document,`click`,r),e.on(document,`mousedown`,i)]);
|
|
2
2
|
//# sourceMappingURL=readonly.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readonly.cjs","names":["attr","onHotReload","on"],"sources":["../../../src/readonly/readonly.ts"],"sourcesContent":["import { attr, on, onHotReload } from '../utils/utils';\n\nconst isReadOnly = (el: unknown): el is HTMLInputElement | HTMLSelectElement =>\n (el instanceof HTMLSelectElement || el instanceof HTMLInputElement) &&\n (el.hasAttribute('readonly') || attr(el, 'aria-readonly') === 'true');\n\n// Allow tabbing when readonly, and only fix readonly input/select elements (since type select and non-text-inputs do not support readonly)\n// If radio buttons, move focus without changing checked state\nconst handleKeyDown = (e: Event & Partial<KeyboardEvent>) => {\n if (e.key !== 'Tab' && isReadOnly(e.target)) {\n const isArrow = e.key?.startsWith('Arrow'); // Always control arrow keys\n const isModifier = e.altKey || e.ctrlKey || e.metaKey; // Allow modifier keys so native functions like CMD + D to bookmark etc. still works\n\n if (isArrow || !isModifier) e.preventDefault(); // Prevent changing <select> value with keyboard, but allow non-arrow modifier keys\n if (isArrow && attr(e.target, 'type') === 'radio') {\n const all = document.querySelectorAll(`input[name=\"${e.target.name}\"]`);\n const move = e.key?.match(/Arrow(Right|Down)/) ? 1 : -1;\n const next = all.length + [...all].indexOf(e.target) + move;\n (all[next % all.length] as HTMLElement)?.focus();\n }\n }\n};\n\nconst handleClick = (e: Event) => {\n const input = (e.target as Element)?.closest?.('label')?.control || e.target;\n if (isReadOnly(input)) {\n e.preventDefault();\n input.focus();\n }\n};\n\nconst handleMouseDown = (e: Event) => {\n if (e.target instanceof HTMLSelectElement && isReadOnly(e.target))\n e.preventDefault();\n};\n\nonHotReload('readonly', () => [\n on(document, 'keydown', handleKeyDown),\n on(document, 'click', handleClick), // click needed for <label> and <input>\n on(document, 'mousedown', handleMouseDown), // mousedown needed for <select>\n]);\n"],"mappings":"sCAEM,EAAc,IACjB,aAAc,mBAAqB,aAAc,oBACjD,EAAG,aAAa,UAAU,GAAKA,EAAAA,KAAK,EAAI,eAAe,IAAM,QAI1D,EAAiB,GAAsC,CAC3D,GAAI,EAAE,MAAQ,OAAS,EAAW,EAAE,MAAM,EAAG,CAC3C,IAAM,EAAU,EAAE,KAAK,WAAW,OAAO,EACnC,EAAa,EAAE,QAAU,EAAE,SAAW,EAAE,QAG9C,IADI,GAAW,CAAC,IAAY,EAAE,eAAe,EACzC,GAAWA,EAAAA,KAAK,EAAE,OAAQ,MAAM,IAAM,QAAS,CACjD,IAAM,EAAM,SAAS,iBAAiB,eAAe,EAAE,OAAO,KAAK,GAAG,EAChE,EAAO,EAAE,KAAK,MAAM,mBAAmB,EAAI,EAAI,GAErD,GADa,EAAI,OAAS,CAAC,GAAG,CAAG,
|
|
1
|
+
{"version":3,"file":"readonly.cjs","names":["attr","onHotReload","on"],"sources":["../../../src/readonly/readonly.ts"],"sourcesContent":["import { attr, on, onHotReload } from '../utils/utils';\n\nconst isReadOnly = (el: unknown): el is HTMLInputElement | HTMLSelectElement =>\n (el instanceof HTMLSelectElement || el instanceof HTMLInputElement) &&\n (el.hasAttribute('readonly') || attr(el, 'aria-readonly') === 'true');\n\n// Allow tabbing when readonly, and only fix readonly input/select elements (since type select and non-text-inputs do not support readonly)\n// If radio buttons, move focus without changing checked state\nconst handleKeyDown = (e: Event & Partial<KeyboardEvent>) => {\n if (e.key !== 'Tab' && isReadOnly(e.target)) {\n const isArrow = e.key?.startsWith('Arrow'); // Always control arrow keys\n const isModifier = e.altKey || e.ctrlKey || e.metaKey; // Allow modifier keys so native functions like CMD + D to bookmark etc. still works\n\n if (isArrow || !isModifier) e.preventDefault(); // Prevent changing <select> value with keyboard, but allow non-arrow modifier keys\n if (isArrow && attr(e.target, 'type') === 'radio') {\n const all = document.querySelectorAll(`input[name=\"${e.target.name}\"]`);\n const move = e.key?.match(/Arrow(Right|Down)/) ? 1 : -1;\n const next = all.length + [...all].indexOf(e.target) + move;\n (all[next % all.length] as HTMLElement)?.focus();\n }\n }\n};\n\nconst handleClick = (e: Event) => {\n const input = (e.target as Element)?.closest?.('label')?.control || e.target;\n if (isReadOnly(input)) {\n e.preventDefault();\n input.focus();\n }\n};\n\nconst handleMouseDown = (e: Event) => {\n if (e.target instanceof HTMLSelectElement && isReadOnly(e.target))\n e.preventDefault();\n};\n\nonHotReload('readonly', () => [\n on(document, 'keydown', handleKeyDown),\n on(document, 'click', handleClick), // click needed for <label> and <input>\n on(document, 'mousedown', handleMouseDown), // mousedown needed for <select>\n]);\n"],"mappings":"sCAEM,EAAc,IACjB,aAAc,mBAAqB,aAAc,oBACjD,EAAG,aAAa,UAAU,GAAKA,EAAAA,KAAK,EAAI,eAAe,IAAM,QAI1D,EAAiB,GAAsC,CAC3D,GAAI,EAAE,MAAQ,OAAS,EAAW,EAAE,MAAM,EAAG,CAC3C,IAAM,EAAU,EAAE,KAAK,WAAW,OAAO,EACnC,EAAa,EAAE,QAAU,EAAE,SAAW,EAAE,QAG9C,IADI,GAAW,CAAC,IAAY,EAAE,eAAe,EACzC,GAAWA,EAAAA,KAAK,EAAE,OAAQ,MAAM,IAAM,QAAS,CACjD,IAAM,EAAM,SAAS,iBAAiB,eAAe,EAAE,OAAO,KAAK,GAAG,EAChE,EAAO,EAAE,KAAK,MAAM,mBAAmB,EAAI,EAAI,GAErD,GADa,EAAI,OAAS,CAAC,GAAG,CAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAI,GAC3C,EAAI,OAAO,EAAkB,MAAM,CACjD,CACF,CACF,EAEM,EAAe,GAAa,CAChC,IAAM,EAAS,EAAE,QAAoB,UAAU,OAAO,CAAC,EAAE,SAAW,EAAE,OAClE,EAAW,CAAK,IAClB,EAAE,eAAe,EACjB,EAAM,MAAM,EAEhB,EAEM,EAAmB,GAAa,CAChC,EAAE,kBAAkB,mBAAqB,EAAW,EAAE,MAAM,GAC9D,EAAE,eAAe,CACrB,EAEAC,EAAAA,YAAY,eAAkB,CAC5BC,EAAAA,GAAG,SAAU,UAAW,CAAa,EACrCA,EAAAA,GAAG,SAAU,QAAS,CAAW,EACjCA,EAAAA,GAAG,SAAU,YAAa,CAAe,CAC3C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../utils/utils.cjs");let t=require("@u-elements/u-combobox");var n=class extends t.UHTMLComboboxElement{_unmutate;connectedCallback(){super.connectedCallback(),this._unmutate=e.onMutation(this,r,{childList:!0}),e.on(this,`toggle`,i,e.QUICK_EVENT)}disconnectedCallback(){super.disconnectedCallback(),this._unmutate?.(),this._unmutate=void 0,e.off(this,`toggle`,i,e.QUICK_EVENT)}};const r=t=>{let{control:n,list:r}=t,i=r||t.querySelector(`u-datalist`);n&&!n.placeholder&&e.attr(n,`placeholder`,` `),n&&e.attr(n,`popovertarget`,e.useId(r)||null),i&&e.attr(i,`popover`,`manual`),i&&e.attr(i,`data-is-floating`,`true`)},i=e=>{let t=e.currentTarget,n=e.newState===`open`&&t.control;n&&t.list?.dispatchEvent(new CustomEvent(`ds-toggle-source`,{detail:n}))};e.customElements.define(`ds-suggestion`,n),exports.DSSuggestionElement=n;
|
|
2
2
|
//# sourceMappingURL=suggestion.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion.cjs","names":["UHTMLComboboxElement","onMutation","QUICK_EVENT","useId","customElements"],"sources":["../../../src/suggestion/suggestion.ts"],"sourcesContent":["import { UHTMLComboboxElement } from '@u-elements/u-combobox';\nimport {\n attr,\n customElements,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-suggestion': DSSuggestionElement;\n }\n}\n\nexport class DSSuggestionElement extends UHTMLComboboxElement {\n _unmutate?: ReturnType<typeof onMutation>; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n super.connectedCallback();\n this._unmutate = onMutation(this, render, { childList: true }); // .control and .list are direct children of the custom element\n on(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this._unmutate?.();\n this._unmutate = undefined;\n off(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n}\n\n// A non-empty placeholder attribute is required to activate the :placeholder-shown pseudo selector used in our chevron styling\nconst render = (self: DSSuggestionElement) => {\n const { control, list } = self;\n const datalist = list || self.querySelector('u-datalist'); // Fallback to u-datalist since React can render the ds-suggestion before u-datalist is connected\n\n if (control && !control.placeholder) attr(control, 'placeholder', ' '); // .control comes from UHTMLComboboxElement\n if (control) attr(control, 'popovertarget', useId(list) || null);\n if (datalist) attr(datalist, 'popover', 'manual'); // Ensure popover attribute is set on the list\n if (datalist) attr(datalist, 'data-is-floating', 'true'); // identifier for css to toggle opacity when it is placed by floating-ui.\n};\n\n// Since showPopover({ source }) is not supported in all browsers yet:\nconst polyfillToggleSource = (event: Partial<ToggleEvent>) => {\n const self = event.currentTarget as DSSuggestionElement;\n const detail = event.newState === 'open' && self.control; // .control comes from UHTMLComboboxElement\n\n if (detail)\n self.list?.dispatchEvent(new CustomEvent('ds-toggle-source', { detail }));\n};\n\n// Ensure u-datalist is defined before ds-suggestion\ncustomElements.define('ds-suggestion', DSSuggestionElement);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"suggestion.cjs","names":["UHTMLComboboxElement","onMutation","QUICK_EVENT","useId","customElements"],"sources":["../../../src/suggestion/suggestion.ts"],"sourcesContent":["import { UHTMLComboboxElement } from '@u-elements/u-combobox';\nimport {\n attr,\n customElements,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-suggestion': DSSuggestionElement;\n }\n}\n\nexport class DSSuggestionElement extends UHTMLComboboxElement {\n _unmutate?: ReturnType<typeof onMutation>; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n super.connectedCallback();\n this._unmutate = onMutation(this, render, { childList: true }); // .control and .list are direct children of the custom element\n on(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this._unmutate?.();\n this._unmutate = undefined;\n off(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\n }\n}\n\n// A non-empty placeholder attribute is required to activate the :placeholder-shown pseudo selector used in our chevron styling\nconst render = (self: DSSuggestionElement) => {\n const { control, list } = self;\n const datalist = list || self.querySelector('u-datalist'); // Fallback to u-datalist since React can render the ds-suggestion before u-datalist is connected\n\n if (control && !control.placeholder) attr(control, 'placeholder', ' '); // .control comes from UHTMLComboboxElement\n if (control) attr(control, 'popovertarget', useId(list) || null);\n if (datalist) attr(datalist, 'popover', 'manual'); // Ensure popover attribute is set on the list\n if (datalist) attr(datalist, 'data-is-floating', 'true'); // identifier for css to toggle opacity when it is placed by floating-ui.\n};\n\n// Since showPopover({ source }) is not supported in all browsers yet:\nconst polyfillToggleSource = (event: Partial<ToggleEvent>) => {\n const self = event.currentTarget as DSSuggestionElement;\n const detail = event.newState === 'open' && self.control; // .control comes from UHTMLComboboxElement\n\n if (detail)\n self.list?.dispatchEvent(new CustomEvent('ds-toggle-source', { detail }));\n};\n\n// Ensure u-datalist is defined before ds-suggestion\ncustomElements.define('ds-suggestion', DSSuggestionElement);\n"],"mappings":"8EAiBA,IAAa,EAAb,cAAyCA,EAAAA,oBAAqB,CAC5D,UAEA,mBAAoB,CAClB,MAAM,kBAAkB,EACxB,KAAK,UAAYC,EAAAA,WAAW,KAAM,EAAQ,CAAE,UAAW,EAAK,CAAC,EAC7D,EAAA,GAAG,KAAM,SAAU,EAAsBC,EAAAA,WAAW,CACtD,CACA,sBAAuB,CACrB,MAAM,qBAAqB,EAC3B,KAAK,YAAY,EACjB,KAAK,UAAY,IAAA,GACjB,EAAA,IAAI,KAAM,SAAU,EAAsBA,EAAAA,WAAW,CACvD,CACF,EAGA,MAAM,EAAU,GAA8B,CAC5C,GAAM,CAAE,UAAS,QAAS,EACpB,EAAW,GAAQ,EAAK,cAAc,YAAY,EAEpD,GAAW,CAAC,EAAQ,aAAa,EAAA,KAAK,EAAS,cAAe,GAAG,EACjE,GAAS,EAAA,KAAK,EAAS,gBAAiBC,EAAAA,MAAM,CAAI,GAAK,IAAI,EAC3D,GAAU,EAAA,KAAK,EAAU,UAAW,QAAQ,EAC5C,GAAU,EAAA,KAAK,EAAU,mBAAoB,MAAM,CACzD,EAGM,EAAwB,GAAgC,CAC5D,IAAM,EAAO,EAAM,cACb,EAAS,EAAM,WAAa,QAAU,EAAK,QAE7C,GACF,EAAK,MAAM,cAAc,IAAI,YAAY,mBAAoB,CAAE,QAAO,CAAC,CAAC,CAC5E,EAGAC,EAAAA,eAAe,OAAO,gBAAiB,CAAmB"}
|
package/dist/cjs/tabs/tabs.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../utils/utils.cjs");let n=require("@u-elements/u-tabs");n=e.__toESM(n,1);var r=class extends n.UHTMLTabsElement{},i=class extends n.UHTMLTabListElement{},a=class extends n.UHTMLTabElement{},o=class extends n.UHTMLTabPanelElement{};t.customElements.define(`ds-tabs`,r),t.customElements.define(`ds-tablist`,i),t.customElements.define(`ds-tab`,a),t.customElements.define(`ds-tabpanel`,o),exports.DSTabElement=a,exports.DSTabListElement=i,exports.DSTabPanelElement=o,exports.DSTabsElement=r;
|
|
2
2
|
//# sourceMappingURL=tabs.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(
|
|
1
|
+
const e=require("../utils/utils.cjs"),t=`aria-label`,n=`data-toggle-group`,r=`[${n}]`,i=()=>{for(let t of document.querySelectorAll(r))e.attr(t,`aria-label`,e.attrOrCSS(t,n))},a=i=>{let{key:a,target:o}=i,s=o instanceof HTMLInputElement&&o.closest(r);if(s&&(!e.attr(s,t)&&!e.attr(s,`aria-labelledby`)&&e.attr(s,t,e.attrOrCSS(s,n)),a===`Enter`&&o.click(),a?.startsWith(`Arrow`))){i.preventDefault?.();let e=[...s.getElementsByTagName(`input`)],t=e.indexOf(o),n=a.match(/Arrow(Right|Down)/)?1:-1,r=t;for(let t=0;t<e.length;t++)if(r=(e.length+r+n)%e.length,!e[r]?.disabled){e[r]?.focus();break}}};e.onHotReload(`toggle-group`,()=>[e.on(document,`keydown`,a),e.onMutation(document,i,{attributeFilter:[n],attributes:!0,childList:!0,subtree:!0})]);
|
|
2
2
|
//# sourceMappingURL=toggle-group.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.cjs","names":["attrOrCSS","attr","onHotReload","on","onMutation"],"sources":["../../../src/toggle-group/toggle-group.ts"],"sourcesContent":["import { attr, attrOrCSS, on, onHotReload, onMutation } from '../utils/utils';\n\nconst ARIA_LABELLEDBY = 'aria-labelledby';\nconst ARIA_LABEL = 'aria-label';\nconst ATTR_TOGGLEGROUP = 'data-toggle-group';\nconst SELECTOR_TOGGLEGROUP = `[${ATTR_TOGGLEGROUP}]`;\n\nconst handleAriaAttributes = () => {\n for (const group of document.querySelectorAll(SELECTOR_TOGGLEGROUP))\n attr(group, 'aria-label', attrOrCSS(group, ATTR_TOGGLEGROUP));\n};\n\nconst handleKeydown = (event: Partial<KeyboardEvent>) => {\n const { key, target: el } = event;\n const group =\n el instanceof HTMLInputElement && el.closest(SELECTOR_TOGGLEGROUP);\n\n if (!group) return;\n if (!attr(group, ARIA_LABEL) && !attr(group, ARIA_LABELLEDBY))\n attr(group, ARIA_LABEL, attrOrCSS(group, ATTR_TOGGLEGROUP));\n if (key === 'Enter') el.click(); // Forward Enter, but no need to listen for space key, as this is handled by the browser\n if (key?.startsWith('Arrow')) {\n event.preventDefault?.();\n const inputs = [...group.getElementsByTagName('input')];\n const index = inputs.indexOf(el);\n const move = key.match(/Arrow(Right|Down)/) ? 1 : -1;\n let nextIndex = index;\n\n for (let i = 0; i < inputs.length; i++) {\n nextIndex = (inputs.length + nextIndex + move) % inputs.length;\n if (!inputs[nextIndex]?.disabled) {\n inputs[nextIndex]?.focus();\n break;\n }\n }\n }\n};\n\nonHotReload('toggle-group', () => [\n on(document, 'keydown', handleKeydown),\n onMutation(document, handleAriaAttributes, {\n attributeFilter: [ATTR_TOGGLEGROUP],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"sCAGM,EAAa,aACb,EAAmB,oBACnB,EAAuB,IAAI,EAAiB,GAE5C,MAA6B,CACjC,IAAK,IAAM,KAAS,SAAS,iBAAiB,CAAoB,EAChE,EAAA,KAAK,EAAO,aAAcA,EAAAA,UAAU,EAAO,CAAgB,CAAC,CAChE,EAEM,EAAiB,GAAkC,CACvD,GAAM,CAAE,MAAK,OAAQ,GAAO,EACtB,EACJ,aAAc,kBAAoB,EAAG,QAAQ,CAAoB,EAE9D,OACD,CAACC,EAAAA,KAAK,EAAO,CAAU,GAAK,CAACA,EAAAA,KAAK,EAAO,iBAAe,GAC1D,EAAA,KAAK,EAAO,EAAYD,EAAAA,UAAU,EAAO,CAAgB,CAAC,EACxD,IAAQ,SAAS,EAAG,MAAM,EAC1B,GAAK,WAAW,OAAO,GAAG,CAC5B,EAAM,iBAAiB,EACvB,IAAM,EAAS,CAAC,GAAG,EAAM,qBAAqB,OAAO,CAAC,EAChD,EAAQ,EAAO,QAAQ,CAAE,EACzB,EAAO,EAAI,MAAM,mBAAmB,EAAI,EAAI,GAC9C,EAAY,EAEhB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IAEjC,GADA,GAAa,EAAO,OAAS,EAAY,GAAQ,EAAO,OACpD,CAAC,EAAO,
|
|
1
|
+
{"version":3,"file":"toggle-group.cjs","names":["attrOrCSS","attr","onHotReload","on","onMutation"],"sources":["../../../src/toggle-group/toggle-group.ts"],"sourcesContent":["import { attr, attrOrCSS, on, onHotReload, onMutation } from '../utils/utils';\n\nconst ARIA_LABELLEDBY = 'aria-labelledby';\nconst ARIA_LABEL = 'aria-label';\nconst ATTR_TOGGLEGROUP = 'data-toggle-group';\nconst SELECTOR_TOGGLEGROUP = `[${ATTR_TOGGLEGROUP}]`;\n\nconst handleAriaAttributes = () => {\n for (const group of document.querySelectorAll(SELECTOR_TOGGLEGROUP))\n attr(group, 'aria-label', attrOrCSS(group, ATTR_TOGGLEGROUP));\n};\n\nconst handleKeydown = (event: Partial<KeyboardEvent>) => {\n const { key, target: el } = event;\n const group =\n el instanceof HTMLInputElement && el.closest(SELECTOR_TOGGLEGROUP);\n\n if (!group) return;\n if (!attr(group, ARIA_LABEL) && !attr(group, ARIA_LABELLEDBY))\n attr(group, ARIA_LABEL, attrOrCSS(group, ATTR_TOGGLEGROUP));\n if (key === 'Enter') el.click(); // Forward Enter, but no need to listen for space key, as this is handled by the browser\n if (key?.startsWith('Arrow')) {\n event.preventDefault?.();\n const inputs = [...group.getElementsByTagName('input')];\n const index = inputs.indexOf(el);\n const move = key.match(/Arrow(Right|Down)/) ? 1 : -1;\n let nextIndex = index;\n\n for (let i = 0; i < inputs.length; i++) {\n nextIndex = (inputs.length + nextIndex + move) % inputs.length;\n if (!inputs[nextIndex]?.disabled) {\n inputs[nextIndex]?.focus();\n break;\n }\n }\n }\n};\n\nonHotReload('toggle-group', () => [\n on(document, 'keydown', handleKeydown),\n onMutation(document, handleAriaAttributes, {\n attributeFilter: [ATTR_TOGGLEGROUP],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"sCAGM,EAAa,aACb,EAAmB,oBACnB,EAAuB,IAAI,EAAiB,GAE5C,MAA6B,CACjC,IAAK,IAAM,KAAS,SAAS,iBAAiB,CAAoB,EAChE,EAAA,KAAK,EAAO,aAAcA,EAAAA,UAAU,EAAO,CAAgB,CAAC,CAChE,EAEM,EAAiB,GAAkC,CACvD,GAAM,CAAE,MAAK,OAAQ,GAAO,EACtB,EACJ,aAAc,kBAAoB,EAAG,QAAQ,CAAoB,EAE9D,OACD,CAACC,EAAAA,KAAK,EAAO,CAAU,GAAK,CAACA,EAAAA,KAAK,EAAO,iBAAe,GAC1D,EAAA,KAAK,EAAO,EAAYD,EAAAA,UAAU,EAAO,CAAgB,CAAC,EACxD,IAAQ,SAAS,EAAG,MAAM,EAC1B,GAAK,WAAW,OAAO,GAAG,CAC5B,EAAM,iBAAiB,EACvB,IAAM,EAAS,CAAC,GAAG,EAAM,qBAAqB,OAAO,CAAC,EAChD,EAAQ,EAAO,QAAQ,CAAE,EACzB,EAAO,EAAI,MAAM,mBAAmB,EAAI,EAAI,GAC9C,EAAY,EAEhB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IAEjC,GADA,GAAa,EAAO,OAAS,EAAY,GAAQ,EAAO,OACpD,CAAC,EAAO,EAAU,EAAE,SAAU,CAChC,EAAO,EAAU,EAAE,MAAM,EACzB,KACF,CAEJ,CACF,EAEAE,EAAAA,YAAY,mBAAsB,CAChCC,EAAAA,GAAG,SAAU,UAAW,CAAa,EACrCC,EAAAA,WAAW,SAAU,EAAsB,CACzC,gBAAiB,CAAC,CAAgB,EAClC,WAAY,GACZ,UAAW,GACX,QAAS,EACX,CAAC,CACH,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(
|
|
1
|
+
const e=require("../utils/utils.cjs");require("../popover/popover.cjs");let t,n,r=!1,i=0,a=0;const o=e.isBrowser()&&/iPad|iPhone|iPod/.test(navigator.userAgent),s=`data-tooltip`,c=`data-color`,l=`aria-label`,u=`aria-description`,d=`[${c}]`,f=`[${s}]`,p=`data-color-scheme`,m=`[${p}]`,h=o=>{o&&!(o instanceof HTMLElement)&&e.warn(`setTooltipElement expects an HTMLElement, got: `,o),clearTimeout(a),clearTimeout(i),n=void 0,r=!1,t=o||void 0},g=()=>{for(let r of document.querySelectorAll(f)){let i=e.attrOrCSS(r,s);if(!i)return;if(i!==(r.getAttribute(l)||r.getAttribute(u))){let t=e.attr(r,`role`)!==`img`&&r.textContent?.trim();e.attr(r,s,i),e.attr(r,l,t?null:i),e.attr(r,u,t?i:null),r.matches(`a,button,input,label,select,textarea,[tabindex]`)||e.warn(`Missing tabindex="0" attribute on: `,r)}let a=r===n&&t?.offsetHeight&&t?.offsetWidth,o=a&&i&&t?.textContent!==i;a&&o&&(t&&(t.textContent=i),document.activeElement===r&&e.announce(i))}},_=({type:l,target:u})=>{if(clearTimeout(i),u===t)return;if(l===`mouseover`&&!r&&!o){i=setTimeout(_,300,{target:u});return}let f=u?.closest?.(`[${s}]`);if(f===n)return;if(!f)return v();t||=e.tag(`div`,{class:`ds-tooltip`}),t.isConnected||document.body.appendChild(t);let h=f.closest(d),g=f.closest(m),y=h!==g&&h?.contains(g);clearTimeout(a),e.attr(t,`popover`,`manual`),e.attr(t,p,g?.getAttribute(p)||null),e.attr(t,c,y&&h?.getAttribute(c)||null),t.textContent=e.attr(f,s),t.showPopover(),t.dispatchEvent(new CustomEvent(`ds-toggle-source`,{detail:f})),r=!0,n=f},v=()=>t?.isConnected&&t.popover&&t.hidePopover(),y=e=>{if(e?.type===`keydown`)return e?.key===`Escape`&&v();e?e.target===t&&e.newState===`closed`&&(n=void 0,a=setTimeout(y,300)):r=!1};e.onHotReload(`tooltip`,()=>[e.on(document,`blur focus mouseover`,_,e.QUICK_EVENT),e.on(document,`toggle keydown`,y,e.QUICK_EVENT),e.onMutation(document,g,{attributeFilter:[s],attributes:!0,childList:!0,subtree:!0})]),exports.setTooltipElement=h;
|
|
2
2
|
//# sourceMappingURL=tooltip.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/utils/utils.ts"],"sourcesContent":["export const QUICK_EVENT = { passive: true, capture: true };\n\n// Using function instead of constant to support evnironments where DOM can be unloaded (like Vitest with jsdom)\nexport const isBrowser = () =>\n typeof window !== 'undefined' && typeof document !== 'undefined';\n\nexport const isWindows = () =>\n isBrowser() &&\n // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\n /^Win/i.test(navigator.userAgentData?.platform || navigator.platform);\n\n// Make sure we have a HTMLElement to extend (for server side rendering)\nexport const DSElement =\n typeof HTMLElement === 'undefined'\n ? (class {} as typeof HTMLElement)\n : HTMLElement;\n\nexport function debounce<T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n) {\n let timer: ReturnType<typeof setTimeout>;\n\n return function (this: unknown, ...args: T) {\n clearTimeout(timer);\n timer = setTimeout(() => callback.apply(this, args), delay);\n };\n}\n\n/**\n * warn\n * @description Utility to console.log, but can be silenced in production with window.dsWarnings = false;\n */\ndeclare global {\n interface Window {\n dsWarnings?: boolean;\n }\n}\nexport const warn = (\n message: string,\n ...args: Parameters<typeof console.log> // Using console.log, not console.warn, to prevent stopping test runners such as Jest\n) =>\n !isBrowser() ||\n window.dsWarnings === false ||\n console.log(`\\x1B[1mDesignsystemet:\\x1B[m ${message}`, ...args);\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to read/write attributes from\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport const attr = (\n el: Element,\n name: string,\n value?: string | null,\n): string | null => {\n if (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n if (value === null) el.removeAttribute(name);\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n return null;\n};\n\n/**\n * getCSSProp\n * @description Retrieves and CSS property value and trims it\n * @param el The Element to read attributes/CSS from\n * @param name Attribute or CSS property to get\n * @return string CSS property value\n */\nexport const getCSSProp = (el: Element, prop: string) =>\n getComputedStyle(el).getPropertyValue(prop).trim();\n\nconst STRIP_QUOTES = /^[\"']|[\"']$/g; // Matches surrounding single or double quotes\n/**\n * attrOrCSS\n * @description Retrieves and updates attribute based on attribute or CSS property value\n * @param el The Element to read attributes/CSS from\n * @param name Attribute or CSS property to get\n * @return string attribute or CSS property value\n */\nexport const attrOrCSS = (el: Element, name: string) => {\n let value = attr(el, name);\n if (!value)\n value = getCSSProp(el, `--_ds-${name}`).replace(STRIP_QUOTES, '').trim();\n if (!value) warn(`Missing ${name} on:`, el);\n return value || null;\n};\n\n/**\n * on\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n el: Node | Window | ShadowRoot,\n ...rest: Parameters<typeof Element.prototype.addEventListener>\n): (() => void) => {\n const [types, ...options] = rest;\n for (const type of types.split(' ')) el.addEventListener(type, ...options);\n return () => off(el, ...rest);\n};\n\n/**\n * off\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n el: Node | Window | ShadowRoot,\n ...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => {\n const [types, ...options] = rest;\n for (const type of types.split(' ')) el.removeEventListener(type, ...options);\n};\n\n// Used to store cleanup functions for hot-reloading\ndeclare global {\n interface Window {\n _dsHotReloadCleanup?: Map<string, Array<() => void>>;\n }\n}\n\n/**\n * onHotReload\n * @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading\n * @param key The key to identify setup and corresponding cleanup\n * @param callback The callback to run when the page is ready\n */\nexport const onHotReload = (key: string, setup: () => Array<() => void>) => {\n if (!isBrowser()) return; // Skip if not in modern browser environment, but on each call as Vitest might have unloaded jsdom between tests\n if (!window._dsHotReloadCleanup) window._dsHotReloadCleanup = new Map(); // Hot reload cleanup support supporting all build tools\n\n window._dsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup()); // Run previous cleanup\n window._dsHotReloadCleanup?.set(key, setup()); // Store new cleanup\n};\n\n/**\n * MutationObserver wrapper with automatic cleanup\n * @return new MutaionObserver\n */\nexport const onMutation = <T extends Node>(\n el: T,\n callback: (el: T, records?: MutationRecord[]) => void,\n options: MutationObserverInit,\n) => {\n const cleanup = () => observer.disconnect();\n const observer = new MutationObserver((records) => {\n if (!isBrowser() || !el.isConnected) return cleanup(); // Stop observing if element is removed from DOM or document is removed by jdsom tests\n callback(el, records);\n });\n\n callback(el); // Initial is run instantly to make test markup predictable\n observer.observe(el, options);\n return cleanup;\n};\n\n/**\n * tag\n * @description creates element and assigns properties\n * @param tagName The tagname of element to create\n * @param attrs Optional attributes to add to the element\n * @param text Optional text content to add to the element\n * @return HTMLElement with props\n */\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\n tagName: TagName,\n attrs?: Record<string, string | null> | null,\n): HTMLElementTagNameMap[TagName] => {\n const el = document.createElement(tagName);\n if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n return el;\n};\n\n/**\n * customElements.define\n * @description Defines a customElement if running in browser and if not already registered\n * Scoped/named \"customElements.define\" so @custom-elements-manifest/analyzer can find tag names\n */\nexport const customElements = {\n define: (name: string, instance: CustomElementConstructor) =>\n !isBrowser() ||\n window.customElements.get(name) ||\n window.customElements.define(name, instance),\n};\n\n/**\n * useId\n * @return A generated unique ID\n */\ndeclare global {\n interface Window {\n dsUseId?: number; // Use a global counter to ensure this works even when loading designsystemet multiple times\n }\n}\nlet id = 0;\nexport function useId(el?: Element | null) {\n if (!isBrowser()) return `:ds:${++id}`; // Emulate browser environment if window not available\n if (!window.dsUseId) window.dsUseId = 0; // Make sure we have a global to support multiple instances of designsystemet in same page\n if (el && !el.id) el.id = `:ds:${++window.dsUseId}`;\n return el?.id || '';\n}\n\n/**\n * @description Based off speak function from [U-elements](https://github.com/u-elements/u-elements/blob/main/packages/utils.ts#L210)\n * @param text The text to announce\n */\nlet LIVE_EL: HTMLElement | undefined;\nlet LIVE_FIX = 0;\nlet LIVE_CLEAR: ReturnType<typeof setTimeout> | number = 0;\nexport const announce = (text: string) => {\n clearTimeout(LIVE_CLEAR);\n if (LIVE_EL) LIVE_EL.textContent = `${text}${LIVE_FIX++ % 2 ? '\\u00A0' : ''}`; // Non-breaking space to ensure screen reader announces\n if (text) LIVE_CLEAR = setTimeout(announce, 2000, ''); // Clear prevent old announcements being found by screen readers, with 2 seconds brace period to avoid cutting of Android Talkback\n};\n\n// Mount live region on first focus so its ready to be used\nconst announceMount = () => {\n if (document.readyState !== 'complete') return; // Ensure page is loaded trying to avoid issues with React hydration\n if (!LIVE_EL) {\n LIVE_EL = tag('div', { 'aria-live': 'assertive' });\n LIVE_EL.style.overflow = 'hidden'; // Settings styles individually to prevent issues with CSP\n LIVE_EL.style.position = 'fixed';\n LIVE_EL.style.whiteSpace = 'nowrap';\n LIVE_EL.style.width = '1px';\n }\n if (!LIVE_EL.isConnected) document.body.appendChild(LIVE_EL);\n};\nonHotReload('announce', () => [\n on(document, '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SAAS,aAAe,aACvB,IACH,EAAU,EAAI,MAAO,CAAE,YAAa,WAAY,CAAC,EACjD,EAAQ,MAAM,SAAW,SACzB,EAAQ,MAAM,SAAW,QACzB,EAAQ,MAAM,WAAa,SAC3B,EAAQ,MAAM,MAAQ,OAEnB,EAAQ,aAAa,SAAS,KAAK,YAAY,CAAO,EAC7D,EACA,EAAY,eAAkB,CAC5B,EAAG,SAAU,kBAAmB,EAAe,CAAW,CAC5D,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/utils/utils.ts"],"sourcesContent":["export const QUICK_EVENT = { passive: true, capture: true };\n\n// Using function instead of constant to support evnironments where DOM can be unloaded (like Vitest with jsdom)\nexport const isBrowser = () =>\n typeof window !== 'undefined' && typeof document !== 'undefined';\n\nexport const isWindows = () =>\n isBrowser() &&\n // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\n /^Win/i.test(navigator.userAgentData?.platform || navigator.platform);\n\n// Make sure we have a HTMLElement to extend (for server side rendering)\nexport const DSElement =\n typeof HTMLElement === 'undefined'\n ? (class {} as typeof HTMLElement)\n : HTMLElement;\n\nexport function debounce<T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n) {\n let timer: ReturnType<typeof setTimeout>;\n\n return function (this: unknown, ...args: T) {\n clearTimeout(timer);\n timer = setTimeout(() => callback.apply(this, args), delay);\n };\n}\n\n/**\n * warn\n * @description Utility to console.log, but can be silenced in production with window.dsWarnings = false;\n */\ndeclare global {\n interface Window {\n dsWarnings?: boolean;\n }\n}\nexport const warn = (\n message: string,\n ...args: Parameters<typeof console.log> // Using console.log, not console.warn, to prevent stopping test runners such as Jest\n) =>\n !isBrowser() ||\n window.dsWarnings === false ||\n console.log(`\\x1B[1mDesignsystemet:\\x1B[m ${message}`, ...args);\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to read/write attributes from\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport const attr = (\n el: Element,\n name: string,\n value?: string | null,\n): string | null => {\n if (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n if (value === null) el.removeAttribute(name);\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n return null;\n};\n\n/**\n * getCSSProp\n * @description Retrieves and CSS property value and trims it\n * @param el The Element to read attributes/CSS from\n * @param name Attribute or CSS property to get\n * @return string CSS property value\n */\nexport const getCSSProp = (el: Element, prop: string) =>\n getComputedStyle(el).getPropertyValue(prop).trim();\n\nconst STRIP_QUOTES = /^[\"']|[\"']$/g; // Matches surrounding single or double quotes\n/**\n * attrOrCSS\n * @description Retrieves and updates attribute based on attribute or CSS property value\n * @param el The Element to read attributes/CSS from\n * @param name Attribute or CSS property to get\n * @return string attribute or CSS property value\n */\nexport const attrOrCSS = (el: Element, name: string) => {\n let value = attr(el, name);\n if (!value)\n value = getCSSProp(el, `--_ds-${name}`).replace(STRIP_QUOTES, '').trim();\n if (!value) warn(`Missing ${name} on:`, el);\n return value || null;\n};\n\n/**\n * on\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n el: Node | Window | ShadowRoot,\n ...rest: Parameters<typeof Element.prototype.addEventListener>\n): (() => void) => {\n const [types, ...options] = rest;\n for (const type of types.split(' ')) el.addEventListener(type, ...options);\n return () => off(el, ...rest);\n};\n\n/**\n * off\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n el: Node | Window | ShadowRoot,\n ...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => {\n const [types, ...options] = rest;\n for (const type of types.split(' ')) el.removeEventListener(type, ...options);\n};\n\n// Used to store cleanup functions for hot-reloading\ndeclare global {\n interface Window {\n _dsHotReloadCleanup?: Map<string, Array<() => void>>;\n }\n}\n\n/**\n * onHotReload\n * @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading\n * @param key The key to identify setup and corresponding cleanup\n * @param callback The callback to run when the page is ready\n */\nexport const onHotReload = (key: string, setup: () => Array<() => void>) => {\n if (!isBrowser()) return; // Skip if not in modern browser environment, but on each call as Vitest might have unloaded jsdom between tests\n if (!window._dsHotReloadCleanup) window._dsHotReloadCleanup = new Map(); // Hot reload cleanup support supporting all build tools\n\n window._dsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup()); // Run previous cleanup\n window._dsHotReloadCleanup?.set(key, setup()); // Store new cleanup\n};\n\n/**\n * MutationObserver wrapper with automatic cleanup\n * @return new MutaionObserver\n */\nexport const onMutation = <T extends Node>(\n el: T,\n callback: (el: T, records?: MutationRecord[]) => void,\n options: MutationObserverInit,\n) => {\n const cleanup = () => observer.disconnect();\n const observer = new MutationObserver((records) => {\n if (!isBrowser() || !el.isConnected) return cleanup(); // Stop observing if element is removed from DOM or document is removed by jdsom tests\n callback(el, records);\n });\n\n callback(el); // Initial is run instantly to make test markup predictable\n observer.observe(el, options);\n return cleanup;\n};\n\n/**\n * tag\n * @description creates element and assigns properties\n * @param tagName The tagname of element to create\n * @param attrs Optional attributes to add to the element\n * @param text Optional text content to add to the element\n * @return HTMLElement with props\n */\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\n tagName: TagName,\n attrs?: Record<string, string | null> | null,\n): HTMLElementTagNameMap[TagName] => {\n const el = document.createElement(tagName);\n if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n return el;\n};\n\n/**\n * customElements.define\n * @description Defines a customElement if running in browser and if not already registered\n * Scoped/named \"customElements.define\" so @custom-elements-manifest/analyzer can find tag names\n */\nexport const customElements = {\n define: (name: string, instance: CustomElementConstructor) =>\n !isBrowser() ||\n window.customElements.get(name) ||\n window.customElements.define(name, instance),\n};\n\n/**\n * useId\n * @return A generated unique ID\n */\ndeclare global {\n interface Window {\n dsUseId?: number; // Use a global counter to ensure this works even when loading designsystemet multiple times\n }\n}\nlet id = 0;\nexport function useId(el?: Element | null) {\n if (!isBrowser()) return `:ds:${++id}`; // Emulate browser environment if window not available\n if (!window.dsUseId) window.dsUseId = 0; // Make sure we have a global to support multiple instances of designsystemet in same page\n if (el && !el.id) el.id = `:ds:${++window.dsUseId}`;\n return el?.id || '';\n}\n\n/**\n * @description Based off speak function from [U-elements](https://github.com/u-elements/u-elements/blob/main/packages/utils.ts#L210)\n * @param text The text to announce\n */\nlet LIVE_EL: HTMLElement | undefined;\nlet LIVE_FIX = 0;\nlet LIVE_CLEAR: ReturnType<typeof setTimeout> | number = 0;\nexport const announce = (text: string) => {\n clearTimeout(LIVE_CLEAR);\n if (LIVE_EL) LIVE_EL.textContent = `${text}${LIVE_FIX++ % 2 ? '\\u00A0' : ''}`; // Non-breaking space to ensure screen reader announces\n if (text) LIVE_CLEAR = setTimeout(announce, 2000, ''); // Clear prevent old announcements being found by screen readers, with 2 seconds brace period to avoid cutting of Android Talkback\n};\n\n// Mount live region on first focus so its ready to be used\nconst announceMount = () => {\n if (document.readyState !== 'complete') return; // Ensure page is loaded trying to avoid issues with React hydration\n if (!LIVE_EL) {\n LIVE_EL = tag('div', { 'aria-live': 'assertive' });\n LIVE_EL.style.overflow = 'hidden'; // Settings styles individually to prevent issues with CSP\n LIVE_EL.style.position = 'fixed';\n LIVE_EL.style.whiteSpace = 'nowrap';\n LIVE_EL.style.width = '1px';\n }\n if (!LIVE_EL.isConnected) document.body.appendChild(LIVE_EL);\n};\nonHotReload('announce', () => [\n on(document, 'focus mouseover', announceMount, QUICK_EVENT),\n]);\n"],"mappings":"AAAA,MAAa,EAAc,CAAE,QAAS,GAAM,QAAS,EAAK,EAG7C,MACX,OAAO,OAAW,KAAe,OAAO,SAAa,IAE1C,MACX,EAAU,GAEV,QAAQ,KAAK,UAAU,eAAe,UAAY,UAAU,QAAQ,EAGzD,EACX,OAAO,YAAgB,IAClB,KAAM,CAAC,EACR,YAEN,SAAgB,EACd,EACA,EACA,CACA,IAAI,EAEJ,OAAO,SAAyB,GAAG,EA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AC"}
|
|
@@ -141,13 +141,13 @@
|
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
"kind": "javascript-module",
|
|
144
|
-
"path": "src/
|
|
144
|
+
"path": "src/clickdelegatefor/clickdelegatefor.ts",
|
|
145
145
|
"declarations": [],
|
|
146
146
|
"exports": []
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
"kind": "javascript-module",
|
|
150
|
-
"path": "src/
|
|
150
|
+
"path": "src/details/details.ts",
|
|
151
151
|
"declarations": [],
|
|
152
152
|
"exports": []
|
|
153
153
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-fn.js","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@oddbird+popover-polyfill@0.6.1/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js"],"sourcesContent":["// src/events.ts\nvar ToggleEvent = class extends Event {\n oldState;\n newState;\n constructor(type, { oldState = \"\", newState = \"\", ...init } = {}) {\n super(type, init);\n this.oldState = String(oldState || \"\");\n this.newState = String(newState || \"\");\n }\n};\nvar popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();\nfunction queuePopoverToggleEventTask(element, oldState, newState) {\n popoverToggleTaskQueue.set(\n element,\n setTimeout(() => {\n if (!popoverToggleTaskQueue.has(element)) return;\n element.dispatchEvent(\n new ToggleEvent(\"toggle\", {\n cancelable: false,\n oldState,\n newState\n })\n );\n }, 0)\n );\n}\n\n// src/popover-helpers.ts\nvar ShadowRoot = globalThis.ShadowRoot || function() {\n};\nvar HTMLDialogElement = globalThis.HTMLDialogElement || function() {\n};\nvar topLayerElements = /* @__PURE__ */ new WeakMap();\nvar autoPopoverList = /* @__PURE__ */ new WeakMap();\nvar hintPopoverList = /* @__PURE__ */ new WeakMap();\nvar visibilityState = /* @__PURE__ */ new WeakMap();\nfunction getPopoverVisibilityState(popover) {\n return visibilityState.get(popover) || \"hidden\";\n}\nvar popoverInvoker = /* @__PURE__ */ new WeakMap();\nfunction lastSetElement(set) {\n return [...set].pop();\n}\nfunction popoverTargetAttributeActivationBehavior(element) {\n const popover = element.popoverTargetElement;\n if (!(popover instanceof HTMLElement)) {\n return;\n }\n const visibility = getPopoverVisibilityState(popover);\n if (element.popoverTargetAction === \"show\" && visibility === \"showing\") {\n return;\n }\n if (element.popoverTargetAction === \"hide\" && visibility === \"hidden\") return;\n if (visibility === \"showing\") {\n hidePopover(popover, true, true);\n } else if (checkPopoverValidity(popover, false)) {\n popoverInvoker.set(popover, element);\n showPopover(popover);\n }\n}\nfunction checkPopoverValidity(element, expectedToBeShowing) {\n if (element.popover !== \"auto\" && element.popover !== \"manual\" && element.popover !== \"hint\") {\n return false;\n }\n if (!element.isConnected) return false;\n if (expectedToBeShowing && getPopoverVisibilityState(element) !== \"showing\") {\n return false;\n }\n if (!expectedToBeShowing && getPopoverVisibilityState(element) !== \"hidden\") {\n return false;\n }\n if (element instanceof HTMLDialogElement && element.hasAttribute(\"open\")) {\n return false;\n }\n if (document.fullscreenElement === element) return false;\n return true;\n}\nfunction getStackPosition(popover) {\n if (!popover) return 0;\n const autoPopovers = autoPopoverList.get(document) || /* @__PURE__ */ new Set();\n const hintPopovers = hintPopoverList.get(document) || /* @__PURE__ */ new Set();\n if (hintPopovers.has(popover)) {\n return [...hintPopovers].indexOf(popover) + autoPopovers.size + 1;\n }\n if (autoPopovers.has(popover)) {\n return [...autoPopovers].indexOf(popover) + 1;\n }\n return 0;\n}\nfunction topMostClickedPopover(target) {\n const clickedPopover = nearestInclusiveOpenPopover(target);\n const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);\n if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {\n return clickedPopover;\n }\n return invokerPopover;\n}\nfunction topmostAutoOrHintPopover(document2) {\n let topmostPopover;\n const hintPopovers = hintPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopovers = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const usedStack = hintPopovers.size > 0 ? hintPopovers : autoPopovers.size > 0 ? autoPopovers : null;\n if (usedStack) {\n topmostPopover = lastSetElement(usedStack);\n if (!topmostPopover.isConnected) {\n usedStack.delete(topmostPopover);\n return topmostAutoOrHintPopover(document2);\n }\n return topmostPopover;\n }\n return null;\n}\nfunction topMostPopoverInList(list) {\n for (const popover of list || []) {\n if (!popover.isConnected) {\n list.delete(popover);\n } else {\n return popover;\n }\n }\n return null;\n}\nfunction getRootNode(node) {\n if (typeof node.getRootNode === \"function\") {\n return node.getRootNode();\n }\n if (node.parentNode) return getRootNode(node.parentNode);\n return node;\n}\nfunction nearestInclusiveOpenPopover(node) {\n while (node) {\n if (node instanceof HTMLElement && node.popover === \"auto\" && visibilityState.get(node) === \"showing\") {\n return node;\n }\n node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction nearestInclusiveTargetPopoverForInvoker(node) {\n while (node) {\n const nodePopover = node.popoverTargetElement;\n if (nodePopover instanceof HTMLElement) return nodePopover;\n node = node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction topMostPopoverAncestor(newPopover, list) {\n const popoverPositions = /* @__PURE__ */ new Map();\n let i = 0;\n for (const popover of list || []) {\n popoverPositions.set(popover, i);\n i += 1;\n }\n popoverPositions.set(newPopover, i);\n i += 1;\n let topMostPopoverAncestor2 = null;\n function checkAncestor(candidate) {\n if (!candidate) return;\n let okNesting = false;\n let candidateAncestor = null;\n let candidatePosition = null;\n while (!okNesting) {\n candidateAncestor = nearestInclusiveOpenPopover(candidate) || null;\n if (candidateAncestor === null) return;\n if (!popoverPositions.has(candidateAncestor)) return;\n if (newPopover.popover === \"hint\" || candidateAncestor.popover === \"auto\") {\n okNesting = true;\n }\n if (!okNesting) {\n candidate = candidateAncestor.parentElement;\n }\n }\n candidatePosition = popoverPositions.get(candidateAncestor);\n if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {\n topMostPopoverAncestor2 = candidateAncestor;\n }\n }\n checkAncestor(newPopover.parentElement || getRootNode(newPopover));\n return topMostPopoverAncestor2;\n}\nfunction isFocusable(focusTarget) {\n if (focusTarget.hidden || focusTarget instanceof ShadowRoot) return false;\n if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {\n if (focusTarget.disabled) return false;\n }\n if (focusTarget instanceof HTMLInputElement && focusTarget.type === \"hidden\") {\n return false;\n }\n if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === \"\") {\n return false;\n }\n return typeof focusTarget.tabIndex === \"number\" && focusTarget.tabIndex !== -1;\n}\nfunction focusDelegate(focusTarget) {\n if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {\n return null;\n }\n let whereToLook = focusTarget;\n if (whereToLook.shadowRoot) {\n whereToLook = whereToLook.shadowRoot;\n }\n let autoFocusDelegate = whereToLook.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n } else {\n const slots = whereToLook.querySelectorAll(\"slot\");\n for (const slot of slots) {\n const assignedElements = slot.assignedElements({ flatten: true });\n for (const el of assignedElements) {\n if (el.hasAttribute(\"autofocus\")) {\n return el;\n } else {\n autoFocusDelegate = el.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n }\n }\n }\n }\n }\n const walker = focusTarget.ownerDocument.createTreeWalker(\n whereToLook,\n NodeFilter.SHOW_ELEMENT\n );\n let descendant = walker.currentNode;\n while (descendant) {\n if (isFocusable(descendant)) {\n return descendant;\n }\n descendant = walker.nextNode();\n }\n}\nfunction popoverFocusingSteps(subject) {\n var _a;\n (_a = focusDelegate(subject)) == null ? void 0 : _a.focus();\n}\nvar previouslyFocusedElements = /* @__PURE__ */ new WeakMap();\nfunction showPopover(element) {\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n const document2 = element.ownerDocument;\n if (!element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n cancelable: true,\n oldState: \"closed\",\n newState: \"open\"\n })\n )) {\n return;\n }\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n let shouldRestoreFocus = false;\n const originalType = element.popover;\n let stackToAppendTo = null;\n const autoAncestor = topMostPopoverAncestor(\n element,\n autoPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n const hintAncestor = topMostPopoverAncestor(\n element,\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n if (originalType === \"auto\") {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n const ancestor = autoAncestor || document2;\n hideAllPopoversUntil(ancestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n }\n if (originalType === \"hint\") {\n if (hintAncestor) {\n hideAllPopoversUntil(hintAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"hint\";\n } else {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n if (autoAncestor) {\n hideAllPopoversUntil(autoAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n } else {\n stackToAppendTo = \"hint\";\n }\n }\n }\n if (originalType === \"auto\" || originalType === \"hint\") {\n if (originalType !== element.popover || !checkPopoverValidity(element, false)) {\n return;\n }\n if (!topmostAutoOrHintPopover(document2)) {\n shouldRestoreFocus = true;\n }\n if (stackToAppendTo === \"auto\") {\n if (!autoPopoverList.has(document2)) {\n autoPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n autoPopoverList.get(document2).add(element);\n } else if (stackToAppendTo === \"hint\") {\n if (!hintPopoverList.has(document2)) {\n hintPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n hintPopoverList.get(document2).add(element);\n }\n }\n previouslyFocusedElements.delete(element);\n const originallyFocusedElement = document2.activeElement;\n element.classList.add(\":popover-open\");\n visibilityState.set(element, \"showing\");\n if (!topLayerElements.has(document2)) {\n topLayerElements.set(document2, /* @__PURE__ */ new Set());\n }\n topLayerElements.get(document2).add(element);\n setInvokerAriaExpanded(popoverInvoker.get(element), true);\n popoverFocusingSteps(element);\n if (shouldRestoreFocus && originallyFocusedElement && element.popover === \"auto\") {\n previouslyFocusedElements.set(element, originallyFocusedElement);\n }\n queuePopoverToggleEventTask(element, \"closed\", \"open\");\n}\nfunction hidePopover(element, focusPreviousElement = false, fireEvents = false) {\n var _a, _b;\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n const document2 = element.ownerDocument;\n if ([\"auto\", \"hint\"].includes(element.popover)) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n const autoList = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopoverListContainsElement = autoList.has(element) && lastSetElement(autoList) === element;\n setInvokerAriaExpanded(popoverInvoker.get(element), false);\n popoverInvoker.delete(element);\n if (fireEvents) {\n element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n oldState: \"open\",\n newState: \"closed\"\n })\n );\n if (autoPopoverListContainsElement && lastSetElement(autoList) !== element) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n }\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n (_a = topLayerElements.get(document2)) == null ? void 0 : _a.delete(element);\n autoList.delete(element);\n (_b = hintPopoverList.get(document2)) == null ? void 0 : _b.delete(element);\n element.classList.remove(\":popover-open\");\n visibilityState.set(element, \"hidden\");\n if (fireEvents) {\n queuePopoverToggleEventTask(element, \"open\", \"closed\");\n }\n const previouslyFocusedElement = previouslyFocusedElements.get(element);\n if (previouslyFocusedElement) {\n previouslyFocusedElements.delete(element);\n if (focusPreviousElement) {\n previouslyFocusedElement.focus();\n }\n }\n}\nfunction closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {\n let popover = topmostAutoOrHintPopover(document2);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topmostAutoOrHintPopover(document2);\n }\n}\nfunction closeAllOpenPopoversInList(list, focusPreviousElement = false, fireEvents = false) {\n let popover = topMostPopoverInList(list);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topMostPopoverInList(list);\n }\n}\nfunction hidePopoverStackUntil(endpoint, set, focusPreviousElement, fireEvents) {\n let repeatingHide = false;\n let hasRunOnce = false;\n while (repeatingHide || !hasRunOnce) {\n hasRunOnce = true;\n let lastToHide = null;\n let foundEndpoint = false;\n for (const popover of set) {\n if (popover === endpoint) {\n foundEndpoint = true;\n } else if (foundEndpoint) {\n lastToHide = popover;\n break;\n }\n }\n if (!lastToHide) return;\n while (getPopoverVisibilityState(lastToHide) === \"showing\" && set.size) {\n hidePopover(lastSetElement(set), focusPreviousElement, fireEvents);\n }\n if (set.has(endpoint) && lastSetElement(set) !== endpoint) {\n repeatingHide = true;\n }\n if (repeatingHide) {\n fireEvents = false;\n }\n }\n}\nfunction hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {\n var _a, _b;\n const document2 = endpoint.ownerDocument || endpoint;\n if (endpoint instanceof Document) {\n return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);\n }\n if ((_a = hintPopoverList.get(document2)) == null ? void 0 : _a.has(endpoint)) {\n hidePopoverStackUntil(\n endpoint,\n hintPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n return;\n }\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n focusPreviousElement,\n fireEvents\n );\n if (!((_b = autoPopoverList.get(document2)) == null ? void 0 : _b.has(endpoint))) {\n return;\n }\n hidePopoverStackUntil(\n endpoint,\n autoPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n}\nvar popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();\nfunction lightDismissOpenPopovers(event) {\n if (!event.isTrusted) return;\n const target = event.composedPath()[0];\n if (!target) return;\n const document2 = target.ownerDocument;\n const topMostPopover = topmostAutoOrHintPopover(document2);\n if (!topMostPopover) return;\n const ancestor = topMostClickedPopover(target);\n if (ancestor && event.type === \"pointerdown\") {\n popoverPointerDownTargets.set(document2, ancestor);\n } else if (event.type === \"pointerup\") {\n const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;\n popoverPointerDownTargets.delete(document2);\n if (sameTarget) {\n hideAllPopoversUntil(ancestor || document2, false, true);\n }\n }\n}\nvar initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();\nfunction setInvokerAriaExpanded(el, force = false) {\n if (!el) return;\n if (!initialAriaExpandedValue.has(el)) {\n initialAriaExpandedValue.set(el, el.getAttribute(\"aria-expanded\"));\n }\n const popover = el.popoverTargetElement;\n if (popover instanceof HTMLElement && popover.popover === \"auto\") {\n el.setAttribute(\"aria-expanded\", String(force));\n } else {\n const initialValue = initialAriaExpandedValue.get(el);\n if (!initialValue) {\n el.removeAttribute(\"aria-expanded\");\n } else {\n el.setAttribute(\"aria-expanded\", initialValue);\n }\n }\n}\n\n// src/popover.ts\nvar ShadowRoot2 = globalThis.ShadowRoot || function() {\n};\nfunction isSupported() {\n return typeof HTMLElement !== \"undefined\" && typeof HTMLElement.prototype === \"object\" && \"popover\" in HTMLElement.prototype;\n}\nfunction isHintSupported() {\n const el = document.createElement(\"div\");\n el.setAttribute(\"popover\", \"hint\");\n return el.popover === \"hint\";\n}\nfunction isPolyfilled() {\n var _a;\n return Boolean(\n ((_a = document.body) == null ? void 0 : _a.showPopover) && !/native code/i.test(document.body.showPopover.toString())\n );\n}\nfunction patchSelectorFn(object, name, mapper) {\n const original = object[name];\n Object.defineProperty(object, name, {\n value(selector) {\n return original.call(this, mapper(selector));\n }\n });\n}\nvar nonEscapedPopoverSelector = /(^|[^\\\\]):popover-open\\b/g;\nfunction hasLayerSupport() {\n return typeof globalThis.CSSLayerBlockRule === \"function\";\n}\nfunction getStyles() {\n const useLayer = hasLayerSupport();\n return `\n${useLayer ? \"@layer popover-polyfill {\" : \"\"}\n :where([popover]) {\n position: fixed;\n z-index: 2147483647;\n inset: 0;\n padding: 0.25em;\n width: fit-content;\n height: fit-content;\n border-width: initial;\n border-color: initial;\n border-image: initial;\n border-style: solid;\n background-color: canvas;\n color: canvastext;\n overflow: auto;\n margin: auto;\n }\n\n :where([popover]:not(.\\\\:popover-open)) {\n display: none;\n }\n\n :where(dialog[popover].\\\\:popover-open) {\n display: block;\n }\n\n :where(dialog[popover][open]) {\n display: revert;\n }\n\n :where([anchor].\\\\:popover-open) {\n inset: auto;\n }\n\n :where([anchor]:popover-open) {\n inset: auto;\n }\n\n @supports not (background-color: canvas) {\n :where([popover]) {\n background-color: white;\n color: black;\n }\n }\n\n @supports (width: -moz-fit-content) {\n :where([popover]) {\n width: -moz-fit-content;\n height: -moz-fit-content;\n }\n }\n\n @supports not (inset: 0) {\n :where([popover]) {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n }\n${useLayer ? \"}\" : \"\"}\n`;\n}\nvar popoverStyleSheet = null;\nfunction injectStyles(root) {\n const styles = getStyles();\n if (popoverStyleSheet === null) {\n try {\n popoverStyleSheet = new CSSStyleSheet();\n popoverStyleSheet.replaceSync(styles);\n } catch {\n popoverStyleSheet = false;\n }\n }\n if (popoverStyleSheet === false) {\n const sheet = document.createElement(\"style\");\n sheet.textContent = styles;\n if (root instanceof Document) {\n root.head.prepend(sheet);\n } else {\n root.prepend(sheet);\n }\n } else {\n root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];\n }\n}\nfunction apply() {\n if (typeof window === \"undefined\") return;\n window.ToggleEvent = window.ToggleEvent || ToggleEvent;\n function rewriteSelector(selector) {\n if (selector == null ? void 0 : selector.includes(\":popover-open\")) {\n selector = selector.replace(\n nonEscapedPopoverSelector,\n \"$1.\\\\:popover-open\"\n );\n }\n return selector;\n }\n patchSelectorFn(Document.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Document.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"matches\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"closest\", rewriteSelector);\n patchSelectorFn(\n DocumentFragment.prototype,\n \"querySelectorAll\",\n rewriteSelector\n );\n Object.defineProperties(HTMLElement.prototype, {\n popover: {\n enumerable: true,\n configurable: true,\n get() {\n if (!this.hasAttribute(\"popover\")) return null;\n const value = (this.getAttribute(\"popover\") || \"\").toLowerCase();\n if (value === \"\" || value == \"auto\") return \"auto\";\n if (value == \"hint\") return \"hint\";\n return \"manual\";\n },\n set(value) {\n if (value === null) {\n this.removeAttribute(\"popover\");\n } else {\n this.setAttribute(\"popover\", value);\n }\n }\n },\n showPopover: {\n enumerable: true,\n configurable: true,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n value(options = {}) {\n showPopover(this);\n }\n },\n hidePopover: {\n enumerable: true,\n configurable: true,\n value() {\n hidePopover(this, true, true);\n }\n },\n togglePopover: {\n enumerable: true,\n configurable: true,\n value(options = {}) {\n if (typeof options === \"boolean\") {\n options = { force: options };\n }\n if (visibilityState.get(this) === \"showing\" && options.force === void 0 || options.force === false) {\n hidePopover(this, true, true);\n } else if (options.force === void 0 || options.force === true) {\n showPopover(this);\n }\n return visibilityState.get(this) === \"showing\";\n }\n }\n });\n const originalAttachShadow = Element.prototype.attachShadow;\n if (originalAttachShadow) {\n Object.defineProperties(Element.prototype, {\n attachShadow: {\n enumerable: true,\n configurable: true,\n writable: true,\n value(options) {\n const shadowRoot = originalAttachShadow.call(this, options);\n injectStyles(shadowRoot);\n return shadowRoot;\n }\n }\n });\n }\n const originalAttachInternals = HTMLElement.prototype.attachInternals;\n if (originalAttachInternals) {\n Object.defineProperties(HTMLElement.prototype, {\n attachInternals: {\n enumerable: true,\n configurable: true,\n writable: true,\n value() {\n const internals = originalAttachInternals.call(this);\n if (internals.shadowRoot) {\n injectStyles(internals.shadowRoot);\n }\n return internals;\n }\n }\n });\n }\n const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();\n function applyPopoverInvokerElementMixin(ElementClass) {\n Object.defineProperties(ElementClass.prototype, {\n popoverTargetElement: {\n enumerable: true,\n configurable: true,\n set(targetElement) {\n if (targetElement === null) {\n this.removeAttribute(\"popovertarget\");\n popoverTargetAssociatedElements.delete(this);\n } else if (!(targetElement instanceof Element)) {\n throw new TypeError(\n `popoverTargetElement must be an element or null`\n );\n } else {\n this.setAttribute(\"popovertarget\", \"\");\n popoverTargetAssociatedElements.set(this, targetElement);\n }\n },\n get() {\n if (this.localName !== \"button\" && this.localName !== \"input\") {\n return null;\n }\n if (this.localName === \"input\" && this.type !== \"reset\" && this.type !== \"image\" && this.type !== \"button\") {\n return null;\n }\n if (this.disabled) {\n return null;\n }\n if (this.form && this.type === \"submit\") {\n return null;\n }\n const targetElement = popoverTargetAssociatedElements.get(this);\n if (targetElement && targetElement.isConnected) {\n return targetElement;\n } else if (targetElement && !targetElement.isConnected) {\n popoverTargetAssociatedElements.delete(this);\n return null;\n }\n const root = getRootNode(this);\n const idref = this.getAttribute(\"popovertarget\");\n if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {\n return root.getElementById(idref) || null;\n }\n return null;\n }\n },\n popoverTargetAction: {\n enumerable: true,\n configurable: true,\n get() {\n const value = (this.getAttribute(\"popovertargetaction\") || \"\").toLowerCase();\n if (value === \"show\" || value === \"hide\") return value;\n return \"toggle\";\n },\n set(value) {\n this.setAttribute(\"popovertargetaction\", value);\n }\n }\n });\n }\n applyPopoverInvokerElementMixin(HTMLButtonElement);\n applyPopoverInvokerElementMixin(HTMLInputElement);\n const handleInvokerActivation = (event) => {\n if (event.defaultPrevented) {\n return;\n }\n const composedPath = event.composedPath();\n const target = composedPath[0];\n if (!(target instanceof Element) || (target == null ? void 0 : target.shadowRoot)) {\n return;\n }\n const root = getRootNode(target);\n if (!(root instanceof ShadowRoot2 || root instanceof Document)) {\n return;\n }\n const invoker = composedPath.find(\n (el) => {\n var _a;\n return (_a = el.matches) == null ? void 0 : _a.call(el, \"[popovertargetaction],[popovertarget]\");\n }\n );\n if (invoker) {\n popoverTargetAttributeActivationBehavior(invoker);\n event.preventDefault();\n return;\n }\n };\n const onKeydown = (event) => {\n const key = event.key;\n const target = event.target;\n if (!event.defaultPrevented && target && (key === \"Escape\" || key === \"Esc\")) {\n hideAllPopoversUntil(target.ownerDocument, true, true);\n }\n };\n const addEventListeners = (root) => {\n root.addEventListener(\"click\", handleInvokerActivation);\n root.addEventListener(\"keydown\", onKeydown);\n root.addEventListener(\"pointerdown\", lightDismissOpenPopovers);\n root.addEventListener(\"pointerup\", lightDismissOpenPopovers);\n };\n addEventListeners(document);\n injectStyles(document);\n}\nexport {\n apply,\n injectStyles,\n isHintSupported,\n isPolyfilled,\n isSupported\n};\n//# sourceMappingURL=popover-fn.js.map\n"],"x_google_ignoreList":[0],"mappings":"AACA,IAAI,EAAc,cAAc,KAAM,CACpC,SACA,SACA,YAAY,EAAM,CAAE,WAAW,GAAI,WAAW,GAAI,GAAG,GAAS,CAAC,EAAG,CAChE,MAAM,EAAM,CAAI,EAChB,KAAK,SAAW,OAAO,GAAY,EAAE,EACrC,KAAK,SAAW,OAAO,GAAY,EAAE,CACvC,CACF,EACI,EAAyC,IAAI,QACjD,SAAS,EAA4B,EAAS,EAAU,EAAU,CAChE,EAAuB,IACrB,EACA,eAAiB,CACV,EAAuB,IAAI,CAAO,GACvC,EAAQ,cACN,IAAI,EAAY,SAAU,CACxB,WAAY,GACZ,WACA,UACF,CAAC,CACH,CACF,EAAG,CAAC,CACN,CACF,CAGA,IAAI,EAAa,WAAW,YAAc,UAAW,CACrD,EACI,EAAoB,WAAW,mBAAqB,UAAW,CACnE,EACI,EAAmC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AU,CACzC,GAAI,EAAM,iBACR,OAEF,IAAM,EAAe,EAAM,aAAa,EAClC,EAAS,EAAa,GAC5B,GAAI,EAAE,aAAkB,UAAa,GAAiC,WACpE,OAEF,IAAM,EAAO,EAAY,CAAM,EAC/B,GAAI,EAAE,aAAgB,GAAe,aAAgB,UACnD,OAEF,IAAM,EAAU,EAAa,KAC1B,GAEc,EAAG,SAA+B,KAAK,EAAI,uCAAuC,CAEnG,EACA,GAAI,EAAS,CACX,EAAyC,CAAO,EAChD,EAAM,eAAe,EACrB,MACF,CACF,EACM,EAAa,GAAU,CAC3B,IAAM,EAAM,EAAM,IACZ,EAAS,EAAM,OACjB,CAAC,EAAM,kBAAoB,IAAW,IAAQ,UAAY,IAAQ,QACpE,EAAqB,EAAO,cAAe,GAAM,EAAI,CAEzD,GAC2B,GAAS,CAClC,EAAK,iBAAiB,QAAS,CAAuB,EACtD,EAAK,iBAAiB,UAAW,CAAS,EAC1C,EAAK,iBAAiB,cAAe,CAAwB,EAC7D,EAAK,iBAAiB,YAAa,CAAwB,CAC7D,GACkB,QAAQ,EAC1B,EAAa,QAAQ,CACvB"}
|
|
1
|
+
{"version":3,"file":"popover-fn.js","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@oddbird+popover-polyfill@0.6.1/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js"],"sourcesContent":["// src/events.ts\nvar ToggleEvent = class extends Event {\n oldState;\n newState;\n constructor(type, { oldState = \"\", newState = \"\", ...init } = {}) {\n super(type, init);\n this.oldState = String(oldState || \"\");\n this.newState = String(newState || \"\");\n }\n};\nvar popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();\nfunction queuePopoverToggleEventTask(element, oldState, newState) {\n popoverToggleTaskQueue.set(\n element,\n setTimeout(() => {\n if (!popoverToggleTaskQueue.has(element)) return;\n element.dispatchEvent(\n new ToggleEvent(\"toggle\", {\n cancelable: false,\n oldState,\n newState\n })\n );\n }, 0)\n );\n}\n\n// src/popover-helpers.ts\nvar ShadowRoot = globalThis.ShadowRoot || function() {\n};\nvar HTMLDialogElement = globalThis.HTMLDialogElement || function() {\n};\nvar topLayerElements = /* @__PURE__ */ new WeakMap();\nvar autoPopoverList = /* @__PURE__ */ new WeakMap();\nvar hintPopoverList = /* @__PURE__ */ new WeakMap();\nvar visibilityState = /* @__PURE__ */ new WeakMap();\nfunction getPopoverVisibilityState(popover) {\n return visibilityState.get(popover) || \"hidden\";\n}\nvar popoverInvoker = /* @__PURE__ */ new WeakMap();\nfunction lastSetElement(set) {\n return [...set].pop();\n}\nfunction popoverTargetAttributeActivationBehavior(element) {\n const popover = element.popoverTargetElement;\n if (!(popover instanceof HTMLElement)) {\n return;\n }\n const visibility = getPopoverVisibilityState(popover);\n if (element.popoverTargetAction === \"show\" && visibility === \"showing\") {\n return;\n }\n if (element.popoverTargetAction === \"hide\" && visibility === \"hidden\") return;\n if (visibility === \"showing\") {\n hidePopover(popover, true, true);\n } else if (checkPopoverValidity(popover, false)) {\n popoverInvoker.set(popover, element);\n showPopover(popover);\n }\n}\nfunction checkPopoverValidity(element, expectedToBeShowing) {\n if (element.popover !== \"auto\" && element.popover !== \"manual\" && element.popover !== \"hint\") {\n return false;\n }\n if (!element.isConnected) return false;\n if (expectedToBeShowing && getPopoverVisibilityState(element) !== \"showing\") {\n return false;\n }\n if (!expectedToBeShowing && getPopoverVisibilityState(element) !== \"hidden\") {\n return false;\n }\n if (element instanceof HTMLDialogElement && element.hasAttribute(\"open\")) {\n return false;\n }\n if (document.fullscreenElement === element) return false;\n return true;\n}\nfunction getStackPosition(popover) {\n if (!popover) return 0;\n const autoPopovers = autoPopoverList.get(document) || /* @__PURE__ */ new Set();\n const hintPopovers = hintPopoverList.get(document) || /* @__PURE__ */ new Set();\n if (hintPopovers.has(popover)) {\n return [...hintPopovers].indexOf(popover) + autoPopovers.size + 1;\n }\n if (autoPopovers.has(popover)) {\n return [...autoPopovers].indexOf(popover) + 1;\n }\n return 0;\n}\nfunction topMostClickedPopover(target) {\n const clickedPopover = nearestInclusiveOpenPopover(target);\n const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);\n if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {\n return clickedPopover;\n }\n return invokerPopover;\n}\nfunction topmostAutoOrHintPopover(document2) {\n let topmostPopover;\n const hintPopovers = hintPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopovers = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const usedStack = hintPopovers.size > 0 ? hintPopovers : autoPopovers.size > 0 ? autoPopovers : null;\n if (usedStack) {\n topmostPopover = lastSetElement(usedStack);\n if (!topmostPopover.isConnected) {\n usedStack.delete(topmostPopover);\n return topmostAutoOrHintPopover(document2);\n }\n return topmostPopover;\n }\n return null;\n}\nfunction topMostPopoverInList(list) {\n for (const popover of list || []) {\n if (!popover.isConnected) {\n list.delete(popover);\n } else {\n return popover;\n }\n }\n return null;\n}\nfunction getRootNode(node) {\n if (typeof node.getRootNode === \"function\") {\n return node.getRootNode();\n }\n if (node.parentNode) return getRootNode(node.parentNode);\n return node;\n}\nfunction nearestInclusiveOpenPopover(node) {\n while (node) {\n if (node instanceof HTMLElement && node.popover === \"auto\" && visibilityState.get(node) === \"showing\") {\n return node;\n }\n node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction nearestInclusiveTargetPopoverForInvoker(node) {\n while (node) {\n const nodePopover = node.popoverTargetElement;\n if (nodePopover instanceof HTMLElement) return nodePopover;\n node = node.parentElement || getRootNode(node);\n if (node instanceof ShadowRoot) node = node.host;\n if (node instanceof Document) return;\n }\n}\nfunction topMostPopoverAncestor(newPopover, list) {\n const popoverPositions = /* @__PURE__ */ new Map();\n let i = 0;\n for (const popover of list || []) {\n popoverPositions.set(popover, i);\n i += 1;\n }\n popoverPositions.set(newPopover, i);\n i += 1;\n let topMostPopoverAncestor2 = null;\n function checkAncestor(candidate) {\n if (!candidate) return;\n let okNesting = false;\n let candidateAncestor = null;\n let candidatePosition = null;\n while (!okNesting) {\n candidateAncestor = nearestInclusiveOpenPopover(candidate) || null;\n if (candidateAncestor === null) return;\n if (!popoverPositions.has(candidateAncestor)) return;\n if (newPopover.popover === \"hint\" || candidateAncestor.popover === \"auto\") {\n okNesting = true;\n }\n if (!okNesting) {\n candidate = candidateAncestor.parentElement;\n }\n }\n candidatePosition = popoverPositions.get(candidateAncestor);\n if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {\n topMostPopoverAncestor2 = candidateAncestor;\n }\n }\n checkAncestor(newPopover.parentElement || getRootNode(newPopover));\n return topMostPopoverAncestor2;\n}\nfunction isFocusable(focusTarget) {\n if (focusTarget.hidden || focusTarget instanceof ShadowRoot) return false;\n if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {\n if (focusTarget.disabled) return false;\n }\n if (focusTarget instanceof HTMLInputElement && focusTarget.type === \"hidden\") {\n return false;\n }\n if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === \"\") {\n return false;\n }\n return typeof focusTarget.tabIndex === \"number\" && focusTarget.tabIndex !== -1;\n}\nfunction focusDelegate(focusTarget) {\n if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {\n return null;\n }\n let whereToLook = focusTarget;\n if (whereToLook.shadowRoot) {\n whereToLook = whereToLook.shadowRoot;\n }\n let autoFocusDelegate = whereToLook.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n } else {\n const slots = whereToLook.querySelectorAll(\"slot\");\n for (const slot of slots) {\n const assignedElements = slot.assignedElements({ flatten: true });\n for (const el of assignedElements) {\n if (el.hasAttribute(\"autofocus\")) {\n return el;\n } else {\n autoFocusDelegate = el.querySelector(\"[autofocus]\");\n if (autoFocusDelegate) {\n return autoFocusDelegate;\n }\n }\n }\n }\n }\n const walker = focusTarget.ownerDocument.createTreeWalker(\n whereToLook,\n NodeFilter.SHOW_ELEMENT\n );\n let descendant = walker.currentNode;\n while (descendant) {\n if (isFocusable(descendant)) {\n return descendant;\n }\n descendant = walker.nextNode();\n }\n}\nfunction popoverFocusingSteps(subject) {\n var _a;\n (_a = focusDelegate(subject)) == null ? void 0 : _a.focus();\n}\nvar previouslyFocusedElements = /* @__PURE__ */ new WeakMap();\nfunction showPopover(element) {\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n const document2 = element.ownerDocument;\n if (!element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n cancelable: true,\n oldState: \"closed\",\n newState: \"open\"\n })\n )) {\n return;\n }\n if (!checkPopoverValidity(element, false)) {\n return;\n }\n let shouldRestoreFocus = false;\n const originalType = element.popover;\n let stackToAppendTo = null;\n const autoAncestor = topMostPopoverAncestor(\n element,\n autoPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n const hintAncestor = topMostPopoverAncestor(\n element,\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set()\n );\n if (originalType === \"auto\") {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n const ancestor = autoAncestor || document2;\n hideAllPopoversUntil(ancestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n }\n if (originalType === \"hint\") {\n if (hintAncestor) {\n hideAllPopoversUntil(hintAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"hint\";\n } else {\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n shouldRestoreFocus,\n true\n );\n if (autoAncestor) {\n hideAllPopoversUntil(autoAncestor, shouldRestoreFocus, true);\n stackToAppendTo = \"auto\";\n } else {\n stackToAppendTo = \"hint\";\n }\n }\n }\n if (originalType === \"auto\" || originalType === \"hint\") {\n if (originalType !== element.popover || !checkPopoverValidity(element, false)) {\n return;\n }\n if (!topmostAutoOrHintPopover(document2)) {\n shouldRestoreFocus = true;\n }\n if (stackToAppendTo === \"auto\") {\n if (!autoPopoverList.has(document2)) {\n autoPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n autoPopoverList.get(document2).add(element);\n } else if (stackToAppendTo === \"hint\") {\n if (!hintPopoverList.has(document2)) {\n hintPopoverList.set(document2, /* @__PURE__ */ new Set());\n }\n hintPopoverList.get(document2).add(element);\n }\n }\n previouslyFocusedElements.delete(element);\n const originallyFocusedElement = document2.activeElement;\n element.classList.add(\":popover-open\");\n visibilityState.set(element, \"showing\");\n if (!topLayerElements.has(document2)) {\n topLayerElements.set(document2, /* @__PURE__ */ new Set());\n }\n topLayerElements.get(document2).add(element);\n setInvokerAriaExpanded(popoverInvoker.get(element), true);\n popoverFocusingSteps(element);\n if (shouldRestoreFocus && originallyFocusedElement && element.popover === \"auto\") {\n previouslyFocusedElements.set(element, originallyFocusedElement);\n }\n queuePopoverToggleEventTask(element, \"closed\", \"open\");\n}\nfunction hidePopover(element, focusPreviousElement = false, fireEvents = false) {\n var _a, _b;\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n const document2 = element.ownerDocument;\n if ([\"auto\", \"hint\"].includes(element.popover)) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n const autoList = autoPopoverList.get(document2) || /* @__PURE__ */ new Set();\n const autoPopoverListContainsElement = autoList.has(element) && lastSetElement(autoList) === element;\n setInvokerAriaExpanded(popoverInvoker.get(element), false);\n popoverInvoker.delete(element);\n if (fireEvents) {\n element.dispatchEvent(\n new ToggleEvent(\"beforetoggle\", {\n oldState: \"open\",\n newState: \"closed\"\n })\n );\n if (autoPopoverListContainsElement && lastSetElement(autoList) !== element) {\n hideAllPopoversUntil(element, focusPreviousElement, fireEvents);\n }\n if (!checkPopoverValidity(element, true)) {\n return;\n }\n }\n (_a = topLayerElements.get(document2)) == null ? void 0 : _a.delete(element);\n autoList.delete(element);\n (_b = hintPopoverList.get(document2)) == null ? void 0 : _b.delete(element);\n element.classList.remove(\":popover-open\");\n visibilityState.set(element, \"hidden\");\n if (fireEvents) {\n queuePopoverToggleEventTask(element, \"open\", \"closed\");\n }\n const previouslyFocusedElement = previouslyFocusedElements.get(element);\n if (previouslyFocusedElement) {\n previouslyFocusedElements.delete(element);\n if (focusPreviousElement) {\n previouslyFocusedElement.focus();\n }\n }\n}\nfunction closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {\n let popover = topmostAutoOrHintPopover(document2);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topmostAutoOrHintPopover(document2);\n }\n}\nfunction closeAllOpenPopoversInList(list, focusPreviousElement = false, fireEvents = false) {\n let popover = topMostPopoverInList(list);\n while (popover) {\n hidePopover(popover, focusPreviousElement, fireEvents);\n popover = topMostPopoverInList(list);\n }\n}\nfunction hidePopoverStackUntil(endpoint, set, focusPreviousElement, fireEvents) {\n let repeatingHide = false;\n let hasRunOnce = false;\n while (repeatingHide || !hasRunOnce) {\n hasRunOnce = true;\n let lastToHide = null;\n let foundEndpoint = false;\n for (const popover of set) {\n if (popover === endpoint) {\n foundEndpoint = true;\n } else if (foundEndpoint) {\n lastToHide = popover;\n break;\n }\n }\n if (!lastToHide) return;\n while (getPopoverVisibilityState(lastToHide) === \"showing\" && set.size) {\n hidePopover(lastSetElement(set), focusPreviousElement, fireEvents);\n }\n if (set.has(endpoint) && lastSetElement(set) !== endpoint) {\n repeatingHide = true;\n }\n if (repeatingHide) {\n fireEvents = false;\n }\n }\n}\nfunction hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {\n var _a, _b;\n const document2 = endpoint.ownerDocument || endpoint;\n if (endpoint instanceof Document) {\n return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);\n }\n if ((_a = hintPopoverList.get(document2)) == null ? void 0 : _a.has(endpoint)) {\n hidePopoverStackUntil(\n endpoint,\n hintPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n return;\n }\n closeAllOpenPopoversInList(\n hintPopoverList.get(document2) || /* @__PURE__ */ new Set(),\n focusPreviousElement,\n fireEvents\n );\n if (!((_b = autoPopoverList.get(document2)) == null ? void 0 : _b.has(endpoint))) {\n return;\n }\n hidePopoverStackUntil(\n endpoint,\n autoPopoverList.get(document2),\n focusPreviousElement,\n fireEvents\n );\n}\nvar popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();\nfunction lightDismissOpenPopovers(event) {\n if (!event.isTrusted) return;\n const target = event.composedPath()[0];\n if (!target) return;\n const document2 = target.ownerDocument;\n const topMostPopover = topmostAutoOrHintPopover(document2);\n if (!topMostPopover) return;\n const ancestor = topMostClickedPopover(target);\n if (ancestor && event.type === \"pointerdown\") {\n popoverPointerDownTargets.set(document2, ancestor);\n } else if (event.type === \"pointerup\") {\n const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;\n popoverPointerDownTargets.delete(document2);\n if (sameTarget) {\n hideAllPopoversUntil(ancestor || document2, false, true);\n }\n }\n}\nvar initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();\nfunction setInvokerAriaExpanded(el, force = false) {\n if (!el) return;\n if (!initialAriaExpandedValue.has(el)) {\n initialAriaExpandedValue.set(el, el.getAttribute(\"aria-expanded\"));\n }\n const popover = el.popoverTargetElement;\n if (popover instanceof HTMLElement && popover.popover === \"auto\") {\n el.setAttribute(\"aria-expanded\", String(force));\n } else {\n const initialValue = initialAriaExpandedValue.get(el);\n if (!initialValue) {\n el.removeAttribute(\"aria-expanded\");\n } else {\n el.setAttribute(\"aria-expanded\", initialValue);\n }\n }\n}\n\n// src/popover.ts\nvar ShadowRoot2 = globalThis.ShadowRoot || function() {\n};\nfunction isSupported() {\n return typeof HTMLElement !== \"undefined\" && typeof HTMLElement.prototype === \"object\" && \"popover\" in HTMLElement.prototype;\n}\nfunction isHintSupported() {\n const el = document.createElement(\"div\");\n el.setAttribute(\"popover\", \"hint\");\n return el.popover === \"hint\";\n}\nfunction isPolyfilled() {\n var _a;\n return Boolean(\n ((_a = document.body) == null ? void 0 : _a.showPopover) && !/native code/i.test(document.body.showPopover.toString())\n );\n}\nfunction patchSelectorFn(object, name, mapper) {\n const original = object[name];\n Object.defineProperty(object, name, {\n value(selector) {\n return original.call(this, mapper(selector));\n }\n });\n}\nvar nonEscapedPopoverSelector = /(^|[^\\\\]):popover-open\\b/g;\nfunction hasLayerSupport() {\n return typeof globalThis.CSSLayerBlockRule === \"function\";\n}\nfunction getStyles() {\n const useLayer = hasLayerSupport();\n return `\n${useLayer ? \"@layer popover-polyfill {\" : \"\"}\n :where([popover]) {\n position: fixed;\n z-index: 2147483647;\n inset: 0;\n padding: 0.25em;\n width: fit-content;\n height: fit-content;\n border-width: initial;\n border-color: initial;\n border-image: initial;\n border-style: solid;\n background-color: canvas;\n color: canvastext;\n overflow: auto;\n margin: auto;\n }\n\n :where([popover]:not(.\\\\:popover-open)) {\n display: none;\n }\n\n :where(dialog[popover].\\\\:popover-open) {\n display: block;\n }\n\n :where(dialog[popover][open]) {\n display: revert;\n }\n\n :where([anchor].\\\\:popover-open) {\n inset: auto;\n }\n\n :where([anchor]:popover-open) {\n inset: auto;\n }\n\n @supports not (background-color: canvas) {\n :where([popover]) {\n background-color: white;\n color: black;\n }\n }\n\n @supports (width: -moz-fit-content) {\n :where([popover]) {\n width: -moz-fit-content;\n height: -moz-fit-content;\n }\n }\n\n @supports not (inset: 0) {\n :where([popover]) {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n }\n${useLayer ? \"}\" : \"\"}\n`;\n}\nvar popoverStyleSheet = null;\nfunction injectStyles(root) {\n const styles = getStyles();\n if (popoverStyleSheet === null) {\n try {\n popoverStyleSheet = new CSSStyleSheet();\n popoverStyleSheet.replaceSync(styles);\n } catch {\n popoverStyleSheet = false;\n }\n }\n if (popoverStyleSheet === false) {\n const sheet = document.createElement(\"style\");\n sheet.textContent = styles;\n if (root instanceof Document) {\n root.head.prepend(sheet);\n } else {\n root.prepend(sheet);\n }\n } else {\n root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];\n }\n}\nfunction apply() {\n if (typeof window === \"undefined\") return;\n window.ToggleEvent = window.ToggleEvent || ToggleEvent;\n function rewriteSelector(selector) {\n if (selector == null ? void 0 : selector.includes(\":popover-open\")) {\n selector = selector.replace(\n nonEscapedPopoverSelector,\n \"$1.\\\\:popover-open\"\n );\n }\n return selector;\n }\n patchSelectorFn(Document.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Document.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelector\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"querySelectorAll\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"matches\", rewriteSelector);\n patchSelectorFn(Element.prototype, \"closest\", rewriteSelector);\n patchSelectorFn(\n DocumentFragment.prototype,\n \"querySelectorAll\",\n rewriteSelector\n );\n Object.defineProperties(HTMLElement.prototype, {\n popover: {\n enumerable: true,\n configurable: true,\n get() {\n if (!this.hasAttribute(\"popover\")) return null;\n const value = (this.getAttribute(\"popover\") || \"\").toLowerCase();\n if (value === \"\" || value == \"auto\") return \"auto\";\n if (value == \"hint\") return \"hint\";\n return \"manual\";\n },\n set(value) {\n if (value === null) {\n this.removeAttribute(\"popover\");\n } else {\n this.setAttribute(\"popover\", value);\n }\n }\n },\n showPopover: {\n enumerable: true,\n configurable: true,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n value(options = {}) {\n showPopover(this);\n }\n },\n hidePopover: {\n enumerable: true,\n configurable: true,\n value() {\n hidePopover(this, true, true);\n }\n },\n togglePopover: {\n enumerable: true,\n configurable: true,\n value(options = {}) {\n if (typeof options === \"boolean\") {\n options = { force: options };\n }\n if (visibilityState.get(this) === \"showing\" && options.force === void 0 || options.force === false) {\n hidePopover(this, true, true);\n } else if (options.force === void 0 || options.force === true) {\n showPopover(this);\n }\n return visibilityState.get(this) === \"showing\";\n }\n }\n });\n const originalAttachShadow = Element.prototype.attachShadow;\n if (originalAttachShadow) {\n Object.defineProperties(Element.prototype, {\n attachShadow: {\n enumerable: true,\n configurable: true,\n writable: true,\n value(options) {\n const shadowRoot = originalAttachShadow.call(this, options);\n injectStyles(shadowRoot);\n return shadowRoot;\n }\n }\n });\n }\n const originalAttachInternals = HTMLElement.prototype.attachInternals;\n if (originalAttachInternals) {\n Object.defineProperties(HTMLElement.prototype, {\n attachInternals: {\n enumerable: true,\n configurable: true,\n writable: true,\n value() {\n const internals = originalAttachInternals.call(this);\n if (internals.shadowRoot) {\n injectStyles(internals.shadowRoot);\n }\n return internals;\n }\n }\n });\n }\n const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();\n function applyPopoverInvokerElementMixin(ElementClass) {\n Object.defineProperties(ElementClass.prototype, {\n popoverTargetElement: {\n enumerable: true,\n configurable: true,\n set(targetElement) {\n if (targetElement === null) {\n this.removeAttribute(\"popovertarget\");\n popoverTargetAssociatedElements.delete(this);\n } else if (!(targetElement instanceof Element)) {\n throw new TypeError(\n `popoverTargetElement must be an element or null`\n );\n } else {\n this.setAttribute(\"popovertarget\", \"\");\n popoverTargetAssociatedElements.set(this, targetElement);\n }\n },\n get() {\n if (this.localName !== \"button\" && this.localName !== \"input\") {\n return null;\n }\n if (this.localName === \"input\" && this.type !== \"reset\" && this.type !== \"image\" && this.type !== \"button\") {\n return null;\n }\n if (this.disabled) {\n return null;\n }\n if (this.form && this.type === \"submit\") {\n return null;\n }\n const targetElement = popoverTargetAssociatedElements.get(this);\n if (targetElement && targetElement.isConnected) {\n return targetElement;\n } else if (targetElement && !targetElement.isConnected) {\n popoverTargetAssociatedElements.delete(this);\n return null;\n }\n const root = getRootNode(this);\n const idref = this.getAttribute(\"popovertarget\");\n if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {\n return root.getElementById(idref) || null;\n }\n return null;\n }\n },\n popoverTargetAction: {\n enumerable: true,\n configurable: true,\n get() {\n const value = (this.getAttribute(\"popovertargetaction\") || \"\").toLowerCase();\n if (value === \"show\" || value === \"hide\") return value;\n return \"toggle\";\n },\n set(value) {\n this.setAttribute(\"popovertargetaction\", value);\n }\n }\n });\n }\n applyPopoverInvokerElementMixin(HTMLButtonElement);\n applyPopoverInvokerElementMixin(HTMLInputElement);\n const handleInvokerActivation = (event) => {\n if (event.defaultPrevented) {\n return;\n }\n const composedPath = event.composedPath();\n const target = composedPath[0];\n if (!(target instanceof Element) || (target == null ? void 0 : target.shadowRoot)) {\n return;\n }\n const root = getRootNode(target);\n if (!(root instanceof ShadowRoot2 || root instanceof Document)) {\n return;\n }\n const invoker = composedPath.find(\n (el) => {\n var _a;\n return (_a = el.matches) == null ? void 0 : _a.call(el, \"[popovertargetaction],[popovertarget]\");\n }\n );\n if (invoker) {\n popoverTargetAttributeActivationBehavior(invoker);\n event.preventDefault();\n return;\n }\n };\n const onKeydown = (event) => {\n const key = event.key;\n const target = event.target;\n if (!event.defaultPrevented && target && (key === \"Escape\" || key === \"Esc\")) {\n hideAllPopoversUntil(target.ownerDocument, true, true);\n }\n };\n const addEventListeners = (root) => {\n root.addEventListener(\"click\", handleInvokerActivation);\n root.addEventListener(\"keydown\", onKeydown);\n root.addEventListener(\"pointerdown\", lightDismissOpenPopovers);\n root.addEventListener(\"pointerup\", lightDismissOpenPopovers);\n };\n addEventListeners(document);\n injectStyles(document);\n}\nexport {\n apply,\n injectStyles,\n isHintSupported,\n isPolyfilled,\n isSupported\n};\n//# sourceMappingURL=popover-fn.js.map\n"],"x_google_ignoreList":[0],"mappings":"AACA,IAAI,EAAc,cAAc,KAAM,CACpC,SACA,SACA,YAAY,EAAM,CAAE,WAAW,GAAI,WAAW,GAAI,GAAG,GAAS,CAAC,EAAG,CAChE,MAAM,EAAM,CAAI,EAChB,KAAK,SAAW,OAAO,GAAY,EAAE,EACrC,KAAK,SAAW,OAAO,GA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AAK,aAAa,eAAe,EAI/C,OAHK,aAAgB,UAAY,aAAgB,IAAgB,GACxD,EAAK,eAAe,CAAK,GAE3B,IACT,CACF,EACA,oBAAqB,CACnB,WAAY,GACZ,aAAc,GACd,KAAM,CACJ,IAAM,GAAS,KAAK,aAAa,qBAAqB,GAAK,GAAA,CAAI,YAAY,EAE3E,OADI,IAAU,QAAU,IAAU,OAAe,EAC1C,QACT,EACA,IAAI,EAAO,CACT,KAAK,aAAa,sBAAuB,CAAK,CAChD,CACF,CACF,CAAC,CACH,CACA,EAAgC,iBAAiB,EACjD,EAAgC,gBAAgB,EAChD,IAAM,EAA2B,GAAU,CACzC,GAAI,EAAM,iBACR,OAEF,IAAM,EAAe,EAAM,aAAa,EAClC,EAAS,EAAa,GAC5B,GAAI,EAAE,aAAkB,UAAa,GAAiC,WACpE,OAEF,IAAM,EAAO,EAAY,CAAM,EAC/B,GAAI,EAAE,aAAgB,GAAe,aAAgB,UACnD,OAEF,IAAM,EAAU,EAAa,KAC1B,GAEc,EAAG,SAA+B,KAAK,EAAI,uCAAuC,CAEnG,EACA,GAAI,EAAS,CACX,EAAyC,CAAO,EAChD,EAAM,eAAe,EACrB,MACF,CACF,EACM,EAAa,GAAU,CAC3B,IAAM,EAAM,EAAM,IACZ,EAAS,EAAM,OACjB,CAAC,EAAM,kBAAoB,IAAW,IAAQ,UAAY,IAAQ,QACpE,EAAqB,EAAO,cAAe,GAAM,EAAI,CAEzD,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,QAAQ,CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoker.js","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,GAAG,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,E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[],"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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EAE7B,OAAO,OAAO,WAAY,CAAE,cAAa,CAAC,CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickdelegatefor.js","names":[],"sources":["../../../src/clickdelegatefor/clickdelegatefor.ts"],"sourcesContent":["// Adding support for click deletagtion, following\n// https://open-ui.org/components/link-area-delegation-explainer/\n// and https://github.com/openui/open-ui/issues/1104#issuecomment-3151387080\nimport { on, onHotReload, QUICK_EVENT } from '../utils/utils';\n\nconst CLASS_HOVER = ':click-delegate-hover';\nconst ATTR_CLICKDELEGATEFOR = 'data-clickdelegatefor';\nconst SELECTOR_CLICKDELEGATEFOR = `[${ATTR_CLICKDELEGATEFOR}]`;\nconst SELECTOR_SKIP =\n 'a,button,label,input,select,textarea,details,dialog,[role=\"button\"],[popover],[contenteditable]';\n\nconst handleClickDelegateFor = (event: MouseEvent) => {\n const isNewTab = event.button === 1 || event.metaKey || event.ctrlKey; // Middle click or cmd/ctrl + click should open in new tab\n const delegateTarget = event.button < 2 && getDelegateTarget(event); // Only accept left or middle clicks\n\n if (!delegateTarget || delegateTarget.contains(event.target as Node)) return; // Only proxy event if delegated target isn't part of the original target\n if (isNewTab && delegateTarget instanceof HTMLAnchorElement)\n return window.open(delegateTarget.href, undefined, delegateTarget.rel); // If middle click or cmd/ctrl click on link, open in new tab\n event.stopImmediatePropagation(); // We'll trigger a new click event anyway, so prevent actions on this one\n delegateTarget.click(); // Forward click to the clickable element\n};\n\nlet HOVER: Element | undefined;\nconst handleMouseOver = (event: Event) => {\n const delegateTarget = getDelegateTarget(event);\n if (HOVER === delegateTarget) return; // No change\n if (HOVER) HOVER.classList.remove(CLASS_HOVER);\n if (delegateTarget) delegateTarget.classList.add(CLASS_HOVER);\n HOVER = delegateTarget;\n};\n\nconst getDelegateTarget = ({ target: el }: Event) => {\n const scope =\n el instanceof Element ? el.closest(SELECTOR_CLICKDELEGATEFOR) : null;\n const id = scope?.getAttribute(ATTR_CLICKDELEGATEFOR);\n const target = (id && document.getElementById(id)) || undefined;\n const skip = target && (el as Element).closest(SELECTOR_SKIP); // Ignore if interactive\n\n return (!skip || skip === target) && !(target as HTMLInputElement)?.disabled\n ? target\n : undefined; // Skip disabled inputs\n};\n\nonHotReload('clickdelegatefor', () => [\n on(window, 'click auxclick', handleClickDelegateFor as EventListener, true), // Use capture to ensure we run before other click listeners\n on(document, 'mouseover', handleMouseOver, QUICK_EVENT), // Use passive for better performance\n]);\n"],"mappings":"yEAKA,MAAM,EAAc,wBACd,EAAwB,wBACxB,EAA4B,IAAI,EAAsB,GAItD,EAA0B,GAAsB,CACpD,IAAM,EAAW,EAAM,SAAW,GAAK,EAAM,SAAW,EAAM,QACxD,EAAiB,EAAM,OAAS,GAAK,EAAkB,CAAK,EAE9D,MAAC,GAAkB,EAAe,SAAS,EAAM,MAAc,GACnE,IAAI,GAAY,aAA0B,kBACxC,OAAO,OAAO,KAAK,EAAe,KAAM,IAAA,GAAW,EAAe,GAAG,EACvE,EAAM,yBAAyB,EAC/B,EAAe,MAAM,CAFkD,CAGzE,EAEA,IAAI,EACJ,MAAM,EAAmB,GAAiB,CACxC,IAAM,EAAiB,EAAkB,CAAK,EAC1C,IAAU,IACV,GAAO,EAAM,UAAU,OAAO,CAAW,EACzC,GAAgB,EAAe,UAAU,IAAI,CAAW,EAC5D,EAAQ,EACV,EAEM,GAAqB,CAAE,OAAQ,KAAgB,CAGnD,IAAM,GADJ,aAAc,QAAU,EAAG,QAAQ,CAAyB,EAAI,
|
|
1
|
+
{"version":3,"file":"clickdelegatefor.js","names":[],"sources":["../../../src/clickdelegatefor/clickdelegatefor.ts"],"sourcesContent":["// Adding support for click deletagtion, following\n// https://open-ui.org/components/link-area-delegation-explainer/\n// and https://github.com/openui/open-ui/issues/1104#issuecomment-3151387080\nimport { on, onHotReload, QUICK_EVENT } from '../utils/utils';\n\nconst CLASS_HOVER = ':click-delegate-hover';\nconst ATTR_CLICKDELEGATEFOR = 'data-clickdelegatefor';\nconst SELECTOR_CLICKDELEGATEFOR = `[${ATTR_CLICKDELEGATEFOR}]`;\nconst SELECTOR_SKIP =\n 'a,button,label,input,select,textarea,details,dialog,[role=\"button\"],[popover],[contenteditable]';\n\nconst handleClickDelegateFor = (event: MouseEvent) => {\n const isNewTab = event.button === 1 || event.metaKey || event.ctrlKey; // Middle click or cmd/ctrl + click should open in new tab\n const delegateTarget = event.button < 2 && getDelegateTarget(event); // Only accept left or middle clicks\n\n if (!delegateTarget || delegateTarget.contains(event.target as Node)) return; // Only proxy event if delegated target isn't part of the original target\n if (isNewTab && delegateTarget instanceof HTMLAnchorElement)\n return window.open(delegateTarget.href, undefined, delegateTarget.rel); // If middle click or cmd/ctrl click on link, open in new tab\n event.stopImmediatePropagation(); // We'll trigger a new click event anyway, so prevent actions on this one\n delegateTarget.click(); // Forward click to the clickable element\n};\n\nlet HOVER: Element | undefined;\nconst handleMouseOver = (event: Event) => {\n const delegateTarget = getDelegateTarget(event);\n if (HOVER === delegateTarget) return; // No change\n if (HOVER) HOVER.classList.remove(CLASS_HOVER);\n if (delegateTarget) delegateTarget.classList.add(CLASS_HOVER);\n HOVER = delegateTarget;\n};\n\nconst getDelegateTarget = ({ target: el }: Event) => {\n const scope =\n el instanceof Element ? el.closest(SELECTOR_CLICKDELEGATEFOR) : null;\n const id = scope?.getAttribute(ATTR_CLICKDELEGATEFOR);\n const target = (id && document.getElementById(id)) || undefined;\n const skip = target && (el as Element).closest(SELECTOR_SKIP); // Ignore if interactive\n\n return (!skip || skip === target) && !(target as HTMLInputElement)?.disabled\n ? target\n : undefined; // Skip disabled inputs\n};\n\nonHotReload('clickdelegatefor', () => [\n on(window, 'click auxclick', handleClickDelegateFor as EventListener, true), // Use capture to ensure we run before other click listeners\n on(document, 'mouseover', handleMouseOver, QUICK_EVENT), // Use passive for better performance\n]);\n"],"mappings":"yEAKA,MAAM,EAAc,wBACd,EAAwB,wBACxB,EAA4B,IAAI,EAAsB,GAItD,EAA0B,GAAsB,CACpD,IAAM,EAAW,EAAM,SAAW,GAAK,EAAM,SAAW,EAAM,QACxD,EAAiB,EAAM,OAAS,GAAK,EAAkB,CAAK,EAE9D,MAAC,GAAkB,EAAe,SAAS,EAAM,MAAc,GACnE,IAAI,GAAY,aAA0B,kBACxC,OAAO,OAAO,KAAK,EAAe,KAAM,IAAA,GAAW,EAAe,GAAG,EACvE,EAAM,yBAAyB,EAC/B,EAAe,MAAM,CAFkD,CAGzE,EAEA,IAAI,EACJ,MAAM,EAAmB,GAAiB,CACxC,IAAM,EAAiB,EAAkB,CAAK,EAC1C,IAAU,IACV,GAAO,EAAM,UAAU,OAAO,CAAW,EACzC,GAAgB,EAAe,UAAU,IAAI,CAAW,EAC5D,EAAQ,EACV,EAEM,GAAqB,CAAE,OAAQ,KAAgB,CAGnD,IAAM,GADJ,aAAc,QAAU,EAAG,QAAQ,CAAyB,EAAI,KAAA,EAChD,aAAa,CAAqB,EAC9C,EAAU,GAAM,SAAS,eAAe,CAAE,GAAM,IAAA,GAChD,EAAO,GAAW,EAAe,QAAQ,iGAAa,EAE5D,OAAQ,CAAC,GAAQ,IAAS,IAAW,CAAE,GAA6B,SAChE,EACA,IAAA,EACN,EAEA,EAAY,uBAA0B,CACpC,EAAG,OAAQ,iBAAkB,EAAyC,EAAI,EAC1E,EAAG,SAAU,YAAa,EAAiB,CAAW,CACxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":[],"sources":["../../../src/dialog/dialog.ts"],"sourcesContent":["import {\n attr,\n isBrowser,\n on,\n onHotReload,\n onMutation,\n QUICK_EVENT,\n} from '../utils/utils';\n\n// Polyfill closedby functionaliy in Safari\n// Also in Safari 26.2 where `closedBy` property is supported natively,\n// but no corresponding functionality/behavior is implemented.\nlet DOWN_INSIDE = false; // Prevent close if selecting text inside dialog\nconst handleClosedbyAny = ({\n type,\n target: el,\n clientX: x = 0,\n clientY: y = 0,\n}: Partial<MouseEvent>) => {\n if (type === 'pointerdown') {\n const r = (el as Element)?.closest?.('dialog')?.getBoundingClientRect();\n const isInside =\n r && r.top <= y && y <= r.bottom && r.left <= x && x <= r.right;\n\n DOWN_INSIDE = !!isInside;\n } else {\n const isDialog = el instanceof HTMLDialogElement;\n const isClose = isDialog && !DOWN_INSIDE && attr(el, 'closedby') === 'any';\n\n DOWN_INSIDE = false; // Reset on every pointerup\n if (isClose) requestAnimationFrame(() => el.open && el.close()); // Close if browser did not do it\n }\n};\n\n// Ensure buttons that trigger a modeal dialog has aria-haspopup=\"dialog\" for better screen reader experience\nconst BUTTONS = isBrowser() ? document.getElementsByTagName('button') : [];\nconst handleAriaAttributes = () => {\n for (const btn of BUTTONS)\n if (btn.getAttribute('command')?.endsWith('-modal'))\n btn.setAttribute('aria-haspopup', 'dialog'); // Using get/setAttribute for performance\n};\n\nconst handleCommand = ({ command, target }: Event & { command?: string }) =>\n command === '--show-non-modal' &&\n target instanceof HTMLDialogElement &&\n target.show();\n\nonHotReload('dialog', () => [\n on(document, 'command', handleCommand, QUICK_EVENT),\n on(document, 'pointerdown pointerup', handleClosedbyAny, QUICK_EVENT),\n onMutation(document, handleAriaAttributes, {\n attributeFilter: ['command'],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"kHAYA,IAAI,EAAc,GAClB,MAAM,GAAqB,CACzB,OACA,OAAQ,EACR,QAAS,EAAI,EACb,QAAS,EAAI,KACY,CACzB,GAAI,IAAS,cAAe,CAC1B,IAAM,EAAK,GAAgB,UAAU,QAAQ,
|
|
1
|
+
{"version":3,"file":"dialog.js","names":[],"sources":["../../../src/dialog/dialog.ts"],"sourcesContent":["import {\n attr,\n isBrowser,\n on,\n onHotReload,\n onMutation,\n QUICK_EVENT,\n} from '../utils/utils';\n\n// Polyfill closedby functionaliy in Safari\n// Also in Safari 26.2 where `closedBy` property is supported natively,\n// but no corresponding functionality/behavior is implemented.\nlet DOWN_INSIDE = false; // Prevent close if selecting text inside dialog\nconst handleClosedbyAny = ({\n type,\n target: el,\n clientX: x = 0,\n clientY: y = 0,\n}: Partial<MouseEvent>) => {\n if (type === 'pointerdown') {\n const r = (el as Element)?.closest?.('dialog')?.getBoundingClientRect();\n const isInside =\n r && r.top <= y && y <= r.bottom && r.left <= x && x <= r.right;\n\n DOWN_INSIDE = !!isInside;\n } else {\n const isDialog = el instanceof HTMLDialogElement;\n const isClose = isDialog && !DOWN_INSIDE && attr(el, 'closedby') === 'any';\n\n DOWN_INSIDE = false; // Reset on every pointerup\n if (isClose) requestAnimationFrame(() => el.open && el.close()); // Close if browser did not do it\n }\n};\n\n// Ensure buttons that trigger a modeal dialog has aria-haspopup=\"dialog\" for better screen reader experience\nconst BUTTONS = isBrowser() ? document.getElementsByTagName('button') : [];\nconst handleAriaAttributes = () => {\n for (const btn of BUTTONS)\n if (btn.getAttribute('command')?.endsWith('-modal'))\n btn.setAttribute('aria-haspopup', 'dialog'); // Using get/setAttribute for performance\n};\n\nconst handleCommand = ({ command, target }: Event & { command?: string }) =>\n command === '--show-non-modal' &&\n target instanceof HTMLDialogElement &&\n target.show();\n\nonHotReload('dialog', () => [\n on(document, 'command', handleCommand, QUICK_EVENT),\n on(document, 'pointerdown pointerup', handleClosedbyAny, QUICK_EVENT),\n onMutation(document, handleAriaAttributes, {\n attributeFilter: ['command'],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"kHAYA,IAAI,EAAc,GAClB,MAAM,GAAqB,CACzB,OACA,OAAQ,EACR,QAAS,EAAI,EACb,QAAS,EAAI,KACY,CACzB,GAAI,IAAS,cAAe,CAC1B,IAAM,EAAK,GAAgB,UAAU,QAAQ,CAAC,EAAE,sBAAsB,EAItE,EAAc,CAAC,EAFb,GAAK,EAAE,KAAO,GAAK,GAAK,EAAE,QAAU,EAAE,MAAQ,GAAK,GAAK,EAAE,MAG9D,KAAO,CAEL,IAAM,EADW,aAAc,mBACH,CAAC,GAAe,EAAK,EAAI,UAAU,IAAM,MAErE,EAAc,GACV,GAAS,0BAA4B,EAAG,MAAQ,EAAG,MAAM,CAAC,CAChE,CACF,EAGM,EAAU,EAAU,EAAI,SAAS,qBAAqB,QAAQ,EAAI,CAAC,EACnE,MAA6B,CACjC,IAAK,IAAM,KAAO,EACZ,EAAI,aAAa,SAAS,CAAC,EAAE,SAAS,QAAQ,GAChD,EAAI,aAAa,gBAAiB,QAAQ,CAChD,EAEM,GAAiB,CAAE,UAAS,YAChC,IAAY,oBACZ,aAAkB,mBAClB,EAAO,KAAK,EAEd,EAAY,aAAgB,CAC1B,EAAG,SAAU,UAAW,EAAe,CAAW,EAClD,EAAG,SAAU,wBAAyB,EAAmB,CAAW,EACpE,EAAW,SAAU,EAAsB,CACzC,gBAAiB,CAAC,SAAS,EAC3B,WAAY,GACZ,UAAW,GACX,QAAS,EACX,CAAC,CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-summary.js","names":[],"sources":["../../../src/error-summary/error-summary.ts"],"sourcesContent":["import {\n attr,\n customElements,\n DSElement,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-error-summary': DSErrorSummaryElement;\n }\n}\n\nexport class DSErrorSummaryElement extends DSElement {\n _unmutate?: () => void; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n on(this, 'animationend', this, QUICK_EVENT); // Using animationend to detect when element is visible\n attr(this, 'role', 'group');\n attr(this, 'tabindex', '-1');\n this._unmutate = onMutation(this, render, {\n childList: true,\n subtree: true,\n });\n this.focus();\n }\n handleEvent({ target }: Event) {\n if (target === this) this.focus(); // Ignore if animation event was triggered by child\n }\n disconnectedCallback() {\n off(this, 'animationend', this, QUICK_EVENT);\n this._unmutate?.();\n this._unmutate = undefined;\n }\n}\n\nconst render = (self: DSErrorSummaryElement) => {\n const label = attr(self, 'aria-label')?.trim();\n const labelledBy = attr(self, 'aria-labelledby')?.trim();\n const heading = self.querySelector('h2,h3,h4,h5,h6');\n if (heading && !label && !labelledBy) {\n attr(self, 'aria-labelledby', useId(heading));\n }\n if (!heading && !label && !labelledBy) {\n warn(\n 'Missing accessible name on:',\n self,\n '\\nAdd a heading (h2–h6), or set aria-label or aria-labelledby to provide an accessible name for screen readers.',\n );\n }\n};\n\ncustomElements.define('ds-error-summary', DSErrorSummaryElement);\n"],"mappings":"mJAkBA,IAAa,EAAb,cAA2C,CAAU,CACnD,UAEA,mBAAoB,CAClB,EAAG,KAAM,eAAgB,KAAM,CAAW,EAC1C,EAAK,KAAM,OAAQ,OAAO,EAC1B,EAAK,KAAM,WAAY,IAAI,EAC3B,KAAK,UAAY,EAAW,KAAM,EAAQ,CACxC,UAAW,GACX,QAAS,EACX,CAAC,EACD,KAAK,MAAM,CACb,CACA,YAAY,CAAE,UAAiB,CACzB,IAAW,MAAM,KAAK,MAAM,CAClC,CACA,sBAAuB,CACrB,EAAI,KAAM,eAAgB,KAAM,CAAW,EAC3C,KAAK,YAAY,EACjB,KAAK,UAAY,IAAA,EACnB,CACF,EAEA,MAAM,EAAU,GAAgC,CAC9C,IAAM,EAAQ,EAAK,EAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"error-summary.js","names":[],"sources":["../../../src/error-summary/error-summary.ts"],"sourcesContent":["import {\n attr,\n customElements,\n DSElement,\n off,\n on,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-error-summary': DSErrorSummaryElement;\n }\n}\n\nexport class DSErrorSummaryElement extends DSElement {\n _unmutate?: () => void; // Using underscore instead of private fields for backwards compatibility\n\n connectedCallback() {\n on(this, 'animationend', this, QUICK_EVENT); // Using animationend to detect when element is visible\n attr(this, 'role', 'group');\n attr(this, 'tabindex', '-1');\n this._unmutate = onMutation(this, render, {\n childList: true,\n subtree: true,\n });\n this.focus();\n }\n handleEvent({ target }: Event) {\n if (target === this) this.focus(); // Ignore if animation event was triggered by child\n }\n disconnectedCallback() {\n off(this, 'animationend', this, QUICK_EVENT);\n this._unmutate?.();\n this._unmutate = undefined;\n }\n}\n\nconst render = (self: DSErrorSummaryElement) => {\n const label = attr(self, 'aria-label')?.trim();\n const labelledBy = attr(self, 'aria-labelledby')?.trim();\n const heading = self.querySelector('h2,h3,h4,h5,h6');\n if (heading && !label && !labelledBy) {\n attr(self, 'aria-labelledby', useId(heading));\n }\n if (!heading && !label && !labelledBy) {\n warn(\n 'Missing accessible name on:',\n self,\n '\\nAdd a heading (h2–h6), or set aria-label or aria-labelledby to provide an accessible name for screen readers.',\n );\n }\n};\n\ncustomElements.define('ds-error-summary', DSErrorSummaryElement);\n"],"mappings":"mJAkBA,IAAa,EAAb,cAA2C,CAAU,CACnD,UAEA,mBAAoB,CAClB,EAAG,KAAM,eAAgB,KAAM,CAAW,EAC1C,EAAK,KAAM,OAAQ,OAAO,EAC1B,EAAK,KAAM,WAAY,IAAI,EAC3B,KAAK,UAAY,EAAW,KAAM,EAAQ,CACxC,UAAW,GACX,QAAS,EACX,CAAC,EACD,KAAK,MAAM,CACb,CACA,YAAY,CAAE,UAAiB,CACzB,IAAW,MAAM,KAAK,MAAM,CAClC,CACA,sBAAuB,CACrB,EAAI,KAAM,eAAgB,KAAM,CAAW,EAC3C,KAAK,YAAY,EACjB,KAAK,UAAY,IAAA,EACnB,CACF,EAEA,MAAM,EAAU,GAAgC,CAC9C,IAAM,EAAQ,EAAK,EAAM,YAAY,CAAC,EAAE,KAAK,EACvC,EAAa,EAAK,EAAM,iBAAiB,CAAC,EAAE,KAAK,EACjD,EAAU,EAAK,cAAc,gBAAgB,EAC/C,GAAW,CAAC,GAAS,CAAC,GACxB,EAAK,EAAM,kBAAmB,EAAM,CAAO,CAAC,EAE1C,CAAC,GAAW,CAAC,GAAS,CAAC,GACzB,EACE,8BACA,EACA;8GACF,CAEJ,EAEA,EAAe,OAAO,mBAAoB,CAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","names":[],"sources":["../../../src/field/field.ts"],"sourcesContent":["import {\n announce,\n attr,\n attrOrCSS,\n customElements,\n DSElement,\n debounce,\n isWindows,\n on,\n onHotReload,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\n// TODO: Document that Validation must be hidden with \"hidden\" attribute (or completely removed from DOM), not display: none\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-field': DSFieldElement;\n }\n}\n\nconst ATTR_INVALID = 'aria-invalid';\nconst ATTR_DESCRIBEDBY = 'aria-describedby';\nconst ATTR_INDETERMINATE = 'data-indeterminate';\nconst COUNTER_DEBOUNCE = isWindows() ? 800 : 200; // Longer debounce on Windows due to NVDA performance\nconst COUNTS = new WeakMap<HTMLInputElement, Element>(); // Using WeakMap so removed inputs/counts does not cause memory leaks\nconst FIELDS = new Map<DSFieldElement, string[]>(); // Map of Field and its describedby IDs so we can identify the ones we add/remove\nconst VALIDATIONS = new WeakSet<HTMLInputElement>(); // Used to ensure we only take control of aria-invalid if the current is or has been a validation element\nconst WARNING_MULTIPLE_INPUTS = `Fields should only have one input element. Use <fieldset> to group multiple fields:`;\n\nconst handleFieldMutations = (_doc: Node, records: MutationRecord[] = []) => {\n for (const { target } of records) {\n const isFieldset = target instanceof HTMLFieldSetElement;\n for (const [field] of FIELDS)\n if (isFieldset ? target.contains(field) : field.contains(target))\n handleFieldMutation(field);\n }\n};\n\nconst handleFieldMutation = (field: DSFieldElement) => {\n const labels: HTMLLabelElement[] = [];\n const nextDescs: string[] = []; // Keep track of descriptions we are adding in this mutation\n const prevDescs = FIELDS.get(field) || []; // Retrieve previously managed IDs for this field\n let input: HTMLInputElement | undefined;\n let counter: Element | undefined;\n let hasValidation = false;\n let invalid = false;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n if ((el as HTMLElement).hidden) continue; // Skip hidden elements except labels\n if (isInputLike(el)) {\n if (input) warn(WARNING_MULTIPLE_INPUTS, field);\n else input = el; // Only register if visible input\n } else {\n const type = el.getAttribute('data-field'); // Using getAttribute instead of attr for best performance\n if (type === 'counter') counter = el;\n if (type === 'validation') {\n nextDescs.unshift(useId(el));\n hasValidation = true;\n invalid = invalid || isInvalid(el);\n } else if (type) nextDescs.push(useId(el)); // Adds both counter and descriptions\n }\n }\n\n if (!input) return; // Do not warn about missing input as virtual DOM libraries might give false positives\n if (counter) COUNTS.set(input, counter);\n for (const label of labels) attr(label, 'for', useId(input));\n\n const fieldsetValidation = field\n .closest('fieldset')\n ?.querySelector<HTMLElement>(':scope > [data-field=\"validation\"]');\n\n // Connect fieldset validation to inputs\n if (fieldsetValidation && !fieldsetValidation?.hidden) {\n hasValidation = true;\n invalid = invalid || isInvalid(fieldsetValidation);\n nextDescs.unshift(useId(fieldsetValidation));\n }\n\n // Add support for data-indeterminate attribute as this normally can only be set by javascript\n const indeterminate = attr(input, ATTR_INDETERMINATE);\n if (indeterminate) input.indeterminate = indeterminate === 'true';\n\n // Expand click area to ds-field if radio/checkbox\n const isBoolish = input.type === 'radio' || input.type === 'checkbox';\n if (isBoolish) attr(field, 'data-clickdelegatefor', useId(input));\n\n // Setup aria-describedby, but repsect existing ids in aria-describedby\n const describedby = attr(input, ATTR_DESCRIBEDBY)?.trim().split(/\\s+/);\n const keep = describedby?.filter((id) => !prevDescs.includes(id)) || []; // Find non-ds-field-managed aria-describedby IDs\n attr(input, ATTR_DESCRIBEDBY, [...nextDescs, ...keep].join(' ') || null);\n FIELDS.set(field, nextDescs);\n\n // Only manage aria-invalid when field has validation elements, and aria-invalid does not already exist\n const hadValidation = VALIDATIONS.has(input);\n if (hasValidation && !hadValidation && !input.hasAttribute(ATTR_INVALID)) {\n attr(input, ATTR_INVALID, 'true');\n VALIDATIONS.add(input);\n } else if (!hasValidation && hadValidation) {\n attr(input, ATTR_INVALID, null); // Remove aria-invalid\n VALIDATIONS.delete(input);\n }\n\n handleFieldInput(input); // Update counter and textarea sizing\n};\n\n// Used as fallback in tests when CSS is not loaded\nconst TEXTS = {\n over: '%d tegn for mye',\n under: '%d tegn igjen',\n};\n\nconst handleFieldInput = (e: Event | Element) => {\n const input = ((e as Event).target || e) as HTMLInputElement;\n const counter = COUNTS.get(input);\n\n if (counter?.isConnected) {\n const limit = Number(attr(counter, 'data-limit')) || 0;\n const count = limit - input.value.length;\n const state = count < 0 ? 'over' : 'under';\n const label = (\n attrOrCSS(counter, `data-${state}`) || TEXTS[state]\n )?.replace('%d', `${Math.abs(count)}`);\n\n attr(counter, 'data-label', label); // Using attribute to prevent hydation errors, not using aria-label to make axe tests happy\n attr(counter, 'data-state', state);\n attr(counter, 'data-color', count < 0 ? 'danger' : null);\n\n // Only update live region when user is actually typing\n if ((e as Event).type === 'input' && label)\n debouncedCounterLiveRegion(input, label); // Debounce live region to avoid NVDA interupting announcing typed text\n }\n if (input instanceof HTMLTextAreaElement) {\n input.style.setProperty('--_ds-field-sizing', 'auto');\n input.style.setProperty('--_ds-field-sizing', `${input.scrollHeight}px`);\n }\n};\n\nconst debouncedCounterLiveRegion = debounce((input: Element, text: string) => {\n if (document.activeElement === input) announce(text); // Only announce if input is still focused\n}, COUNTER_DEBOUNCE);\n\nconst isInvalid = (el: Element) => el.getAttribute('data-color') !== 'success';\nconst isInputLike = (el: unknown): el is HTMLInputElement =>\n el instanceof HTMLElement &&\n 'validity' in el && // Adds support for custom elements implemeted with attachInternals()\n !(el instanceof HTMLButtonElement) && // But skip <button> elements\n (el as HTMLInputElement).type !== 'hidden'; // And skip input type=\"hidden\"\n\n// Custom element is used to performantly keep track of fields on the page\nexport class DSFieldElement extends DSElement {\n connectedCallback() {\n FIELDS.set(this, []); // Register field\n handleFieldMutation(this); // Initial setup\n }\n disconnectedCallback() {\n FIELDS.delete(this);\n }\n}\n\ncustomElements.define('ds-field', DSFieldElement);\n\nonHotReload('field', () => [\n on(document, 'input', handleFieldInput, QUICK_EVENT),\n onMutation(document, handleFieldMutations, {\n attributeFilter: [\n 'data-field',\n 'data-limit',\n 'hidden', // Needed to check validation visibility\n 'id', // Needed to sync label \"for\" when ID of input/selec/textarea changes\n 'value', // Needed to detect changes in controlled React inputs as they do not trigger input events\n ATTR_INDETERMINATE,\n ],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"qNAuBA,MAAM,EAAe,eACf,EAAmB,mBACnB,EAAqB,qBACrB,EAAmB,EAAU,EAAI,IAAM,IACvC,EAAS,IAAI,QACb,EAAS,IAAI,IACb,EAAc,IAAI,QAGlB,GAAwB,EAAY,EAA4B,CAAC,IAAM,CAC3E,IAAK,GAAM,CAAE,YAAY,EAAS,CAChC,IAAM,EAAa,aAAkB,oBACrC,IAAK,GAAM,CAAC,KAAU,GAChB,EAAa,EAAO,SAAS,CAAK,EAAI,EAAM,SAAS,CAAM,IAC7D,EAAoB,CAAK,CAC/B,CACF,EAEM,EAAuB,GAA0B,CACrD,IAAM,EAA6B,CAAC,EAC9B,EAAsB,CAAC,EACvB,EAAY,EAAO,IAAI,CAAK,GAAK,CAAC,EACpC,EACA,EACA,EAAgB,GAChB,EAAU,GAEd,IAAK,IAAM,KAAM,EAAM,qBAAqB,GAAG,EAC7C,GAAI,aAAc,kBAAkB,EAAO,KAAK,CAAE,EAC7C,GAAmB,OACxB,GAAI,EAAY,CAAE,EACZ,EAAO,EAAK,sFAAyB,CAAK,EACzC,EAAQ,MACR,CACL,IAAM,EAAO,EAAG,aAAa,YAAY,EACrC,IAAS,YAAW,EAAU,GAC9B,IAAS,cACX,EAAU,QAAQ,EAAM,CAAE,CAAC,EAC3B,EAAgB,GAChB,IAAqB,EAAU,CAAE,GACxB,GAAM,EAAU,KAAK,EAAM,CAAE,CAAC,CAC3C,CAGF,GAAI,CAAC,EAAO,OACR,GAAS,EAAO,IAAI,EAAO,CAAO,EACtC,IAAK,IAAM,KAAS,EAAQ,EAAK,EAAO,MAAO,EAAM,CAAK,CAAC,EAE3D,IAAM,EAAqB,EACxB,QAAQ,UAAU,GACjB,cAA2B,oCAAoC,EAG/D,GAAsB,CAAC,G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A2B,EAAO,CAAK,CAC3C,CACI,aAAiB,sBACnB,EAAM,MAAM,YAAY,qBAAsB,MAAM,EACpD,EAAM,MAAM,YAAY,qBAAsB,GAAG,EAAM,aAAa,GAAG,EAE3E,EAEM,EAA6B,GAAU,EAAgB,IAAiB,CACxE,SAAS,gBAAkB,GAAO,EAAS,CAAI,CACrD,EAAG,CAAgB,EAEb,EAAa,GAAgB,EAAG,aAAa,YAAY,IAAM,UAC/D,EAAe,GACnB,aAAc,aACd,aAAc,GACd,EAAE,aAAc,oBACf,EAAwB,OAAS,SAGpC,IAAa,EAAb,cAAoC,CAAU,CAC5C,mBAAoB,CAClB,EAAO,IAAI,KAAM,CAAC,CAAC,EACnB,EAAoB,IAAI,CAC1B,CACA,sBAAuB,CACrB,EAAO,OAAO,IAAI,CACpB,CACF,EAEA,EAAe,OAAO,WAAY,CAAc,EAEhD,EAAY,YAAe,CACzB,EAAG,SAAU,QAAS,EAAkB,CAAW,EACnD,EAAW,SAAU,EAAsB,CACzC,gBAAiB,CACf,aACA,aACA,SACA,KACA,QACA,CACF,EACA,WAAY,GACZ,UAAW,GACX,QAAS,EACX,CAAC,CACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"field.js","names":[],"sources":["../../../src/field/field.ts"],"sourcesContent":["import {\n announce,\n attr,\n attrOrCSS,\n customElements,\n DSElement,\n debounce,\n isWindows,\n on,\n onHotReload,\n onMutation,\n QUICK_EVENT,\n useId,\n warn,\n} from '../utils/utils';\n\n// TODO: Document that Validation must be hidden with \"hidden\" attribute (or completely removed from DOM), not display: none\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ds-field': DSFieldElement;\n }\n}\n\nconst ATTR_INVALID = 'aria-invalid';\nconst ATTR_DESCRIBEDBY = 'aria-describedby';\nconst ATTR_INDETERMINATE = 'data-indeterminate';\nconst COUNTER_DEBOUNCE = isWindows() ? 800 : 200; // Longer debounce on Windows due to NVDA performance\nconst COUNTS = new WeakMap<HTMLInputElement, Element>(); // Using WeakMap so removed inputs/counts does not cause memory leaks\nconst FIELDS = new Map<DSFieldElement, string[]>(); // Map of Field and its describedby IDs so we can identify the ones we add/remove\nconst VALIDATIONS = new WeakSet<HTMLInputElement>(); // Used to ensure we only take control of aria-invalid if the current is or has been a validation element\nconst WARNING_MULTIPLE_INPUTS = `Fields should only have one input element. Use <fieldset> to group multiple fields:`;\n\nconst handleFieldMutations = (_doc: Node, records: MutationRecord[] = []) => {\n for (const { target } of records) {\n const isFieldset = target instanceof HTMLFieldSetElement;\n for (const [field] of FIELDS)\n if (isFieldset ? target.contains(field) : field.contains(target))\n handleFieldMutation(field);\n }\n};\n\nconst handleFieldMutation = (field: DSFieldElement) => {\n const labels: HTMLLabelElement[] = [];\n const nextDescs: string[] = []; // Keep track of descriptions we are adding in this mutation\n const prevDescs = FIELDS.get(field) || []; // Retrieve previously managed IDs for this field\n let input: HTMLInputElement | undefined;\n let counter: Element | undefined;\n let hasValidation = false;\n let invalid = false;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n if ((el as HTMLElement).hidden) continue; // Skip hidden elements except labels\n if (isInputLike(el)) {\n if (input) warn(WARNING_MULTIPLE_INPUTS, field);\n else input = el; // Only register if visible input\n } else {\n const type = el.getAttribute('data-field'); // Using getAttribute instead of attr for best performance\n if (type === 'counter') counter = el;\n if (type === 'validation') {\n nextDescs.unshift(useId(el));\n hasValidation = true;\n invalid = invalid || isInvalid(el);\n } else if (type) nextDescs.push(useId(el)); // Adds both counter and descriptions\n }\n }\n\n if (!input) return; // Do not warn about missing input as virtual DOM libraries might give false positives\n if (counter) COUNTS.set(input, counter);\n for (const label of labels) attr(label, 'for', useId(input));\n\n const fieldsetValidation = field\n .closest('fieldset')\n ?.querySelector<HTMLElement>(':scope > [data-field=\"validation\"]');\n\n // Connect fieldset validation to inputs\n if (fieldsetValidation && !fieldsetValidation?.hidden) {\n hasValidation = true;\n invalid = invalid || isInvalid(fieldsetValidation);\n nextDescs.unshift(useId(fieldsetValidation));\n }\n\n // Add support for data-indeterminate attribute as this normally can only be set by javascript\n const indeterminate = attr(input, ATTR_INDETERMINATE);\n if (indeterminate) input.indeterminate = indeterminate === 'true';\n\n // Expand click area to ds-field if radio/checkbox\n const isBoolish = input.type === 'radio' || input.type === 'checkbox';\n if (isBoolish) attr(field, 'data-clickdelegatefor', useId(input));\n\n // Setup aria-describedby, but repsect existing ids in aria-describedby\n const describedby = attr(input, ATTR_DESCRIBEDBY)?.trim().split(/\\s+/);\n const keep = describedby?.filter((id) => !prevDescs.includes(id)) || []; // Find non-ds-field-managed aria-describedby IDs\n attr(input, ATTR_DESCRIBEDBY, [...nextDescs, ...keep].join(' ') || null);\n FIELDS.set(field, nextDescs);\n\n // Only manage aria-invalid when field has validation elements, and aria-invalid does not already exist\n const hadValidation = VALIDATIONS.has(input);\n if (hasValidation && !hadValidation && !input.hasAttribute(ATTR_INVALID)) {\n attr(input, ATTR_INVALID, 'true');\n VALIDATIONS.add(input);\n } else if (!hasValidation && hadValidation) {\n attr(input, ATTR_INVALID, null); // Remove aria-invalid\n VALIDATIONS.delete(input);\n }\n\n handleFieldInput(input); // Update counter and textarea sizing\n};\n\n// Used as fallback in tests when CSS is not loaded\nconst TEXTS = {\n over: '%d tegn for mye',\n under: '%d tegn igjen',\n};\n\nconst handleFieldInput = (e: Event | Element) => {\n const input = ((e as Event).target || e) as HTMLInputElement;\n const counter = COUNTS.get(input);\n\n if (counter?.isConnected) {\n const limit = Number(attr(counter, 'data-limit')) || 0;\n const count = limit - input.value.length;\n const state = count < 0 ? 'over' : 'under';\n const label = (\n attrOrCSS(counter, `data-${state}`) || TEXTS[state]\n )?.replace('%d', `${Math.abs(count)}`);\n\n attr(counter, 'data-label', label); // Using attribute to prevent hydation errors, not using aria-label to make axe tests happy\n attr(counter, 'data-state', state);\n attr(counter, 'data-color', count < 0 ? 'danger' : null);\n\n // Only update live region when user is actually typing\n if ((e as Event).type === 'input' && label)\n debouncedCounterLiveRegion(input, label); // Debounce live region to avoid NVDA interupting announcing typed text\n }\n if (input instanceof HTMLTextAreaElement) {\n input.style.setProperty('--_ds-field-sizing', 'auto');\n input.style.setProperty('--_ds-field-sizing', `${input.scrollHeight}px`);\n }\n};\n\nconst debouncedCounterLiveRegion = debounce((input: Element, text: string) => {\n if (document.activeElement === input) announce(text); // Only announce if input is still focused\n}, COUNTER_DEBOUNCE);\n\nconst isInvalid = (el: Element) => el.getAttribute('data-color') !== 'success';\nconst isInputLike = (el: unknown): el is HTMLInputElement =>\n el instanceof HTMLElement &&\n 'validity' in el && // Adds support for custom elements implemeted with attachInternals()\n !(el instanceof HTMLButtonElement) && // But skip <button> elements\n (el as HTMLInputElement).type !== 'hidden'; // And skip input type=\"hidden\"\n\n// Custom element is used to performantly keep track of fields on the page\nexport class DSFieldElement extends DSElement {\n connectedCallback() {\n FIELDS.set(this, []); // Register field\n handleFieldMutation(this); // Initial setup\n }\n disconnectedCallback() {\n FIELDS.delete(this);\n }\n}\n\ncustomElements.define('ds-field', DSFieldElement);\n\nonHotReload('field', () => [\n on(document, 'input', handleFieldInput, QUICK_EVENT),\n onMutation(document, handleFieldMutations, {\n attributeFilter: [\n 'data-field',\n 'data-limit',\n 'hidden', // Needed to check validation visibility\n 'id', // Needed to sync label \"for\" when ID of input/selec/textarea changes\n 'value', // Needed to detect changes in controlled React inputs as they do not trigger input events\n ATTR_INDETERMINATE,\n ],\n attributes: true,\n childList: true,\n subtree: true,\n }),\n]);\n"],"mappings":"qNAuBA,MAAM,EAAe,eACf,EAAmB,mBACnB,EAAqB,qBACrB,EAAmB,EAAU,EAAI,IAAM,IACvC,EAAS,IAAI,QACb,EAAS,IAAI,IACb,EAAc,IAAI,QAGlB,GAAwB,EAAY,EAA4B,CAAC,IAAM,CAC3E,IAAK,GAAM,CAAE,YAAY,EAAS,CAChC,IAAM,EAAa,aAAkB,oBACrC,IAAK,GAAM,CAAC,KAAU,GAChB,EAAa,EAAO,SAAS,CAAK,EAAI,EAAM,SAAS,CAA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