@birdapi/velinstyle 0.6.1 → 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/README.de.md +315 -316
- package/README.md +8 -9
- package/cli/index.js +4 -3
- package/cli/scanner.js +46 -0
- package/components/focus-manager.js +106 -80
- package/components/index.js +1 -1
- package/components/velin-accordion.js +112 -98
- package/components/velin-carousel.js +40 -5
- package/components/velin-collapse.js +95 -65
- package/components/velin-drawer.js +6 -3
- package/components/velin-dropdown.js +33 -2
- package/components/velin-modal.js +3 -1
- package/components/velin-popover.js +61 -21
- package/components/velin-tooltip-wc.js +26 -2
- package/dist/velinstyle-components.iife.js +220 -51
- package/dist/velinstyle-components.js +222 -51
- package/dist/velinstyle-components.min.js +67 -68
- package/dist/velinstyle.css +168 -41
- package/dist/velinstyle.min.css +1 -1
- package/package.json +6 -3
- package/src/a11y/focus-not-obscured.css +21 -0
- package/src/a11y/forced-colors.css +86 -38
- package/src/a11y/high-contrast-aaa.css +37 -0
- package/src/a11y/preferences.css +106 -85
- package/src/a11y/security.css +101 -104
- package/src/a11y/target-size.css +32 -0
- package/src/base/root.css +4 -4
- package/src/velinstyle.css +6 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ee=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])',"summary","details"].join(", ");function te(o){if(o.hasAttribute("disabled")||o.getAttribute("aria-hidden")==="true"||o.closest("[inert]"))return!1;let e=o.ownerDocument.defaultView?.getComputedStyle(o);return e&&(e.visibility==="hidden"||e.display==="none")?!1:o.getClientRects().length>0}function h(o){return[...o.querySelectorAll(ee)].filter(te)}function u(o,e){if(e.key!=="Tab")return;let t=h(o);if(t.length===0)return;let s=t[0],i=t[t.length-1],r=o.getRootNode().activeElement;e.shiftKey&&r===s?(e.preventDefault(),i.focus()):!e.shiftKey&&r===i&&(e.preventDefault(),s.focus())}function f(o,e,t){let s=e.indexOf(t.target);if(s===-1)return;let i;switch(t.key){case"ArrowDown":case"ArrowRight":t.preventDefault(),i=(s+1)%e.length;break;case"ArrowUp":case"ArrowLeft":t.preventDefault(),i=(s-1+e.length)%e.length;break;case"Home":t.preventDefault(),i=0;break;case"End":t.preventDefault(),i=e.length-1;break;default:return}e.forEach((r,n)=>{r.setAttribute("tabindex",n===i?"0":"-1")}),e[i].focus()}function p(){return document.activeElement}function v(o){o&&typeof o.focus=="function"&&o.focus()}var x=[];function g(o){x=[];for(let e of document.body.children)e===o||e.contains(o)||e.hasAttribute("inert")||(e.setAttribute("inert",""),x.push(e))}function y(){for(let o of x)o.removeAttribute("inert");x=[]}var se={"&":"&","<":"<",">":">",'"':""","'":"'"},ie=/[&<>"']/g;function a(o){return typeof o!="string"?"":o.replace(ie,e=>se[e])}function J(o){if(typeof o!="string")return"";try{let e=new URL(o,location.href);return["http:","https:","data:"].includes(e.protocol)?o:""}catch{return""}}var re=`
|
|
2
2
|
:host {
|
|
3
3
|
display: contents;
|
|
4
4
|
}
|
|
@@ -80,8 +80,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
80
80
|
@media (prefers-reduced-motion: reduce) {
|
|
81
81
|
.overlay, .dialog { transition: none; }
|
|
82
82
|
}
|
|
83
|
-
`,
|
|
84
|
-
<style>${
|
|
83
|
+
`,w=class extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._previouslyFocused=null,this._onKeydown=this._onKeydown.bind(this)}connectedCallback(){let e=this.getAttribute("title")||"",t=a(e);this.shadowRoot.innerHTML=`
|
|
84
|
+
<style>${re}</style>
|
|
85
85
|
<div class="overlay" part="overlay">
|
|
86
86
|
<div class="dialog" role="dialog" aria-modal="true" aria-labelledby="velin-modal-title" part="dialog">
|
|
87
87
|
<div class="header" part="header">
|
|
@@ -92,7 +92,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
92
92
|
<div class="footer" part="footer"><slot name="footer"></slot></div>
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
|
-
`,this.shadowRoot.querySelector(".close-btn").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".overlay").addEventListener("click",s=>{s.target===s.currentTarget&&this.close()})}attributeChangedCallback(e,t,s){e==="open"&&(s!==null?this._open():this._close())}open(){this.setAttribute("open","")}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_open(){this._previouslyFocused=
|
|
95
|
+
`,this.shadowRoot.querySelector(".close-btn").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".overlay").addEventListener("click",s=>{s.target===s.currentTarget&&this.close()})}attributeChangedCallback(e,t,s){e==="open"&&(s!==null?this._open():this._close())}open(){this.setAttribute("open","")}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_open(){this._previouslyFocused=p(),g(this),document.addEventListener("keydown",this._onKeydown),document.body.style.overflow="hidden",requestAnimationFrame(()=>{let e=h(this.shadowRoot);e.length>0&&e[0].focus()})}_close(){document.removeEventListener("keydown",this._onKeydown),document.body.style.overflow="",y(),v(this._previouslyFocused)}_onKeydown(e){if(e.key==="Escape"){this.close();return}u(this.shadowRoot,e)}disconnectedCallback(){document.removeEventListener("keydown",this._onKeydown),document.body.style.overflow=""}};customElements.define("velin-modal",w);var oe=w;var ne=`
|
|
96
96
|
:host {
|
|
97
97
|
display: inline-block;
|
|
98
98
|
position: relative;
|
|
@@ -142,13 +142,13 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
142
142
|
@media (prefers-reduced-motion: reduce) {
|
|
143
143
|
.menu { transition: none; }
|
|
144
144
|
}
|
|
145
|
-
`,
|
|
146
|
-
<style>${
|
|
145
|
+
`,k=class extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._onDocClick=this._onDocClick.bind(this),this._onKeydown=this._onKeydown.bind(this),this._typeahead="",this._typeaheadTimer=null}connectedCallback(){let e=this.getAttribute("align")||"start";this.shadowRoot.innerHTML=`
|
|
146
|
+
<style>${ne}</style>
|
|
147
147
|
<slot name="trigger"></slot>
|
|
148
148
|
<div class="menu ${e==="end"?"menu-end":""}" role="menu" part="menu">
|
|
149
149
|
<slot></slot>
|
|
150
150
|
</div>
|
|
151
|
-
`;let t=this.shadowRoot.querySelector('slot[name="trigger"]');t.addEventListener("click",()=>this.toggle()),t.addEventListener("slotchange",()=>{let
|
|
151
|
+
`;let t=this.shadowRoot.querySelector('slot[name="trigger"]'),s=this.shadowRoot.querySelector("slot:not([name])");t.addEventListener("click",()=>this.toggle()),t.addEventListener("slotchange",()=>{let i=t.assignedElements()[0];if(i){i.setAttribute("aria-haspopup","menu"),i.setAttribute("aria-expanded",this.hasAttribute("open")?"true":"false");let r=this._menuId||(this._menuId=`velin-dropdown-menu-${Math.random().toString(36).slice(2,9)}`);i.setAttribute("aria-controls",r),this.shadowRoot.querySelector(".menu")?.setAttribute("id",r)}}),s?.addEventListener("slotchange",()=>this._normalizeMenuItems()),this._normalizeMenuItems(),this.addEventListener("keydown",this._onKeydown)}_normalizeMenuItems(){this._getMenuItems().forEach((t,s)=>{t.hasAttribute("role")||t.setAttribute("role","menuitem"),t.setAttribute("tabindex",s===0?"0":"-1")})}toggle(){this.hasAttribute("open")?this.close():this.open()}open(){this.setAttribute("open","");let e=this.querySelector('[slot="trigger"]');e&&e.setAttribute("aria-expanded","true"),document.addEventListener("click",this._onDocClick,!0),requestAnimationFrame(()=>{let t=this._getMenuItems();t.length>0&&t[0].focus()})}close(){this.removeAttribute("open");let e=this.querySelector('[slot="trigger"]');e&&e.setAttribute("aria-expanded","false"),document.removeEventListener("click",this._onDocClick,!0),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_getMenuItems(){let e=this.shadowRoot.querySelector("slot:not([name])");return e?e.assignedElements().filter(t=>!t.hasAttribute("disabled")):[]}_onDocClick(e){this.contains(e.target)||this.close()}_onKeydown(e){if(e.key==="Escape"){this.close();let s=this.querySelector('[slot="trigger"]');s&&s.focus();return}let t=this._getMenuItems();if(t.length!==0){if(e.key.length===1&&/[a-z0-9]/i.test(e.key)){clearTimeout(this._typeaheadTimer),this._typeahead+=e.key.toLowerCase(),this._typeaheadTimer=setTimeout(()=>{this._typeahead=""},500);let s=t.find(i=>(i.textContent?.trim().toLowerCase()||"").startsWith(this._typeahead));s&&(e.preventDefault(),t.forEach(i=>i.setAttribute("tabindex",i===s?"0":"-1")),s.focus());return}f(this,t,e)}}disconnectedCallback(){document.removeEventListener("click",this._onDocClick,!0)}};customElements.define("velin-dropdown",k);var ae=k;var le=`
|
|
152
152
|
:host {
|
|
153
153
|
display: block;
|
|
154
154
|
border: 1px solid var(--velin-color-border, #ddd);
|
|
@@ -176,10 +176,10 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
176
176
|
::slotted(details > summary::-webkit-details-marker) {
|
|
177
177
|
display: none;
|
|
178
178
|
}
|
|
179
|
-
`,
|
|
180
|
-
<style>${
|
|
181
|
-
<
|
|
182
|
-
`,this._exclusive=this.hasAttribute("exclusive"),this.addEventListener("toggle",this._onToggle,!0),this.addEventListener("keydown",this._onKeydown.bind(this))}_onToggle(e){if(!this._exclusive)return;let t=e.target;if(!t.open)return;[...this.querySelectorAll("details")].forEach(i=>{i!==t&&i.open&&(i.open=!1)})}_onKeydown(e){let t=[...this.querySelectorAll("summary")],s=t.indexOf(e.target);if(s===-1)return;let i;switch(e.key){case"ArrowDown":e.preventDefault(),i=(s+1)%t.length;break;case"ArrowUp":e.preventDefault(),i=(s-1+t.length)%t.length;break;case"Home":e.preventDefault(),i=0;break;case"End":e.preventDefault(),i=t.length-1;break;default:return}t[i].focus()}disconnectedCallback(){this.removeEventListener("toggle",this._onToggle,!0)}};customElements.define("velin-accordion",
|
|
179
|
+
`,A=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._onToggle=this._onToggle.bind(this)}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
180
|
+
<style>${le}</style>
|
|
181
|
+
<slot></slot>
|
|
182
|
+
`,this._exclusive=this.hasAttribute("exclusive"),this._wireDetails(),this.addEventListener("toggle",this._onToggle,!0),this.addEventListener("keydown",this._onKeydown.bind(this))}_wireDetails(){let e=0;for(let t of this.querySelectorAll("details")){let s=t.querySelector("summary"),i=t.querySelector(":scope > :not(summary)"),r=i?.id||`velin-accordion-panel-${++e}`;i&&!i.id&&(i.id=r),s&&i&&s.setAttribute("aria-controls",r)}}_onToggle(e){if(!this._exclusive)return;let t=e.target;if(!t.open)return;[...this.querySelectorAll("details")].forEach(i=>{i!==t&&i.open&&(i.open=!1)})}_onKeydown(e){let t=[...this.querySelectorAll("summary")],s=t.indexOf(e.target);if(s===-1)return;let i;switch(e.key){case"ArrowDown":e.preventDefault(),i=(s+1)%t.length;break;case"ArrowUp":e.preventDefault(),i=(s-1+t.length)%t.length;break;case"Home":e.preventDefault(),i=0;break;case"End":e.preventDefault(),i=t.length-1;break;default:return}t[i].focus()}disconnectedCallback(){this.removeEventListener("toggle",this._onToggle,!0)}};customElements.define("velin-accordion",A);var ce=A;var de=`
|
|
183
183
|
:host {
|
|
184
184
|
display: block;
|
|
185
185
|
}
|
|
@@ -221,15 +221,15 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
221
221
|
::slotted([role="tabpanel"][hidden]) {
|
|
222
222
|
display: none;
|
|
223
223
|
}
|
|
224
|
-
`,
|
|
225
|
-
<style>${
|
|
224
|
+
`,E=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._onTabClick=this._onTabClick.bind(this),this._onKeydown=this._onKeydown.bind(this)}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
225
|
+
<style>${de}</style>
|
|
226
226
|
<div class="tablist" role="tablist" part="tablist">
|
|
227
227
|
<slot name="tab"></slot>
|
|
228
228
|
</div>
|
|
229
229
|
<div class="panels" part="panels">
|
|
230
230
|
<slot name="panel"></slot>
|
|
231
231
|
</div>
|
|
232
|
-
`,this.addEventListener("click",this._onTabClick),this.addEventListener("keydown",this._onKeydown),requestAnimationFrame(()=>this._initTabs())}_initTabs(){let e=this._getTabs(),t=this._getPanels();e.forEach((i,r)=>{i.setAttribute("role","tab"),i.setAttribute("slot","tab"),i.id||(i.id=`velin-tab-${r}`);let
|
|
232
|
+
`,this.addEventListener("click",this._onTabClick),this.addEventListener("keydown",this._onKeydown),requestAnimationFrame(()=>this._initTabs())}_initTabs(){let e=this._getTabs(),t=this._getPanels();e.forEach((i,r)=>{i.setAttribute("role","tab"),i.setAttribute("slot","tab"),i.id||(i.id=`velin-tab-${r}`);let n=t[r];n&&(n.setAttribute("role","tabpanel"),n.setAttribute("slot","panel"),n.id||(n.id=`velin-panel-${r}`),i.setAttribute("aria-controls",n.id),n.setAttribute("aria-labelledby",i.id))});let s=e.find(i=>i.getAttribute("aria-selected")==="true")||e[0];s&&this._selectTab(s)}_getTabs(){return[...this.querySelectorAll('[role="tab"], [slot="tab"]')]}_getPanels(){return[...this.querySelectorAll('[role="tabpanel"], [slot="panel"]')]}_onTabClick(e){let t=e.target.closest('[role="tab"]');t&&this.contains(t)&&this._selectTab(t)}_selectTab(e){let t=this._getTabs(),s=this._getPanels();t.forEach((i,r)=>{let n=i===e;i.setAttribute("aria-selected",String(n)),i.setAttribute("tabindex",n?"0":"-1"),s[r]&&(s[r].hidden=!n)}),this.dispatchEvent(new CustomEvent("velin-tab-change",{bubbles:!0,detail:{tab:e}}))}_onKeydown(e){let t=this._getTabs();if(t.includes(e.target)&&(f(this,t,e),e.key==="ArrowRight"||e.key==="ArrowLeft"||e.key==="Home"||e.key==="End")){let s=t.find(i=>i.getAttribute("tabindex")==="0");s&&this._selectTab(s)}}disconnectedCallback(){this.removeEventListener("click",this._onTabClick),this.removeEventListener("keydown",this._onKeydown)}};customElements.define("velin-tabs",E);var ue=E;var he=`
|
|
233
233
|
:host {
|
|
234
234
|
position: fixed;
|
|
235
235
|
z-index: var(--velin-z-toast, 600);
|
|
@@ -291,10 +291,10 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
291
291
|
@media (prefers-reduced-motion: reduce) {
|
|
292
292
|
.toast, .toast--out { animation: none; }
|
|
293
293
|
}
|
|
294
|
-
`,
|
|
294
|
+
`,L=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._container=null}connectedCallback(){this.shadowRoot.innerHTML=`<style>${he}</style>`,this._container=this.shadowRoot,this.setAttribute("role","status"),this.setAttribute("aria-live","polite"),this.setAttribute("aria-atomic","true")}show({message:e,type:t="info",duration:s=5e3}={}){let i=document.createElement("div");return i.className=`toast toast--${t}`,i.innerHTML=`
|
|
295
295
|
<div class="toast-content">${a(e)}</div>
|
|
296
296
|
<button class="toast-close" aria-label="Close">×</button>
|
|
297
|
-
`,i.querySelector(".toast-close").addEventListener("click",()=>{this._dismiss(i)}),this._container.appendChild(i),s>0&&setTimeout(()=>this._dismiss(i),s),i}_dismiss(e){!e||!e.parentNode||(e.classList.add("toast--out"),e.addEventListener("animationend",()=>e.remove(),{once:!0}),setTimeout(()=>e.remove(),300))}};customElements.define("velin-toast",
|
|
297
|
+
`,i.querySelector(".toast-close").addEventListener("click",()=>{this._dismiss(i)}),this._container.appendChild(i),s>0&&setTimeout(()=>this._dismiss(i),s),i}_dismiss(e){!e||!e.parentNode||(e.classList.add("toast--out"),e.addEventListener("animationend",()=>e.remove(),{once:!0}),setTimeout(()=>e.remove(),300))}};customElements.define("velin-toast",L);var pe=L;var S={lucide:"https://unpkg.com/lucide-static@latest/icons/{name}.svg",heroicons:"https://unpkg.com/heroicons@2/24/outline/{name}.svg",bootstrap:"https://unpkg.com/bootstrap-icons@latest/icons/{name}.svg",material:"https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/{name}/default/24px.svg",fontawesome:"https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/regular/{name}.svg"},G=new Map,T=class extends HTMLElement{static get observedAttributes(){return["name","size","label","provider","sprite"]}constructor(){super(),this._rendered=!1}connectedCallback(){this._render()}attributeChangedCallback(){this._rendered&&this._render()}_render(){let e=this.getAttribute("name"),t=this.getAttribute("size")||"24",s=this.getAttribute("label"),i=this.getAttribute("provider");if(!e){this.innerHTML="";return}if(i&&S[i]){this._renderFromCDN(e,t,s,i);return}this._renderFromSprite(e,t,s)}_renderFromSprite(e,t,s){let i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg");r.setAttribute("width",t),r.setAttribute("height",t),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","2"),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),this._applyStyle(r),this._applyA11y(r,s);let n=document.createElementNS(i,"use"),l=this.getAttribute("sprite")||"velin-icons.svg";n.setAttribute("href",`${l}#${e}`),r.appendChild(n),this.innerHTML="",this.appendChild(r),this._rendered=!0}async _renderFromCDN(e,t,s,i){let r=`${i}:${e}`;if(G.has(r)){this._injectSVG(G.get(r),t,s);return}let n=S[i].replace("{name}",e);try{let l=await fetch(n);if(!l.ok)throw new Error(`${l.status}`);let d=await l.text();if(!d.includes("<svg"))throw new Error("Not SVG");G.set(r,d),this._injectSVG(d,t,s)}catch{this._renderFromSprite(e,t,s)}}_injectSVG(e,t,s){let n=new DOMParser().parseFromString(e,"image/svg+xml").querySelector("svg");if(!n){this.innerHTML="";return}n.setAttribute("width",t),n.setAttribute("height",t),n.getAttribute("viewBox")||n.setAttribute("viewBox","0 0 24 24"),this._applyStyle(n),this._applyA11y(n,s),this.innerHTML="",this.appendChild(document.importNode(n,!0)),this._rendered=!0}_applyStyle(e){e.style.display="inline-block",e.style.verticalAlign="middle",e.style.flexShrink="0"}_applyA11y(e,t){t?(e.setAttribute("role","img"),e.setAttribute("aria-label",t)):e.setAttribute("aria-hidden","true")}static get providers(){return Object.keys(S)}static registerProvider(e,t){S[e]=t}};customElements.define("velin-icon",T);var ve=T;var me=`
|
|
298
298
|
:host { display: contents; }
|
|
299
299
|
.overlay {
|
|
300
300
|
position: fixed;
|
|
@@ -339,17 +339,17 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
339
339
|
.close-btn:hover { background: var(--velin-color-surface-dim, #eee); color: var(--velin-color-text, #111); }
|
|
340
340
|
.body { flex: 1; padding: var(--velin-space-5, 1.25rem); overflow-y: auto; }
|
|
341
341
|
@media (prefers-reduced-motion: reduce) { .overlay, .drawer { transition: none; } }
|
|
342
|
-
`,
|
|
343
|
-
<style>${
|
|
342
|
+
`,C=class extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._prev=null,this._onKey=this._onKey.bind(this)}connectedCallback(){let e=this.getAttribute("title")||"",t=a(e),s="velin-drawer-title";this.shadowRoot.innerHTML=`
|
|
343
|
+
<style>${me}</style>
|
|
344
344
|
<div class="overlay" part="overlay"></div>
|
|
345
|
-
<div class="drawer" role="dialog" aria-modal="true" aria-
|
|
345
|
+
<div class="drawer" role="dialog" aria-modal="true" aria-labelledby="${s}" part="drawer">
|
|
346
346
|
<div class="header" part="header">
|
|
347
|
-
<h2 class="title">${t}</h2>
|
|
347
|
+
<h2 class="title" id="${s}">${t}</h2>
|
|
348
348
|
<button class="close-btn" aria-label="Close" part="close">×</button>
|
|
349
349
|
</div>
|
|
350
350
|
<div class="body" part="body"><slot></slot></div>
|
|
351
351
|
</div>
|
|
352
|
-
`,this.shadowRoot.querySelector(".close-btn").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".overlay").addEventListener("click",()=>this.close())}attributeChangedCallback(e){e==="open"&&(this.hasAttribute("open")?this._open():this._close())}open(){this.setAttribute("open","")}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_open(){this._prev=
|
|
352
|
+
`,this.shadowRoot.querySelector(".close-btn").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".overlay").addEventListener("click",()=>this.close())}attributeChangedCallback(e){e==="open"&&(this.hasAttribute("open")?this._open():this._close())}open(){this.setAttribute("open","")}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_open(){this._prev=p(),g(this),document.addEventListener("keydown",this._onKey),document.body.style.overflow="hidden",requestAnimationFrame(()=>{let e=h(this.shadowRoot);e.length&&e[0].focus()})}_close(){document.removeEventListener("keydown",this._onKey),document.body.style.overflow="",y(),v(this._prev)}_onKey(e){if(e.key==="Escape"){this.close();return}u(this.shadowRoot,e)}disconnectedCallback(){document.removeEventListener("keydown",this._onKey),document.body.style.overflow=""}};customElements.define("velin-drawer",C);var be=C;var fe=`
|
|
353
353
|
:host { display: inline-flex; }
|
|
354
354
|
button {
|
|
355
355
|
display: inline-flex; align-items: center; justify-content: center;
|
|
@@ -364,8 +364,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
364
364
|
:host([theme="dark"]) .sun { display: none; }
|
|
365
365
|
:host(:not([theme="dark"])) .moon { display: none; }
|
|
366
366
|
@media (prefers-reduced-motion: reduce) { svg { transition: none; } }
|
|
367
|
-
|
|
368
|
-
<style>${
|
|
367
|
+
`,$=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
368
|
+
<style>${fe}</style>
|
|
369
369
|
<button part="button" aria-label="Toggle dark mode">
|
|
370
370
|
<svg class="sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
371
371
|
<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/>
|
|
@@ -377,7 +377,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
377
377
|
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/>
|
|
378
378
|
</svg>
|
|
379
379
|
</button>
|
|
380
|
-
`;let e=this.getAttribute("target")||"html",t=document.querySelector(e),s=localStorage.getItem("velin-theme"),i=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{localStorage.getItem("velin-theme")||(i.matches?(t?.setAttribute("data-velin-theme","dark"),this.setAttribute("theme","dark")):(t?.removeAttribute("data-velin-theme"),this.removeAttribute("theme")))},
|
|
380
|
+
`;let e=this.getAttribute("target")||"html",t=document.querySelector(e),s=localStorage.getItem("velin-theme"),i=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{localStorage.getItem("velin-theme")||(i.matches?(t?.setAttribute("data-velin-theme","dark"),this.setAttribute("theme","dark")):(t?.removeAttribute("data-velin-theme"),this.removeAttribute("theme")))},n=i.matches;(s==="dark"||!s&&n)&&(t?.setAttribute("data-velin-theme","dark"),this.setAttribute("theme","dark")),i.addEventListener("change",r),window.addEventListener("storage",l=>{l.key!=="velin-theme"||!t||(l.newValue==="dark"?(t.setAttribute("data-velin-theme","dark"),this.setAttribute("theme","dark")):(t.removeAttribute("data-velin-theme"),this.removeAttribute("theme")))}),this.shadowRoot.querySelector("button").addEventListener("click",()=>{let l=t?.getAttribute("data-velin-theme")==="dark";l?(t?.removeAttribute("data-velin-theme"),this.removeAttribute("theme"),localStorage.setItem("velin-theme","light")):(t?.setAttribute("data-velin-theme","dark"),this.setAttribute("theme","dark"),localStorage.setItem("velin-theme","dark")),this.dispatchEvent(new CustomEvent("velin-theme-change",{bubbles:!0,detail:{theme:l?"light":"dark",dark:!l}}))})}};customElements.define("velin-theme-toggle",$);var ge=$;var ye=`
|
|
381
381
|
:host { position: relative; display: inline-block; }
|
|
382
382
|
.popover {
|
|
383
383
|
position: absolute; z-index: var(--velin-z-dropdown, 200);
|
|
@@ -391,7 +391,6 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
391
391
|
transition: opacity 150ms ease, visibility 150ms ease;
|
|
392
392
|
}
|
|
393
393
|
:host([open]) .popover { opacity: 1; visibility: visible; }
|
|
394
|
-
/* Placement */
|
|
395
394
|
.popover--top { inset-block-end: calc(100% + 0.5rem); inset-inline-start: 50%; transform: translateX(-50%); }
|
|
396
395
|
.popover--bottom { inset-block-start: calc(100% + 0.5rem); inset-inline-start: 50%; transform: translateX(-50%); }
|
|
397
396
|
.popover--start { inset-inline-end: calc(100% + 0.5rem); inset-block-start: 50%; transform: translateY(-50%); }
|
|
@@ -403,14 +402,14 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
403
402
|
border-bottom: 1px solid var(--velin-color-border, #ddd);
|
|
404
403
|
}
|
|
405
404
|
@media (prefers-reduced-motion: reduce) { .popover { transition: none; } }
|
|
406
|
-
`,
|
|
407
|
-
<style>${
|
|
405
|
+
`,_e=0,M=class extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),this.attachShadow({mode:"open"}),this._popoverId=`velin-popover-${++_e}`,this._onOutside=this._onOutside.bind(this),this._onKey=this._onKey.bind(this),this._prevFocus=null,this._isDialog=!1}connectedCallback(){let e=this.getAttribute("placement")||"bottom",t=this.getAttribute("trigger")||"click",s=this.getAttribute("title")||"",i=t==="hover"?"tooltip":"dialog";this._isDialog=i==="dialog",this.shadowRoot.innerHTML=`
|
|
406
|
+
<style>${ye}</style>
|
|
408
407
|
<slot name="trigger"></slot>
|
|
409
|
-
<div class="popover popover--${e}" role="${i}" part="popover">
|
|
408
|
+
<div class="popover popover--${e}" id="${this._popoverId}" role="${i}" part="popover">
|
|
410
409
|
${s?`<div class="popover__title" part="title">${a(s)}</div>`:""}
|
|
411
410
|
<slot></slot>
|
|
412
411
|
</div>
|
|
413
|
-
|
|
412
|
+
`,this.shadowRoot.querySelector('slot[name="trigger"]').addEventListener("slotchange",()=>this._wireTrigger(t)),this._wireTrigger(t)}_wireTrigger(e){let t=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];if(!t)return;let s=e==="hover";t.setAttribute("aria-haspopup",s?"true":"dialog"),t.setAttribute("aria-expanded",this.hasAttribute("open")?"true":"false"),this._isDialog&&t.setAttribute("aria-controls",this._popoverId),e==="click"?t.onclick=()=>this.toggle():e==="hover"?(this.onmouseenter=()=>this.open(),this.onmouseleave=()=>this.close(),this.onfocusin=()=>this.open(),this.onfocusout=i=>{this.contains(i.relatedTarget)||this.close()}):e==="focus"&&(t.onfocusin=()=>this.open(),t.onfocusout=()=>this.close())}open(){this.setAttribute("open","");let e=this.querySelector('[slot="trigger"]');e&&e.setAttribute("aria-expanded","true"),document.addEventListener("click",this._onOutside,!0),document.addEventListener("keydown",this._onKey),this._isDialog&&(this._prevFocus=p(),requestAnimationFrame(()=>{let t=h(this.shadowRoot.querySelector(".popover"));t.length?t[0].focus():this.shadowRoot.querySelector(".popover")?.focus()}))}close(){this.removeAttribute("open");let e=this.querySelector('[slot="trigger"]');e&&e.setAttribute("aria-expanded","false"),document.removeEventListener("click",this._onOutside,!0),document.removeEventListener("keydown",this._onKey),this._isDialog&&this._prevFocus&&(v(this._prevFocus),this._prevFocus=null)}toggle(){this.hasAttribute("open")?this.close():this.open()}_onOutside(e){this.contains(e.target)||this.close()}_onKey(e){if(e.key==="Escape"){this.close();let t=this.querySelector('[slot="trigger"]');t&&t.focus();return}this._isDialog&&this.hasAttribute("open")&&u(this.shadowRoot.querySelector(".popover"),e)}disconnectedCallback(){document.removeEventListener("click",this._onOutside,!0),document.removeEventListener("keydown",this._onKey)}};customElements.define("velin-popover",M);var xe=M;var we=`
|
|
414
413
|
:host { display: inline-flex; }
|
|
415
414
|
button {
|
|
416
415
|
display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
|
|
@@ -430,8 +429,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
430
429
|
button[data-copied] .copy-icon { display: none; }
|
|
431
430
|
button[data-copied] .check { display: block; }
|
|
432
431
|
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
|
|
433
|
-
`,
|
|
434
|
-
<style>${
|
|
432
|
+
`,R=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){let e=this.getAttribute("label")||"";this.shadowRoot.innerHTML=`
|
|
433
|
+
<style>${we}</style>
|
|
435
434
|
<button part="button" aria-label="Copy">
|
|
436
435
|
<svg class="copy-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
437
436
|
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/>
|
|
@@ -441,7 +440,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
441
440
|
</svg>
|
|
442
441
|
${e?`<span>${e}</span>`:""}
|
|
443
442
|
</button>
|
|
444
|
-
`,this.shadowRoot.querySelector("button").addEventListener("click",()=>this._copy())}async _copy(){let e=this.getAttribute("value")||"";if(!e)return;try{await navigator.clipboard.writeText(e)}catch{let s=document.createElement("textarea");s.value=e,s.style.cssText="position:fixed;opacity:0",document.body.appendChild(s),s.select(),document.execCommand("copy"),s.remove()}let t=this.shadowRoot.querySelector("button");t.setAttribute("data-copied",""),t.setAttribute("aria-label","Copied"),this.dispatchEvent(new CustomEvent("velin-copied",{bubbles:!0,detail:{value:e}})),setTimeout(()=>{t.removeAttribute("data-copied"),t.setAttribute("aria-label","Copy")},2e3)}};customElements.define("velin-copy",
|
|
443
|
+
`,this.shadowRoot.querySelector("button").addEventListener("click",()=>this._copy())}async _copy(){let e=this.getAttribute("value")||"";if(!e)return;try{await navigator.clipboard.writeText(e)}catch{let s=document.createElement("textarea");s.value=e,s.style.cssText="position:fixed;opacity:0",document.body.appendChild(s),s.select(),document.execCommand("copy"),s.remove()}let t=this.shadowRoot.querySelector("button");t.setAttribute("data-copied",""),t.setAttribute("aria-label","Copied"),this.dispatchEvent(new CustomEvent("velin-copied",{bubbles:!0,detail:{value:e}})),setTimeout(()=>{t.removeAttribute("data-copied"),t.setAttribute("aria-label","Copy")},2e3)}};customElements.define("velin-copy",R);var ke=R;var Ae=`
|
|
445
444
|
:host { position: fixed; inset-block-end: var(--velin-scroll-top-bottom, var(--velin-space-4, 1rem)); inset-inline-end: var(--velin-scroll-top-end, var(--velin-space-4, 1rem)); z-index: var(--velin-z-fixed, 300); }
|
|
446
445
|
button {
|
|
447
446
|
display: inline-flex; align-items: center; justify-content: center;
|
|
@@ -457,14 +456,14 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
457
456
|
:host([visible]) button { opacity: 1; visibility: visible; transform: translateY(0); }
|
|
458
457
|
svg { width: 1.25rem; height: 1.25rem; }
|
|
459
458
|
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
|
|
460
|
-
|
|
461
|
-
<style>${
|
|
459
|
+
`,q=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._onScroll=this._onScroll.bind(this)}connectedCallback(){let e=parseInt(this.getAttribute("threshold")||"300",10);this._threshold=e,this.shadowRoot.innerHTML=`
|
|
460
|
+
<style>${Ae}</style>
|
|
462
461
|
<button part="button" aria-label="Scroll to top">
|
|
463
462
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
464
463
|
<line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/>
|
|
465
464
|
</svg>
|
|
466
465
|
</button>
|
|
467
|
-
`,this.shadowRoot.querySelector("button").addEventListener("click",()=>{let t=window.matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:0,behavior:t?"auto":"smooth"})}),window.addEventListener("scroll",this._onScroll,{passive:!0}),this._onScroll()}_onScroll(){window.scrollY>this._threshold?this.setAttribute("visible",""):this.removeAttribute("visible")}disconnectedCallback(){window.removeEventListener("scroll",this._onScroll)}};customElements.define("velin-scroll-top"
|
|
466
|
+
`,this.shadowRoot.querySelector("button").addEventListener("click",()=>{let t=window.matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:0,behavior:t?"auto":"smooth"})}),window.addEventListener("scroll",this._onScroll,{passive:!0}),this._onScroll()}_onScroll(){window.scrollY>this._threshold?this.setAttribute("visible",""):this.removeAttribute("visible")}disconnectedCallback(){window.removeEventListener("scroll",this._onScroll)}};customElements.define("velin-scroll-top",q);var Ee=q;var Le=`
|
|
468
467
|
:host { display: block; position: relative; overflow: hidden; }
|
|
469
468
|
.track {
|
|
470
469
|
display: flex; transition: transform 400ms ease;
|
|
@@ -491,9 +490,15 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
491
490
|
button:disabled { opacity: 0.3; cursor: not-allowed; }
|
|
492
491
|
svg { width: 1.25rem; height: 1.25rem; }
|
|
493
492
|
.indicators {
|
|
494
|
-
display: flex; justify-content: center; gap: var(--velin-space-2, 0.5rem);
|
|
493
|
+
display: flex; justify-content: center; align-items: center; gap: var(--velin-space-2, 0.5rem);
|
|
495
494
|
padding-block: var(--velin-space-3, 0.75rem);
|
|
496
495
|
}
|
|
496
|
+
.pause-btn {
|
|
497
|
+
font-size: var(--velin-text-xs, 0.75rem);
|
|
498
|
+
padding-inline: var(--velin-space-3, 0.75rem);
|
|
499
|
+
min-inline-size: auto;
|
|
500
|
+
border-radius: var(--velin-radius-md, 0.375rem);
|
|
501
|
+
}
|
|
497
502
|
.dot {
|
|
498
503
|
display: inline-flex; align-items: center; justify-content: center;
|
|
499
504
|
min-width: 2.75rem; min-height: 2.75rem;
|
|
@@ -509,8 +514,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
509
514
|
.dot[aria-current="true"]::before { background: var(--velin-color-primary, #2563eb); transform: scale(1.3); }
|
|
510
515
|
.dot:focus-visible { outline: 2px solid var(--velin-color-focus, #2563eb); outline-offset: 2px; }
|
|
511
516
|
@media (prefers-reduced-motion: reduce) { .track { transition: none; } }
|
|
512
|
-
`,
|
|
513
|
-
<style>${
|
|
517
|
+
`,z=class extends HTMLElement{static get observedAttributes(){return["autoplay","interval"]}constructor(){super(),this.attachShadow({mode:"open"}),this._index=0,this._timer=null,this._startX=0,this._autoplayPaused=!1}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
518
|
+
<style>${Le}</style>
|
|
514
519
|
<div class="track" role="group" aria-roledescription="carousel" part="track"><slot></slot></div>
|
|
515
520
|
<div class="controls" part="controls">
|
|
516
521
|
<button class="prev" aria-label="Previous slide" part="prev">
|
|
@@ -520,8 +525,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
520
525
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 6 15 12 9 18"/></svg>
|
|
521
526
|
</button>
|
|
522
527
|
</div>
|
|
523
|
-
<div class="indicators" role="
|
|
524
|
-
`,this.shadowRoot.querySelector(".prev").addEventListener("click",()=>this.prev()),this.shadowRoot.querySelector(".next").addEventListener("click",()=>this.next());let e=this.shadowRoot.querySelector(".track");e.addEventListener("touchstart",s=>{this._startX=s.touches[0].clientX},{passive:!0}),e.addEventListener("touchend",s=>{let i=this._startX-s.changedTouches[0].clientX;Math.abs(i)>50&&(i>0?this.next():this.prev())}),this.addEventListener("mouseenter",()=>this._pause()),this.addEventListener("mouseleave",()=>this._resume()),this.addEventListener("focusin",()=>this._pause()),this.addEventListener("focusout",()=>this._resume()),this.addEventListener("keydown",s=>{s.key==="ArrowLeft"?(this.prev(),s.preventDefault()):s.key==="ArrowRight"?(this.next(),s.preventDefault()):s.key==="Home"?(this.goTo(0),s.preventDefault()):s.key==="End"&&(this.goTo(this._count-1),s.preventDefault())}),this.hasAttribute("role")||this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.shadowRoot.querySelector("slot").addEventListener("slotchange",()=>{this._buildDots(),this._update()}),this.hasAttribute("autoplay")&&this._startAutoplay()}get _slides(){return this.shadowRoot.querySelector("slot").assignedElements()}get _count(){return this._slides.length}prev(){this._index=(this._index-1+this._count)%this._count,this._update(),this._emit()}next(){this._index=(this._index+1)%this._count,this._update(),this._emit()}goTo(e){this._index=Math.max(0,Math.min(e,this._count-1)),this._update(),this._emit()}_update(){let e=this.shadowRoot.querySelector(".track");e.style.transform=`translateX(-${this._index*100}%)`,this._slides.forEach((t,s)=>{t.setAttribute("aria-hidden",s!==this._index?"true":"false"),t.inert=s!==this._index,t.setAttribute("aria-roledescription","slide"),t.setAttribute("aria-label",`Slide ${s+1} of ${this._count}`)}),this.shadowRoot.querySelectorAll(".dot").forEach((t,s)=>{t.setAttribute("aria-current",s===this._index?"true":"false")})}_buildDots(){let e=this.shadowRoot.querySelector(".indicators");e.innerHTML="",this._slides.forEach((t,s)=>{let i=document.createElement("button");i.
|
|
528
|
+
<div class="indicators" role="group" aria-label="Slide indicators" part="indicators"></div>
|
|
529
|
+
`,this.shadowRoot.querySelector(".prev").addEventListener("click",()=>this.prev()),this.shadowRoot.querySelector(".next").addEventListener("click",()=>this.next());let e=this.shadowRoot.querySelector(".track");e.addEventListener("touchstart",s=>{this._startX=s.touches[0].clientX},{passive:!0}),e.addEventListener("touchend",s=>{let i=this._startX-s.changedTouches[0].clientX;Math.abs(i)>50&&(i>0?this.next():this.prev())}),this.addEventListener("mouseenter",()=>this._pause()),this.addEventListener("mouseleave",()=>this._resume()),this.addEventListener("focusin",()=>this._pause()),this.addEventListener("focusout",()=>this._resume()),this.addEventListener("keydown",s=>{s.key==="ArrowLeft"?(this.prev(),s.preventDefault()):s.key==="ArrowRight"?(this.next(),s.preventDefault()):s.key==="Home"?(this.goTo(0),s.preventDefault()):s.key==="End"&&(this.goTo(this._count-1),s.preventDefault())}),this.hasAttribute("role")||this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.shadowRoot.querySelector("slot").addEventListener("slotchange",()=>{this._buildDots(),this._update()}),this.hasAttribute("autoplay")&&this._startAutoplay()}get _slides(){return this.shadowRoot.querySelector("slot").assignedElements()}get _count(){return this._slides.length}prev(){this._index=(this._index-1+this._count)%this._count,this._update(),this._emit()}next(){this._index=(this._index+1)%this._count,this._update(),this._emit()}goTo(e){this._index=Math.max(0,Math.min(e,this._count-1)),this._update(),this._emit()}_update(){let e=this.shadowRoot.querySelector(".track");e.style.transform=`translateX(-${this._index*100}%)`,this._slides.forEach((t,s)=>{t.setAttribute("aria-hidden",s!==this._index?"true":"false"),t.inert=s!==this._index,t.setAttribute("aria-roledescription","slide"),t.setAttribute("aria-label",`Slide ${s+1} of ${this._count}`)}),this.shadowRoot.querySelectorAll(".dot").forEach((t,s)=>{t.setAttribute("aria-current",s===this._index?"true":"false")})}_buildDots(){let e=this.shadowRoot.querySelector(".indicators");if(e.innerHTML="",this._slides.forEach((t,s)=>{let i=document.createElement("button");i.type="button",i.className="dot",i.setAttribute("aria-label",`Go to slide ${s+1}`),i.addEventListener("click",()=>this.goTo(s)),e.appendChild(i)}),this.hasAttribute("autoplay")){let t=document.createElement("button");t.type="button",t.className="pause-btn",t.setAttribute("aria-pressed","false"),t.setAttribute("aria-label","Pause automatic slide show"),t.textContent="Pause",t.addEventListener("click",()=>this._toggleAutoplayPause(t)),e.appendChild(t)}this._update()}_toggleAutoplayPause(e){this._autoplayPaused=!this._autoplayPaused,this._autoplayPaused?(this._pause(),e.setAttribute("aria-pressed","true"),e.setAttribute("aria-label","Resume automatic slide show"),e.textContent="Play"):(this._resume(),e.setAttribute("aria-pressed","false"),e.setAttribute("aria-label","Pause automatic slide show"),e.textContent="Pause")}_emit(){this.dispatchEvent(new CustomEvent("velin-slide-change",{bubbles:!0,detail:{index:this._index}}))}_startAutoplay(){let e=parseInt(this.getAttribute("interval")||"5000",10);this._timer=setInterval(()=>this.next(),e)}_pause(){this._timer&&(clearInterval(this._timer),this._timer=null)}_resume(){this.hasAttribute("autoplay")&&!this._timer&&!this._autoplayPaused&&this._startAutoplay()}disconnectedCallback(){this._pause()}};customElements.define("velin-carousel",z);var Se=z;var Te=`
|
|
525
530
|
:host { display: block; }
|
|
526
531
|
.content {
|
|
527
532
|
overflow: hidden;
|
|
@@ -532,13 +537,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
532
537
|
:host([open]) .content { grid-template-rows: 1fr; }
|
|
533
538
|
.inner { min-height: 0; }
|
|
534
539
|
@media (prefers-reduced-motion: reduce) { .content { transition: none; } }
|
|
535
|
-
`,
|
|
536
|
-
<style>${ke}</style>
|
|
537
|
-
<slot name="trigger"></slot>
|
|
538
|
-
<div class="content" role="region" part="content">
|
|
539
|
-
<div class="inner"><slot></slot></div>
|
|
540
|
-
</div>
|
|
541
|
-
`;let e=this.shadowRoot.querySelector('slot[name="trigger"]');e.addEventListener("slotchange",()=>{let t=e.assignedElements()[0];t&&(t.addEventListener("click",()=>this.toggle()),t.setAttribute("aria-expanded",this.hasAttribute("open")))})}attributeChangedCallback(e){if(e==="open"){let t=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];t&&t.setAttribute("aria-expanded",this.hasAttribute("open"))}}toggle(){this.hasAttribute("open")?this.close():this.open()}open(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("velin-open",{bubbles:!0}))}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}};customElements.define("velin-collapse",R);var Ee=R;var z=class extends HTMLElement{constructor(){super(),this._observer=null,this._activeId=null}connectedCallback(){let e=this.getAttribute("target")||"section[id]",t=this.getAttribute("nav")||"a",s=this.getAttribute("root-margin")||"-20% 0px -60% 0px",i=document.querySelectorAll(e);i.length&&(this._observer=new IntersectionObserver(r=>{for(let o of r)o.isIntersecting&&this._activate(o.target.id,t)},{rootMargin:s,threshold:0}),i.forEach(r=>this._observer.observe(r)))}_activate(e,t){if(this._activeId===e)return;this._activeId=e,this.querySelectorAll(t).forEach(i=>{i.getAttribute("href")===`#${e}`?(i.classList.add("velin-doc-sidebar__link--active"),i.setAttribute("aria-current","true")):(i.classList.remove("velin-doc-sidebar__link--active"),i.removeAttribute("aria-current"))}),this.dispatchEvent(new CustomEvent("velin-spy-change",{bubbles:!0,detail:{id:e}}))}disconnectedCallback(){this._observer&&this._observer.disconnect()}};customElements.define("velin-scrollspy",z);var Ae=z;var Le=`
|
|
540
|
+
`,Ce=0;function $e(o){let e=o.tagName;return e==="BUTTON"||e==="A"&&o.hasAttribute("href")||o.getAttribute("role")==="button"}var I=class extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),this.attachShadow({mode:"open"}),this._contentId=`velin-collapse-panel-${++Ce}`,this._onTriggerKey=this._onTriggerKey.bind(this)}connectedCallback(){let e=this._contentId;this.shadowRoot.innerHTML="<style>"+Te+'</style><slot name="trigger"></slot><div class="content" id="'+e+'" part="content"><div class="inner"><slot></slot></div></div>',this.shadowRoot.querySelector('slot[name="trigger"]').addEventListener("slotchange",()=>this._wireTrigger()),this._wireTrigger()}_wireTrigger(){let e=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];e&&($e(e)||(e.setAttribute("role","button"),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0")),e.setAttribute("aria-controls",this._contentId),e.setAttribute("aria-expanded",this.hasAttribute("open")?"true":"false"),e.removeEventListener("click",this._onClick),e.removeEventListener("keydown",this._onTriggerKey),this._onClick=()=>this.toggle(),e.addEventListener("click",this._onClick),e.addEventListener("keydown",this._onTriggerKey))}_onTriggerKey(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.toggle())}attributeChangedCallback(e){if(e==="open"){let t=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];t&&t.setAttribute("aria-expanded",this.hasAttribute("open")?"true":"false")}}toggle(){this.hasAttribute("open")?this.close():this.open()}open(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("velin-open",{bubbles:!0}))}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}};customElements.define("velin-collapse",I);var Me=I;var H=class extends HTMLElement{constructor(){super(),this._observer=null,this._activeId=null}connectedCallback(){let e=this.getAttribute("target")||"section[id]",t=this.getAttribute("nav")||"a",s=this.getAttribute("root-margin")||"-20% 0px -60% 0px",i=document.querySelectorAll(e);i.length&&(this._observer=new IntersectionObserver(r=>{for(let n of r)n.isIntersecting&&this._activate(n.target.id,t)},{rootMargin:s,threshold:0}),i.forEach(r=>this._observer.observe(r)))}_activate(e,t){if(this._activeId===e)return;this._activeId=e,this.querySelectorAll(t).forEach(i=>{i.getAttribute("href")===`#${e}`?(i.classList.add("velin-doc-sidebar__link--active"),i.setAttribute("aria-current","true")):(i.classList.remove("velin-doc-sidebar__link--active"),i.removeAttribute("aria-current"))}),this.dispatchEvent(new CustomEvent("velin-spy-change",{bubbles:!0,detail:{id:e}}))}disconnectedCallback(){this._observer&&this._observer.disconnect()}};customElements.define("velin-scrollspy",H);var Re=H;var qe=`
|
|
542
541
|
:host { position: relative; display: inline-block; }
|
|
543
542
|
.tip {
|
|
544
543
|
position: absolute; z-index: var(--velin-z-tooltip, 700);
|
|
@@ -557,11 +556,11 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
557
556
|
.tip[data-placement="start"] { right: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
|
|
558
557
|
.tip[data-placement="end"] { left: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
|
|
559
558
|
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }
|
|
560
|
-
`,
|
|
561
|
-
<style>${
|
|
559
|
+
`,ze=0,F=class extends HTMLElement{static get observedAttributes(){return["content","placement"]}constructor(){super(),this.attachShadow({mode:"open"}),this._tipId=`velin-tooltip-${++ze}`}connectedCallback(){let e=this.getAttribute("placement")||"top",t="div";this.shadowRoot.innerHTML=`
|
|
560
|
+
<style>${qe}</style>
|
|
562
561
|
<slot></slot>
|
|
563
|
-
|
|
564
|
-
`,this.addEventListener("mouseenter",()=>this._show()),this.addEventListener("mouseleave",()=>this._hide()),this.addEventListener("focusin",()=>this._show()),this.addEventListener("focusout",()=>this._hide()),this.addEventListener("keydown",
|
|
562
|
+
<${t} class="tip" id="${this._tipId}" role="tooltip" data-placement="${a(e)}" part="tip">${a(this.getAttribute("content")||"")}</${t}>
|
|
563
|
+
`,this.addEventListener("mouseenter",()=>this._show()),this.addEventListener("mouseleave",()=>this._hide()),this.addEventListener("focusin",()=>this._show()),this.addEventListener("focusout",()=>this._hide()),this.addEventListener("keydown",i=>{i.key==="Escape"&&this._hide()}),this.shadowRoot.querySelector("slot").addEventListener("slotchange",()=>this._linkTrigger()),this._linkTrigger()}_linkTrigger(){let e=this.shadowRoot.querySelector("slot")?.assignedElements()[0];e&&(this.hasAttribute("visible")?e.setAttribute("aria-describedby",this._tipId):e.removeAttribute("aria-describedby"))}_show(){this.setAttribute("visible","");let e=this.shadowRoot.querySelector("slot")?.assignedElements()[0];e&&e.setAttribute("aria-describedby",this._tipId),this._flip()}_hide(){this.removeAttribute("visible");let e=this.shadowRoot.querySelector("slot")?.assignedElements()[0];e&&e.removeAttribute("aria-describedby")}_flip(){let e=this.shadowRoot.querySelector(".tip");if(!e)return;let t=e.getBoundingClientRect(),s=this.getAttribute("placement")||"top";s==="top"&&t.top<0?e.setAttribute("data-placement","bottom"):s==="bottom"&&t.bottom>window.innerHeight?e.setAttribute("data-placement","top"):e.setAttribute("data-placement",s)}attributeChangedCallback(e,t,s){let i=this.shadowRoot?.querySelector(".tip");i&&(e==="content"&&(i.textContent=s),e==="placement"&&i.setAttribute("data-placement",s))}};customElements.define("velin-tooltip-wc",F);var Ie=F;var He=`
|
|
565
564
|
:host { display: contents; }
|
|
566
565
|
.overlay {
|
|
567
566
|
position: fixed; inset: 0; z-index: var(--velin-z-modal, 500);
|
|
@@ -600,8 +599,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
600
599
|
.nav--prev { left: 0.5rem; }
|
|
601
600
|
.nav--next { right: 0.5rem; }
|
|
602
601
|
}
|
|
603
|
-
`,
|
|
604
|
-
<style>${
|
|
602
|
+
`,D=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._index=0,this._items=[],this._previousFocus=null,this._onTrapKey=e=>{e.key==="Tab"&&u(this.shadowRoot,e)}}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
603
|
+
<style>${He}</style>
|
|
605
604
|
<slot></slot>
|
|
606
605
|
<div class="overlay" role="dialog" aria-modal="true" aria-label="Image lightbox" aria-roledescription="lightbox" part="overlay">
|
|
607
606
|
<button class="nav nav--prev" aria-label="Previous">‹</button>
|
|
@@ -610,7 +609,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
610
609
|
<button class="close" aria-label="Close">×</button>
|
|
611
610
|
<div class="counter" part="counter"></div>
|
|
612
611
|
</div>
|
|
613
|
-
`;let e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",()=>{this._items=e.assignedElements().filter(t=>t.tagName==="IMG"||t.tagName==="VIDEO"||t.dataset.velinLightbox),this._items.forEach((t,s)=>{t.style.cursor="pointer",t.addEventListener("click",()=>this.open(s))})}),this.shadowRoot.querySelector(".close").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".nav--prev").addEventListener("click",()=>this._prev()),this.shadowRoot.querySelector(".nav--next").addEventListener("click",()=>this._next()),this.shadowRoot.querySelector(".overlay").addEventListener("click",t=>{t.target.classList.contains("overlay")&&this.close()}),this.shadowRoot.querySelector(".overlay").addEventListener("keydown",t=>{t.key==="Escape"&&this.close(),t.key==="ArrowLeft"&&this._prev(),t.key==="ArrowRight"&&this._next()})}open(e=0){this._previousFocus=document.activeElement,this._index=e,this.setAttribute("open",""),this._render(),document.body.style.overflow="hidden";let t=this.shadowRoot.querySelector(".overlay");t.removeEventListener("keydown",this._onTrapKey),t.addEventListener("keydown",this._onTrapKey),this.shadowRoot.querySelector(".close").focus()}close(){this.removeAttribute("open"),document.body.style.overflow="",this._previousFocus&&(this._previousFocus.focus(),this._previousFocus=null),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_prev(){this._index=(this._index-1+this._items.length)%this._items.length,this._render()}_next(){this._index=(this._index+1)%this._items.length,this._render()}_render(){let e=this.shadowRoot.querySelector(".content"),t=this._items[this._index];if(!t)return;let s=
|
|
612
|
+
`;let e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",()=>{this._items=e.assignedElements().filter(t=>t.tagName==="IMG"||t.tagName==="VIDEO"||t.dataset.velinLightbox),this._items.forEach((t,s)=>{t.style.cursor="pointer",t.addEventListener("click",()=>this.open(s))})}),this.shadowRoot.querySelector(".close").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".nav--prev").addEventListener("click",()=>this._prev()),this.shadowRoot.querySelector(".nav--next").addEventListener("click",()=>this._next()),this.shadowRoot.querySelector(".overlay").addEventListener("click",t=>{t.target.classList.contains("overlay")&&this.close()}),this.shadowRoot.querySelector(".overlay").addEventListener("keydown",t=>{t.key==="Escape"&&this.close(),t.key==="ArrowLeft"&&this._prev(),t.key==="ArrowRight"&&this._next()})}open(e=0){this._previousFocus=document.activeElement,this._index=e,this.setAttribute("open",""),this._render(),document.body.style.overflow="hidden";let t=this.shadowRoot.querySelector(".overlay");t.removeEventListener("keydown",this._onTrapKey),t.addEventListener("keydown",this._onTrapKey),this.shadowRoot.querySelector(".close").focus()}close(){this.removeAttribute("open"),document.body.style.overflow="",this._previousFocus&&(this._previousFocus.focus(),this._previousFocus=null),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_prev(){this._index=(this._index-1+this._items.length)%this._items.length,this._render()}_next(){this._index=(this._index+1)%this._items.length,this._render()}_render(){let e=this.shadowRoot.querySelector(".content"),t=this._items[this._index];if(!t)return;let s=J(t.dataset.velinLightbox||t.src),i=a(t.alt||"");t.tagName==="VIDEO"?e.innerHTML=`<video src="${a(s)}" controls autoplay></video>`:e.innerHTML=`<img src="${a(s)}" alt="${i}">`;let r=this.shadowRoot.querySelector(".counter");r.textContent=`${this._index+1} / ${this._items.length}`}};customElements.define("velin-lightbox",D);var Fe=D;var De=`
|
|
614
613
|
:host { display: block; }
|
|
615
614
|
.steps {
|
|
616
615
|
display: flex; gap: var(--velin-space-2, 0.5rem);
|
|
@@ -659,11 +658,11 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
659
658
|
.panels ::slotted(*) { display: none; }
|
|
660
659
|
.panels ::slotted([data-active]) { display: block; }
|
|
661
660
|
@media (prefers-reduced-motion: reduce) { .step__marker { transition: none; } }
|
|
662
|
-
`,
|
|
663
|
-
<style>${
|
|
661
|
+
`,K=class extends HTMLElement{static get observedAttributes(){return["active"]}constructor(){super(),this.attachShadow({mode:"open"}),this._current=0}connectedCallback(){this._current=parseInt(this.getAttribute("active")||"0",10),this._buildSteps()}_buildSteps(){let t=(this.getAttribute("labels")||"").split(",").map(s=>s.trim()).map((s,i)=>{let r=i<this._current?"completed":i===this._current?"active":"",n=i<this._current?"✓":i+1,l=i===this._current?' aria-current="step"':"";return`<div class="step ${r}" role="listitem"${l}><span class="step__marker" aria-hidden="true">${n}</span><span class="step__label">${a(s)}</span></div>`}).join("");this.shadowRoot.innerHTML=`
|
|
662
|
+
<style>${De}</style>
|
|
664
663
|
<div class="steps" role="list" aria-label="Progress" part="steps">${t}</div>
|
|
665
664
|
<div class="panels" part="panels"><slot></slot></div>
|
|
666
|
-
`,this._updatePanels()}_updatePanels(){(this.shadowRoot.querySelector("slot")?.assignedElements()||[]).forEach((t,s)=>{s===this._current?t.setAttribute("data-active",""):t.removeAttribute("data-active")})}next(){let e=(this.getAttribute("labels")||"").split(",");this._current<e.length-1&&(this._current++,this.setAttribute("active",this._current),this._buildSteps(),this.dispatchEvent(new CustomEvent("velin-step-change",{bubbles:!0,detail:{step:this._current}})))}prev(){this._current>0&&(this._current--,this.setAttribute("active",this._current),this._buildSteps(),this.dispatchEvent(new CustomEvent("velin-step-change",{bubbles:!0,detail:{step:this._current}})))}goTo(e){this._current=e,this.setAttribute("active",this._current),this._buildSteps(),this.dispatchEvent(new CustomEvent("velin-step-change",{bubbles:!0,detail:{step:this._current}}))}attributeChangedCallback(e,t,s){e==="active"&&t!==null&&t!==s&&(this._current=parseInt(s,10),this._buildSteps())}};customElements.define("velin-stepper-wc",
|
|
665
|
+
`,this._updatePanels()}_updatePanels(){(this.shadowRoot.querySelector("slot")?.assignedElements()||[]).forEach((t,s)=>{s===this._current?t.setAttribute("data-active",""):t.removeAttribute("data-active")})}next(){let e=(this.getAttribute("labels")||"").split(",");this._current<e.length-1&&(this._current++,this.setAttribute("active",this._current),this._buildSteps(),this.dispatchEvent(new CustomEvent("velin-step-change",{bubbles:!0,detail:{step:this._current}})))}prev(){this._current>0&&(this._current--,this.setAttribute("active",this._current),this._buildSteps(),this.dispatchEvent(new CustomEvent("velin-step-change",{bubbles:!0,detail:{step:this._current}})))}goTo(e){this._current=e,this.setAttribute("active",this._current),this._buildSteps(),this.dispatchEvent(new CustomEvent("velin-step-change",{bubbles:!0,detail:{step:this._current}}))}attributeChangedCallback(e,t,s){e==="active"&&t!==null&&t!==s&&(this._current=parseInt(s,10),this._buildSteps())}};customElements.define("velin-stepper-wc",K);var Ke=K;var je=`
|
|
667
666
|
:host { display: contents; }
|
|
668
667
|
dialog {
|
|
669
668
|
border: none; border-radius: var(--velin-radius-lg, 0.75rem);
|
|
@@ -720,12 +719,12 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
720
719
|
color: var(--velin-color-text, #1a1a2e);
|
|
721
720
|
}
|
|
722
721
|
.input:focus { outline: 3px solid var(--velin-color-focus, #2563eb); outline-offset: 0; border-color: var(--velin-color-primary, #2563eb); }
|
|
723
|
-
`,
|
|
724
|
-
<button class="btn ${s.danger?"btn--danger":"btn--primary"}" data-action="confirm">${l}</button>`,
|
|
722
|
+
`,j=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._resolve=null,this._previousFocus=null}connectedCallback(){this.shadowRoot.innerHTML=`<style>${je}</style><dialog part="dialog"></dialog>`}alert(e,{title:t="Alert",confirmText:s="OK"}={}){return this._show("alert",e,{title:t,confirmText:s})}confirm(e,{title:t="Confirm",confirmText:s="Confirm",cancelText:i="Cancel",danger:r=!1}={}){return this._show("confirm",e,{title:t,confirmText:s,cancelText:i,danger:r})}prompt(e,{title:t="Input",confirmText:s="Submit",cancelText:i="Cancel",placeholder:r="",defaultValue:n=""}={}){return this._show("prompt",e,{title:t,confirmText:s,cancelText:i,placeholder:r,defaultValue:n})}_show(e,t,s){let i=this.shadowRoot.querySelector("dialog");this._previousFocus=document.activeElement;let r=a(s.title),n=a(t),l=a(s.confirmText),d=a(s.cancelText||""),b=a(s.placeholder||""),X=a(s.defaultValue||""),Y=e==="alert"?`<button class="btn btn--primary" data-action="confirm">${l}</button>`:`<button class="btn" data-action="cancel">${d}</button>
|
|
723
|
+
<button class="btn ${s.danger?"btn--danger":"btn--primary"}" data-action="confirm">${l}</button>`,V=e==="prompt"?`<input class="input" placeholder="${b}" value="${X}" part="input">`:"";if(i.innerHTML=`
|
|
725
724
|
<div class="header"><h3 class="title">${r}</h3><button class="close" aria-label="Close">×</button></div>
|
|
726
|
-
<div class="body"><p>${
|
|
727
|
-
<div class="footer">${
|
|
728
|
-
`,i.showModal(),e!=="prompt"){let
|
|
725
|
+
<div class="body"><p>${n}</p>${V}</div>
|
|
726
|
+
<div class="footer">${Y}</div>
|
|
727
|
+
`,i.showModal(),e!=="prompt"){let m=i.querySelector("[data-action]");m&&m.focus()}return new Promise(m=>{if(this._resolve=m,i.querySelector(".close").addEventListener("click",()=>this._dismiss(e,!1,i)),i.querySelectorAll("[data-action]").forEach(c=>{c.addEventListener("click",()=>this._dismiss(e,c.dataset.action==="confirm",i))}),i.addEventListener("cancel",c=>{c.preventDefault(),this._dismiss(e,!1,i)}),e==="prompt"){let c=i.querySelector(".input");c.focus(),c.addEventListener("keydown",U=>{U.key==="Enter"&&this._dismiss(e,!0,i)})}})}_dismiss(e,t,s){if(!this._resolve)return;let i;e==="alert"?i=!0:e==="confirm"?i=t:i=t?s.querySelector(".input")?.value??"":null,s.close(),this._previousFocus&&(this._previousFocus.focus(),this._previousFocus=null),this._resolve(i),this._resolve=null,this.dispatchEvent(new CustomEvent("velin-dialog-close",{bubbles:!0,detail:{value:i}}))}};customElements.define("velin-dialog",j);var Pe=j;var Ne=`
|
|
729
728
|
:host { display: inline-flex; font-variant-numeric: tabular-nums; }
|
|
730
729
|
.wrap { display: inline-flex; gap: var(--velin-space-3, 0.75rem); align-items: flex-start; }
|
|
731
730
|
.segment {
|
|
@@ -755,7 +754,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
755
754
|
:host([size="sm"]) .value { font-size: var(--velin-text-xl, 1.25rem); }
|
|
756
755
|
:host([size="sm"]) .segment { min-width: 2.5rem; }
|
|
757
756
|
:host([size="lg"]) .value { font-size: var(--velin-text-5xl, 3.052rem); }
|
|
758
|
-
`,
|
|
757
|
+
`,P=class extends HTMLElement{static get observedAttributes(){return["datetime"]}constructor(){super(),this.attachShadow({mode:"open"}),this._timer=null}connectedCallback(){this.shadowRoot.innerHTML=`<style>${Ne}</style><div class="wrap"></div>`,this._wrap=this.shadowRoot.querySelector(".wrap"),this.setAttribute("role","timer"),this.setAttribute("aria-live","polite"),this.setAttribute("aria-atomic","true"),this._start()}_start(){this._update(),this._timer=setInterval(()=>this._update(),1e3)}_update(){let e=new Date(this.getAttribute("datetime")).getTime(),t=Date.now(),s=Math.max(0,e-t),i=Math.floor(s/864e5),r=Math.floor(s%864e5/36e5),n=Math.floor(s%36e5/6e4),l=Math.floor(s%6e4/1e3),d=Q=>String(Q).padStart(2,"0"),b=this.getAttribute("show-days")!=="false",X=a(this.getAttribute("label-days")||"Days"),Y=a(this.getAttribute("label-hours")||"Hours"),V=a(this.getAttribute("label-minutes")||"Min"),m=a(this.getAttribute("label-seconds")||"Sec"),c="";b&&(c+=`<div class="segment" part="days"><span class="value">${d(i)}</span><span class="label">${X}</span></div><span class="separator">:</span>`),c+=`<div class="segment" part="hours"><span class="value">${d(r)}</span><span class="label">${Y}</span></div><span class="separator">:</span>`,c+=`<div class="segment" part="minutes"><span class="value">${d(n)}</span><span class="label">${V}</span></div><span class="separator">:</span>`,c+=`<div class="segment" part="seconds"><span class="value">${d(l)}</span><span class="label">${m}</span></div>`,this._wrap&&(this._wrap.innerHTML=c);let U=`${i} days, ${r} hours, ${n} minutes, ${l} seconds remaining`;this.setAttribute("aria-label",U),s<=0&&(clearInterval(this._timer),this.dispatchEvent(new CustomEvent("velin-countdown-end",{bubbles:!0})))}disconnectedCallback(){this._timer&&clearInterval(this._timer)}attributeChangedCallback(){this._timer&&(clearInterval(this._timer),this._start())}};customElements.define("velin-countdown",P);var Be=P;var Oe=`
|
|
759
758
|
:host { display: inline-flex; align-items: center; justify-content: center; }
|
|
760
759
|
svg { transform: rotate(-90deg); }
|
|
761
760
|
.track { fill: none; stroke: var(--velin-color-border, #e5e5e5); }
|
|
@@ -773,13 +772,13 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
773
772
|
}
|
|
774
773
|
:host { position: relative; }
|
|
775
774
|
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
|
|
776
|
-
`,
|
|
777
|
-
<style>${
|
|
775
|
+
`,N=class extends HTMLElement{static get observedAttributes(){return["value","size","stroke","color"]}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this._render()}_render(){let e=Math.min(100,Math.max(0,parseInt(this.getAttribute("value")||"0",10))),t=parseInt(this.getAttribute("size")||"120",10),s=parseInt(this.getAttribute("stroke")||"8",10),i=(t-s)/2,r=2*Math.PI*i,n=r-e/100*r,l=this.getAttribute("color"),d=l?`stroke: var(--velin-color-${l}, ${l});`:"",b=this.getAttribute("label")!=="false";this.shadowRoot.innerHTML=`
|
|
776
|
+
<style>${Oe}</style>
|
|
778
777
|
<svg width="${t}" height="${t}" viewBox="0 0 ${t} ${t}" part="svg" role="progressbar" aria-valuenow="${e}" aria-valuemin="0" aria-valuemax="100">
|
|
779
778
|
<circle class="track" cx="${t/2}" cy="${t/2}" r="${i}" stroke-width="${s}" />
|
|
780
779
|
<circle class="fill" cx="${t/2}" cy="${t/2}" r="${i}" stroke-width="${s}"
|
|
781
|
-
stroke-dasharray="${r}" stroke-dashoffset="${
|
|
780
|
+
stroke-dasharray="${r}" stroke-dashoffset="${n}"
|
|
782
781
|
style="${d}" part="fill" />
|
|
783
782
|
</svg>
|
|
784
|
-
${
|
|
785
|
-
`,this.setAttribute("role","progressbar"),this.setAttribute("aria-valuenow",e),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.setAttribute("aria-label",this.getAttribute("aria-label")||`${e}%`)}attributeChangedCallback(){this._render()}};customElements.define("velin-progress-ring",
|
|
783
|
+
${b?`<span class="label" part="label">${e}%</span>`:""}
|
|
784
|
+
`,this.setAttribute("role","progressbar"),this.setAttribute("aria-valuenow",e),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.setAttribute("aria-label",this.getAttribute("aria-label")||`${e}%`)}attributeChangedCallback(){this._render()}};customElements.define("velin-progress-ring",N);var Xe=N;var Ye=/^[a-zA-Z0-9_-]{1,64}$/;var B=class extends HTMLElement{static get observedAttributes(){return["key","storage"]}constructor(){super(),this._debounceTimer=null,this._onInput=this._onInput.bind(this),this._onSubmit=this._onSubmit.bind(this),this._onReset=this._onReset.bind(this)}get storageKey(){let e=this.getAttribute("key")||"default";return`velin-persist-${Ye.test(e)?e:"default"}`}get _storage(){return this.getAttribute("storage")==="session"?sessionStorage:localStorage}connectedCallback(){this.style.display="contents",this.addEventListener("input",this._onInput),this.addEventListener("change",this._onInput),this.addEventListener("submit",this._onSubmit),this.addEventListener("reset",this._onReset),requestAnimationFrame(()=>this._restore())}disconnectedCallback(){this.removeEventListener("input",this._onInput),this.removeEventListener("change",this._onInput),this.removeEventListener("submit",this._onSubmit),this.removeEventListener("reset",this._onReset),this._debounceTimer&&clearTimeout(this._debounceTimer)}_onInput(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._save(),300)}_onSubmit(e){this.clear()}_onReset(){requestAnimationFrame(()=>this.clear())}_getFields(){return this.querySelectorAll("input[name], textarea[name], select[name]")}_save(){let e={};this._getFields().forEach(t=>{let s=t.name;s&&(t.type==="password"||t.type==="file"||(t.type==="checkbox"?e[s]=t.checked:t.type==="radio"?t.checked&&(e[s]=t.value):e[s]=t.value))});try{let t=JSON.stringify(e);if(t.length>65536)return;this._storage.setItem(this.storageKey,t)}catch(t){(t.name==="QuotaExceededError"||t.code===22)&&this.dispatchEvent(new CustomEvent("velin-persist-error",{bubbles:!0,detail:{error:"quota"}}))}}_restore(){let e;try{let t=this._storage.getItem(this.storageKey);if(!t||t.length>65536||(e=JSON.parse(t),typeof e!="object"||e===null))return}catch{return}this._getFields().forEach(t=>{let s=t.name;s in e&&(t.type==="checkbox"?t.checked=!!e[s]:t.type==="radio"?t.checked=t.value===e[s]:t.value=e[s])}),this.dispatchEvent(new CustomEvent("velin-persist-restore",{bubbles:!0,detail:{data:e}}))}clear(){try{this._storage.removeItem(this.storageKey)}catch{}this.dispatchEvent(new CustomEvent("velin-persist-clear",{bubbles:!0}))}};customElements.define("velin-persist",B);var Ve=B;var Z={tap:[10],"double-tap":[10,50,10],success:[50],error:[100,30,100],warning:[30,20,30],long:[200]};function W(o){if(typeof navigator>"u"||!navigator.vibrate||window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches)return;let t=typeof o=="string"?Z[o]||Z.tap:o;navigator.vibrate(t)}function O(o){let e=o.getAttribute("haptic")||"tap";o.addEventListener("click",()=>W(e))}var _=class{constructor(){this._observer=null}start(e=document.body){e.querySelectorAll("[haptic]").forEach(O),this._observer=new MutationObserver(s=>{for(let i of s)for(let r of i.addedNodes)r.nodeType===1&&(r.hasAttribute?.("haptic")&&O(r),r.querySelectorAll?.("[haptic]").forEach(O))}),this._observer.observe(e,{childList:!0,subtree:!0})}stop(){this._observer?.disconnect()}};if(typeof document<"u"){let o=()=>{new _().start(document.body)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o()}export{Z as HapticPatterns,ce as VelinAccordion,Se as VelinCarousel,Me as VelinCollapse,ke as VelinCopy,Be as VelinCountdown,Pe as VelinDialog,be as VelinDrawer,ae as VelinDropdown,_ as VelinHapticObserver,ve as VelinIcon,Fe as VelinLightbox,oe as VelinModal,Ve as VelinPersist,xe as VelinPopover,Xe as VelinProgressRing,Ee as VelinScrollTop,Re as VelinScrollspy,Ke as VelinStepperWC,ue as VelinTabs,ge as VelinThemeToggle,pe as VelinToast,Ie as VelinTooltipWC,O as applyHaptic,y as clearBackgroundInert,h as getFocusableElements,v as restoreFocus,f as rovingTabindex,p as saveFocus,g as setBackgroundInert,u as trapFocus,W as vibrate};
|