vanilla-breeze 0.6.2 → 0.7.0
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/activity-feed.js +1 -1
- package/dist/cdn/components/ai-chat.js +6 -6
- package/dist/cdn/components/ai-summary.js +2 -2
- package/dist/cdn/components/analytics-panel.js +2 -2
- package/dist/cdn/components/audio-player.js +4 -4
- package/dist/cdn/components/audio-visualizer.js +2 -2
- package/dist/cdn/components/author-index.js +2 -2
- package/dist/cdn/components/brand-mark.js +1 -1
- package/dist/cdn/components/bread-crumb.js +1 -1
- package/dist/cdn/components/calendar-wc.js +2 -2
- package/dist/cdn/components/card-list.js +1 -1
- package/dist/cdn/components/carousel-wc.js +1 -1
- package/dist/cdn/components/change-set.js +1 -1
- package/dist/cdn/components/chart-wc.js +13 -13
- package/dist/cdn/components/chat-input.js +1 -1
- package/dist/cdn/components/chat-window.js +1 -1
- package/dist/cdn/components/color-picker.js +1 -1
- package/dist/cdn/components/combo-box.js +1 -1
- package/dist/cdn/components/command-palette.js +1 -1
- package/dist/cdn/components/comment-box.js +35 -35
- package/dist/cdn/components/comment-thread.js +38 -38
- package/dist/cdn/components/comment-wc.js +1 -1
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/consent-banner.js +1 -1
- package/dist/cdn/components/content-lens.js +1 -1
- package/dist/cdn/components/content-swap.js +1 -1
- package/dist/cdn/components/context-menu.js +1 -1
- package/dist/cdn/components/data-table.js +1 -1
- package/dist/cdn/components/date-picker.js +1 -1
- package/dist/cdn/components/day-view.js +1 -1
- package/dist/cdn/components/diagram-wc.js +2 -2
- package/dist/cdn/components/drag-surface.js +1 -1
- package/dist/cdn/components/drop-down.js +1 -1
- package/dist/cdn/components/emoji-picker.js +1 -1
- package/dist/cdn/components/flow-diagram.js +1 -1
- package/dist/cdn/components/foot-notes.js +1 -1
- package/dist/cdn/components/form-field.js +1 -1
- package/dist/cdn/components/geo-map.js +3 -3
- package/dist/cdn/components/glossary-index.js +1 -1
- package/dist/cdn/components/glossary-wc.js +1 -1
- package/dist/cdn/components/heading-links.js +1 -1
- package/dist/cdn/components/highlight-wc.js +2 -2
- package/dist/cdn/components/icon-wc.js +2 -2
- package/dist/cdn/components/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/manifest.json +58 -54
- package/dist/cdn/components/markdown-editor.js +25 -25
- package/dist/cdn/components/markdown-viewer.js +27 -27
- package/dist/cdn/components/nav-bar.js +1 -1
- package/dist/cdn/components/note-wc.js +2 -2
- package/dist/cdn/components/notification-wc.js +23 -23
- package/dist/cdn/components/page-info.js +6 -6
- package/dist/cdn/components/page-stats.js +1 -1
- package/dist/cdn/components/page-toc.js +1 -1
- package/dist/cdn/components/page-tools.js +1 -1
- package/dist/cdn/components/page-tour.js +1 -1
- package/dist/cdn/components/pager-wc.js +1 -1
- package/dist/cdn/components/poll-wc.js +1 -1
- package/dist/cdn/components/pop-over.js +1 -1
- package/dist/cdn/components/popularity-index.js +1 -1
- package/dist/cdn/components/print-page.js +1 -1
- package/dist/cdn/components/progress-tracker.js +1 -1
- package/dist/cdn/components/qr-code.js +1 -1
- package/dist/cdn/components/reaction-bar.js +1 -1
- package/dist/cdn/components/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +1 -1
- package/dist/cdn/components/score-card.js +2 -2
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/settings-panel.js +6 -6
- package/dist/cdn/components/share-wc.js +2 -2
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -1
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +1 -1
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/social-links.js +2 -0
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/status-wc.js +1 -1
- package/dist/cdn/components/stepper-wc.js +1 -1
- package/dist/cdn/components/tab-set.js +1 -1
- package/dist/cdn/components/text-reader.js +2 -2
- package/dist/cdn/components/theme-picker.js +20 -20
- package/dist/cdn/components/time-index.js +1 -1
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +2 -2
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +4 -4
- package/dist/cdn/components/trust-filter.js +1 -1
- package/dist/cdn/components/version-switcher.js +6 -6
- package/dist/cdn/components/video-player.js +4 -4
- package/dist/cdn/components/watch-wc.js +2 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/fonts/barlow-condensed-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii.full.css +1 -1
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +4 -4
- package/dist/cdn/packs/prototype.full.js +1 -1
- package/dist/cdn/packs/ui.full.js +19 -19
- package/dist/cdn/themes/8bit.tokens.json +8 -37
- package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999.css +1 -1
- package/dist/cdn/themes/alpha1999.tokens.json +3 -6
- package/dist/cdn/themes/art-deco-dark.tokens.json +3 -27
- package/dist/cdn/themes/art-deco.css +1 -1
- package/dist/cdn/themes/art-deco.tokens.json +5 -11
- package/dist/cdn/themes/bauhaus-dark.tokens.json +1 -1
- package/dist/cdn/themes/bauhaus.css +1 -1
- package/dist/cdn/themes/bauhaus.tokens.json +13 -7
- package/dist/cdn/themes/brutalist-dark.tokens.json +3 -27
- package/dist/cdn/themes/brutalist.tokens.json +5 -11
- package/dist/cdn/themes/catppuccin-frappe.css +1 -1
- package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte.css +1 -1
- package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-mocha.css +1 -1
- package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
- package/dist/cdn/themes/classic-dark.tokens.json +41 -41
- package/dist/cdn/themes/classic.tokens.json +25 -31
- package/dist/cdn/themes/claymorphism-dark.tokens.json +533 -161
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/claymorphism.tokens.json +531 -135
- package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
- package/dist/cdn/themes/clinical.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore.css +1 -1
- package/dist/cdn/themes/cottagecore.tokens.json +1 -1
- package/dist/cdn/themes/cyber.css +1 -1
- package/dist/cdn/themes/cyber.tokens.json +5 -11
- package/dist/cdn/themes/dawn-dark.tokens.json +3 -27
- package/dist/cdn/themes/dawn.css +1 -1
- package/dist/cdn/themes/dawn.tokens.json +1 -1
- package/dist/cdn/themes/dracula.tokens.json +1 -1
- package/dist/cdn/themes/dusk.tokens.json +1 -1
- package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
- package/dist/cdn/themes/editorial.tokens.json +19 -16
- package/dist/cdn/themes/financial-dark.tokens.json +1 -1
- package/dist/cdn/themes/financial.css +1 -1
- package/dist/cdn/themes/financial.tokens.json +1 -1
- package/dist/cdn/themes/genai.css +1 -1
- package/dist/cdn/themes/genai.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism-dark.tokens.json +233 -116
- package/dist/cdn/themes/glassmorphism.css +1 -1
- package/dist/cdn/themes/glassmorphism.tokens.json +233 -116
- package/dist/cdn/themes/government-dark.tokens.json +1 -1
- package/dist/cdn/themes/government.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox.css +1 -1
- package/dist/cdn/themes/gruvbox.tokens.json +1 -1
- package/dist/cdn/themes/high-noon-dark.tokens.json +1 -1
- package/dist/cdn/themes/high-noon.tokens.json +1 -1
- package/dist/cdn/themes/journal-dark.tokens.json +3 -27
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +21 -21
- package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
- package/dist/cdn/themes/kawaii.css +1 -1
- package/dist/cdn/themes/kawaii.tokens.json +1 -1
- package/dist/cdn/themes/magna-dark.tokens.json +1 -1
- package/dist/cdn/themes/magna.css +1 -1
- package/dist/cdn/themes/magna.tokens.json +2 -14
- package/dist/cdn/themes/manifest.json +25 -25
- package/dist/cdn/themes/midnight.tokens.json +1 -1
- package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
- package/dist/cdn/themes/minimal.tokens.json +25 -27
- package/dist/cdn/themes/modern-dark.tokens.json +41 -41
- package/dist/cdn/themes/modern.css +1 -1
- package/dist/cdn/themes/modern.tokens.json +21 -21
- package/dist/cdn/themes/nes-dark.tokens.json +3 -27
- package/dist/cdn/themes/nes.tokens.json +10 -39
- package/dist/cdn/themes/neumorphism-dark.tokens.json +266 -134
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/neumorphism.tokens.json +266 -134
- package/dist/cdn/themes/nord-dark.tokens.json +3 -27
- package/dist/cdn/themes/nord.css +1 -1
- package/dist/cdn/themes/nord.tokens.json +1 -1
- package/dist/cdn/themes/organic-dark.tokens.json +1 -1
- package/dist/cdn/themes/organic.tokens.json +5 -14
- package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine.css +1 -1
- package/dist/cdn/themes/rose-pine.tokens.json +1 -1
- package/dist/cdn/themes/rough-dark.tokens.json +1 -1
- package/dist/cdn/themes/rough.tokens.json +1 -1
- package/dist/cdn/themes/solarized-dark.tokens.json +1 -1
- package/dist/cdn/themes/solarized.tokens.json +1 -1
- package/dist/cdn/themes/startup-dark.tokens.json +1 -1
- package/dist/cdn/themes/startup.css +1 -1
- package/dist/cdn/themes/startup.tokens.json +1 -1
- package/dist/cdn/themes/super2026-dark.tokens.json +6 -30
- package/dist/cdn/themes/super2026.css +1 -1
- package/dist/cdn/themes/super2026.tokens.json +1 -1
- package/dist/cdn/themes/swiss-dark.tokens.json +4 -40
- package/dist/cdn/themes/swiss.tokens.json +34 -68
- package/dist/cdn/themes/terminal.tokens.json +286 -120
- package/dist/cdn/themes/tokyo-night-dark.tokens.json +3 -27
- package/dist/cdn/themes/tokyo-night.css +1 -1
- package/dist/cdn/themes/tokyo-night.tokens.json +1 -1
- package/dist/cdn/themes/vaporwave-dark.tokens.json +3 -27
- package/dist/cdn/themes/vaporwave.tokens.json +1 -1
- package/dist/cdn/themes/win9x-dark.tokens.json +5 -29
- package/dist/cdn/themes/win9x.tokens.json +9 -9
- package/dist/cdn/vanilla-breeze-autoload.js +113 -108
- package/dist/cdn/vanilla-breeze-charts.js +13 -13
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +80 -75
- package/dist/cdn/vanilla-breeze-extras.js +31 -31
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +133 -133
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var T=window.matchMedia("(prefers-reduced-motion: reduce)");var y=new Map;function g(t,e,r={}){let n=r.priority??10,s={impl:e,bundle:r.bundle,contract:r.contract,priority:n},i=y.get(t);if(customElements.get(t)){if(!i||i.priority>=n){i&&i.priority===n&&i.impl!==e&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${r.bundle}".`);return}console.warn(`[VB Bundle] Tag <${t}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${r.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=n){i.priority===n&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${i.bundle}". Skipping "${r.bundle}" (first wins at equal priority).`);return}y.set(t,s),customElements.define(t,e)}var u=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,r,n,s){e.addEventListener(r,n,s),this.#e.push(()=>e.removeEventListener(r,n,s))}_reinit(){for(let e of this.#e)e();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,r){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{r?n.add(e):n.delete(e)}catch{let s=`--${e}`;r?n.add(s):n.delete(s)}}_adoptInternals(e){this.#t||(this.#t=e)}#r(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};function S(){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,r){t.setItem(e,r)},async removeRaw(e){t.removeItem(e)},async keys(e){let r=[];for(let n=0;n<t.length;n++){let s=t.key(n);s&&s.startsWith(e)&&r.push(s)}return r}}}var d="__vbStoreBackend",l=globalThis;function a(){return l[d]||(l[d]=S()),l[d]}function p(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 m(t){if(typeof t!="string"||!t)throw new TypeError("VBStore: namespace must be a non-empty string");return`vb:${t}:`}function w(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={}){l[d]=t.backend??null},async set(t,e,r){let n={data:r,timestamp:Date.now()};await a().setRaw(p(t,e),JSON.stringify(n))},async get(t,e,r){let n=await a().getRaw(p(t,e));if(n==null)return null;let s=w(n);return!s||r?.maxAge!=null&&Date.now()-s.timestamp>r.maxAge?null:s.data},async remove(t,e){await a().removeRaw(p(t,e))},async list(t){let e=m(t),r=await a().keys(e),n=[];for(let s of r){let i=await a().getRaw(s);if(i==null)continue;let o=w(i);o&&n.push({key:s.slice(e.length),data:o.data,timestamp:o.timestamp})}return n},async clear(t){let e=m(t),r=await a().keys(e);for(let n of r)await a().removeRaw(n)},async clearAll(){let t=await a().keys("vb:");for(let e of t)await a().removeRaw(e)},async setMany(t,e){for(let[r,n]of e)await c.set(t,r,n)}};if(typeof window<"u"){let t=window.VB??(window.VB={});t.store??=c}var f="banner",v=365,E=864e5;function A(t){if(t===0||t==="0"||t==="never")return;let e=t==null||t===""?v:Number.parseFloat(String(t));return Number.isFinite(e)?e>0?e*E:void 0:v*E}var k=0,b=class extends u{#e=null;static get observedAttributes(){return["position"]}get#t(){return this.getAttribute("persist")||f}get#r(){return A(this.getAttribute("expires"))}get#n(){return this.getAttribute("position")==="center"}setup(){return this.#e=this.querySelector("dialog"),this.#e?(this.#a(),this.getAttribute("trigger")&&this.listen(document,"click",this.#f),this.listen(this,"click",this.#l),this.listen(this.#e,"cancel",this.#d),this.#c(),!0):!1}attributeChangedCallback(e,r,n){r===n||!this.#e?.open||(this.#e.close(),this.#s())}#a(){let e=this.#e;if(e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby"))return;let r=e.querySelector("h1, h2, h3, h4, h5, h6");r?(r.id||(r.id=`consent-banner-title-${++k}`),e.setAttribute("aria-labelledby",r.id)):e.setAttribute("aria-label","Cookie consent")}async#c(){if(await this.#o()){this.getAttribute("trigger")?this.hidden=!0:this.remove();return}this.#i()}#s(){this.#n?this.#e.showModal():this.#e.show()}#i(){!this.isConnected||this.#e.open||this.#s()}#u(){this.#e.close(),this.getAttribute("trigger")?this.hidden=!0:this.remove()}#d=e=>{this.#n&&e.preventDefault()};#l=async e=>{if(!this.#e.open)return;let r=e.target.closest("button[value]");if(!r||!this.#e.contains(r))return;let n=r.value;if(!["accept","reject","save"].includes(n))return;let s=[...this.querySelectorAll('input[type="checkbox"]')],i={};n==="accept"?s.forEach(o=>{i[o.name]=!0}):n==="reject"?s.forEach(o=>{i[o.name]=!!o.disabled}):s.forEach(o=>{i[o.name]=o.checked}),await this.#h({preferences:i,action:n}),this.dispatchEvent(new CustomEvent("consent-banner:change",{bubbles:!0,detail:{preferences:i,action:n}})),this.#u()};#f=async e=>{let r=this.getAttribute("trigger");if(!r||!e.target.closest(r))return;e.preventDefault();let s=await this.#o();if(s?.preferences)for(let[i,o]of Object.entries(s.preferences)){let h=this.querySelector(`input[type="checkbox"][name="${CSS.escape(i)}"]`);h&&!h.disabled&&(h.checked=o)}this.hidden=!1,this.#i()};async#o(){let e=this.#r;try{return await c.get("consent",this.#t,e?{maxAge:e}:void 0)}catch{return null}}async#h(e){try{await c.set("consent",this.#t,e)}catch{}}static async reset(e=f){try{await c.remove("consent",e)}catch{}}static async getConsent(e=f,r={}){let n=r.expires;n===void 0&&typeof document<"u"&&(n=[...document.querySelectorAll("consent-banner")].find(o=>(o.getAttribute("persist")||f)===e)?.getAttribute("expires")??void 0);let s=A(n);try{return await c.get("consent",e,s?{maxAge:s}:void 0)}catch{return null}}};g("consent-banner",b);export{b as ConsentBanner};
|
|
2
2
|
//# sourceMappingURL=consent-banner.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function f(i,t,e={}){let r=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:r},n=l.get(i);if(customElements.get(i)){if(!n||n.priority>=r){n&&n.priority===r&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=r){n.priority===r&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}l.set(i,s),customElements.define(i,t)}var c=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,s){t.addEventListener(e,r,s),this.#t.push(()=>t.removeEventListener(e,r,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let s=`--${t}`;e?r.add(s):r.delete(s)}}_adoptInternals(t){this.#e||(this.#e=t)}#r(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};var d=class extends c{#t=new Map;#e="";#r=null;setup(){if(this.#i(),this.#t.size===0)return!1;this.#o(),this.#a();let t=this.#d();return this.#n(t,{persist:!1,notify:!1}),!0}#i(){for(let t of this.children){let e=t.getAttribute("data-lens-name");e&&this.#t.set(e,t)}}#o(){let t=this.getAttribute("data-lens-src");if(t)for(let e of this.#t.values()){if(e.hasAttribute("data-lens-src")||e.hasAttribute("src"))continue;e.setAttribute("data-lens-src",t);let r=e;e.hasAttribute("data-upgraded")&&typeof r._reinit=="function"&&r._reinit()}}#a(){if(this.getAttribute("data-lens-controls")==="off"||this.#r?.parentNode===this)return;let t=document.createElement("fieldset");t.setAttribute("data-content-lens-controls","");let e=document.createElement("legend");e.textContent="View",t.append(e);let r=`content-lens-${Math.random().toString(36).slice(2,8)}`;for(let[s,n]of this.#t){let a=document.createElement("label"),o=document.createElement("input");o.type="radio",o.name=r,o.value=s,o.addEventListener("change",()=>{o.checked&&this.#n(s,{persist:!0,notify:!0})});let u=document.createElement("span");u.textContent=n.getAttribute("data-lens-label")||this.#c(s),a.append(o,u),t.append(a)}this.prepend(t),this.#r=t}#c(t){return t.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}#s(){return`vb:content-lens:${this.getAttribute("data-lens-storage")||(typeof location<"u"?location.pathname:"default")}`}#d(){let t=(()=>{try{return typeof sessionStorage<"u"?sessionStorage.getItem(this.#s()):null}catch{return null}})();if(t&&this.#t.has(t))return t;let e=this.getAttribute("data-lens-default");return e&&this.#t.has(e)?e:[...this.#t.keys()][0]}#n(t,{persist:e,notify:r}){if(!this.#t.has(t))return;let s=t!==this.#e;for(let[n,a]of this.#t){let o=n===t;a.toggleAttribute("hidden",!o)}if(this.#r){let n=this.#r.querySelector(`input[value="${CSS.escape(t)}"]`);n&&(n.checked=!0)}if(this.#e=t,this.setAttribute("data-active-lens",t),e)try{sessionStorage.setItem(this.#s(),t)}catch{}r&&s&&this.dispatchEvent(new CustomEvent("content-lens:change",{detail:{lens:t},bubbles:!0}))}get activeLens(){return this.#e}setLens(t){this.#n(t,{persist:!0,notify:!0})}};f("content-lens",d);export{d as ContentLens};
|
|
2
2
|
//# sourceMappingURL=content-lens.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function E(t){return document.startViewTransition?document.startViewTransition(t):t()}var
|
|
1
|
+
function E(t){return document.startViewTransition?document.startViewTransition(t):t()}var V=window.matchMedia("(prefers-reduced-motion: reduce)");var g=new Map;function S(t,e,n={}){let o=n.priority??10,i={impl:e,bundle:n.bundle,contract:n.contract,priority:o},s=g.get(t);if(customElements.get(t)){if(!s||s.priority>=o){s&&s.priority===o&&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>=o){s.priority===o&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${s.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}g.set(t,i),customElements.define(t,e)}var h=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#t)e();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,n,o,i){e.addEventListener(n,o,i),this.#t.push(()=>e.removeEventListener(n,o,i))}_reinit(){for(let e of this.#t)e();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,n){this.#e||(this.#e=this.attachInternals());let o=this.#e.states;try{n?o.add(e):o.delete(e)}catch{let i=`--${e}`;n?o.add(i):o.delete(i)}}_adoptInternals(e){this.#e||(this.#e=e)}#n(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var T=0;function m(t,e){return t.matches("content-swap")?e:`data-${e}`}function b(t){let e=t.querySelector(':scope > [data-face="front"]'),n=t.querySelector(':scope > [data-face="back"]');if(!e||!n)return;t.style.viewTransitionName||(t.style.viewTransitionName=`content-swap-${++T}`);let o=t.matches("content-swap");o||t.setAttribute("data-swap-init","");let i=[];function s(r,d,a,u){r.addEventListener(d,a,u),i.push(()=>r.removeEventListener(d,a,u))}let p=[...t.querySelectorAll("[data-swap]")].filter(r=>r.parentElement?.closest("content-swap, [data-swap]")===t),w=p.length===0,c=t.querySelector(":scope > [data-swap-toggle]");if(w){if(!c){let r=document.createElement("button");r.type="button",r.setAttribute("data-swap-toggle",""),r.textContent="Show back",t.append(r),c=r}s(c,"click",r=>{r.stopPropagation(),f(t,r.detail===0?"keyboard":"pointer")}),s(t,"click",r=>{let a=r.target.closest?.(M);a&&a!==t&&t.contains(a)||f(t,"pointer")})}else c&&!c.hasAttribute("data-swap")&&c.remove(),c=null,p.forEach(r=>{let d=r.matches(C);s(r,"click",a=>{a.stopPropagation();let u=d&&a.detail===0;f(t,u?"keyboard":"pointer")}),!d&&(r.hasAttribute("role")||(r.setAttribute("role","button"),i.push(()=>r.removeAttribute("role"))),r.hasAttribute("tabindex")||(r.setAttribute("tabindex","0"),i.push(()=>r.removeAttribute("tabindex"))),s(r,"keydown",a=>{a.target===r&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),f(t,"keyboard"))}))});if(t.matches('[data-gesture="flick"], [data-gesture="swipe"]')&&(s(t,"swipe-left",()=>f(t,"pointer")),s(t,"swipe-right",()=>f(t,"pointer"))),!o){let r=new MutationObserver(()=>y(t,e,n));r.observe(t,{attributes:!0,attributeFilter:["data-swapped"]}),i.push(()=>r.disconnect())}return y(t,e,n),x([e,n]),()=>{for(let r of i)r();i.length=0}}var C='button, a[href], summary, input:is([type="button"], [type="submit"], [type="reset"])',M='a[href], button, input, select, textarea, label, summary, [contenteditable=""], [contenteditable="true"], [tabindex]';function x(t){let e=t.map(n=>n.style.transition);for(let n of t)n.style.transition="none";for(let n of t)getComputedStyle(n).transform;t.forEach((n,o)=>{n.style.transition=e[o]})}function y(t,e,n){let o=t.hasAttribute(m(t,"swapped"));e.inert=o,n.inert=!o,t.querySelector(":scope > [data-swap-toggle]")?.setAttribute("aria-pressed",String(o))}function k(t){return{front:t.querySelector(':scope > [data-face="front"]'),back:t.querySelector(':scope > [data-face="back"]')}}function l(t,e,n="api"){let{front:o,back:i}=k(t);if(!o||!i)return;let s=m(t,"swapped");if(e&&t.hasAttribute(s)||!e&&!t.hasAttribute(s))return;let p=document.activeElement,w=()=>{e?t.setAttribute(s,""):t.removeAttribute(s),y(t,o,i),L(t,n);let d=e?i:o,a=e?o:i,u=d.querySelector("[autofocus]");u?u.focus():n==="keyboard"&&a.contains(p)&&q(d)},c=d=>{let a=t;typeof a.setState=="function"&&a.setState("transition-running",d)};c(!0);let r=E(w);r&&r.finished&&typeof r.finished.finally=="function"?r.finished.finally(()=>c(!1)):c(!1)}function f(t,e="api"){l(t,!t.hasAttribute(m(t,"swapped")),e)}function L(t,e="internal"){t.dispatchEvent(new CustomEvent("content-swap:swap",{detail:{swapped:t.hasAttribute(m(t,"swapped")),source:e},bubbles:!0}))}function q(t){let e=t.querySelector("[data-swap], button, a, input, select, textarea");e&&e.focus()}var v=class extends h{static observedAttributes=["swapped"];#t=null;attributeChangedCallback(){if(!this.isConnected)return;let{front:e,back:n}=k(this);e&&n&&y(this,e,n)}setup(){this.#t=b(this)??null}teardown(){this.#t?.(),this.#t=null}flip(){l(this,!0)}unflip(){l(this,!1)}toggle(){f(this)}get flipped(){return this.hasAttribute("swapped")}set flipped(e){l(this,!!e)}get swapped(){return this.hasAttribute("swapped")}set swapped(e){l(this,!!e)}};S("content-swap",v);function A(){document.querySelectorAll("[data-swap]:not(content-swap):not([data-swap-init])").forEach(t=>{t.querySelector(":scope > [data-face]")&&b(t)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A):A();var $=new MutationObserver(t=>{for(let e of t)for(let n of e.addedNodes){if(n.nodeType!==Node.ELEMENT_NODE)continue;let o=n;o.hasAttribute("data-swap")&&!o.matches("content-swap")&&!o.hasAttribute("data-swap-init")&&o.querySelector(":scope > [data-face]")&&b(o),o.querySelectorAll("[data-swap]:not(content-swap):not([data-swap-init])").forEach(i=>{i.querySelector(":scope > [data-face]")&&b(i)})}});document.body?$.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{$.observe(document.body,{childList:!0,subtree:!0})});export{v as ContentSwap};
|
|
2
2
|
//# sourceMappingURL=content-swap.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var h=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),$={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",option:"\u2325",shift:"\u21E7",ctrl:"\u2303",control:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Ctrl",control:"Ctrl"}},T={mac:{meta:"Command",cmd:"Command",alt:"Option",option:"Option",shift:"Shift",ctrl:"Control",control:"Control"},other:{meta:"Control",cmd:"Control",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Control",control:"Control"}},F={escape:{label:"Esc",spoken:"Escape"},esc:{label:"Esc",spoken:"Escape"},enter:{label:"Enter",spoken:"Enter"},return:{label:"Enter",spoken:"Enter"},tab:{label:"Tab",spoken:"Tab"},space:{label:"Space",spoken:"Space"},backspace:{label:"Backspace",spoken:"Backspace"},delete:{label:"Del",spoken:"Delete"},del:{label:"Del",spoken:"Delete"},insert:{label:"Ins",spoken:"Insert"},home:{label:"Home",spoken:"Home"},end:{label:"End",spoken:"End"},pageup:{label:"PgUp",spoken:"Page up"},pagedown:{label:"PgDn",spoken:"Page down"},arrowup:{label:"\u2191",spoken:"Up arrow"},up:{label:"\u2191",spoken:"Up arrow"},arrowdown:{label:"\u2193",spoken:"Down arrow"},down:{label:"\u2193",spoken:"Down arrow"},arrowleft:{label:"\u2190",spoken:"Left arrow"},left:{label:"\u2190",spoken:"Left arrow"},arrowright:{label:"\u2192",spoken:"Right arrow"},right:{label:"\u2192",spoken:"Right arrow"},"+":{label:"+",spoken:"Plus"},plus:{label:"+",spoken:"Plus"}};function M(o){return[...String(o??"").trim().toLowerCase().matchAll(/([^+]+|\+)(?:\+|$)/g)].map(e=>e[1].trim()).filter(Boolean).map(e=>e==="plus"?"+":e)}function j(o,t=h){let e=t?$.mac:$.other;if(o in e)return{label:e[o],spoken:(t?T.mac:T.other)[o],modifier:!0};let s=F[o];if(s)return{...s,modifier:!1};let n=o.toUpperCase();return{label:n,spoken:n,modifier:!1}}function D(o){return M(o).map(t=>j(t).label).join(h?"":"+")}var Y={esc:"escape",return:"enter",del:"delete",ins:"insert",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",space:" ",spacebar:" ",plus:"+",pgup:"pageup",pgdn:"pagedown"};function W(o){let t=String(o??"").toLowerCase();return Y[t]??t}function d(o){let t=M(o);return{key:W(t.pop()??""),meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option")}}function q(o){return o.length===1&&!/[a-z0-9 ]/.test(o)}function H(o,t){let s=(o.key==="Spacebar"?" ":String(o.key??"").toLowerCase())===t.key;if(!s&&(o.altKey||o.shiftKey)&&/^[a-z0-9]$/.test(t.key)){let r=/\d/.test(t.key)?`Digit${t.key}`:`Key${t.key.toUpperCase()}`;s=o.code===r}if(!s)return!1;let n,i;return h?(n=t.meta,i=t.ctrl):(n=!1,i=t.meta||t.ctrl),!(n!==o.metaKey||i!==o.ctrlKey||!q(t.key)&&t.shift!==o.shiftKey||t.alt!==o.altKey)}function L(o){let t=typeof o=="string"?d(o):o;return!t.meta&&!t.ctrl&&!t.alt&&t.key.length===1}function N(o,t){let e=d(o),s=d(t),n=h?e.ctrl:e.ctrl||e.meta,i=h?s.ctrl:s.ctrl||s.meta,r=h&&e.meta,l=h&&s.meta,a=!q(e.key);return e.key===s.key&&n===i&&r===l&&e.alt===s.alt&&(!a||e.shift===s.shift)}var X={" ":"Space","+":"Plus",escape:"Escape",enter:"Enter",tab:"Tab",backspace:"Backspace",delete:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight"};function B(o,t=h){let e=d(o),s=[];e.alt&&s.push("Alt"),(e.ctrl||e.meta&&!t)&&s.push("Control"),e.meta&&t&&s.push("Meta"),e.shift&&s.push("Shift");let n=X[e.key];return n||(n=/^f\d{1,2}$/.test(e.key)||e.key.length===1?e.key.toUpperCase():e.key[0].toUpperCase()+e.key.slice(1)),[...s,n].join("+")}var w="data-char-shortcuts";var z="vb:settings:extensions";function k(){return typeof document>"u"?!0:document.documentElement.getAttribute(w)!=="off"}function G(){try{let o=globalThis.localStorage?.getItem(z);if(!o)return null;let t=JSON.parse(o)?.data?.charShortcuts;return typeof t=="boolean"?t:null}catch{return null}}var J=!0;if(typeof document<"u"){let o=G();o===null&&(J=k()),o===!1?document.documentElement.setAttribute(w,"off"):o===!0&&document.documentElement.removeAttribute(w)}var Q=new Set(["INPUT","TEXTAREA","SELECT"]),f=[],I=!1;function Z(o){let t=o;return!t||!t.tagName?!1:Q.has(t.tagName)||t.isContentEditable}function tt(o){if(o.repeat||o.isComposing||o.defaultPrevented)return;let t=Z(o.target),e=!k(),s=document.activeElement;for(let n of f)if(!(t&&!n.global)&&!(n.scope&&!(n.scope.isConnected&&n.scope.contains(s)))&&!(e&&n.character&&!n.scope)&&!(n.enabled&&!n.enabled())&&H(o,n.descriptor)){o.preventDefault(),n.callback(o);return}}function et(){I||(document.addEventListener("keydown",tt),I=!0)}function O(o,t,e={}){et();let s=d(o),n={combo:o,descriptor:s,callback:t,global:e.global===!0,scope:e.scope??null,enabled:typeof e.enabled=="function"?e.enabled:null,character:L(s)},i=f.find(r=>!r.scope&&!n.scope&&N(r.combo,o));return i&&console.warn(`[hotkey-bind] Shortcut "${o}" is already bound as "${i.combo}". Last-bound wins.`),f.unshift(n),function(){let l=f.indexOf(n);l!==-1&&f.splice(l,1)}}var gt=window.matchMedia("(prefers-reduced-motion: reduce)");var K=new Map;function m(o,t,e={}){let s=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:s},i=K.get(o);if(customElements.get(o)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.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 "${e.bundle}" (first wins at equal priority).`);return}K.set(o,n),customElements.define(o,t)}var p=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,n){t.addEventListener(e,s,n),this.#t.push(()=>t.removeEventListener(e,s,n))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let n=`--${t}`;e?s.add(n):s.delete(n)}}_adoptInternals(t){this.#e||(this.#e=t)}#o(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#o()?.validity}get validationMessage(){return this.#o()?.validationMessage??""}get willValidate(){return this.#o()?.willValidate??!1}get form(){return this.#o()?.form??null}checkValidity(){return this.#o()?.checkValidity()??!0}reportValidity(){return this.#o()?.reportValidity()??!0}};var b=CSS.supports("anchor-name","--x"),ot=CSS.supports("position-area","bottom"),st=(()=>{let o=document.createElement("span");return o.setAttribute("popover","hint"),o.popover==="hint"})(),nt=["auto","manual","hint"];function it(o){let t=nt.includes(o||"")?o:"auto";return t==="hint"&&!st?"auto":t}var rt=["top","bottom","left","right","inset-inline-start","inset-inline-end"],at=["position","top","left","right","bottom","margin"],_=8,lt=0,ct=0;function R(o){return!o||o==="none"?[]:o.split(",").map(t=>t.trim()).filter(Boolean)}var E=class extends p{static get observedAttributes(){return["data-mode","data-anchor","data-position"]}#t=null;#e=null;#o=`--pop-over-anchor-${++ct}`;#n=!1;#i=!1;#s=!1;setup(){if(this.id||(this.id=`pop-over-${++lt}`),(!this.hasAttribute("popover")||this.#n)&&this.#r(),this.#u(),this.#h(),this.listen(this,"beforetoggle",t=>{let e=t.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${e}`,{detail:{state:t.newState},bubbles:!0,composed:!0})),!b&&t.newState==="open"&&this.#t&&queueMicrotask(()=>{this.matches(":popover-open")&&this.#a()})}),!b){let t=()=>{this.matches(":popover-open")&&this.#t&&this.#a()};this.listen(window,"resize",t),this.listen(window,"scroll",t,{capture:!0,passive:!0})}}teardown(){this.#d(),this.#i&&(rt.forEach(t=>this.style.removeProperty(t)),this.#i=!1),this.#s&&(at.forEach(t=>this.style.removeProperty(t)),this.#s=!1),this.#t=null}attributeChangedCallback(t,e,s){if(e!==s){if(!this.hasAttribute("data-upgraded")){t==="data-mode"&&this.hasAttribute("popover")&&!this.isConnected&&(this.#n=!0);return}if(t==="data-mode"){this.#r();return}this._reinit()}}#r(){let t=it(this.dataset.mode);this.getAttribute("popover")!==t&&this.setAttribute("popover",t),this.#n=!0}show(){this.matches(":popover-open")||(this.showPopover(),!b&&this.#t&&this.matches(":popover-open")&&this.#a())}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#u(){let t=this.dataset.anchor;if(t){let e=document.getElementById(t);if(!e)try{e=document.querySelector(t)}catch{e=null}this.#t=e}else this.#t=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#h(){if(!this.#t||!b)return;let t=this.#t,e=t.style.getPropertyValue("anchor-name"),s=R(e||getComputedStyle(t).getPropertyValue("anchor-name"));s.includes(this.#o)||s.push(this.#o),t.style.setProperty("anchor-name",s.join(", ")),this.#e=this.#o,this.style.setProperty("position-anchor",this.#o),this.setAttribute("data-anchor-name",this.#o),ot||this.#p(this.dataset.position||"bottom")}#d(){if(this.#t&&this.#e){let t=R(this.#t.style.getPropertyValue("anchor-name")).filter(e=>e!==this.#e);t.length?this.#t.style.setProperty("anchor-name",t.join(", ")):this.#t.style.removeProperty("anchor-name")}this.#e=null,this.style.getPropertyValue("position-anchor")&&this.style.removeProperty("position-anchor"),this.hasAttribute("data-anchor-name")&&this.removeAttribute("data-anchor-name")}#p(t){let e="var(--_pop-over-offset, var(--size-xs))",s=t.endsWith("-end")?{"inset-inline-end":"anchor(end)"}:{"inset-inline-start":"anchor(start)"},n={top:{bottom:`calc(anchor(top) + ${e})`,...s},bottom:{top:`calc(anchor(bottom) + ${e})`,...s},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},i=t.split("-")[0],r=n[i]||n.bottom;Object.entries(r).forEach(([l,a])=>this.style.setProperty(l,a)),this.#i=!0}#a(){if(!this.#t)return;let t=this.#t.getBoundingClientRect(),e=this.dataset.position||"bottom",s=this.#l(),n=document.documentElement.clientWidth,i=document.documentElement.clientHeight;this.style.position="fixed",this.style.margin="0",this.style.right="auto",this.style.bottom="auto",this.#s=!0;let r=this.offsetWidth,l=this.offsetHeight,a=e.split("-")[0];["top","bottom","left","right"].includes(a)||(a="bottom");let y={top:t.top-s,bottom:i-t.bottom-s,left:t.left-s,right:n-t.right-s},S={top:"bottom",bottom:"top",left:"right",right:"left"},U=a==="top"||a==="bottom"?l:r;y[a]<U&&y[S[a]]>y[a]&&(a=S[a]);let c,u;switch(a){case"top":c=t.top-l-s,u=t.left;break;case"left":c=t.top,u=t.left-r-s;break;case"right":c=t.top,u=t.right+s;break;default:c=t.bottom+s,u=t.left;break}if(a==="top"||a==="bottom"){let A=getComputedStyle(this).direction==="rtl";u=e.endsWith("-end")!==A?t.right-r:t.left}else e.endsWith("-end")&&(c=t.bottom-l);let x=(A,P,V)=>Math.max(_,Math.min(A,V-P-_));u=x(u,r,n),c=x(c,l,i),this.style.top=`${Math.round(c)}px`,this.style.left=`${Math.round(u)}px`}#l(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset||""]??t.xs}};m("pop-over",E);var v=0,ut='a[href], button, input, select, textarea, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])';function g(o){return o.hasAttribute("data-disabled")||o.getAttribute("aria-disabled")==="true"||!!o.disabled}function ht(o){return o.pointerType===""||o.pointerId===-1||o.button===-1||o.clientX===0&&o.clientY===0&&o.buttons===0}var C=class extends p{#t;#e;#o;#n=[];#i=-1;#s=!1;#r=[];setup(){let t=this.querySelector(":scope > [data-trigger]"),e=this.querySelector('menu, ul[role="menu"]');if(!t||!e)return!1;this.#t=t,this.#e=e;let s=this.querySelector(":scope > pop-over[data-context-menu-host]");s?this.#o=s:(this.#o=document.createElement("pop-over"),this.#o.setAttribute("data-context-menu-host",""),this.#o.id=`ctx-menu-${++v}`,this.#o.dataset.mode="auto",this.#o.appendChild(this.#e),this.appendChild(this.#o)),this.#e.parentElement!==this.#o&&this.#o.appendChild(this.#e),this.#e.setAttribute("role","menu"),this.#e.id||(this.#e.id=`ctx-menu-list-${++v}`),this.#t.setAttribute("aria-haspopup","menu"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-controls",this.#e.id),this.#t.matches(ut)||this.#t.setAttribute("tabindex","0"),this.#e.querySelectorAll(':scope > li:empty:not([data-group]), :scope > [role="separator"], :scope > hr').forEach(i=>{i.setAttribute("role","separator")}),this.#u();let n=Array.from(this.#e.querySelectorAll('button, a, [role="menuitem"]'));return n.forEach(i=>{i.setAttribute("role","menuitem"),i.setAttribute("tabindex","-1")}),this.#n=n.filter(i=>!i.disabled),this.#e.querySelectorAll("li").forEach(i=>{i.querySelector(':scope > :is(button, a, [role="menuitem"])')&&i.setAttribute("role","none")}),this.#n.forEach(i=>{i.hasAttribute("data-disabled")&&i.setAttribute("aria-disabled","true"),this.listen(i,"click",this.#y);let r=i.getAttribute("data-shortcut");if(r){if(!i.querySelector(":scope > .ctx-kbd")){let a=document.createElement("kbd");a.className="ctx-kbd",a.setAttribute("aria-hidden","true"),a.textContent=D(r),i.appendChild(a)}i.setAttribute("aria-keyshortcuts",B(r));let l=O(r,()=>{g(i)||i.click()});this.#r.push(l)}}),this.listen(this.#t,"contextmenu",this.#d),this.listen(this.#t,"keydown",this.#p),this.listen(this.#e,"keydown",this.#b),this.listen(this.#e,"click",this.#g,{capture:!0}),this.listen(window,"scroll",this.#w,{capture:!0}),this.listen(this.#o,"pop-over:hide",this.#A),!0}teardown(){this.#r.forEach(t=>t()),this.#r=[],this.#s&&(this.#s=!1,this.removeAttribute("data-open"),this.#o?.hide?.()),this.#i=-1,this.#n=[],this.#e?.querySelectorAll(".ctx-kbd").forEach(t=>t.remove()),this.#h()}#u(){let t=this.#e;for(let e of Array.from(t.querySelectorAll(":scope > li[data-group]"))){e.id||(e.id=`ctx-group-${++v}`),e.classList.add("ctx-group-label"),e.setAttribute("aria-hidden","true");let s=document.createElement("li");s.setAttribute("role","group"),s.setAttribute("aria-labelledby",e.id),s.setAttribute("data-ctx-group","");let n=document.createElement("ul");n.setAttribute("role","none"),s.appendChild(n),t.insertBefore(s,e),n.appendChild(e);let i=s.nextElementSibling;for(;i&&!i.hasAttribute("data-group")&&i.getAttribute("role")!=="separator";){let r=i;i=i.nextElementSibling,n.appendChild(r)}}}#h(){let t=this.#e;if(t)for(let e of Array.from(t.querySelectorAll(":scope > li[data-ctx-group]"))){let s=e.querySelector(":scope > ul");if(s)for(let n of Array.from(s.children))t.insertBefore(n,e);e.remove()}}get items(){if(!this.#e)return[];let t=[],e=this.#e.querySelectorAll(":scope > li:not([data-ctx-group]), :scope > li[data-ctx-group] > ul > li");for(let s of e){if(s.hasAttribute("data-group")){t.push({group:s.textContent.trim()});continue}if(s.matches(':empty, [role="separator"]')||s.querySelector("hr")){t.push({separator:!0});continue}let n=s.querySelector('button, a, [role="menuitem"]');if(!n)continue;let i=Array.from(n.childNodes).filter(r=>!(r instanceof Element&&r.classList.contains("ctx-kbd"))).map(r=>r.textContent).join("");t.push({label:i.trim().replace(/\s+/g," "),value:n.getAttribute("data-value")||void 0,href:n.tagName==="A"?n.getAttribute("href"):void 0,shortcut:n.getAttribute("data-shortcut")||void 0,disabled:n.disabled||n.hasAttribute("data-disabled")||void 0})}return t}set items(t){let e=Array.isArray(t)?t:[],s=this.querySelector('menu, ul[role="menu"]');for(s||(s=document.createElement("menu"),this.appendChild(s));s.firstChild;)s.firstChild.remove();for(let n of e){let i=document.createElement("li");if(n.separator)i.setAttribute("role","separator");else if(n.group!=null)i.setAttribute("data-group",""),i.textContent=n.group;else{let r=n.href?document.createElement("a"):document.createElement("button");n.href&&r.setAttribute("href",n.href),n.value&&r.setAttribute("data-value",n.value),n.shortcut&&r.setAttribute("data-shortcut",n.shortcut),n.disabled&&r.setAttribute("data-disabled",""),r.tagName==="BUTTON"&&r.setAttribute("type","button"),r.textContent=n.label||"",i.appendChild(r)}s.appendChild(i)}this._reinit(),this.dispatchEvent(new CustomEvent("context-menu:items-changed",{detail:{items:e,source:"property"},bubbles:!0}))}#d=t=>{if(t.preventDefault(),ht(t)){this.#s||this.#a();return}t.buttons!==0?this.listen(window,"pointerup",()=>{setTimeout(()=>this.#l(t.clientX,t.clientY),0)},{once:!0,capture:!0}):this.#l(t.clientX,t.clientY)};#p=t=>{t.target===this.#t&&(t.key==="ContextMenu"||t.key==="F10"&&t.shiftKey)&&(t.preventDefault(),this.#s||this.#a())};#a(){let t=this.#t.getBoundingClientRect();this.#l(t.left,t.bottom)}#l(t,e){this.#s=!0,this.setAttribute("data-open",""),this.#t?.setAttribute("aria-expanded","true"),this.#o.style.top=`${e}px`,this.#o.style.left=`${t}px`,this.#o.show(),requestAnimationFrame(()=>{let s=this.#o.getBoundingClientRect(),n=t+s.width>window.innerWidth?t-s.width:t,i=e+s.height>window.innerHeight?e-s.height:e;this.#o.style.top=`${Math.max(0,i)}px`,this.#o.style.left=`${Math.max(0,n)}px`}),this.#i=-1,this.#c(0),this.dispatchEvent(new CustomEvent("context-menu:open",{bubbles:!0}))}close(){if(!this.#s)return;let t=this.#f();this.#s=!1,this.removeAttribute("data-open"),this.#t?.setAttribute("aria-expanded","false"),this.#i=-1,this.#o?.hide(),t&&this.#m(),this.dispatchEvent(new CustomEvent("context-menu:close",{bubbles:!0}))}#f(){let t=document.activeElement;return!t||t===document.body||!!this.#o?.contains(t)}#m(){this.#t?.isConnected&&this.#t.focus({preventScroll:!0})}#b=t=>{switch(t.key){case"ArrowDown":case"Down":t.preventDefault(),this.#c(this.#i+1);break;case"ArrowUp":case"Up":t.preventDefault(),this.#c(this.#i-1);break;case"Home":t.preventDefault(),this.#c(0);break;case"End":t.preventDefault(),this.#c(this.#n.length-1);break;case"Enter":case" ":{t.preventDefault();let e=this.#n[this.#i];e&&!g(e)&&e.click();break}case"Tab":this.close();break}};#g=t=>{let e=t.target.closest?.('button, a, [role="menuitem"]');e&&this.#e.contains(e)&&g(e)&&(t.preventDefault(),t.stopPropagation())};#y=t=>{let e=t.currentTarget;g(e)||(this.close(),this.dispatchEvent(new CustomEvent("context-menu:select",{bubbles:!0,detail:{item:e,value:e.getAttribute("data-value")||void 0}})))};#A=()=>{this.#s&&(this.#s=!1,this.removeAttribute("data-open"),this.#t?.setAttribute("aria-expanded","false"),this.#i=-1,this.#f()&&this.#m(),this.dispatchEvent(new CustomEvent("context-menu:close",{bubbles:!0})))};#w=()=>{this.#s&&this.close()};#c(t){this.#n.length!==0&&(t<0&&(t=this.#n.length-1),t>=this.#n.length&&(t=0),this.#i=t,this.#n[t].focus())}get isOpen(){return this.#s}};m("context-menu",C);export{C as ContextMenuWc};
|
|
1
|
+
var h=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),T={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",option:"\u2325",shift:"\u21E7",ctrl:"\u2303",control:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Ctrl",control:"Ctrl"}},P={mac:{meta:"Command",cmd:"Command",alt:"Option",option:"Option",shift:"Shift",ctrl:"Control",control:"Control"},other:{meta:"Control",cmd:"Control",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Control",control:"Control"}},j={escape:{label:"Esc",spoken:"Escape"},esc:{label:"Esc",spoken:"Escape"},enter:{label:"Enter",spoken:"Enter"},return:{label:"Enter",spoken:"Enter"},tab:{label:"Tab",spoken:"Tab"},space:{label:"Space",spoken:"Space"},backspace:{label:"Backspace",spoken:"Backspace"},delete:{label:"Del",spoken:"Delete"},del:{label:"Del",spoken:"Delete"},insert:{label:"Ins",spoken:"Insert"},home:{label:"Home",spoken:"Home"},end:{label:"End",spoken:"End"},pageup:{label:"PgUp",spoken:"Page up"},pagedown:{label:"PgDn",spoken:"Page down"},arrowup:{label:"\u2191",spoken:"Up arrow"},up:{label:"\u2191",spoken:"Up arrow"},arrowdown:{label:"\u2193",spoken:"Down arrow"},down:{label:"\u2193",spoken:"Down arrow"},arrowleft:{label:"\u2190",spoken:"Left arrow"},left:{label:"\u2190",spoken:"Left arrow"},arrowright:{label:"\u2192",spoken:"Right arrow"},right:{label:"\u2192",spoken:"Right arrow"},"+":{label:"+",spoken:"Plus"},plus:{label:"+",spoken:"Plus"}};function M(n){return[...String(n??"").trim().toLowerCase().matchAll(/([^+]+|\+)(?:\+|$)/g)].map(e=>e[1].trim()).filter(Boolean).map(e=>e==="plus"?"+":e)}function Y(n,t=h){let e=t?T.mac:T.other;if(n in e)return{label:e[n],spoken:(t?P.mac:P.other)[n],modifier:!0};let o=j[n];if(o)return{...o,modifier:!1};let r=n.toUpperCase();return{label:r,spoken:r,modifier:!1}}function H(n){return M(n).map(t=>Y(t).label).join(h?"":"+")}var W={esc:"escape",return:"enter",del:"delete",ins:"insert",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",space:" ",spacebar:" ",plus:"+",pgup:"pageup",pgdn:"pagedown"};function X(n){let t=String(n??"").toLowerCase();return W[t]??t}function d(n){let t=M(n);return{key:X(t.pop()??""),meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option")}}function L(n){return n.length===1&&!/[a-z0-9 ]/.test(n)}function D(n,t){let o=(n.key==="Spacebar"?" ":String(n.key??"").toLowerCase())===t.key;if(!o&&(n.altKey||n.shiftKey)&&/^[a-z0-9]$/.test(t.key)){let i=/\d/.test(t.key)?`Digit${t.key}`:`Key${t.key.toUpperCase()}`;o=n.code===i}if(!o)return!1;let r,s;return h?(r=t.meta,s=t.ctrl):(r=!1,s=t.meta||t.ctrl),!(r!==n.metaKey||s!==n.ctrlKey||!L(t.key)&&t.shift!==n.shiftKey||t.alt!==n.altKey)}function q(n){let t=typeof n=="string"?d(n):n;return!t.meta&&!t.ctrl&&!t.alt&&t.key.length===1}function B(n,t){let e=d(n),o=d(t),r=h?e.ctrl:e.ctrl||e.meta,s=h?o.ctrl:o.ctrl||o.meta,i=h&&e.meta,c=h&&o.meta,a=!L(e.key);return e.key===o.key&&r===s&&i===c&&e.alt===o.alt&&(!a||e.shift===o.shift)}var z={" ":"Space","+":"Plus",escape:"Escape",enter:"Enter",tab:"Tab",backspace:"Backspace",delete:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight"};function _(n,t=h){let e=d(n),o=[];e.alt&&o.push("Alt"),(e.ctrl||e.meta&&!t)&&o.push("Control"),e.meta&&t&&o.push("Meta"),e.shift&&o.push("Shift");let r=z[e.key];return r||(r=/^f\d{1,2}$/.test(e.key)||e.key.length===1?e.key.toUpperCase():e.key[0].toUpperCase()+e.key.slice(1)),[...o,r].join("+")}var w="data-char-shortcuts";var G="vb:settings:extensions";function E(){return typeof document>"u"?!0:document.documentElement.getAttribute(w)!=="off"}function J(){try{let n=globalThis.localStorage?.getItem(G);if(!n)return null;let t=JSON.parse(n)?.data?.charShortcuts;return typeof t=="boolean"?t:null}catch{return null}}var Q=!0;if(typeof document<"u"){let n=J();n===null&&(Q=E()),n===!1?document.documentElement.setAttribute(w,"off"):n===!0&&document.documentElement.removeAttribute(w)}var Z=new Set(["INPUT","TEXTAREA","SELECT"]),f=[],I=!1;function N(n){let t=n;return!t||!t.tagName?!1:Z.has(t.tagName)||t.isContentEditable}function tt(n){if(n.repeat||n.isComposing||n.defaultPrevented)return;let t=N(n.target),e=!E(),o=document.activeElement;for(let r of f)if(!(t&&!r.global)&&!(r.scope&&!(r.scope.isConnected&&r.scope.contains(o)))&&!(e&&r.character&&!r.scope)&&!(r.enabled&&!r.enabled())&&D(n,r.descriptor)){n.preventDefault(),r.callback(n);return}}function et(){I||(document.addEventListener("keydown",tt),I=!0)}function O(n,t,e={}){et();let o=d(n),r={combo:n,descriptor:o,callback:t,global:e.global===!0,scope:e.scope??null,enabled:typeof e.enabled=="function"?e.enabled:null,character:q(o)},s=f.find(i=>!i.scope&&!r.scope&&B(i.combo,n));return s&&console.warn(`[hotkey-bind] Shortcut "${n}" is already bound as "${s.combo}". Last-bound wins.`),f.unshift(r),function(){let c=f.indexOf(r);c!==-1&&f.splice(c,1)}}var vt=window.matchMedia("(prefers-reduced-motion: reduce)");var K=new Map;function m(n,t,e={}){let o=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:o},s=K.get(n);if(customElements.get(n)){if(!s||s.priority>=o){s&&s.priority===o&&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>=o){s.priority===o&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}K.set(n,r),customElements.define(n,t)}var p=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,o,r){t.addEventListener(e,o,r),this.#t.push(()=>t.removeEventListener(e,o,r))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let o=this.#e.states;try{e?o.add(t):o.delete(t)}catch{let r=`--${t}`;e?o.add(r):o.delete(r)}}_adoptInternals(t){this.#e||(this.#e=t)}#o(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#o()?.validity}get validationMessage(){return this.#o()?.validationMessage??""}get willValidate(){return this.#o()?.willValidate??!1}get form(){return this.#o()?.form??null}checkValidity(){return this.#o()?.checkValidity()??!0}reportValidity(){return this.#o()?.reportValidity()??!0}};var b=CSS.supports("anchor-name","--x"),ot=CSS.supports("position-area","bottom"),nt=(()=>{let n=document.createElement("span");return n.setAttribute("popover","hint"),n.popover==="hint"})(),rt=["auto","manual","hint"];function st(n){let t=rt.includes(n||"")?n:"auto";return t==="hint"&&!nt?"auto":t}var it=["top","bottom","left","right","inset-inline-start","inset-inline-end"],at=["position","top","left","right","bottom","margin"],R=8,ct=0,lt=0;function V(n){return!n||n==="none"?[]:n.split(",").map(t=>t.trim()).filter(Boolean)}var v=class extends p{static get observedAttributes(){return["data-mode","data-anchor","data-position"]}#t=null;#e=null;#o=`--pop-over-anchor-${++lt}`;#r=!1;#s=!1;#n=!1;setup(){if(this.id||(this.id=`pop-over-${++ct}`),(!this.hasAttribute("popover")||this.#r)&&this.#l(),this.#i(),this.#u(),this.listen(this,"beforetoggle",t=>{let e=t.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${e}`,{detail:{state:t.newState},bubbles:!0,composed:!0})),!b&&t.newState==="open"&&this.#t&&queueMicrotask(()=>{this.matches(":popover-open")&&this.#h()})}),!b){let t=()=>{this.matches(":popover-open")&&this.#t&&this.#h()};this.listen(window,"resize",t),this.listen(window,"scroll",t,{capture:!0,passive:!0})}}teardown(){this.#a(),this.#s&&(it.forEach(t=>this.style.removeProperty(t)),this.#s=!1),this.#n&&(at.forEach(t=>this.style.removeProperty(t)),this.#n=!1),this.#t=null}attributeChangedCallback(t,e,o){if(e!==o){if(!this.hasAttribute("data-upgraded")){t==="data-mode"&&this.hasAttribute("popover")&&!this.isConnected&&(this.#r=!0);return}if(t==="data-mode"){this.#l();return}this._reinit()}}#l(){let t=st(this.dataset.mode);this.getAttribute("popover")!==t&&this.setAttribute("popover",t),this.#r=!0}show(){this.matches(":popover-open")||(this.showPopover(),!b&&this.#t&&this.matches(":popover-open")&&this.#h())}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#i(){let t=this.dataset.anchor;if(t){let e=document.getElementById(t);if(!e)try{e=document.querySelector(t)}catch{e=null}this.#t=e}else this.#t=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#u(){if(!this.#t||!b)return;let t=this.#t,e=t.style.getPropertyValue("anchor-name"),o=V(e||getComputedStyle(t).getPropertyValue("anchor-name"));o.includes(this.#o)||o.push(this.#o),t.style.setProperty("anchor-name",o.join(", ")),this.#e=this.#o,this.style.setProperty("position-anchor",this.#o),this.setAttribute("data-anchor-name",this.#o),ot||this.#c(this.dataset.position||"bottom")}#a(){if(this.#t&&this.#e){let t=V(this.#t.style.getPropertyValue("anchor-name")).filter(e=>e!==this.#e);t.length?this.#t.style.setProperty("anchor-name",t.join(", ")):this.#t.style.removeProperty("anchor-name")}this.#e=null,this.style.getPropertyValue("position-anchor")&&this.style.removeProperty("position-anchor"),this.hasAttribute("data-anchor-name")&&this.removeAttribute("data-anchor-name")}#c(t){let e="var(--_pop-over-offset, var(--size-xs))",o=t.endsWith("-end")?{"inset-inline-end":"anchor(end)"}:{"inset-inline-start":"anchor(start)"},r={top:{bottom:`calc(anchor(top) + ${e})`,...o},bottom:{top:`calc(anchor(bottom) + ${e})`,...o},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},s=t.split("-")[0],i=r[s]||r.bottom;Object.entries(i).forEach(([c,a])=>this.style.setProperty(c,a)),this.#s=!0}#h(){if(!this.#t)return;let t=this.#t.getBoundingClientRect(),e=this.dataset.position||"bottom",o=this.#p(),r=document.documentElement.clientWidth,s=document.documentElement.clientHeight;this.style.position="fixed",this.style.margin="0",this.style.right="auto",this.style.bottom="auto",this.#n=!0;let i=this.offsetWidth,c=this.offsetHeight,a=e.split("-")[0];["top","bottom","left","right"].includes(a)||(a="bottom");let g={top:t.top-o,bottom:s-t.bottom-o,left:t.left-o,right:r-t.right-o},C={top:"bottom",bottom:"top",left:"right",right:"left"},F=a==="top"||a==="bottom"?c:i;g[a]<F&&g[C[a]]>g[a]&&(a=C[a]);let l,u;switch(a){case"top":l=t.top-c-o,u=t.left;break;case"left":l=t.top,u=t.left-i-o;break;case"right":l=t.top,u=t.right+o;break;default:l=t.bottom+o,u=t.left;break}if(a==="top"||a==="bottom"){let A=getComputedStyle(this).direction==="rtl";u=e.endsWith("-end")!==A?t.right-i:t.left}else e.endsWith("-end")&&(l=t.bottom-c);let x=(A,$,U)=>Math.max(R,Math.min(A,U-$-R));u=x(u,i,r),l=x(l,c,s),this.style.top=`${Math.round(l)}px`,this.style.left=`${Math.round(u)}px`}#p(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset||""]??t.xs}};m("pop-over",v);var k=0,ut='a[href], button, input, select, textarea, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])',ht="a[href], button, input, select, textarea, summary",dt=new Set(["button","link","checkbox","radio","switch","tab","option","treeitem","gridcell","menuitem","menuitemcheckbox","menuitemradio","combobox","textbox","searchbox","slider","spinbutton"]);function y(n){return n.hasAttribute("data-disabled")||n.getAttribute("aria-disabled")==="true"||!!n.disabled}function pt(n){return n.pointerType===""||n.pointerId===-1||n.button===-1||n.clientX===0&&n.clientY===0&&n.buttons===0}var S=class extends p{#t;#e;#o;#r=[];#s=-1;#n=!1;#l=[];#i=!1;#u=[];#a=null;setup(){let t=this.querySelector(":scope > [data-trigger]"),e=this.querySelector('menu, ul[role="menu"]');if(!t||!e)return!1;this.#t=t,this.#e=e;let o=this.querySelector(":scope > pop-over[data-context-menu-host]");o?this.#o=o:(this.#o=document.createElement("pop-over"),this.#o.setAttribute("data-context-menu-host",""),this.#o.id=`ctx-menu-${++k}`,this.#o.dataset.mode="auto",this.#o.appendChild(this.#e),this.appendChild(this.#o)),this.#e.parentElement!==this.#o&&this.#o.appendChild(this.#e),this.#e.setAttribute("role","menu"),this.#e.id||(this.#e.id=`ctx-menu-list-${++k}`),this.#t.matches(ut)||this.#c("tabindex","0"),this.#i=this.#t.matches(ht)||this.#t.hasAttribute("tabindex")&&dt.has((this.#t.getAttribute("role")||"").trim().toLowerCase()),this.#i?(this.#c("aria-haspopup","menu"),this.#c("aria-expanded","false"),this.#c("aria-controls",this.#e.id)):!this.#t.hasAttribute("aria-description")&&!this.#t.hasAttribute("aria-describedby")&&this.#c("aria-description",this.getAttribute("data-label-available")||"Context menu available"),this.#e.querySelectorAll(':scope > li:empty:not([data-group]), :scope > [role="separator"], :scope > hr').forEach(s=>{s.setAttribute("role","separator")}),this.#h();let r=Array.from(this.#e.querySelectorAll('button, a, [role="menuitem"]'));return r.forEach(s=>{s.setAttribute("role","menuitem"),s.setAttribute("tabindex","-1")}),this.#r=r.filter(s=>!s.disabled),this.#e.querySelectorAll("li").forEach(s=>{s.querySelector(':scope > :is(button, a, [role="menuitem"])')&&s.setAttribute("role","none")}),this.#r.forEach(s=>{s.hasAttribute("data-disabled")&&s.setAttribute("aria-disabled","true"),this.listen(s,"click",this.#v);let i=s.getAttribute("data-shortcut");if(i){if(!s.querySelector(":scope > .ctx-kbd")){let a=document.createElement("kbd");a.className="ctx-kbd",a.setAttribute("aria-hidden","true"),a.textContent=H(i),s.appendChild(a)}s.setAttribute("aria-keyshortcuts",_(i));let c=O(i,()=>{y(s)||s.click()});this.#l.push(c)}}),this.listen(this.#t,"contextmenu",this.#g),this.listen(this.#t,"keydown",this.#A),this.listen(this.#e,"keydown",this.#w),this.listen(this.#e,"click",this.#E,{capture:!0}),this.listen(window,"scroll",this.#S,{capture:!0}),this.listen(this.#o,"pop-over:hide",this.#k),!0}teardown(){this.#l.forEach(t=>t()),this.#l=[];for(let t of this.#u)this.#t?.removeAttribute(t);this.#u=[],this.#a=null,this.#n&&(this.#n=!1,this.removeAttribute("data-open"),this.#o?.hide?.()),this.#s=-1,this.#r=[],this.#e?.querySelectorAll(".ctx-kbd").forEach(t=>t.remove()),this.#p()}#c(t,e){this.#t.setAttribute(t,e),this.#u.push(t)}#h(){let t=this.#e;for(let e of Array.from(t.querySelectorAll(":scope > li[data-group]"))){e.id||(e.id=`ctx-group-${++k}`),e.classList.add("ctx-group-label"),e.setAttribute("aria-hidden","true");let o=document.createElement("li");o.setAttribute("role","group"),o.setAttribute("aria-labelledby",e.id),o.setAttribute("data-ctx-group","");let r=document.createElement("ul");r.setAttribute("role","none"),o.appendChild(r),t.insertBefore(o,e),r.appendChild(e);let s=o.nextElementSibling;for(;s&&!s.hasAttribute("data-group")&&s.getAttribute("role")!=="separator";){let i=s;s=s.nextElementSibling,r.appendChild(i)}}}#p(){let t=this.#e;if(t)for(let e of Array.from(t.querySelectorAll(":scope > li[data-ctx-group]"))){let o=e.querySelector(":scope > ul");if(o)for(let r of Array.from(o.children))t.insertBefore(r,e);e.remove()}}get items(){if(!this.#e)return[];let t=[],e=this.#e.querySelectorAll(":scope > li:not([data-ctx-group]), :scope > li[data-ctx-group] > ul > li");for(let o of e){if(o.hasAttribute("data-group")){t.push({group:o.textContent.trim()});continue}if(o.matches(':empty, [role="separator"]')||o.querySelector("hr")){t.push({separator:!0});continue}let r=o.querySelector('button, a, [role="menuitem"]');if(!r)continue;let s=Array.from(r.childNodes).filter(i=>!(i instanceof Element&&i.classList.contains("ctx-kbd"))).map(i=>i.textContent).join("");t.push({label:s.trim().replace(/\s+/g," "),value:r.getAttribute("data-value")||void 0,href:r.tagName==="A"?r.getAttribute("href"):void 0,shortcut:r.getAttribute("data-shortcut")||void 0,disabled:r.disabled||r.hasAttribute("data-disabled")||void 0})}return t}set items(t){let e=Array.isArray(t)?t:[],o=this.querySelector('menu, ul[role="menu"]');for(o||(o=document.createElement("menu"),this.appendChild(o));o.firstChild;)o.firstChild.remove();for(let r of e){let s=document.createElement("li");if(r.separator)s.setAttribute("role","separator");else if(r.group!=null)s.setAttribute("data-group",""),s.textContent=r.group;else{let i=r.href?document.createElement("a"):document.createElement("button");r.href&&i.setAttribute("href",r.href),r.value&&i.setAttribute("data-value",r.value),r.shortcut&&i.setAttribute("data-shortcut",r.shortcut),r.disabled&&i.setAttribute("data-disabled",""),i.tagName==="BUTTON"&&i.setAttribute("type","button"),i.textContent=r.label||"",s.appendChild(i)}o.appendChild(s)}this._reinit(),this.dispatchEvent(new CustomEvent("context-menu:items-changed",{detail:{items:e,source:"property"},bubbles:!0}))}#g=t=>{if(t.preventDefault(),pt(t)){this.#n||this.#m();return}t.buttons!==0?this.listen(window,"pointerup",()=>{setTimeout(()=>this.#f(t.clientX,t.clientY),0)},{once:!0,capture:!0}):this.#f(t.clientX,t.clientY)};#A=t=>{t.defaultPrevented||(t.key==="ContextMenu"||t.key==="F10"&&t.shiftKey)&&(t.preventDefault(),this.#n||this.#m())};#m(){let t=document.activeElement,o=(t&&this.#t.contains(t)?t:this.#t).getBoundingClientRect();this.#f(o.left,o.bottom)}#f(t,e){let o=document.activeElement;this.#a=o&&this.#t.contains(o)?o:this.#t,this.#n=!0,this.setAttribute("data-open",""),this.#i&&this.#t?.setAttribute("aria-expanded","true"),this.#o.style.top=`${e}px`,this.#o.style.left=`${t}px`,this.#o.show(),requestAnimationFrame(()=>{let r=this.#o.getBoundingClientRect(),s=t+r.width>window.innerWidth?t-r.width:t,i=e+r.height>window.innerHeight?e-r.height:e;this.#o.style.top=`${Math.max(0,i)}px`,this.#o.style.left=`${Math.max(0,s)}px`}),this.#s=-1,this.#d(0),this.dispatchEvent(new CustomEvent("context-menu:open",{bubbles:!0}))}close(){if(!this.#n)return;let t=this.#b();this.#n=!1,this.removeAttribute("data-open"),this.#i&&this.#t?.setAttribute("aria-expanded","false"),this.#s=-1,this.#o?.hide(),t&&this.#y(),this.dispatchEvent(new CustomEvent("context-menu:close",{bubbles:!0}))}#b(){let t=document.activeElement;return!t||t===document.body||!!this.#o?.contains(t)}#y(){let t=this.#a?.isConnected?this.#a:this.#t;this.#a=null,t?.isConnected&&t.focus({preventScroll:!0})}#w=t=>{switch(t.key){case"ArrowDown":case"Down":t.preventDefault(),this.#d(this.#s+1);break;case"ArrowUp":case"Up":t.preventDefault(),this.#d(this.#s-1);break;case"Home":t.preventDefault(),this.#d(0);break;case"End":t.preventDefault(),this.#d(this.#r.length-1);break;case"Enter":case" ":{t.preventDefault();let e=this.#r[this.#s];e&&!y(e)&&e.click();break}case"Tab":this.close();break}};#E=t=>{let e=t.target.closest?.('button, a, [role="menuitem"]');e&&this.#e.contains(e)&&y(e)&&(t.preventDefault(),t.stopPropagation())};#v=t=>{let e=t.currentTarget;y(e)||(this.close(),this.dispatchEvent(new CustomEvent("context-menu:select",{bubbles:!0,detail:{item:e,value:e.getAttribute("data-value")||void 0}})))};#k=()=>{this.#n&&(this.#n=!1,this.removeAttribute("data-open"),this.#i&&this.#t?.setAttribute("aria-expanded","false"),this.#s=-1,this.#b()&&this.#y(),this.dispatchEvent(new CustomEvent("context-menu:close",{bubbles:!0})))};#S=()=>{this.#n&&this.close()};#d(t){this.#r.length!==0&&(t<0&&(t=this.#r.length-1),t>=this.#r.length&&(t=0),this.#s=t,this.#r[t].focus())}get isOpen(){return this.#n}};m("context-menu",S);export{S as ContextMenuWc};
|
|
2
2
|
//# sourceMappingURL=context-menu.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var C=window.matchMedia("(prefers-reduced-motion: reduce)");var y=new Map;function v(u,t,e={}){let s=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=y.get(u);if(customElements.get(u)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${u}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}y.set(u,i),customElements.define(u,t)}var m=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,i){t.addEventListener(e,s,i),this.#e.push(()=>t.removeEventListener(e,s,i))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{e?s.add(t):s.delete(t)}catch{let i=`--${t}`;e?s.add(i):s.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}#r(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};function x({newItems:u,nodes:t,keyOf:e,renderItem:s,containerFor:i}){let n=[],a=[],c=[],o=new Set;for(let d of u)o.add(e(d));for(let[d,l]of[...t])o.has(d)||(l.remove(),t.delete(d),c.push(d));let r=new Map;for(let d of u){let l=e(d),h=t.get(l)||null,f=i(d,h);r.has(f)||r.set(f,[]),r.get(f)?.push({item:d,key:l,existing:h})}for(let[d,l]of r)for(let h=0;h<l.length;h++){let{item:f,key:p,existing:E}=l[h],b=E;b?(b.parentElement!==d||d.children[h]!==b)&&a.push(p):(b=s(f),t.set(p,b),n.push(p));let w=d.children[h];w!==b&&d.insertBefore(b,w||null)}return{added:n,moved:a,removed:c}}var g=":scope > tr:not([data-expand-content])",A=class u extends m{#e;#t;#r=[];#s=[];#i=[];#c=-1;#d=null;#n=1;#a=0;#u=null;#h=null;#f=null;#l="";#o=null;#C=null;#m=null;#p=null;#g=[];#S=new Map;#A=[];setup(){return this.#e=this.querySelector(":scope > table"),!this.#e||(this.#t=this.#e.querySelector("tbody"),!this.#t)?!1:(this.#V(),!0)}teardown(){this.#O(),this.#r=[],this.#s=[],this.#i=[]}#V(){this.#s=[...this.#t.querySelectorAll(g)],this.#i=[...this.#s],this.#n=1,this.#c=-1,this.#d=null,this.#l="",this.#a=0,this.#A=[...this.#e.tHead?.rows[0]?.cells||[]].map(e=>({key:e.getAttribute("data-key")||e.textContent.trim().toLowerCase(),label:e.textContent.trim(),sort:e.getAttribute("data-sort")||void 0})),this.#S.clear(),this.#g=[];for(let e of this.#s){let s=e.getAttribute("data-id")||e.getAttribute("data-key");s&&(this.#S.set(s,e),this.#g.push({id:s}))}this.#L(),this.#k(),this.#M(),this.#D(),this.#_(),this.#e.hasAttribute("data-filterable")&&this.#G();let t=this.#e.getAttribute("data-paginate");t&&(this.#a=parseInt(t,10),this.#a>0&&this.#U()),this.#X(),this.#Z(),this.#x()}get rows(){return this.#g}set rows(t){let e=t||[],s=x({newItems:e,nodes:this.#S,keyOf:i=>i.id,renderItem:i=>this._renderRow(i),containerFor:()=>this.#t});this.#g=e,this.#s=[...this.#t.querySelectorAll(g)],this.#k(),this.#M(),this.#v(this.#l),this.dispatchEvent(new CustomEvent("data-table:rows-changed",{detail:{rows:e,added:s.added,moved:s.moved,removed:s.removed,source:"api"},bubbles:!0}))}get columns(){return this.#A}_renderRow(t){let e=this;if(typeof e.renderRow=="function"){let i=e.renderRow(t,this.#A);if(!(i instanceof Element))throw new Error("data-table: renderRow must return an Element");return i.hasAttribute("data-id")||i.setAttribute("data-id",String(t.id)),i}let s=document.createElement("tr");s.setAttribute("data-id",String(t.id));for(let i of this.#A){let n=document.createElement("td"),a=t[i.key];n.textContent=a==null?"":String(a),s.appendChild(n)}return s}#N=[];#b=[];#w=[];#L(){let t=[...this.#e.tHead?.rows[0]?.cells||[]];this.#N=t.map(e=>{let s=parseFloat(e.getAttribute("data-weight"));return Number.isFinite(s)?s:null}),this.#b=t.map(e=>e.getAttribute("data-rollup")||null),this.#w=t.map(e=>e.getAttribute("data-heatmap")||null)}#k(){if(this.#b.some(Boolean))for(let t=0;t<this.#b.length;t++){let e=this.#b[t];if(e)for(let s of this.#s){let i=s.children[t];if(!i)continue;let n=this.#P(s,t,e),a=u.#H(n);i.textContent=a,i.setAttribute("data-rollup-value",String(n)),i.hasAttribute("data-sort-value")||i.setAttribute("data-sort-value",String(n))}}}#P(t,e,s){let i=[...t.children],n=0,a=0,c=-1/0,o=0,r=1,d=!1;for(let l=0;l<i.length;l++){if(l===e||this.#b[l])continue;let h=i[l].getAttribute("data-sort-value")??i[l].textContent??"",f=parseFloat(h);if(!Number.isFinite(f))continue;n+=f,a++,f>c&&(c=f),r*=f,d=!0;let p=this.#N[l];p!==null&&(o+=f*p)}switch(s){case"sum":return n;case"avg":return a?n/a:0;case"max":return c===-1/0?0:c;case"weighted-sum":return o;case"product":return d?r:0;default:return n}}static#H(t){return Number.isFinite(t)?Number.isInteger(t)?String(t):(Math.round(t*100)/100).toString():""}#M(){if(this.#w.some(Boolean))for(let t=0;t<this.#w.length;t++){let e=this.#w[t];if(!e)continue;let s=this.#s.map(o=>{let r=o.children[t];if(!r)return null;let d=r.getAttribute("data-rollup-value")??r.getAttribute("data-sort-value")??r.textContent??"",l=parseFloat(d);return Number.isFinite(l)?l:null}),i=s.filter(o=>o!==null);if(!i.length)continue;let n=Math.min(...i),c=Math.max(...i)-n||1;for(let o=0;o<this.#s.length;o++){let r=this.#s[o].children[t];if(!r)continue;let d=s[o];if(d===null){r.removeAttribute("data-heat-level");continue}let l=(d-n)/c;e==="low-good"&&(l=1-l);let h=l<.34?"low":l<.67?"mid":"high";r.setAttribute("data-heat-level",h)}}}#O(){this.#f&&clearTimeout(this.#f),this.#u?.parentElement?.remove(),this.#h?.remove(),this.#m?.remove(),this.#p?.remove(),this.#u=null,this.#h=null,this.#m=null,this.#p=null}#T(t,e){return this.dataset[`label${t}`]||e}#D(){let t=document.createElement("span");t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-table-status",""),t.className="visually-hidden",this.appendChild(t),this.#m=t}#R(t){let e=this.#m;e&&(e.textContent=e.textContent===t?`${t}\xA0`:t)}#_(){this.#e.querySelectorAll("thead th[data-sort]").forEach((e,s)=>{let i=e.getAttribute("data-sort"),n=this.#j(e);this.#r.push({th:e,sortType:i,columnIndex:n}),e.setAttribute("aria-sort","none"),u.#K(e),e.dataset.columnIndex=n,this.listen(e,"click",this.#z)})}static#K(t){if(t.querySelector(":scope > button[data-sort-button]"))return;let e=document.createElement("button");e.type="button",e.setAttribute("data-sort-button",""),e.append(...t.childNodes),t.appendChild(e)}#j(t){return[...t.parentElement.children].indexOf(t)}#z=t=>{let e=t.currentTarget,s=t.target.closest?.("a, input, select, textarea, button:not([data-sort-button])");if(s&&e.contains(s))return;let i=parseInt(e.dataset.columnIndex,10);this.#W(i)};#Q(t,e,s){let i=this.#i;if(i.length<2)return!0;let n=s==="asc"?1:-1;for(let a=1;a<i.length;a++){let c=this.#y(i[a-1].children[t],e),o=this.#y(i[a].children[t],e);if((typeof c=="string"?c.localeCompare(o)*n:(c-o)*n)>0)return!1}return!0}#W(t){let e=this.#r.find(n=>n.columnIndex===t);if(!e)return;let s;this.#c===t?s=this.#d==="asc"?"desc":"asc":this.#Q(t,e.sortType,"asc")?s="desc":s="asc",this.#r.forEach(({th:n})=>{n.setAttribute("aria-sort","none")}),e.th.setAttribute("aria-sort",s==="asc"?"ascending":"descending"),this.#c=t,this.#d=s,this.#B(t,s,e.sortType),this.#n=1,this.#x();let i=e.th.textContent.trim();this.#R(`Sorted by ${i}, ${s==="asc"?"ascending":"descending"}`),this.dispatchEvent(new CustomEvent("data-table:sort",{detail:{column:t,direction:s,columnName:i},bubbles:!0}))}#B(t,e,s){let i=e==="asc"?1:-1;this.#i.sort((n,a)=>{let c=n.children[t],o=a.children[t];if(!c||!o)return 0;let r=this.#y(c,s),d=this.#y(o,s),l=0;switch(s){case"number":l=r-d;break;case"date":l=r-d;break;default:l=r.localeCompare(d,void 0,{numeric:!0,sensitivity:"base"});break}return l*i})}#y(t,e){let i=t.getAttribute("data-sort-value")??t.textContent.trim();switch(e){case"number":return parseFloat(i)||0;case"date":return new Date(i).getTime()||0;default:return i.toLowerCase()}}#G(){let t=document.createElement("div");t.setAttribute("data-table-filter","");let e=document.createElement("input");e.type="search",e.setAttribute("data-filter-input",""),e.setAttribute("placeholder","Filter table..."),e.setAttribute("aria-label","Filter table rows"),t.appendChild(e),this.insertBefore(t,this.#e),this.#u=e;let s=document.createElement("p");s.setAttribute("data-table-empty",""),s.hidden=!0,s.textContent=this.#T("NoResults","No matching rows found"),this.#e.after(s),this.#p=s,this.listen(e,"input",this.#J)}#J=t=>{let e=t.target.value;this.#f&&clearTimeout(this.#f),this.#f=setTimeout(()=>{this.#v(e,{announce:!0})},150)};#v(t,{announce:e=!1,keepPage:s=!1}={}){if(this.#l=String(t??"").toLowerCase().trim(),this.#l===""?this.#i=[...this.#s]:this.#i=this.#s.filter(i=>[...i.children].some(a=>(a.getAttribute("data-filter-value")??a.textContent).toLowerCase().includes(this.#l))),this.#c>=0&&this.#d){let i=this.#r.find(n=>n.columnIndex===this.#c);i&&this.#B(this.#c,this.#d,i.sortType)}if(s?this.#n=Math.min(this.#n,this.totalPages):this.#n=1,this.#x(),e){let i=this.#i.length,n=this.#s.length;this.#R(i===0?this.#T("NoResults","No matching rows found"):this.#l?`${i} of ${n} ${n===1?"row":"rows"} shown`:`All ${n} ${n===1?"row":"rows"} shown`)}this.dispatchEvent(new CustomEvent("data-table:filter",{detail:{query:this.#l,count:this.#i.length},bubbles:!0}))}#U(){let t=document.createElement("nav");t.setAttribute("data-pagination",""),t.setAttribute("aria-label","Table pagination"),this.appendChild(t),this.#h=t}#X(){for(let t of this.#t.querySelectorAll(":scope > tr[data-expandable]")){let e=t.querySelector('[data-action="toggle-expand"]');e&&e.setAttribute("aria-expanded",String(t.hasAttribute("data-state-expanded")))}this.listen(this.#e,"click",this.#Y)}#Y=t=>{let e=t.target.closest('[data-action="toggle-expand"]');if(!e)return;let s=e.closest("tr[data-expandable]");if(!s)return;let i=s.hasAttribute("data-state-expanded"),n=s.nextElementSibling;i?(s.removeAttribute("data-state-expanded"),e.setAttribute("aria-expanded","false"),n?.hasAttribute("data-expand-content")&&(n.hidden=!0,n.setAttribute("aria-hidden","true"))):(s.setAttribute("data-state-expanded",""),e.setAttribute("aria-expanded","true"),n?.hasAttribute("data-expand-content")&&(n.hidden=!1,n.removeAttribute("aria-hidden"))),this.dispatchEvent(new CustomEvent("data-table:expand",{detail:{row:s,expanded:!i},bubbles:!0}))};#Z(){this.#o=this.#e.querySelector('thead [data-action="select-all"]'),this.#o&&this.listen(this.#o,"change",this.#tt),this.listen(this.#t,"change",this.#et),this.#C=this.querySelector("[data-selected-count]"),this.#$()}#tt=t=>{let e=t.target.checked;this.#t.querySelectorAll("tr[data-selectable]").forEach(i=>{let n=i.querySelector('[data-action="select-row"]');e?(i.setAttribute("data-state-selected",""),n&&(n.checked=!0)):(i.removeAttribute("data-state-selected"),n&&(n.checked=!1))}),t.target.indeterminate=!1,this.#q(),this.#F(),this.#I()};#et=t=>{let e=t.target.closest('[data-action="select-row"]');if(!e)return;let s=e.closest("tr[data-selectable]");s&&(e.checked?s.setAttribute("data-state-selected",""):s.removeAttribute("data-state-selected"),this.#$(),this.#F(),this.#I())};#F(){let t=this.getSelectedRows().length;this.#R(`${t} ${t===1?"row":"rows"} selected`)}#$(){if(!this.#o){this.#q();return}let t=this.#t.querySelectorAll("tr[data-selectable]"),e=this.#t.querySelectorAll("tr[data-selectable][data-state-selected]"),s=t.length,i=e.length;i===0?(this.#o.checked=!1,this.#o.indeterminate=!1):i===s?(this.#o.checked=!0,this.#o.indeterminate=!1):(this.#o.checked=!1,this.#o.indeterminate=!0),this.#q()}#q(){let e=this.#t.querySelectorAll("tr[data-selectable][data-state-selected]").length;this.#C&&(this.#C.textContent=e)}#I(){let t=[...this.#t.querySelectorAll("tr[data-selectable][data-state-selected]")];this.dispatchEvent(new CustomEvent("data-table:selection",{detail:{count:t.length,rows:t},bubbles:!0}))}#st(){if(!this.#h||this.#a<=0)return;let t=this.#h,e=Math.ceil(this.#i.length/this.#a),s=document.activeElement,i=null;if(s instanceof HTMLElement&&t.contains(s)&&(i=s.hasAttribute("data-pagination-prev")?"prev":s.hasAttribute("data-pagination-next")?"next":"page"),t.replaceChildren(),e<=1)return;let n=document.createElement("button");n.type="button",n.textContent="Previous",n.setAttribute("data-pagination-prev",""),n.disabled=this.#n===1,n.addEventListener("click",()=>this.goToPage(this.#n-1)),t.appendChild(n),this.#it(e).forEach(o=>{if(o==="..."){let r=document.createElement("span");r.textContent="...",r.setAttribute("data-pagination-ellipsis",""),t.appendChild(r)}else{let r=document.createElement("button");r.type="button",r.textContent=o,r.setAttribute("data-pagination-page",""),o===this.#n&&(r.setAttribute("aria-current","page"),r.setAttribute("data-current","")),r.addEventListener("click",()=>this.goToPage(o)),t.appendChild(r)}});let c=document.createElement("button");if(c.type="button",c.textContent="Next",c.setAttribute("data-pagination-next",""),c.disabled=this.#n===e,c.addEventListener("click",()=>this.goToPage(this.#n+1)),t.appendChild(c),i){let o=t.querySelector('[aria-current="page"]');(i==="prev"&&!n.disabled?n:i==="next"&&!c.disabled?c:o)?.focus()}}#it(t){let e=this.#n,s=[];if(t<=7)for(let i=1;i<=t;i++)s.push(i);else{s.push(1),e>3&&s.push("...");let i=Math.max(2,e-1),n=Math.min(t-1,e+1);for(let a=i;a<=n;a++)s.push(a);e<t-2&&s.push("..."),s.push(t)}return s}#x(){this.#s.forEach(s=>{s.setAttribute("data-state-hidden",""),this.#E(s)?.setAttribute("data-state-hidden","")});let t;if(this.#a>0){let s=(this.#n-1)*this.#a,i=s+this.#a;t=this.#i.slice(s,i)}else t=this.#i;t.forEach(s=>{s.removeAttribute("data-state-hidden");let i=this.#E(s);this.#t.appendChild(s),i&&(i.removeAttribute("data-state-hidden"),this.#t.appendChild(i))}),this.#i.forEach(s=>{if(s.hasAttribute("data-state-hidden")){let i=this.#E(s);this.#t.appendChild(s),i&&this.#t.appendChild(i)}});let e=new Set(this.#i);this.#s.forEach(s=>{if(!e.has(s)){let i=this.#E(s);this.#t.appendChild(s),i&&this.#t.appendChild(i)}}),this.#p&&(this.#p.hidden=!(this.#l&&this.#i.length===0&&this.#s.length>0)),this.#st()}#E(t){if(!t.hasAttribute("data-expandable"))return null;let e=t.nextElementSibling;return e?.hasAttribute("data-expand-content")?e:null}goToPage(t){if(this.#a<=0)return;let e=Math.max(1,Math.ceil(this.#i.length/this.#a)),s=Math.max(1,Math.min(Math.trunc(Number(t))||1,e));s!==this.#n&&(this.#n=s,this.#x(),this.dispatchEvent(new CustomEvent("data-table:page",{detail:{page:this.#n},bubbles:!0})))}setFilter(t){this.#u&&(this.#u.value=t),this.#v(t,{announce:!0})}refresh(){this.#t&&(this.#s=[...this.#t.querySelectorAll(g)],this.#k(),this.#M(),this.#v(this.#l,{keepPage:!0}),this.#$())}get currentPage(){return this.#n}get totalPages(){return this.#a<=0?1:Math.max(1,Math.ceil(this.#i.length/this.#a))}get filteredCount(){return this.#i.length}get totalCount(){return this.#s.length}getSelectedRows(){return this.#t?[...this.#t.querySelectorAll("tr[data-selectable][data-state-selected]")]:[]}};v("data-table",A);export{A as DataTable};
|
|
1
|
+
var $=window.matchMedia("(prefers-reduced-motion: reduce)");var A=new Map;function y(u,t,e={}){let s=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:s},i=A.get(u);if(customElements.get(u)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${u}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}A.set(u,n),customElements.define(u,t)}var m=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,n){t.addEventListener(e,s,n),this.#e.push(()=>t.removeEventListener(e,s,n))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{e?s.add(t):s.delete(t)}catch{let n=`--${t}`;e?s.add(n):s.delete(n)}}_adoptInternals(t){this.#t||(this.#t=t)}#r(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};function E({newItems:u,nodes:t,keyOf:e,renderItem:s,containerFor:n}){let i=[],a=[],c=[],o=new Set;for(let d of u)o.add(e(d));for(let[d,l]of[...t])o.has(d)||(l.remove(),t.delete(d),c.push(d));let r=new Map;for(let d of u){let l=e(d),h=t.get(l)||null,f=n(d,h);r.has(f)||r.set(f,[]),r.get(f)?.push({item:d,key:l,existing:h})}for(let[d,l]of r)for(let h=0;h<l.length;h++){let{item:f,key:p,existing:x}=l[h],b=x;b?(b.parentElement!==d||d.children[h]!==b)&&a.push(p):(b=s(f),t.set(p,b),i.push(p));let w=d.children[h];w!==b&&d.insertBefore(b,w||null)}return{added:i,moved:a,removed:c}}var g=":scope > tr:not([data-expand-content])",v=class u extends m{#e;#t;#r=[];#s=[];#n=[];#c=-1;#d=null;#i=1;#a=0;#u=null;#h=null;#f=null;#l="";#o=null;#C=null;#m=null;#p=null;#g=[];#S=new Map;#v=[];setup(){return this.#e=this.querySelector(":scope > table"),!this.#e||(this.#t=this.#e.querySelector("tbody"),!this.#t)?!1:(this.#V(),!0)}teardown(){this.#O(),this.#r=[],this.#s=[],this.#n=[]}#V(){this.#s=[...this.#t.querySelectorAll(g)],this.#n=[...this.#s],this.#i=1,this.#c=-1,this.#d=null,this.#l="",this.#a=0,this.#v=[...this.#e.tHead?.rows[0]?.cells||[]].map(e=>({key:e.getAttribute("data-key")||e.textContent.trim().toLowerCase(),label:e.textContent.trim(),sort:e.getAttribute("data-sort")||void 0})),this.#S.clear(),this.#g=[];for(let e of this.#s){let s=e.getAttribute("data-id")||e.getAttribute("data-key");s&&(this.#S.set(s,e),this.#g.push({id:s}))}this.#H(),this.#k(),this.#$(),this.#j(),this.#D(),this.#e.hasAttribute("data-filterable")&&this.#J();let t=this.#e.getAttribute("data-paginate");t&&(this.#a=parseInt(t,10),this.#a>0&&this.#X()),this.#Y(),this.#N(),this.#E()}get rows(){return this.#g}set rows(t){let e=t||[],s=E({newItems:e,nodes:this.#S,keyOf:n=>n.id,renderItem:n=>this._renderRow(n),containerFor:()=>this.#t});this.#g=e,this.#s=[...this.#t.querySelectorAll(g)],this.#k(),this.#$(),this.#y(this.#l),this.dispatchEvent(new CustomEvent("data-table:rows-changed",{detail:{rows:e,added:s.added,moved:s.moved,removed:s.removed,source:"api"},bubbles:!0}))}get columns(){return this.#v}_renderRow(t){let e=this;if(typeof e.renderRow=="function"){let n=e.renderRow(t,this.#v);if(!(n instanceof Element))throw new Error("data-table: renderRow must return an Element");return n.hasAttribute("data-id")||n.setAttribute("data-id",String(t.id)),n}let s=document.createElement("tr");s.setAttribute("data-id",String(t.id));for(let n of this.#v){let i=document.createElement("td"),a=t[n.key];i.textContent=a==null?"":String(a),s.appendChild(i)}return s}#q=[];#b=[];#w=[];#H(){let t=[...this.#e.tHead?.rows[0]?.cells||[]];this.#q=t.map(e=>{let s=parseFloat(e.getAttribute("data-weight"));return Number.isFinite(s)?s:null}),this.#b=t.map(e=>e.getAttribute("data-rollup")||null),this.#w=t.map(e=>e.getAttribute("data-heatmap")||null)}#k(){if(this.#b.some(Boolean))for(let t=0;t<this.#b.length;t++){let e=this.#b[t];if(e)for(let s of this.#s){let n=s.children[t];if(!n)continue;let i=this.#I(s,t,e),a=u.#_(i);n.textContent=a,n.setAttribute("data-rollup-value",String(i)),n.hasAttribute("data-sort-value")||n.setAttribute("data-sort-value",String(i))}}}#I(t,e,s){let n=[...t.children],i=0,a=0,c=-1/0,o=0,r=1,d=!1;for(let l=0;l<n.length;l++){if(l===e||this.#b[l])continue;let h=n[l].getAttribute("data-sort-value")??n[l].textContent??"",f=parseFloat(h);if(!Number.isFinite(f))continue;i+=f,a++,f>c&&(c=f),r*=f,d=!0;let p=this.#q[l];p!==null&&(o+=f*p)}switch(s){case"sum":return i;case"avg":return a?i/a:0;case"max":return c===-1/0?0:c;case"weighted-sum":return o;case"product":return d?r:0;default:return i}}static#_(t){return Number.isFinite(t)?Number.isInteger(t)?String(t):(Math.round(t*100)/100).toString():""}#$(){if(this.#w.some(Boolean))for(let t=0;t<this.#w.length;t++){let e=this.#w[t];if(!e)continue;let s=this.#s.map(o=>{let r=o.children[t];if(!r)return null;let d=r.getAttribute("data-rollup-value")??r.getAttribute("data-sort-value")??r.textContent??"",l=parseFloat(d);return Number.isFinite(l)?l:null}),n=s.filter(o=>o!==null);if(!n.length)continue;let i=Math.min(...n),c=Math.max(...n)-i||1;for(let o=0;o<this.#s.length;o++){let r=this.#s[o].children[t];if(!r)continue;let d=s[o];if(d===null){r.removeAttribute("data-heat-level");continue}let l=(d-i)/c;e==="low-good"&&(l=1-l);let h=l<.34?"low":l<.67?"mid":"high";r.setAttribute("data-heat-level",h)}}}#O(){this.#f&&clearTimeout(this.#f),this.#u?.parentElement?.remove(),this.#h?.remove(),this.#m?.remove(),this.#p?.remove(),this.#u=null,this.#h=null,this.#m=null,this.#p=null}#P(t,e){return this.dataset[`label${t}`]||e}#j(){let t=document.createElement("span");t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("data-table-status",""),t.className="visually-hidden",this.appendChild(t),this.#m=t}#M(t){let e=this.#m;e&&(e.textContent=e.textContent===t?`${t}\xA0`:t)}#D(){this.#e.querySelectorAll("thead th[data-sort]").forEach((e,s)=>{let n=e.getAttribute("data-sort"),i=this.#z(e);this.#r.push({th:e,sortType:n,columnIndex:i}),e.setAttribute("aria-sort","none"),u.#K(e),e.dataset.columnIndex=i,this.listen(e,"click",this.#Q)})}static#K(t){if(t.querySelector(":scope > button[data-sort-button]"))return;let e=document.createElement("button");e.type="button",e.setAttribute("data-sort-button",""),e.append(...t.childNodes),t.appendChild(e)}#z(t){return[...t.parentElement.children].indexOf(t)}#Q=t=>{let e=t.currentTarget,s=t.target.closest?.("a, input, select, textarea, button:not([data-sort-button])");if(s&&e.contains(s))return;let n=parseInt(e.dataset.columnIndex,10);this.#G(n)};#W(t,e,s){let n=this.#n;if(n.length<2)return!0;let i=s==="asc"?1:-1;for(let a=1;a<n.length;a++){let c=this.#A(n[a-1].children[t],e),o=this.#A(n[a].children[t],e);if((typeof c=="string"?c.localeCompare(o)*i:(c-o)*i)>0)return!1}return!0}#G(t){let e=this.#r.find(i=>i.columnIndex===t);if(!e)return;let s;this.#c===t?s=this.#d==="asc"?"desc":"asc":this.#W(t,e.sortType,"asc")?s="desc":s="asc",this.#r.forEach(({th:i})=>{i.setAttribute("aria-sort","none")}),e.th.setAttribute("aria-sort",s==="asc"?"ascending":"descending"),this.#c=t,this.#d=s,this.#B(t,s,e.sortType),this.#i=1,this.#E();let n=e.th.textContent.trim();this.#M(`Sorted by ${n}, ${s==="asc"?"ascending":"descending"}`),this.dispatchEvent(new CustomEvent("data-table:sort",{detail:{column:t,direction:s,columnName:n},bubbles:!0}))}#B(t,e,s){let n=e==="asc"?1:-1;this.#n.sort((i,a)=>{let c=i.children[t],o=a.children[t];if(!c||!o)return 0;let r=this.#A(c,s),d=this.#A(o,s),l=0;switch(s){case"number":l=r-d;break;case"date":l=r-d;break;default:l=r.localeCompare(d,void 0,{numeric:!0,sensitivity:"base"});break}return l*n})}#A(t,e){let n=t.getAttribute("data-sort-value")??t.textContent.trim();switch(e){case"number":return parseFloat(n)||0;case"date":return new Date(n).getTime()||0;default:return n.toLowerCase()}}#J(){let t=document.createElement("div");t.setAttribute("data-table-filter","");let e=document.createElement("input");e.type="search",e.setAttribute("data-filter-input",""),e.setAttribute("placeholder","Filter table..."),e.setAttribute("aria-label","Filter table rows"),t.appendChild(e),this.insertBefore(t,this.#e),this.#u=e;let s=document.createElement("p");s.setAttribute("data-table-empty",""),s.hidden=!0,s.textContent=this.#P("NoResults","No matching rows found"),this.#e.after(s),this.#p=s,this.listen(e,"input",this.#U)}#U=t=>{let e=t.target.value;this.#f&&clearTimeout(this.#f),this.#f=setTimeout(()=>{this.#y(e,{announce:!0})},150)};#y(t,{announce:e=!1,keepPage:s=!1}={}){if(this.#l=String(t??"").toLowerCase().trim(),this.#l===""?this.#n=[...this.#s]:this.#n=this.#s.filter(n=>[...n.children].some(a=>(a.getAttribute("data-filter-value")??a.textContent).toLowerCase().includes(this.#l))),this.#c>=0&&this.#d){let n=this.#r.find(i=>i.columnIndex===this.#c);n&&this.#B(this.#c,this.#d,n.sortType)}if(s?this.#i=Math.min(this.#i,this.totalPages):this.#i=1,this.#E(),e){let n=this.#n.length,i=this.#s.length;this.#M(n===0?this.#P("NoResults","No matching rows found"):this.#l?`${n} of ${i} ${i===1?"row":"rows"} shown`:`All ${i} ${i===1?"row":"rows"} shown`)}this.dispatchEvent(new CustomEvent("data-table:filter",{detail:{query:this.#l,count:this.#n.length},bubbles:!0}))}#X(){let t=document.createElement("nav");t.setAttribute("data-pagination",""),t.setAttribute("aria-label","Table pagination"),this.appendChild(t),this.#h=t}#Y(){for(let t of this.#t.querySelectorAll(":scope > tr[data-expandable]")){let e=t.querySelector('[data-action="toggle-expand"]');e&&e.setAttribute("aria-expanded",String(t.hasAttribute("data-state-expanded")))}this.listen(this.#e,"click",this.#Z)}#Z=t=>{let e=t.target.closest('[data-action="toggle-expand"]');if(!e)return;let s=e.closest("tr[data-expandable]");if(!s)return;let n=s.hasAttribute("data-state-expanded"),i=s.nextElementSibling;n?(s.removeAttribute("data-state-expanded"),e.setAttribute("aria-expanded","false"),i?.hasAttribute("data-expand-content")&&(i.hidden=!0,i.setAttribute("aria-hidden","true"))):(s.setAttribute("data-state-expanded",""),e.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}))};#N(){this.#o=this.#e.querySelector('thead [data-action="select-all"]'),this.#o&&this.listen(this.#o,"change",this.#tt),this.listen(this.#t,"change",this.#et),this.#C=this.querySelector("[data-selected-count]"),this.#T()}#tt=t=>{let e=t.target.checked;this.#t.querySelectorAll("tr[data-selectable]").forEach(n=>{let i=n.querySelector('[data-action="select-row"]');e?(n.setAttribute("data-state-selected",""),i&&(i.checked=!0)):(n.removeAttribute("data-state-selected"),i&&(i.checked=!1))}),t.target.indeterminate=!1,this.#R(),this.#L(),this.#F()};#et=t=>{let e=t.target.closest('[data-action="select-row"]');if(!e)return;let s=e.closest("tr[data-selectable]");s&&(e.checked?s.setAttribute("data-state-selected",""):s.removeAttribute("data-state-selected"),this.#T(),this.#L(),this.#F())};#L(){let t=this.getSelectedRows().length;this.#M(`${t} ${t===1?"row":"rows"} selected`)}#T(){if(!this.#o){this.#R();return}let t=this.#t.querySelectorAll("tr[data-selectable]"),e=this.#t.querySelectorAll("tr[data-selectable][data-state-selected]"),s=t.length,n=e.length;n===0?(this.#o.checked=!1,this.#o.indeterminate=!1):n===s?(this.#o.checked=!0,this.#o.indeterminate=!1):(this.#o.checked=!1,this.#o.indeterminate=!0),this.#R()}#R(){let e=this.#t.querySelectorAll("tr[data-selectable][data-state-selected]").length;this.#C&&(this.#C.textContent=e)}#F(){let t=[...this.#t.querySelectorAll("tr[data-selectable][data-state-selected]")];this.dispatchEvent(new CustomEvent("data-table:selection",{detail:{count:t.length,rows:t},bubbles:!0}))}#st(){if(!this.#h||this.#a<=0)return;let t=this.#h,e=Math.ceil(this.#n.length/this.#a),s=document.activeElement,n=null;if(s instanceof HTMLElement&&t.contains(s)&&(n=s.hasAttribute("data-pagination-prev")?"prev":s.hasAttribute("data-pagination-next")?"next":"page"),t.replaceChildren(),e<=1)return;let i=document.createElement("button");i.type="button",i.textContent="Previous",i.setAttribute("data-pagination-prev",""),i.disabled=this.#i===1,i.addEventListener("click",()=>this.goToPage(this.#i-1)),t.appendChild(i),this.#nt(e).forEach(o=>{if(o==="..."){let r=document.createElement("span");r.textContent="...",r.setAttribute("data-pagination-ellipsis",""),t.appendChild(r)}else{let r=document.createElement("button");r.type="button",r.textContent=o,r.setAttribute("data-pagination-page",""),o===this.#i&&(r.setAttribute("aria-current","page"),r.setAttribute("data-current","")),r.addEventListener("click",()=>this.goToPage(o)),t.appendChild(r)}});let c=document.createElement("button");if(c.type="button",c.textContent="Next",c.setAttribute("data-pagination-next",""),c.disabled=this.#i===e,c.addEventListener("click",()=>this.goToPage(this.#i+1)),t.appendChild(c),n){let o=t.querySelector('[aria-current="page"]');(n==="prev"&&!i.disabled?i:n==="next"&&!c.disabled?c:o)?.focus()}}#nt(t){let e=this.#i,s=[];if(t<=7)for(let n=1;n<=t;n++)s.push(n);else{s.push(1),e>3&&s.push("...");let n=Math.max(2,e-1),i=Math.min(t-1,e+1);for(let a=n;a<=i;a++)s.push(a);e<t-2&&s.push("..."),s.push(t)}return s}#E(){this.#s.forEach(s=>{s.setAttribute("data-state-hidden",""),this.#x(s)?.setAttribute("data-state-hidden","")});let t;if(this.#a>0){let s=(this.#i-1)*this.#a,n=s+this.#a;t=this.#n.slice(s,n)}else t=this.#n;t.forEach(s=>{s.removeAttribute("data-state-hidden");let n=this.#x(s);this.#t.appendChild(s),n&&(n.removeAttribute("data-state-hidden"),this.#t.appendChild(n))}),this.#n.forEach(s=>{if(s.hasAttribute("data-state-hidden")){let n=this.#x(s);this.#t.appendChild(s),n&&this.#t.appendChild(n)}});let e=new Set(this.#n);this.#s.forEach(s=>{if(!e.has(s)){let n=this.#x(s);this.#t.appendChild(s),n&&this.#t.appendChild(n)}}),this.#p&&(this.#p.hidden=!(this.#l&&this.#n.length===0&&this.#s.length>0)),this.#st()}#x(t){if(!t.hasAttribute("data-expandable"))return null;let e=t.nextElementSibling;return e?.hasAttribute("data-expand-content")?e:null}goToPage(t){if(this.#a<=0)return;let e=Math.max(1,Math.ceil(this.#n.length/this.#a)),s=Math.max(1,Math.min(Math.trunc(Number(t))||1,e));s!==this.#i&&(this.#i=s,this.#E(),this.dispatchEvent(new CustomEvent("data-table:page",{detail:{page:this.#i},bubbles:!0})))}setFilter(t){this.#u&&(this.#u.value=t),this.#y(t,{announce:!0})}refresh(){this.#t&&(this.#s=[...this.#t.querySelectorAll(g)],this.#k(),this.#$(),this.#y(this.#l,{keepPage:!0}),this.#T())}get currentPage(){return this.#i}get totalPages(){return this.#a<=0?1:Math.max(1,Math.ceil(this.#n.length/this.#a))}get filteredCount(){return this.#n.length}get totalCount(){return this.#s.length}getSelectedRows(){return this.#t?[...this.#t.querySelectorAll("tr[data-selectable][data-state-selected]")]:[]}};y("data-table",v);export{v as DataTable};
|
|
2
2
|
//# sourceMappingURL=data-table.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var W=window.matchMedia("(prefers-reduced-motion: reduce)");var S=new Map;function $(n,t,i={}){let e=i.priority??10,s={impl:t,bundle:i.bundle,contract:i.contract,priority:e},r=S.get(n);if(customElements.get(n)){if(!r||r.priority>=e){r&&r.priority===e&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=e){r.priority===e&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}S.set(n,s),customElements.define(n,t)}var v=class extends HTMLElement{#a=[];#d;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#a)t();this.#a=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,i,e,s){t.addEventListener(i,e,s),this.#a.push(()=>t.removeEventListener(i,e,s))}_reinit(){for(let t of this.#a)t();this.#a=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,i){this.#d||(this.#d=this.attachInternals());let e=this.#d.states;try{i?e.add(t):e.delete(t)}catch{let s=`--${t}`;i?e.add(s):e.delete(s)}}_adoptInternals(t){this.#d||(this.#d=t)}#o(){return this.constructor.formAssociated&&this.#d?this.#d:null}get validity(){return this.#o()?.validity}get validationMessage(){return this.#o()?.validationMessage??""}get willValidate(){return this.#o()?.willValidate??!1}get form(){return this.#o()?.form??null}checkValidity(){return this.#o()?.checkValidity()??!0}reportValidity(){return this.#o()?.reportValidity()??!0}};var F="popover"in HTMLElement.prototype;var m=[{ja:"\u4EE4\u548C",latin:"R",start:[2019,5,1]},{ja:"\u5E73\u6210",latin:"H",start:[1989,1,8]},{ja:"\u662D\u548C",latin:"S",start:[1926,12,25]},{ja:"\u5927\u6B63",latin:"T",start:[1912,7,30]},{ja:"\u660E\u6CBB",latin:"M",start:[1868,10,23]}],O=new RegExp(`^(?:(${m.map(n=>n.ja).join("|")})|(${m.map(n=>n.latin).join("|")}))`+String.raw`\s*(元|\d{1,2})年?[/.\-]?\s*(\d{1,2})月?[/.\-]?\s*(\d{1,2})日?$`,"i"),B=/^(\d{4})年(\d{1,2})月(\d{1,2})日?$/;function L(n){return n.trim().replace(/[0-9]/g,t=>String(t.charCodeAt(0)-65296)).replace(/\s+/g,"")}function T(n,t,i){let e=new Date(2e3,t-1,i);return e.setFullYear(n),e.getMonth()===t-1&&e.getDate()===i?e:null}function I(n){let t=L(n).match(O);if(!t)return null;let i=t[1]?m.find(a=>a.ja===t[1]):m.find(a=>a.latin.toUpperCase()===t[2].toUpperCase());if(!i)return null;let e=t[3]==="\u5143"?1:Number(t[3]);if(e<1)return null;let s=T(i.start[0]+e-1,Number(t[4]),Number(t[5]));if(!s||s<new Date(i.start[0],i.start[1]-1,i.start[2]))return null;let r=m.indexOf(i);if(r>0){let a=m[r-1].start;if(s>=new Date(a[0],a[1]-1,a[2]))return null}return s}function Y(n){let t=L(n).match(B);return t?T(Number(t[1]),Number(t[2]),Number(t[3])):null}function V(n){return n.split("-")[0].toLowerCase()}function R(n,t="en-US"){try{if(n)return Intl.getCanonicalLocales(n),n}catch{}try{return Intl.getCanonicalLocales(t),t}catch{return"en-US"}}var M=["january","february","march","april","may","june","july","august","september","october","november","december"],U=0;function c(n){let t=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),e=String(n.getDate()).padStart(2,"0");return`${t}-${i}-${e}`}function k(n,t,i){if(!Number.isInteger(n)||!Number.isInteger(t)||!Number.isInteger(i))return null;let e=new Date(n,t,i);return e.getFullYear()!==n||e.getMonth()!==t||e.getDate()!==i?null:e}function f(n){if(!n)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(n).trim());return t?k(Number(t[1]),Number(t[2])-1,Number(t[3])):null}function g(n,t){return new Date(n,t+1,0).getDate()}function A(n,t){let i=new Date(n.getFullYear(),n.getMonth()+t,1),e=i.getFullYear(),s=i.getMonth();return new Date(e,s,Math.min(n.getDate(),g(e,s)))}function _(n){try{let t=new Intl.Locale(n),i=t.getWeekInfo?.()??t.weekInfo;if(i)return i.firstDay%7}catch{}return 0}var D=new Map;function q(n,t){let i=`${n}:${t}`;if(D.has(i))return D.get(i);let e;try{let s=new Intl.DateTimeFormat(n,{weekday:t});e=Array.from({length:7},(r,a)=>s.format(new Date(2026,0,4+a)))}catch{e=t==="long"?["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}return D.set(i,e),e}function P(n,t){try{return new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"numeric"}).format(n)}catch{return c(n)}}function E(n,t){return!!(n&&t&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate())}var C=new Map;function z(n){if(C.has(n))return C.get(n);let t=new Map;M.forEach((i,e)=>{t.set(i,e),t.set(i.slice(0,3),e)});try{let i=new Intl.DateTimeFormat(n,{month:"long"}),e=new Intl.DateTimeFormat(n,{month:"short"});for(let s=0;s<12;s++){let r=new Date(2e3,s,1);t.set(i.format(r).toLowerCase(),s),t.set(e.format(r).toLowerCase().replace(".",""),s)}}catch{}return C.set(n,t),t}function x(n,t){let i=n.trim(),e={date:null,partial:null};if(!i)return e;if(/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(i)){let o=f(i.replace(/\//g,"-"));return o?{date:o,partial:null}:e}if(V(t)==="ja"){let o=I(i);if(o)return{date:o,partial:null}}let s=Y(i);if(s)return{date:s,partial:null};let r=z(t),a=i.match(/^([a-zÀ-ɏ]+)\.?\s+(\d{1,2}),?\s+(\d{4})$/i);if(a){let o=r.get(a[1].toLowerCase());if(o===void 0)return e;let h=k(Number(a[3]),o,Number(a[2]));return h?{date:h,partial:null}:e}if(a=i.match(/^(\d{1,2})\.?\s+([a-zÀ-ɏ]+)\.?\s+(\d{4})$/i),a){let o=r.get(a[2].toLowerCase());if(o===void 0)return e;let h=k(Number(a[3]),o,Number(a[1]));return h?{date:h,partial:null}:e}if(a=i.match(/^([a-zÀ-ɏ]+)\.?\s+(\d{4})$/i),a){let o=r.get(a[1].toLowerCase());if(o!==void 0)return{date:null,partial:{year:Number(a[2]),month:o}}}return e}function j(n){let t=new Map;if(!n)return t;for(let i of n.split(",")){let[e,s]=i.trim().split(":");e&&t.set(e,s||"")}return t}var N=class extends v{static formAssociated=!0;static get observedAttributes(){return["disabled","required"]}#a;#d=`dp${++U}`;#o=!1;#n;#t;#g;#v;#s;#y;#E;#f;#u=!1;#C=!1;#p="en-US";#c=null;#e=null;#i=new Date().getFullYear();#r=new Date().getMonth();#h=null;#l=null;#N=new Map;#S=new Map;#T;#x;#$=0;#O="";#F=!1;constructor(){super(),this.#a=this.attachInternals(),this._adoptInternals(this.#a)}setup(){let t=this.querySelector(':scope > input[type="date"]');if(!t)return!1;this.#n=t,this.#p=R(this.closest("[lang]")?.lang||navigator.language),this.#$=_(this.#p),this.#h=f(t.getAttribute("min")),this.#l=f(t.getAttribute("max")),this.#N=j(this.getAttribute("data-disabled-dates")),this.#S=j(this.getAttribute("data-highlight-dates"));let i=t.getAttribute("name");i&&(this.hasAttribute("name")||this.setAttribute("name",i),t.removeAttribute("name")),t.hasAttribute("disabled")&&(t.removeAttribute("disabled"),this.hasAttribute("disabled")||this.setAttribute("disabled",""));let e=`${this.#d}-no-form`,s=t.getAttribute("form");s&&s!==e&&!this.hasAttribute("form")&&this.setAttribute("form",s),t.setAttribute("form",e),this.#T===void 0&&(this.#T=t.defaultValue),this.#x!==void 0&&(t.value=this.#x,this.#x=void 0),this.#c=f(t.value);let r=new Date;return this.#l&&r>this.#l&&(r=this.#l),this.#h&&r<this.#h&&(r=this.#h),this.#e=this.#c||r,this.#i=this.#e.getFullYear(),this.#r=this.#e.getMonth(),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.listen(t,"click",this.#G),this.listen(t,"focus",this.#Y),this.#X(),this.#Q(),this.#o=!0,this.#J(),this.#k(),this.#P(!1),this.#D(),this.#C=F,this.#C&&this.#s.setAttribute("popover","manual"),this.listen(document,"click",this.#it),this.listen(this,"invalid",this.#W),this.#I(this.matches(":disabled")),!0}teardown(){this.#u=!1,this.removeAttribute("open"),window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A),this.#v?.remove(),this.#s?.remove(),this.#N=new Map,this.#S=new Map,this.#o=!1}attributeChangedCallback(t){this.#o&&(t==="disabled"&&this.#I(this.matches(":disabled")),t==="required"&&this.#D())}formDisabledCallback(t){this.#o&&this.#I(t)}#I(t){this.#t.disabled=t,this.#g.disabled=t,t&&this.#b()}#w(t,i){return this.dataset[`label${t}`]||i}#Y=()=>{this.#o&&!this.#t.disabled&&this.#t.focus()};#G=t=>{t.preventDefault(),this.#Y()};#J(){let t=new Set([...Array.from(this.#n.labels||[]),...Array.from(this.#a.labels||[])]),i=[];for(let a of t)a.id||(a.id=`${this.#d}-label-${i.length}`),i.push(a.id),this.listen(a,"click",this.#Y);let e=this.#t,s=i.join(" ")||this.#n.getAttribute("aria-labelledby")||this.getAttribute("aria-labelledby");s?e.setAttribute("aria-labelledby",s):e.setAttribute("aria-label",this.#n.getAttribute("aria-label")||this.getAttribute("aria-label")||this.#w("Input","Date"));let r=this.#n.getAttribute("aria-describedby");r&&e.setAttribute("aria-describedby",r)}#X(){this.#v=document.createElement("div"),this.#v.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",this.#w("Placeholder","Type a date\u2026")),this.#v.appendChild(this.#t),this.#g=document.createElement("button"),this.#g.type="button",this.#g.className="date-trigger-icon",this.#g.setAttribute("aria-label",this.#w("Toggle","Toggle calendar")),this.#g.setAttribute("tabindex","-1");let t=document.createElement("icon-wc");t.setAttribute("name","calendar"),t.setAttribute("size","sm"),t.setAttribute("aria-hidden","true"),this.#g.appendChild(t),this.#v.appendChild(this.#g),this.appendChild(this.#v),this.listen(this.#g,"click",i=>{i.stopPropagation(),this.#u?this.#b():this.#q(),this.#t.focus()}),this.listen(this.#t,"focus",()=>this.#t.select()),this.listen(this.#t,"input",this.#Z),this.listen(this.#t,"keydown",this.#tt),this.listen(this.#t,"blur",this.#et)}#Q(){let t=`${this.#d}-calendar`;this.#s=document.createElement("div"),this.#s.className="calendar",this.#s.id=t,this.#s.setAttribute("role","dialog"),this.#s.setAttribute("aria-modal","false"),this.#s.setAttribute("aria-label",this.#w("Dialog","Choose date")),this.#s.hidden=!0,this.#t.setAttribute("aria-controls",t);let i=document.createElement("div");i.className="calendar-header";let e=document.createElement("button");e.type="button",e.className="calendar-nav",e.setAttribute("aria-label",this.#w("Prev","Previous month"));let s=document.createElement("icon-wc");s.setAttribute("name","chevron-left"),s.setAttribute("size","sm"),s.setAttribute("aria-hidden","true"),e.appendChild(s);let r=document.createElement("span");r.className="calendar-title",r.id=`${t}-title`,r.setAttribute("aria-live","polite"),this.#E=document.createElement("span"),this.#E.className="calendar-month",this.#f=document.createElement("select"),this.#f.className="calendar-year",this.#f.setAttribute("aria-label",this.#w("Year","Year")),this.#U(),r.appendChild(this.#E),r.appendChild(this.#f);let a=document.createElement("button");a.type="button",a.className="calendar-nav",a.setAttribute("aria-label",this.#w("Next","Next month"));let o=document.createElement("icon-wc");o.setAttribute("name","chevron-right"),o.setAttribute("size","sm"),o.setAttribute("aria-hidden","true"),a.appendChild(o),i.appendChild(e),i.appendChild(r),i.appendChild(a),this.#s.appendChild(i);let h=document.createElement("table");h.setAttribute("role","grid"),h.setAttribute("aria-labelledby",`${t}-title`);let d=q(this.#p,"short"),u=q(this.#p,"long"),l=document.createElement("thead"),b=document.createElement("tr");for(let p=0;p<7;p++){let y=(this.#$+p)%7,w=document.createElement("th");w.setAttribute("abbr",u[y]),w.setAttribute("scope","col"),w.textContent=d[y],b.appendChild(w)}l.appendChild(b),h.appendChild(l),this.#y=document.createElement("tbody"),h.appendChild(this.#y),this.#s.appendChild(h),this.appendChild(this.#s),this.#m(),this.listen(e,"click",()=>this.#_(-1)),this.listen(a,"click",()=>this.#_(1)),this.listen(this.#f,"change",()=>{this.#i=Number(this.#f.value);let p=g(this.#i,this.#r),y=Math.min(this.#e?.getDate()??1,p);this.#e=new Date(this.#i,this.#r,y),this.#m()}),this.listen(this.#y,"click",this.#st),this.listen(this.#s,"keydown",this.#nt)}#m(){try{this.#E.textContent=new Intl.DateTimeFormat(this.#p,{month:"long"}).format(new Date(this.#i,this.#r,1))}catch{this.#E.textContent=M[this.#r].charAt(0).toUpperCase()+M[this.#r].slice(1)}this.#f.querySelector(`option[value="${this.#i}"]`)||this.#U(),this.#f.value=String(this.#i),this.#y.replaceChildren();let t=g(this.#i,this.#r),e=(new Date(this.#i,this.#r,1).getDay()-this.#$+7)%7,s=new Date,r=document.createElement("tr");for(let o=0;o<e;o++)r.appendChild(document.createElement("td"));for(let o=1;o<=t;o++){let h=new Date(this.#i,this.#r,o),d=c(h),u=document.createElement("td"),l=document.createElement("button");l.type="button",l.setAttribute("data-date",d),l.textContent=String(o),E(h,s)&&l.setAttribute("aria-current","date");let b=E(h,this.#c);u.setAttribute("aria-selected",String(b));let p=this.#B(h,d);p.disabled&&(l.setAttribute("aria-disabled","true"),p.reason&&l.setAttribute("data-disabled-reason",p.reason)),this.#S.has(d)&&l.setAttribute("data-highlight",this.#S.get(d)||""),E(h,this.#e)?(l.setAttribute("tabindex","0"),b||l.setAttribute("data-focused","")):l.setAttribute("tabindex","-1"),u.appendChild(l),r.appendChild(u),(e+o)%7===0&&(this.#y.appendChild(r),r=document.createElement("tr"))}let a=(e+t)%7;if(a>0){for(let o=a;o<7;o++)r.appendChild(document.createElement("td"));this.#y.appendChild(r)}}#L(t){return this.#B(t,c(t)).disabled}#B(t,i){return this.#N.has(i)?{disabled:!0,reason:this.#N.get(i)}:this.#h&&t<this.#h?{disabled:!0,reason:null}:this.#l&&t>this.#l?{disabled:!0,reason:null}:{disabled:!1,reason:null}}#U(){this.#f.replaceChildren();let t=new Date().getFullYear(),i=this.#h?this.#h.getFullYear():t-100,e=this.#l?this.#l.getFullYear():t+10;i=Math.min(i,this.#i),e=Math.max(e,this.#i);for(let s=i;s<=e;s++){let r=document.createElement("option");r.value=String(s),r.textContent=String(s),this.#f.appendChild(r)}}#_(t){let i=this.#e??new Date(this.#i,this.#r,1),e=new Date(this.#i,this.#r,Math.min(i.getDate(),g(this.#i,this.#r)));this.#e=A(e,t),this.#i=this.#e.getFullYear(),this.#r=this.#e.getMonth(),this.#m(),this.#R(this.#e)}#M(t,i){if(t&&this.#L(t))return!1;let e=this.value,s=t?c(t):"";return this.#c=t,t&&(this.#e=t),this.#k(),s===e?!1:(this.#P(),this.#D(),t&&i==="api"&&(this.#i=t.getFullYear(),this.#r=t.getMonth()),(this.#u||i==="api")&&this.#m(),this.dispatchEvent(new CustomEvent("date-picker:change",{bubbles:!0,detail:{value:s,date:t?new Date(t):null,source:i}})),!0)}#V(t,i){this.#L(t)||(this.#M(t,i),this.#b(),this.#t.focus())}#R(t){let i=this.#y.querySelector(`[data-date="${c(t)}"]`);if(i){for(let e of this.#y.querySelectorAll("button[data-date]"))e.setAttribute("tabindex",e===i?"0":"-1"),e!==i&&e.removeAttribute("data-focused");i.closest("td")?.getAttribute("aria-selected")!=="true"&&i.setAttribute("data-focused",""),i.focus()}}#k(){this.#t.value=this.#c?P(this.#c,this.#p):""}#q(){if(!(this.#u||this.#t.disabled)){if(this.#u=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#s.hidden=!1,this.#e&&(this.#i=this.#e.getFullYear(),this.#r=this.#e.getMonth()),this.#m(),this.#C){try{this.#s.showPopover()}catch{}this.#z(),window.addEventListener("scroll",this.#A,{capture:!0,passive:!0}),window.addEventListener("resize",this.#A,{passive:!0})}this.dispatchEvent(new CustomEvent("date-picker:open",{bubbles:!0}))}}#b(){if(this.#u){if(this.#u=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#s.hidden=!0,this.#C){try{this.#s.hidePopover()}catch{}window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}this.dispatchEvent(new CustomEvent("date-picker:close",{bubbles:!0}))}}#z(){if(!this.#C)return;let t=this.#v.getBoundingClientRect(),i=this.#s.getBoundingClientRect(),e=4,s=8,r=window.innerHeight,a=window.innerWidth,o=r-t.bottom-s,h=t.top-s,d;o<i.height&&h>o?(d=t.top-i.height-e,this.#s.dataset.placement="top"):(d=t.bottom+e,delete this.#s.dataset.placement);let u=t.left;u+i.width>a-s&&(u=a-i.width-s),u<s&&(u=s),this.#s.style.setProperty("--calendar-top",`${d}px`),this.#s.style.setProperty("--calendar-left",`${u}px`)}#A=()=>{this.#u&&this.#z()};#Z=()=>{let t=this.#t.value,{date:i,partial:e}=x(t,this.#p);if(i)this.#e=i,this.#i=i.getFullYear(),this.#r=i.getMonth(),this.#m();else if(e){this.#i=e.year,this.#r=e.month;let s=g(e.year,e.month),r=Math.min(this.#e?.getDate()??1,s);this.#e=new Date(e.year,e.month,r),this.#m()}!this.#u&&t.length>0&&this.#q()};#tt=t=>{switch(t.key){case"Enter":{t.preventDefault(),t.stopPropagation();let i=this.#t.value.trim();if(!i){this.#M(null,"keyboard"),this.#b();return}let{date:e}=x(i,this.#p);e&&!this.#L(e)&&this.#V(e,"keyboard");return}case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.#u||this.#q(),requestAnimationFrame(()=>{this.#e&&this.#R(this.#e)});return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#u&&this.#b(),this.#k();return;case"Tab":this.#u&&this.#b();return}};#et=t=>{if(t.relatedTarget instanceof Node&&this.contains(t.relatedTarget))return;let i=this.#t.value.trim();if(!i)this.#M(null,"keyboard");else{let{date:e}=x(i,this.#p);e&&!this.#L(e)&&this.#M(e,"keyboard")}this.#k(),this.#u&&this.#b(),this.#W()};#W=()=>{this.#o&&(this.#F||(this.#F=!0,this.#D()),this.#n.dispatchEvent(new Event("blur",{bubbles:!0})))};#it=t=>{this.#u&&!this.contains(t.target)&&this.#b()};#st=t=>{let e=t.target?.closest("button[data-date]");if(!e||e.getAttribute("aria-disabled")==="true")return;let s=f(e.getAttribute("data-date"));s&&this.#V(s,"pointer")};#nt=t=>{if(t.key==="Tab"){this.#b();return}let i=t.target instanceof Element&&this.#y.contains(t.target),e=this.#e;if(!e)return;let s,r=(e.getDay()-this.#$+7)%7;switch(t.key){case"ArrowRight":s=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1);break;case"ArrowLeft":s=new Date(e.getFullYear(),e.getMonth(),e.getDate()-1);break;case"ArrowDown":s=new Date(e.getFullYear(),e.getMonth(),e.getDate()+7);break;case"ArrowUp":s=new Date(e.getFullYear(),e.getMonth(),e.getDate()-7);break;case"PageDown":s=A(e,t.shiftKey?12:1);break;case"PageUp":s=A(e,t.shiftKey?-12:-1);break;case"Home":s=new Date(e.getFullYear(),e.getMonth(),e.getDate()-r);break;case"End":s=new Date(e.getFullYear(),e.getMonth(),e.getDate()+(6-r));break;case"Enter":case" ":if(!i)return;t.preventDefault(),t.stopPropagation(),this.#V(e,"keyboard");return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#b(),this.#t.focus();return;default:return}i&&(t.preventDefault(),t.stopPropagation(),this.#h&&s<this.#h&&(s=this.#h),this.#l&&s>this.#l&&(s=this.#l),this.#e=s,(s.getMonth()!==this.#r||s.getFullYear()!==this.#i)&&(this.#r=s.getMonth(),this.#i=s.getFullYear(),this.#m()),this.#R(s))};#P(t=!0){let i=this.#c?c(this.#c):"";this.#a.setFormValue(i||null),this.#n.value=i,t&&this.#n.dispatchEvent(new Event("input",{bubbles:!0}))}#j(t,i,e,s=null){let r=this.#n.getAttribute(`data-message-${t.toLowerCase()}`)??this.#w(i,e);return s?r.replaceAll("{date}",P(s,this.#p)):r}#D(){if(!this.#o)return!1;let t=this.hasAttribute("required")||this.#n.hasAttribute("required");t?this.#t.setAttribute("aria-required","true"):this.#t.removeAttribute("aria-required");let i=this.#c,e={},s="";t&&!i?(e={valueMissing:!0},s=this.#j("valueMissing","Required","Please select a date")):i&&this.#h&&i<this.#h?(e={rangeUnderflow:!0},s=this.#j("rangeUnderflow","RangeUnderflow","Choose a date on or after {date}",this.#h)):i&&this.#l&&i>this.#l&&(e={rangeOverflow:!0},s=this.#j("rangeOverflow","RangeOverflow","Choose a date on or before {date}",this.#l));let r=this.#a.validationMessage;return s?this.#a.setValidity(e,s,this.#t):this.#a.setValidity({}),s&&(i||this.#F)?this.#t.setAttribute("aria-invalid","true"):this.#t.removeAttribute("aria-invalid"),(this.#n.validationMessage===this.#O||!this.#n.validity.customError)&&(this.#n.setCustomValidity(s),this.#O=s),r!==s}#K(){this.#o&&(this.#m(),this.#D()&&this.#n.dispatchEvent(new Event("input",{bubbles:!0})))}#H(t){let i=t||new Date;this.#c=t,this.#e=i,this.#i=i.getFullYear(),this.#r=i.getMonth(),this.#k(),this.#P(),this.#D(),this.#m()}formResetCallback(){this.#o&&(this.#F=!1,this.#H(f(this.#T)))}formStateRestoreCallback(t){!this.#o||typeof t!="string"||this.#H(f(t))}get form(){return this.#a.form}get validity(){return this.#a.validity}get validationMessage(){return this.#a.validationMessage}get willValidate(){return this.#a.willValidate}checkValidity(){return this.#a.checkValidity()}reportValidity(){return this.#a.reportValidity()}get value(){return this.#o?this.#c?c(this.#c):"":this.#x??""}set value(t){let i=t==null?"":String(t).trim(),e=i?f(i):null;if(!(i&&!e)){if(!this.#o){this.#x=i;return}this.#M(e,"api")}}get min(){return this.#h?c(this.#h):""}set min(t){this.#h=f(t),this.#n&&(this.#h?this.#n.setAttribute("min",c(this.#h)):this.#n.removeAttribute("min")),this.#K()}get max(){return this.#l?c(this.#l):""}set max(t){this.#l=f(t),this.#n&&(this.#l?this.#n.setAttribute("max",c(this.#l)):this.#n.removeAttribute("max")),this.#K()}};$("date-picker",N);export{N as DatePicker};
|
|
1
|
+
var G=window.matchMedia("(prefers-reduced-motion: reduce)");var $=new Map;function T(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=$.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}$.set(n,s),customElements.define(n,t)}var w=class extends HTMLElement{#a=[];#d;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#a)t();this.#a=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#a.push(()=>t.removeEventListener(e,i,s))}_reinit(){for(let t of this.#a)t();this.#a=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#d||(this.#d=this.attachInternals());let i=this.#d.states;try{e?i.add(t):i.delete(t)}catch{let s=`--${t}`;e?i.add(s):i.delete(s)}}_adoptInternals(t){this.#d||(this.#d=t)}#o(){return this.constructor.formAssociated&&this.#d?this.#d:null}get validity(){return this.#o()?.validity}get validationMessage(){return this.#o()?.validationMessage??""}get willValidate(){return this.#o()?.willValidate??!1}get form(){return this.#o()?.form??null}checkValidity(){return this.#o()?.checkValidity()??!0}reportValidity(){return this.#o()?.reportValidity()??!0}};var F="popover"in HTMLElement.prototype;var y=[{ja:"\u4EE4\u548C",latin:"R",start:[2019,5,1]},{ja:"\u5E73\u6210",latin:"H",start:[1989,1,8]},{ja:"\u662D\u548C",latin:"S",start:[1926,12,25]},{ja:"\u5927\u6B63",latin:"T",start:[1912,7,30]},{ja:"\u660E\u6CBB",latin:"M",start:[1868,10,23]}],_=new RegExp(`^(?:(${y.map(n=>n.ja).join("|")})|(${y.map(n=>n.latin).join("|")}))`+String.raw`\s*(元|\d{1,2})年?[/.\-]?\s*(\d{1,2})月?[/.\-]?\s*(\d{1,2})日?$`,"i"),R=/^(\d{4})年(\d{1,2})月(\d{1,2})日?$/;function L(n){return n.trim().replace(/[0-9]/g,t=>String(t.charCodeAt(0)-65296)).replace(/\s+/g,"")}function I(n,t,e){let i=new Date(2e3,t-1,e);return i.setFullYear(n),i.getMonth()===t-1&&i.getDate()===e?i:null}function P(n){let t=L(n).match(_);if(!t)return null;let e=t[1]?y.find(a=>a.ja===t[1]):y.find(a=>a.latin.toUpperCase()===t[2].toUpperCase());if(!e)return null;let i=t[3]==="\u5143"?1:Number(t[3]);if(i<1)return null;let s=I(e.start[0]+i-1,Number(t[4]),Number(t[5]));if(!s||s<new Date(e.start[0],e.start[1]-1,e.start[2]))return null;let r=y.indexOf(e);if(r>0){let a=y[r-1].start;if(s>=new Date(a[0],a[1]-1,a[2]))return null}return s}function Y(n){let t=L(n).match(R);return t?I(Number(t[1]),Number(t[2]),Number(t[3])):null}function V(n){return n.split("-")[0].toLowerCase()}function j(n,t="en-US"){try{if(n)return Intl.getCanonicalLocales(n),n}catch{}try{return Intl.getCanonicalLocales(t),t}catch{return"en-US"}}var M=["january","february","march","april","may","june","july","august","september","october","november","december"],N=0;function d(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 k(n,t,e){if(!Number.isInteger(n)||!Number.isInteger(t)||!Number.isInteger(e))return null;let i=new Date(n,t,e);return i.getFullYear()!==n||i.getMonth()!==t||i.getDate()!==e?null:i}function f(n){if(!n)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(n).trim());return t?k(Number(t[1]),Number(t[2])-1,Number(t[3])):null}function v(n,t){return new Date(n,t+1,0).getDate()}function A(n,t){let e=new Date(n.getFullYear(),n.getMonth()+t,1),i=e.getFullYear(),s=e.getMonth();return new Date(i,s,Math.min(n.getDate(),v(i,s)))}function H(n){try{let t=new Intl.Locale(n),e=t.getWeekInfo?.()??t.weekInfo;if(e)return e.firstDay%7}catch{}return 0}var E=new Map;function q(n,t){let e=`${n}:${t}`;if(E.has(e))return E.get(e);let i;try{let s=new Intl.DateTimeFormat(n,{weekday:t});i=Array.from({length:7},(r,a)=>s.format(new Date(2026,0,4+a)))}catch{i=t==="long"?["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}return E.set(e,i),i}function B(n,t){try{return new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"numeric"}).format(n)}catch{return d(n)}}function C(n,t){return!!(n&&t&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate())}var D=new Map;function U(n){if(D.has(n))return D.get(n);let t=new Map;M.forEach((e,i)=>{t.set(e,i),t.set(e.slice(0,3),i)});try{let e=new Intl.DateTimeFormat(n,{month:"long"}),i=new Intl.DateTimeFormat(n,{month:"short"});for(let s=0;s<12;s++){let r=new Date(2e3,s,1);t.set(e.format(r).toLowerCase(),s),t.set(i.format(r).toLowerCase().replace(".",""),s)}}catch{}return D.set(n,t),t}function x(n,t){let e=n.trim(),i={date:null,partial:null};if(!e)return i;if(/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(e)){let o=f(e.replace(/\//g,"-"));return o?{date:o,partial:null}:i}if(V(t)==="ja"){let o=P(e);if(o)return{date:o,partial:null}}let s=Y(e);if(s)return{date:s,partial:null};let r=U(t),a=e.match(/^([a-zÀ-ɏ]+)\.?\s+(\d{1,2}),?\s+(\d{4})$/i);if(a){let o=r.get(a[1].toLowerCase());if(o===void 0)return i;let h=k(Number(a[3]),o,Number(a[2]));return h?{date:h,partial:null}:i}if(a=e.match(/^(\d{1,2})\.?\s+([a-zÀ-ɏ]+)\.?\s+(\d{4})$/i),a){let o=r.get(a[2].toLowerCase());if(o===void 0)return i;let h=k(Number(a[3]),o,Number(a[1]));return h?{date:h,partial:null}:i}if(a=e.match(/^([a-zÀ-ɏ]+)\.?\s+(\d{4})$/i),a){let o=r.get(a[1].toLowerCase());if(o!==void 0)return{date:null,partial:{year:Number(a[2]),month:o}}}return i}function O(n){let t=new Map;if(!n)return t;for(let e of n.split(",")){let[i,s]=e.trim().split(":");i&&t.set(i,s||"")}return t}var S=class extends w{static formAssociated=!0;static get observedAttributes(){return["disabled","required"]}#a;#d=`dp${++N}`;#o=!1;#r;#t;#b;#A;#i;#g;#v;#p;#c=!1;#D=!1;#f="en-US";#u=null;#s=null;#e=new Date().getFullYear();#n=new Date().getMonth();#l=null;#h=null;#S=new Map;#$=new Map;#I;#x;#T=0;#_="";#F=!1;constructor(){super(),this.#a=this.attachInternals(),this._adoptInternals(this.#a)}setup(){let t=this.querySelector(':scope > input[type="date"]');if(!t)return!1;this.#r=t,this.#f=j(this.closest("[lang]")?.lang||navigator.language),this.#T=H(this.#f),this.#l=f(t.getAttribute("min")),this.#h=f(t.getAttribute("max")),this.#S=O(this.getAttribute("data-disabled-dates")),this.#$=O(this.getAttribute("data-highlight-dates"));let e=t.getAttribute("name");e&&(this.hasAttribute("name")||this.setAttribute("name",e),t.removeAttribute("name")),t.hasAttribute("disabled")&&(t.removeAttribute("disabled"),this.hasAttribute("disabled")||this.setAttribute("disabled",""));let i=`${this.#d}-no-form`,s=t.getAttribute("form");s&&s!==i&&!this.hasAttribute("form")&&this.setAttribute("form",s),t.setAttribute("form",i),this.#I===void 0&&(this.#I=t.defaultValue),this.#x!==void 0&&(t.value=this.#x,this.#x=void 0),this.#u=f(t.value);let r=new Date;return this.#h&&r>this.#h&&(r=this.#h),this.#l&&r<this.#l&&(r=this.#l),this.#s=this.#u||r,this.#e=this.#s.getFullYear(),this.#n=this.#s.getMonth(),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.listen(t,"click",this.#G),this.listen(t,"focus",this.#Y),this.#X(),this.#Q(),this.#o=!0,this.#J(),this.#k(),this.#B(!1),this.#C(),this.#D=F,this.#D&&this.#i.setAttribute("popover","manual"),this.listen(document,"click",this.#it),this.listen(this,"invalid",this.#z),this.#P(this.matches(":disabled")),!0}teardown(){this.#c=!1,this.removeAttribute("open"),window.removeEventListener("scroll",this.#E,{capture:!0}),window.removeEventListener("resize",this.#E),this.#A?.remove(),this.#i?.remove(),this.#S=new Map,this.#$=new Map,this.#o=!1}attributeChangedCallback(t){this.#o&&(t==="disabled"&&this.#P(this.matches(":disabled")),t==="required"&&this.#C())}formDisabledCallback(t){this.#o&&this.#P(t)}#P(t){this.#t.disabled=t,this.#b.disabled=t,t&&this.#y()}#w(t,e){return this.dataset[`label${t}`]||e}#Y=()=>{this.#o&&!this.#t.disabled&&this.#t.focus()};#G=t=>{t.preventDefault(),this.#Y()};#J(){let t=new Set([...Array.from(this.#r.labels||[]),...Array.from(this.#a.labels||[])]),e=[];for(let a of t)a.id||(a.id=`${this.#d}-label-${e.length}`),e.push(a.id),this.listen(a,"click",this.#Y);let i=this.#t,s=e.join(" ")||this.#r.getAttribute("aria-labelledby")||this.getAttribute("aria-labelledby");s?i.setAttribute("aria-labelledby",s):i.setAttribute("aria-label",this.#r.getAttribute("aria-label")||this.getAttribute("aria-label")||this.#w("Input","Date"));let r=this.#r.getAttribute("aria-describedby");r&&i.setAttribute("aria-describedby",r)}#X(){this.#A=document.createElement("div"),this.#A.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",this.#w("Placeholder","Type a date\u2026")),this.#A.appendChild(this.#t),this.#b=document.createElement("button"),this.#b.type="button",this.#b.className="date-trigger-icon",this.#b.setAttribute("aria-label",this.#w("Toggle","Toggle calendar")),this.#b.setAttribute("tabindex","-1");let t=document.createElement("icon-wc");t.setAttribute("name","calendar"),t.setAttribute("size","sm"),t.setAttribute("aria-hidden","true"),this.#b.appendChild(t),this.#A.appendChild(this.#b),this.appendChild(this.#A),this.listen(this.#b,"click",e=>{e.stopPropagation(),this.#c?this.#y():this.#q(),this.#t.focus()}),this.listen(this.#t,"focus",()=>this.#t.select()),this.listen(this.#t,"input",this.#Z),this.listen(this.#t,"keydown",this.#tt),this.listen(this.#t,"blur",this.#et)}#Q(){let t=`${this.#d}-calendar`;this.#i=document.createElement("div"),this.#i.className="calendar",this.#i.id=t,this.#i.setAttribute("role","dialog"),this.#i.setAttribute("aria-modal","false"),this.#i.setAttribute("aria-label",this.#w("Dialog","Choose date")),this.#i.hidden=!0,this.#t.setAttribute("aria-controls",t);let e=document.createElement("div");e.className="calendar-header";let i=document.createElement("button");i.type="button",i.className="calendar-nav",i.setAttribute("aria-label",this.#w("Prev","Previous month"));let s=document.createElement("icon-wc");s.setAttribute("name","chevron-left"),s.setAttribute("size","sm"),s.setAttribute("aria-hidden","true"),i.appendChild(s);let r=document.createElement("span");r.className="calendar-title",this.#v=document.createElement("span"),this.#v.className="calendar-month",this.#v.id=`${t}-title`,this.#v.setAttribute("aria-live","polite"),this.#v.setAttribute("aria-atomic","true"),this.#p=document.createElement("select"),this.#p.className="calendar-year",this.#p.setAttribute("aria-label",this.#w("Year","Year")),this.#N(),r.appendChild(this.#v),r.appendChild(this.#p);let a=document.createElement("button");a.type="button",a.className="calendar-nav",a.setAttribute("aria-label",this.#w("Next","Next month"));let o=document.createElement("icon-wc");o.setAttribute("name","chevron-right"),o.setAttribute("size","sm"),o.setAttribute("aria-hidden","true"),a.appendChild(o),e.appendChild(i),e.appendChild(r),e.appendChild(a),this.#i.appendChild(e);let h=document.createElement("table");h.setAttribute("role","grid"),h.setAttribute("aria-labelledby",`${t}-title`);let l=q(this.#f,"short"),c=q(this.#f,"long"),m=document.createElement("thead"),g=document.createElement("tr");for(let u=0;u<7;u++){let b=(this.#T+u)%7,p=document.createElement("th");p.setAttribute("abbr",c[b]),p.setAttribute("scope","col"),p.textContent=l[b],g.appendChild(p)}m.appendChild(g),h.appendChild(m),this.#g=document.createElement("tbody"),h.appendChild(this.#g),this.#i.appendChild(h),this.appendChild(this.#i),this.#m(),this.listen(i,"click",()=>this.#H(-1)),this.listen(a,"click",()=>this.#H(1)),this.listen(this.#p,"change",()=>{this.#e=Number(this.#p.value);let u=v(this.#e,this.#n),b=Math.min(this.#s?.getDate()??1,u);this.#s=new Date(this.#e,this.#n,b),this.#m()}),this.listen(this.#g,"click",this.#st),this.listen(this.#i,"keydown",this.#nt)}#m(){let t;try{t=new Intl.DateTimeFormat(this.#f,{month:"long"}).format(new Date(this.#e,this.#n,1))}catch{t=M[this.#n].charAt(0).toUpperCase()+M[this.#n].slice(1)}let e;try{e=new Intl.DateTimeFormat(this.#f,{month:"long",year:"numeric"}).format(new Date(this.#e,this.#n,1))}catch{e=`${t} ${this.#e}`}if(this.#v.lastElementChild?.textContent!==e){let l=document.createElement("span");l.setAttribute("aria-hidden","true"),l.textContent=t;let c=document.createElement("span");c.className="visually-hidden",c.textContent=e,this.#v.replaceChildren(l,c)}this.#p.querySelector(`option[value="${this.#e}"]`)||this.#N(),this.#p.value=String(this.#e),this.#g.replaceChildren();let i=v(this.#e,this.#n),r=(new Date(this.#e,this.#n,1).getDay()-this.#T+7)%7,a=new Date,o=document.createElement("tr");for(let l=0;l<r;l++)o.appendChild(document.createElement("td"));for(let l=1;l<=i;l++){let c=new Date(this.#e,this.#n,l),m=d(c),g=document.createElement("td"),u=document.createElement("button");u.type="button",u.setAttribute("data-date",m),u.textContent=String(l),C(c,a)&&u.setAttribute("aria-current","date");let b=C(c,this.#u);g.setAttribute("aria-selected",String(b));let p=this.#R(c,m);p.disabled&&(u.setAttribute("aria-disabled","true"),p.reason&&u.setAttribute("data-disabled-reason",p.reason)),this.#$.has(m)&&u.setAttribute("data-highlight",this.#$.get(m)||""),C(c,this.#s)?(u.setAttribute("tabindex","0"),b||u.setAttribute("data-focused","")):u.setAttribute("tabindex","-1"),g.appendChild(u),o.appendChild(g),(r+l)%7===0&&(this.#g.appendChild(o),o=document.createElement("tr"))}let h=(r+i)%7;if(h>0){for(let l=h;l<7;l++)o.appendChild(document.createElement("td"));this.#g.appendChild(o)}}#L(t){return this.#R(t,d(t)).disabled}#R(t,e){return this.#S.has(e)?{disabled:!0,reason:this.#S.get(e)}:this.#l&&t<this.#l?{disabled:!0,reason:null}:this.#h&&t>this.#h?{disabled:!0,reason:null}:{disabled:!1,reason:null}}#N(){this.#p.replaceChildren();let t=new Date().getFullYear(),e=this.#l?this.#l.getFullYear():t-100,i=this.#h?this.#h.getFullYear():t+10;e=Math.min(e,this.#e),i=Math.max(i,this.#e);for(let s=e;s<=i;s++){let r=document.createElement("option");r.value=String(s),r.textContent=String(s),this.#p.appendChild(r)}}#H(t){let e=this.#s??new Date(this.#e,this.#n,1),i=new Date(this.#e,this.#n,Math.min(e.getDate(),v(this.#e,this.#n)));this.#s=A(i,t),this.#e=this.#s.getFullYear(),this.#n=this.#s.getMonth(),this.#m();let s=document.activeElement;s?.matches(".calendar-nav:focus-visible")&&this.#i.contains(s)||this.#j(this.#s)}#M(t,e){if(t&&this.#L(t))return!1;let i=this.value,s=t?d(t):"";return this.#u=t,t&&(this.#s=t),this.#k(),s===i?!1:(this.#B(),this.#C(),t&&e==="api"&&(this.#e=t.getFullYear(),this.#n=t.getMonth()),(this.#c||e==="api")&&this.#m(),this.dispatchEvent(new CustomEvent("date-picker:change",{bubbles:!0,detail:{value:s,date:t?new Date(t):null,source:e}})),!0)}#V(t,e){this.#L(t)||(this.#M(t,e),this.#y(),this.#t.focus())}#j(t){let e=this.#g.querySelector(`[data-date="${d(t)}"]`);if(e){for(let i of this.#g.querySelectorAll("button[data-date]"))i.setAttribute("tabindex",i===e?"0":"-1"),i!==e&&i.removeAttribute("data-focused");e.closest("td")?.getAttribute("aria-selected")!=="true"&&e.setAttribute("data-focused",""),e.focus()}}#k(){this.#t.value=this.#u?B(this.#u,this.#f):""}#q(){if(!(this.#c||this.#t.disabled)){if(this.#c=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#i.hidden=!1,this.#s&&(this.#e=this.#s.getFullYear(),this.#n=this.#s.getMonth()),this.#m(),this.#D){try{this.#i.showPopover()}catch{}this.#U(),window.addEventListener("scroll",this.#E,{capture:!0,passive:!0}),window.addEventListener("resize",this.#E,{passive:!0})}this.dispatchEvent(new CustomEvent("date-picker:open",{bubbles:!0}))}}#y(){if(this.#c){if(this.#c=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#i.hidden=!0,this.#D){try{this.#i.hidePopover()}catch{}window.removeEventListener("scroll",this.#E,{capture:!0}),window.removeEventListener("resize",this.#E)}this.dispatchEvent(new CustomEvent("date-picker:close",{bubbles:!0}))}}#U(){if(!this.#D)return;let t=this.#A.getBoundingClientRect(),e=this.#i.getBoundingClientRect(),i=4,s=8,r=window.innerHeight,a=window.innerWidth,o=r-t.bottom-s,h=t.top-s,l;o<e.height&&h>o?(l=t.top-e.height-i,this.#i.dataset.placement="top"):(l=t.bottom+i,delete this.#i.dataset.placement);let c=t.left;c+e.width>a-s&&(c=a-e.width-s),c<s&&(c=s),this.#i.style.setProperty("--calendar-top",`${l}px`),this.#i.style.setProperty("--calendar-left",`${c}px`)}#E=()=>{this.#c&&this.#U()};#Z=()=>{let t=this.#t.value,{date:e,partial:i}=x(t,this.#f);if(e)this.#s=e,this.#e=e.getFullYear(),this.#n=e.getMonth(),this.#m();else if(i){this.#e=i.year,this.#n=i.month;let s=v(i.year,i.month),r=Math.min(this.#s?.getDate()??1,s);this.#s=new Date(i.year,i.month,r),this.#m()}!this.#c&&t.length>0&&this.#q()};#tt=t=>{switch(t.key){case"Enter":{t.preventDefault(),t.stopPropagation();let e=this.#t.value.trim();if(!e){this.#M(null,"keyboard"),this.#y();return}let{date:i}=x(e,this.#f);i&&!this.#L(i)&&this.#V(i,"keyboard");return}case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.#c||this.#q(),requestAnimationFrame(()=>{this.#s&&this.#j(this.#s)});return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#c&&this.#y(),this.#k();return;case"Tab":this.#c&&this.#y();return}};#et=t=>{if(t.relatedTarget instanceof Node&&this.contains(t.relatedTarget))return;let e=this.#t.value.trim();if(!e)this.#M(null,"keyboard");else{let{date:i}=x(e,this.#f);i&&!this.#L(i)&&this.#M(i,"keyboard")}this.#k(),this.#c&&this.#y(),this.#z()};#z=()=>{this.#o&&(this.#F||(this.#F=!0,this.#C()),this.#r.dispatchEvent(new Event("blur",{bubbles:!0})))};#it=t=>{this.#c&&!this.contains(t.target)&&this.#y()};#st=t=>{let i=t.target?.closest("button[data-date]");if(!i||i.getAttribute("aria-disabled")==="true")return;let s=f(i.getAttribute("data-date"));s&&this.#V(s,"pointer")};#nt=t=>{if(t.key==="Tab"){let o=[...this.#i.querySelectorAll('.calendar-header button, .calendar-header select, tbody button[tabindex="0"]')];if(!o.length)return;let h=o.indexOf(document.activeElement),l=h<0?0:(h+(t.shiftKey?-1:1)+o.length)%o.length;t.preventDefault(),o[l].focus();return}let e=t.target instanceof Element&&this.#g.contains(t.target),i=this.#s;if(!i)return;let s,r=(i.getDay()-this.#T+7)%7,a=getComputedStyle(this).direction==="rtl"?-1:1;switch(t.key){case"ArrowRight":s=new Date(i.getFullYear(),i.getMonth(),i.getDate()+a);break;case"ArrowLeft":s=new Date(i.getFullYear(),i.getMonth(),i.getDate()-a);break;case"ArrowDown":s=new Date(i.getFullYear(),i.getMonth(),i.getDate()+7);break;case"ArrowUp":s=new Date(i.getFullYear(),i.getMonth(),i.getDate()-7);break;case"PageDown":s=A(i,t.shiftKey?12:1);break;case"PageUp":s=A(i,t.shiftKey?-12:-1);break;case"Home":s=new Date(i.getFullYear(),i.getMonth(),i.getDate()-r);break;case"End":s=new Date(i.getFullYear(),i.getMonth(),i.getDate()+(6-r));break;case"Enter":case" ":if(!e)return;t.preventDefault(),t.stopPropagation(),this.#V(i,"keyboard");return;case"Escape":t.preventDefault(),t.stopPropagation(),this.#y(),this.#t.focus();return;default:return}e&&(t.preventDefault(),t.stopPropagation(),this.#l&&s<this.#l&&(s=this.#l),this.#h&&s>this.#h&&(s=this.#h),this.#s=s,(s.getMonth()!==this.#n||s.getFullYear()!==this.#e)&&(this.#n=s.getMonth(),this.#e=s.getFullYear(),this.#m()),this.#j(s))};#B(t=!0){let e=this.#u?d(this.#u):"";this.#a.setFormValue(e||null),this.#r.value=e,t&&this.#r.dispatchEvent(new Event("input",{bubbles:!0}))}#O(t,e,i,s=null){let r=this.#r.getAttribute(`data-message-${t.toLowerCase()}`)??this.#w(e,i);return s?r.replaceAll("{date}",B(s,this.#f)):r}#C(){if(!this.#o)return!1;let t=this.hasAttribute("required")||this.#r.hasAttribute("required");t?this.#t.setAttribute("aria-required","true"):this.#t.removeAttribute("aria-required");let e=this.#u,i={},s="";t&&!e?(i={valueMissing:!0},s=this.#O("valueMissing","Required","Please select a date")):e&&this.#l&&e<this.#l?(i={rangeUnderflow:!0},s=this.#O("rangeUnderflow","RangeUnderflow","Choose a date on or after {date}",this.#l)):e&&this.#h&&e>this.#h&&(i={rangeOverflow:!0},s=this.#O("rangeOverflow","RangeOverflow","Choose a date on or before {date}",this.#h));let r=this.#a.validationMessage;return s?this.#a.setValidity(i,s,this.#t):this.#a.setValidity({}),s&&(e||this.#F)?this.#t.setAttribute("aria-invalid","true"):this.#t.removeAttribute("aria-invalid"),(this.#r.validationMessage===this.#_||!this.#r.validity.customError)&&(this.#r.setCustomValidity(s),this.#_=s),r!==s}#K(){this.#o&&(this.#m(),this.#C()&&this.#r.dispatchEvent(new Event("input",{bubbles:!0})))}#W(t){let e=t||new Date;this.#u=t,this.#s=e,this.#e=e.getFullYear(),this.#n=e.getMonth(),this.#k(),this.#B(),this.#C(),this.#m()}formResetCallback(){this.#o&&(this.#F=!1,this.#W(f(this.#I)))}formStateRestoreCallback(t){!this.#o||typeof t!="string"||this.#W(f(t))}get form(){return this.#a.form}get validity(){return this.#a.validity}get validationMessage(){return this.#a.validationMessage}get willValidate(){return this.#a.willValidate}checkValidity(){return this.#a.checkValidity()}reportValidity(){return this.#a.reportValidity()}get value(){return this.#o?this.#u?d(this.#u):"":this.#x??""}set value(t){let e=t==null?"":String(t).trim(),i=e?f(e):null;if(!(e&&!i)){if(!this.#o){this.#x=e;return}this.#M(i,"api")}}get min(){return this.#l?d(this.#l):""}set min(t){this.#l=f(t),this.#r&&(this.#l?this.#r.setAttribute("min",d(this.#l)):this.#r.removeAttribute("min")),this.#K()}get max(){return this.#h?d(this.#h):""}set max(t){this.#h=f(t),this.#r&&(this.#h?this.#r.setAttribute("max",d(this.#h)):this.#r.removeAttribute("max")),this.#K()}};T("date-picker",S);export{S as DatePicker};
|
|
2
2
|
//# sourceMappingURL=date-picker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var A=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,s){t.addEventListener(e,n,s),this.#e.push(()=>t.removeEventListener(e,n,s))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{e?n.add(t):n.delete(t)}catch{let s=`--${t}`;e?n.add(s):n.delete(s)}}_adoptInternals(t){this.#t||(this.#t=t)}#n(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var P=window.matchMedia("(prefers-reduced-motion: reduce)");var N=new Map;function T(o,t,e={}){let n=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:n},r=N.get(o);if(customElements.get(o)){if(!r||r.priority>=n){r&&r.priority===n&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=n){r.priority===n&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}N.set(o,s),customElements.define(o,t)}function L(o,t="en-US"){try{if(o)return Intl.getCanonicalLocales(o),o}catch{}try{return Intl.getCanonicalLocales(t),t}catch{return"en-US"}}function E(o){if(!o)return null;let t=/(?:^|T|\s)(\d{1,2}):(\d{2})/.exec(String(o).trim());if(!t)return null;let e=Math.min(23,Math.max(0,parseInt(t[1],10))),n=Math.min(59,Math.max(0,parseInt(t[2],10)));return{hour:e,minute:n}}var $=60,v="(\\d+(?:\\.\\d+)?)",D=new RegExp(`^PT(?:${v}H)?(?:${v}M)?(?:${v}S)?$`,"i"),H=new RegExp(`^(?:${v}\\s*h(?:ours?|rs?)?)?\\s*(?:${v}\\s*m(?:in(?:utes?|s)?)?)?$`,"i"),I=new RegExp(`^${v}$`);function k(o){if(o==null)return null;let t=String(o).trim();if(!t)return null;let e=null,n;return(n=I.exec(t))?e=parseFloat(n[1]):(n=D.exec(t))&&(n[1]||n[2]||n[3])?e=(n[1]?parseFloat(n[1])*60:0)+(n[2]?parseFloat(n[2]):0)+(n[3]?parseFloat(n[3])/60:0):(n=H.exec(t))&&(n[1]||n[2])&&(e=(n[1]?parseFloat(n[1])*60:0)+(n[2]?parseFloat(n[2]):0)),e===null||!Number.isFinite(e)?null:(e=Math.round(e),e>0?e:null)}function S(o){let t=[...o].sort((l,u)=>l.start-u.start||u.end-l.end),e=[],n=[],s=[],r=-1/0,a=()=>{for(let l of n)l.columns=s.length;n=[],s=[]};for(let l of t){l.start>=r&&(a(),r=-1/0);let u=s.findIndex(b=>b<=l.start);u===-1?(u=s.length,s.push(l.end)):s[u]=l.end;let y={...l,column:u,columns:1};n.push(y),e.push(y),r=Math.max(r,l.end)}return a(),e}function q(o){let t=o.filter(e=>!e.dataset.duration).map(e=>{let n=e.dataset.start==="30"?30:0;return{start:n,end:n+30}});return S(t).some(e=>e.columns>1)}function F(o){let t=o.cloneNode(!0);return t.querySelectorAll('details, time[datetime^="PT"]').forEach(e=>e.remove()),(t.textContent||"").replace(/\s+/g," ").trim()}var R=["position","top","height","inset-inline-start","inset-inline-end"];var O=7,U=19,B=["ArrowDown","ArrowUp","Home","End"];function _(o,t){let e=parseInt(o??"",10);return Number.isNaN(e)?t:Math.min(23,Math.max(0,e))}var w=new WeakMap,M=class extends A{#e=null;#t=0;#n=null;setup(){return this.#e=this.querySelector(":scope > ol"),!this.#e&&this.querySelector(":scope > calendar-event")&&this.#h(),!this.#e&&!this.querySelector(":scope > .all-day-events")?!1:(this.#u(),this.#d(),this.listen(this,"click",t=>{let e=this.#i(t.target);e&&this.#o(e)}),this.listen(this,"keydown",t=>{let e=t,n=this.#i(e.target);if(!n)return;if((e.key==="Enter"||e.key===" ")&&e.target===n){e.preventDefault(),this.#o(n);return}if(!B.includes(e.key))return;let s=this.#r(),r=s.indexOf(n);if(r===-1)return;let a;e.key==="ArrowDown"?a=s[r+1]:e.key==="ArrowUp"?a=s[r-1]:e.key==="Home"?a=s[0]:e.key==="End"&&(a=s[s.length-1]),a&&a!==n&&(e.preventDefault(),n.setAttribute("tabindex","-1"),a.setAttribute("tabindex","0"),a.focus())}),this.#e&&(typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#a()),this.#n.observe(this.#e)),this.#a()),!0)}teardown(){this.#t&&cancelAnimationFrame(this.#t),this.#t=0,this.#n?.disconnect(),this.#n=null,this.#l()}refresh(){this.#t&&cancelAnimationFrame(this.#t),this.#t=0,this.#c()}get events(){return this.#r().map(t=>({time:t.querySelector("time[datetime]")?.getAttribute("datetime")||void 0,text:t.textContent?.trim()??"",category:t.dataset.category||void 0,duration:t.dataset.duration||void 0,href:t.querySelector("a[href]")?.getAttribute("href")||void 0}))}set events(t){let e=Array.isArray(t)?t:[];for(;this.firstChild;)this.firstChild.remove();this.dataset.startHour="auto";let n=new Intl.DateTimeFormat(this.#s(),{hour:"numeric",minute:"2-digit"});for(let s of e){let r=document.createElement("calendar-event");if(s.category&&(r.dataset.category=s.category),s.duration&&(r.dataset.duration=String(s.duration)),s.time){let a=document.createElement("time");a.setAttribute("datetime",s.time);let l=E(s.time);a.textContent=l?n.format(new Date(2026,0,1,l.hour,l.minute)):s.time,r.appendChild(a),r.appendChild(document.createTextNode(" "))}if(s.href){let a=document.createElement("a");a.href=s.href,a.textContent=s.text||"",r.appendChild(a)}else r.appendChild(document.createTextNode(s.text||""));this.appendChild(r)}this._reinit(),this.dispatchEvent(new CustomEvent("day-view:events-changed",{detail:{events:e,source:"property"},bubbles:!0}))}#s(){return L(this.closest("[lang]")?.lang||navigator.language)}#r(){return[...this.querySelectorAll("calendar-event")].filter(t=>t.closest("day-view")===this)}#i(t){let n=(t instanceof Element?t:null)?.closest("calendar-event")??null;return n&&n.closest("day-view")===this?n:null}#o(t){this.dispatchEvent(new CustomEvent("day-view:event-click",{bubbles:!0,detail:{date:this.dataset.date,time:t.querySelector("time[datetime]")?.getAttribute("datetime"),text:t.textContent?.trim()??"",element:t,category:t.dataset.category,duration:t.dataset.duration}}))}#u(){let t=this.#e,e=this.dataset.date;if(!t||!e||t.hasAttribute("aria-label")&&!w.has(t))return;let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return;let s=new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));if(Number.isNaN(s.getTime()))return;let r=new Intl.DateTimeFormat(this.#s(),{dateStyle:"full"}).format(s);w.set(t,r),t.setAttribute("aria-label",r)}#d(){let t=this.#r(),e=t.find(s=>s.getAttribute("tabindex")==="0");for(let s of t){if(s.hasAttribute("role")||s.setAttribute("role","group"),!s.hasAttribute("aria-label")||w.has(s)){let r=F(s);w.set(s,r),s.setAttribute("aria-label",r)}s.setAttribute("tabindex","-1")}let n=e??t[0];n&&n.setAttribute("tabindex","0")}#h(){let t=[...this.querySelectorAll(":scope > calendar-event")];if(t.length===0)return;let e=new Map,n=[];for(let c of t){let f=E(c.querySelector("time[datetime]")?.getAttribute("datetime"));if(!f){n.push(c);continue}f.minute>=30&&!c.dataset.start&&(c.dataset.start="30");let i=e.get(f.hour)??[];i.push(c),e.set(f.hour,i)}if(n.length>0){let c=this.querySelector(":scope > .all-day-events");c||(c=document.createElement("ul"),c.className="all-day-events",this.prepend(c));for(let f of n){let i=document.createElement("li");i.appendChild(f),c.appendChild(i)}}let s=[...e.keys()].sort((c,f)=>c-f),r=s[0],a=s[s.length-1],l,u;if(this.dataset.startHour==="auto"){if(s.length===0)return;l=Math.max(0,r-1),u=Math.min(23,a+1)}else l=_(this.dataset.startHour,O),u=Math.max(l,_(this.dataset.endHour,U)),s.length>0&&(l=Math.min(l,r),u=Math.max(u,a));let y=new Intl.DateTimeFormat(this.#s(),{hour:"numeric"}),b=document.createElement("ol");for(let c=l;c<=u;c++){let f=document.createElement("li"),i=document.createElement("time");i.setAttribute("datetime",`${String(c).padStart(2,"0")}:00`),i.textContent=y.format(new Date(2026,0,1,c));let h=document.createElement("hour-view"),d=e.get(c)||[];q(d)&&(h.dataset.overlap=""),d.forEach(m=>h.appendChild(m)),f.append(i,h),b.appendChild(f)}this.appendChild(b),this.#e=b}#a(){this.#t||(this.#t=requestAnimationFrame(()=>{this.#t=0,this.#c()}))}#l(){this.querySelectorAll("calendar-event.dv-spanning").forEach(t=>{let e=t;for(let s of R)e.style.removeProperty(s);e.classList.remove("dv-spanning"),e.removeAttribute("data-continues");let n=w.get(e);n!==void 0&&e.setAttribute("aria-label",n)})}#c(){let t=this.#e;if(this.#l(),!t||!t.isConnected)return;let e=[...t.querySelectorAll("calendar-event[data-duration]")];if(e.length===0)return;let n=t.getBoundingClientRect(),s=new Map,r=64,a=-1,l=0;if(t.querySelectorAll(":scope > li").forEach(i=>{let h=i.querySelector(":scope > time"),d=E(h?.getAttribute("datetime"));if(!h||!d)return;let m=i.getBoundingClientRect(),g=m.top-n.top;s.set(d.hour,{top:g,height:m.height}),d.hour>a&&(a=d.hour,l=g+m.height),r=h.getBoundingClientRect().width}),s.size===0)return;let u=(a+1)*60,y=i=>{let h=s.get(Math.floor(i/60));return h?h.top+h.height*(i%60/60):null},b=[];for(let i of e){let h=i.closest("ol > li"),d=E(h?.querySelector(":scope > time")?.getAttribute("datetime"));if(!d||!s.has(d.hour))continue;let m=E(i.querySelector("time[datetime]")?.getAttribute("datetime")),g=i.dataset.start?parseInt(i.dataset.start,10)||0:m&&m.hour===d.hour?m.minute:0,x=d.hour*60+Math.min(59,Math.max(0,g)),p=k(i.dataset.duration)??$;b.push({event:i,start:x,end:x+p})}let c=Math.max(0,n.width-r-8),f=this.dataset.labelContinues||"continues after the visible hours";for(let i of S(b)){let h=s.get(Math.floor(i.start/60)),d=y(i.start),m=i.end>u,g=m||i.end===u?l:y(i.end);g===null&&(g=d+h.height*((i.end-i.start)/60));let x=c/i.columns,{event:p}=i;if(p.style.position="absolute",p.style.top=`${d}px`,p.style.height=`${Math.max(g-d,1)}px`,p.style.insetInlineStart=`${r+4+i.column*x}px`,p.style.insetInlineEnd=`${4+(i.columns-1-i.column)*x}px`,p.classList.add("dv-spanning"),m){p.setAttribute("data-continues","");let C=w.get(p);C!==void 0&&p.setAttribute("aria-label",`${C}, ${f}`)}}}};T("day-view",M);export{M as DayView};
|
|
1
|
+
var x=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,r){t.addEventListener(e,n,r),this.#e.push(()=>t.removeEventListener(e,n,r))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{e?n.add(t):n.delete(t)}catch{let r=`--${t}`;e?n.add(r):n.delete(r)}}_adoptInternals(t){this.#t||(this.#t=t)}#n(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};var Y=window.matchMedia("(prefers-reduced-motion: reduce)");var T=new Map;function M(i,t,e={}){let n=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:n},s=T.get(i);if(customElements.get(i)){if(!s||s.priority>=n){s&&s.priority===n&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.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 "${e.bundle}" (first wins at equal priority).`);return}T.set(i,r),customElements.define(i,t)}function L(i,t="en-US"){try{if(i)return Intl.getCanonicalLocales(i),i}catch{}try{return Intl.getCanonicalLocales(t),t}catch{return"en-US"}}function E(i){if(!i)return null;let t=/(?:^|T|\s)(\d{1,2}):(\d{2})/.exec(String(i).trim());if(!t)return null;let e=Math.min(23,Math.max(0,parseInt(t[1],10))),n=Math.min(59,Math.max(0,parseInt(t[2],10)));return{hour:e,minute:n}}var k=60,v="(\\d+(?:\\.\\d+)?)",R=new RegExp(`^PT(?:${v}H)?(?:${v}M)?(?:${v}S)?$`,"i"),I=new RegExp(`^(?:${v}\\s*h(?:ours?|rs?)?)?\\s*(?:${v}\\s*m(?:in(?:utes?|s)?)?)?$`,"i"),D=new RegExp(`^${v}$`);function _(i){if(i==null)return null;let t=String(i).trim();if(!t)return null;let e=null,n;return(n=D.exec(t))?e=parseFloat(n[1]):(n=R.exec(t))&&(n[1]||n[2]||n[3])?e=(n[1]?parseFloat(n[1])*60:0)+(n[2]?parseFloat(n[2]):0)+(n[3]?parseFloat(n[3])/60:0):(n=I.exec(t))&&(n[1]||n[2])&&(e=(n[1]?parseFloat(n[1])*60:0)+(n[2]?parseFloat(n[2]):0)),e===null||!Number.isFinite(e)?null:(e=Math.round(e),e>0?e:null)}function S(i){let t=[...i].sort((c,u)=>c.start-u.start||u.end-c.end),e=[],n=[],r=[],s=-1/0,a=()=>{for(let c of n)c.columns=r.length;n=[],r=[]};for(let c of t){c.start>=s&&(a(),s=-1/0);let u=r.findIndex(b=>b<=c.start);u===-1?(u=r.length,r.push(c.end)):r[u]=c.end;let g={...c,column:u,columns:1};n.push(g),e.push(g),s=Math.max(s,c.end)}return a(),e}function q(i){let t=i.filter(e=>!e.dataset.duration).map(e=>{let n=e.dataset.start==="30"?30:0;return{start:n,end:n+30}});return S(t).some(e=>e.columns>1)}function H(i){let t=i.cloneNode(!0);return t.querySelectorAll('details, time[datetime^="PT"]').forEach(e=>e.remove()),(t.textContent||"").replace(/\s+/g," ").trim()}var F=["position","top","height","inset-inline-start","inset-inline-end"];var B=7,O=19,U=["ArrowDown","ArrowUp","Home","End"],V="a[href], button, input, select, textarea, summary, audio[controls], video[controls], [tabindex], [contenteditable]";function P(i,t){let e=parseInt(i??"",10);return Number.isNaN(e)?t:Math.min(23,Math.max(0,e))}var w=new WeakMap,C=class extends x{#e=null;#t=0;#n=null;setup(){return this.#e=this.querySelector(":scope > ol"),!this.#e&&this.querySelector(":scope > calendar-event")&&this.#h(),!this.#e&&!this.querySelector(":scope > .all-day-events")?!1:(this.#u(),this.#d(),this.listen(this,"click",t=>{let e=this.#o(t.target);e&&this.#i(e)}),this.listen(this,"keydown",t=>{let e=t,n=this.#o(e.target);if(!n)return;if((e.key==="Enter"||e.key===" ")&&e.target===n){e.preventDefault(),this.#i(n);return}if(!U.includes(e.key))return;let r=this.#s(),s=r.indexOf(n);if(s===-1)return;let a;e.key==="ArrowDown"?a=r[s+1]:e.key==="ArrowUp"?a=r[s-1]:e.key==="Home"?a=r[0]:e.key==="End"&&(a=r[r.length-1]),a&&a!==n&&(e.preventDefault(),n.setAttribute("tabindex","-1"),a.setAttribute("tabindex","0"),a.focus())}),this.#e&&(typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#a()),this.#n.observe(this.#e)),this.#a()),!0)}teardown(){this.#t&&cancelAnimationFrame(this.#t),this.#t=0,this.#n?.disconnect(),this.#n=null,this.#c()}refresh(){this.#t&&cancelAnimationFrame(this.#t),this.#t=0,this.#l()}get events(){return this.#s().map(t=>({time:t.querySelector("time[datetime]")?.getAttribute("datetime")||void 0,text:t.textContent?.trim()??"",category:t.dataset.category||void 0,duration:t.dataset.duration||void 0,href:t.querySelector("a[href]")?.getAttribute("href")||void 0}))}set events(t){let e=Array.isArray(t)?t:[];for(;this.firstChild;)this.firstChild.remove();this.dataset.startHour="auto";let n=new Intl.DateTimeFormat(this.#r(),{hour:"numeric",minute:"2-digit"});for(let r of e){let s=document.createElement("calendar-event");if(r.category&&(s.dataset.category=r.category),r.duration&&(s.dataset.duration=String(r.duration)),r.time){let a=document.createElement("time");a.setAttribute("datetime",r.time);let c=E(r.time);a.textContent=c?n.format(new Date(2026,0,1,c.hour,c.minute)):r.time,s.appendChild(a),s.appendChild(document.createTextNode(" "))}if(r.href){let a=document.createElement("a");a.href=r.href,a.textContent=r.text||"",s.appendChild(a)}else s.appendChild(document.createTextNode(r.text||""));this.appendChild(s)}this._reinit(),this.dispatchEvent(new CustomEvent("day-view:events-changed",{detail:{events:e,source:"property"},bubbles:!0}))}#r(){return L(this.closest("[lang]")?.lang||navigator.language)}#s(){return[...this.querySelectorAll("calendar-event")].filter(t=>t.closest("day-view")===this)}#o(t){let n=(t instanceof Element?t:null)?.closest("calendar-event")??null;return n&&n.closest("day-view")===this?n:null}#i(t){this.dispatchEvent(new CustomEvent("day-view:event-click",{bubbles:!0,detail:{date:this.dataset.date,time:t.querySelector("time[datetime]")?.getAttribute("datetime"),text:t.textContent?.trim()??"",element:t,category:t.dataset.category,duration:t.dataset.duration}}))}#u(){let t=this.#e,e=this.dataset.date;if(!t||!e||t.hasAttribute("aria-label")&&!w.has(t))return;let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return;let r=new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));if(Number.isNaN(r.getTime()))return;let s=new Intl.DateTimeFormat(this.#r(),{dateStyle:"full"}).format(r);w.set(t,s),t.setAttribute("aria-label",s)}#d(){let t=this.#s(),e=t.find(r=>r.getAttribute("tabindex")==="0");for(let r of t){if(r.hasAttribute("role")||r.setAttribute("role",r.querySelector(V)?"group":"button"),!r.hasAttribute("aria-label")||w.has(r)){let s=H(r);w.set(r,s),r.setAttribute("aria-label",s)}r.setAttribute("tabindex","-1")}let n=e??t[0];n&&n.setAttribute("tabindex","0")}#h(){let t=[...this.querySelectorAll(":scope > calendar-event")];if(t.length===0)return;let e=new Map,n=[];for(let l of t){let f=E(l.querySelector("time[datetime]")?.getAttribute("datetime"));if(!f){n.push(l);continue}f.minute>=30&&!l.dataset.start&&(l.dataset.start="30");let o=e.get(f.hour)??[];o.push(l),e.set(f.hour,o)}if(n.length>0){let l=this.querySelector(":scope > .all-day-events");l||(l=document.createElement("ul"),l.className="all-day-events",this.prepend(l));for(let f of n){let o=document.createElement("li");o.appendChild(f),l.appendChild(o)}}let r=[...e.keys()].sort((l,f)=>l-f),s=r[0],a=r[r.length-1],c,u;if(this.dataset.startHour==="auto"){if(r.length===0)return;c=Math.max(0,s-1),u=Math.min(23,a+1)}else c=P(this.dataset.startHour,B),u=Math.max(c,P(this.dataset.endHour,O)),r.length>0&&(c=Math.min(c,s),u=Math.max(u,a));let g=new Intl.DateTimeFormat(this.#r(),{hour:"numeric"}),b=document.createElement("ol");for(let l=c;l<=u;l++){let f=document.createElement("li"),o=document.createElement("time");o.setAttribute("datetime",`${String(l).padStart(2,"0")}:00`),o.textContent=g.format(new Date(2026,0,1,l));let h=document.createElement("hour-view"),d=e.get(l)||[];q(d)&&(h.dataset.overlap=""),d.forEach(m=>h.appendChild(m)),f.append(o,h),b.appendChild(f)}this.appendChild(b),this.#e=b}#a(){this.#t||(this.#t=requestAnimationFrame(()=>{this.#t=0,this.#l()}))}#c(){this.querySelectorAll("calendar-event.dv-spanning").forEach(t=>{let e=t;for(let r of F)e.style.removeProperty(r);e.classList.remove("dv-spanning"),e.removeAttribute("data-continues");let n=w.get(e);n!==void 0&&e.setAttribute("aria-label",n)})}#l(){let t=this.#e;if(this.#c(),!t||!t.isConnected)return;let e=[...t.querySelectorAll("calendar-event[data-duration]")];if(e.length===0)return;let n=t.getBoundingClientRect(),r=new Map,s=64,a=-1,c=0;if(t.querySelectorAll(":scope > li").forEach(o=>{let h=o.querySelector(":scope > time"),d=E(h?.getAttribute("datetime"));if(!h||!d)return;let m=o.getBoundingClientRect(),y=m.top-n.top;r.set(d.hour,{top:y,height:m.height}),d.hour>a&&(a=d.hour,c=y+m.height),s=h.getBoundingClientRect().width}),r.size===0)return;let u=(a+1)*60,g=o=>{let h=r.get(Math.floor(o/60));return h?h.top+h.height*(o%60/60):null},b=[];for(let o of e){let h=o.closest("ol > li"),d=E(h?.querySelector(":scope > time")?.getAttribute("datetime"));if(!d||!r.has(d.hour))continue;let m=E(o.querySelector("time[datetime]")?.getAttribute("datetime")),y=o.dataset.start?parseInt(o.dataset.start,10)||0:m&&m.hour===d.hour?m.minute:0,A=d.hour*60+Math.min(59,Math.max(0,y)),p=_(o.dataset.duration)??k;b.push({event:o,start:A,end:A+p})}let l=Math.max(0,n.width-s-8),f=this.dataset.labelContinues||"continues after the visible hours";for(let o of S(b)){let h=r.get(Math.floor(o.start/60)),d=g(o.start),m=o.end>u,y=m||o.end===u?c:g(o.end);y===null&&(y=d+h.height*((o.end-o.start)/60));let A=l/o.columns,{event:p}=o;if(p.style.position="absolute",p.style.top=`${d}px`,p.style.height=`${Math.max(y-d,1)}px`,p.style.insetInlineStart=`${s+4+o.column*A}px`,p.style.insetInlineEnd=`${4+(o.columns-1-o.column)*A}px`,p.classList.add("dv-spanning"),m){p.setAttribute("data-continues","");let $=w.get(p);$!==void 0&&p.setAttribute("aria-label",`${$}, ${f}`)}}}};M("day-view",C);export{C as DayView};
|
|
2
2
|
//# sourceMappingURL=day-view.js.map
|