vanilla-breeze 0.6.2 → 0.7.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/custom-elements.json +6768 -6425
- package/dist/cdn/components/accordion-wc.js +1 -1
- package/dist/cdn/components/activity-feed.js +1 -1
- package/dist/cdn/components/ai-chat.js +6 -6
- package/dist/cdn/components/ai-summary.js +2 -2
- package/dist/cdn/components/analytics-panel.js +2 -2
- package/dist/cdn/components/audio-player.js +4 -4
- package/dist/cdn/components/audio-visualizer.js +2 -2
- package/dist/cdn/components/author-index.js +2 -2
- package/dist/cdn/components/brand-mark.js +1 -1
- package/dist/cdn/components/bread-crumb.js +1 -1
- package/dist/cdn/components/calendar-wc.js +2 -2
- package/dist/cdn/components/card-list.js +1 -1
- package/dist/cdn/components/carousel-wc.js +1 -1
- package/dist/cdn/components/change-set.js +1 -1
- package/dist/cdn/components/chart-wc.js +13 -13
- package/dist/cdn/components/chat-input.js +1 -1
- package/dist/cdn/components/chat-window.js +1 -1
- package/dist/cdn/components/color-picker.js +1 -1
- package/dist/cdn/components/combo-box.js +1 -1
- package/dist/cdn/components/command-palette.js +1 -1
- package/dist/cdn/components/comment-box.js +35 -35
- package/dist/cdn/components/comment-thread.js +38 -38
- package/dist/cdn/components/comment-wc.js +1 -1
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/consent-banner.js +1 -1
- package/dist/cdn/components/content-lens.js +1 -1
- package/dist/cdn/components/content-swap.js +1 -1
- package/dist/cdn/components/context-menu.js +1 -1
- package/dist/cdn/components/data-table.js +1 -1
- package/dist/cdn/components/date-picker.js +1 -1
- package/dist/cdn/components/day-view.js +1 -1
- package/dist/cdn/components/diagram-wc.js +2 -2
- package/dist/cdn/components/drag-surface.js +1 -1
- package/dist/cdn/components/drop-down.js +1 -1
- package/dist/cdn/components/emoji-picker.js +1 -1
- package/dist/cdn/components/flow-diagram.js +1 -1
- package/dist/cdn/components/foot-notes.js +1 -1
- package/dist/cdn/components/form-field.js +1 -1
- package/dist/cdn/components/geo-map.js +3 -3
- package/dist/cdn/components/glossary-index.js +1 -1
- package/dist/cdn/components/glossary-wc.js +1 -1
- package/dist/cdn/components/heading-links.js +1 -1
- package/dist/cdn/components/highlight-wc.js +2 -2
- package/dist/cdn/components/icon-wc.js +2 -2
- package/dist/cdn/components/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/manifest.json +58 -54
- package/dist/cdn/components/markdown-editor.js +25 -25
- package/dist/cdn/components/markdown-viewer.js +27 -27
- package/dist/cdn/components/nav-bar.js +1 -1
- package/dist/cdn/components/note-wc.js +2 -2
- package/dist/cdn/components/notification-wc.js +23 -23
- package/dist/cdn/components/page-info.js +6 -6
- package/dist/cdn/components/page-stats.js +1 -1
- package/dist/cdn/components/page-toc.js +1 -1
- package/dist/cdn/components/page-tools.js +1 -1
- package/dist/cdn/components/page-tour.js +1 -1
- package/dist/cdn/components/pager-wc.js +1 -1
- package/dist/cdn/components/poll-wc.js +1 -1
- package/dist/cdn/components/pop-over.js +1 -1
- package/dist/cdn/components/popularity-index.js +1 -1
- package/dist/cdn/components/print-page.js +1 -1
- package/dist/cdn/components/progress-tracker.js +1 -1
- package/dist/cdn/components/qr-code.js +1 -1
- package/dist/cdn/components/reaction-bar.js +1 -1
- package/dist/cdn/components/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +1 -1
- package/dist/cdn/components/score-card.js +2 -2
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/settings-panel.js +6 -6
- package/dist/cdn/components/share-wc.js +2 -2
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -1
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +1 -1
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/social-links.js +2 -0
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/status-wc.js +1 -1
- package/dist/cdn/components/stepper-wc.js +1 -1
- package/dist/cdn/components/tab-set.js +1 -1
- package/dist/cdn/components/text-reader.js +2 -2
- package/dist/cdn/components/theme-picker.js +20 -20
- package/dist/cdn/components/time-index.js +1 -1
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +2 -2
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +4 -4
- package/dist/cdn/components/trust-filter.js +1 -1
- package/dist/cdn/components/version-switcher.js +6 -6
- package/dist/cdn/components/video-player.js +4 -4
- package/dist/cdn/components/watch-wc.js +2 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/fonts/barlow-condensed-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii.full.css +1 -1
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +4 -4
- package/dist/cdn/packs/prototype.full.js +1 -1
- package/dist/cdn/packs/ui.full.js +19 -19
- package/dist/cdn/themes/8bit.tokens.json +8 -37
- package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999.css +1 -1
- package/dist/cdn/themes/alpha1999.tokens.json +3 -6
- package/dist/cdn/themes/art-deco-dark.tokens.json +3 -27
- package/dist/cdn/themes/art-deco.css +1 -1
- package/dist/cdn/themes/art-deco.tokens.json +5 -11
- package/dist/cdn/themes/bauhaus-dark.tokens.json +1 -1
- package/dist/cdn/themes/bauhaus.css +1 -1
- package/dist/cdn/themes/bauhaus.tokens.json +13 -7
- package/dist/cdn/themes/brutalist-dark.tokens.json +3 -27
- package/dist/cdn/themes/brutalist.tokens.json +5 -11
- package/dist/cdn/themes/catppuccin-frappe.css +1 -1
- package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte.css +1 -1
- package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-mocha.css +1 -1
- package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
- package/dist/cdn/themes/classic-dark.tokens.json +41 -41
- package/dist/cdn/themes/classic.tokens.json +25 -31
- package/dist/cdn/themes/claymorphism-dark.tokens.json +533 -161
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/claymorphism.tokens.json +531 -135
- package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
- package/dist/cdn/themes/clinical.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore.css +1 -1
- package/dist/cdn/themes/cottagecore.tokens.json +1 -1
- package/dist/cdn/themes/cyber.css +1 -1
- package/dist/cdn/themes/cyber.tokens.json +5 -11
- package/dist/cdn/themes/dawn-dark.tokens.json +3 -27
- package/dist/cdn/themes/dawn.css +1 -1
- package/dist/cdn/themes/dawn.tokens.json +1 -1
- package/dist/cdn/themes/dracula.tokens.json +1 -1
- package/dist/cdn/themes/dusk.tokens.json +1 -1
- package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
- package/dist/cdn/themes/editorial.tokens.json +19 -16
- package/dist/cdn/themes/financial-dark.tokens.json +1 -1
- package/dist/cdn/themes/financial.css +1 -1
- package/dist/cdn/themes/financial.tokens.json +1 -1
- package/dist/cdn/themes/genai.css +1 -1
- package/dist/cdn/themes/genai.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism-dark.tokens.json +233 -116
- package/dist/cdn/themes/glassmorphism.css +1 -1
- package/dist/cdn/themes/glassmorphism.tokens.json +233 -116
- package/dist/cdn/themes/government-dark.tokens.json +1 -1
- package/dist/cdn/themes/government.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox.css +1 -1
- package/dist/cdn/themes/gruvbox.tokens.json +1 -1
- package/dist/cdn/themes/high-noon-dark.tokens.json +1 -1
- package/dist/cdn/themes/high-noon.tokens.json +1 -1
- package/dist/cdn/themes/journal-dark.tokens.json +3 -27
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +21 -21
- package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
- package/dist/cdn/themes/kawaii.css +1 -1
- package/dist/cdn/themes/kawaii.tokens.json +1 -1
- package/dist/cdn/themes/magna-dark.tokens.json +1 -1
- package/dist/cdn/themes/magna.css +1 -1
- package/dist/cdn/themes/magna.tokens.json +2 -14
- package/dist/cdn/themes/manifest.json +25 -25
- package/dist/cdn/themes/midnight.tokens.json +1 -1
- package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
- package/dist/cdn/themes/minimal.tokens.json +25 -27
- package/dist/cdn/themes/modern-dark.tokens.json +41 -41
- package/dist/cdn/themes/modern.css +1 -1
- package/dist/cdn/themes/modern.tokens.json +21 -21
- package/dist/cdn/themes/nes-dark.tokens.json +3 -27
- package/dist/cdn/themes/nes.tokens.json +10 -39
- package/dist/cdn/themes/neumorphism-dark.tokens.json +266 -134
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/neumorphism.tokens.json +266 -134
- package/dist/cdn/themes/nord-dark.tokens.json +3 -27
- package/dist/cdn/themes/nord.css +1 -1
- package/dist/cdn/themes/nord.tokens.json +1 -1
- package/dist/cdn/themes/organic-dark.tokens.json +1 -1
- package/dist/cdn/themes/organic.tokens.json +5 -14
- package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine.css +1 -1
- package/dist/cdn/themes/rose-pine.tokens.json +1 -1
- package/dist/cdn/themes/rough-dark.tokens.json +1 -1
- package/dist/cdn/themes/rough.tokens.json +1 -1
- package/dist/cdn/themes/solarized-dark.tokens.json +1 -1
- package/dist/cdn/themes/solarized.tokens.json +1 -1
- package/dist/cdn/themes/startup-dark.tokens.json +1 -1
- package/dist/cdn/themes/startup.css +1 -1
- package/dist/cdn/themes/startup.tokens.json +1 -1
- package/dist/cdn/themes/super2026-dark.tokens.json +6 -30
- package/dist/cdn/themes/super2026.css +1 -1
- package/dist/cdn/themes/super2026.tokens.json +1 -1
- package/dist/cdn/themes/swiss-dark.tokens.json +4 -40
- package/dist/cdn/themes/swiss.tokens.json +34 -68
- package/dist/cdn/themes/terminal.tokens.json +286 -120
- package/dist/cdn/themes/tokyo-night-dark.tokens.json +3 -27
- package/dist/cdn/themes/tokyo-night.css +1 -1
- package/dist/cdn/themes/tokyo-night.tokens.json +1 -1
- package/dist/cdn/themes/vaporwave-dark.tokens.json +3 -27
- package/dist/cdn/themes/vaporwave.tokens.json +1 -1
- package/dist/cdn/themes/win9x-dark.tokens.json +5 -29
- package/dist/cdn/themes/win9x.tokens.json +9 -9
- package/dist/cdn/vanilla-breeze-autoload.js +113 -108
- package/dist/cdn/vanilla-breeze-charts.js +13 -13
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +80 -75
- package/dist/cdn/vanilla-breeze-extras.js +31 -31
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +133 -133
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var lt=window.matchMedia("(prefers-reduced-motion: reduce)");var F=new Map;function P(s,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=F.get(s);if(customElements.get(s)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=i){r.priority===i&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}F.set(s,n),customElements.define(s,t)}var E=class extends HTMLElement{#d=[];#n;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#d)t();this.#d=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#d.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#d)t();this.#d=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#n||(this.#n=this.attachInternals());let i=this.#n.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#n||(this.#n=t)}#t(){return this.constructor.formAssociated&&this.#n?this.#n:null}get validity(){return this.#t()?.validity}get validationMessage(){return this.#t()?.validationMessage??""}get willValidate(){return this.#t()?.willValidate??!1}get form(){return this.#t()?.form??null}checkValidity(){return this.#t()?.checkValidity()??!0}reportValidity(){return this.#t()?.reportValidity()??!0}};var R="popover"in HTMLElement.prototype;var W=["position:absolute","inline-size:1px","block-size:1px","padding:0","margin:-1px","overflow:hidden","clip-path:inset(50%)","white-space:nowrap","border:0"].join(";"),I=new WeakMap;function j(s,t){let e=I.get(t);e||I.set(t,e=new Map);let i=e.get(s);if(!i||!i.region.isConnected){let r=(t.ownerDocument||document).createElement("span");r.setAttribute("data-vb-announcer",s),r.setAttribute("role",s==="assertive"?"alert":"status"),r.setAttribute("aria-live",s),r.setAttribute("aria-atomic","true"),r.style.cssText=W,t.appendChild(r),i={region:r},e.set(s,i)}return i}function _(s,{politeness:t="polite",root:e}={}){let i=String(s??"").trim();if(!i||typeof document>"u")return null;let n=e||document.body;if(!n)return null;let a=j(t==="assertive"?"assertive":"polite",n);return clearTimeout(a.write),clearTimeout(a.clear),a.region.textContent="",a.write=setTimeout(()=>{a.region.textContent=i,a.clear=setTimeout(()=>{a.region.textContent=""},7e3)},50),a.region}function w(s,t,e,i){let n=`data-label-${t}`,a=s?.closest?.(`[${n}]`)?.getAttribute(n)||e;return i?a.replace(/\{(\w+)\}/g,(o,l)=>l in i?String(i[l]):o):a}var B=1500,U="[data-copy], [data-copy-target], [data-paste-target]",A={copied:"Copied to clipboard",pasted:"Pasted from clipboard","copy-failed":"Copy failed","copy-failed-selected":"Copy failed. Text selected, press Ctrl+C to copy","paste-failed":"Paste failed"},T=new WeakMap;function z(s){if(typeof document.execCommand!="function"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none",document.body.appendChild(e),e.select();let i=!1;try{i=document.execCommand("copy")}catch{i=!1}return e.remove(),t?.focus?.({preventScroll:!0}),i}function G(s){if(!s)return!1;if(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)return s.focus(),s.select(),!0;let t=window.getSelection?.();if(!t)return!1;let e=document.createRange();return e.selectNodeContents(s),t.removeAllRanges(),t.addRange(e),!t.isCollapsed}async function L(s,t={}){if(s==null||s==="")return!1;let{button:e,duration:i=B}=t,n=!1,r=null;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(s),n=!0}catch(o){r=o,n=z(s)}if(n)return k({button:e,duration:i,state:"copied",eventName:"copy:done",eventDetail:{text:s},message:t.announceMessage??w(e,"copied",A.copied)}),!0;let a=G(t.source);return k({button:e,duration:i,state:"failed",eventName:"copy:error",eventDetail:{text:s,error:r},message:t.failureMessage??w(e,"copy-failed",a?A["copy-failed-selected"]:A["copy-failed"])}),!1}function k({button:s,duration:t,message:e,eventDetail:i,state:n,eventName:r}){if(s){s.dataset.state=n;let a=T.get(s);a&&clearTimeout(a),T.set(s,setTimeout(()=>{s.dataset.state===n&&delete s.dataset.state,T.delete(s)},t)),s.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:i}))}_(e,{politeness:n==="failed"?"assertive":"polite"})}async function K(s,t={}){let{button:e,duration:i=B}=t,n;try{if(!navigator.clipboard?.readText)throw new Error("Clipboard API unavailable");n=await navigator.clipboard.readText()}catch(r){return k({button:e,duration:i,state:"failed",eventName:"paste:error",eventDetail:{target:s,error:r},message:t.failureMessage??w(e,"paste-failed",A["paste-failed"])}),null}return s&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement?s.value=n:s.textContent=n,s.dispatchEvent(new Event("input",{bubbles:!0}))),k({button:e,duration:i,state:"pasted",eventName:"paste:done",eventDetail:{text:n,target:s},message:t.announceMessage??w(e,"pasted",A.pasted)}),n}function O(s){let t=s.dataset.copyTarget;if(!t)return null;try{return document.querySelector(t)}catch{return null}}function Y(s){if(s.dataset.copy)return s.dataset.copy;let t=O(s);if(!t)return"";let e=s.dataset.copyAttr;return e?t.getAttribute(e)??"":t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value:t.textContent??""}function X(s){let t=s.target?.closest?.(U);if(!t||t.matches(':disabled, [aria-disabled="true"]'))return;if(t.dataset.pasteTarget){let i=null;try{i=document.querySelector(t.dataset.pasteTarget)}catch{}if(!i)return;K(i,{button:t});return}let e=Y(t);e&&L(e,{button:t,source:O(t)??void 0})}typeof document<"u"&&!document.__vbCopyDelegated&&(document.__vbCopyDelegated=!0,document.addEventListener("click",X));function b(s,t,e){t/=100,e/=100;let i=a=>(a+s/30)%12,n=t*Math.min(e,1-e),r=a=>e-n*Math.max(-1,Math.min(i(a)-3,9-i(a),1));return{r:Math.round(r(0)*255),g:Math.round(r(8)*255),b:Math.round(r(4)*255)}}function M(s,t,e,i=!1){s/=255,t/=255,e/=255;let n=Math.max(s,t,e),r=Math.min(s,t,e),a=(n+r)/2,o=0,l=0;if(n!==r){let h=n-r;switch(l=a>.5?h/(2-n-r):h/(n+r),n){case s:o=((t-e)/h+(t<e?6:0))/6;break;case t:o=((e-s)/h+2)/6;break;case e:o=((s-t)/h+4)/6;break}}return i?{h:o*360,s:l*100,l:a*100}:{h:Math.round(o*360),s:Math.round(l*100),l:Math.round(a*100)}}function J(s){s=s.replace(/^#/,""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=parseInt(s,16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function Q(s,t,e){return"#"+[s,t,e].map(i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0")).join("")}function p(s,t=!1){let{r:e,g:i,b:n}=J(s);return M(e,i,n,t)}function f(s,t,e){let{r:i,g:n,b:r}=b(s,t,e);return Q(i,n,r)}function c(s,t,e){return Math.max(t,Math.min(e,s))}function S(s){return s/=255,s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function H(s){let t=s<=.0031308?s*12.92:1.055*Math.pow(s,.4166666666666667)-.055;return Math.round(c(t,0,1)*255)}function Z(s,t,e){let i=S(s),n=S(t),r=S(e),a=.4122214708*i+.5363325363*n+.0514459929*r,o=.2119034982*i+.6806995451*n+.1073969566*r,l=.0883024619*i+.2817188376*n+.6299787005*r,h=Math.cbrt(a),u=Math.cbrt(o),d=Math.cbrt(l),m=.2104542553*h+.793617785*u-.0040720468*d,y=1.9779984951*h-2.428592205*u+.4505937099*d,x=.0259040371*h+.7827717662*u-.808675766*d,D=Math.sqrt(y*y+x*x),C=Math.atan2(x,y)*180/Math.PI;return C<0&&(C+=360),D<1e-4&&(C=0),{L:m,C:D,H:C}}function tt(s,t,e){let i=e*Math.PI/180,n=t*Math.cos(i),r=t*Math.sin(i),a=s+.3963377774*n+.2158037573*r,o=s-.1055613458*n-.0638541728*r,l=s-.0894841775*n-1.291485548*r,h=a**3,u=o**3,d=l**3,m=4.0767416621*h-3.3077115913*u+.2309699292*d,y=-1.2684380046*h+2.6097574011*u-.3413193965*d,x=-.0041960863*h-.7034186147*u+1.707614701*d;return{r:H(m),g:H(y),b:H(x)}}function N(s,t,e){let i=b(s,t,e);return Z(i.r,i.g,i.b)}function q(s,t,e,i=!1){let{r:n,g:r,b:a}=tt(s,t,e);return M(n,r,a,i)}function et(s,t,e){return f(s,t,e)}function it(s,t,e){let{r:i,g:n,b:r}=b(s,t,e);return`rgb(${i} ${n} ${r})`}function st(s,t,e){return`hsl(${Math.round(s)}deg ${Math.round(t)}% ${Math.round(e)}%)`}function nt(s,t,e){let{L:i,C:n,H:r}=N(s,t,e);return`oklch(${(i*100).toFixed(1)}% ${n.toFixed(3)} ${r.toFixed(1)}deg)`}function V(s,t,e,i){switch(s){case"rgb":return it(t,e,i);case"hsl":return st(t,e,i);case"oklch":return nt(t,e,i);default:return et(t,e,i)}}var g=["hex","rgb","hsl","oklch"],rt="hex",ot=/^#[0-9a-fA-F]{6}$/,v=8,at=0,$=class extends E{static formAssociated=!0;#d;#n;#t;#E;#g;#v;#a;#r;#y;#o;#k;#b;#f={};#x=rt;#c;#m;#u;#p=!1;#A=!1;#$=!1;#H=`cp${++at}`;#e=0;#i=100;#s=50;#M;static get observedAttributes(){return["disabled"]}constructor(){super(),this.#d=this.attachInternals(),this._adoptInternals(this.#d)}setup(){if(this.#n=this.querySelector(':scope > input[type="color"]'),!this.#n)return!1;if(!this.#$){let i=this.getAttribute("format");i&&g.includes(i)&&(this.#x=i),this.#$=!0}if(this.#M===void 0){let i=this.#n.defaultValue;this.#M=ot.test(i)?i.toLowerCase():this.#n.value||"#000000"}let t=p(this.#n.value||this.#M,!0);this.#e=t.h,this.#i=t.s,this.#s=t.l;let e=this.#n.getAttribute("name");return e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#n.removeAttribute("name")),this.#n.hasAttribute("disabled")&&(this.#n.removeAttribute("disabled"),this.hasAttribute("disabled")||this.setAttribute("disabled","")),this.#n.setAttribute("tabindex","-1"),this.#n.setAttribute("aria-hidden","true"),this.#n.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.listen(this.#n,"click",this.#I),this.#B(),this.#O(),this.#C(),this.#S(),this.#A=R,this.#A&&this.#a.setAttribute("popover","manual"),this.listen(document,"click",this.#tt),this.listen(this,"keydown",this.#_),this.#N(this.matches(":disabled")),!0}teardown(){this.#p=!1,this.removeAttribute("open"),window.removeEventListener("scroll",this.#w,{capture:!0}),window.removeEventListener("resize",this.#w),this.#t?.remove(),this.#a?.remove()}attributeChangedCallback(t){t==="disabled"&&this.#t&&this.#N(this.matches(":disabled"))}formDisabledCallback(t){this.#t&&this.#N(t)}#N(t){this.#t.disabled=t,t&&this.#L()}#I=t=>{t.preventDefault(),this.#t.disabled||this.#t.focus()};#_=t=>{t.key!=="Escape"||!this.#p||(t.preventDefault(),t.stopPropagation(),this.#L(),this.#t.focus())};#B(){this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="color-trigger",this.#t.setAttribute("aria-haspopup","dialog"),this.#t.setAttribute("aria-expanded","false"),this.#E=document.createElement("span"),this.#E.className="color-swatch",this.#g=document.createElement("span"),this.#g.className="color-hex",this.#g.id=`${this.#H}-value`,this.#t.appendChild(this.#E),this.#t.appendChild(this.#g);let t=[];for(let e of Array.from(this.#n.labels||[]))e.id||(e.id=`${this.#H}-label-${t.length}`),t.push(e.id);t.length===0&&(this.#v=document.createElement("span"),this.#v.className="visually-hidden",this.#v.id=`${this.#H}-name`,this.#v.textContent=this.#n.getAttribute("aria-label")||this.getAttribute("aria-label")||"Color",this.#t.prepend(this.#v),t.push(this.#v.id)),this.#t.setAttribute("aria-labelledby",[...t,this.#g.id].join(" ")),this.appendChild(this.#t),this.listen(this.#t,"click",()=>{this.#p?this.#L():this.#Z()})}#O(){this.#c=void 0,this.#m=void 0,this.#a=document.createElement("div"),this.#a.className="color-panel",this.#a.setAttribute("role","dialog"),this.#a.setAttribute("aria-label","Color picker"),this.#r=document.createElement("div"),this.#r.className="color-area",this.#r.setAttribute("role","slider"),this.#r.setAttribute("aria-label","Saturation and lightness"),this.#r.setAttribute("aria-valuemin","0"),this.#r.setAttribute("aria-valuemax","100"),this.#r.setAttribute("tabindex","0"),this.#y=document.createElement("div"),this.#y.className="color-area-thumb",this.#r.appendChild(this.#y),this.#a.appendChild(this.#r);let t=document.createElement("div");t.className="color-hue-wrap",this.#o=document.createElement("div"),this.#o.className="color-hue",this.#o.setAttribute("role","slider"),this.#o.setAttribute("aria-label","Hue"),this.#o.setAttribute("aria-valuemin","0"),this.#o.setAttribute("aria-valuemax","360"),this.#o.setAttribute("tabindex","0"),this.#k=document.createElement("div"),this.#k.className="color-hue-thumb",this.#o.appendChild(this.#k),t.appendChild(this.#o),this.#a.appendChild(t);let e=document.createElement("div");e.className="color-format-row";let i=document.createElement("label");i.className="color-format-label";let n=document.createElement("span");n.textContent="Format",this.#b=document.createElement("select"),this.#b.className="color-format-select";for(let o of g){let l=document.createElement("option");l.value=o,l.textContent=o.toUpperCase(),this.#b.appendChild(l)}this.#b.value=this.#x,i.appendChild(n),i.appendChild(this.#b),e.appendChild(i),this.#a.appendChild(e),this.listen(this.#b,"change",this.#q),this.#f.hex=this.#T("hex",[{label:"Hex",channel:"hex",kind:"text",maxLength:7}]),this.#f.rgb=this.#T("rgb",[{label:"R",channel:"r",kind:"number",min:0,max:255,step:1},{label:"G",channel:"g",kind:"number",min:0,max:255,step:1},{label:"B",channel:"b",kind:"number",min:0,max:255,step:1}]),this.#f.hsl=this.#T("hsl",[{label:"H",channel:"h",kind:"number",min:0,max:360,step:1},{label:"S",channel:"s",kind:"number",min:0,max:100,step:1},{label:"L",channel:"l",kind:"number",min:0,max:100,step:1}]),this.#f.oklch=this.#T("oklch",[{label:"L%",channel:"oL",kind:"number",min:0,max:100,step:.1},{label:"C",channel:"oC",kind:"number",min:0,max:.4,step:.001},{label:"H\xB0",channel:"oH",kind:"number",min:0,max:360,step:.1}]);for(let o of g)this.#a.appendChild(this.#f[o].wrapper);this.#D();let r=this.querySelector(":scope > datalist");if(r){this.#c=document.createElement("div"),this.#c.className="color-swatches",this.#c.setAttribute("role","group"),this.#c.setAttribute("aria-label","Preset colors");for(let o of r.querySelectorAll("option[value]")){let l=document.createElement("button");l.type="button",l.setAttribute("aria-pressed","false"),l.style.background=o.value,l.setAttribute("aria-label",o.textContent||o.value),l.setAttribute("data-color",o.value),this.#c.appendChild(l)}this.#a.appendChild(this.#c),this.listen(this.#c,"click",this.#X)}let a=document.createElement("div");a.className="color-actions","EyeDropper"in window&&(this.#m=document.createElement("button"),this.#m.type="button",this.#m.className="color-eyedropper",this.#m.setAttribute("aria-label","Pick color from screen"),this.#m.textContent="\u{1F4A7}",a.appendChild(this.#m),this.listen(this.#m,"click",this.#J)),this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="color-copy",this.#u.setAttribute("aria-label","Copy hex value"),this.#u.textContent="Copy",a.appendChild(this.#u),this.listen(this.#u,"click",this.#Q),this.#a.appendChild(a),this.appendChild(this.#a),this.listen(this.#r,"pointerdown",this.#V),this.listen(this.#r,"keydown",this.#W),this.listen(this.#o,"pointerdown",this.#j),this.listen(this.#o,"keydown",this.#U);for(let o of g){let l=o==="hex"?this.#z:o==="rgb"?this.#G:o==="hsl"?this.#K:this.#Y;for(let{el:h}of this.#f[o].inputs)this.listen(h,"change",l)}}#T(t,e){let i=document.createElement("div");i.className=`color-inputs color-inputs-${t}`,i.setAttribute("data-format",t);let n=[];for(let r of e){let a=document.createElement("label");a.className="color-input-label";let o=document.createElement("span");o.textContent=r.label;let l=document.createElement("input");l.type=r.kind,l.setAttribute("data-channel",r.channel),l.setAttribute("autocomplete","off"),l.setAttribute("spellcheck","false"),r.kind==="text"&&r.maxLength&&l.setAttribute("maxlength",String(r.maxLength)),r.kind==="number"&&(l.min=String(r.min),l.max=String(r.max),r.step!=null&&(l.step=String(r.step))),a.appendChild(o),a.appendChild(l),i.appendChild(a),n.push({el:l,channel:r.channel})}return{wrapper:i,inputs:n}}#D(){for(let t of g)this.#f[t].wrapper.hidden=t!==this.#x;this.#u&&this.#u.setAttribute("aria-label",`Copy ${this.#x.toUpperCase()} value`)}#q=()=>{let t=this.#b.value;g.includes(t)&&(this.#x=t,this.#D(),this.#C())};#V=t=>{t.preventDefault(),this.#r.setPointerCapture(t.pointerId),this.#F(t);let e=n=>this.#F(n),i=n=>{this.#r.releasePointerCapture(n.pointerId),this.#r.removeEventListener("pointermove",e),this.#r.removeEventListener("pointerup",i)};this.#r.addEventListener("pointermove",e),this.#r.addEventListener("pointerup",i)};#F(t){let e=this.#r.getBoundingClientRect(),i=c((t.clientX-e.left)/e.width,0,1),n=c((t.clientY-e.top)/e.height,0,1);this.#i=Math.round(i*100),this.#s=Math.round((1-n)*100),this.#h("pointer")}#W=t=>{let e=t.shiftKey?10:1;switch(this.#i=Math.round(this.#i),this.#s=Math.round(this.#s),t.key){case"ArrowRight":t.preventDefault(),this.#i=c(this.#i+e,0,100);break;case"ArrowLeft":t.preventDefault(),this.#i=c(this.#i-e,0,100);break;case"ArrowUp":t.preventDefault(),this.#s=c(this.#s+e,0,100);break;case"ArrowDown":t.preventDefault(),this.#s=c(this.#s-e,0,100);break;default:return}this.#h("keyboard")};#j=t=>{t.preventDefault(),this.#o.setPointerCapture(t.pointerId),this.#P(t);let e=n=>this.#P(n),i=n=>{this.#o.releasePointerCapture(n.pointerId),this.#o.removeEventListener("pointermove",e),this.#o.removeEventListener("pointerup",i)};this.#o.addEventListener("pointermove",e),this.#o.addEventListener("pointerup",i)};#P(t){let e=this.#o.getBoundingClientRect(),i=c((t.clientX-e.left)/e.width,0,1);this.#e=Math.round(i*360),this.#h("pointer")}#U=t=>{let e=t.shiftKey?10:1;switch(this.#e=Math.round(this.#e),t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#e=(this.#e+e)%361;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#e=(this.#e-e+361)%361;break;default:return}this.#h("keyboard")};#l(t,e){return this.#f[t].inputs.find(i=>i.channel===e)?.el}#z=()=>{let t=this.#l("hex","hex");if(!t)return;let e=t.value.trim();if(e.startsWith("#")||(e="#"+e),/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e)){let i=p(e,!0);this.#e=i.h,this.#i=i.s,this.#s=i.l,this.#h()}};#G=()=>{let t=c(Number(this.#l("rgb","r").value)||0,0,255),e=c(Number(this.#l("rgb","g").value)||0,0,255),i=c(Number(this.#l("rgb","b").value)||0,0,255),n=M(t,e,i,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h()};#K=()=>{let t=c(Number(this.#l("hsl","h").value)||0,0,360)%361,e=c(Number(this.#l("hsl","s").value)||0,0,100),i=c(Number(this.#l("hsl","l").value)||0,0,100);this.#e=t,this.#i=e,this.#s=i,this.#h()};#Y=()=>{let t=c(Number(this.#l("oklch","oL").value)||0,0,100)/100,e=c(Number(this.#l("oklch","oC").value)||0,0,.4),i=c(Number(this.#l("oklch","oH").value)||0,0,360),n=q(t,e,i,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h()};#X=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let i=e.getAttribute("data-color"),n=p(i,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h()};#J=async()=>{try{let e=await new window.EyeDropper().open(),i=p(e.sRGBHex,!0);this.#e=i.h,this.#i=i.s,this.#s=i.l,this.#h()}catch{}};#Q=()=>{let t=V(this.#x,this.#e,this.#i,this.#s);L(t,{button:this.#u,announceMessage:"Color copied"})};#h(t="internal"){this.#C(),this.#S();let e=f(this.#e,this.#i,this.#s),i=b(this.#e,this.#i,this.#s);this.dispatchEvent(new CustomEvent("color-picker:change",{bubbles:!0,detail:{hex:e,rgb:{r:i.r,g:i.g,b:i.b},hsl:{h:Math.round(this.#e),s:Math.round(this.#i),l:Math.round(this.#s)},source:t}}))}#C(){let t=f(this.#e,this.#i,this.#s),e=b(this.#e,this.#i,this.#s),i=f(this.#e,100,50);this.#E.style.background=t,this.#g.textContent=t,this.#r.style.setProperty("--area-hue",i),this.#y.style.left=`${this.#i}%`,this.#y.style.top=`${100-this.#s}%`,this.#y.style.background=t;let n=Math.round(this.#e),r=Math.round(this.#i),a=Math.round(this.#s);this.#r.setAttribute("aria-valuenow",String(r)),this.#r.setAttribute("aria-valuetext",`Saturation ${r}%, lightness ${a}%`),this.#k.style.left=`${this.#e/360*100}%`,this.#o.setAttribute("aria-valuenow",String(n)),this.#o.setAttribute("aria-valuetext",`Hue ${n}\xB0`);let o=(h,u,d)=>{let m=this.#l(h,u);m&&(m.value=String(d))};o("hex","hex",t),o("rgb","r",e.r),o("rgb","g",e.g),o("rgb","b",e.b),o("hsl","h",n),o("hsl","s",r),o("hsl","l",a);let l=N(this.#e,this.#i,this.#s);if(o("oklch","oL",(l.L*100).toFixed(1)),o("oklch","oC",l.C.toFixed(3)),o("oklch","oH",l.H.toFixed(1)),this.#c)for(let h of this.#c.querySelectorAll("button[data-color]")){let u=(h.getAttribute("data-color")||"").toLowerCase()===t.toLowerCase();h.setAttribute("aria-pressed",String(u))}}#Z(){if(!(this.#p||this.#t.disabled)){if(this.#p=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#A){try{this.#a.showPopover()}catch{}this.#R(),window.addEventListener("scroll",this.#w,{capture:!0,passive:!0}),window.addEventListener("resize",this.#w,{passive:!0})}requestAnimationFrame(()=>this.#r.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#L(){if(this.#p){if(this.#p=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#A){try{this.#a.hidePopover()}catch{}window.removeEventListener("scroll",this.#w,{capture:!0}),window.removeEventListener("resize",this.#w)}this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}}#R(){if(!this.#A)return;let t=this.#t.getBoundingClientRect(),e=this.#a.offsetWidth,i=this.#a.offsetHeight,n=document.documentElement.clientWidth,r=document.documentElement.clientHeight,o=getComputedStyle(this).direction==="rtl"?t.right-e:t.left;o=Math.min(o,n-e-v),o=Math.max(o,v);let l=t.bottom+4;l+i>r-v&&t.top-i-4>=v&&(l=t.top-i-4),l=Math.max(v,Math.min(l,r-i-v)),this.#a.style.setProperty("--panel-top",`${Math.round(l)}px`),this.#a.style.setProperty("--panel-left",`${Math.round(o)}px`)}#w=()=>{this.#p&&this.#R()};#tt=t=>{this.#p&&!this.contains(t.target)&&this.#L()};#S(){let t=f(this.#e,this.#i,this.#s);this.#d.setFormValue(t),this.#n.value=t,this.#n.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){if(!this.#t)return;let t=p(this.#M,!0);this.#e=t.h,this.#i=t.s,this.#s=t.l,this.#C(),this.#S()}formStateRestoreCallback(t){if(!t||!this.#t)return;let e=p(t,!0);this.#e=e.h,this.#i=e.s,this.#s=e.l,this.#C(),this.#S()}get value(){return f(this.#e,this.#i,this.#s)}set value(t){if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t))return;let e=f(this.#e,this.#i,this.#s).toLowerCase(),i=t.toLowerCase();if(e===i||e===i.toLowerCase())return;let n=p(t,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h("api")}};P("color-picker",$);export{$ as ColorPicker};
|
|
1
|
+
var ut=window.matchMedia("(prefers-reduced-motion: reduce)");var F=new Map;function R(i,t,e={}){let s=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:s},r=F.get(i);if(customElements.get(i)){if(!r||r.priority>=s){r&&r.priority===s&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=s){r.priority===s&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}F.set(i,n),customElements.define(i,t)}var C=class extends HTMLElement{#d=[];#n;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#d)t();this.#d=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,n){t.addEventListener(e,s,n),this.#d.push(()=>t.removeEventListener(e,s,n))}_reinit(){for(let t of this.#d)t();this.#d=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#n||(this.#n=this.attachInternals());let s=this.#n.states;try{e?s.add(t):s.delete(t)}catch{let n=`--${t}`;e?s.add(n):s.delete(n)}}_adoptInternals(t){this.#n||(this.#n=t)}#e(){return this.constructor.formAssociated&&this.#n?this.#n:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};var _="popover"in HTMLElement.prototype;var N=["position:absolute","inline-size:1px","block-size:1px","padding:0","margin:-1px","overflow:hidden","clip-path:inset(50%)","white-space:nowrap","border:0"].join(";"),I=new WeakMap;function W(i,t){let e=I.get(t);e||I.set(t,e=new Map);let s=e.get(i);if(!s||!s.region.isConnected){let r=(t.ownerDocument||document).createElement("span");r.setAttribute("data-vb-announcer",i),r.setAttribute("role",i==="assertive"?"alert":"status"),r.setAttribute("aria-live",i),r.setAttribute("aria-atomic","true"),r.style.cssText=N,t.appendChild(r),s={region:r},e.set(i,s)}return s}function B(i,{politeness:t="polite",root:e}={}){let s=String(i??"").trim();if(!s||typeof document>"u")return null;let n=e||document.body;if(!n)return null;let a=W(t==="assertive"?"assertive":"polite",n);return clearTimeout(a.write),clearTimeout(a.clear),a.region.textContent="",a.write=setTimeout(()=>{a.region.textContent=s,a.clear=setTimeout(()=>{a.region.textContent=""},7e3)},50),a.region}function x(i,t,e,s){let n=`data-label-${t}`,a=i?.closest?.(`[${n}]`)?.getAttribute(n)||e;return s?a.replace(/\{(\w+)\}/g,(o,l)=>l in s?String(s[l]):o):a}var q=1500,U="[data-copy], [data-copy-target], [data-paste-target]",A={copied:"Copied to clipboard",pasted:"Pasted from clipboard","copy-failed":"Copy failed","copy-failed-selected":"Copy failed. Text selected, press Ctrl+C to copy","paste-failed":"Paste failed"},T=new WeakMap;function z(i){if(typeof document.execCommand!="function"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=i,e.setAttribute("readonly",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none",document.body.appendChild(e),e.select();let s=!1;try{s=document.execCommand("copy")}catch{s=!1}return e.remove(),t?.focus?.({preventScroll:!0}),s}function K(i){if(!i)return!1;if(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement)return i.focus(),i.select(),!0;let t=window.getSelection?.();if(!t)return!1;let e=document.createRange();return e.selectNodeContents(i),t.removeAllRanges(),t.addRange(e),!t.isCollapsed}async function S(i,t={}){if(i==null||i==="")return!1;let{button:e,duration:s=q}=t,n=!1,r=null;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(i),n=!0}catch(o){r=o,n=z(i)}if(n)return k({button:e,duration:s,state:"copied",eventName:"copy:done",eventDetail:{text:i},message:t.announceMessage??x(e,"copied",A.copied)}),!0;let a=K(t.source);return k({button:e,duration:s,state:"failed",eventName:"copy:error",eventDetail:{text:i,error:r},message:t.failureMessage??x(e,"copy-failed",a?A["copy-failed-selected"]:A["copy-failed"])}),!1}function k({button:i,duration:t,message:e,eventDetail:s,state:n,eventName:r}){if(i){i.dataset.state=n;let a=T.get(i);a&&clearTimeout(a),T.set(i,setTimeout(()=>{i.dataset.state===n&&delete i.dataset.state,T.delete(i)},t)),i.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:s}))}B(e,{politeness:n==="failed"?"assertive":"polite"})}async function G(i,t={}){let{button:e,duration:s=q}=t,n;try{if(!navigator.clipboard?.readText)throw new Error("Clipboard API unavailable");n=await navigator.clipboard.readText()}catch(r){return k({button:e,duration:s,state:"failed",eventName:"paste:error",eventDetail:{target:i,error:r},message:t.failureMessage??x(e,"paste-failed",A["paste-failed"])}),null}return i&&(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement?i.value=n:i.textContent=n,i.dispatchEvent(new Event("input",{bubbles:!0}))),k({button:e,duration:s,state:"pasted",eventName:"paste:done",eventDetail:{text:n,target:i},message:t.announceMessage??x(e,"pasted",A.pasted)}),n}function O(i){let t=i.dataset.copyTarget;if(!t)return null;try{return document.querySelector(t)}catch{return null}}function Y(i){if(i.dataset.copy)return i.dataset.copy;let t=O(i);if(!t)return"";let e=i.dataset.copyAttr;return e?t.getAttribute(e)??"":t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value:t.textContent??""}function X(i){let t=i.target?.closest?.(U);if(!t||t.matches(':disabled, [aria-disabled="true"]'))return;if(t.dataset.pasteTarget){let s=null;try{s=document.querySelector(t.dataset.pasteTarget)}catch{}if(!s)return;G(s,{button:t});return}let e=Y(t);e&&S(e,{button:t,source:O(t)??void 0})}typeof document<"u"&&!document.__vbCopyDelegated&&(document.__vbCopyDelegated=!0,document.addEventListener("click",X));function b(i,t,e){t/=100,e/=100;let s=a=>(a+i/30)%12,n=t*Math.min(e,1-e),r=a=>e-n*Math.max(-1,Math.min(s(a)-3,9-s(a),1));return{r:Math.round(r(0)*255),g:Math.round(r(8)*255),b:Math.round(r(4)*255)}}function M(i,t,e,s=!1){i/=255,t/=255,e/=255;let n=Math.max(i,t,e),r=Math.min(i,t,e),a=(n+r)/2,o=0,l=0;if(n!==r){let h=n-r;switch(l=a>.5?h/(2-n-r):h/(n+r),n){case i:o=((t-e)/h+(t<e?6:0))/6;break;case t:o=((e-i)/h+2)/6;break;case e:o=((i-t)/h+4)/6;break}}return s?{h:o*360,s:l*100,l:a*100}:{h:Math.round(o*360),s:Math.round(l*100),l:Math.round(a*100)}}function J(i){i=i.replace(/^#/,""),i.length===3&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]);let t=parseInt(i,16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function Q(i,t,e){return"#"+[i,t,e].map(s=>Math.max(0,Math.min(255,Math.round(s))).toString(16).padStart(2,"0")).join("")}function p(i,t=!1){let{r:e,g:s,b:n}=J(i);return M(e,s,n,t)}function f(i,t,e){let{r:s,g:n,b:r}=b(i,t,e);return Q(s,n,r)}function c(i,t,e){return Math.max(t,Math.min(e,i))}function L(i){return i/=255,i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function $(i){let t=i<=.0031308?i*12.92:1.055*Math.pow(i,.4166666666666667)-.055;return Math.round(c(t,0,1)*255)}function Z(i,t,e){let s=L(i),n=L(t),r=L(e),a=.4122214708*s+.5363325363*n+.0514459929*r,o=.2119034982*s+.6806995451*n+.1073969566*r,l=.0883024619*s+.2817188376*n+.6299787005*r,h=Math.cbrt(a),u=Math.cbrt(o),d=Math.cbrt(l),m=.2104542553*h+.793617785*u-.0040720468*d,y=1.9779984951*h-2.428592205*u+.4505937099*d,w=.0259040371*h+.7827717662*u-.808675766*d,D=Math.sqrt(y*y+w*w),E=Math.atan2(w,y)*180/Math.PI;return E<0&&(E+=360),D<1e-4&&(E=0),{L:m,C:D,H:E}}function tt(i,t,e){let s=e*Math.PI/180,n=t*Math.cos(s),r=t*Math.sin(s),a=i+.3963377774*n+.2158037573*r,o=i-.1055613458*n-.0638541728*r,l=i-.0894841775*n-1.291485548*r,h=a**3,u=o**3,d=l**3,m=4.0767416621*h-3.3077115913*u+.2309699292*d,y=-1.2684380046*h+2.6097574011*u-.3413193965*d,w=-.0041960863*h-.7034186147*u+1.707614701*d;return{r:$(m),g:$(y),b:$(w)}}function H(i,t,e){let s=b(i,t,e);return Z(s.r,s.g,s.b)}function V(i,t,e,s=!1){let{r:n,g:r,b:a}=tt(i,t,e);return M(n,r,a,s)}function et(i,t,e){return f(i,t,e)}function st(i,t,e){let{r:s,g:n,b:r}=b(i,t,e);return`rgb(${s} ${n} ${r})`}function it(i,t,e){return`hsl(${Math.round(i)}deg ${Math.round(t)}% ${Math.round(e)}%)`}function nt(i,t,e){let{L:s,C:n,H:r}=H(i,t,e);return`oklch(${(s*100).toFixed(1)}% ${n.toFixed(3)} ${r.toFixed(1)}deg)`}function j(i,t,e,s){switch(i){case"rgb":return st(t,e,s);case"hsl":return it(t,e,s);case"oklch":return nt(t,e,s);default:return et(t,e,s)}}var v=["hex","rgb","hsl","oklch"],rt="hex",ot=/^#[0-9a-fA-F]{6}$/,g=8,at=0,P=class extends C{static formAssociated=!0;#d;#n;#e;#C;#v;#g;#o;#r;#y;#a;#k;#b;#f={};#w=rt;#h;#m;#u;#p=!1;#A=!1;#P=!1;#$=`cp${++at}`;#t=0;#i=100;#s=50;#M;static get observedAttributes(){return["disabled"]}constructor(){super(),this.#d=this.attachInternals(),this._adoptInternals(this.#d)}setup(){if(this.#n=this.querySelector(':scope > input[type="color"]'),!this.#n)return!1;if(!this.#P){let s=this.getAttribute("format");s&&v.includes(s)&&(this.#w=s),this.#P=!0}if(this.#M===void 0){let s=this.#n.defaultValue;this.#M=ot.test(s)?s.toLowerCase():this.#n.value||"#000000"}let t=p(this.#n.value||this.#M,!0);this.#t=t.h,this.#i=t.s,this.#s=t.l;let e=this.#n.getAttribute("name");return e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#n.removeAttribute("name")),this.#n.hasAttribute("disabled")&&(this.#n.removeAttribute("disabled"),this.hasAttribute("disabled")||this.setAttribute("disabled","")),this.#n.setAttribute("tabindex","-1"),this.#n.setAttribute("aria-hidden","true"),this.#n.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.listen(this.#n,"click",this.#I),this.#q(),this.#O(),this.#E(),this.#L(),this.#A=_,this.#A&&this.#o.setAttribute("popover","manual"),this.listen(document,"click",this.#tt),this.listen(this,"keydown",this.#B),this.#H(this.matches(":disabled")),!0}teardown(){this.#p=!1,this.removeAttribute("open"),window.removeEventListener("scroll",this.#x,{capture:!0}),window.removeEventListener("resize",this.#x),this.#e?.remove(),this.#o?.remove()}attributeChangedCallback(t){t==="disabled"&&this.#e&&this.#H(this.matches(":disabled"))}formDisabledCallback(t){this.#e&&this.#H(t)}#H(t){this.#e.disabled=t,t&&this.#S()}#I=t=>{t.preventDefault(),this.#e.disabled||this.#e.focus()};#B=t=>{t.key!=="Escape"||t.defaultPrevented||!this.#p||(t.preventDefault(),t.stopPropagation(),this.#S())};#q(){this.#e=document.createElement("button"),this.#e.type="button",this.#e.className="color-trigger",this.#e.setAttribute("aria-haspopup","dialog"),this.#e.setAttribute("aria-expanded","false"),this.#C=document.createElement("span"),this.#C.className="color-swatch",this.#v=document.createElement("span"),this.#v.className="color-hex",this.#v.id=`${this.#$}-value`,this.#e.appendChild(this.#C),this.#e.appendChild(this.#v);let t=[];for(let e of Array.from(this.#n.labels||[]))e.id||(e.id=`${this.#$}-label-${t.length}`),t.push(e.id);t.length===0&&(this.#g=document.createElement("span"),this.#g.className="visually-hidden",this.#g.id=`${this.#$}-name`,this.#g.textContent=this.#n.getAttribute("aria-label")||this.getAttribute("aria-label")||"Color",this.#e.prepend(this.#g),t.push(this.#g.id)),this.#e.setAttribute("aria-labelledby",[...t,this.#v.id].join(" ")),this.appendChild(this.#e),this.listen(this.#e,"click",()=>{this.#p?this.#S():this.#Z()})}#O(){this.#h=void 0,this.#m=void 0,this.#o=document.createElement("div"),this.#o.className="color-panel",this.#o.setAttribute("role","dialog"),this.#o.setAttribute("aria-label","Color picker"),this.#r=document.createElement("div"),this.#r.className="color-area",this.#r.setAttribute("role","slider"),this.#r.setAttribute("aria-label","Saturation and lightness"),this.#r.setAttribute("aria-valuemin","0"),this.#r.setAttribute("aria-valuemax","100"),this.#r.setAttribute("tabindex","0"),this.#y=document.createElement("div"),this.#y.className="color-area-thumb",this.#r.appendChild(this.#y),this.#o.appendChild(this.#r);let t=document.createElement("div");t.className="color-hue-wrap",this.#a=document.createElement("div"),this.#a.className="color-hue",this.#a.setAttribute("role","slider"),this.#a.setAttribute("aria-label","Hue"),this.#a.setAttribute("aria-valuemin","0"),this.#a.setAttribute("aria-valuemax","360"),this.#a.setAttribute("tabindex","0"),this.#k=document.createElement("div"),this.#k.className="color-hue-thumb",this.#a.appendChild(this.#k),t.appendChild(this.#a),this.#o.appendChild(t);let e=document.createElement("div");e.className="color-format-row";let s=document.createElement("label");s.className="color-format-label";let n=document.createElement("span");n.textContent="Format",this.#b=document.createElement("select"),this.#b.className="color-format-select";for(let o of v){let l=document.createElement("option");l.value=o,l.textContent=o.toUpperCase(),this.#b.appendChild(l)}this.#b.value=this.#w,s.appendChild(n),s.appendChild(this.#b),e.appendChild(s),this.#o.appendChild(e),this.listen(this.#b,"change",this.#V),this.#f.hex=this.#T("hex",[{label:"Hex",channel:"hex",kind:"text",maxLength:7}]),this.#f.rgb=this.#T("rgb",[{label:"R",channel:"r",kind:"number",min:0,max:255,step:1},{label:"G",channel:"g",kind:"number",min:0,max:255,step:1},{label:"B",channel:"b",kind:"number",min:0,max:255,step:1}]),this.#f.hsl=this.#T("hsl",[{label:"H",channel:"h",kind:"number",min:0,max:360,step:1},{label:"S",channel:"s",kind:"number",min:0,max:100,step:1},{label:"L",channel:"l",kind:"number",min:0,max:100,step:1}]),this.#f.oklch=this.#T("oklch",[{label:"L%",channel:"oL",kind:"number",min:0,max:100,step:.1},{label:"C",channel:"oC",kind:"number",min:0,max:.4,step:.001},{label:"H\xB0",channel:"oH",kind:"number",min:0,max:360,step:.1}]);for(let o of v)this.#o.appendChild(this.#f[o].wrapper);this.#D();let r=this.querySelector(":scope > datalist");if(r){this.#h=document.createElement("div"),this.#h.className="color-swatches",this.#h.setAttribute("role","group"),this.#h.setAttribute("aria-label","Preset colors");for(let o of r.querySelectorAll("option[value]")){let l=document.createElement("button");l.type="button",l.setAttribute("aria-pressed","false"),l.style.background=o.value,l.setAttribute("aria-label",o.textContent||o.value),l.setAttribute("data-color",o.value),this.#h.appendChild(l)}this.#o.appendChild(this.#h),this.listen(this.#h,"click",this.#X)}let a=document.createElement("div");a.className="color-actions","EyeDropper"in window&&(this.#m=document.createElement("button"),this.#m.type="button",this.#m.className="color-eyedropper",this.#m.setAttribute("aria-label","Pick color from screen"),this.#m.textContent="\u{1F4A7}",a.appendChild(this.#m),this.listen(this.#m,"click",this.#J)),this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="color-copy",this.#u.setAttribute("aria-label","Copy hex value"),this.#u.textContent="Copy",a.appendChild(this.#u),this.listen(this.#u,"click",this.#Q),this.#o.appendChild(a),this.appendChild(this.#o),this.listen(this.#r,"pointerdown",this.#j),this.listen(this.#r,"keydown",this.#N),this.listen(this.#a,"pointerdown",this.#W),this.listen(this.#a,"keydown",this.#U);for(let o of v){let l=o==="hex"?this.#z:o==="rgb"?this.#K:o==="hsl"?this.#G:this.#Y;for(let{el:h}of this.#f[o].inputs)this.listen(h,"change",l)}}#T(t,e){let s=document.createElement("div");s.className=`color-inputs color-inputs-${t}`,s.setAttribute("data-format",t);let n=[];for(let r of e){let a=document.createElement("label");a.className="color-input-label";let o=document.createElement("span");o.textContent=r.label;let l=document.createElement("input");l.type=r.kind,l.setAttribute("data-channel",r.channel),l.setAttribute("autocomplete","off"),l.setAttribute("spellcheck","false"),r.kind==="text"&&r.maxLength&&l.setAttribute("maxlength",String(r.maxLength)),r.kind==="number"&&(l.min=String(r.min),l.max=String(r.max),r.step!=null&&(l.step=String(r.step))),a.appendChild(o),a.appendChild(l),s.appendChild(a),n.push({el:l,channel:r.channel})}return{wrapper:s,inputs:n}}#D(){for(let t of v)this.#f[t].wrapper.hidden=t!==this.#w;this.#u&&this.#u.setAttribute("aria-label",`Copy ${this.#w.toUpperCase()} value`)}#V=()=>{let t=this.#b.value;v.includes(t)&&(this.#w=t,this.#D(),this.#E())};#j=t=>{t.preventDefault(),this.#r.setPointerCapture(t.pointerId),this.#F(t);let e=n=>this.#F(n),s=n=>{this.#r.releasePointerCapture(n.pointerId),this.#r.removeEventListener("pointermove",e),this.#r.removeEventListener("pointerup",s)};this.#r.addEventListener("pointermove",e),this.#r.addEventListener("pointerup",s)};#F(t){let e=this.#r.getBoundingClientRect(),s=c((t.clientX-e.left)/e.width,0,1),n=c((t.clientY-e.top)/e.height,0,1);this.#i=Math.round(s*100),this.#s=Math.round((1-n)*100),this.#c("pointer")}#N=t=>{let e=t.shiftKey?10:1;switch(this.#i=Math.round(this.#i),this.#s=Math.round(this.#s),t.key){case"ArrowRight":t.preventDefault(),this.#i=c(this.#i+e,0,100);break;case"ArrowLeft":t.preventDefault(),this.#i=c(this.#i-e,0,100);break;case"ArrowUp":t.preventDefault(),this.#s=c(this.#s+e,0,100);break;case"ArrowDown":t.preventDefault(),this.#s=c(this.#s-e,0,100);break;case"Home":t.preventDefault(),this.#i=0;break;case"End":t.preventDefault(),this.#i=100;break;case"PageUp":t.preventDefault(),this.#s=c(this.#s+10,0,100);break;case"PageDown":t.preventDefault(),this.#s=c(this.#s-10,0,100);break;default:return}this.#c("keyboard")};#W=t=>{t.preventDefault(),this.#a.setPointerCapture(t.pointerId),this.#R(t);let e=n=>this.#R(n),s=n=>{this.#a.releasePointerCapture(n.pointerId),this.#a.removeEventListener("pointermove",e),this.#a.removeEventListener("pointerup",s)};this.#a.addEventListener("pointermove",e),this.#a.addEventListener("pointerup",s)};#R(t){let e=this.#a.getBoundingClientRect(),s=c((t.clientX-e.left)/e.width,0,1);this.#t=Math.round(s*360),this.#c("pointer")}#U=t=>{let e=t.shiftKey?10:1;switch(this.#t=Math.round(this.#t),t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#t=(this.#t+e)%361;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#t=(this.#t-e+361)%361;break;case"PageUp":t.preventDefault(),this.#t=c(this.#t+10,0,360);break;case"PageDown":t.preventDefault(),this.#t=c(this.#t-10,0,360);break;case"Home":t.preventDefault(),this.#t=0;break;case"End":t.preventDefault(),this.#t=360;break;default:return}this.#c("keyboard")};#l(t,e){return this.#f[t].inputs.find(s=>s.channel===e)?.el}#z=()=>{let t=this.#l("hex","hex");if(!t)return;let e=t.value.trim();if(e.startsWith("#")||(e="#"+e),/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e)){let s=p(e,!0);this.#t=s.h,this.#i=s.s,this.#s=s.l,this.#c()}};#K=()=>{let t=c(Number(this.#l("rgb","r").value)||0,0,255),e=c(Number(this.#l("rgb","g").value)||0,0,255),s=c(Number(this.#l("rgb","b").value)||0,0,255),n=M(t,e,s,!0);this.#t=n.h,this.#i=n.s,this.#s=n.l,this.#c()};#G=()=>{let t=c(Number(this.#l("hsl","h").value)||0,0,360)%361,e=c(Number(this.#l("hsl","s").value)||0,0,100),s=c(Number(this.#l("hsl","l").value)||0,0,100);this.#t=t,this.#i=e,this.#s=s,this.#c()};#Y=()=>{let t=c(Number(this.#l("oklch","oL").value)||0,0,100)/100,e=c(Number(this.#l("oklch","oC").value)||0,0,.4),s=c(Number(this.#l("oklch","oH").value)||0,0,360),n=V(t,e,s,!0);this.#t=n.h,this.#i=n.s,this.#s=n.l,this.#c()};#X=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let s=e.getAttribute("data-color"),n=p(s,!0);this.#t=n.h,this.#i=n.s,this.#s=n.l,this.#c()};#J=async()=>{try{let e=await new window.EyeDropper().open(),s=p(e.sRGBHex,!0);this.#t=s.h,this.#i=s.s,this.#s=s.l,this.#c()}catch{}};#Q=()=>{let t=j(this.#w,this.#t,this.#i,this.#s);S(t,{button:this.#u,announceMessage:"Color copied"})};#c(t="internal"){this.#E(),this.#L();let e=f(this.#t,this.#i,this.#s),s=b(this.#t,this.#i,this.#s);this.dispatchEvent(new CustomEvent("color-picker:change",{bubbles:!0,detail:{hex:e,rgb:{r:s.r,g:s.g,b:s.b},hsl:{h:Math.round(this.#t),s:Math.round(this.#i),l:Math.round(this.#s)},source:t}}))}#E(){let t=f(this.#t,this.#i,this.#s),e=b(this.#t,this.#i,this.#s),s=f(this.#t,100,50);this.#C.style.background=t,this.#v.textContent=t,this.#r.style.setProperty("--area-hue",s),this.#y.style.left=`${this.#i}%`,this.#y.style.top=`${100-this.#s}%`,this.#y.style.background=t;let n=Math.round(this.#t),r=Math.round(this.#i),a=Math.round(this.#s);this.#r.setAttribute("aria-valuenow",String(r)),this.#r.setAttribute("aria-valuetext",(this.getAttribute("data-label-area-value")||"Saturation {s}%, lightness {l}%").replaceAll("{s}",String(r)).replaceAll("{l}",String(a))),this.#k.style.left=`${this.#t/360*100}%`,this.#a.setAttribute("aria-valuenow",String(n)),this.#a.setAttribute("aria-valuetext",`Hue ${n}\xB0`);let o=(h,u,d)=>{let m=this.#l(h,u);m&&(m.value=String(d))};o("hex","hex",t),o("rgb","r",e.r),o("rgb","g",e.g),o("rgb","b",e.b),o("hsl","h",n),o("hsl","s",r),o("hsl","l",a);let l=H(this.#t,this.#i,this.#s);if(o("oklch","oL",(l.L*100).toFixed(1)),o("oklch","oC",l.C.toFixed(3)),o("oklch","oH",l.H.toFixed(1)),this.#h)for(let h of this.#h.querySelectorAll("button[data-color]")){let u=(h.getAttribute("data-color")||"").toLowerCase()===t.toLowerCase();h.setAttribute("aria-pressed",String(u))}}#Z(){if(!(this.#p||this.#e.disabled)){if(this.#p=!0,this.setAttribute("open",""),this.#e.setAttribute("aria-expanded","true"),this.#A){try{this.#o.showPopover()}catch{}this.#_(),window.addEventListener("scroll",this.#x,{capture:!0,passive:!0}),window.addEventListener("resize",this.#x,{passive:!0})}requestAnimationFrame(()=>this.#r.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#S(){if(!this.#p)return;let t=this.#o.contains(document.activeElement);if(this.#p=!1,this.removeAttribute("open"),this.#e.setAttribute("aria-expanded","false"),this.#A){try{this.#o.hidePopover()}catch{}window.removeEventListener("scroll",this.#x,{capture:!0}),window.removeEventListener("resize",this.#x)}t&&this.#e.isConnected&&!this.#e.disabled&&this.#e.focus(),this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}#_(){if(!this.#A)return;let t=this.#e.getBoundingClientRect(),e=this.#o.offsetWidth,s=this.#o.offsetHeight,n=document.documentElement.clientWidth,r=document.documentElement.clientHeight,o=getComputedStyle(this).direction==="rtl"?t.right-e:t.left;o=Math.min(o,n-e-g),o=Math.max(o,g);let l=t.bottom+4;l+s>r-g&&t.top-s-4>=g&&(l=t.top-s-4),l=Math.max(g,Math.min(l,r-s-g)),this.#o.style.setProperty("--panel-top",`${Math.round(l)}px`),this.#o.style.setProperty("--panel-left",`${Math.round(o)}px`)}#x=()=>{this.#p&&this.#_()};#tt=t=>{this.#p&&!this.contains(t.target)&&this.#S()};#L(){let t=f(this.#t,this.#i,this.#s);this.#d.setFormValue(t),this.#n.value=t,this.#n.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){if(!this.#e)return;let t=p(this.#M,!0);this.#t=t.h,this.#i=t.s,this.#s=t.l,this.#E(),this.#L()}formStateRestoreCallback(t){if(!t||!this.#e)return;let e=p(t,!0);this.#t=e.h,this.#i=e.s,this.#s=e.l,this.#E(),this.#L()}get value(){return f(this.#t,this.#i,this.#s)}set value(t){if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t))return;let e=f(this.#t,this.#i,this.#s).toLowerCase(),s=t.toLowerCase();if(e===s||e===s.toLowerCase())return;let n=p(t,!0);this.#t=n.h,this.#i=n.s,this.#s=n.l,this.#c("api")}};R("color-picker",P);export{P as ColorPicker};
|
|
2
2
|
//# sourceMappingURL=color-picker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var N=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function p(h,t,e={}){let i=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=E.get(h);if(customElements.get(h)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${h}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(h,o),customElements.define(h,t)}var d=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,o){t.addEventListener(e,i,o),this.#e.push(()=>t.removeEventListener(e,i,o))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{e?i.add(t):i.delete(t)}catch{let o=`--${t}`;e?i.add(o):i.delete(o)}}_adoptInternals(t){this.#t||(this.#t=t)}#i(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#i()?.validity}get validationMessage(){return this.#i()?.validationMessage??""}get willValidate(){return this.#i()?.willValidate??!1}get form(){return this.#i()?.form??null}checkValidity(){return this.#i()?.checkValidity()??!0}reportValidity(){return this.#i()?.reportValidity()??!0}};var b=CSS.supports("anchor-name","--x"),S=CSS.supports("position-area","bottom"),$=(()=>{let h=document.createElement("span");return h.setAttribute("popover","hint"),h.popover==="hint"})(),V=["auto","manual","hint"];function M(h){let t=V.includes(h||"")?h:"auto";return t==="hint"&&!$?"auto":t}var P=["top","bottom","left","right","inset-inline-start","inset-inline-end"],q=["position","top","left","right","bottom","margin"],x=8,D=0,O=0;function w(h){return!h||h==="none"?[]:h.split(",").map(t=>t.trim()).filter(Boolean)}var v=class extends d{static get observedAttributes(){return["data-mode","data-anchor","data-position"]}#e=null;#t=null;#i=`--pop-over-anchor-${++O}`;#s=!1;#h=!1;#o=!1;setup(){if(this.id||(this.id=`pop-over-${++D}`),(!this.hasAttribute("popover")||this.#s)&&this.#l(),this.#n(),this.#c(),this.listen(this,"beforetoggle",t=>{let e=t.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${e}`,{detail:{state:t.newState},bubbles:!0,composed:!0})),!b&&t.newState==="open"&&this.#e&&queueMicrotask(()=>{this.matches(":popover-open")&&this.#f()})}),!b){let t=()=>{this.matches(":popover-open")&&this.#e&&this.#f()};this.listen(window,"resize",t),this.listen(window,"scroll",t,{capture:!0,passive:!0})}}teardown(){this.#d(),this.#h&&(P.forEach(t=>this.style.removeProperty(t)),this.#h=!1),this.#o&&(q.forEach(t=>this.style.removeProperty(t)),this.#o=!1),this.#e=null}attributeChangedCallback(t,e,i){if(e!==i){if(!this.hasAttribute("data-upgraded")){t==="data-mode"&&this.hasAttribute("popover")&&!this.isConnected&&(this.#s=!0);return}if(t==="data-mode"){this.#l();return}this._reinit()}}#l(){let t=M(this.dataset.mode);this.getAttribute("popover")!==t&&this.setAttribute("popover",t),this.#s=!0}show(){this.matches(":popover-open")||(this.showPopover(),!b&&this.#e&&this.matches(":popover-open")&&this.#f())}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#n(){let t=this.dataset.anchor;if(t){let e=document.getElementById(t);if(!e)try{e=document.querySelector(t)}catch{e=null}this.#e=e}else this.#e=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#c(){if(!this.#e||!b)return;let t=this.#e,e=t.style.getPropertyValue("anchor-name"),i=w(e||getComputedStyle(t).getPropertyValue("anchor-name"));i.includes(this.#i)||i.push(this.#i),t.style.setProperty("anchor-name",i.join(", ")),this.#t=this.#i,this.style.setProperty("position-anchor",this.#i),this.setAttribute("data-anchor-name",this.#i),S||this.#v(this.dataset.position||"bottom")}#d(){if(this.#e&&this.#t){let t=w(this.#e.style.getPropertyValue("anchor-name")).filter(e=>e!==this.#t);t.length?this.#e.style.setProperty("anchor-name",t.join(", ")):this.#e.style.removeProperty("anchor-name")}this.#t=null,this.style.getPropertyValue("position-anchor")&&this.style.removeProperty("position-anchor"),this.hasAttribute("data-anchor-name")&&this.removeAttribute("data-anchor-name")}#v(t){let e="var(--_pop-over-offset, var(--size-xs))",i=t.endsWith("-end")?{"inset-inline-end":"anchor(end)"}:{"inset-inline-start":"anchor(start)"},o={top:{bottom:`calc(anchor(top) + ${e})`,...i},bottom:{top:`calc(anchor(bottom) + ${e})`,...i},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},s=t.split("-")[0],n=o[s]||o.bottom;Object.entries(n).forEach(([a,r])=>this.style.setProperty(a,r)),this.#h=!0}#f(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),e=this.dataset.position||"bottom",i=this.#u(),o=document.documentElement.clientWidth,s=document.documentElement.clientHeight;this.style.position="fixed",this.style.margin="0",this.style.right="auto",this.style.bottom="auto",this.#o=!0;let n=this.offsetWidth,a=this.offsetHeight,r=e.split("-")[0];["top","bottom","left","right"].includes(r)||(r="bottom");let l={top:t.top-i,bottom:s-t.bottom-i,left:t.left-i,right:o-t.right-i},f={top:"bottom",bottom:"top",left:"right",right:"left"},C=r==="top"||r==="bottom"?a:n;l[r]<C&&l[f[r]]>l[r]&&(r=f[r]);let c,u;switch(r){case"top":c=t.top-a-i,u=t.left;break;case"left":c=t.top,u=t.left-n-i;break;case"right":c=t.top,u=t.right+i;break;default:c=t.bottom+i,u=t.left;break}if(r==="top"||r==="bottom"){let m=getComputedStyle(this).direction==="rtl";u=e.endsWith("-end")!==m?t.right-n:t.left}else e.endsWith("-end")&&(c=t.bottom-a);let A=(m,y,k)=>Math.max(x,Math.min(m,k-y-x));u=A(u,n,o),c=A(c,a,s),this.style.top=`${Math.round(c)}px`,this.style.left=`${Math.round(u)}px`}#u(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset||""]??t.xs}};p("pop-over",v);var I=0,g=class extends d{static formAssociated=!0;#e;#t;#i;#s;#h=[];#o=[];#l=-1;#n=!1;#c="";#d="";#v;#f=!1;#u;#E;#r=[];constructor(){super(),this.#e=this.attachInternals(),this._adoptInternals(this.#e)}get#a(){return this.hasAttribute("multiple")}setup(){let t=this.querySelector(":scope > input")||this.querySelector(":scope > .tags-input-area > input");if(!t)return!1;this.#t=t;let e=this.#t.getAttribute("name");e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#t.removeAttribute("name"));let i=this.querySelector("ul, ol");if(!i)return!1;if(this.#i=i,this.#a){let r=this.querySelector(":scope > .tags-input-area");if(!r){r=document.createElement("div"),r.className="tags-input-area";let f=this.querySelector(":scope > pop-over[data-combobox-host]")||this.#i;this.insertBefore(r,f)}this.#u=r,this.#t.parentNode!==this.#u&&this.#u.appendChild(this.#t);let l=this.querySelector(":scope > [data-combobox-live]");l||(l=document.createElement("div"),l.setAttribute("aria-live","polite"),l.setAttribute("aria-atomic","true"),l.setAttribute("data-combobox-live",""),l.className="visually-hidden",this.appendChild(l)),this.#E=l}let o=this.getAttribute("placeholder");o&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",o);let s=`cb${++I}`;this.#i.id||(this.#i.id=`combobox-listbox-${s}`),this.#t.setAttribute("role","combobox"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#i.id),this.#t.setAttribute("autocomplete","off"),this.#i.setAttribute("role","listbox"),this.#a&&this.#i.setAttribute("aria-multiselectable","true");let n=this.#a?this.#u:this.#t;n.id||(n.id=`combobox-anchor-${s}`);let a=this.querySelector(":scope > pop-over[data-combobox-host]");if(a?this.#s=a:(this.#s=document.createElement("pop-over"),this.#s.setAttribute("data-combobox-host",""),this.#s.id=`combobox-pop-${s}`,this.#s.dataset.mode="manual",this.#s.dataset.position="bottom-start",this.#s.dataset.anchor=n.id,this.#s.appendChild(this.#i),this.appendChild(this.#s)),this.#s.dataset.anchor=n.id,this.#i.parentElement!==this.#s&&this.#s.appendChild(this.#i),this.#O(),!this.#a){let r=this.getAttribute("value");r&&this.#y(r,!1),this.#v===void 0&&(this.#v=this.#c)}return this.listen(this.#t,"input",this.#I),this.listen(this.#t,"keydown",this.#N),this.listen(this.#t,"focus",this.#T),this.listen(this.#t,"click",this.#B),this.listen(this.#i,"click",this.#F),this.listen(this.#i,"pointerdown",this.#L),this.listen(document,"click",this.#R),this.listen(this.#s,"pop-over:hide",this.#_),this.listen(this,"invalid",this.#D),this.#b(),this.#m(),this.#p(),this.#k(this.matches(":disabled")),!0}teardown(){}#D=()=>{this.#t.setAttribute("aria-invalid","true")};formDisabledCallback(t){this.#t&&this.#k(t)}#k(t){this.#f=t,t&&this.#p();let e=this.#S(),i=this.#a&&e>0&&this.#r.length>=e;if(this.#t.disabled=t||i,this.#u)for(let o of this.#u.querySelectorAll(".tag button"))o.disabled=t}#O(){this.#h=Array.from(this.#i.querySelectorAll(":scope > li[data-value]")),this.#h.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#i.id}-option-${e}`)}),this.#o=[...this.#h]}#x(t,e){if(this.#r.some(a=>a.value===t))return;let i=this.#S();if(i&&this.#r.length>=i)return;this.#r.push({value:t,label:e});let o=document.createElement("span");o.className="tag",o.dataset.value=t,o.textContent=e+" ";let s=document.createElement("button");s.type="button",s.setAttribute("aria-label",`Remove ${e}`),s.innerHTML="×",s.disabled=this.#f,s.addEventListener("click",a=>{a.stopPropagation(),this.#V(t)}),o.appendChild(s),this.#u.insertBefore(o,this.#t);let n=this.#h.find(a=>a.getAttribute("data-value")===t);n&&n.setAttribute("aria-selected","true"),this.#M(`${e} added`),this.#t.value="",this.#g(""),this.#b(),this.#m(),this.#P(),i&&this.#r.length>=i&&(this.#t.disabled=!0,this.#p())}#V(t){let e=this.#r.findIndex(a=>a.value===t);if(e===-1)return;let i=this.#r.splice(e,1)[0],o=this.#u.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);o&&o.remove();let s=this.#h.find(a=>a.getAttribute("data-value")===t);s&&s.setAttribute("aria-selected","false"),this.#M(`${i.label} removed`),this.#S()&&this.#t.disabled&&(this.#t.disabled=this.#f),this.#g(this.#t.value.trim()),this.#b(),this.#m(),this.#P(),this.#t.focus()}#S(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#M(t){this.#E&&(this.#E.textContent="",requestAnimationFrame(()=>{this.#E.textContent=t}))}#I=()=>{let t=this.#t.value.trim();if(!this.#a&&this.#c){let e=this.#i.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#c="",this.#d="",this.removeAttribute("value"),this.#b(),this.#m()}this.#g(t),this.#A()};#N=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#n||this.#A(),this.#w(this.#l+1);break;case"ArrowUp":t.preventDefault(),this.#n||this.#A(),this.#w(this.#l-1);break;case"Home":this.#n&&(t.preventDefault(),this.#w(0));break;case"End":this.#n&&(t.preventDefault(),this.#w(this.#o.length-1));break;case"Enter":if(t.preventDefault(),this.#n&&this.#l>=0&&this.#o[this.#l]){let e=this.#o[this.#l];this.#a?this.#x(e.getAttribute("data-value"),e.textContent.trim()):this.#$(e)}else if(this.#a&&this.hasAttribute("custom")&&this.#t.value.trim()){let e=this.#t.value.trim();this.#x(e,e)}break;case"Backspace":if(this.#a&&!this.#t.value&&this.#r.length>0){let e=this.#r[this.#r.length-1];this.#V(e.value)}break;case",":if(this.#a&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#x(e,e)}break;case"Escape":this.#n&&(t.preventDefault(),t.stopPropagation(),this.#p(),this.#t.focus());break;case"Tab":this.#n&&this.#p();break}};#T=()=>{this.#a?(this.#g(this.#t.value.trim()),this.#A()):(this.#t.value||!this.#c)&&(this.#g(this.#t.value.trim()),this.#A())};#B=()=>{this.#n||(this.#g(this.#t.value.trim()),this.#A())};#F=t=>{let e=t.target.closest("li[data-value]");e&&this.#o.includes(e)&&(this.#a?this.#x(e.getAttribute("data-value"),e.textContent.trim()):this.#$(e))};#L=t=>{t.preventDefault()};#R=t=>{this.#n&&!this.contains(t.target)&&this.#p()};#g(t){let e=this.getAttribute("filter")||"contains",i=t.toLowerCase(),o=this.#a?new Set(this.#r.map(s=>s.value)):null;this.#o=[],this.#h.forEach(s=>{let n=s.getAttribute("data-value"),a=s.textContent.trim().toLowerCase();if(o&&o.has(n)){s.hidden=!0;return}let r;t?e==="startsWith"?r=a.startsWith(i):r=a.includes(i):r=!0,s.hidden=!r,r&&this.#o.push(s)}),this.#l=-1,this.#C(),this.setState("no-matches",this.#o.length===0)}#w(t){if(this.#o.length===0)return;t<0&&(t=this.#o.length-1),t>=this.#o.length&&(t=0),this.#l>=0&&this.#o[this.#l]&&this.#o[this.#l].removeAttribute("data-active"),this.#l=t;let e=this.#o[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#C(){this.#h.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#$(t,e="internal"){let i=t.getAttribute("data-value")||"",o=t.textContent.trim();if(this.#c===i){this.#t.value=o,this.#p(),this.#t.focus();return}this.#h.forEach(s=>s.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#c=i,this.#d=o,this.#t.value=o,this.setAttribute("value",i),this.#b(),this.#m(),this.#p(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:i,label:o,source:e}}))}#y(t,e=!0,i="api"){let o=this.#h.find(s=>s.getAttribute("data-value")===t);o&&(e?this.#$(o,i):(this.#h.forEach(s=>s.setAttribute("aria-selected","false")),o.setAttribute("aria-selected","true"),this.#c=t,this.#d=o.textContent.trim(),this.#t.value=this.#d,this.setAttribute("value",t)))}#A(){this.#n||this.#f||(this.#n=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#s?.show(),this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0})))}#p(){this.#n&&(this.#n=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#C(),this.#s?.hide(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))}#_=()=>{this.#n&&(this.#n=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#C(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#b(){if(this.#a)if(this.#r.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let i of this.#r)t.append(e,i.value);this.#e.setFormValue(t)}else this.#e.setFormValue(null);else this.#c?this.#e.setFormValue(this.#c,this.#d):this.#e.setFormValue(null)}#m(){this.hasAttribute("required")?this.#a?this.#r.length===0?this.#e.setValidity({valueMissing:!0},"Please select at least one option",this.#t):this.#e.setValidity({}):this.#c?this.#e.setValidity({}):this.#e.setValidity({valueMissing:!0},"Please select an option",this.#t):this.#e.setValidity({}),this.#e.validity.valid&&this.#t.removeAttribute("aria-invalid")}#P(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#r.map(t=>t.value),labels:this.#r.map(t=>t.label),source:"internal"}}))}formResetCallback(){this.#a?(this.#u.querySelectorAll(".tag").forEach(t=>t.remove()),this.#r=[],this.#t.value="",this.#t.disabled=this.#f):(this.#c="",this.#d="",this.#t.value="",this.removeAttribute("value")),this.#h.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#o=[...this.#h],this.#l=-1,this.#C(),this.#p(),this.#t.removeAttribute("aria-invalid"),!this.#a&&this.#v&&this.#y(this.#v,!1),this.#b(),this.#m()}formStateRestoreCallback(t){t&&(this.#a||(this.#y(t,!1),this.#b(),this.#m()))}get value(){return this.#c}set value(t){t?this.#y(t):this.#q()}#q(){this.#h.forEach(t=>t.setAttribute("aria-selected","false")),this.#c="",this.#d="",this.#t&&(this.#t.value=""),this.removeAttribute("value"),this.#b(),this.#m()}get label(){return this.#d}get values(){return this.#r.map(t=>t.value)}get labels(){return this.#r.map(t=>t.label)}static get observedAttributes(){return["value","disabled"]}attributeChangedCallback(t,e,i){if(!this.#t)return;if(t==="disabled"){this.#k(this.matches(":disabled"));return}let o=i??"";t==="value"&&o!==this.#c&&(o?(this.#y(o,!1),this.#b(),this.#m()):this.#q())}};p("combo-box",g);export{g as ComboBox};
|
|
1
|
+
var F=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function p(a,t,e={}){let i=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=E.get(a);if(customElements.get(a)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(a,r),customElements.define(a,t)}var d=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,r){t.addEventListener(e,i,r),this.#e.push(()=>t.removeEventListener(e,i,r))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{e?i.add(t):i.delete(t)}catch{let r=`--${t}`;e?i.add(r):i.delete(r)}}_adoptInternals(t){this.#t||(this.#t=t)}#i(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#i()?.validity}get validationMessage(){return this.#i()?.validationMessage??""}get willValidate(){return this.#i()?.willValidate??!1}get form(){return this.#i()?.form??null}checkValidity(){return this.#i()?.checkValidity()??!0}reportValidity(){return this.#i()?.reportValidity()??!0}};var b=CSS.supports("anchor-name","--x"),$=CSS.supports("position-area","bottom"),k=(()=>{let a=document.createElement("span");return a.setAttribute("popover","hint"),a.popover==="hint"})(),P=["auto","manual","hint"];function M(a){let t=P.includes(a||"")?a:"auto";return t==="hint"&&!k?"auto":t}var V=["top","bottom","left","right","inset-inline-start","inset-inline-end"],T=["position","top","left","right","bottom","margin"],w=8,q=0,B=0;function x(a){return!a||a==="none"?[]:a.split(",").map(t=>t.trim()).filter(Boolean)}var v=class extends d{static get observedAttributes(){return["data-mode","data-anchor","data-position"]}#e=null;#t=null;#i=`--pop-over-anchor-${++B}`;#s=!1;#a=!1;#r=!1;setup(){if(this.id||(this.id=`pop-over-${++q}`),(!this.hasAttribute("popover")||this.#s)&&this.#l(),this.#h(),this.#c(),this.listen(this,"beforetoggle",t=>{let e=t.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${e}`,{detail:{state:t.newState},bubbles:!0,composed:!0})),!b&&t.newState==="open"&&this.#e&&queueMicrotask(()=>{this.matches(":popover-open")&&this.#f()})}),!b){let t=()=>{this.matches(":popover-open")&&this.#e&&this.#f()};this.listen(window,"resize",t),this.listen(window,"scroll",t,{capture:!0,passive:!0})}}teardown(){this.#d(),this.#a&&(V.forEach(t=>this.style.removeProperty(t)),this.#a=!1),this.#r&&(T.forEach(t=>this.style.removeProperty(t)),this.#r=!1),this.#e=null}attributeChangedCallback(t,e,i){if(e!==i){if(!this.hasAttribute("data-upgraded")){t==="data-mode"&&this.hasAttribute("popover")&&!this.isConnected&&(this.#s=!0);return}if(t==="data-mode"){this.#l();return}this._reinit()}}#l(){let t=M(this.dataset.mode);this.getAttribute("popover")!==t&&this.setAttribute("popover",t),this.#s=!0}show(){this.matches(":popover-open")||(this.showPopover(),!b&&this.#e&&this.matches(":popover-open")&&this.#f())}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#h(){let t=this.dataset.anchor;if(t){let e=document.getElementById(t);if(!e)try{e=document.querySelector(t)}catch{e=null}this.#e=e}else this.#e=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#c(){if(!this.#e||!b)return;let t=this.#e,e=t.style.getPropertyValue("anchor-name"),i=x(e||getComputedStyle(t).getPropertyValue("anchor-name"));i.includes(this.#i)||i.push(this.#i),t.style.setProperty("anchor-name",i.join(", ")),this.#t=this.#i,this.style.setProperty("position-anchor",this.#i),this.setAttribute("data-anchor-name",this.#i),$||this.#v(this.dataset.position||"bottom")}#d(){if(this.#e&&this.#t){let t=x(this.#e.style.getPropertyValue("anchor-name")).filter(e=>e!==this.#t);t.length?this.#e.style.setProperty("anchor-name",t.join(", ")):this.#e.style.removeProperty("anchor-name")}this.#t=null,this.style.getPropertyValue("position-anchor")&&this.style.removeProperty("position-anchor"),this.hasAttribute("data-anchor-name")&&this.removeAttribute("data-anchor-name")}#v(t){let e="var(--_pop-over-offset, var(--size-xs))",i=t.endsWith("-end")?{"inset-inline-end":"anchor(end)"}:{"inset-inline-start":"anchor(start)"},r={top:{bottom:`calc(anchor(top) + ${e})`,...i},bottom:{top:`calc(anchor(bottom) + ${e})`,...i},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},s=t.split("-")[0],h=r[s]||r.bottom;Object.entries(h).forEach(([n,o])=>this.style.setProperty(n,o)),this.#a=!0}#f(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),e=this.dataset.position||"bottom",i=this.#u(),r=document.documentElement.clientWidth,s=document.documentElement.clientHeight;this.style.position="fixed",this.style.margin="0",this.style.right="auto",this.style.bottom="auto",this.#r=!0;let h=this.offsetWidth,n=this.offsetHeight,o=e.split("-")[0];["top","bottom","left","right"].includes(o)||(o="bottom");let l={top:t.top-i,bottom:s-t.bottom-i,left:t.left-i,right:r-t.right-i},f={top:"bottom",bottom:"top",left:"right",right:"left"},C=o==="top"||o==="bottom"?n:h;l[o]<C&&l[f[o]]>l[o]&&(o=f[o]);let c,u;switch(o){case"top":c=t.top-n-i,u=t.left;break;case"left":c=t.top,u=t.left-h-i;break;case"right":c=t.top,u=t.right+i;break;default:c=t.bottom+i,u=t.left;break}if(o==="top"||o==="bottom"){let m=getComputedStyle(this).direction==="rtl";u=e.endsWith("-end")!==m?t.right-h:t.left}else e.endsWith("-end")&&(c=t.bottom-n);let A=(m,y,S)=>Math.max(w,Math.min(m,S-y-w));u=A(u,h,r),c=A(c,n,s),this.style.top=`${Math.round(c)}px`,this.style.left=`${Math.round(u)}px`}#u(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset||""]??t.xs}};p("pop-over",v);var L=0,g=class extends d{static formAssociated=!0;#e;#t;#i;#s;#a=[];#r=[];#l=-1;#h=!1;#c="";#d="";#v;#f=!1;#u;#E;#o=[];constructor(){super(),this.#e=this.attachInternals(),this._adoptInternals(this.#e)}get#n(){return this.hasAttribute("multiple")}setup(){let t=this.querySelector(":scope > input")||this.querySelector(":scope > .tags-input-area > input");if(!t)return!1;this.#t=t;let e=this.#t.getAttribute("name");e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#t.removeAttribute("name"));let i=this.querySelector("ul, ol");if(!i)return!1;if(this.#i=i,this.#n){let o=this.querySelector(":scope > .tags-input-area");if(!o){o=document.createElement("div"),o.className="tags-input-area";let f=this.querySelector(":scope > pop-over[data-combobox-host]")||this.#i;this.insertBefore(o,f)}this.#u=o,this.#t.parentNode!==this.#u&&this.#u.appendChild(this.#t);let l=this.querySelector(":scope > [data-combobox-live]");l||(l=document.createElement("div"),l.setAttribute("aria-live","polite"),l.setAttribute("aria-atomic","true"),l.setAttribute("data-combobox-live",""),l.className="visually-hidden",this.appendChild(l)),this.#E=l}let r=this.getAttribute("placeholder");r&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",r);let s=`cb${++L}`;this.#i.id||(this.#i.id=`combobox-listbox-${s}`),this.#t.setAttribute("role","combobox"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#i.id),this.#t.setAttribute("autocomplete","off"),this.#i.setAttribute("role","listbox"),this.#n&&this.#i.setAttribute("aria-multiselectable","true");let h=this.#n?this.#u:this.#t;h.id||(h.id=`combobox-anchor-${s}`);let n=this.querySelector(":scope > pop-over[data-combobox-host]");if(n?this.#s=n:(this.#s=document.createElement("pop-over"),this.#s.setAttribute("data-combobox-host",""),this.#s.id=`combobox-pop-${s}`,this.#s.dataset.mode="manual",this.#s.dataset.position="bottom-start",this.#s.dataset.anchor=h.id,this.#s.appendChild(this.#i),this.appendChild(this.#s)),this.#s.dataset.anchor=h.id,this.#i.parentElement!==this.#s&&this.#s.appendChild(this.#i),this.#B(),!this.#n){let o=this.getAttribute("value");o&&this.#y(o,!1),this.#v===void 0&&(this.#v=this.#c)}return this.listen(this.#t,"input",this.#L),this.listen(this.#t,"keydown",this.#O),this.listen(this.#t,"focus",this.#D),this.listen(this.#t,"click",this.#_),this.listen(this.#i,"click",this.#F),this.listen(this.#i,"pointerdown",this.#I),this.listen(document,"click",this.#H),this.listen(this.#s,"pop-over:hide",this.#j),this.listen(this,"invalid",this.#q),this.#b(),this.#m(),this.#p(),this.#S(this.matches(":disabled")),!0}teardown(){}#q=()=>{this.#t.setAttribute("aria-invalid","true")};formDisabledCallback(t){this.#t&&this.#S(t)}#S(t){this.#f=t,t&&this.#p();let e=this.#$(),i=this.#n&&e>0&&this.#o.length>=e;if(this.#t.disabled=t||i,this.#u)for(let r of this.#u.querySelectorAll(".tag button"))r.disabled=t}#B(){this.#a=Array.from(this.#i.querySelectorAll(":scope > li[data-value]")),this.#a.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#i.id}-option-${e}`)}),this.#r=[...this.#a]}#w(t,e){if(this.#o.some(n=>n.value===t))return;let i=this.#$();if(i&&this.#o.length>=i)return;this.#o.push({value:t,label:e});let r=document.createElement("span");r.className="tag",r.dataset.value=t,r.textContent=e+" ";let s=document.createElement("button");s.type="button",s.setAttribute("aria-label",`Remove ${e}`),s.innerHTML="×",s.disabled=this.#f,s.addEventListener("click",n=>{n.stopPropagation(),this.#P(t)}),r.appendChild(s),this.#u.insertBefore(r,this.#t);let h=this.#a.find(n=>n.getAttribute("data-value")===t);h&&h.setAttribute("aria-selected","true"),this.#M(`${e} added`),this.#t.value="",this.#g(""),this.#b(),this.#m(),this.#V(),i&&this.#o.length>=i&&(this.#t.disabled=!0,this.#p())}#P(t){let e=this.#o.findIndex(n=>n.value===t);if(e===-1)return;let i=this.#o.splice(e,1)[0],r=this.#u.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);r&&r.remove();let s=this.#a.find(n=>n.getAttribute("data-value")===t);s&&s.setAttribute("aria-selected","false"),this.#M(`${i.label} removed`),this.#$()&&this.#t.disabled&&(this.#t.disabled=this.#f),this.#g(this.#t.value.trim()),this.#b(),this.#m(),this.#V(),this.#t.focus()}#$(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#M(t){this.#E&&(this.#E.textContent="",requestAnimationFrame(()=>{this.#E.textContent=t}))}#L=()=>{let t=this.#t.value.trim();if(!this.#n&&this.#c){let e=this.#i.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#c="",this.#d="",this.removeAttribute("value"),this.#b(),this.#m()}this.#g(t),this.#A()};#O=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#h||this.#A(),this.#x(this.#l+1);break;case"ArrowUp":t.preventDefault(),this.#h||this.#A(),this.#x(this.#l-1);break;case"Home":this.#h&&(t.preventDefault(),this.#x(0));break;case"End":this.#h&&(t.preventDefault(),this.#x(this.#r.length-1));break;case"Enter":if(this.#h&&this.#l>=0&&this.#r[this.#l]){t.preventDefault();let e=this.#r[this.#l];this.#n?this.#w(e.getAttribute("data-value"),e.textContent.trim()):this.#k(e)}else if(this.#n&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#w(e,e)}break;case"Backspace":if(this.#n&&!this.#t.value&&this.#o.length>0){let e=this.#o[this.#o.length-1];this.#P(e.value)}break;case",":if(this.#n&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#w(e,e)}break;case"Escape":this.#h&&(t.preventDefault(),t.stopPropagation(),this.#p(),this.#t.focus());break;case"Tab":this.#h&&this.#p();break}};#D=()=>{this.#n?(this.#g(this.#t.value.trim()),this.#A()):(this.#t.value||!this.#c)&&(this.#g(this.#t.value.trim()),this.#A())};#_=()=>{this.#h||(this.#g(this.#t.value.trim()),this.#A())};#F=t=>{let e=t.target.closest("li[data-value]");e&&this.#r.includes(e)&&(this.#n?this.#w(e.getAttribute("data-value"),e.textContent.trim()):this.#k(e))};#I=t=>{t.preventDefault()};#H=t=>{this.#h&&!this.contains(t.target)&&this.#p()};#g(t){let e=this.getAttribute("filter")||"contains",i=t.toLowerCase(),r=this.#n?new Set(this.#o.map(s=>s.value)):null;this.#r=[],this.#a.forEach(s=>{let h=s.getAttribute("data-value"),n=s.textContent.trim().toLowerCase();if(r&&r.has(h)){s.hidden=!0;return}let o;t?e==="startsWith"?o=n.startsWith(i):o=n.includes(i):o=!0,s.hidden=!o,o&&this.#r.push(s)}),this.#l=-1,this.#C(),this.setState("no-matches",this.#r.length===0)}#x(t){if(this.#r.length===0)return;t<0&&(t=this.#r.length-1),t>=this.#r.length&&(t=0),this.#l>=0&&this.#r[this.#l]&&this.#r[this.#l].removeAttribute("data-active"),this.#l=t;let e=this.#r[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#C(){this.#a.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#k(t,e="internal"){let i=t.getAttribute("data-value")||"",r=t.textContent.trim();if(this.#c===i){this.#t.value=r,this.#p(),this.#t.focus();return}this.#a.forEach(s=>s.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#c=i,this.#d=r,this.#t.value=r,this.setAttribute("value",i),this.#b(),this.#m(),this.#p(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:i,label:r,source:e}}))}#y(t,e=!0,i="api"){let r=this.#a.find(s=>s.getAttribute("data-value")===t);r&&(e?this.#k(r,i):(this.#a.forEach(s=>s.setAttribute("aria-selected","false")),r.setAttribute("aria-selected","true"),this.#c=t,this.#d=r.textContent.trim(),this.#t.value=this.#d,this.setAttribute("value",t)))}#A(){this.#h||this.#f||(this.#h=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#s?.show(),this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0})))}#p(){this.#h&&(this.#h=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#C(),this.#s?.hide(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))}#j=()=>{this.#h&&(this.#h=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#C(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#b(){if(this.#n)if(this.#o.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let i of this.#o)t.append(e,i.value);this.#e.setFormValue(t)}else this.#e.setFormValue(null);else this.#c?this.#e.setFormValue(this.#c,this.#d):this.#e.setFormValue(null)}#m(){this.hasAttribute("required")?this.#n?this.#o.length===0?this.#e.setValidity({valueMissing:!0},"Please select at least one option",this.#t):this.#e.setValidity({}):this.#c?this.#e.setValidity({}):this.#e.setValidity({valueMissing:!0},"Please select an option",this.#t):this.#e.setValidity({}),this.#e.validity.valid&&this.#t.removeAttribute("aria-invalid")}#V(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#o.map(t=>t.value),labels:this.#o.map(t=>t.label),source:"internal"}}))}formResetCallback(){this.#n?(this.#u.querySelectorAll(".tag").forEach(t=>t.remove()),this.#o=[],this.#t.value="",this.#t.disabled=this.#f):(this.#c="",this.#d="",this.#t.value="",this.removeAttribute("value")),this.#a.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#r=[...this.#a],this.#l=-1,this.#C(),this.#p(),this.#t.removeAttribute("aria-invalid"),!this.#n&&this.#v&&this.#y(this.#v,!1),this.#b(),this.#m()}formStateRestoreCallback(t){t&&(this.#n||(this.#y(t,!1),this.#b(),this.#m()))}get value(){return this.#c}set value(t){t?this.#y(t):this.#T()}#T(){this.#a.forEach(t=>t.setAttribute("aria-selected","false")),this.#c="",this.#d="",this.#t&&(this.#t.value=""),this.removeAttribute("value"),this.#b(),this.#m()}get label(){return this.#d}get values(){return this.#o.map(t=>t.value)}get labels(){return this.#o.map(t=>t.label)}static get observedAttributes(){return["value","disabled"]}attributeChangedCallback(t,e,i){if(!this.#t)return;if(t==="disabled"){this.#S(this.matches(":disabled"));return}let r=i??"";t==="value"&&r!==this.#c&&(r?(this.#y(r,!1),this.#b(),this.#m()):this.#T())}};p("combo-box",g);export{g as ComboBox};
|
|
2
2
|
//# sourceMappingURL=combo-box.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var d=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),v={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",option:"\u2325",shift:"\u21E7",ctrl:"\u2303",control:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Ctrl",control:"Ctrl"}},C={mac:{meta:"Command",cmd:"Command",alt:"Option",option:"Option",shift:"Shift",ctrl:"Control",control:"Control"},other:{meta:"Control",cmd:"Control",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Control",control:"Control"}},H={escape:{label:"Esc",spoken:"Escape"},esc:{label:"Esc",spoken:"Escape"},enter:{label:"Enter",spoken:"Enter"},return:{label:"Enter",spoken:"Enter"},tab:{label:"Tab",spoken:"Tab"},space:{label:"Space",spoken:"Space"},backspace:{label:"Backspace",spoken:"Backspace"},delete:{label:"Del",spoken:"Delete"},del:{label:"Del",spoken:"Delete"},insert:{label:"Ins",spoken:"Insert"},home:{label:"Home",spoken:"Home"},end:{label:"End",spoken:"End"},pageup:{label:"PgUp",spoken:"Page up"},pagedown:{label:"PgDn",spoken:"Page down"},arrowup:{label:"\u2191",spoken:"Up arrow"},up:{label:"\u2191",spoken:"Up arrow"},arrowdown:{label:"\u2193",spoken:"Down arrow"},down:{label:"\u2193",spoken:"Down arrow"},arrowleft:{label:"\u2190",spoken:"Left arrow"},left:{label:"\u2190",spoken:"Left arrow"},arrowright:{label:"\u2192",spoken:"Right arrow"},right:{label:"\u2192",spoken:"Right arrow"},"+":{label:"+",spoken:"Plus"},plus:{label:"+",spoken:"Plus"}};function S(o){return[...String(o??"").trim().toLowerCase().matchAll(/([^+]+|\+)(?:\+|$)/g)].map(e=>e[1].trim()).filter(Boolean).map(e=>e==="plus"?"+":e)}function I(o,t=d){let e=t?v.mac:v.other;if(o in e)return{label:e[o],spoken:(t?C.mac:C.other)[o],modifier:!0};let n=H[o];if(n)return{...n,modifier:!1};let s=o.toUpperCase();return{label:s,spoken:s,modifier:!1}}function L(o){return S(o).map(t=>I(t).label).join(d?"":"+")}var O={esc:"escape",return:"enter",del:"delete",ins:"insert",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",space:" ",spacebar:" ",plus:"+",pgup:"pageup",pgdn:"pagedown"};function _(o){let t=String(o??"").toLowerCase();return O[t]??t}function p(o){let t=S(o);return{key:_(t.pop()??""),meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option")}}function M(o){return o.length===1&&!/[a-z0-9 ]/.test(o)}function x(o,t){let n=(o.key==="Spacebar"?" ":String(o.key??"").toLowerCase())===t.key;if(!n&&(o.altKey||o.shiftKey)&&/^[a-z0-9]$/.test(t.key)){let a=/\d/.test(t.key)?`Digit${t.key}`:`Key${t.key.toUpperCase()}`;n=o.code===a}if(!n)return!1;let s,r;return d?(s=t.meta,r=t.ctrl):(s=!1,r=t.meta||t.ctrl),!(s!==o.metaKey||r!==o.ctrlKey||!M(t.key)&&t.shift!==o.shiftKey||t.alt!==o.altKey)}function N(o){let t=typeof o=="string"?p(o):o;return!t.meta&&!t.ctrl&&!t.alt&&t.key.length===1}function T(o,t){let e=p(o),n=p(t),s=d?e.ctrl:e.ctrl||e.meta,r=d?n.ctrl:n.ctrl||n.meta,a=d&&e.meta,i=d&&n.meta,c=!M(e.key);return e.key===n.key&&s===r&&a===i&&e.alt===n.alt&&(!c||e.shift===n.shift)}var g="data-char-shortcuts";var q="vb:settings:extensions";function y(){return typeof document>"u"?!0:document.documentElement.getAttribute(g)!=="off"}function P(){try{let o=globalThis.localStorage?.getItem(q);if(!o)return null;let t=JSON.parse(o)?.data?.charShortcuts;return typeof t=="boolean"?t:null}catch{return null}}var B=!0;if(typeof document<"u"){let o=P();o===null&&(B=y()),o===!1?document.documentElement.setAttribute(g,"off"):o===!0&&document.documentElement.removeAttribute(g)}var K=new Set(["INPUT","TEXTAREA","SELECT"]),m=[],$=!1;function R(o){let t=o;return!t||!t.tagName?!1:K.has(t.tagName)||t.isContentEditable}function U(o){if(o.repeat||o.isComposing||o.defaultPrevented)return;let t=R(o.target),e=!y(),n=document.activeElement;for(let s of m)if(!(t&&!s.global)&&!(s.scope&&!(s.scope.isConnected&&s.scope.contains(n)))&&!(e&&s.character&&!s.scope)&&!(s.enabled&&!s.enabled())&&x(o,s.descriptor)){o.preventDefault(),s.callback(o);return}}function V(){$||(document.addEventListener("keydown",U),$=!0)}function k(o,t,e={}){V();let n=p(o),s={combo:o,descriptor:n,callback:t,global:e.global===!0,scope:e.scope??null,enabled:typeof e.enabled=="function"?e.enabled:null,character:N(n)},r=m.find(a=>!a.scope&&!s.scope&&T(a.combo,o));return r&&console.warn(`[hotkey-bind] Shortcut "${o}" is already bound as "${r.combo}". Last-bound wins.`),m.unshift(s),function(){let i=m.indexOf(s);i!==-1&&m.splice(i,1)}}var X=window.matchMedia("(prefers-reduced-motion: reduce)");var D=new Map;function f(o,t,e={}){let n=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:n},r=D.get(o);if(customElements.get(o)){if(!r||r.priority>=n){r&&r.priority===n&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=n){r.priority===n&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}D.set(o,s),customElements.define(o,t)}var b=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,s){t.addEventListener(e,n,s),this.#e.push(()=>t.removeEventListener(e,n,s))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{e?n.add(t):n.delete(t)}catch{let s=`--${t}`;e?n.add(s):n.delete(s)}}_adoptInternals(t){this.#t||(this.#t=t)}#s(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var F=0,E=class extends b{#e=null;#t;#s;#n=[];#o=-1;#c=[];#i=[];#r=[];#a="";#l=0;setup(){this.#a=`cmdp-${++F}`,this.#l=0,this.#g(),this.#y(),this.hasAttribute("discover")&&this.#E()}teardown(){this.#i.forEach(t=>t()),this.#i=[],this.#e?.remove(),this.#e=null,this.#n=[],this.#c=[],this.#r=[],this.#o=-1}get commands(){let t=[];for(let e of this.querySelectorAll("command-group")){let n=e.getAttribute("label")||"";for(let s of e.querySelectorAll("command-item"))t.push({value:s.getAttribute("value")||"",label:s.textContent.trim(),hotkey:s.getAttribute("data-hotkey")||void 0,group:n||void 0})}return t}set commands(t){let e=Array.isArray(t)?t:[],n=new Map;for(let s of e){let r=s.group||"";n.has(r)||n.set(r,[]),n.get(r).push(s)}for(let s of[...this.children])(s.tagName==="COMMAND-GROUP"||s.tagName==="COMMAND-ITEM")&&s.remove();for(let[s,r]of n){let a=document.createElement("command-group");s&&a.setAttribute("label",s);for(let i of r){let c=document.createElement("command-item");if(i.value&&c.setAttribute("value",i.value),i.hotkey&&c.setAttribute("data-hotkey",i.hotkey),i.icon){let l=document.createElement("span");l.setAttribute("slot","icon"),l.innerHTML=i.icon,c.appendChild(l)}c.appendChild(document.createTextNode(i.label||i.value||"")),a.appendChild(c)}this.appendChild(a)}this._reinit(),this.dispatchEvent(new CustomEvent("command-palette:commands-changed",{detail:{commands:e,source:"property"},bubbles:!0}))}#g(){this.#e=document.createElement("dialog"),this.#e.className="command-dialog",this.#e.setAttribute("aria-label",this.getAttribute("label")||"Command palette"),this.#e.addEventListener("click",n=>{n.target===this.#e&&this.close()}),this.#e.addEventListener("close",()=>{this.#t?.setAttribute("aria-expanded","false"),this.#t?.removeAttribute("aria-activedescendant"),this.dispatchEvent(new CustomEvent("command-palette:close",{bubbles:!0}))});let t=document.createElement("div");t.className="command-search",this.#s=document.createElement("div"),this.#s.className="command-list",this.#s.id=`${this.#a}-list`,this.#s.setAttribute("role","listbox"),this.#s.setAttribute("aria-label","Commands"),this.#t=document.createElement("input"),this.#t.type="search",this.#t.placeholder=this.getAttribute("placeholder")||"Type a command...",this.#t.setAttribute("aria-label","Search commands"),this.#t.autocomplete="off",this.#t.setAttribute("role","combobox"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#s.id),this.#t.setAttribute("aria-expanded","false"),this.#t.addEventListener("input",this.#d),this.#t.addEventListener("keydown",this.#k),t.appendChild(this.#t),this.#c=Array.from(this.querySelectorAll("command-group")),this.#c.forEach(n=>{let s=this.#u(n.getAttribute("label")||"");this.#s.appendChild(s),n.querySelectorAll("command-item").forEach(r=>{let a=r.querySelector('[slot="icon"]'),i=this.#p(r.textContent.trim(),a?a.cloneNode(!0):null,r.getAttribute("data-hotkey"));i.dataset.value=r.getAttribute("value")||"",i.addEventListener("click",()=>{this.#f(i.dataset.value)}),s.appendChild(i),this.#n.push({btn:i,group:s,source:r})})});let e=document.createElement("div");e.className="command-empty",e.textContent="No results found.",e.hidden=!0,this.#s.appendChild(e),this.#e.appendChild(t),this.#e.appendChild(this.#s),this.appendChild(this.#e)}#u(t){let e=document.createElement("div");e.className="command-group",e.setAttribute("role","group");let n=document.createElement("div");return n.className="command-group-header",n.id=`${this.#a}-g${++this.#l}`,n.setAttribute("aria-hidden","true"),n.textContent=t,t?e.setAttribute("aria-labelledby",n.id):n.hidden=!0,e.appendChild(n),e}#y(){let t=this.getAttribute("hotkey")||"meta+k";this.#i.push(k(t,()=>{this.#e?.open?this.close():this.open()},{global:!0}));for(let{btn:e,source:n}of this.#n){let s=n?.getAttribute("data-hotkey");if(!s||s.toLowerCase()===t.toLowerCase())continue;let r=e.dataset.value;this.#i.push(k(s,()=>this.#f(r)))}}#d=()=>{let t=this.#t.value.toLowerCase().trim(),e=0,n=new Set;this.#n.forEach(({btn:r,group:a})=>{let i=!t||(r.dataset.searchText??"").includes(t);r.hidden=!i,i&&(e++,n.add(a))}),this.#s.querySelectorAll(":scope > .command-group").forEach(r=>{r.hidden=!n.has(r)});let s=this.#s.querySelector(".command-empty");s&&(s.hidden=e>0),this.#o=-1,this.#n.forEach(({btn:r})=>{r.removeAttribute("data-active"),r.setAttribute("aria-selected","false")}),this.#t.removeAttribute("aria-activedescendant"),e>0&&this.#h(0)};#k=t=>{let e=this.#m();switch(t.key){case"ArrowDown":t.preventDefault(),this.#h(this.#o+1);break;case"ArrowUp":t.preventDefault(),this.#h(this.#o-1);break;case"Enter":t.preventDefault(),this.#o>=0&&e[this.#o]&&e[this.#o].btn.click();break;case"Escape":t.preventDefault(),this.close();break}};#m(){return this.#n.filter(({btn:t})=>!t.hidden)}#h(t){let e=this.#m();if(e.length===0)return;e.forEach(({btn:s})=>{s.removeAttribute("data-active"),s.setAttribute("aria-selected","false")}),t<0&&(t=e.length-1),t>=e.length&&(t=0),this.#o=t;let{btn:n}=e[t];n.setAttribute("data-active",""),n.setAttribute("aria-selected","true"),this.#t.setAttribute("aria-activedescendant",n.id),n.scrollIntoView({block:"nearest"})}#f(t){this.close(),this.dispatchEvent(new CustomEvent("command-palette:select",{bubbles:!0,detail:{value:t}}))}#E(){this.listen(document,"vb:command-registry-change",this.#A)}#A=()=>{this.#e?.open&&(this.#b(),this.#d())};#b(){if(!this.hasAttribute("discover"))return;let{getRegisteredCommands:t,scanAutoDiscoverable:e}=window.__commandRegistry||{};if(!t)return;this.#n=this.#n.filter(r=>!r.discovered),this.#r.forEach(r=>r.remove()),this.#r=[];let n=this.#s.querySelector(".command-empty"),s=t();for(let[r,a]of s){let i=this.#u(r);this.#s.insertBefore(i,n),this.#r.push(i);for(let c of a){if(this.contains(c.element))continue;let l=this.#p(c.label,c.icon,c.shortcut);l.dataset.value=`__discovered:${c.label}`,l.addEventListener("click",()=>{this.close(),c.element.click()}),i.appendChild(l),this.#n.push({btn:l,group:i,source:null,discovered:!0})}}if(this.getAttribute("discover")==="auto"&&e){let r=e(),a=new Map;for(let i of r){let c=a.get(i.group)||[];c.push(i),a.set(i.group,c)}for(let[i,c]of a){let l=this.#u(i);this.#s.insertBefore(l,n),this.#r.push(l);for(let u of c){if(this.contains(u.element))continue;let h=this.#p(u.label,u.icon,u.shortcut);h.dataset.value=`__auto:${u.label}`,h.dataset.auto="",h.addEventListener("click",()=>{this.close(),u.action?u.action():u.element.click()}),l.appendChild(h),this.#n.push({btn:h,group:l,source:null,discovered:!0})}}}}#p(t,e,n){let s=document.createElement("button");if(s.type="button",s.className="command-option",s.id=`${this.#a}-opt-${++this.#l}`,s.setAttribute("role","option"),s.setAttribute("aria-selected","false"),s.tabIndex=-1,s.dataset.searchText=t.toLowerCase(),e){let a=document.createElement("span");if(a.className="command-icon",typeof e=="string"){let i=document.createElement("icon-wc");i.setAttribute("name",e),a.appendChild(i)}else a.appendChild(e);s.appendChild(a)}let r=document.createElement("span");if(r.className="command-label",r.textContent=t,s.appendChild(r),n){let a=document.createElement("kbd");a.className="command-kbd",a.setAttribute("aria-hidden","true"),a.textContent=L(n),s.appendChild(a),s.setAttribute("aria-keyshortcuts",n)}return s}open(){!this.#e||this.#e.open||(this.#b(),this.#e.showModal(),this.#t.setAttribute("aria-expanded","true"),this.#t.value="",this.#d(),this.#t.focus(),this.dispatchEvent(new CustomEvent("command-palette:open",{bubbles:!0})))}close(){this.#e?.open&&this.#e.close()}get isOpen(){return this.#e?.open??!1}},A=class extends HTMLElement{},w=class extends HTMLElement{};f("command-palette",E);f("command-group",A);f("command-item",w);export{E as CommandPalette};
|
|
1
|
+
var u=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),w={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",option:"\u2325",shift:"\u21E7",ctrl:"\u2303",control:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Ctrl",control:"Ctrl"}},C={mac:{meta:"Command",cmd:"Command",alt:"Option",option:"Option",shift:"Shift",ctrl:"Control",control:"Control"},other:{meta:"Control",cmd:"Control",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Control",control:"Control"}},_={escape:{label:"Esc",spoken:"Escape"},esc:{label:"Esc",spoken:"Escape"},enter:{label:"Enter",spoken:"Enter"},return:{label:"Enter",spoken:"Enter"},tab:{label:"Tab",spoken:"Tab"},space:{label:"Space",spoken:"Space"},backspace:{label:"Backspace",spoken:"Backspace"},delete:{label:"Del",spoken:"Delete"},del:{label:"Del",spoken:"Delete"},insert:{label:"Ins",spoken:"Insert"},home:{label:"Home",spoken:"Home"},end:{label:"End",spoken:"End"},pageup:{label:"PgUp",spoken:"Page up"},pagedown:{label:"PgDn",spoken:"Page down"},arrowup:{label:"\u2191",spoken:"Up arrow"},up:{label:"\u2191",spoken:"Up arrow"},arrowdown:{label:"\u2193",spoken:"Down arrow"},down:{label:"\u2193",spoken:"Down arrow"},arrowleft:{label:"\u2190",spoken:"Left arrow"},left:{label:"\u2190",spoken:"Left arrow"},arrowright:{label:"\u2192",spoken:"Right arrow"},right:{label:"\u2192",spoken:"Right arrow"},"+":{label:"+",spoken:"Plus"},plus:{label:"+",spoken:"Plus"}};function S(s){return[...String(s??"").trim().toLowerCase().matchAll(/([^+]+|\+)(?:\+|$)/g)].map(e=>e[1].trim()).filter(Boolean).map(e=>e==="plus"?"+":e)}function D(s,t=u){let e=t?w.mac:w.other;if(s in e)return{label:e[s],spoken:(t?C.mac:C.other)[s],modifier:!0};let r=_[s];if(r)return{...r,modifier:!1};let n=s.toUpperCase();return{label:n,spoken:n,modifier:!1}}function $(s){return S(s).map(t=>D(t).label).join(u?"":"+")}var B={esc:"escape",return:"enter",del:"delete",ins:"insert",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",space:" ",spacebar:" ",plus:"+",pgup:"pageup",pgdn:"pagedown"};function O(s){let t=String(s??"").toLowerCase();return B[t]??t}function f(s){let t=S(s);return{key:O(t.pop()??""),meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option")}}function T(s){return s.length===1&&!/[a-z0-9 ]/.test(s)}function x(s,t){let r=(s.key==="Spacebar"?" ":String(s.key??"").toLowerCase())===t.key;if(!r&&(s.altKey||s.shiftKey)&&/^[a-z0-9]$/.test(t.key)){let a=/\d/.test(t.key)?`Digit${t.key}`:`Key${t.key.toUpperCase()}`;r=s.code===a}if(!r)return!1;let n,o;return u?(n=t.meta,o=t.ctrl):(n=!1,o=t.meta||t.ctrl),!(n!==s.metaKey||o!==s.ctrlKey||!T(t.key)&&t.shift!==s.shiftKey||t.alt!==s.altKey)}function L(s){let t=typeof s=="string"?f(s):s;return!t.meta&&!t.ctrl&&!t.alt&&t.key.length===1}function M(s,t){let e=f(s),r=f(t),n=u?e.ctrl:e.ctrl||e.meta,o=u?r.ctrl:r.ctrl||r.meta,a=u&&e.meta,i=u&&r.meta,c=!T(e.key);return e.key===r.key&&n===o&&a===i&&e.alt===r.alt&&(!c||e.shift===r.shift)}var y="data-char-shortcuts";var q="vb:settings:extensions";function g(){return typeof document>"u"?!0:document.documentElement.getAttribute(y)!=="off"}function I(){try{let s=globalThis.localStorage?.getItem(q);if(!s)return null;let t=JSON.parse(s)?.data?.charShortcuts;return typeof t=="boolean"?t:null}catch{return null}}var K=!0;if(typeof document<"u"){let s=I();s===null&&(K=g()),s===!1?document.documentElement.setAttribute(y,"off"):s===!0&&document.documentElement.removeAttribute(y)}var R=new Set(["INPUT","TEXTAREA","SELECT"]),p=[],H=!1;function U(s){let t=s;return!t||!t.tagName?!1:R.has(t.tagName)||t.isContentEditable}function V(s){if(s.repeat||s.isComposing||s.defaultPrevented)return;let t=U(s.target),e=!g(),r=document.activeElement;for(let n of p)if(!(t&&!n.global)&&!(n.scope&&!(n.scope.isConnected&&n.scope.contains(r)))&&!(e&&n.character&&!n.scope)&&!(n.enabled&&!n.enabled())&&x(s,n.descriptor)){s.preventDefault(),n.callback(s);return}}function F(){H||(document.addEventListener("keydown",V),H=!0)}function E(s,t,e={}){F();let r=f(s),n={combo:s,descriptor:r,callback:t,global:e.global===!0,scope:e.scope??null,enabled:typeof e.enabled=="function"?e.enabled:null,character:L(r)},o=p.find(a=>!a.scope&&!n.scope&&M(a.combo,s));return o&&console.warn(`[hotkey-bind] Shortcut "${s}" is already bound as "${o.combo}". Last-bound wins.`),p.unshift(n),function(){let i=p.indexOf(n);i!==-1&&p.splice(i,1)}}var N=window.matchMedia("(prefers-reduced-motion: reduce)");var P=new Map;function m(s,t,e={}){let r=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:r},o=P.get(s);if(customElements.get(s)){if(!o||o.priority>=r){o&&o.priority===r&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=r){o.priority===r&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${o.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}P.set(s,n),customElements.define(s,t)}var b=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,n){t.addEventListener(e,r,n),this.#e.push(()=>t.removeEventListener(e,r,n))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let r=this.#t.states;try{e?r.add(t):r.delete(t)}catch{let n=`--${t}`;e?r.add(n):r.delete(n)}}_adoptInternals(t){this.#t||(this.#t=t)}#n(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var j=0,k=class extends b{#e=null;#t;#n;#r=[];#s=-1;#c=[];#i=[];#o=[];#a="";#l=0;setup(){this.#a=`cmdp-${++j}`,this.#l=0,this.#y(),this.#g(),this.hasAttribute("discover")&&this.#k()}teardown(){this.#i.forEach(t=>t()),this.#i=[],this.#e?.remove(),this.#e=null,this.#r=[],this.#c=[],this.#o=[],this.#s=-1}get commands(){let t=[];for(let e of this.querySelectorAll("command-group")){let r=e.getAttribute("label")||"";for(let n of e.querySelectorAll("command-item"))t.push({value:n.getAttribute("value")||"",label:n.textContent.trim(),hotkey:n.getAttribute("data-hotkey")||void 0,group:r||void 0})}return t}set commands(t){let e=Array.isArray(t)?t:[],r=new Map;for(let n of e){let o=n.group||"";r.has(o)||r.set(o,[]),r.get(o).push(n)}for(let n of[...this.children])(n.tagName==="COMMAND-GROUP"||n.tagName==="COMMAND-ITEM")&&n.remove();for(let[n,o]of r){let a=document.createElement("command-group");n&&a.setAttribute("label",n);for(let i of o){let c=document.createElement("command-item");if(i.value&&c.setAttribute("value",i.value),i.hotkey&&c.setAttribute("data-hotkey",i.hotkey),i.icon){let l=document.createElement("span");l.setAttribute("slot","icon"),l.innerHTML=i.icon,c.appendChild(l)}c.appendChild(document.createTextNode(i.label||i.value||"")),a.appendChild(c)}this.appendChild(a)}this._reinit(),this.dispatchEvent(new CustomEvent("command-palette:commands-changed",{detail:{commands:e,source:"property"},bubbles:!0}))}#y(){this.#e=document.createElement("dialog"),this.#e.className="command-dialog",this.#e.setAttribute("aria-label",this.getAttribute("label")||"Command palette"),this.#e.addEventListener("click",r=>{r.target===this.#e&&this.close()}),this.#e.addEventListener("close",()=>{this.#t?.setAttribute("aria-expanded","false"),this.#t?.removeAttribute("aria-activedescendant"),this.dispatchEvent(new CustomEvent("command-palette:close",{bubbles:!0}))});let t=document.createElement("div");t.className="command-search",this.#n=document.createElement("div"),this.#n.className="command-list",this.#n.id=`${this.#a}-list`,this.#n.setAttribute("role","listbox"),this.#n.setAttribute("aria-label","Commands"),this.#t=document.createElement("input"),this.#t.type="search",this.#t.placeholder=this.getAttribute("placeholder")||"Type a command...",this.#t.setAttribute("aria-label","Search commands"),this.#t.autocomplete="off",this.#t.setAttribute("role","combobox"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#n.id),this.#t.setAttribute("aria-expanded","false"),this.#t.addEventListener("input",this.#u),this.#t.addEventListener("keydown",this.#E),t.appendChild(this.#t),this.#c=Array.from(this.querySelectorAll("command-group")),this.#c.forEach(r=>{let n=this.#d(r.getAttribute("label")||"");this.#n.appendChild(n),r.querySelectorAll("command-item").forEach(o=>{let a=o.querySelector('[slot="icon"]'),i=this.#f(o.textContent.trim(),a?a.cloneNode(!0):null,o.getAttribute("data-hotkey"));i.dataset.value=o.getAttribute("value")||"",i.addEventListener("click",()=>{this.#m(i.dataset.value)}),n.appendChild(i),this.#r.push({btn:i,group:n,source:o})})});let e=document.createElement("div");e.className="command-empty",e.textContent="No results found.",e.hidden=!0,this.#n.appendChild(e),this.#e.appendChild(t),this.#e.appendChild(this.#n),this.appendChild(this.#e)}#d(t){let e=document.createElement("div");e.className="command-group",e.setAttribute("role","group");let r=document.createElement("div");return r.className="command-group-header",r.id=`${this.#a}-g${++this.#l}`,r.setAttribute("aria-hidden","true"),r.textContent=t,t?e.setAttribute("aria-labelledby",r.id):r.hidden=!0,e.appendChild(r),e}#g(){let t=this.getAttribute("hotkey")||"meta+k";this.#i.push(E(t,()=>{this.#e?.open?this.close():this.open()},{global:!0}));for(let{btn:e,source:r}of this.#r){let n=r?.getAttribute("data-hotkey");if(!n||n.toLowerCase()===t.toLowerCase())continue;let o=e.dataset.value;this.#i.push(E(n,()=>this.#m(o)))}}#u=()=>{let t=this.#t.value.toLowerCase().trim(),e=0,r=new Set;this.#r.forEach(({btn:o,group:a})=>{let i=!t||(o.dataset.searchText??"").includes(t);o.hidden=!i,i&&(e++,r.add(a))}),this.#n.querySelectorAll(":scope > .command-group").forEach(o=>{o.hidden=!r.has(o)});let n=this.#n.querySelector(".command-empty");n&&(n.hidden=e>0),this.#s=-1,this.#r.forEach(({btn:o})=>{o.removeAttribute("data-active"),o.setAttribute("aria-selected","false")}),this.#t.removeAttribute("aria-activedescendant"),e>0&&this.#h(0)};#E=t=>{let e=this.#p();switch(t.key){case"ArrowDown":t.preventDefault(),this.#h(this.#s+1);break;case"ArrowUp":t.preventDefault(),this.#h(this.#s-1);break;case"Enter":t.preventDefault(),this.#s>=0&&e[this.#s]&&e[this.#s].btn.click();break;case"Escape":t.preventDefault(),this.close();break}};#p(){return this.#r.filter(({btn:t})=>!t.hidden)}#h(t){let e=this.#p();if(e.length===0)return;e.forEach(({btn:n})=>{n.removeAttribute("data-active"),n.setAttribute("aria-selected","false")}),t<0&&(t=e.length-1),t>=e.length&&(t=0),this.#s=t;let{btn:r}=e[t];r.setAttribute("data-active",""),r.setAttribute("aria-selected","true"),this.#t.setAttribute("aria-activedescendant",r.id),r.scrollIntoView({block:"nearest"})}#m(t){this.close(),this.dispatchEvent(new CustomEvent("command-palette:select",{bubbles:!0,detail:{value:t}}))}#k(){this.listen(document,"vb:command-registry-change",this.#v)}#v=()=>{this.#e?.open&&(this.#b(),this.#u())};#b(){if(!this.hasAttribute("discover"))return;let{getRegisteredCommands:t,scanAutoDiscoverable:e}=window.__commandRegistry||{};if(!t)return;this.#r=this.#r.filter(o=>!o.discovered),this.#o.forEach(o=>o.remove()),this.#o=[];let r=this.#n.querySelector(".command-empty"),n=t();for(let[o,a]of n){let i=this.#d(o);this.#n.insertBefore(i,r),this.#o.push(i);for(let c of a){if(this.contains(c.element))continue;let l=this.#f(c.label,c.icon,c.shortcut);l.dataset.value=`__discovered:${c.label}`,l.addEventListener("click",()=>{this.close(),c.element.click()}),i.appendChild(l),this.#r.push({btn:l,group:i,source:null,discovered:!0})}}if(this.getAttribute("discover")==="auto"&&e){let o=e(),a=new Map;for(let i of o){let c=a.get(i.group)||[];c.push(i),a.set(i.group,c)}for(let[i,c]of a){let l=this.#d(i);this.#n.insertBefore(l,r),this.#o.push(l);for(let d of c){if(this.contains(d.element))continue;let h=this.#f(d.label,d.icon,d.shortcut);h.dataset.value=`__auto:${d.label}`,h.dataset.auto="",h.addEventListener("click",()=>{this.close(),d.action?d.action():d.element.click()}),l.appendChild(h),this.#r.push({btn:h,group:l,source:null,discovered:!0})}}}}#f(t,e,r){let n=document.createElement("button");if(n.type="button",n.className="command-option",n.id=`${this.#a}-opt-${++this.#l}`,n.setAttribute("role","option"),n.setAttribute("aria-selected","false"),n.tabIndex=-1,n.dataset.searchText=t.toLowerCase(),e){let a=document.createElement("span");if(a.className="command-icon",typeof e=="string"){let i=document.createElement("icon-wc");i.setAttribute("name",e),a.appendChild(i)}else a.appendChild(e);n.appendChild(a)}let o=document.createElement("span");if(o.className="command-label",o.textContent=t,n.appendChild(o),r){let a=document.createElement("kbd");a.className="command-kbd",a.setAttribute("aria-hidden","true"),a.textContent=$(r),n.appendChild(a),n.setAttribute("aria-keyshortcuts",r)}return n}open(){!this.#e||this.#e.open||(this.#b(),this.#e.showModal(),this.#t.setAttribute("aria-expanded","true"),this.#t.value="",this.#u(),this.#t.focus(),this.dispatchEvent(new CustomEvent("command-palette:open",{bubbles:!0})))}close(){this.#e?.open&&this.#e.close()}get isOpen(){return this.#e?.open??!1}},v=class extends HTMLElement{},A=class extends HTMLElement{};m("command-palette",k);m("command-group",v);m("command-item",A);export{k as CommandPalette};
|
|
2
2
|
//# sourceMappingURL=command-palette.js.map
|