@zywave/zywave-api-toolkit-bundle
Version:
2 lines (1 loc) • 9.72 kB
JavaScript
var e=class extends Event{oldState;newState;constructor(e,{oldState:t="",newState:n="",...o}={}){super(e,o),this.oldState=String(t||""),this.newState=String(n||"")}},t=new WeakMap;function n(n,o,r){t.set(n,setTimeout((()=>{t.has(n)&&n.dispatchEvent(new e("toggle",{cancelable:!1,oldState:o,newState:r}))}),0))}var o=globalThis.ShadowRoot||function(){},r=globalThis.HTMLDialogElement||function(){},i=new WeakMap,a=new WeakMap,s=new WeakMap;function l(e){return s.get(e)||"hidden"}var c=new WeakMap;function u(e,t){return("auto"===e.popover||"manual"===e.popover)&&(!!e.isConnected&&((!t||"showing"===l(e))&&(!(!t&&"hidden"!==l(e))&&(!(e instanceof r&&e.hasAttribute("open"))&&document.fullscreenElement!==e))))}function p(e){return e?Array.from(a.get(e.ownerDocument)||[]).indexOf(e)+1:0}function f(e){const t=g(e),n=function(e){for(;e;){const t=e.popoverTargetElement;if(t instanceof HTMLElement)return t;if((e=e.parentElement||h(e))instanceof o&&(e=e.host),e instanceof Document)return}}(e);return p(t)>p(n)?t:n}function d(e){const t=a.get(e);for(const e of t||[]){if(e.isConnected)return e;t.delete(e)}return null}function h(e){return"function"==typeof e.getRootNode?e.getRootNode():e.parentNode?h(e.parentNode):e}function g(e){for(;e;){if(e instanceof HTMLElement&&"auto"===e.popover&&"showing"===s.get(e))return e;if((e=e instanceof Element&&e.assignedSlot||e.parentElement||h(e))instanceof o&&(e=e.host),e instanceof Document)return}}function m(e){return!(e.hidden||e instanceof o)&&((!(e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement||e instanceof HTMLFieldSetElement)||!e.disabled)&&(!(e instanceof HTMLInputElement&&"hidden"===e.type)&&(!(e instanceof HTMLAnchorElement&&""===e.href)&&("number"==typeof e.tabIndex&&-1!==e.tabIndex))))}function v(e){(function(e){if(e.shadowRoot&&!0!==e.shadowRoot.delegatesFocus)return null;let t=e;t.shadowRoot&&(t=t.shadowRoot);let n=t.querySelector("[autofocus]");if(n)return n;{const e=t.querySelectorAll("slot");for(const t of e){const e=t.assignedElements({flatten:!0});for(const t of e){if(t.hasAttribute("autofocus"))return t;if(n=t.querySelector("[autofocus]"),n)return n}}}const o=e.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let r=o.currentNode;for(;r;){if(m(r))return r;r=o.nextNode()}})(e)?.focus()}var w=new WeakMap;function b(t){if(!u(t,!1))return;const o=t.ownerDocument;if(!t.dispatchEvent(new e("beforetoggle",{cancelable:!0,oldState:"closed",newState:"open"})))return;if(!u(t,!1))return;let r=!1;if("auto"===t.popover){const e=t.getAttribute("popover");if(S(function(e){const t=new Map;let n=0;for(const o of a.get(e.ownerDocument)||[])t.set(o,n),n+=1;t.set(e,n),n+=1;let o=null;return function(e){const n=g(e);if(null===n)return null;const r=t.get(n);(null===o||t.get(o)<r)&&(o=n)}(e.parentElement||h(e)),o}(t)||o,!1,!0),e!==t.getAttribute("popover")||!u(t,!1))return}d(o)||(r=!0),w.delete(t);const l=o.activeElement;t.classList.add(":popover-open"),s.set(t,"showing"),i.has(o)||i.set(o,new Set),i.get(o).add(t),v(t),"auto"===t.popover&&(a.has(o)||a.set(o,new Set),a.get(o).add(t),A(c.get(t),!0)),r&&l&&"auto"===t.popover&&w.set(t,l),n(t,"closed","open")}function E(t,o=!1,r=!1){if(!u(t,!0))return;const l=t.ownerDocument;if("auto"===t.popover&&(S(t,o,r),!u(t,!0)))return;if(A(c.get(t),!1),c.delete(t),r&&(t.dispatchEvent(new e("beforetoggle",{oldState:"open",newState:"closed"})),!u(t,!0)))return;i.get(l)?.delete(t),a.get(l)?.delete(t),t.classList.remove(":popover-open"),s.set(t,"hidden"),r&&n(t,"open","closed");const p=w.get(t);p&&(w.delete(t),o&&p.focus())}function y(e,t=!1,n=!1){let o=d(e);for(;o;)E(o,t,n),o=d(e)}function S(e,t,n){const o=e.ownerDocument||e;if(e instanceof Document)return y(o,t,n);let r=null,i=!1;for(const t of a.get(o)||[])if(t===e)i=!0;else if(i){r=t;break}if(!i)return y(o,t,n);for(;r&&"showing"===l(r)&&a.get(o)?.size;)E(r,t,n)}var T=new WeakMap;function M(e){if(!e.isTrusted)return;const t=e.composedPath()[0];if(!t)return;const n=t.ownerDocument;if(!d(n))return;const o=f(t);if(o&&"pointerdown"===e.type)T.set(n,o);else if("pointerup"===e.type){const e=T.get(n)===o;T.delete(n),e&&S(o||n,!1,!0)}}var L=new WeakMap;function A(e,t=!1){if(!e)return;L.has(e)||L.set(e,e.getAttribute("aria-expanded"));const n=e.popoverTargetElement;if(n instanceof HTMLElement&&"auto"===n.popover)e.setAttribute("aria-expanded",String(t));else{const t=L.get(e);t?e.setAttribute("aria-expanded",t):e.removeAttribute("aria-expanded")}}var H=globalThis.ShadowRoot||function(){};function k(e,t,n){const o=e[t];Object.defineProperty(e,t,{value(e){return o.call(this,n(e))}})}var D=/(^|[^\\]):popover-open\b/g;function x(){const e="function"==typeof globalThis.CSSLayerBlockRule;return`\n${e?"@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 not (background-color: canvas) {\n :where([popover]) {\n background-color: white;\n color: black;\n }\n }\n\n (width: -moz-fit-content) {\n :where([popover]) {\n width: -moz-fit-content;\n height: -moz-fit-content;\n }\n }\n\n not (inset: 0) {\n :where([popover]) {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n }\n${e?"}":""}\n`}var R=null;function N(e){const t=x();if(null===R)try{(R=new CSSStyleSheet).replaceSync(t)}catch{R=!1}if(!1===R){const n=document.createElement("style");n.textContent=t,e instanceof Document?e.head.prepend(n):e.prepend(n)}else e.adoptedStyleSheets=[R,...e.adoptedStyleSheets]}"undefined"!=typeof HTMLElement&&"object"==typeof HTMLElement.prototype&&"popover"in HTMLElement.prototype||function(){if("undefined"==typeof window)return;function t(e){return e?.includes(":popover-open")&&(e=e.replace(D,"$1.\\:popover-open")),e}window.ToggleEvent=window.ToggleEvent||e,k(Document.prototype,"querySelector",t),k(Document.prototype,"querySelectorAll",t),k(Element.prototype,"querySelector",t),k(Element.prototype,"querySelectorAll",t),k(Element.prototype,"matches",t),k(Element.prototype,"closest",t),k(DocumentFragment.prototype,"querySelectorAll",t),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){if(!this.hasAttribute("popover"))return null;const e=(this.getAttribute("popover")||"").toLowerCase();return""===e||"auto"==e?"auto":"manual"},set(e){null===e?this.removeAttribute("popover"):this.setAttribute("popover",e)}},showPopover:{enumerable:!0,configurable:!0,value(){b(this)}},hidePopover:{enumerable:!0,configurable:!0,value(){E(this,!0,!0)}},togglePopover:{enumerable:!0,configurable:!0,value(e){"showing"===s.get(this)&&void 0===e||!1===e?E(this,!0,!0):void 0!==e&&!0!==e||b(this)}}});const n=Element.prototype.attachShadow;n&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(e){const t=n.call(this,e);return N(t),t}}});const o=HTMLElement.prototype.attachInternals;o&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){const e=o.call(this);return e.shadowRoot&&N(e.shadowRoot),e}}});const r=new WeakMap;function i(e){Object.defineProperties(e.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(e){if(null===e)this.removeAttribute("popovertarget"),r.delete(this);else{if(!(e instanceof Element))throw new TypeError("popoverTargetElement must be an element or null");this.setAttribute("popovertarget",""),r.set(this,e)}},get(){if("button"!==this.localName&&"input"!==this.localName)return null;if("input"===this.localName&&"reset"!==this.type&&"image"!==this.type&&"button"!==this.type)return null;if(this.disabled)return null;if(this.form&&"submit"===this.type)return null;const e=r.get(this);if(e&&e.isConnected)return e;if(e&&!e.isConnected)return r.delete(this),null;const t=h(this),n=this.getAttribute("popovertarget");return(t instanceof Document||t instanceof H)&&n&&t.getElementById(n)||null}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){const e=(this.getAttribute("popovertargetaction")||"").toLowerCase();return"show"===e||"hide"===e?e:"toggle"},set(e){this.setAttribute("popovertargetaction",e)}}})}i(HTMLButtonElement),i(HTMLInputElement);const a=e=>{const t=e.composedPath(),n=t[0];if(!(n instanceof Element)||n?.shadowRoot)return;const o=h(n);if(!(o instanceof H||o instanceof Document))return;const r=t.find((e=>e.matches?.("[popovertargetaction],[popovertarget]")));return r?(function(e){const t=e.popoverTargetElement;if(!(t instanceof HTMLElement))return;const n=l(t);"show"===e.popoverTargetAction&&"showing"===n||"hide"===e.popoverTargetAction&&"hidden"===n||("showing"===n?E(t,!0,!0):u(t,!1)&&(c.set(t,e),b(t)))}(r),void e.preventDefault()):void 0},p=e=>{const t=e.key,n=e.target;e.defaultPrevented||!n||"Escape"!==t&&"Esc"!==t||S(n.ownerDocument,!0,!0)};var f;(f=document).addEventListener("click",a),f.addEventListener("keydown",p),f.addEventListener("pointerdown",M),f.addEventListener("pointerup",M),N(document)}();