vanilla-breeze 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/components/accordion-wc.js +1 -1
- package/dist/cdn/components/analytics-panel.js +1 -1
- package/dist/cdn/components/audio-player.js +1 -1
- package/dist/cdn/components/audio-visualizer.js +2 -2
- package/dist/cdn/components/author-index.js +1 -1
- package/dist/cdn/components/brand-mark.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 +11 -11
- package/dist/cdn/components/chat-input.js +1 -1
- package/dist/cdn/components/chat-window.js +1 -1
- package/dist/cdn/components/color-palette.js +4 -4
- 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-wc.js +1 -1
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/component-sampler.js +4 -4
- 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/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/font-pairer.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/gantt-chart.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/gradient-builder.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/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/impact-effort.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/kanban-board.js +1 -1
- package/dist/cdn/components/manifest.json +95 -95
- package/dist/cdn/components/markdown-editor.js +1 -1
- package/dist/cdn/components/markdown-viewer.js +1 -1
- package/dist/cdn/components/motion-specimen.js +3 -3
- package/dist/cdn/components/note-wc.js +1 -1
- package/dist/cdn/components/notification-wc.js +4 -4
- package/dist/cdn/components/page-info.js +20 -20
- 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 +2 -2
- package/dist/cdn/components/palette-generator.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/qr-code.js +1 -1
- package/dist/cdn/components/reader-view.js +2 -2
- package/dist/cdn/components/recently-visited.js +26 -2
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/semantic-palette.js +1 -1
- package/dist/cdn/components/settings-panel.js +2 -2
- package/dist/cdn/components/share-wc.js +1 -1
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -1
- package/dist/cdn/components/site-map-wc.js +1 -1
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +3 -3
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/spacing-specimen.js +2 -2
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/story-map.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-export.js +1 -1
- package/dist/cdn/components/theme-picker.js +3 -3
- 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 +1 -1
- package/dist/cdn/components/token-specimen.js +6 -6
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +3 -2
- package/dist/cdn/components/trust-filter.js +3 -3
- package/dist/cdn/components/type-specimen.js +1 -1
- package/dist/cdn/components/user-story.js +8 -8
- 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/work-item.js +14 -14
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/packs/design-system.full.js +15 -15
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/manifest.json +5 -5
- package/dist/cdn/packs/ui.full.css +1 -1
- package/dist/cdn/packs/ui.full.js +5 -5
- package/dist/cdn/packs/ux-planning.full.js +119 -119
- package/dist/cdn/vanilla-breeze-charts.css +1 -1
- package/dist/cdn/vanilla-breeze-charts.js +11 -11
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +21 -21
- package/dist/cdn/vanilla-breeze-extras.js +3 -3
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +210 -185
- package/package.json +5 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var E=window.matchMedia("(prefers-reduced-motion: reduce)");var f=new Map;function v(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=f.get(n);if(customElements.get(n)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> 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 <${n}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}f.set(n,s),customElements.define(n,t)}var p=class extends HTMLElement{#d=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let t of this.#d)t();this.#d=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#d.push(()=>t.removeEventListener(e,i,s))}setup(){}teardown(){}};var y="popover"in HTMLElement.prototype;function d(n,t,e){t/=100,e/=100;let i=o=>(o+n/30)%12,s=t*Math.min(e,1-e),r=o=>e-s*Math.max(-1,Math.min(i(o)-3,9-i(o),1));return{r:Math.round(r(0)*255),g:Math.round(r(8)*255),b:Math.round(r(4)*255)}}function m(n,t,e){n/=255,t/=255,e/=255;let i=Math.max(n,t,e),s=Math.min(n,t,e),r=(i+s)/2,o=0,a=0;if(i!==s){let u=i-s;switch(a=r>.5?u/(2-i-s):u/(i+s),i){case n:o=((t-e)/u+(t<e?6:0))/6;break;case t:o=((e-n)/u+2)/6;break;case e:o=((n-t)/u+4)/6;break}}return{h:Math.round(o*360),s:Math.round(a*100),l:Math.round(r*100)}}function w(n){n=n.replace(/^#/,""),n.length===3&&(n=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]);let t=parseInt(n,16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function g(n,t,e){return"#"+[n,t,e].map(i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0")).join("")}function l(n){let{r:t,g:e,b:i}=w(n);return m(t,e,i)}function c(n,t,e){let{r:i,g:s,b:r}=d(n,t,e);return g(i,s,r)}function h(n,t,e){return Math.max(t,Math.min(e,n))}var b=class extends p{static formAssociated=!0;#d;#h;#o;#E;#A;#r;#n;#m;#s;#x;#f;#v;#y;#w;#c;#u;#a;#p=!1;#g=!1;#t=0;#e=100;#i=50;#T;constructor(){super(),this.#d=this.attachInternals()}setup(){if(this.#h=this.querySelector(':scope > input[type="color"]'),!this.#h)return!1;let t=this.#h.value||"#000000";this.#T=t;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#h.setAttribute("tabindex","-1"),this.#h.setAttribute("aria-hidden","true"),this.#h.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.#P(),this.#D(),this.#C(),this.#k(),this.#g=y,this.#g&&this.#r.setAttribute("popover","manual"),this.listen(document,"click",this.#G),(this.#h.disabled||this.hasAttribute("disabled"))&&this.setAttribute("data-disabled","")}teardown(){window.removeEventListener("scroll",this.#b,{capture:!0}),window.removeEventListener("resize",this.#b)}#P(){this.#o=document.createElement("button"),this.#o.type="button",this.#o.className="color-trigger",this.#o.setAttribute("aria-haspopup","dialog"),this.#o.setAttribute("aria-expanded","false"),this.#E=document.createElement("span"),this.#E.className="color-swatch",this.#A=document.createElement("span"),this.#A.className="color-hex",this.#o.appendChild(this.#E),this.#o.appendChild(this.#A),this.appendChild(this.#o),this.listen(this.#o,"click",()=>{this.#p?this.#$():this.#z()})}#D(){this.#r=document.createElement("div"),this.#r.className="color-panel",this.#r.setAttribute("role","dialog"),this.#r.setAttribute("aria-label","Color picker"),this.#n=document.createElement("div"),this.#n.className="color-area",this.#n.setAttribute("role","slider"),this.#n.setAttribute("aria-label","Saturation and lightness"),this.#n.setAttribute("tabindex","0"),this.#m=document.createElement("div"),this.#m.className="color-area-thumb",this.#n.appendChild(this.#m),this.#r.appendChild(this.#n);let t=document.createElement("div");t.className="color-hue-wrap",this.#s=document.createElement("div"),this.#s.className="color-hue",this.#s.setAttribute("role","slider"),this.#s.setAttribute("aria-label","Hue"),this.#s.setAttribute("aria-valuemin","0"),this.#s.setAttribute("aria-valuemax","360"),this.#s.setAttribute("tabindex","0"),this.#x=document.createElement("div"),this.#x.className="color-hue-thumb",this.#s.appendChild(this.#x),t.appendChild(this.#s),this.#r.appendChild(t);let e=document.createElement("div");e.className="color-inputs",this.#f=this.#B("Hex","hex",7),this.#v=this.#M("R","r",0,255),this.#y=this.#M("G","g",0,255),this.#w=this.#M("B","b",0,255),e.appendChild(this.#f.wrapper),e.appendChild(this.#v.wrapper),e.appendChild(this.#y.wrapper),e.appendChild(this.#w.wrapper),this.#r.appendChild(e);let i=this.querySelector(":scope > datalist");if(i){this.#c=document.createElement("div"),this.#c.className="color-swatches",this.#c.setAttribute("role","listbox"),this.#c.setAttribute("aria-label","Preset colors");for(let r of i.querySelectorAll("option[value]")){let o=document.createElement("button");o.type="button",o.setAttribute("role","option"),o.style.background=r.value,o.setAttribute("aria-label",r.textContent||r.value),o.setAttribute("data-color",r.value),this.#c.appendChild(o)}this.#r.appendChild(this.#c),this.listen(this.#c,"click",this.#V)}let s=document.createElement("div");s.className="color-actions","EyeDropper"in window&&(this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="color-eyedropper",this.#u.setAttribute("aria-label","Pick color from screen"),this.#u.textContent="\u{1F4A7}",s.appendChild(this.#u),this.listen(this.#u,"click",this.#j)),this.#a=document.createElement("button"),this.#a.type="button",this.#a.className="color-copy",this.#a.setAttribute("aria-label","Copy hex value"),this.#a.textContent="Copy",s.appendChild(this.#a),this.listen(this.#a,"click",this.#K),this.#r.appendChild(s),this.appendChild(this.#r),this.listen(this.#n,"pointerdown",this.#F),this.listen(this.#n,"keydown",this.#R),this.listen(this.#s,"pointerdown",this.#I),this.listen(this.#s,"keydown",this.#q),this.listen(this.#f.input,"change",this.#O),this.listen(this.#v.input,"change",this.#S),this.listen(this.#y.input,"change",this.#S),this.listen(this.#w.input,"change",this.#S)}#B(t,e,i){let s=document.createElement("label");s.className="color-input-label";let r=document.createElement("span");r.textContent=t;let o=document.createElement("input");return o.type="text",o.setAttribute("data-channel",e),o.setAttribute("maxlength",String(i)),o.setAttribute("spellcheck","false"),o.setAttribute("autocomplete","off"),s.appendChild(r),s.appendChild(o),{wrapper:s,input:o}}#M(t,e,i,s){let r=document.createElement("label");r.className="color-input-label";let o=document.createElement("span");o.textContent=t;let a=document.createElement("input");return a.type="number",a.setAttribute("data-channel",e),a.min=String(i),a.max=String(s),r.appendChild(o),r.appendChild(a),{wrapper:r,input:a}}#F=t=>{t.preventDefault(),this.#n.setPointerCapture(t.pointerId),this.#N(t);let e=s=>this.#N(s),i=s=>{this.#n.releasePointerCapture(s.pointerId),this.#n.removeEventListener("pointermove",e),this.#n.removeEventListener("pointerup",i)};this.#n.addEventListener("pointermove",e),this.#n.addEventListener("pointerup",i)};#N(t){let e=this.#n.getBoundingClientRect(),i=h((t.clientX-e.left)/e.width,0,1),s=h((t.clientY-e.top)/e.height,0,1);this.#e=Math.round(i*100),this.#i=Math.round((1-s)*100),this.#l()}#R=t=>{let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":t.preventDefault(),this.#e=h(this.#e+e,0,100);break;case"ArrowLeft":t.preventDefault(),this.#e=h(this.#e-e,0,100);break;case"ArrowUp":t.preventDefault(),this.#i=h(this.#i+e,0,100);break;case"ArrowDown":t.preventDefault(),this.#i=h(this.#i-e,0,100);break;default:return}this.#l()};#I=t=>{t.preventDefault(),this.#s.setPointerCapture(t.pointerId),this.#L(t);let e=s=>this.#L(s),i=s=>{this.#s.releasePointerCapture(s.pointerId),this.#s.removeEventListener("pointermove",e),this.#s.removeEventListener("pointerup",i)};this.#s.addEventListener("pointermove",e),this.#s.addEventListener("pointerup",i)};#L(t){let e=this.#s.getBoundingClientRect(),i=h((t.clientX-e.left)/e.width,0,1);this.#t=Math.round(i*360),this.#l()}#q=t=>{let e=t.shiftKey?10:1;switch(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;default:return}this.#l()};#O=()=>{let t=this.#f.input.value.trim();if(t.startsWith("#")||(t="#"+t),/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)){let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#l()}};#S=()=>{let t=h(Number(this.#v.input.value)||0,0,255),e=h(Number(this.#y.input.value)||0,0,255),i=h(Number(this.#w.input.value)||0,0,255),s=m(t,e,i);this.#t=s.h,this.#e=s.s,this.#i=s.l,this.#l()};#V=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let i=e.getAttribute("data-color"),s=l(i);this.#t=s.h,this.#e=s.s,this.#i=s.l,this.#l()};#j=async()=>{try{let e=await new EyeDropper().open(),i=l(e.sRGBHex);this.#t=i.h,this.#e=i.s,this.#i=i.l,this.#l()}catch{}};#K=async()=>{let t=c(this.#t,this.#e,this.#i);try{await navigator.clipboard.writeText(t),this.#a.textContent="Copied!",setTimeout(()=>{this.#a.textContent="Copy"},1500)}catch{}};#l(){this.#C(),this.#k();let t=c(this.#t,this.#e,this.#i),e=d(this.#t,this.#e,this.#i);this.dispatchEvent(new CustomEvent("color-picker:change",{bubbles:!0,detail:{hex:t,rgb:{r:e.r,g:e.g,b:e.b},hsl:{h:this.#t,s:this.#e,l:this.#i}}}))}#C(){let t=c(this.#t,this.#e,this.#i),e=d(this.#t,this.#e,this.#i),i=c(this.#t,100,50);this.#E.style.background=t,this.#A.textContent=t,this.#n.style.setProperty("--area-hue",i),this.#m.style.insetInlineStart=`${this.#e}%`,this.#m.style.insetBlockStart=`${100-this.#i}%`,this.#m.style.background=t,this.#n.setAttribute("aria-valuetext",`Saturation ${this.#e}%, Lightness ${this.#i}%`),this.#x.style.insetInlineStart=`${this.#t/360*100}%`,this.#s.setAttribute("aria-valuenow",String(this.#t)),this.#s.setAttribute("aria-valuetext",`Hue ${this.#t}\xB0`),this.#f.input.value=t,this.#v.input.value=String(e.r),this.#y.input.value=String(e.g),this.#w.input.value=String(e.b)}#z(){if(!this.#p){if(this.#p=!0,this.setAttribute("open",""),this.#o.setAttribute("aria-expanded","true"),this.#g){this.#H();try{this.#r.showPopover()}catch{}window.addEventListener("scroll",this.#b,{capture:!0,passive:!0}),window.addEventListener("resize",this.#b,{passive:!0})}requestAnimationFrame(()=>this.#n.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#$(){if(this.#p){if(this.#p=!1,this.removeAttribute("open"),this.#o.setAttribute("aria-expanded","false"),this.#g){try{this.#r.hidePopover()}catch{}window.removeEventListener("scroll",this.#b,{capture:!0}),window.removeEventListener("resize",this.#b)}this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}}#H(){if(!this.#g)return;let t=this.#o.getBoundingClientRect();this.#r.style.setProperty("--panel-top",`${t.bottom+4}px`),this.#r.style.setProperty("--panel-left",`${t.left}px`)}#b=()=>{this.#p&&this.#H()};#G=t=>{this.#p&&!this.contains(t.target)&&this.#$()};#k(){let t=c(this.#t,this.#e,this.#i);this.#d.setFormValue(t),this.#h.value=t,this.#h.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){let t=l(this.#T);this.#t=t.h,this.#e=t.s,this.#i=t.l,this.#C(),this.#k()}formStateRestoreCallback(t){if(!t)return;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#C(),this.#k()}get value(){return c(this.#t,this.#e,this.#i)}set value(t){if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t))return;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#l()}};v("color-picker",b);export{b as ColorPicker};
|
|
1
|
+
var E=window.matchMedia("(prefers-reduced-motion: reduce)");var f=new Map;function v(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=f.get(n);if(customElements.get(n)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> 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 <${n}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}f.set(n,s),customElements.define(n,t)}var p=class extends HTMLElement{#d=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),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,s){t.addEventListener(e,i,s),this.#d.push(()=>t.removeEventListener(e,i,s))}setup(){}teardown(){}};var y="popover"in HTMLElement.prototype;function d(n,t,e){t/=100,e/=100;let i=o=>(o+n/30)%12,s=t*Math.min(e,1-e),r=o=>e-s*Math.max(-1,Math.min(i(o)-3,9-i(o),1));return{r:Math.round(r(0)*255),g:Math.round(r(8)*255),b:Math.round(r(4)*255)}}function m(n,t,e){n/=255,t/=255,e/=255;let i=Math.max(n,t,e),s=Math.min(n,t,e),r=(i+s)/2,o=0,a=0;if(i!==s){let u=i-s;switch(a=r>.5?u/(2-i-s):u/(i+s),i){case n:o=((t-e)/u+(t<e?6:0))/6;break;case t:o=((e-n)/u+2)/6;break;case e:o=((n-t)/u+4)/6;break}}return{h:Math.round(o*360),s:Math.round(a*100),l:Math.round(r*100)}}function w(n){n=n.replace(/^#/,""),n.length===3&&(n=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]);let t=parseInt(n,16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function g(n,t,e){return"#"+[n,t,e].map(i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0")).join("")}function l(n){let{r:t,g:e,b:i}=w(n);return m(t,e,i)}function c(n,t,e){let{r:i,g:s,b:r}=d(n,t,e);return g(i,s,r)}function h(n,t,e){return Math.max(t,Math.min(e,n))}var b=class extends p{static formAssociated=!0;#d;#h;#o;#E;#A;#r;#n;#m;#s;#x;#f;#v;#y;#w;#c;#u;#a;#p=!1;#g=!1;#t=0;#e=100;#i=50;#N;constructor(){super(),this.#d=this.attachInternals()}setup(){if(this.#h=this.querySelector(':scope > input[type="color"]'),!this.#h)return!1;let t=this.#h.value||"#000000";this.#N=t;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#h.setAttribute("tabindex","-1"),this.#h.setAttribute("aria-hidden","true"),this.#h.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.#P(),this.#D(),this.#C(),this.#k(),this.#g=y,this.#g&&this.#r.setAttribute("popover","manual"),this.listen(document,"click",this.#G),(this.#h.disabled||this.hasAttribute("disabled"))&&this.setAttribute("data-disabled","")}teardown(){window.removeEventListener("scroll",this.#b,{capture:!0}),window.removeEventListener("resize",this.#b)}#P(){this.#o=document.createElement("button"),this.#o.type="button",this.#o.className="color-trigger",this.#o.setAttribute("aria-haspopup","dialog"),this.#o.setAttribute("aria-expanded","false"),this.#E=document.createElement("span"),this.#E.className="color-swatch",this.#A=document.createElement("span"),this.#A.className="color-hex",this.#o.appendChild(this.#E),this.#o.appendChild(this.#A),this.appendChild(this.#o),this.listen(this.#o,"click",()=>{this.#p?this.#L():this.#z()})}#D(){this.#r=document.createElement("div"),this.#r.className="color-panel",this.#r.setAttribute("role","dialog"),this.#r.setAttribute("aria-label","Color picker"),this.#n=document.createElement("div"),this.#n.className="color-area",this.#n.setAttribute("role","slider"),this.#n.setAttribute("aria-label","Saturation and lightness"),this.#n.setAttribute("tabindex","0"),this.#m=document.createElement("div"),this.#m.className="color-area-thumb",this.#n.appendChild(this.#m),this.#r.appendChild(this.#n);let t=document.createElement("div");t.className="color-hue-wrap",this.#s=document.createElement("div"),this.#s.className="color-hue",this.#s.setAttribute("role","slider"),this.#s.setAttribute("aria-label","Hue"),this.#s.setAttribute("aria-valuemin","0"),this.#s.setAttribute("aria-valuemax","360"),this.#s.setAttribute("tabindex","0"),this.#x=document.createElement("div"),this.#x.className="color-hue-thumb",this.#s.appendChild(this.#x),t.appendChild(this.#s),this.#r.appendChild(t);let e=document.createElement("div");e.className="color-inputs",this.#f=this.#B("Hex","hex",7),this.#v=this.#M("R","r",0,255),this.#y=this.#M("G","g",0,255),this.#w=this.#M("B","b",0,255),e.appendChild(this.#f.wrapper),e.appendChild(this.#v.wrapper),e.appendChild(this.#y.wrapper),e.appendChild(this.#w.wrapper),this.#r.appendChild(e);let i=this.querySelector(":scope > datalist");if(i){this.#c=document.createElement("div"),this.#c.className="color-swatches",this.#c.setAttribute("role","listbox"),this.#c.setAttribute("aria-label","Preset colors");for(let r of i.querySelectorAll("option[value]")){let o=document.createElement("button");o.type="button",o.setAttribute("role","option"),o.style.background=r.value,o.setAttribute("aria-label",r.textContent||r.value),o.setAttribute("data-color",r.value),this.#c.appendChild(o)}this.#r.appendChild(this.#c),this.listen(this.#c,"click",this.#V)}let s=document.createElement("div");s.className="color-actions","EyeDropper"in window&&(this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="color-eyedropper",this.#u.setAttribute("aria-label","Pick color from screen"),this.#u.textContent="\u{1F4A7}",s.appendChild(this.#u),this.listen(this.#u,"click",this.#j)),this.#a=document.createElement("button"),this.#a.type="button",this.#a.className="color-copy",this.#a.setAttribute("aria-label","Copy hex value"),this.#a.textContent="Copy",s.appendChild(this.#a),this.listen(this.#a,"click",this.#K),this.#r.appendChild(s),this.appendChild(this.#r),this.listen(this.#n,"pointerdown",this.#F),this.listen(this.#n,"keydown",this.#R),this.listen(this.#s,"pointerdown",this.#I),this.listen(this.#s,"keydown",this.#q),this.listen(this.#f.input,"change",this.#O),this.listen(this.#v.input,"change",this.#S),this.listen(this.#y.input,"change",this.#S),this.listen(this.#w.input,"change",this.#S)}#B(t,e,i){let s=document.createElement("label");s.className="color-input-label";let r=document.createElement("span");r.textContent=t;let o=document.createElement("input");return o.type="text",o.setAttribute("data-channel",e),o.setAttribute("maxlength",String(i)),o.setAttribute("spellcheck","false"),o.setAttribute("autocomplete","off"),s.appendChild(r),s.appendChild(o),{wrapper:s,input:o}}#M(t,e,i,s){let r=document.createElement("label");r.className="color-input-label";let o=document.createElement("span");o.textContent=t;let a=document.createElement("input");return a.type="number",a.setAttribute("data-channel",e),a.min=String(i),a.max=String(s),r.appendChild(o),r.appendChild(a),{wrapper:r,input:a}}#F=t=>{t.preventDefault(),this.#n.setPointerCapture(t.pointerId),this.#T(t);let e=s=>this.#T(s),i=s=>{this.#n.releasePointerCapture(s.pointerId),this.#n.removeEventListener("pointermove",e),this.#n.removeEventListener("pointerup",i)};this.#n.addEventListener("pointermove",e),this.#n.addEventListener("pointerup",i)};#T(t){let e=this.#n.getBoundingClientRect(),i=h((t.clientX-e.left)/e.width,0,1),s=h((t.clientY-e.top)/e.height,0,1);this.#e=Math.round(i*100),this.#i=Math.round((1-s)*100),this.#l()}#R=t=>{let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":t.preventDefault(),this.#e=h(this.#e+e,0,100);break;case"ArrowLeft":t.preventDefault(),this.#e=h(this.#e-e,0,100);break;case"ArrowUp":t.preventDefault(),this.#i=h(this.#i+e,0,100);break;case"ArrowDown":t.preventDefault(),this.#i=h(this.#i-e,0,100);break;default:return}this.#l()};#I=t=>{t.preventDefault(),this.#s.setPointerCapture(t.pointerId),this.#$(t);let e=s=>this.#$(s),i=s=>{this.#s.releasePointerCapture(s.pointerId),this.#s.removeEventListener("pointermove",e),this.#s.removeEventListener("pointerup",i)};this.#s.addEventListener("pointermove",e),this.#s.addEventListener("pointerup",i)};#$(t){let e=this.#s.getBoundingClientRect(),i=h((t.clientX-e.left)/e.width,0,1);this.#t=Math.round(i*360),this.#l()}#q=t=>{let e=t.shiftKey?10:1;switch(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;default:return}this.#l()};#O=()=>{let t=this.#f.input.value.trim();if(t.startsWith("#")||(t="#"+t),/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)){let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#l()}};#S=()=>{let t=h(Number(this.#v.input.value)||0,0,255),e=h(Number(this.#y.input.value)||0,0,255),i=h(Number(this.#w.input.value)||0,0,255),s=m(t,e,i);this.#t=s.h,this.#e=s.s,this.#i=s.l,this.#l()};#V=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let i=e.getAttribute("data-color"),s=l(i);this.#t=s.h,this.#e=s.s,this.#i=s.l,this.#l()};#j=async()=>{try{let e=await new EyeDropper().open(),i=l(e.sRGBHex);this.#t=i.h,this.#e=i.s,this.#i=i.l,this.#l()}catch{}};#K=async()=>{let t=c(this.#t,this.#e,this.#i);try{await navigator.clipboard.writeText(t),this.#a.textContent="Copied!",setTimeout(()=>{this.#a.textContent="Copy"},1500)}catch{}};#l(){this.#C(),this.#k();let t=c(this.#t,this.#e,this.#i),e=d(this.#t,this.#e,this.#i);this.dispatchEvent(new CustomEvent("color-picker:change",{bubbles:!0,detail:{hex:t,rgb:{r:e.r,g:e.g,b:e.b},hsl:{h:this.#t,s:this.#e,l:this.#i}}}))}#C(){let t=c(this.#t,this.#e,this.#i),e=d(this.#t,this.#e,this.#i),i=c(this.#t,100,50);this.#E.style.background=t,this.#A.textContent=t,this.#n.style.setProperty("--area-hue",i),this.#m.style.insetInlineStart=`${this.#e}%`,this.#m.style.insetBlockStart=`${100-this.#i}%`,this.#m.style.background=t,this.#n.setAttribute("aria-valuetext",`Saturation ${this.#e}%, Lightness ${this.#i}%`),this.#x.style.insetInlineStart=`${this.#t/360*100}%`,this.#s.setAttribute("aria-valuenow",String(this.#t)),this.#s.setAttribute("aria-valuetext",`Hue ${this.#t}\xB0`),this.#f.input.value=t,this.#v.input.value=String(e.r),this.#y.input.value=String(e.g),this.#w.input.value=String(e.b)}#z(){if(!this.#p){if(this.#p=!0,this.setAttribute("open",""),this.#o.setAttribute("aria-expanded","true"),this.#g){this.#H();try{this.#r.showPopover()}catch{}window.addEventListener("scroll",this.#b,{capture:!0,passive:!0}),window.addEventListener("resize",this.#b,{passive:!0})}requestAnimationFrame(()=>this.#n.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#L(){if(this.#p){if(this.#p=!1,this.removeAttribute("open"),this.#o.setAttribute("aria-expanded","false"),this.#g){try{this.#r.hidePopover()}catch{}window.removeEventListener("scroll",this.#b,{capture:!0}),window.removeEventListener("resize",this.#b)}this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}}#H(){if(!this.#g)return;let t=this.#o.getBoundingClientRect();this.#r.style.setProperty("--panel-top",`${t.bottom+4}px`),this.#r.style.setProperty("--panel-left",`${t.left}px`)}#b=()=>{this.#p&&this.#H()};#G=t=>{this.#p&&!this.contains(t.target)&&this.#L()};#k(){let t=c(this.#t,this.#e,this.#i);this.#d.setFormValue(t),this.#h.value=t,this.#h.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){let t=l(this.#N);this.#t=t.h,this.#e=t.s,this.#i=t.l,this.#C(),this.#k()}formStateRestoreCallback(t){if(!t)return;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#C(),this.#k()}get value(){return c(this.#t,this.#e,this.#i)}set value(t){if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t))return;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#l()}};v("color-picker",b);export{b as ColorPicker};
|
|
2
2
|
//# sourceMappingURL=color-picker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(h,t,e={}){let i=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=c.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}c.set(h,r),customElements.define(h,t)}var l=class extends HTMLElement{#r=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let t of this.#r)t();this.#r=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,r){t.addEventListener(e,i,r),this.#r.push(()=>t.removeEventListener(e,i,r))}setup(){}teardown(){}};function f(h,t,e){"role"in ElementInternals.prototype?t.role=e:h.setAttribute("role",e)}var p="popover"in HTMLElement.prototype;var u=class extends l{static formAssociated=!0;#r;#t;#e;#l=[];#h=[];#o=-1;#a=!1;#m=!1;#n="";#f="";#k="";#u;#p;#i=[];constructor(){super(),this.#r=this.attachInternals()}get#s(){return this.hasAttribute("multiple")}setup(){if(this.#t=this.querySelector(":scope > input")||this.querySelector(":scope > .tags-input-area > input"),!this.#t||(this.#e=this.querySelector(":scope > ul, :scope > ol"),!this.#e))return!1;this.#m=p,this.#m&&this.#e.setAttribute("popover","manual"),this.#s&&(this.#u=document.createElement("div"),this.#u.className="tags-input-area",this.insertBefore(this.#u,this.#e),this.#u.appendChild(this.#t),this.#p=document.createElement("div"),this.#p.setAttribute("aria-live","polite"),this.#p.setAttribute("aria-atomic","true"),this.#p.className="sr-only",this.appendChild(this.#p));let t=this.getAttribute("placeholder");t&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",t);let e=crypto.randomUUID().slice(0,8);if(this.#e.id||(this.#e.id=`combobox-listbox-${e}`),f(this.#t,this.#r,"combobox"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#e.id),this.#t.setAttribute("autocomplete","off"),this.#e.setAttribute("role","listbox"),this.#s&&this.#e.setAttribute("aria-multiselectable","true"),this.#P(),!this.#s){let i=this.getAttribute("value");i&&this.#y(i,!1),this.#k=this.#n}this.listen(this.#t,"input",this.#V),this.listen(this.#t,"keydown",this.#T),this.listen(this.#t,"focus",this.#q),this.listen(this.#t,"click",this.#O),this.listen(this.#e,"click",this.#F),this.listen(this.#e,"pointerdown",this.#B),this.listen(document,"click",this.#I),this.#m&&this.listen(this.#e,"toggle",this.#R),this.#c(),this.#d(),this.#b()}teardown(){window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}#P(){this.#l=Array.from(this.#e.querySelectorAll(":scope > li[data-value]")),this.#l.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#e.id}-option-${e}`)}),this.#h=[...this.#l]}#E(t,e){if(this.#i.some(a=>a.value===t))return;let i=this.#S();if(i&&this.#i.length>=i)return;this.#i.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.addEventListener("click",a=>{a.stopPropagation(),this.#$(t)}),r.appendChild(s),this.#u.insertBefore(r,this.#t);let o=this.#l.find(a=>a.getAttribute("data-value")===t);o&&o.setAttribute("aria-selected","true"),this.#L(`${e} added`),this.#t.value="",this.#v(""),this.#c(),this.#d(),this.#D(),i&&this.#i.length>=i&&(this.#t.disabled=!0,this.#b())}#$(t){let e=this.#i.findIndex(a=>a.value===t);if(e===-1)return;let i=this.#i.splice(e,1)[0],r=this.#u.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);r&&r.remove();let s=this.#l.find(a=>a.getAttribute("data-value")===t);s&&s.setAttribute("aria-selected","false"),this.#L(`${i.label} removed`),this.#S()&&this.#t.disabled&&(this.#t.disabled=!1),this.#v(this.#t.value.trim()),this.#c(),this.#d(),this.#D(),this.#t.focus()}#S(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#L(t){this.#p&&(this.#p.textContent="",requestAnimationFrame(()=>{this.#p.textContent=t}))}#V=()=>{let t=this.#t.value.trim();if(!this.#s&&this.#n){let e=this.#e.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#n="",this.#f="",this.removeAttribute("value"),this.#c(),this.#d()}this.#v(t),this.#g()};#T=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#a||this.#g(),this.#w(this.#o+1);break;case"ArrowUp":t.preventDefault(),this.#a||this.#g(),this.#w(this.#o-1);break;case"Home":this.#a&&(t.preventDefault(),this.#w(0));break;case"End":this.#a&&(t.preventDefault(),this.#w(this.#h.length-1));break;case"Enter":if(t.preventDefault(),this.#a&&this.#o>=0&&this.#h[this.#o]){let e=this.#h[this.#o];this.#s?this.#E(e.getAttribute("data-value"),e.textContent.trim()):this.#C(e)}else if(this.#s&&this.hasAttribute("custom")&&this.#t.value.trim()){let e=this.#t.value.trim();this.#E(e,e)}break;case"Backspace":if(this.#s&&!this.#t.value&&this.#i.length>0){let e=this.#i[this.#i.length-1];this.#$(e.value)}break;case",":if(this.#s&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#E(e,e)}break;case"Escape":this.#a&&(t.preventDefault(),t.stopPropagation(),this.#b(),this.#t.focus());break;case"Tab":this.#a&&this.#b();break}};#q=()=>{this.#s?(this.#v(this.#t.value.trim()),this.#g()):(this.#t.value||!this.#n)&&(this.#v(this.#t.value.trim()),this.#g())};#O=()=>{this.#a||(this.#v(this.#t.value.trim()),this.#g())};#F=t=>{let e=t.target.closest("li[data-value]");e&&this.#h.includes(e)&&(this.#s?this.#E(e.getAttribute("data-value"),e.textContent.trim()):this.#C(e))};#B=t=>{t.preventDefault()};#I=t=>{this.#a&&!this.contains(t.target)&&this.#b()};#v(t){let e=this.getAttribute("filter")||"contains",i=t.toLowerCase(),r=this.#s?new Set(this.#i.map(s=>s.value)):null;this.#h=[],this.#l.forEach(s=>{let o=s.getAttribute("data-value"),a=s.textContent.trim().toLowerCase();if(r&&r.has(o)){s.hidden=!0;return}let n;t?e==="startsWith"?n=a.startsWith(i):n=a.includes(i):n=!0,s.hidden=!n,n&&this.#h.push(s)}),this.#o=-1,this.#x()}#w(t){if(this.#h.length===0)return;t<0&&(t=this.#h.length-1),t>=this.#h.length&&(t=0),this.#o>=0&&this.#h[this.#o]&&this.#h[this.#o].removeAttribute("data-active"),this.#o=t;let e=this.#h[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#x(){this.#l.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#C(t){let e=t.getAttribute("data-value"),i=t.textContent.trim();this.#l.forEach(r=>r.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#n=e,this.#f=i,this.#t.value=i,this.setAttribute("value",e),this.#c(),this.#d(),this.#b(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:e,label:i}}))}#y(t,e=!0){let i=this.#l.find(r=>r.getAttribute("data-value")===t);i&&(e?this.#C(i):(i.setAttribute("aria-selected","true"),this.#n=t,this.#f=i.textContent.trim(),this.#t.value=this.#f,this.setAttribute("value",t)))}#A=()=>this.#M();#g(){if(!this.#a){if(this.#a=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#e.hidden=!1,this.#m){this.#M();try{this.#e.showPopover()}catch{}window.addEventListener("scroll",this.#A,{capture:!0,passive:!0}),window.addEventListener("resize",this.#A,{passive:!0})}this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0}))}}#b(){if(!(!this.#a&&this.#e.hidden)){if(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#e.hidden=!0,this.#o=-1,this.#x(),this.#m){try{this.#e.hidePopover()}catch{}window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0}))}}get#N(){return this.#s&&this.#u?this.#u:this.#t}#M(){if(!this.#m)return;let t=this.#N;if(!t)return;let e=t.getBoundingClientRect();this.#e.style.setProperty("--combobox-top",`${e.bottom+2}px`),this.#e.style.setProperty("--combobox-left",`${e.left}px`),this.#e.style.setProperty("--combobox-width",`${e.width}px`)}#R=t=>{t.newState==="closed"&&this.#a&&(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#e.hidden=!0,this.#o=-1,this.#x(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#c(){if(this.#s)if(this.#i.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let i of this.#i)t.append(e,i.value);this.#r.setFormValue(t)}else this.#r.setFormValue(null);else this.#n?this.#r.setFormValue(this.#n,this.#f):this.#r.setFormValue(null)}#d(){this.hasAttribute("required")?this.#s?this.#i.length===0?this.#r.setValidity({valueMissing:!0},"Please select at least one option",this.#t):this.#r.setValidity({}):this.#n?this.#r.setValidity({}):this.#r.setValidity({valueMissing:!0},"Please select an option",this.#t):this.#r.setValidity({})}#D(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#i.map(t=>t.value),labels:this.#i.map(t=>t.label)}}))}formResetCallback(){this.#s?(this.#u.querySelectorAll(".tag").forEach(t=>t.remove()),this.#i=[],this.#t.value="",this.#t.disabled=!1):(this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value")),this.#l.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#h=[...this.#l],this.#o=-1,this.#x(),this.#b(),!this.#s&&this.#k&&this.#y(this.#k,!1),this.#c(),this.#d()}formStateRestoreCallback(t){t&&(this.#s||(this.#y(t,!1),this.#c(),this.#d()))}get value(){return this.#n}set value(t){t?this.#y(t):(this.#l.forEach(e=>e.setAttribute("aria-selected","false")),this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value"),this.#c(),this.#d())}get label(){return this.#f}get values(){return this.#i.map(t=>t.value)}get labels(){return this.#i.map(t=>t.label)}static get observedAttributes(){return["value"]}attributeChangedCallback(t,e,i){t==="value"&&this.#t&&i!==this.#n&&i&&(this.#y(i,!1),this.#c(),this.#d())}};d("combo-box",u);export{u as ComboBox};
|
|
1
|
+
var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(h,t,e={}){let i=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=c.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}c.set(h,r),customElements.define(h,t)}var l=class extends HTMLElement{#r=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#r)t();this.#r=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,r){t.addEventListener(e,i,r),this.#r.push(()=>t.removeEventListener(e,i,r))}setup(){}teardown(){}};function f(h,t,e){"role"in ElementInternals.prototype?t.role=e:h.setAttribute("role",e)}var p="popover"in HTMLElement.prototype;var u=class extends l{static formAssociated=!0;#r;#t;#e;#l=[];#h=[];#o=-1;#a=!1;#m=!1;#n="";#f="";#C="";#u;#p;#i=[];constructor(){super(),this.#r=this.attachInternals()}get#s(){return this.hasAttribute("multiple")}setup(){if(this.#t=this.querySelector(":scope > input")||this.querySelector(":scope > .tags-input-area > input"),!this.#t||(this.#e=this.querySelector(":scope > ul, :scope > ol"),!this.#e))return!1;this.#m=p,this.#m&&this.#e.setAttribute("popover","manual"),this.#s&&(this.#u=document.createElement("div"),this.#u.className="tags-input-area",this.insertBefore(this.#u,this.#e),this.#u.appendChild(this.#t),this.#p=document.createElement("div"),this.#p.setAttribute("aria-live","polite"),this.#p.setAttribute("aria-atomic","true"),this.#p.className="visually-hidden",this.appendChild(this.#p));let t=this.getAttribute("placeholder");t&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",t);let e=crypto.randomUUID().slice(0,8);if(this.#e.id||(this.#e.id=`combobox-listbox-${e}`),f(this.#t,this.#r,"combobox"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#e.id),this.#t.setAttribute("autocomplete","off"),this.#e.setAttribute("role","listbox"),this.#s&&this.#e.setAttribute("aria-multiselectable","true"),this.#P(),!this.#s){let i=this.getAttribute("value");i&&this.#y(i,!1),this.#C=this.#n}this.listen(this.#t,"input",this.#V),this.listen(this.#t,"keydown",this.#T),this.listen(this.#t,"focus",this.#q),this.listen(this.#t,"click",this.#O),this.listen(this.#e,"click",this.#F),this.listen(this.#e,"pointerdown",this.#B),this.listen(document,"click",this.#N),this.#m&&this.listen(this.#e,"toggle",this.#R),this.#c(),this.#d(),this.#b()}teardown(){window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}#P(){this.#l=Array.from(this.#e.querySelectorAll(":scope > li[data-value]")),this.#l.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#e.id}-option-${e}`)}),this.#h=[...this.#l]}#E(t,e){if(this.#i.some(a=>a.value===t))return;let i=this.#S();if(i&&this.#i.length>=i)return;this.#i.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.addEventListener("click",a=>{a.stopPropagation(),this.#$(t)}),r.appendChild(s),this.#u.insertBefore(r,this.#t);let o=this.#l.find(a=>a.getAttribute("data-value")===t);o&&o.setAttribute("aria-selected","true"),this.#L(`${e} added`),this.#t.value="",this.#v(""),this.#c(),this.#d(),this.#D(),i&&this.#i.length>=i&&(this.#t.disabled=!0,this.#b())}#$(t){let e=this.#i.findIndex(a=>a.value===t);if(e===-1)return;let i=this.#i.splice(e,1)[0],r=this.#u.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);r&&r.remove();let s=this.#l.find(a=>a.getAttribute("data-value")===t);s&&s.setAttribute("aria-selected","false"),this.#L(`${i.label} removed`),this.#S()&&this.#t.disabled&&(this.#t.disabled=!1),this.#v(this.#t.value.trim()),this.#c(),this.#d(),this.#D(),this.#t.focus()}#S(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#L(t){this.#p&&(this.#p.textContent="",requestAnimationFrame(()=>{this.#p.textContent=t}))}#V=()=>{let t=this.#t.value.trim();if(!this.#s&&this.#n){let e=this.#e.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#n="",this.#f="",this.removeAttribute("value"),this.#c(),this.#d()}this.#v(t),this.#g()};#T=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#a||this.#g(),this.#w(this.#o+1);break;case"ArrowUp":t.preventDefault(),this.#a||this.#g(),this.#w(this.#o-1);break;case"Home":this.#a&&(t.preventDefault(),this.#w(0));break;case"End":this.#a&&(t.preventDefault(),this.#w(this.#h.length-1));break;case"Enter":if(t.preventDefault(),this.#a&&this.#o>=0&&this.#h[this.#o]){let e=this.#h[this.#o];this.#s?this.#E(e.getAttribute("data-value"),e.textContent.trim()):this.#k(e)}else if(this.#s&&this.hasAttribute("custom")&&this.#t.value.trim()){let e=this.#t.value.trim();this.#E(e,e)}break;case"Backspace":if(this.#s&&!this.#t.value&&this.#i.length>0){let e=this.#i[this.#i.length-1];this.#$(e.value)}break;case",":if(this.#s&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#E(e,e)}break;case"Escape":this.#a&&(t.preventDefault(),t.stopPropagation(),this.#b(),this.#t.focus());break;case"Tab":this.#a&&this.#b();break}};#q=()=>{this.#s?(this.#v(this.#t.value.trim()),this.#g()):(this.#t.value||!this.#n)&&(this.#v(this.#t.value.trim()),this.#g())};#O=()=>{this.#a||(this.#v(this.#t.value.trim()),this.#g())};#F=t=>{let e=t.target.closest("li[data-value]");e&&this.#h.includes(e)&&(this.#s?this.#E(e.getAttribute("data-value"),e.textContent.trim()):this.#k(e))};#B=t=>{t.preventDefault()};#N=t=>{this.#a&&!this.contains(t.target)&&this.#b()};#v(t){let e=this.getAttribute("filter")||"contains",i=t.toLowerCase(),r=this.#s?new Set(this.#i.map(s=>s.value)):null;this.#h=[],this.#l.forEach(s=>{let o=s.getAttribute("data-value"),a=s.textContent.trim().toLowerCase();if(r&&r.has(o)){s.hidden=!0;return}let n;t?e==="startsWith"?n=a.startsWith(i):n=a.includes(i):n=!0,s.hidden=!n,n&&this.#h.push(s)}),this.#o=-1,this.#x()}#w(t){if(this.#h.length===0)return;t<0&&(t=this.#h.length-1),t>=this.#h.length&&(t=0),this.#o>=0&&this.#h[this.#o]&&this.#h[this.#o].removeAttribute("data-active"),this.#o=t;let e=this.#h[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#x(){this.#l.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#k(t){let e=t.getAttribute("data-value"),i=t.textContent.trim();this.#l.forEach(r=>r.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#n=e,this.#f=i,this.#t.value=i,this.setAttribute("value",e),this.#c(),this.#d(),this.#b(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:e,label:i}}))}#y(t,e=!0){let i=this.#l.find(r=>r.getAttribute("data-value")===t);i&&(e?this.#k(i):(i.setAttribute("aria-selected","true"),this.#n=t,this.#f=i.textContent.trim(),this.#t.value=this.#f,this.setAttribute("value",t)))}#A=()=>this.#M();#g(){if(!this.#a){if(this.#a=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#e.hidden=!1,this.#m){this.#M();try{this.#e.showPopover()}catch{}window.addEventListener("scroll",this.#A,{capture:!0,passive:!0}),window.addEventListener("resize",this.#A,{passive:!0})}this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0}))}}#b(){if(!(!this.#a&&this.#e.hidden)){if(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#e.hidden=!0,this.#o=-1,this.#x(),this.#m){try{this.#e.hidePopover()}catch{}window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0}))}}get#I(){return this.#s&&this.#u?this.#u:this.#t}#M(){if(!this.#m)return;let t=this.#I;if(!t)return;let e=t.getBoundingClientRect();this.#e.style.setProperty("--combobox-top",`${e.bottom+2}px`),this.#e.style.setProperty("--combobox-left",`${e.left}px`),this.#e.style.setProperty("--combobox-width",`${e.width}px`)}#R=t=>{t.newState==="closed"&&this.#a&&(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#e.hidden=!0,this.#o=-1,this.#x(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#c(){if(this.#s)if(this.#i.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let i of this.#i)t.append(e,i.value);this.#r.setFormValue(t)}else this.#r.setFormValue(null);else this.#n?this.#r.setFormValue(this.#n,this.#f):this.#r.setFormValue(null)}#d(){this.hasAttribute("required")?this.#s?this.#i.length===0?this.#r.setValidity({valueMissing:!0},"Please select at least one option",this.#t):this.#r.setValidity({}):this.#n?this.#r.setValidity({}):this.#r.setValidity({valueMissing:!0},"Please select an option",this.#t):this.#r.setValidity({})}#D(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#i.map(t=>t.value),labels:this.#i.map(t=>t.label)}}))}formResetCallback(){this.#s?(this.#u.querySelectorAll(".tag").forEach(t=>t.remove()),this.#i=[],this.#t.value="",this.#t.disabled=!1):(this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value")),this.#l.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#h=[...this.#l],this.#o=-1,this.#x(),this.#b(),!this.#s&&this.#C&&this.#y(this.#C,!1),this.#c(),this.#d()}formStateRestoreCallback(t){t&&(this.#s||(this.#y(t,!1),this.#c(),this.#d()))}get value(){return this.#n}set value(t){t?this.#y(t):(this.#l.forEach(e=>e.setAttribute("aria-selected","false")),this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value"),this.#c(),this.#d())}get label(){return this.#f}get values(){return this.#i.map(t=>t.value)}get labels(){return this.#i.map(t=>t.label)}static get observedAttributes(){return["value"]}attributeChangedCallback(t,e,i){t==="value"&&this.#t&&i!==this.#n&&i&&(this.#y(i,!1),this.#c(),this.#d())}};d("combo-box",u);export{u as ComboBox};
|
|
2
2
|
//# sourceMappingURL=combo-box.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),v={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",shift:"\u21E7",ctrl:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",shift:"Shift",ctrl:"Ctrl"}};function b(i){let e=f?v.mac:v.other;return i.split("+").map(t=>{let n=t.trim().toLowerCase();return e[n]??n.toUpperCase()}).join(f?"":"+")}function k(i){let e=i.toLowerCase().split("+").map(n=>n.trim());return{key:e.pop()??"",meta:e.includes("meta")||e.includes("cmd"),ctrl:e.includes("ctrl"),shift:e.includes("shift"),alt:e.includes("alt")}}function C(i,e){if(i.key.toLowerCase()!==e.key)return!1;let t,n;return f?(t=e.meta,n=e.ctrl):(t=!1,n=e.meta||e.ctrl),!(t!==i.metaKey||n!==i.ctrlKey||e.shift!==i.shiftKey||e.alt!==i.altKey)}var x=new Set(["INPUT","TEXTAREA","SELECT"]),h=[],w=!1;function L(i){let e=x.has(i.target.tagName)||i.target.isContentEditable;for(let t of h)if(!(e&&!t.global)&&C(i,t.descriptor)){i.preventDefault(),t.callback(i);return}}function S(){w||(document.addEventListener("keydown",L),w=!0)}function A(i,e,t={}){S();let n=k(i),r={combo:i,descriptor:n,callback:e,global:t.global===!0};return h.find(a=>a.combo===i)&&console.warn(`[hotkey-bind] Shortcut "${i}" already bound. Last-connected-wins.`),h.unshift(r),function(){let o=h.indexOf(r);o!==-1&&h.splice(o,1)}}var H=window.matchMedia("(prefers-reduced-motion: reduce)");var N=new Map;function m(i,e,t={}){let n=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:n},s=N.get(i);if(customElements.get(i)){if(!s||s.priority>=n){s&&s.priority===n&&s.impl!==e&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=n){s.priority===n&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}N.set(i,r),customElements.define(i,e)}var p=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,n,r){e.addEventListener(t,n,r),this.#e.push(()=>e.removeEventListener(t,n,r))}setup(){}teardown(){}};var y=class extends p{#e;#n;#t;#s=[];#o=-1;#c=[];#l=null;#i=[];setup(){this.#m(),this.#p(),this.hasAttribute("discover")&&this.#y()}teardown(){this.#l?.()}#m(){this.#e=document.createElement("dialog"),this.#e.className="command-dialog",this.#e.addEventListener("click",n=>{n.target===this.#e&&this.close()});let e=document.createElement("div");e.className="command-search",this.#n=document.createElement("input"),this.#n.type="search",this.#n.placeholder=this.getAttribute("placeholder")||"Type a command...",this.#n.setAttribute("aria-label","Search commands"),this.#n.autocomplete="off",this.#n.addEventListener("input",this.#r),this.#n.addEventListener("keydown",this.#f),e.appendChild(this.#n),this.#t=document.createElement("div"),this.#t.className="command-list",this.#t.setAttribute("role","listbox"),this.#c=Array.from(this.querySelectorAll("command-group")),this.#c.forEach(n=>{let r=document.createElement("div");r.className="command-group-header",r.textContent=n.getAttribute("label")||"",r.setAttribute("role","presentation");let s=Array.from(n.querySelectorAll("command-item"));this.#t.appendChild(r),s.forEach(a=>{let o=document.createElement("button");o.className="command-option",o.setAttribute("role","option"),o.dataset.value=a.getAttribute("value")||"",o.dataset.searchText=a.textContent.toLowerCase().trim();let l=a.querySelector('[slot="icon"]');if(l){let d=document.createElement("span");d.className="command-icon",d.appendChild(l.cloneNode(!0)),o.appendChild(d)}let c=document.createElement("span");c.className="command-label",c.textContent=a.textContent.trim(),o.appendChild(c);let u=a.getAttribute("data-hotkey");if(u){let d=document.createElement("kbd");d.className="command-kbd",d.textContent=b(u),o.appendChild(d)}o.addEventListener("click",()=>{this.#b(o.dataset.value)}),this.#t.appendChild(o),this.#s.push({btn:o,header:r,group:n})})});let t=document.createElement("div");t.className="command-empty",t.textContent="No results found.",t.hidden=!0,this.#t.appendChild(t),this.#e.appendChild(e),this.#e.appendChild(this.#t),this.appendChild(this.#e)}#p(){let e=this.getAttribute("hotkey")||"meta+k";this.#l=A(e,()=>{this.#e.open?this.close():this.open()},{global:!0})}#r=()=>{let e=this.#n.value.toLowerCase().trim(),t=0,n=new Set;this.#s.forEach(({btn:s,header:a})=>{let o=!e||s.dataset.searchText.includes(e);s.hidden=!o,o&&(t++,n.add(a))}),this.#t.querySelectorAll(".command-group-header").forEach(s=>{s.hidden=!n.has(s)});let r=this.#t.querySelector(".command-empty");r&&(r.hidden=t>0),this.#o=-1,t>0&&this.#a(0)};#f=e=>{let t=this.#d();switch(e.key){case"ArrowDown":e.preventDefault(),this.#a(this.#o+1);break;case"ArrowUp":e.preventDefault(),this.#a(this.#o-1);break;case"Enter":e.preventDefault(),this.#o>=0&&t[this.#o]&&t[this.#o].btn.click();break;case"Escape":e.preventDefault(),this.close();break}};#d(){return this.#s.filter(({btn:e})=>!e.hidden)}#a(e){let t=this.#d();if(t.length===0)return;t.forEach(({btn:r})=>r.removeAttribute("data-active")),e<0&&(e=t.length-1),e>=t.length&&(e=0),this.#o=e;let{btn:n}=t[e];n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"})}#b(e){this.close(),this.dispatchEvent(new CustomEvent("command-palette:select",{bubbles:!0,detail:{value:e}}))}#y(){this.listen(document,"vb:command-registry-change",this.#E)}#E=()=>{this.#e?.open&&(this.#u(),this.#r())};#u(){if(!this.hasAttribute("discover"))return;let{getRegisteredCommands:e,scanAutoDiscoverable:t}=window.__commandRegistry||{};if(!e)return;this.#s=this.#s.filter(s=>!s.discovered),this.#i.forEach(s=>s.remove()),this.#i=[];let n=this.#t.querySelector(".command-empty"),r=e();for(let[s,a]of r){let o=document.createElement("div");o.className="command-group-header",o.textContent=s,o.setAttribute("role","presentation"),this.#t.insertBefore(o,n),this.#i.push(o);for(let l of a){if(this.contains(l.element))continue;let c=this.#h(l.label,l.icon,l.shortcut);c.dataset.value=`__discovered:${l.label}`,c.addEventListener("click",()=>{this.close(),l.element.click()}),this.#t.insertBefore(c,n),this.#s.push({btn:c,header:o,group:null,discovered:!0})}}if(this.getAttribute("discover")==="auto"&&t){let s=t(),a=new Map;for(let o of s){let l=a.get(o.group)||[];l.push(o),a.set(o.group,l)}for(let[o,l]of a){let c=document.createElement("div");c.className="command-group-header",c.textContent=o,c.setAttribute("role","presentation"),this.#t.insertBefore(c,n),this.#i.push(c);for(let u of l){if(this.contains(u.element))continue;let d=this.#h(u.label,u.icon,u.shortcut);d.dataset.value=`__auto:${u.label}`,d.dataset.auto="",d.addEventListener("click",()=>{this.close(),u.action?u.action():u.element.click()}),this.#t.insertBefore(d,n),this.#s.push({btn:d,header:c,group:null,discovered:!0})}}}}#h(e,t,n){let r=document.createElement("button");if(r.className="command-option",r.setAttribute("role","option"),r.dataset.searchText=e.toLowerCase(),t){let a=document.createElement("span");a.className="command-icon";let o=document.createElement("icon-wc");o.setAttribute("name",t),a.appendChild(o),r.appendChild(a)}let s=document.createElement("span");if(s.className="command-label",s.textContent=e,r.appendChild(s),n){let a=document.createElement("kbd");a.className="command-kbd",a.textContent=b(n),r.appendChild(a)}return r}open(){this.#e.open||(this.#u(),this.#e.showModal(),this.#n.value="",this.#r(),this.#n.focus(),this.dispatchEvent(new CustomEvent("command-palette:open",{bubbles:!0})))}close(){this.#e.open&&(this.#e.close(),this.dispatchEvent(new CustomEvent("command-palette:close",{bubbles:!0})))}get isOpen(){return this.#e?.open??!1}},E=class extends HTMLElement{},g=class extends HTMLElement{};m("command-palette",y);m("command-group",E);m("command-item",g);export{y as CommandPalette};
|
|
2
2
|
//# sourceMappingURL=command-palette.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,o,r){e.addEventListener(t,o,r),this.#e.push(()=>e.removeEventListener(t,o,r))}setup(){}teardown(){}};var m=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function u(i,e,t={}){let o=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:o},n=l.get(i);if(customElements.get(i)){if(!n||n.priority>=o){n&&n.priority===o&&n.impl!==e&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=o){n.priority===o&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}l.set(i,r),customElements.define(i,e)}var c=class extends s{setup(){let e=document.createElement("button");e.type="button";let t=document.createElement("icon-wc");t.setAttribute("name","message-circle"),t.setAttribute("size","sm"),t.setAttribute("aria-hidden","true"),e.appendChild(t);let o=this.closest("selection-menu")?.getAttribute("for"),r=this.closest("review-surface")||(o?document.querySelector(`review-surface[for="${o}"]`):null);r?(e.setAttribute("aria-label","Add comment"),e.addEventListener("click",()=>this.#e(r))):(e.setAttribute("aria-label","Comments not available"),e.style.opacity="0.4",e.setAttribute("title","Wrap content in <review-surface> to enable comments")),this.appendChild(e)}#e(e){let t=this.closest("selection-menu");if(!t)return;let o=t.getSelection();if(!o)return;let r=o.range.getBoundingClientRect(),n=e.getBoundingClientRect(),d=(r.left+r.width/2-n.left)/n.width*100,a=(r.top-n.top)/n.height*100;typeof e.addPin=="function"&&e.addPin({x:d,y:a,text:o.text}),this.dispatchEvent(new CustomEvent("comment-wc:created",{detail:{text:o.text,x:d,y:a},bubbles:!0})),t.dismiss()}};u("comment-wc",c);
|
|
1
|
+
var s=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,o,r){e.addEventListener(t,o,r),this.#e.push(()=>e.removeEventListener(t,o,r))}setup(){}teardown(){}};var m=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function u(i,e,t={}){let o=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:o},n=l.get(i);if(customElements.get(i)){if(!n||n.priority>=o){n&&n.priority===o&&n.impl!==e&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=o){n.priority===o&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}l.set(i,r),customElements.define(i,e)}var c=class extends s{setup(){let e=document.createElement("button");e.type="button";let t=document.createElement("icon-wc");t.setAttribute("name","message-circle"),t.setAttribute("size","sm"),t.setAttribute("aria-hidden","true"),e.appendChild(t);let o=this.closest("selection-menu")?.getAttribute("for"),r=this.closest("review-surface")||(o?document.querySelector(`review-surface[for="${o}"]`):null);r?(e.setAttribute("aria-label","Add comment"),e.addEventListener("click",()=>this.#e(r))):(e.setAttribute("aria-label","Comments not available"),e.style.opacity="0.4",e.setAttribute("title","Wrap content in <review-surface> to enable comments")),this.appendChild(e)}#e(e){let t=this.closest("selection-menu");if(!t)return;let o=t.getSelection();if(!o)return;let r=o.range.getBoundingClientRect(),n=e.getBoundingClientRect(),d=(r.left+r.width/2-n.left)/n.width*100,a=(r.top-n.top)/n.height*100;typeof e.addPin=="function"&&e.addPin({x:d,y:a,text:o.text}),this.dispatchEvent(new CustomEvent("comment-wc:created",{detail:{text:o.text,x:d,y:a},bubbles:!0})),t.dismiss()}};u("comment-wc",c);
|
|
2
2
|
//# sourceMappingURL=comment-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var l=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(r,e,t={}){let i=t.priority??10,o={impl:e,bundle:t.bundle,contract:t.contract,priority:i},n=c.get(r);if(customElements.get(r)){if(!n||n.priority>=i){n&&n.priority===i&&n.impl!==e&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=i){n.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}c.set(r,o),customElements.define(r,e)}var s=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,i,o){e.addEventListener(t,i,o),this.#e.push(()=>e.removeEventListener(t,i,o))}setup(){}teardown(){}};var a=class extends s{#e;#i=!1;setup(){let e=[...this.children];if(e.length<2)return!1;e.length>2&&console.warn("[compare-surface] Expected exactly 2 children; extra children will be ignored.");let t=this.getAttribute("position"),i=t!==null?Number(t):50,o=Math.min(100,Math.max(0,isNaN(i)?50:i));this.#e=document.createElement("div"),this.#e.className="comparison-divider",this.#e.setAttribute("role","slider"),this.#e.setAttribute("aria-label","Comparison slider"),this.#e.setAttribute("aria-valuemin","0"),this.#e.setAttribute("aria-valuemax","100"),this.#e.setAttribute("aria-valuenow",String(Math.round(o))),this.#e.setAttribute("tabindex","0"),this.appendChild(this.#e),this.#t(o),this.listen(this.#e,"pointerdown",this.#o),this.listen(this.#e,"keydown",this.#s)}teardown(){this.#e&&(this.#e.remove(),this.#e=null),this.#i=!1}#o=e=>{e.preventDefault(),this.#i=!0,this.#e.setPointerCapture(e.pointerId),this.#e.addEventListener("pointermove",this.#n),this.#e.addEventListener("pointerup",this.#r)};#n=e=>{if(!this.#i)return;let t=this.getBoundingClientRect(),i=e.clientX-t.left,o=Math.min(100,Math.max(0,i/t.width*100));this.#t(o)};#r=e=>{this.#i=!1,this.#e.releasePointerCapture(e.pointerId),this.#e.removeEventListener("pointermove",this.#n),this.#e.removeEventListener("pointerup",this.#r)};#s=e=>{let t=e.shiftKey?10:1,i=Number(this.#e.getAttribute("aria-valuenow"));e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),this.#t(Math.max(0,i-t))):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),this.#t(Math.min(100,i+t)))};#t(e){let t=Math.round(e);this.style.setProperty("--_position",`${e}%`),this.#e&&(this.#e.setAttribute("aria-valuenow",String(t)),this.#e.style.left=`${e}%`),this.setAttribute("position",String(t)),this.dispatchEvent(new CustomEvent("compare-surface:change",{detail:{position:e},bubbles:!0}))}get position(){return Number(this.getAttribute("position"))||0}set position(e){let t=Math.min(100,Math.max(0,Number(e)||0));this.#t(t)}};d("compare-surface",a);export{a as CompareSurface};
|
|
1
|
+
var l=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(r,e,t={}){let i=t.priority??10,o={impl:e,bundle:t.bundle,contract:t.contract,priority:i},n=c.get(r);if(customElements.get(r)){if(!n||n.priority>=i){n&&n.priority===i&&n.impl!==e&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=i){n.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}c.set(r,o),customElements.define(r,e)}var s=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,i,o){e.addEventListener(t,i,o),this.#e.push(()=>e.removeEventListener(t,i,o))}setup(){}teardown(){}};var a=class extends s{#e;#i=!1;setup(){let e=[...this.children];if(e.length<2)return!1;e.length>2&&console.warn("[compare-surface] Expected exactly 2 children; extra children will be ignored.");let t=this.getAttribute("position"),i=t!==null?Number(t):50,o=Math.min(100,Math.max(0,isNaN(i)?50:i));this.#e=document.createElement("div"),this.#e.className="comparison-divider",this.#e.setAttribute("role","slider"),this.#e.setAttribute("aria-label","Comparison slider"),this.#e.setAttribute("aria-valuemin","0"),this.#e.setAttribute("aria-valuemax","100"),this.#e.setAttribute("aria-valuenow",String(Math.round(o))),this.#e.setAttribute("tabindex","0"),this.appendChild(this.#e),this.#t(o),this.listen(this.#e,"pointerdown",this.#o),this.listen(this.#e,"keydown",this.#s)}teardown(){this.#e&&(this.#e.remove(),this.#e=null),this.#i=!1}#o=e=>{e.preventDefault(),this.#i=!0,this.#e.setPointerCapture(e.pointerId),this.#e.addEventListener("pointermove",this.#n),this.#e.addEventListener("pointerup",this.#r)};#n=e=>{if(!this.#i)return;let t=this.getBoundingClientRect(),i=e.clientX-t.left,o=Math.min(100,Math.max(0,i/t.width*100));this.#t(o)};#r=e=>{this.#i=!1,this.#e.releasePointerCapture(e.pointerId),this.#e.removeEventListener("pointermove",this.#n),this.#e.removeEventListener("pointerup",this.#r)};#s=e=>{let t=e.shiftKey?10:1,i=Number(this.#e.getAttribute("aria-valuenow"));e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),this.#t(Math.max(0,i-t))):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),this.#t(Math.min(100,i+t)))};#t(e){let t=Math.round(e);this.style.setProperty("--_position",`${e}%`),this.#e&&(this.#e.setAttribute("aria-valuenow",String(t)),this.#e.style.left=`${e}%`),this.setAttribute("position",String(t)),this.dispatchEvent(new CustomEvent("compare-surface:change",{detail:{position:e},bubbles:!0}))}get position(){return Number(this.getAttribute("position"))||0}set position(e){let t=Math.min(100,Math.max(0,Number(e)||0));this.#t(t)}};d("compare-surface",a);export{a as CompareSurface};
|
|
2
2
|
//# sourceMappingURL=compare-surface.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function p(r,a,t={}){let o=t.priority??10,n={impl:a,bundle:t.bundle,contract:t.contract,priority:o},e=u.get(r);if(customElements.get(r)){if(!e||e.priority>=o){e&&e.priority===o&&e.impl!==a&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${e.bundle}" (priority ${e.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${e.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(e&&e.priority>=o){e.priority===o&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${e.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}u.set(r,n),customElements.define(r,a)}var i=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let a of this.#e)a();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(a,t,o,n){a.addEventListener(t,o,n),this.#e.push(()=>a.removeEventListener(t,o,n))}setup(){}teardown(){}};var b={button:()=>`
|
|
2
2
|
<layout-cluster data-layout-gap="s">
|
|
3
3
|
<button>Primary</button>
|
|
4
4
|
<button class="secondary">Secondary</button>
|
|
@@ -38,8 +38,8 @@ var b=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
|
|
|
38
38
|
<progress value="100" max="100">100%</progress>
|
|
39
39
|
</layout-stack>`,range:()=>`
|
|
40
40
|
<input type="range" min="0" max="100" value="50" aria-label="Sample range"/>`,textarea:()=>`
|
|
41
|
-
<textarea rows="3" placeholder="Textarea sample" aria-label="Sample textarea" style="width:100%"></textarea>`},c=class extends i{static observedAttributes=["components","label","compact"];setup(){this.#e()}attributeChangedCallback(){this.isConnected&&this.#e()}#e(){let a=this.getAttribute("components")||"button,input,select,checkbox,radio,badge,progress",t=this.getAttribute("label")||"",o=this.hasAttribute("compact"),n=a.split(",").map(
|
|
42
|
-
<p style="font-size:0.625rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--color-text-muted,#999);margin-block-end:var(--size-s,0.5rem);font-family:var(--font-sans,system-ui)">${
|
|
41
|
+
<textarea rows="3" placeholder="Textarea sample" aria-label="Sample textarea" style="width:100%"></textarea>`},c=class extends i{static observedAttributes=["components","label","compact"];setup(){this.#e()}attributeChangedCallback(){this.isConnected&&this.#e()}#e(){let a=this.getAttribute("components")||"button,input,select,checkbox,radio,badge,progress",t=this.getAttribute("label")||"",o=this.hasAttribute("compact"),n=a.split(",").map(l=>l.trim()),e=o?"0.75rem":"1.25rem",s="";t&&(s+=`<p style="font-size:0.75rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--color-text-muted,#666);margin-block-end:0.75rem;font-family:var(--font-sans,system-ui)">${t}</p>`),s+=`<section style="display:grid;grid-template-columns:repeat(auto-fit,minmax(14rem,1fr));gap:${e}">`;for(let l of n){let d=b[l];d&&(s+=`<article style="border:1px solid var(--color-border,#ddd);border-radius:var(--radius-m,0.5rem);padding:var(--size-m,1rem);background:var(--color-surface,#fff)">
|
|
42
|
+
<p style="font-size:0.625rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--color-text-muted,#999);margin-block-end:var(--size-s,0.5rem);font-family:var(--font-sans,system-ui)">${l}</p>
|
|
43
43
|
${d()}
|
|
44
|
-
</article>`)}
|
|
44
|
+
</article>`)}s+="</section>",this.innerHTML=s}};p("component-sampler",c);
|
|
45
45
|
//# sourceMappingURL=component-sampler.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var w=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function m(t,e,n={}){let r=n.priority??10,o={impl:e,bundle:n.bundle,contract:n.contract,priority:r},s=p.get(t);if(customElements.get(t)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==e&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${t}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${s.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}p.set(t,o),customElements.define(t,e)}var l=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,n,r,o){e.addEventListener(n,r,o),this.#e.push(()=>e.removeEventListener(n,r,o))}setup(){}teardown(){}};function
|
|
1
|
+
var w=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function m(t,e,n={}){let r=n.priority??10,o={impl:e,bundle:n.bundle,contract:n.contract,priority:r},s=p.get(t);if(customElements.get(t)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==e&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${t}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${s.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}p.set(t,o),customElements.define(t,e)}var l=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,n,r,o){e.addEventListener(n,r,o),this.#e.push(()=>e.removeEventListener(n,r,o))}setup(){}teardown(){}};function g(){let t=globalThis.localStorage;if(!t)throw new Error("VBStore: localStorage is not available in this environment");return{async getRaw(e){return t.getItem(e)},async setRaw(e,n){t.setItem(e,n)},async removeRaw(e){t.removeItem(e)},async keys(e){let n=[];for(let r=0;r<t.length;r++){let o=t.key(r);o&&o.startsWith(e)&&n.push(o)}return n}}}var u=null;function a(){return u||(u=g()),u}function f(t,e){if(typeof t!="string"||!t)throw new TypeError("VBStore: namespace must be a non-empty string");if(typeof e!="string"||!e)throw new TypeError("VBStore: key must be a non-empty string");return`vb:${t}:${e}`}function y(t){if(typeof t!="string"||!t)throw new TypeError("VBStore: namespace must be a non-empty string");return`vb:${t}:`}function b(t){try{let e=JSON.parse(t);if(e&&typeof e=="object"&&typeof e.timestamp=="number")return e}catch{}return null}var c={configure(t={}){u=t.backend??null},async set(t,e,n){let r={data:n,timestamp:Date.now()};await a().setRaw(f(t,e),JSON.stringify(r))},async get(t,e,n){let r=await a().getRaw(f(t,e));if(r==null)return null;let o=b(r);return!o||n?.maxAge!=null&&Date.now()-o.timestamp>n.maxAge?null:o.data},async remove(t,e){await a().removeRaw(f(t,e))},async list(t){let e=y(t),n=await a().keys(e),r=[];for(let o of n){let s=await a().getRaw(o);if(s==null)continue;let i=b(s);i&&r.push({key:o.slice(e.length),data:i.data,timestamp:i.timestamp})}return r},async clear(t){let e=y(t),n=await a().keys(e);for(let r of n)await a().removeRaw(r)},async clearAll(){let t=await a().keys("vb:");for(let e of t)await a().removeRaw(e)},async setMany(t,e){for(let[n,r]of e)await c.set(t,n,r)}};var h=class extends l{#e=null;static get observedAttributes(){return["position"]}get#t(){return this.getAttribute("persist")||"banner"}get#i(){let e=this.getAttribute("expires");return e==="0"||e==="never"?0:e?parseInt(e,10):365}get#a(){let e=this.#i;return e>0?e*864e5:void 0}async setup(){if(this.#e=this.querySelector("dialog"),!this.#e)return!1;if(this.getAttribute("trigger")&&this.listen(document,"click",this.#l),await this.#o())return this.getAttribute("trigger")?this.hidden=!0:this.remove(),!1;this.#n()}#n(){(this.getAttribute("position")||"bottom")==="center"?(this.#e.showModal(),this.#e.addEventListener("cancel",this.#r)):this.#e.show(),this.addEventListener("click",this.#s)}#c(){this.#e.removeEventListener("cancel",this.#r),this.removeEventListener("click",this.#s),this.#e.close(),this.getAttribute("trigger")?this.hidden=!0:this.remove()}#r=e=>{e.preventDefault()};#s=async e=>{let n=e.target.closest("button[value]");if(!n)return;let r=n.value;if(!["accept","reject","save"].includes(r))return;let o=[...this.querySelectorAll('input[type="checkbox"]')],s={};r==="accept"?o.forEach(i=>{s[i.name]=!0}):r==="reject"?o.forEach(i=>{s[i.name]=!!i.disabled}):o.forEach(i=>{s[i.name]=i.checked}),await this.#u({preferences:s,action:r}),this.dispatchEvent(new CustomEvent("consent-banner:change",{bubbles:!0,detail:{preferences:s,action:r}})),this.#c()};#l=async e=>{let n=this.getAttribute("trigger");if(!n||!e.target.closest(n))return;e.preventDefault();let o=await this.#o();if(o?.preferences)for(let[s,i]of Object.entries(o.preferences)){let d=this.querySelector(`input[type="checkbox"][name="${CSS.escape(s)}"]`);d&&!d.disabled&&(d.checked=i)}this.hidden=!1,this.#n()};async#o(){let e=this.#a;return await c.get("consent",this.#t,e?{maxAge:e}:void 0)}async#u(e){await c.set("consent",this.#t,e)}static async reset(e="banner"){await c.remove("consent",e)}static async getConsent(e="banner"){return await c.get("consent",e)}};m("consent-banner",h);export{h as ConsentBanner};
|
|
2
2
|
//# sourceMappingURL=consent-banner.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var p=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function f(
|
|
1
|
+
var p=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function f(r,e,t={}){let s=t.priority??10,i={impl:e,bundle:t.bundle,contract:t.contract,priority:s},n=u.get(r);if(customElements.get(r)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==e&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}u.set(r,i),customElements.define(r,e)}var c=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,s,i){e.addEventListener(t,s,i),this.#e.push(()=>e.removeEventListener(t,s,i))}setup(){}teardown(){}};var a=class extends c{#e=new Map;#s="";#t=null;setup(){if(this.#i(),this.#e.size===0)return!1;this.#o(),this.#c();let e=this.#l();this.#n(e,!1)}#i(){for(let e of this.children){let t=e.getAttribute("data-lens-name");t&&this.#e.set(t,e)}}#o(){let e=this.getAttribute("data-lens-src");if(e)for(let t of this.#e.values())!t.hasAttribute("data-lens-src")&&!t.hasAttribute("src")&&t.setAttribute("data-lens-src",e)}#c(){if(this.getAttribute("data-lens-controls")==="off")return;let e=document.createElement("nav");e.setAttribute("data-content-lens-controls",""),e.setAttribute("aria-label","Switch lens");let t=document.createElement("fieldset"),s=document.createElement("legend");s.textContent="View",t.append(s);let i=`content-lens-${Math.random().toString(36).slice(2,8)}`;for(let[n,h]of this.#e){let l=document.createElement("label"),o=document.createElement("input");o.type="radio",o.name=i,o.value=n,o.addEventListener("change",()=>{o.checked&&this.#n(n,!0)});let d=document.createElement("span");d.textContent=h.getAttribute("data-lens-label")||this.#a(n),l.append(o,d),t.append(l)}e.append(t),this.prepend(e),this.#t=e}#a(e){return e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase())}#r(){return`vb:content-lens:${this.getAttribute("data-lens-storage")||(typeof location<"u"?location.pathname:"default")}`}#l(){let e=(()=>{try{return typeof sessionStorage<"u"?sessionStorage.getItem(this.#r()):null}catch{return null}})();if(e&&this.#e.has(e))return e;let t=this.getAttribute("data-lens-default");return t&&this.#e.has(t)?t:[...this.#e.keys()][0]}#n(e,t){if(this.#e.has(e)){for(let[s,i]of this.#e){let n=s===e;i.toggleAttribute("hidden",!n),i.setAttribute("aria-hidden",n?"false":"true")}if(this.#t){let s=this.#t.querySelector(`input[value="${e}"]`);s&&(s.checked=!0)}if(this.#s=e,this.setAttribute("data-active-lens",e),t)try{sessionStorage.setItem(this.#r(),e)}catch{}this.dispatchEvent(new CustomEvent("content-lens:change",{detail:{lens:e},bubbles:!0}))}}get activeLens(){return this.#s}setLens(e){this.#n(e,!0)}};f("content-lens",a);export{a as ContentLens};
|
|
2
2
|
//# sourceMappingURL=content-lens.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function w(t){return document.startViewTransition?document.startViewTransition(t):t()}var M=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function y(t,e,r={}){let n=r.priority??10,a={impl:e,bundle:r.bundle,contract:r.contract,priority:n},o=m.get(t);if(customElements.get(t)){if(!o||o.priority>=n){o&&o.priority===n&&o.impl!==e&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${r.bundle}".`);return}console.warn(`[VB Bundle] Tag <${t}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${r.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=n){o.priority===n&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${o.bundle}". Skipping "${r.bundle}" (first wins at equal priority).`);return}m.set(t,a),customElements.define(t,e)}var d=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#t)e();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,r,n,a){e.addEventListener(r,n,a),this.#t.push(()=>e.removeEventListener(r,n,a))}setup(){}teardown(){}};var k=0;function p(t,e){return t.matches("content-swap")?e:`data-${e}`}function f(t){t.style.viewTransitionName||(t.style.viewTransitionName=`content-swap-${++k}`);let e=t.querySelector(':scope > [data-face="front"]'),r=t.querySelector(':scope > [data-face="back"]');if(!e||!r)return;let n=[];function a(s,i,b,h){s.addEventListener(i,b,h),n.push(()=>s.removeEventListener(i,b,h))}let o=[...t.querySelectorAll("[data-swap]")].filter(s=>s!==t&&s.closest("content-swap, [data-swap]")===t);return o.length===0?(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.getAttribute("aria-label")||t.setAttribute("aria-label","Toggle content"),a(t,"click",()=>u(t,"pointer")),a(t,"keydown",s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),u(t,"keyboard"))})):o.forEach(s=>{a(s,"click",i=>{i.stopPropagation(),u(t,"pointer")}),a(s,"keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),u(t,"keyboard"))})}),v(t,e,r),()=>{for(let s of n)s();n.length=0}}function v(t,e,r){let n=t.hasAttribute(p(t,"swapped"));e.inert=n,r.inert=!n}function A(t){return{front:t.querySelector(':scope > [data-face="front"]'),back:t.querySelector(':scope > [data-face="back"]')}}function c(t,e,r="api"){let{front:n,back:a}=A(t);if(!n||!a)return;let o=p(t,"swapped");if(e&&t.hasAttribute(o)||!e&&!t.hasAttribute(o))return;w(()=>{e?t.setAttribute(o,""):t.removeAttribute(o),v(t,n,a),T(t);let s=e?a:n,i=s.querySelector("[autofocus]");i?i.focus():r==="keyboard"&&$(s)})}function u(t,e="api"){c(t,!t.hasAttribute(p(t,"swapped")),e)}function T(t){t.dispatchEvent(new CustomEvent("content-swap:swap",{detail:{swapped:t.hasAttribute(p(t,"swapped"))},bubbles:!0}))}function $(t){let e=t.querySelector("[data-swap], button, a, input, select, textarea");e&&e.focus()}var l=class extends d{#t=null;setup(){this.#t=f(this)??null}teardown(){this.#t?.(),this.#t=null}flip(){c(this,!0)}unflip(){c(this,!1)}toggle(){u(this)}get flipped(){return this.hasAttribute("swapped")}set flipped(e){c(this,!!e)}get swapped(){return this.hasAttribute("swapped")}set swapped(e){c(this,!!e)}};y("content-swap",l);function E(){document.querySelectorAll("[data-swap]:not(content-swap):not([data-swap-init])").forEach(t=>{t.querySelector(":scope > [data-face]")&&(f(t),t.setAttribute("data-swap-init",""))})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E):E();var g=new MutationObserver(t=>{for(let e of t)for(let r of e.addedNodes){if(r.nodeType!==Node.ELEMENT_NODE)continue;let n=r;n.hasAttribute("data-swap")&&!n.matches("content-swap")&&!n.hasAttribute("data-swap-init")&&n.querySelector(":scope > [data-face]")&&(f(n),n.setAttribute("data-swap-init","")),n.querySelectorAll("[data-swap]:not(content-swap):not([data-swap-init])").forEach(a=>{a.querySelector(":scope > [data-face]")&&(f(a),a.setAttribute("data-swap-init",""))})}});document.body?g.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{g.observe(document.body,{childList:!0,subtree:!0})});export{l as ContentSwap};
|
|
2
2
|
//# sourceMappingURL=content-swap.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var c=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),d={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",shift:"\u21E7",ctrl:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",shift:"Shift",ctrl:"Ctrl"}};function f(s){let t=c?d.mac:d.other;return s.split("+").map(e=>{let i=e.trim().toLowerCase();return t[i]??i.toUpperCase()}).join(c?"":"+")}function p(s){let t=s.toLowerCase().split("+").map(i=>i.trim());return{key:t.pop()??"",meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl"),shift:t.includes("shift"),alt:t.includes("alt")}}function m(s,t){if(s.key.toLowerCase()!==t.key)return!1;let e,i;return c?(e=t.meta,i=t.ctrl):(e=!1,i=t.meta||t.ctrl),!(e!==s.metaKey||i!==s.ctrlKey||t.shift!==s.shiftKey||t.alt!==s.altKey)}var g=new Set(["INPUT","TEXTAREA","SELECT"]),o=[],b=!1;function x(s){let t=g.has(s.target.tagName)||s.target.isContentEditable;for(let e of o)if(!(t&&!e.global)&&m(s,e.descriptor)){s.preventDefault(),e.callback(s);return}}function
|
|
1
|
+
var c=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),d={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",shift:"\u21E7",ctrl:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",shift:"Shift",ctrl:"Ctrl"}};function f(s){let t=c?d.mac:d.other;return s.split("+").map(e=>{let i=e.trim().toLowerCase();return t[i]??i.toUpperCase()}).join(c?"":"+")}function p(s){let t=s.toLowerCase().split("+").map(i=>i.trim());return{key:t.pop()??"",meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl"),shift:t.includes("shift"),alt:t.includes("alt")}}function m(s,t){if(s.key.toLowerCase()!==t.key)return!1;let e,i;return c?(e=t.meta,i=t.ctrl):(e=!1,i=t.meta||t.ctrl),!(e!==s.metaKey||i!==s.ctrlKey||t.shift!==s.shiftKey||t.alt!==s.altKey)}var g=new Set(["INPUT","TEXTAREA","SELECT"]),o=[],b=!1;function x(s){let t=g.has(s.target.tagName)||s.target.isContentEditable;for(let e of o)if(!(t&&!e.global)&&m(s,e.descriptor)){s.preventDefault(),e.callback(s);return}}function v(){b||(document.addEventListener("keydown",x),b=!0)}function y(s,t,e={}){v();let i=p(s),r={combo:s,descriptor:i,callback:t,global:e.global===!0};return o.find(u=>u.combo===s)&&console.warn(`[hotkey-bind] Shortcut "${s}" already bound. Last-connected-wins.`),o.unshift(r),function(){let h=o.indexOf(r);h!==-1&&o.splice(h,1)}}var E="popover"in HTMLElement.prototype;var M=window.matchMedia("(prefers-reduced-motion: reduce)");var k=new Map;function w(s,t,e={}){let i=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:i},n=k.get(s);if(customElements.get(s)){if(!n||n.priority>=i){n&&n.priority===i&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=i){n.priority===i&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}k.set(s,r),customElements.define(s,t)}var a=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),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))}setup(){}teardown(){}};var l=class extends a{#e;#t;#i=[];#n=-1;#s=!1;#a=[];#r=!1;setup(){if(this.#e=this.querySelector(":scope > [data-trigger]"),this.#t=this.querySelector(':scope > menu, :scope > ul[role="menu"]'),!this.#e||!this.#t)return!1;this.#r=E,this.#r&&this.#t.setAttribute("popover","auto"),this.#e?.setAttribute("aria-expanded","false"),this.#t.setAttribute("role","menu"),this.#t.id||(this.#t.id=`ctx-menu-${crypto.randomUUID().slice(0,8)}`),this.#t.querySelectorAll(":scope > li[data-group]").forEach(t=>{t.setAttribute("role","presentation"),t.classList.add("ctx-group-label")}),this.#i=Array.from(this.#t.querySelectorAll('button, a, [role="menuitem"]')).filter(t=>!t.disabled&&!t.hasAttribute("data-disabled")),this.#i.forEach(t=>{t.setAttribute("role","menuitem"),t.setAttribute("tabindex","-1"),t.style.cssText+=";border:none;box-shadow:none;transform:none;border-radius:0;",this.listen(t,"click",this.#h);let e=t.getAttribute("data-shortcut");if(e){let i=document.createElement("kbd");i.className="ctx-kbd",i.textContent=f(e),t.appendChild(i);let r=y(e,()=>t.click());this.#a.push(r)}}),this.#t.querySelectorAll('li:empty:not([data-group]), [role="separator"], hr').forEach(t=>{t.setAttribute("role","separator")}),this.listen(this.#e,"contextmenu",this.#c),this.listen(this.#t,"keydown",this.#u),this.listen(window,"scroll",this.#b,{capture:!0}),this.#r?this.listen(this.#t,"toggle",this.#m):(this.listen(document,"click",this.#d),this.listen(document,"contextmenu",this.#f),this.listen(document,"keydown",this.#p))}teardown(){this.#a.forEach(t=>t()),this.#a=[]}#c=t=>{t.preventDefault(),this.#l(t.clientX,t.clientY)};#l(t,e){if(this.#s=!0,this.setAttribute("data-open",""),this.#e?.setAttribute("aria-expanded","true"),this.#t.style.setProperty("--ctx-top",`${e}px`),this.#t.style.setProperty("--ctx-left",`${t}px`),this.#r)try{this.#t.showPopover()}catch{}requestAnimationFrame(()=>{let i=this.#t.getBoundingClientRect(),r=t+i.width>window.innerWidth?t-i.width:t,n=e+i.height>window.innerHeight?e-i.height:e;this.#t.style.setProperty("--ctx-top",`${Math.max(0,n)}px`),this.#t.style.setProperty("--ctx-left",`${Math.max(0,r)}px`)}),this.#n=-1,this.#o(0),this.dispatchEvent(new CustomEvent("context-menu:open",{bubbles:!0}))}close(){if(this.#s){if(this.#s=!1,this.removeAttribute("data-open"),this.#e?.setAttribute("aria-expanded","false"),this.#n=-1,this.#r)try{this.#t.hidePopover()}catch{}this.dispatchEvent(new CustomEvent("context-menu:close",{bubbles:!0}))}}#u=t=>{switch(t.key){case"ArrowDown":case"Down":t.preventDefault(),this.#o(this.#n+1);break;case"ArrowUp":case"Up":t.preventDefault(),this.#o(this.#n-1);break;case"Home":t.preventDefault(),this.#o(0);break;case"End":t.preventDefault(),this.#o(this.#i.length-1);break;case"Enter":case" ":t.preventDefault(),this.#n>=0&&this.#i[this.#n].click();break;case"Tab":this.close();break}};#h=()=>{this.close(),this.dispatchEvent(new CustomEvent("context-menu:select",{bubbles:!0,detail:{item:this.#i[this.#n]}}))};#d=t=>{this.#s&&!this.#t.contains(t.target)&&this.close()};#f=t=>{this.#s&&!this.#e.contains(t.target)&&this.close()};#p=t=>{t.key==="Escape"&&this.#s&&(t.preventDefault(),this.close())};#m=t=>{t.newState==="closed"&&this.#s&&(this.#s=!1,this.removeAttribute("data-open"),this.#n=-1,this.dispatchEvent(new CustomEvent("context-menu:close",{bubbles:!0})))};#b=()=>{this.#s&&this.close()};#o(t){this.#i.length!==0&&(t<0&&(t=this.#i.length-1),t>=this.#i.length&&(t=0),this.#n=t,this.#i[t].focus())}get isOpen(){return this.#s}};w("context-menu",l);export{l as ContextMenuWc};
|
|
2
2
|
//# sourceMappingURL=context-menu.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var m=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function b(o,e,t={}){let s=t.priority??10,n={impl:e,bundle:t.bundle,contract:t.contract,priority:s},i=p.get(o);if(customElements.get(o)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==e&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${i.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}p.set(o,n),customElements.define(o,e)}var d=class extends HTMLElement{#i=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let e of this.#i)e();this.#i=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,s,n){e.addEventListener(t,s,n),this.#i.push(()=>e.removeEventListener(t,s,n))}setup(){}teardown(){}};var f=class extends d{#i;#t;#l=[];#a=[];#e=[];#o=-1;#c=null;#s=1;#n=0;#f=null;#p=null;#d=null;#h="";#r=null;#m=null;setup(){if(this.#i=this.querySelector(":scope > table"),!this.#i||(this.#t=this.#i.querySelector("tbody"),!this.#t))return!1;this.#
|
|
1
|
+
var m=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function b(o,e,t={}){let s=t.priority??10,n={impl:e,bundle:t.bundle,contract:t.contract,priority:s},i=p.get(o);if(customElements.get(o)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==e&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${i.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}p.set(o,n),customElements.define(o,e)}var d=class extends HTMLElement{#i=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#i)e();this.#i=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,s,n){e.addEventListener(t,s,n),this.#i.push(()=>e.removeEventListener(t,s,n))}setup(){}teardown(){}};var f=class extends d{#i;#t;#l=[];#a=[];#e=[];#o=-1;#c=null;#s=1;#n=0;#f=null;#p=null;#d=null;#h="";#r=null;#m=null;setup(){if(this.#i=this.querySelector(":scope > table"),!this.#i||(this.#t=this.#i.querySelector("tbody"),!this.#t))return!1;this.#w()}teardown(){this.#S(),this.#l=[],this.#a=[],this.#e=[]}#w(){this.#a=[...this.#t.querySelectorAll(":scope > tr:not([data-expand-content])")],this.#e=[...this.#a],this.#k(),this.#i.hasAttribute("data-filterable")&&this.#$();let e=this.#i.getAttribute("data-paginate");e&&(this.#n=parseInt(e,10),this.#n>0&&this.#B()),this.#I(),this.#F(),this.#u()}#S(){this.#d&&clearTimeout(this.#d),this.#f?.parentElement?.remove(),this.#p?.remove()}#k(){this.#i.querySelectorAll("thead th[data-sort]").forEach((t,s)=>{let n=t.getAttribute("data-sort"),i=this.#M(t);this.#l.push({th:t,sortType:n,columnIndex:i}),t.setAttribute("tabindex","0"),t.setAttribute("role","columnheader"),t.setAttribute("aria-sort","none"),t.dataset.columnIndex=i,this.listen(t,"click",this.#T),this.listen(t,"keydown",this.#q)})}#M(e){return[...e.parentElement.children].indexOf(e)}#T=e=>{let t=e.currentTarget,s=parseInt(t.dataset.columnIndex,10);this.#x(s)};#q=e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();let t=e.currentTarget,s=parseInt(t.dataset.columnIndex,10);this.#x(s)}};#R(e,t,s){let n=this.#e;if(n.length<2)return!0;let i=s==="asc"?1:-1;for(let r=1;r<n.length;r++){let a=this.#b(n[r-1].children[e],t),l=this.#b(n[r].children[e],t);if((typeof a=="string"?a.localeCompare(l)*i:(a-l)*i)>0)return!1}return!0}#x(e){let t=this.#l.find(n=>n.columnIndex===e);if(!t)return;let s;this.#o===e?s=this.#c==="asc"?"desc":"asc":this.#R(e,t.sortType,"asc")?s="desc":s="asc",this.#l.forEach(({th:n})=>{n.setAttribute("aria-sort","none")}),t.th.setAttribute("aria-sort",s==="asc"?"ascending":"descending"),this.#o=e,this.#c=s,this.#g(e,s,t.sortType),this.#s=1,this.#u(),this.dispatchEvent(new CustomEvent("data-table:sort",{detail:{column:e,direction:s,columnName:t.th.textContent.trim()},bubbles:!0}))}#g(e,t,s){let n=t==="asc"?1:-1;this.#e.sort((i,r)=>{let a=i.children[e],l=r.children[e];if(!a||!l)return 0;let c=this.#b(a,s),u=this.#b(l,s),h=0;switch(s){case"number":h=c-u;break;case"date":h=c-u;break;default:h=c.localeCompare(u,void 0,{numeric:!0,sensitivity:"base"});break}return h*n})}#b(e,t){let n=e.getAttribute("data-sort-value")??e.textContent.trim();switch(t){case"number":return parseFloat(n)||0;case"date":return new Date(n).getTime()||0;default:return n.toLowerCase()}}#$(){let e=document.createElement("div");e.setAttribute("data-table-filter","");let t=document.createElement("input");t.type="search",t.setAttribute("data-filter-input",""),t.setAttribute("placeholder","Filter table..."),t.setAttribute("aria-label","Filter table rows"),e.appendChild(t),this.insertBefore(e,this.#i),this.#f=t,this.listen(t,"input",this.#L)}#L=e=>{let t=e.target.value;this.#d&&clearTimeout(this.#d),this.#d=setTimeout(()=>{this.#E(t)},150)};#E(e){if(this.#h=e.toLowerCase().trim(),this.#h===""?this.#e=[...this.#a]:this.#e=this.#a.filter(t=>[...t.children].some(n=>(n.getAttribute("data-filter-value")??n.textContent).toLowerCase().includes(this.#h))),this.#o>=0&&this.#c){let t=this.#l.find(s=>s.columnIndex===this.#o);t&&this.#g(this.#o,this.#c,t.sortType)}this.#s=1,this.#u(),this.dispatchEvent(new CustomEvent("data-table:filter",{detail:{query:this.#h,count:this.#e.length},bubbles:!0}))}#B(){let e=document.createElement("nav");e.setAttribute("data-pagination",""),e.setAttribute("aria-label","Table pagination"),this.appendChild(e),this.#p=e}#I(){this.listen(this.#i,"click",this.#P)}#P=e=>{let t=e.target.closest('[data-action="toggle-expand"]');if(!t)return;let s=t.closest("tr[data-expandable]");if(!s)return;let n=s.hasAttribute("data-state-expanded"),i=s.nextElementSibling;n?(s.removeAttribute("data-state-expanded"),t.setAttribute("aria-expanded","false"),i?.hasAttribute("data-expand-content")&&(i.hidden=!0,i.setAttribute("aria-hidden","true"))):(s.setAttribute("data-state-expanded",""),t.setAttribute("aria-expanded","true"),i?.hasAttribute("data-expand-content")&&(i.hidden=!1,i.removeAttribute("aria-hidden"))),this.dispatchEvent(new CustomEvent("data-table:expand",{detail:{row:s,expanded:!n},bubbles:!0}))};#F(){this.#r=this.#i.querySelector('thead [data-action="select-all"]'),this.#r&&this.listen(this.#r,"change",this.#N),this.listen(this.#t,"change",this.#V),this.#m=this.querySelector("[data-selected-count]"),this.#C()}#N=e=>{let t=e.target.checked;this.#t.querySelectorAll("tr[data-selectable]").forEach(n=>{let i=n.querySelector('[data-action="select-row"]');t?(n.setAttribute("data-state-selected",""),i&&(i.checked=!0)):(n.removeAttribute("data-state-selected"),i&&(i.checked=!1))}),e.target.indeterminate=!1,this.#A(),this.#v()};#V=e=>{let t=e.target.closest('[data-action="select-row"]');if(!t)return;let s=t.closest("tr[data-selectable]");s&&(t.checked?s.setAttribute("data-state-selected",""):s.removeAttribute("data-state-selected"),this.#C(),this.#v())};#C(){if(!this.#r){this.#A();return}let e=this.#t.querySelectorAll("tr[data-selectable]"),t=this.#t.querySelectorAll("tr[data-selectable][data-state-selected]"),s=e.length,n=t.length;n===0?(this.#r.checked=!1,this.#r.indeterminate=!1):n===s?(this.#r.checked=!0,this.#r.indeterminate=!1):(this.#r.checked=!1,this.#r.indeterminate=!0),this.#A()}#A(){let t=this.#t.querySelectorAll("tr[data-selectable][data-state-selected]").length;this.#m&&(this.#m.textContent=t)}#v(){let e=[...this.#t.querySelectorAll("tr[data-selectable][data-state-selected]")];this.dispatchEvent(new CustomEvent("data-table:selection",{detail:{count:e.length,rows:e},bubbles:!0}))}#D(){if(!this.#p||this.#n<=0)return;let e=this.#p,t=Math.ceil(this.#e.length/this.#n);if(e.innerHTML="",t<=1)return;let s=document.createElement("button");s.type="button",s.textContent="Previous",s.setAttribute("data-pagination-prev",""),s.disabled=this.#s===1,s.addEventListener("click",()=>this.goToPage(this.#s-1)),e.appendChild(s),this.#H(t).forEach(r=>{if(r==="..."){let a=document.createElement("span");a.textContent="...",a.setAttribute("data-pagination-ellipsis",""),e.appendChild(a)}else{let a=document.createElement("button");a.type="button",a.textContent=r,a.setAttribute("data-pagination-page",""),r===this.#s&&(a.setAttribute("aria-current","page"),a.setAttribute("data-current","")),a.addEventListener("click",()=>this.goToPage(r)),e.appendChild(a)}});let i=document.createElement("button");i.type="button",i.textContent="Next",i.setAttribute("data-pagination-next",""),i.disabled=this.#s===t,i.addEventListener("click",()=>this.goToPage(this.#s+1)),e.appendChild(i)}#H(e){let t=this.#s,s=[];if(e<=7)for(let n=1;n<=e;n++)s.push(n);else{s.push(1),t>3&&s.push("...");let n=Math.max(2,t-1),i=Math.min(e-1,t+1);for(let r=n;r<=i;r++)s.push(r);t<e-2&&s.push("..."),s.push(e)}return s}#u(){this.#a.forEach(t=>{t.setAttribute("data-state-hidden","")});let e;if(this.#n>0){let t=(this.#s-1)*this.#n,s=t+this.#n;e=this.#e.slice(t,s)}else e=this.#e;e.forEach(t=>{t.removeAttribute("data-state-hidden"),this.#t.appendChild(t);let s=t.nextElementSibling?.hasAttribute?.("data-expand-content")?t.nextElementSibling:this.#y(t);s&&this.#t.appendChild(s)}),this.#e.forEach(t=>{if(t.hasAttribute("data-state-hidden")){this.#t.appendChild(t);let s=this.#y(t);s&&this.#t.appendChild(s)}}),this.#a.forEach(t=>{if(!this.#e.includes(t)){this.#t.appendChild(t);let s=this.#y(t);s&&this.#t.appendChild(s)}}),this.#D()}#y(e){if(!e.hasAttribute("data-expandable"))return null;let t=e.nextElementSibling;return t?.hasAttribute("data-expand-content")?t:null}goToPage(e){let t=Math.ceil(this.#e.length/this.#n),s=Math.max(1,Math.min(e,t));s!==this.#s&&(this.#s=s,this.#u(),this.dispatchEvent(new CustomEvent("data-table:page",{detail:{page:this.#s},bubbles:!0})))}setFilter(e){this.#f&&(this.#f.value=e),this.#E(e)}refresh(){if(this.#a=[...this.#t.querySelectorAll(":scope > tr")],this.#h?this.#E(this.#h):this.#e=[...this.#a],this.#o>=0&&this.#c){let t=this.#l.find(s=>s.columnIndex===this.#o);t&&this.#g(this.#o,this.#c,t.sortType)}let e=Math.max(1,Math.ceil(this.#e.length/this.#n));this.#s>e&&(this.#s=e),this.#u()}get currentPage(){return this.#s}get totalPages(){return this.#n<=0?1:Math.ceil(this.#e.length/this.#n)}get filteredCount(){return this.#e.length}get totalCount(){return this.#a.length}getSelectedRows(){return this.#t?[...this.#t.querySelectorAll("tr[data-selectable][data-state-selected]")]:[]}};b("data-table",f);export{f as DataTable};
|
|
2
2
|
//# sourceMappingURL=data-table.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var S=window.matchMedia("(prefers-reduced-motion: reduce)");var A=new Map;function E(n,t,e={}){let i=e.priority??10,a={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=A.get(n);if(customElements.get(n)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> 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 <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}A.set(n,a),customElements.define(n,t)}var m=class extends HTMLElement{#c=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let t of this.#c)t();this.#c=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,a){t.addEventListener(e,i,a),this.#c.push(()=>t.removeEventListener(e,i,a))}setup(){}teardown(){}};var C="popover"in HTMLElement.prototype;var x=["Su","Mo","Tu","We","Th","Fr","Sa"],k=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],D=["january","february","march","april","may","june","july","august","september","october","november","december"];function c(n){let t=n.getFullYear(),e=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return`${t}-${e}-${i}`}function p(n){if(!n)return null;let[t,e,i]=n.split("-").map(Number);return new Date(t,e-1,i)}function b(n,t){return new Date(n,t+1,0).getDate()}function F(){try{let n=new Intl.Locale(navigator.language);if(n.weekInfo)return n.weekInfo.firstDay%7}catch{}return 0}function T(n){try{return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"long",day:"numeric"}).format(n)}catch{return c(n)}}function g(n,t){return n&&t&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function N(){let n=new Map;D.forEach((t,e)=>{n.set(t,e),n.set(t.slice(0,3),e)});try{for(let t=0;t<12;t++){let e=new Intl.DateTimeFormat(void 0,{month:"long"}).format(new Date(2e3,t,1)).toLowerCase(),i=new Intl.DateTimeFormat(void 0,{month:"short"}).format(new Date(2e3,t,1)).toLowerCase().replace(".","");n.set(e,t),n.set(i,t)}}catch{}return n}var y=N();function w(n){let t=n.trim();if(!t)return{date:null,partial:null};if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let r=p(t);return r&&!isNaN(r.getTime())?{date:r,partial:null}:{date:null,partial:null}}if(/^\d{4}\/\d{2}\/\d{2}$/.test(t)){let r=p(t.replace(/\//g,"-"));return r&&!isNaN(r.getTime())?{date:r,partial:null}:{date:null,partial:null}}let e=/^([a-z\u00C0-\u024F]+)\s+(\d{1,2}),?\s+(\d{4})$/i,i=t.match(e);if(i){let r=y.get(i[1].toLowerCase());if(r!==void 0){let h=new Date(Number(i[3]),r,Number(i[2]));if(!isNaN(h.getTime()))return{date:h,partial:null}}}let a=/^(\d{1,2})\s+([a-z\u00C0-\u024F]+)\s+(\d{4})$/i;if(i=t.match(a),i){let r=y.get(i[2].toLowerCase());if(r!==void 0){let h=new Date(Number(i[3]),r,Number(i[1]));if(!isNaN(h.getTime()))return{date:h,partial:null}}}let s=/^([a-z\u00C0-\u024F]+)\s+(\d{4})$/i;if(i=t.match(s),i){let r=y.get(i[1].toLowerCase());if(r!==void 0)return{date:null,partial:{year:Number(i[2]),month:r}}}return{date:null,partial:null}}var v=class extends m{static formAssociated=!0;#c;#r;#t;#p;#b;#s;#w;#f;#D;#u;#l=!1;#v=!1;#e=null;#n=null;#a;#i;#h=null;#o=null;#x=new Map;#k=new Map;#S;#A;constructor(){super(),this.#c=this.attachInternals()}setup(){if(this.#r=this.querySelector(':scope > input[type="date"]'),!this.#r)return!1;this.#h=p(this.#r.getAttribute("min")),this.#o=p(this.#r.getAttribute("max")),this.#A=F();let t=this.getAttribute("data-disabled-dates");t&&t.split(",").forEach(a=>{let[s,r]=a.trim().split(":");this.#x.set(s,r||null)});let e=this.getAttribute("data-highlight-dates");e&&e.split(",").forEach(a=>{let[s,r]=a.trim().split(":");this.#k.set(s,r||null)}),this.#e=p(this.#r.value),this.#S=this.#r.value;let i=new Date;this.#o&&i>this.#o&&(i=this.#o),this.#h&&i<this.#h&&(i=this.#h),this.#a=this.#e?this.#e.getFullYear():i.getFullYear(),this.#i=this.#e?this.#e.getMonth():i.getMonth(),this.#n=this.#e||i,this.#r.setAttribute("tabindex","-1"),this.#r.setAttribute("aria-hidden","true"),this.#r.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.#I(),this.#B(),this.#g(),this.#E(),this.#C(),this.#v=C,this.#v&&this.#s.setAttribute("popover","manual"),this.listen(document,"click",this.#z),(this.#r.disabled||this.hasAttribute("disabled"))&&(this.setAttribute("data-disabled",""),this.#t.disabled=!0)}teardown(){window.removeEventListener("scroll",this.#y,{capture:!0}),window.removeEventListener("resize",this.#y)}#I(){this.#b=document.createElement("div"),this.#b.className="date-trigger",this.#t=document.createElement("input"),this.#t.type="text",this.#t.className="date-input",this.#t.setAttribute("role","combobox"),this.#t.setAttribute("aria-haspopup","dialog"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("autocomplete","off"),this.#t.setAttribute("placeholder","Type a date\u2026"),this.#b.appendChild(this.#t),this.#p=document.createElement("button"),this.#p.type="button",this.#p.className="date-trigger-icon",this.#p.setAttribute("aria-label","Toggle calendar"),this.#p.setAttribute("tabindex","-1");let t=document.createElement("icon-wc");t.setAttribute("name","calendar"),t.setAttribute("size","sm"),t.setAttribute("aria-hidden","true"),this.#p.appendChild(t),this.#b.appendChild(this.#p),this.appendChild(this.#b),this.listen(this.#p,"click",e=>{e.stopPropagation(),this.#l?this.#m():this.#N(),this.#t.focus()}),this.listen(this.#t,"focus",()=>this.#t.select()),this.listen(this.#t,"input",this.#O),this.listen(this.#t,"keydown",this.#q),this.listen(this.#t,"blur",this.#R)}#B(){this.#w=`dp-${Math.random().toString(36).slice(2,8)}`,this.#s=document.createElement("div"),this.#s.className="calendar",this.#s.id=this.#w,this.#s.setAttribute("role","dialog"),this.#s.setAttribute("aria-modal","false"),this.#s.setAttribute("aria-label","Choose date"),this.#s.hidden=!0,this.#t.setAttribute("aria-controls",this.#w);let t=document.createElement("div");t.className="calendar-header";let e=document.createElement("button");e.type="button",e.className="calendar-nav",e.setAttribute("aria-label","Previous month");let i=document.createElement("icon-wc");i.setAttribute("name","chevron-left"),i.setAttribute("size","sm"),i.setAttribute("aria-hidden","true"),e.appendChild(i);let a=document.createElement("span");a.className="calendar-title",a.id=`${this.#w}-title`,a.setAttribute("aria-live","polite"),this.#D=document.createElement("span"),this.#D.className="calendar-month",this.#u=document.createElement("select"),this.#u.className="calendar-year",this.#u.setAttribute("aria-label","Year"),this.#$(),a.appendChild(this.#D),a.appendChild(this.#u);let s=document.createElement("button");s.type="button",s.className="calendar-nav",s.setAttribute("aria-label","Next month");let r=document.createElement("icon-wc");r.setAttribute("name","chevron-right"),r.setAttribute("size","sm"),r.setAttribute("aria-hidden","true"),s.appendChild(r),t.appendChild(e),t.appendChild(a),t.appendChild(s),this.#s.appendChild(t);let h=document.createElement("table");h.setAttribute("role","grid"),h.setAttribute("aria-labelledby",`${this.#w}-title`);let d=document.createElement("thead"),u=document.createElement("tr");for(let l=0;l<7;l++){let o=(this.#A+l)%7,f=document.createElement("th");f.setAttribute("abbr",k[o]),f.setAttribute("scope","col"),f.textContent=x[o],u.appendChild(f)}d.appendChild(u),h.appendChild(d),this.#f=document.createElement("tbody"),h.appendChild(this.#f),this.#s.appendChild(h),this.appendChild(this.#s),this.#d(),this.listen(e,"click",()=>this.#L(-1)),this.listen(s,"click",()=>this.#L(1)),this.listen(this.#u,"change",()=>{this.#a=Number(this.#u.value);let l=b(this.#a,this.#i),o=Math.min(this.#n.getDate(),l);this.#n=new Date(this.#a,this.#i,o),this.#d()}),this.listen(this.#f,"click",this.#H),this.listen(this.#s,"keydown",this.#V)}#d(){try{this.#D.textContent=new Intl.DateTimeFormat(void 0,{month:"long"}).format(new Date(this.#a,this.#i,1))}catch{this.#D.textContent=D[this.#i].charAt(0).toUpperCase()+D[this.#i].slice(1)}this.#u.querySelector(`option[value="${this.#a}"]`)||this.#$(),this.#u.value=String(this.#a),this.#f.innerHTML="";let t=b(this.#a,this.#i),i=(new Date(this.#a,this.#i,1).getDay()-this.#A+7)%7,a=new Date,s=document.createElement("tr");for(let h=0;h<i;h++)s.appendChild(document.createElement("td"));for(let h=1;h<=t;h++){let d=new Date(this.#a,this.#i,h),u=c(d),l=document.createElement("td"),o=document.createElement("button");o.type="button",o.setAttribute("data-date",u),o.textContent=String(h),g(d,a)&&o.setAttribute("aria-current","date"),g(d,this.#e)&&o.setAttribute("aria-selected","true");let f=this.#Y(d,u);if(f.disabled&&(o.setAttribute("aria-disabled","true"),o.setAttribute("disabled",""),f.reason&&o.setAttribute("data-disabled-reason",f.reason)),this.#k.has(u)){let M=this.#k.get(u);o.setAttribute("data-highlight",M||"")}g(d,this.#n)?(o.setAttribute("tabindex","0"),g(d,this.#e)||o.setAttribute("data-focused","")):o.setAttribute("tabindex","-1"),l.appendChild(o),s.appendChild(l),(i+h)%7===0&&(this.#f.appendChild(s),s=document.createElement("tr"))}let r=(i+t)%7;if(r>0){for(let h=r;h<7;h++)s.appendChild(document.createElement("td"));this.#f.appendChild(s)}}#F(t,e){return this.#Y(t,e).disabled}#Y(t,e){return this.#x.has(e)?{disabled:!0,reason:this.#x.get(e)}:this.#h&&t<this.#h?{disabled:!0,reason:null}:this.#o&&t>this.#o?{disabled:!0,reason:null}:{disabled:!1,reason:null}}#$(){this.#u.innerHTML="";let t=new Date().getFullYear(),e=this.#h?this.#h.getFullYear():t-100,i=this.#o?this.#o.getFullYear():t+10;for(let a=e;a<=i;a++){let s=document.createElement("option");s.value=String(a),s.textContent=String(a),this.#u.appendChild(s)}}#L(t){this.#i+=t,this.#i>11?(this.#i=0,this.#a++):this.#i<0&&(this.#i=11,this.#a--);let e=b(this.#a,this.#i),i=Math.min(this.#n.getDate(),e);this.#n=new Date(this.#a,this.#i,i),this.#d(),this.#T(this.#n)}#M(t){let e=c(t);this.#F(t,e)||(this.#e=t,this.#n=t,this.#g(),this.#E(),this.#C(),this.#d(),this.#m(),this.#t.focus(),this.dispatchEvent(new CustomEvent("date-picker:change",{bubbles:!0,detail:{value:e,date:new Date(t)}})))}#T(t){let e=c(t),i=this.#f.querySelector(`[data-date="${e}"]`);i&&(this.#f.querySelectorAll('button[tabindex="0"]').forEach(a=>{a.setAttribute("tabindex","-1")}),i.setAttribute("tabindex","0"),i.focus())}#g(){this.#e?this.#t.value=T(this.#e):this.#t.value=""}#N(){if(!this.#l){if(this.#l=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#s.hidden=!1,this.#a=this.#n.getFullYear(),this.#i=this.#n.getMonth(),this.#d(),this.#v){try{this.#s.showPopover()}catch{}this.#P(),window.addEventListener("scroll",this.#y,{capture:!0,passive:!0}),window.addEventListener("resize",this.#y,{passive:!0})}this.dispatchEvent(new CustomEvent("date-picker:open",{bubbles:!0}))}}#m(){if(this.#l){if(this.#l=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#s.hidden=!0,this.#v){try{this.#s.hidePopover()}catch{}window.removeEventListener("scroll",this.#y,{capture:!0}),window.removeEventListener("resize",this.#y)}this.dispatchEvent(new CustomEvent("date-picker:close",{bubbles:!0}))}}#P(){if(!this.#v)return;let t=this.#b.getBoundingClientRect(),e=this.#s.getBoundingClientRect(),i=4,a=8,s=window.innerHeight,r=window.innerWidth,h=s-t.bottom-a,d=t.top-a,u;h<e.height&&d>h?(u=t.top-e.height-i,this.#s.dataset.placement="top"):(u=t.bottom+i,delete this.#s.dataset.placement);let l=t.left;l+e.width>r-a&&(l=r-e.width-a),l<a&&(l=a),this.#s.style.setProperty("--calendar-top",`${u}px`),this.#s.style.setProperty("--calendar-left",`${l}px`)}#y=()=>{this.#l&&this.#P()};#O=()=>{let t=this.#t.value,{date:e,partial:i}=w(t);if(e)this.#n=e,this.#a=e.getFullYear(),this.#i=e.getMonth(),this.#d();else if(i){this.#a=i.year,this.#i=i.month;let a=b(i.year,i.month),s=Math.min(this.#n.getDate(),a);this.#n=new Date(i.year,i.month,s),this.#d()}!this.#l&&t.length>0&&this.#N()};#q=t=>{switch(t.key){case"Enter":{t.preventDefault(),t.stopPropagation();let{date:e}=w(this.#t.value);e&&!this.#F(e,c(e))&&this.#M(e);return}case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.#l||this.#N(),requestAnimationFrame(()=>this.#T(this.#n));return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#l&&this.#m(),this.#g();return;case"Tab":this.#l&&this.#m();return}};#R=t=>{if(t.relatedTarget&&this.contains(t.relatedTarget))return;let e=this.#t.value.trim();if(e){let{date:i}=w(e);i&&!this.#F(i,c(i))&&(this.#e=i,this.#n=i,this.#E(),this.#C(),this.dispatchEvent(new CustomEvent("date-picker:change",{bubbles:!0,detail:{value:c(i),date:new Date(i)}})))}this.#g(),this.#l&&this.#m(),this.#r.dispatchEvent(new Event("blur",{bubbles:!0}))};#z=t=>{this.#l&&!this.contains(t.target)&&this.#m()};#H=t=>{let e=t.target.closest("button[data-date]");!e||e.hasAttribute("disabled")||this.#M(p(e.getAttribute("data-date")))};#V=t=>{if(t.key==="Tab"){this.#m();return}let e=this.#n,i;switch(t.key){case"ArrowRight":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1);break;case"ArrowLeft":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()-1);break;case"ArrowDown":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+7);break;case"ArrowUp":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()-7);break;case"PageDown":t.shiftKey?i=new Date(e.getFullYear()+1,e.getMonth(),e.getDate()):i=new Date(e.getFullYear(),e.getMonth()+1,e.getDate());break;case"PageUp":t.shiftKey?i=new Date(e.getFullYear()-1,e.getMonth(),e.getDate()):i=new Date(e.getFullYear(),e.getMonth()-1,e.getDate());break;case"Home":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()-e.getDay()+this.#A);break;case"End":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+(6-e.getDay()+this.#A));break;case"Enter":case" ":t.preventDefault(),t.stopPropagation(),this.#M(e);return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#m(),this.#t.focus();return;default:return}t.preventDefault(),t.stopPropagation(),i&&(this.#h&&i<this.#h&&(i=this.#h),this.#o&&i>this.#o&&(i=this.#o),this.#n=i,(i.getMonth()!==this.#i||i.getFullYear()!==this.#a)&&(this.#i=i.getMonth(),this.#a=i.getFullYear(),this.#d()),this.#T(i))};#E(){let t=this.#e?c(this.#e):"";this.#c.setFormValue(t||null),this.#r.value=t,this.#r.dispatchEvent(new Event("input",{bubbles:!0}))}#C(){(this.hasAttribute("required")||this.#r.hasAttribute("required"))&&!this.#e?this.#c.setValidity({valueMissing:!0},"Please select a date",this.#t||this):this.#c.setValidity({})}formResetCallback(){this.#e=p(this.#S);let t=new Date;this.#n=this.#e||t,this.#a=this.#n.getFullYear(),this.#i=this.#n.getMonth(),this.#g(),this.#E(),this.#C(),this.#l&&this.#d()}formStateRestoreCallback(t){t&&(this.#e=p(t),this.#e&&(this.#n=this.#e,this.#a=this.#e.getFullYear(),this.#i=this.#e.getMonth(),this.#g(),this.#E(),this.#C()))}get value(){return this.#e?c(this.#e):""}set value(t){let e=p(t);e&&this.#M(e)}get min(){return this.#h?c(this.#h):""}set min(t){this.#h=t?p(t):null,this.#r&&this.#r.setAttribute("min",t||""),this.#d()}get max(){return this.#o?c(this.#o):""}set max(t){this.#o=t?p(t):null,this.#r&&this.#r.setAttribute("max",t||""),this.#d()}};E("date-picker",v);export{v as DatePicker};
|
|
1
|
+
var S=window.matchMedia("(prefers-reduced-motion: reduce)");var A=new Map;function E(n,t,e={}){let i=e.priority??10,a={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=A.get(n);if(customElements.get(n)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> 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 <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}A.set(n,a),customElements.define(n,t)}var m=class extends HTMLElement{#c=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#c)t();this.#c=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,a){t.addEventListener(e,i,a),this.#c.push(()=>t.removeEventListener(e,i,a))}setup(){}teardown(){}};var C="popover"in HTMLElement.prototype;var x=["Su","Mo","Tu","We","Th","Fr","Sa"],k=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],D=["january","february","march","april","may","june","july","august","september","october","november","december"];function c(n){let t=n.getFullYear(),e=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return`${t}-${e}-${i}`}function p(n){if(!n)return null;let[t,e,i]=n.split("-").map(Number);return new Date(t,e-1,i)}function b(n,t){return new Date(n,t+1,0).getDate()}function F(){try{let n=new Intl.Locale(navigator.language);if(n.weekInfo)return n.weekInfo.firstDay%7}catch{}return 0}function N(n){try{return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"long",day:"numeric"}).format(n)}catch{return c(n)}}function g(n,t){return n&&t&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function T(){let n=new Map;D.forEach((t,e)=>{n.set(t,e),n.set(t.slice(0,3),e)});try{for(let t=0;t<12;t++){let e=new Intl.DateTimeFormat(void 0,{month:"long"}).format(new Date(2e3,t,1)).toLowerCase(),i=new Intl.DateTimeFormat(void 0,{month:"short"}).format(new Date(2e3,t,1)).toLowerCase().replace(".","");n.set(e,t),n.set(i,t)}}catch{}return n}var w=T();function y(n){let t=n.trim();if(!t)return{date:null,partial:null};if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let r=p(t);return r&&!isNaN(r.getTime())?{date:r,partial:null}:{date:null,partial:null}}if(/^\d{4}\/\d{2}\/\d{2}$/.test(t)){let r=p(t.replace(/\//g,"-"));return r&&!isNaN(r.getTime())?{date:r,partial:null}:{date:null,partial:null}}let e=/^([a-z\u00C0-\u024F]+)\s+(\d{1,2}),?\s+(\d{4})$/i,i=t.match(e);if(i){let r=w.get(i[1].toLowerCase());if(r!==void 0){let h=new Date(Number(i[3]),r,Number(i[2]));if(!isNaN(h.getTime()))return{date:h,partial:null}}}let a=/^(\d{1,2})\s+([a-z\u00C0-\u024F]+)\s+(\d{4})$/i;if(i=t.match(a),i){let r=w.get(i[2].toLowerCase());if(r!==void 0){let h=new Date(Number(i[3]),r,Number(i[1]));if(!isNaN(h.getTime()))return{date:h,partial:null}}}let s=/^([a-z\u00C0-\u024F]+)\s+(\d{4})$/i;if(i=t.match(s),i){let r=w.get(i[1].toLowerCase());if(r!==void 0)return{date:null,partial:{year:Number(i[2]),month:r}}}return{date:null,partial:null}}var v=class extends m{static formAssociated=!0;#c;#r;#t;#p;#b;#s;#y;#f;#D;#u;#l=!1;#v=!1;#e=null;#n=null;#a;#i;#h=null;#o=null;#x=new Map;#k=new Map;#S;#A;constructor(){super(),this.#c=this.attachInternals()}setup(){if(this.#r=this.querySelector(':scope > input[type="date"]'),!this.#r)return!1;this.#h=p(this.#r.getAttribute("min")),this.#o=p(this.#r.getAttribute("max")),this.#A=F();let t=this.getAttribute("data-disabled-dates");t&&t.split(",").forEach(a=>{let[s,r]=a.trim().split(":");this.#x.set(s,r||null)});let e=this.getAttribute("data-highlight-dates");e&&e.split(",").forEach(a=>{let[s,r]=a.trim().split(":");this.#k.set(s,r||null)}),this.#e=p(this.#r.value),this.#S=this.#r.value;let i=new Date;this.#o&&i>this.#o&&(i=this.#o),this.#h&&i<this.#h&&(i=this.#h),this.#a=this.#e?this.#e.getFullYear():i.getFullYear(),this.#i=this.#e?this.#e.getMonth():i.getMonth(),this.#n=this.#e||i,this.#r.setAttribute("tabindex","-1"),this.#r.setAttribute("aria-hidden","true"),this.#r.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.#I(),this.#B(),this.#g(),this.#E(),this.#C(),this.#v=C,this.#v&&this.#s.setAttribute("popover","manual"),this.listen(document,"click",this.#z),(this.#r.disabled||this.hasAttribute("disabled"))&&(this.setAttribute("data-disabled",""),this.#t.disabled=!0)}teardown(){window.removeEventListener("scroll",this.#w,{capture:!0}),window.removeEventListener("resize",this.#w)}#I(){this.#b=document.createElement("div"),this.#b.className="date-trigger",this.#t=document.createElement("input"),this.#t.type="text",this.#t.className="date-input",this.#t.setAttribute("role","combobox"),this.#t.setAttribute("aria-haspopup","dialog"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("autocomplete","off"),this.#t.setAttribute("placeholder","Type a date\u2026"),this.#b.appendChild(this.#t),this.#p=document.createElement("button"),this.#p.type="button",this.#p.className="date-trigger-icon",this.#p.setAttribute("aria-label","Toggle calendar"),this.#p.setAttribute("tabindex","-1");let t=document.createElement("icon-wc");t.setAttribute("name","calendar"),t.setAttribute("size","sm"),t.setAttribute("aria-hidden","true"),this.#p.appendChild(t),this.#b.appendChild(this.#p),this.appendChild(this.#b),this.listen(this.#p,"click",e=>{e.stopPropagation(),this.#l?this.#m():this.#T(),this.#t.focus()}),this.listen(this.#t,"focus",()=>this.#t.select()),this.listen(this.#t,"input",this.#O),this.listen(this.#t,"keydown",this.#q),this.listen(this.#t,"blur",this.#R)}#B(){this.#y=`dp-${Math.random().toString(36).slice(2,8)}`,this.#s=document.createElement("div"),this.#s.className="calendar",this.#s.id=this.#y,this.#s.setAttribute("role","dialog"),this.#s.setAttribute("aria-modal","false"),this.#s.setAttribute("aria-label","Choose date"),this.#s.hidden=!0,this.#t.setAttribute("aria-controls",this.#y);let t=document.createElement("div");t.className="calendar-header";let e=document.createElement("button");e.type="button",e.className="calendar-nav",e.setAttribute("aria-label","Previous month");let i=document.createElement("icon-wc");i.setAttribute("name","chevron-left"),i.setAttribute("size","sm"),i.setAttribute("aria-hidden","true"),e.appendChild(i);let a=document.createElement("span");a.className="calendar-title",a.id=`${this.#y}-title`,a.setAttribute("aria-live","polite"),this.#D=document.createElement("span"),this.#D.className="calendar-month",this.#u=document.createElement("select"),this.#u.className="calendar-year",this.#u.setAttribute("aria-label","Year"),this.#Y(),a.appendChild(this.#D),a.appendChild(this.#u);let s=document.createElement("button");s.type="button",s.className="calendar-nav",s.setAttribute("aria-label","Next month");let r=document.createElement("icon-wc");r.setAttribute("name","chevron-right"),r.setAttribute("size","sm"),r.setAttribute("aria-hidden","true"),s.appendChild(r),t.appendChild(e),t.appendChild(a),t.appendChild(s),this.#s.appendChild(t);let h=document.createElement("table");h.setAttribute("role","grid"),h.setAttribute("aria-labelledby",`${this.#y}-title`);let d=document.createElement("thead"),u=document.createElement("tr");for(let l=0;l<7;l++){let o=(this.#A+l)%7,f=document.createElement("th");f.setAttribute("abbr",k[o]),f.setAttribute("scope","col"),f.textContent=x[o],u.appendChild(f)}d.appendChild(u),h.appendChild(d),this.#f=document.createElement("tbody"),h.appendChild(this.#f),this.#s.appendChild(h),this.appendChild(this.#s),this.#d(),this.listen(e,"click",()=>this.#L(-1)),this.listen(s,"click",()=>this.#L(1)),this.listen(this.#u,"change",()=>{this.#a=Number(this.#u.value);let l=b(this.#a,this.#i),o=Math.min(this.#n.getDate(),l);this.#n=new Date(this.#a,this.#i,o),this.#d()}),this.listen(this.#f,"click",this.#H),this.listen(this.#s,"keydown",this.#V)}#d(){try{this.#D.textContent=new Intl.DateTimeFormat(void 0,{month:"long"}).format(new Date(this.#a,this.#i,1))}catch{this.#D.textContent=D[this.#i].charAt(0).toUpperCase()+D[this.#i].slice(1)}this.#u.querySelector(`option[value="${this.#a}"]`)||this.#Y(),this.#u.value=String(this.#a),this.#f.innerHTML="";let t=b(this.#a,this.#i),i=(new Date(this.#a,this.#i,1).getDay()-this.#A+7)%7,a=new Date,s=document.createElement("tr");for(let h=0;h<i;h++)s.appendChild(document.createElement("td"));for(let h=1;h<=t;h++){let d=new Date(this.#a,this.#i,h),u=c(d),l=document.createElement("td"),o=document.createElement("button");o.type="button",o.setAttribute("data-date",u),o.textContent=String(h),g(d,a)&&o.setAttribute("aria-current","date"),g(d,this.#e)&&o.setAttribute("aria-selected","true");let f=this.#$(d,u);if(f.disabled&&(o.setAttribute("aria-disabled","true"),o.setAttribute("disabled",""),f.reason&&o.setAttribute("data-disabled-reason",f.reason)),this.#k.has(u)){let M=this.#k.get(u);o.setAttribute("data-highlight",M||"")}g(d,this.#n)?(o.setAttribute("tabindex","0"),g(d,this.#e)||o.setAttribute("data-focused","")):o.setAttribute("tabindex","-1"),l.appendChild(o),s.appendChild(l),(i+h)%7===0&&(this.#f.appendChild(s),s=document.createElement("tr"))}let r=(i+t)%7;if(r>0){for(let h=r;h<7;h++)s.appendChild(document.createElement("td"));this.#f.appendChild(s)}}#F(t,e){return this.#$(t,e).disabled}#$(t,e){return this.#x.has(e)?{disabled:!0,reason:this.#x.get(e)}:this.#h&&t<this.#h?{disabled:!0,reason:null}:this.#o&&t>this.#o?{disabled:!0,reason:null}:{disabled:!1,reason:null}}#Y(){this.#u.innerHTML="";let t=new Date().getFullYear(),e=this.#h?this.#h.getFullYear():t-100,i=this.#o?this.#o.getFullYear():t+10;for(let a=e;a<=i;a++){let s=document.createElement("option");s.value=String(a),s.textContent=String(a),this.#u.appendChild(s)}}#L(t){this.#i+=t,this.#i>11?(this.#i=0,this.#a++):this.#i<0&&(this.#i=11,this.#a--);let e=b(this.#a,this.#i),i=Math.min(this.#n.getDate(),e);this.#n=new Date(this.#a,this.#i,i),this.#d(),this.#N(this.#n)}#M(t){let e=c(t);this.#F(t,e)||(this.#e=t,this.#n=t,this.#g(),this.#E(),this.#C(),this.#d(),this.#m(),this.#t.focus(),this.dispatchEvent(new CustomEvent("date-picker:change",{bubbles:!0,detail:{value:e,date:new Date(t)}})))}#N(t){let e=c(t),i=this.#f.querySelector(`[data-date="${e}"]`);i&&(this.#f.querySelectorAll('button[tabindex="0"]').forEach(a=>{a.setAttribute("tabindex","-1")}),i.setAttribute("tabindex","0"),i.focus())}#g(){this.#e?this.#t.value=N(this.#e):this.#t.value=""}#T(){if(!this.#l){if(this.#l=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#s.hidden=!1,this.#a=this.#n.getFullYear(),this.#i=this.#n.getMonth(),this.#d(),this.#v){try{this.#s.showPopover()}catch{}this.#P(),window.addEventListener("scroll",this.#w,{capture:!0,passive:!0}),window.addEventListener("resize",this.#w,{passive:!0})}this.dispatchEvent(new CustomEvent("date-picker:open",{bubbles:!0}))}}#m(){if(this.#l){if(this.#l=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#s.hidden=!0,this.#v){try{this.#s.hidePopover()}catch{}window.removeEventListener("scroll",this.#w,{capture:!0}),window.removeEventListener("resize",this.#w)}this.dispatchEvent(new CustomEvent("date-picker:close",{bubbles:!0}))}}#P(){if(!this.#v)return;let t=this.#b.getBoundingClientRect(),e=this.#s.getBoundingClientRect(),i=4,a=8,s=window.innerHeight,r=window.innerWidth,h=s-t.bottom-a,d=t.top-a,u;h<e.height&&d>h?(u=t.top-e.height-i,this.#s.dataset.placement="top"):(u=t.bottom+i,delete this.#s.dataset.placement);let l=t.left;l+e.width>r-a&&(l=r-e.width-a),l<a&&(l=a),this.#s.style.setProperty("--calendar-top",`${u}px`),this.#s.style.setProperty("--calendar-left",`${l}px`)}#w=()=>{this.#l&&this.#P()};#O=()=>{let t=this.#t.value,{date:e,partial:i}=y(t);if(e)this.#n=e,this.#a=e.getFullYear(),this.#i=e.getMonth(),this.#d();else if(i){this.#a=i.year,this.#i=i.month;let a=b(i.year,i.month),s=Math.min(this.#n.getDate(),a);this.#n=new Date(i.year,i.month,s),this.#d()}!this.#l&&t.length>0&&this.#T()};#q=t=>{switch(t.key){case"Enter":{t.preventDefault(),t.stopPropagation();let{date:e}=y(this.#t.value);e&&!this.#F(e,c(e))&&this.#M(e);return}case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.#l||this.#T(),requestAnimationFrame(()=>this.#N(this.#n));return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#l&&this.#m(),this.#g();return;case"Tab":this.#l&&this.#m();return}};#R=t=>{if(t.relatedTarget&&this.contains(t.relatedTarget))return;let e=this.#t.value.trim();if(e){let{date:i}=y(e);i&&!this.#F(i,c(i))&&(this.#e=i,this.#n=i,this.#E(),this.#C(),this.dispatchEvent(new CustomEvent("date-picker:change",{bubbles:!0,detail:{value:c(i),date:new Date(i)}})))}this.#g(),this.#l&&this.#m(),this.#r.dispatchEvent(new Event("blur",{bubbles:!0}))};#z=t=>{this.#l&&!this.contains(t.target)&&this.#m()};#H=t=>{let e=t.target.closest("button[data-date]");!e||e.hasAttribute("disabled")||this.#M(p(e.getAttribute("data-date")))};#V=t=>{if(t.key==="Tab"){this.#m();return}let e=this.#n,i;switch(t.key){case"ArrowRight":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1);break;case"ArrowLeft":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()-1);break;case"ArrowDown":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+7);break;case"ArrowUp":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()-7);break;case"PageDown":t.shiftKey?i=new Date(e.getFullYear()+1,e.getMonth(),e.getDate()):i=new Date(e.getFullYear(),e.getMonth()+1,e.getDate());break;case"PageUp":t.shiftKey?i=new Date(e.getFullYear()-1,e.getMonth(),e.getDate()):i=new Date(e.getFullYear(),e.getMonth()-1,e.getDate());break;case"Home":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()-e.getDay()+this.#A);break;case"End":i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+(6-e.getDay()+this.#A));break;case"Enter":case" ":t.preventDefault(),t.stopPropagation(),this.#M(e);return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#m(),this.#t.focus();return;default:return}t.preventDefault(),t.stopPropagation(),i&&(this.#h&&i<this.#h&&(i=this.#h),this.#o&&i>this.#o&&(i=this.#o),this.#n=i,(i.getMonth()!==this.#i||i.getFullYear()!==this.#a)&&(this.#i=i.getMonth(),this.#a=i.getFullYear(),this.#d()),this.#N(i))};#E(){let t=this.#e?c(this.#e):"";this.#c.setFormValue(t||null),this.#r.value=t,this.#r.dispatchEvent(new Event("input",{bubbles:!0}))}#C(){(this.hasAttribute("required")||this.#r.hasAttribute("required"))&&!this.#e?this.#c.setValidity({valueMissing:!0},"Please select a date",this.#t||this):this.#c.setValidity({})}formResetCallback(){this.#e=p(this.#S);let t=new Date;this.#n=this.#e||t,this.#a=this.#n.getFullYear(),this.#i=this.#n.getMonth(),this.#g(),this.#E(),this.#C(),this.#l&&this.#d()}formStateRestoreCallback(t){t&&(this.#e=p(t),this.#e&&(this.#n=this.#e,this.#a=this.#e.getFullYear(),this.#i=this.#e.getMonth(),this.#g(),this.#E(),this.#C()))}get value(){return this.#e?c(this.#e):""}set value(t){let e=p(t);e&&this.#M(e)}get min(){return this.#h?c(this.#h):""}set min(t){this.#h=t?p(t):null,this.#r&&this.#r.setAttribute("min",t||""),this.#d()}get max(){return this.#o?c(this.#o):""}set max(t){this.#o=t?p(t):null,this.#r&&this.#r.setAttribute("max",t||""),this.#d()}};E("date-picker",v);export{v as DatePicker};
|
|
2
2
|
//# sourceMappingURL=date-picker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var g=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let o of this.#t)o();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(o,e,t,s){o.addEventListener(e,t,s),this.#t.push(()=>o.removeEventListener(e,t,s))}setup(){}teardown(){}};var M=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function w(f,o,e={}){let t=e.priority??10,s={impl:o,bundle:e.bundle,contract:e.contract,priority:t},n=E.get(f);if(customElements.get(f)){if(!n||n.priority>=t){n&&n.priority===t&&n.impl!==o&&console.warn(`[VB Bundle] Tag <${f}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${f}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=t){n.priority===t&&console.warn(`[VB Bundle] Tag <${f}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(f,s),customElements.define(f,o)}var b=class extends g{#t;setup(){if(this.#t=this.querySelector("ol"),!this.#t&&this.dataset.startHour==="auto"&&this.#n(),!this.#t)return!1;this.#e(),this.listen(this.#t,"click",e=>{let t=e.target.closest("calendar-event");t&&this.dispatchEvent(new CustomEvent("day-view:event-click",{bubbles:!0,detail:{time:t.querySelector("time[datetime]")?.getAttribute("datetime"),text:t.textContent.trim(),element:t,category:t.dataset.category,duration:t.dataset.duration}}))}),this.listen(this.#t,"keydown",e=>{let t=e.target.closest("calendar-event");if(!t)return;let s=[...this.#t.querySelectorAll("calendar-event")],n=s.indexOf(t);if(n===-1)return;let l;e.key==="ArrowDown"&&n<s.length-1&&(l=s[n+1]),e.key==="ArrowUp"&&n>0&&(l=s[n-1]),l&&(e.preventDefault(),l.setAttribute("tabindex","0"),t.setAttribute("tabindex","-1"),l.focus())});let o=this.#t.querySelector("calendar-event");o&&o.setAttribute("tabindex","0")}#n(){let o=[...this.querySelectorAll(":scope > calendar-event")];if(o.length===0)return;let e=new Map,t=[];if(o.forEach(r=>{let a=r.querySelector("time[datetime]");if(!a){t.push(r);return}let m=a.getAttribute("datetime").split(":"),c=parseInt(m[0],10),p=parseInt(m[1]||"0",10);if(isNaN(c)){t.push(r);return}p>=30&&!r.dataset.start&&(r.dataset.start="30"),e.has(c)||e.set(c,[]),e.get(c).push(r)}),t.length>0){let r=document.createElement("ul");r.className="all-day-events",t.forEach(a=>{let h=document.createElement("li");h.appendChild(a),r.appendChild(h)}),this.prepend(r)}let s=[...e.keys()].sort((r,a)=>r-a);if(s.length===0)return;let n=Math.max(0,s[0]-1),l=Math.min(23,s[s.length-1]+1),i=this.closest("[lang]")?.lang||navigator.language,d=new Intl.DateTimeFormat(i,{hour:"numeric"}),u=document.createElement("ol");for(let r=n;r<=l;r++){let a=document.createElement("li"),h=document.createElement("time"),m=String(r).padStart(2,"0");h.setAttribute("datetime",`${m}:00`),h.textContent=d.format(new Date(2026,0,1,r));let c=document.createElement("hour-view"),p=e.get(r)||[];p.length>1&&(c.dataset.overlap=""),p.forEach(y=>c.appendChild(y)),a.append(h,c),u.appendChild(a)}this.appendChild(u),this.#t=u}teardown(){this.querySelectorAll("calendar-event.dv-spanning").forEach(o=>{o.style.cssText="",o.classList.remove("dv-spanning")})}refresh(){this.teardown(),this.#e()}#e(){let o=this.#t,e=o.querySelectorAll("calendar-event[data-duration]");e.length!==0&&requestAnimationFrame(()=>{let t=o.getBoundingClientRect(),s=new Map,n=64;o.querySelectorAll(":scope > li").forEach(i=>{let d=i.querySelector(":scope > time");if(!d)return;let u=d.getAttribute("datetime");if(!u)return;let r=parseInt(u.split(":")[0],10),a=i.getBoundingClientRect();s.set(r,{top:a.top-t.top,height:a.height}),n=d.getBoundingClientRect().width});let l=[];e.forEach(i=>{let d=i.closest("ol > li");if(!d)return;let u=d.querySelector(":scope > time"),r=parseInt(u?.getAttribute("datetime")?.split(":")[0],10),a=parseInt(i.dataset.start||"0",10),h=i.dataset.duration,m=60,c=h.match(/(\d+)h/),p=h.match(/(\d+)m/);(c||p)&&(m=(c?parseInt(c[1],10)*60:0)+(p?parseInt(p[1],10):0));let y=s.get(r);if(!y)return;let v=a/60,S=y.top+y.height*v,x=y.height*(m/60);l.push({event:i,top:S,height:x})}),l.forEach(({event:i,top:d,height:u})=>{i.style.position="absolute",i.style.top=d+"px",i.style.height=u+"px",i.style.left=n+4+"px",i.style.right="4px",i.classList.add("dv-spanning")})})}};w("day-view",b);export{b as DayView};
|
|
1
|
+
var g=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let o of this.#t)o();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(o,e,t,s){o.addEventListener(e,t,s),this.#t.push(()=>o.removeEventListener(e,t,s))}setup(){}teardown(){}};var M=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function w(f,o,e={}){let t=e.priority??10,s={impl:o,bundle:e.bundle,contract:e.contract,priority:t},n=E.get(f);if(customElements.get(f)){if(!n||n.priority>=t){n&&n.priority===t&&n.impl!==o&&console.warn(`[VB Bundle] Tag <${f}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${f}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=t){n.priority===t&&console.warn(`[VB Bundle] Tag <${f}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(f,s),customElements.define(f,o)}var b=class extends g{#t;setup(){if(this.#t=this.querySelector("ol"),!this.#t&&this.dataset.startHour==="auto"&&this.#n(),!this.#t)return!1;this.#e(),this.listen(this.#t,"click",e=>{let t=e.target.closest("calendar-event");t&&this.dispatchEvent(new CustomEvent("day-view:event-click",{bubbles:!0,detail:{time:t.querySelector("time[datetime]")?.getAttribute("datetime"),text:t.textContent.trim(),element:t,category:t.dataset.category,duration:t.dataset.duration}}))}),this.listen(this.#t,"keydown",e=>{let t=e.target.closest("calendar-event");if(!t)return;let s=[...this.#t.querySelectorAll("calendar-event")],n=s.indexOf(t);if(n===-1)return;let l;e.key==="ArrowDown"&&n<s.length-1&&(l=s[n+1]),e.key==="ArrowUp"&&n>0&&(l=s[n-1]),l&&(e.preventDefault(),l.setAttribute("tabindex","0"),t.setAttribute("tabindex","-1"),l.focus())});let o=this.#t.querySelector("calendar-event");o&&o.setAttribute("tabindex","0")}#n(){let o=[...this.querySelectorAll(":scope > calendar-event")];if(o.length===0)return;let e=new Map,t=[];if(o.forEach(r=>{let a=r.querySelector("time[datetime]");if(!a){t.push(r);return}let m=a.getAttribute("datetime").split(":"),c=parseInt(m[0],10),p=parseInt(m[1]||"0",10);if(isNaN(c)){t.push(r);return}p>=30&&!r.dataset.start&&(r.dataset.start="30"),e.has(c)||e.set(c,[]),e.get(c).push(r)}),t.length>0){let r=document.createElement("ul");r.className="all-day-events",t.forEach(a=>{let h=document.createElement("li");h.appendChild(a),r.appendChild(h)}),this.prepend(r)}let s=[...e.keys()].sort((r,a)=>r-a);if(s.length===0)return;let n=Math.max(0,s[0]-1),l=Math.min(23,s[s.length-1]+1),i=this.closest("[lang]")?.lang||navigator.language,d=new Intl.DateTimeFormat(i,{hour:"numeric"}),u=document.createElement("ol");for(let r=n;r<=l;r++){let a=document.createElement("li"),h=document.createElement("time"),m=String(r).padStart(2,"0");h.setAttribute("datetime",`${m}:00`),h.textContent=d.format(new Date(2026,0,1,r));let c=document.createElement("hour-view"),p=e.get(r)||[];p.length>1&&(c.dataset.overlap=""),p.forEach(y=>c.appendChild(y)),a.append(h,c),u.appendChild(a)}this.appendChild(u),this.#t=u}teardown(){this.querySelectorAll("calendar-event.dv-spanning").forEach(o=>{o.style.cssText="",o.classList.remove("dv-spanning")})}refresh(){this.teardown(),this.#e()}#e(){let o=this.#t,e=o.querySelectorAll("calendar-event[data-duration]");e.length!==0&&requestAnimationFrame(()=>{let t=o.getBoundingClientRect(),s=new Map,n=64;o.querySelectorAll(":scope > li").forEach(i=>{let d=i.querySelector(":scope > time");if(!d)return;let u=d.getAttribute("datetime");if(!u)return;let r=parseInt(u.split(":")[0],10),a=i.getBoundingClientRect();s.set(r,{top:a.top-t.top,height:a.height}),n=d.getBoundingClientRect().width});let l=[];e.forEach(i=>{let d=i.closest("ol > li");if(!d)return;let u=d.querySelector(":scope > time"),r=parseInt(u?.getAttribute("datetime")?.split(":")[0],10),a=parseInt(i.dataset.start||"0",10),h=i.dataset.duration,m=60,c=h.match(/(\d+)h/),p=h.match(/(\d+)m/);(c||p)&&(m=(c?parseInt(c[1],10)*60:0)+(p?parseInt(p[1],10):0));let y=s.get(r);if(!y)return;let v=a/60,S=y.top+y.height*v,x=y.height*(m/60);l.push({event:i,top:S,height:x})}),l.forEach(({event:i,top:d,height:u})=>{i.style.position="absolute",i.style.top=d+"px",i.style.height=u+"px",i.style.left=n+4+"px",i.style.right="4px",i.classList.add("dv-spanning")})})}};w("day-view",b);export{b as DayView};
|
|
2
2
|
//# sourceMappingURL=day-view.js.map
|