@birdapi/velinstyle 0.6.1 → 0.8.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 +337 -316
- package/README.md +33 -12
- package/cli/blueprint.js +8 -0
- package/cli/blueprints/bottom-nav-mobile.html +17 -0
- package/cli/blueprints/cookie-consent.html +9 -0
- package/cli/blueprints/empty-state.html +5 -0
- package/cli/blueprints/filter-bar.html +15 -0
- package/cli/blueprints/notification-center.html +13 -0
- package/cli/blueprints/onboarding.html +23 -0
- package/cli/blueprints/pricing-table.html +20 -0
- package/cli/blueprints/settings-panel.html +20 -0
- package/cli/index.js +119 -3
- package/cli/layout-audit.js +325 -0
- package/cli/scaffold-recipes.json +70 -0
- package/cli/scaffold.js +155 -0
- package/cli/scanner.js +114 -0
- package/components/focus-manager.js +106 -80
- package/components/index.js +20 -1
- package/components/sanitize.js +29 -3
- package/components/shadow-a11y-styles.js +18 -0
- package/components/velin-accordion.js +112 -98
- package/components/velin-announcer.js +35 -0
- package/components/velin-bottom-nav.js +89 -0
- package/components/velin-carousel.js +40 -5
- package/components/velin-collapse.js +95 -65
- package/components/velin-combobox.js +149 -0
- package/components/velin-command.js +127 -0
- package/components/velin-counter.js +152 -0
- package/components/velin-drawer.js +6 -3
- package/components/velin-dropdown.js +33 -2
- package/components/velin-flip.js +220 -0
- package/components/velin-icon.js +43 -9
- package/components/velin-live-dot.js +85 -0
- package/components/velin-menubar.js +83 -0
- package/components/velin-modal.js +3 -1
- package/components/velin-popover.js +61 -21
- package/components/velin-rating.js +91 -0
- package/components/velin-reveal.js +80 -0
- package/components/velin-segmented-control.js +108 -0
- package/components/velin-sheet.js +107 -0
- package/components/velin-sparkline.js +207 -0
- package/components/velin-theme-toggle.js +277 -60
- package/components/velin-tooltip-wc.js +26 -2
- package/dist/velinstyle-components.iife.js +1849 -120
- package/dist/velinstyle-components.js +1871 -120
- package/dist/velinstyle-components.min.js +434 -91
- package/dist/velinstyle.css +640 -44
- package/dist/velinstyle.min.css +1 -1
- package/package.json +7 -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 +119 -104
- package/src/a11y/target-size.css +32 -0
- package/src/base/reset.css +12 -1
- package/src/base/root.css +4 -4
- package/src/components/nav.css +152 -151
- package/src/tokens/motion.css +7 -0
- package/src/utilities/animation.css +97 -1
- package/src/utilities/chart-animation.css +101 -0
- package/src/utilities/filter-effects.css +103 -0
- package/src/utilities/safe-area.css +39 -0
- package/src/velinstyle.css +9 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Pe=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])',"summary","details"].join(", ");function je(r){if(r.hasAttribute("disabled")||r.getAttribute("aria-hidden")==="true"||r.closest("[inert]"))return!1;let e=r.ownerDocument.defaultView?.getComputedStyle(r);return e&&(e.visibility==="hidden"||e.display==="none")?!1:r.getClientRects().length>0}function _(r){return[...r.querySelectorAll(Pe)].filter(je)}function v(r,e){if(e.key!=="Tab")return;let t=_(r);if(t.length===0)return;let i=t[0],s=t[t.length-1],o=r.getRootNode().activeElement;e.shiftKey&&o===i?(e.preventDefault(),s.focus()):!e.shiftKey&&o===s&&(e.preventDefault(),i.focus())}function b(r,e,t){let i=e.indexOf(t.target);if(i===-1)return;let s;switch(t.key){case"ArrowDown":case"ArrowRight":t.preventDefault(),s=(i+1)%e.length;break;case"ArrowUp":case"ArrowLeft":t.preventDefault(),s=(i-1+e.length)%e.length;break;case"Home":t.preventDefault(),s=0;break;case"End":t.preventDefault(),s=e.length-1;break;default:return}e.forEach((o,n)=>{o.setAttribute("tabindex",n===s?"0":"-1")}),e[s].focus()}function g(){return document.activeElement}function y(r){r&&typeof r.focus=="function"&&r.focus()}var q=[];function A(r){q=[];for(let e of document.body.children)e===r||e.contains(r)||e.hasAttribute("inert")||(e.setAttribute("inert",""),q.push(e))}function E(){for(let r of q)r.removeAttribute("inert");q=[]}var Ye={"&":"&","<":"<",">":">",'"':""","'":"'"},Ve=/[&<>"']/g,Xe=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,Ue=new Set(["http:","https:","data:","mailto:","tel:"]),ke=/^data:text\/html/i;function a(r){return typeof r!="string"?"":r.replace(Ve,e=>Ye[e])}function ve(r){return typeof r!="string"?"":r.replace(Xe,"")}function We(r){return a(ve(r))}function be(r){if(typeof r!="string")return"";let e=r.trim();if(/^\s*javascript:/i.test(e)||/^\s*vbscript:/i.test(e)||ke.test(e))return"";try{let t=new URL(e,typeof location<"u"?location.href:"https://example.invalid/");return!Ue.has(t.protocol)||t.protocol==="data:"&&ke.test(e)?"":e}catch{return""}}var I=null;function Ae(){return I||(typeof window<"u"&&window.trustedTypes?.createPolicy&&(I=window.trustedTypes.createPolicy("velinstyle",{createHTML:r=>a(r)})),I)}function Ge(r){let e=Ae(),t=a(ve(r));return e?.createHTML?e.createHTML(t):t}var Ze=`
|
|
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
|
+
`,F=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>${Ze}</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",
|
|
95
|
+
`,this.shadowRoot.querySelector(".close-btn").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".overlay").addEventListener("click",i=>{i.target===i.currentTarget&&this.close()})}attributeChangedCallback(e,t,i){e==="open"&&(i!==null?this._open():this._close())}open(){this.setAttribute("open","")}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_open(){this._previouslyFocused=g(),A(this),document.addEventListener("keydown",this._onKeydown),document.body.style.overflow="hidden",requestAnimationFrame(()=>{let e=_(this.shadowRoot);e.length>0&&e[0].focus()})}_close(){document.removeEventListener("keydown",this._onKeydown),document.body.style.overflow="",E(),y(this._previouslyFocused)}_onKeydown(e){if(e.key==="Escape"){this.close();return}v(this.shadowRoot,e)}disconnectedCallback(){document.removeEventListener("keydown",this._onKeydown),document.body.style.overflow=""}};customElements.define("velin-modal",F);var Je=F;var Qe=`
|
|
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
|
+
`,z=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>${Qe}</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 s=t.assignedElements()[0];
|
|
151
|
+
`;let t=this.shadowRoot.querySelector('slot[name="trigger"]'),i=this.shadowRoot.querySelector("slot:not([name])");t.addEventListener("click",()=>this.toggle()),t.addEventListener("slotchange",()=>{let s=t.assignedElements()[0];if(s){s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded",this.hasAttribute("open")?"true":"false");let o=this._menuId||(this._menuId=`velin-dropdown-menu-${Math.random().toString(36).slice(2,9)}`);s.setAttribute("aria-controls",o),this.shadowRoot.querySelector(".menu")?.setAttribute("id",o)}}),i?.addEventListener("slotchange",()=>this._normalizeMenuItems()),this._normalizeMenuItems(),this.addEventListener("keydown",this._onKeydown)}_normalizeMenuItems(){this._getMenuItems().forEach((t,i)=>{t.hasAttribute("role")||t.setAttribute("role","menuitem"),t.setAttribute("tabindex",i===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 i=this.querySelector('[slot="trigger"]');i&&i.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 i=t.find(s=>(s.textContent?.trim().toLowerCase()||"").startsWith(this._typeahead));i&&(e.preventDefault(),t.forEach(s=>s.setAttribute("tabindex",s===i?"0":"-1")),i.focus());return}b(this,t,e)}}disconnectedCallback(){document.removeEventListener("click",this._onDocClick,!0)}};customElements.define("velin-dropdown",z);var et=z;var tt=`
|
|
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(
|
|
179
|
+
`,H=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._onToggle=this._onToggle.bind(this)}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
180
|
+
<style>${tt}</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 i=t.querySelector("summary"),s=t.querySelector(":scope > :not(summary)"),o=s?.id||`velin-accordion-panel-${++e}`;s&&!s.id&&(s.id=o),i&&s&&i.setAttribute("aria-controls",o)}}_onToggle(e){if(!this._exclusive)return;let t=e.target;if(!t.open)return;[...this.querySelectorAll("details")].forEach(s=>{s!==t&&s.open&&(s.open=!1)})}_onKeydown(e){let t=[...this.querySelectorAll("summary")],i=t.indexOf(e.target);if(i===-1)return;let s;switch(e.key){case"ArrowDown":e.preventDefault(),s=(i+1)%t.length;break;case"ArrowUp":e.preventDefault(),s=(i-1+t.length)%t.length;break;case"Home":e.preventDefault(),s=0;break;case"End":e.preventDefault(),s=t.length-1;break;default:return}t[s].focus()}disconnectedCallback(){this.removeEventListener("toggle",this._onToggle,!0)}};customElements.define("velin-accordion",H);var it=H;var st=`
|
|
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
|
+
`,D=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>${st}</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((
|
|
232
|
+
`,this.addEventListener("click",this._onTabClick),this.addEventListener("keydown",this._onKeydown),requestAnimationFrame(()=>this._initTabs())}_initTabs(){let e=this._getTabs(),t=this._getPanels();e.forEach((s,o)=>{s.setAttribute("role","tab"),s.setAttribute("slot","tab"),s.id||(s.id=`velin-tab-${o}`);let n=t[o];n&&(n.setAttribute("role","tabpanel"),n.setAttribute("slot","panel"),n.id||(n.id=`velin-panel-${o}`),s.setAttribute("aria-controls",n.id),n.setAttribute("aria-labelledby",s.id))});let i=e.find(s=>s.getAttribute("aria-selected")==="true")||e[0];i&&this._selectTab(i)}_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(),i=this._getPanels();t.forEach((s,o)=>{let n=s===e;s.setAttribute("aria-selected",String(n)),s.setAttribute("tabindex",n?"0":"-1"),i[o]&&(i[o].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)&&(b(this,t,e),e.key==="ArrowRight"||e.key==="ArrowLeft"||e.key==="Home"||e.key==="End")){let i=t.find(s=>s.getAttribute("tabindex")==="0");i&&this._selectTab(i)}}disconnectedCallback(){this.removeEventListener("click",this._onTabClick),this.removeEventListener("keydown",this._onKeydown)}};customElements.define("velin-tabs",D);var rt=D;var ot=`
|
|
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
|
+
`,K=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._container=null}connectedCallback(){this.shadowRoot.innerHTML=`<style>${ot}</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:i=5e3}={}){let s=document.createElement("div");return s.className=`toast toast--${t}`,s.innerHTML=`
|
|
295
295
|
<div class="toast-content">${a(e)}</div>
|
|
296
296
|
<button class="toast-close" aria-label="Close">×</button>
|
|
297
|
-
`,
|
|
297
|
+
`,s.querySelector(".toast-close").addEventListener("click",()=>{this._dismiss(s)}),this._container.appendChild(s),i>0&&setTimeout(()=>this._dismiss(s),i),s}_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",K);var nt=K;var N={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/solid/{name}.svg"},Ee={fontawesome:{regular:"https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/regular/{name}.svg",solid:"https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/solid/{name}.svg",brands:"https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.x/svgs/brands/{name}.svg"},heroicons:{outline:"https://unpkg.com/heroicons@2/24/outline/{name}.svg",solid:"https://unpkg.com/heroicons@2/24/solid/{name}.svg",mini:"https://unpkg.com/heroicons@2/20/solid/{name}.svg"}};function at(r,e){let t=Ee[r];return e&&t?.[e]?t[e]:N[r]}var fe=new Map,O=class extends HTMLElement{static get observedAttributes(){return["name","size","label","provider","variant","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",i=this.getAttribute("label"),s=this.getAttribute("provider"),o=this.getAttribute("variant");if(!e){this.innerHTML="";return}if(s&&(N[s]||Ee[s])){this._renderFromCDN(e,t,i,s,o);return}this._renderFromSprite(e,t,i)}_renderFromSprite(e,t,i){let s="http://www.w3.org/2000/svg",o=document.createElementNS(s,"svg");o.setAttribute("width",t),o.setAttribute("height",t),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2"),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),this._applyStyle(o),this._applyA11y(o,i);let n=document.createElementNS(s,"use"),c=this.getAttribute("sprite"),l=document.getElementById(e),d=l&&l.tagName&&l.tagName.toLowerCase()==="symbol",u;c===""||c==null&&d?u=`#${e}`:u=`${c||"velin-icons.svg"}#${e}`,n.setAttribute("href",u),o.appendChild(n),this.innerHTML="",this.appendChild(o),this._rendered=!0}async _renderFromCDN(e,t,i,s,o){let n=`${s}:${o||"default"}:${e}`;if(fe.has(n)){this._injectSVG(fe.get(n),t,i);return}let c=at(s,o);if(!c){this._renderFromSprite(e,t,i);return}let l=c.replace("{name}",e);try{let d=await fetch(l);if(!d.ok)throw new Error(`${d.status}`);let u=await d.text();if(!u.includes("<svg"))throw new Error("Not SVG");fe.set(n,u),this._injectSVG(u,t,i)}catch{this._renderFromSprite(e,t,i)}}_injectSVG(e,t,i){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,i),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(N)}static registerProvider(e,t){N[e]=t}};customElements.define("velin-icon",O);var lt=O;var ct=`
|
|
298
298
|
:host { display: contents; }
|
|
299
299
|
.overlay {
|
|
300
300
|
position: fixed;
|
|
@@ -339,45 +339,124 @@ 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
|
+
`,B=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),i="velin-drawer-title";this.shadowRoot.innerHTML=`
|
|
343
|
+
<style>${ct}</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="${i}" part="drawer">
|
|
346
346
|
<div class="header" part="header">
|
|
347
|
-
<h2 class="title">${t}</h2>
|
|
347
|
+
<h2 class="title" id="${i}">${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=
|
|
353
|
-
:host { display: inline-flex; }
|
|
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=g(),A(this),document.addEventListener("keydown",this._onKey),document.body.style.overflow="hidden",requestAnimationFrame(()=>{let e=_(this.shadowRoot);e.length&&e[0].focus()})}_close(){document.removeEventListener("keydown",this._onKey),document.body.style.overflow="",E(),y(this._prev)}_onKey(e){if(e.key==="Escape"){this.close();return}v(this.shadowRoot,e)}disconnectedCallback(){document.removeEventListener("keydown",this._onKey),document.body.style.overflow=""}};customElements.define("velin-drawer",B);var dt=B;var ut=[{slug:"",label:"Default (Light)"},{slug:"dark",label:"Dark"},{slug:"brutalist",label:"Brutalist"},{slug:"corporate",label:"Corporate"},{slug:"earth",label:"Earth"},{slug:"forest",label:"Forest"},{slug:"midnight",label:"Midnight"},{slug:"neon",label:"Neon"},{slug:"nordic",label:"Nordic"},{slug:"ocean",label:"Ocean"},{slug:"pastel",label:"Pastel"},{slug:"retro",label:"Retro"},{slug:"sharp",label:"Sharp"},{slug:"soft",label:"Soft"},{slug:"sunset",label:"Sunset"}],ht=new Set(["","dark"]),ge=new Set;function pt(r,e){if(!r||ht.has(r)||ge.has(r))return;if(document.querySelector(`link[data-velin-theme-css="${r}"]`)){ge.add(r);return}let i=document.createElement("link");i.rel="stylesheet",i.href=`${e.replace(/\/$/,"")}/${r}.min.css`,i.setAttribute("data-velin-theme-css",r),document.head.appendChild(i),ge.add(r)}var mt=`
|
|
353
|
+
:host { display: inline-flex; position: relative; }
|
|
354
|
+
.group {
|
|
355
|
+
display: inline-flex; align-items: stretch;
|
|
356
|
+
border: 2px solid var(--velin-color-border, #ddd);
|
|
357
|
+
border-radius: var(--velin-radius-md, 0.5rem);
|
|
358
|
+
background: none;
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
}
|
|
354
361
|
button {
|
|
355
362
|
display: inline-flex; align-items: center; justify-content: center;
|
|
356
|
-
min-
|
|
357
|
-
background: none; border:
|
|
358
|
-
|
|
359
|
-
|
|
363
|
+
min-height: 2.75rem; padding: 0.5rem;
|
|
364
|
+
background: none; border: 0; cursor: pointer;
|
|
365
|
+
color: var(--velin-color-text, #111);
|
|
366
|
+
transition: background 150ms ease;
|
|
367
|
+
}
|
|
368
|
+
button:hover { background: var(--velin-color-surface-dim, #eee); }
|
|
369
|
+
button:focus-visible {
|
|
370
|
+
outline: 3px solid var(--velin-color-focus, #2563eb);
|
|
371
|
+
outline-offset: 2px;
|
|
372
|
+
}
|
|
373
|
+
.toggle { min-width: 2.75rem; }
|
|
374
|
+
.picker {
|
|
375
|
+
min-width: 1.75rem;
|
|
376
|
+
border-inline-start: 1px solid var(--velin-color-border, #ddd);
|
|
377
|
+
color: var(--velin-color-text-muted, #555);
|
|
360
378
|
}
|
|
361
|
-
button:hover { background: var(--velin-color-surface-dim, #eee); border-color: var(--velin-color-border-strong, #999); }
|
|
362
|
-
button:focus-visible { outline: 3px solid var(--velin-color-focus, #2563eb); outline-offset: 2px; }
|
|
363
379
|
svg { width: 1.25rem; height: 1.25rem; transition: transform 300ms ease; }
|
|
380
|
+
.chev { width: 0.75rem; height: 0.75rem; }
|
|
364
381
|
:host([theme="dark"]) .sun { display: none; }
|
|
365
382
|
:host(:not([theme="dark"])) .moon { display: none; }
|
|
383
|
+
:host([compact]) .picker { display: none; }
|
|
384
|
+
:host([compact]) .toggle { border-inline-end: 0; }
|
|
366
385
|
@media (prefers-reduced-motion: reduce) { svg { transition: none; } }
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
386
|
+
|
|
387
|
+
.menu {
|
|
388
|
+
position: absolute;
|
|
389
|
+
top: calc(100% + 0.5rem);
|
|
390
|
+
inset-inline-end: 0;
|
|
391
|
+
z-index: 1000;
|
|
392
|
+
min-width: 12rem;
|
|
393
|
+
padding: 0.375rem;
|
|
394
|
+
background: var(--velin-color-surface-bright, #fff);
|
|
395
|
+
border: 1px solid var(--velin-color-border, #ddd);
|
|
396
|
+
border-radius: var(--velin-radius-md, 0.5rem);
|
|
397
|
+
box-shadow: var(--velin-shadow-lg, 0 12px 32px rgba(0,0,0,0.12));
|
|
398
|
+
list-style: none;
|
|
399
|
+
margin: 0;
|
|
400
|
+
display: none;
|
|
401
|
+
max-height: min(70vh, 24rem);
|
|
402
|
+
overflow-y: auto;
|
|
403
|
+
}
|
|
404
|
+
:host([menu-open]) .menu { display: block; }
|
|
405
|
+
.menu li { margin: 0; }
|
|
406
|
+
.menu button {
|
|
407
|
+
width: 100%;
|
|
408
|
+
justify-content: flex-start;
|
|
409
|
+
padding: 0.4rem 0.75rem;
|
|
410
|
+
font-size: 0.875rem;
|
|
411
|
+
color: var(--velin-color-text, #111);
|
|
412
|
+
border-radius: var(--velin-radius-sm, 0.25rem);
|
|
413
|
+
min-height: 2rem;
|
|
414
|
+
text-align: start;
|
|
415
|
+
}
|
|
416
|
+
.menu button:hover,
|
|
417
|
+
.menu button[aria-current="true"] {
|
|
418
|
+
background: var(--velin-color-primary-subtle, #eef);
|
|
419
|
+
color: var(--velin-color-primary, #2a4cf0);
|
|
420
|
+
}
|
|
421
|
+
.menu button[aria-current="true"] {
|
|
422
|
+
font-weight: 600;
|
|
423
|
+
}
|
|
424
|
+
.menu .swatch {
|
|
425
|
+
width: 0.75rem; height: 0.75rem;
|
|
426
|
+
border-radius: 50%;
|
|
427
|
+
margin-inline-end: 0.5rem;
|
|
428
|
+
background: currentColor;
|
|
429
|
+
border: 1px solid var(--velin-color-border, #ddd);
|
|
430
|
+
}
|
|
431
|
+
`,P=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._onDocClick=this._onDocClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this)}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
432
|
+
<style>${mt}</style>
|
|
433
|
+
<div class="group" part="group">
|
|
434
|
+
<button class="toggle" part="button" aria-label="Toggle dark mode">
|
|
435
|
+
<svg class="sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
436
|
+
<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"/>
|
|
437
|
+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
|
|
438
|
+
<line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/>
|
|
439
|
+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
|
440
|
+
</svg>
|
|
441
|
+
<svg class="moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
442
|
+
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/>
|
|
443
|
+
</svg>
|
|
444
|
+
</button>
|
|
445
|
+
<button class="picker" part="picker" aria-label="Choose theme" aria-haspopup="menu" aria-expanded="false">
|
|
446
|
+
<svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
447
|
+
<polyline points="6 9 12 15 18 9"/>
|
|
448
|
+
</svg>
|
|
449
|
+
</button>
|
|
450
|
+
</div>
|
|
451
|
+
<ul class="menu" role="menu" hidden></ul>
|
|
452
|
+
`,this._target=document.querySelector(this.getAttribute("target")||"html"),this._themesBase=this.getAttribute("themes-base")||"dist/themes",this._menu=this.shadowRoot.querySelector(".menu"),this._toggleBtn=this.shadowRoot.querySelector(".toggle"),this._pickerBtn=this.shadowRoot.querySelector(".picker"),this._renderMenu(),this._initPreference(),this._toggleBtn.addEventListener("click",()=>this._toggleDarkMode()),this._pickerBtn.addEventListener("click",t=>{t.stopPropagation(),this._toggleMenu()}),document.addEventListener("click",this._onDocClick),this.shadowRoot.addEventListener("keydown",this._onKeyDown),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>this._applyFromPreference()),window.addEventListener("storage",t=>{t.key==="velin-theme"&&this._readStorage()})}disconnectedCallback(){document.removeEventListener("click",this._onDocClick)}_renderMenu(){this._menu.innerHTML=ut.map(e=>`
|
|
453
|
+
<li role="none">
|
|
454
|
+
<button type="button" role="menuitem" data-theme="${e.slug}">
|
|
455
|
+
<span class="swatch" aria-hidden="true" data-theme-swatch="${e.slug}"></span>
|
|
456
|
+
${e.label}
|
|
457
|
+
</button>
|
|
458
|
+
</li>
|
|
459
|
+
`).join(""),this._menu.removeAttribute("hidden"),this._menu.querySelectorAll("button[data-theme]").forEach(e=>{e.addEventListener("click",()=>{let t=e.getAttribute("data-theme");this._applyTheme(t,{persist:!0}),this._closeMenu()})})}_toggleMenu(){this.hasAttribute("menu-open")?this._closeMenu():this._openMenu()}_openMenu(){this.setAttribute("menu-open",""),this._pickerBtn.setAttribute("aria-expanded","true"),this._highlightActive();let e=this._menu.querySelector("button[data-theme]");e&&e.focus()}_closeMenu(){this.removeAttribute("menu-open"),this._pickerBtn.setAttribute("aria-expanded","false")}_onDocClick(e){this.hasAttribute("menu-open")&&(e.composedPath().includes(this)||this._closeMenu())}_onKeyDown(e){if(this.hasAttribute("menu-open")){if(e.key==="Escape"){e.preventDefault(),this._closeMenu(),this._pickerBtn.focus();return}if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();let t=Array.from(this._menu.querySelectorAll("button[data-theme]")),i=t.indexOf(this.shadowRoot.activeElement);(e.key==="ArrowDown"?t[(i+1)%t.length]:t[(i-1+t.length)%t.length])?.focus()}}}_highlightActive(){let e=this._currentSlug();this._menu.querySelectorAll("button[data-theme]").forEach(t=>{t.getAttribute("data-theme")===e?t.setAttribute("aria-current","true"):t.removeAttribute("aria-current")})}_currentSlug(){if(!this._target)return"";let e=this._target.getAttribute("data-velin-theme");return!e||e==="light"?"":e}_initPreference(){let e=localStorage.getItem("velin-theme");if(e){this._applyTheme(e,{persist:!1});return}this._applyFromPreference()}_readStorage(){let e=localStorage.getItem("velin-theme");this._applyTheme(e||"",{persist:!1})}_applyFromPreference(){if(localStorage.getItem("velin-theme"))return;let e=window.matchMedia("(prefers-color-scheme: dark)").matches;this._applyTheme(e?"dark":"",{persist:!1})}_applyTheme(e,{persist:t}){let i=!e||e==="light"?"":e;this._target&&(i?(this._target.setAttribute("data-velin-theme",i),this.setAttribute("theme",i==="dark"?"dark":i),pt(i,this._themesBase)):(this._target.removeAttribute("data-velin-theme"),this.removeAttribute("theme")),t&&(i?localStorage.setItem("velin-theme",i):localStorage.removeItem("velin-theme")),this._highlightActive(),this.dispatchEvent(new CustomEvent("velin-theme-change",{bubbles:!0,detail:{theme:i||"light",dark:i==="dark",slug:i}})))}_toggleDarkMode(){let t=this._currentSlug()==="dark"?"":"dark";this._applyTheme(t,{persist:!0})}};customElements.define("velin-theme-toggle",P);var vt=P;var bt=`
|
|
381
460
|
:host { position: relative; display: inline-block; }
|
|
382
461
|
.popover {
|
|
383
462
|
position: absolute; z-index: var(--velin-z-dropdown, 200);
|
|
@@ -391,7 +470,6 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
391
470
|
transition: opacity 150ms ease, visibility 150ms ease;
|
|
392
471
|
}
|
|
393
472
|
:host([open]) .popover { opacity: 1; visibility: visible; }
|
|
394
|
-
/* Placement */
|
|
395
473
|
.popover--top { inset-block-end: calc(100% + 0.5rem); inset-inline-start: 50%; transform: translateX(-50%); }
|
|
396
474
|
.popover--bottom { inset-block-start: calc(100% + 0.5rem); inset-inline-start: 50%; transform: translateX(-50%); }
|
|
397
475
|
.popover--start { inset-inline-end: calc(100% + 0.5rem); inset-block-start: 50%; transform: translateY(-50%); }
|
|
@@ -403,14 +481,14 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
403
481
|
border-bottom: 1px solid var(--velin-color-border, #ddd);
|
|
404
482
|
}
|
|
405
483
|
@media (prefers-reduced-motion: reduce) { .popover { transition: none; } }
|
|
406
|
-
`,
|
|
407
|
-
<style>${
|
|
484
|
+
`,ft=0,j=class extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),this.attachShadow({mode:"open"}),this._popoverId=`velin-popover-${++ft}`,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",i=this.getAttribute("title")||"",s=t==="hover"?"tooltip":"dialog";this._isDialog=s==="dialog",this.shadowRoot.innerHTML=`
|
|
485
|
+
<style>${bt}</style>
|
|
408
486
|
<slot name="trigger"></slot>
|
|
409
|
-
<div class="popover popover--${e}" role="${
|
|
410
|
-
${
|
|
487
|
+
<div class="popover popover--${e}" id="${this._popoverId}" role="${s}" part="popover">
|
|
488
|
+
${i?`<div class="popover__title" part="title">${a(i)}</div>`:""}
|
|
411
489
|
<slot></slot>
|
|
412
490
|
</div>
|
|
413
|
-
|
|
491
|
+
`,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 i=e==="hover";t.setAttribute("aria-haspopup",i?"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=s=>{this.contains(s.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=g(),requestAnimationFrame(()=>{let t=_(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&&(y(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")&&v(this.shadowRoot.querySelector(".popover"),e)}disconnectedCallback(){document.removeEventListener("click",this._onOutside,!0),document.removeEventListener("keydown",this._onKey)}};customElements.define("velin-popover",j);var gt=j;var yt=`
|
|
414
492
|
:host { display: inline-flex; }
|
|
415
493
|
button {
|
|
416
494
|
display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
|
|
@@ -430,8 +508,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
430
508
|
button[data-copied] .copy-icon { display: none; }
|
|
431
509
|
button[data-copied] .check { display: block; }
|
|
432
510
|
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
|
|
433
|
-
`,
|
|
434
|
-
<style>${
|
|
511
|
+
`,Y=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){let e=this.getAttribute("label")||"";this.shadowRoot.innerHTML=`
|
|
512
|
+
<style>${yt}</style>
|
|
435
513
|
<button part="button" aria-label="Copy">
|
|
436
514
|
<svg class="copy-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
437
515
|
<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 +519,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
441
519
|
</svg>
|
|
442
520
|
${e?`<span>${e}</span>`:""}
|
|
443
521
|
</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
|
|
522
|
+
`,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 i=document.createElement("textarea");i.value=e,i.style.cssText="position:fixed;opacity:0",document.body.appendChild(i),i.select(),document.execCommand("copy"),i.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",Y);var _t=Y;var xt=`
|
|
445
523
|
: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
524
|
button {
|
|
447
525
|
display: inline-flex; align-items: center; justify-content: center;
|
|
@@ -457,14 +535,14 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
457
535
|
:host([visible]) button { opacity: 1; visibility: visible; transform: translateY(0); }
|
|
458
536
|
svg { width: 1.25rem; height: 1.25rem; }
|
|
459
537
|
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
|
|
460
|
-
|
|
461
|
-
<style>${
|
|
538
|
+
`,V=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=`
|
|
539
|
+
<style>${xt}</style>
|
|
462
540
|
<button part="button" aria-label="Scroll to top">
|
|
463
541
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
464
542
|
<line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/>
|
|
465
543
|
</svg>
|
|
466
544
|
</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"
|
|
545
|
+
`,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",V);var wt=V;var kt=`
|
|
468
546
|
:host { display: block; position: relative; overflow: hidden; }
|
|
469
547
|
.track {
|
|
470
548
|
display: flex; transition: transform 400ms ease;
|
|
@@ -491,9 +569,15 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
491
569
|
button:disabled { opacity: 0.3; cursor: not-allowed; }
|
|
492
570
|
svg { width: 1.25rem; height: 1.25rem; }
|
|
493
571
|
.indicators {
|
|
494
|
-
display: flex; justify-content: center; gap: var(--velin-space-2, 0.5rem);
|
|
572
|
+
display: flex; justify-content: center; align-items: center; gap: var(--velin-space-2, 0.5rem);
|
|
495
573
|
padding-block: var(--velin-space-3, 0.75rem);
|
|
496
574
|
}
|
|
575
|
+
.pause-btn {
|
|
576
|
+
font-size: var(--velin-text-xs, 0.75rem);
|
|
577
|
+
padding-inline: var(--velin-space-3, 0.75rem);
|
|
578
|
+
min-inline-size: auto;
|
|
579
|
+
border-radius: var(--velin-radius-md, 0.375rem);
|
|
580
|
+
}
|
|
497
581
|
.dot {
|
|
498
582
|
display: inline-flex; align-items: center; justify-content: center;
|
|
499
583
|
min-width: 2.75rem; min-height: 2.75rem;
|
|
@@ -509,8 +593,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
509
593
|
.dot[aria-current="true"]::before { background: var(--velin-color-primary, #2563eb); transform: scale(1.3); }
|
|
510
594
|
.dot:focus-visible { outline: 2px solid var(--velin-color-focus, #2563eb); outline-offset: 2px; }
|
|
511
595
|
@media (prefers-reduced-motion: reduce) { .track { transition: none; } }
|
|
512
|
-
`,
|
|
513
|
-
<style>${
|
|
596
|
+
`,X=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=`
|
|
597
|
+
<style>${kt}</style>
|
|
514
598
|
<div class="track" role="group" aria-roledescription="carousel" part="track"><slot></slot></div>
|
|
515
599
|
<div class="controls" part="controls">
|
|
516
600
|
<button class="prev" aria-label="Previous slide" part="prev">
|
|
@@ -520,8 +604,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
520
604
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 6 15 12 9 18"/></svg>
|
|
521
605
|
</button>
|
|
522
606
|
</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",
|
|
607
|
+
<div class="indicators" role="group" aria-label="Slide indicators" part="indicators"></div>
|
|
608
|
+
`,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",i=>{this._startX=i.touches[0].clientX},{passive:!0}),e.addEventListener("touchend",i=>{let s=this._startX-i.changedTouches[0].clientX;Math.abs(s)>50&&(s>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",i=>{i.key==="ArrowLeft"?(this.prev(),i.preventDefault()):i.key==="ArrowRight"?(this.next(),i.preventDefault()):i.key==="Home"?(this.goTo(0),i.preventDefault()):i.key==="End"&&(this.goTo(this._count-1),i.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,i)=>{t.setAttribute("aria-hidden",i!==this._index?"true":"false"),t.inert=i!==this._index,t.setAttribute("aria-roledescription","slide"),t.setAttribute("aria-label",`Slide ${i+1} of ${this._count}`)}),this.shadowRoot.querySelectorAll(".dot").forEach((t,i)=>{t.setAttribute("aria-current",i===this._index?"true":"false")})}_buildDots(){let e=this.shadowRoot.querySelector(".indicators");if(e.innerHTML="",this._slides.forEach((t,i)=>{let s=document.createElement("button");s.type="button",s.className="dot",s.setAttribute("aria-label",`Go to slide ${i+1}`),s.addEventListener("click",()=>this.goTo(i)),e.appendChild(s)}),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",X);var At=X;var Et=`
|
|
525
609
|
:host { display: block; }
|
|
526
610
|
.content {
|
|
527
611
|
overflow: hidden;
|
|
@@ -532,13 +616,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
532
616
|
:host([open]) .content { grid-template-rows: 1fr; }
|
|
533
617
|
.inner { min-height: 0; }
|
|
534
618
|
@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=`
|
|
619
|
+
`,St=0;function Lt(r){let e=r.tagName;return e==="BUTTON"||e==="A"&&r.hasAttribute("href")||r.getAttribute("role")==="button"}var U=class extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),this.attachShadow({mode:"open"}),this._contentId=`velin-collapse-panel-${++St}`,this._onTriggerKey=this._onTriggerKey.bind(this)}connectedCallback(){let e=this._contentId;this.shadowRoot.innerHTML="<style>"+Et+'</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&&(Lt(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",U);var Ct=U;var W=class extends HTMLElement{constructor(){super(),this._observer=null,this._activeId=null}connectedCallback(){let e=this.getAttribute("target")||"section[id]",t=this.getAttribute("nav")||"a",i=this.getAttribute("root-margin")||"-20% 0px -60% 0px",s=document.querySelectorAll(e);s.length&&(this._observer=new IntersectionObserver(o=>{for(let n of o)n.isIntersecting&&this._activate(n.target.id,t)},{rootMargin:i,threshold:0}),s.forEach(o=>this._observer.observe(o)))}_activate(e,t){if(this._activeId===e)return;this._activeId=e,this.querySelectorAll(t).forEach(s=>{s.getAttribute("href")===`#${e}`?(s.classList.add("velin-doc-sidebar__link--active"),s.setAttribute("aria-current","true")):(s.classList.remove("velin-doc-sidebar__link--active"),s.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",W);var Tt=W;var Mt=`
|
|
542
620
|
:host { position: relative; display: inline-block; }
|
|
543
621
|
.tip {
|
|
544
622
|
position: absolute; z-index: var(--velin-z-tooltip, 700);
|
|
@@ -557,11 +635,11 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
557
635
|
.tip[data-placement="start"] { right: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
|
|
558
636
|
.tip[data-placement="end"] { left: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
|
|
559
637
|
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }
|
|
560
|
-
`,
|
|
561
|
-
<style>${
|
|
638
|
+
`,Rt=0,G=class extends HTMLElement{static get observedAttributes(){return["content","placement"]}constructor(){super(),this.attachShadow({mode:"open"}),this._tipId=`velin-tooltip-${++Rt}`}connectedCallback(){let e=this.getAttribute("placement")||"top",t="div";this.shadowRoot.innerHTML=`
|
|
639
|
+
<style>${Mt}</style>
|
|
562
640
|
<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",
|
|
641
|
+
<${t} class="tip" id="${this._tipId}" role="tooltip" data-placement="${a(e)}" part="tip">${a(this.getAttribute("content")||"")}</${t}>
|
|
642
|
+
`,this.addEventListener("mouseenter",()=>this._show()),this.addEventListener("mouseleave",()=>this._hide()),this.addEventListener("focusin",()=>this._show()),this.addEventListener("focusout",()=>this._hide()),this.addEventListener("keydown",s=>{s.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(),i=this.getAttribute("placement")||"top";i==="top"&&t.top<0?e.setAttribute("data-placement","bottom"):i==="bottom"&&t.bottom>window.innerHeight?e.setAttribute("data-placement","top"):e.setAttribute("data-placement",i)}attributeChangedCallback(e,t,i){let s=this.shadowRoot?.querySelector(".tip");s&&(e==="content"&&(s.textContent=i),e==="placement"&&s.setAttribute("data-placement",i))}};customElements.define("velin-tooltip-wc",G);var $t=G;var qt=`
|
|
565
643
|
:host { display: contents; }
|
|
566
644
|
.overlay {
|
|
567
645
|
position: fixed; inset: 0; z-index: var(--velin-z-modal, 500);
|
|
@@ -600,8 +678,8 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
600
678
|
.nav--prev { left: 0.5rem; }
|
|
601
679
|
.nav--next { right: 0.5rem; }
|
|
602
680
|
}
|
|
603
|
-
`,
|
|
604
|
-
<style>${
|
|
681
|
+
`,Z=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._index=0,this._items=[],this._previousFocus=null,this._onTrapKey=e=>{e.key==="Tab"&&v(this.shadowRoot,e)}}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
682
|
+
<style>${qt}</style>
|
|
605
683
|
<slot></slot>
|
|
606
684
|
<div class="overlay" role="dialog" aria-modal="true" aria-label="Image lightbox" aria-roledescription="lightbox" part="overlay">
|
|
607
685
|
<button class="nav nav--prev" aria-label="Previous">‹</button>
|
|
@@ -610,7 +688,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
610
688
|
<button class="close" aria-label="Close">×</button>
|
|
611
689
|
<div class="counter" part="counter"></div>
|
|
612
690
|
</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,
|
|
691
|
+
`;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,i)=>{t.style.cursor="pointer",t.addEventListener("click",()=>this.open(i))})}),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 i=be(t.dataset.velinLightbox||t.src),s=a(t.alt||"");t.tagName==="VIDEO"?e.innerHTML=`<video src="${a(i)}" controls autoplay></video>`:e.innerHTML=`<img src="${a(i)}" alt="${s}">`;let o=this.shadowRoot.querySelector(".counter");o.textContent=`${this._index+1} / ${this._items.length}`}};customElements.define("velin-lightbox",Z);var It=Z;var Ft=`
|
|
614
692
|
:host { display: block; }
|
|
615
693
|
.steps {
|
|
616
694
|
display: flex; gap: var(--velin-space-2, 0.5rem);
|
|
@@ -659,11 +737,11 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
659
737
|
.panels ::slotted(*) { display: none; }
|
|
660
738
|
.panels ::slotted([data-active]) { display: block; }
|
|
661
739
|
@media (prefers-reduced-motion: reduce) { .step__marker { transition: none; } }
|
|
662
|
-
`,
|
|
663
|
-
<style>${
|
|
740
|
+
`,J=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(i=>i.trim()).map((i,s)=>{let o=s<this._current?"completed":s===this._current?"active":"",n=s<this._current?"✓":s+1,c=s===this._current?' aria-current="step"':"";return`<div class="step ${o}" role="listitem"${c}><span class="step__marker" aria-hidden="true">${n}</span><span class="step__label">${a(i)}</span></div>`}).join("");this.shadowRoot.innerHTML=`
|
|
741
|
+
<style>${Ft}</style>
|
|
664
742
|
<div class="steps" role="list" aria-label="Progress" part="steps">${t}</div>
|
|
665
743
|
<div class="panels" part="panels"><slot></slot></div>
|
|
666
|
-
`,this._updatePanels()}_updatePanels(){(this.shadowRoot.querySelector("slot")?.assignedElements()||[]).forEach((t,
|
|
744
|
+
`,this._updatePanels()}_updatePanels(){(this.shadowRoot.querySelector("slot")?.assignedElements()||[]).forEach((t,i)=>{i===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,i){e==="active"&&t!==null&&t!==i&&(this._current=parseInt(i,10),this._buildSteps())}};customElements.define("velin-stepper-wc",J);var zt=J;var Ht=`
|
|
667
745
|
:host { display: contents; }
|
|
668
746
|
dialog {
|
|
669
747
|
border: none; border-radius: var(--velin-radius-lg, 0.75rem);
|
|
@@ -720,12 +798,12 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
720
798
|
color: var(--velin-color-text, #1a1a2e);
|
|
721
799
|
}
|
|
722
800
|
.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 ${
|
|
725
|
-
<div class="header"><h3 class="title">${
|
|
726
|
-
<div class="body"><p>${
|
|
727
|
-
<div class="footer">${
|
|
728
|
-
`,
|
|
801
|
+
`,Q=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._resolve=null,this._previousFocus=null}connectedCallback(){this.shadowRoot.innerHTML=`<style>${Ht}</style><dialog part="dialog"></dialog>`}alert(e,{title:t="Alert",confirmText:i="OK"}={}){return this._show("alert",e,{title:t,confirmText:i})}confirm(e,{title:t="Confirm",confirmText:i="Confirm",cancelText:s="Cancel",danger:o=!1}={}){return this._show("confirm",e,{title:t,confirmText:i,cancelText:s,danger:o})}prompt(e,{title:t="Input",confirmText:i="Submit",cancelText:s="Cancel",placeholder:o="",defaultValue:n=""}={}){return this._show("prompt",e,{title:t,confirmText:i,cancelText:s,placeholder:o,defaultValue:n})}_show(e,t,i){let s=this.shadowRoot.querySelector("dialog");this._previousFocus=document.activeElement;let o=a(i.title),n=a(t),c=a(i.confirmText),l=a(i.cancelText||""),d=a(i.placeholder||""),u=a(i.defaultValue||""),f=e==="alert"?`<button class="btn btn--primary" data-action="confirm">${c}</button>`:`<button class="btn" data-action="cancel">${l}</button>
|
|
802
|
+
<button class="btn ${i.danger?"btn--danger":"btn--primary"}" data-action="confirm">${c}</button>`,w=e==="prompt"?`<input class="input" placeholder="${d}" value="${u}" part="input">`:"";if(s.innerHTML=`
|
|
803
|
+
<div class="header"><h3 class="title">${o}</h3><button class="close" aria-label="Close">×</button></div>
|
|
804
|
+
<div class="body"><p>${n}</p>${w}</div>
|
|
805
|
+
<div class="footer">${f}</div>
|
|
806
|
+
`,s.showModal(),e!=="prompt"){let k=s.querySelector("[data-action]");k&&k.focus()}return new Promise(k=>{if(this._resolve=k,s.querySelector(".close").addEventListener("click",()=>this._dismiss(e,!1,s)),s.querySelectorAll("[data-action]").forEach(h=>{h.addEventListener("click",()=>this._dismiss(e,h.dataset.action==="confirm",s))}),s.addEventListener("cancel",h=>{h.preventDefault(),this._dismiss(e,!1,s)}),e==="prompt"){let h=s.querySelector(".input");h.focus(),h.addEventListener("keydown",C=>{C.key==="Enter"&&this._dismiss(e,!0,s)})}})}_dismiss(e,t,i){if(!this._resolve)return;let s;e==="alert"?s=!0:e==="confirm"?s=t:s=t?i.querySelector(".input")?.value??"":null,i.close(),this._previousFocus&&(this._previousFocus.focus(),this._previousFocus=null),this._resolve(s),this._resolve=null,this.dispatchEvent(new CustomEvent("velin-dialog-close",{bubbles:!0,detail:{value:s}}))}};customElements.define("velin-dialog",Q);var Dt=Q;var Kt=`
|
|
729
807
|
:host { display: inline-flex; font-variant-numeric: tabular-nums; }
|
|
730
808
|
.wrap { display: inline-flex; gap: var(--velin-space-3, 0.75rem); align-items: flex-start; }
|
|
731
809
|
.segment {
|
|
@@ -755,7 +833,7 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
755
833
|
:host([size="sm"]) .value { font-size: var(--velin-text-xl, 1.25rem); }
|
|
756
834
|
:host([size="sm"]) .segment { min-width: 2.5rem; }
|
|
757
835
|
:host([size="lg"]) .value { font-size: var(--velin-text-5xl, 3.052rem); }
|
|
758
|
-
`,
|
|
836
|
+
`,ee=class extends HTMLElement{static get observedAttributes(){return["datetime"]}constructor(){super(),this.attachShadow({mode:"open"}),this._timer=null}connectedCallback(){this.shadowRoot.innerHTML=`<style>${Kt}</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(),i=Math.max(0,e-t),s=Math.floor(i/864e5),o=Math.floor(i%864e5/36e5),n=Math.floor(i%36e5/6e4),c=Math.floor(i%6e4/1e3),l=p=>String(p).padStart(2,"0"),d=this.getAttribute("show-days")!=="false",u=a(this.getAttribute("label-days")||"Days"),f=a(this.getAttribute("label-hours")||"Hours"),w=a(this.getAttribute("label-minutes")||"Min"),k=a(this.getAttribute("label-seconds")||"Sec"),h="";d&&(h+=`<div class="segment" part="days"><span class="value">${l(s)}</span><span class="label">${u}</span></div><span class="separator">:</span>`),h+=`<div class="segment" part="hours"><span class="value">${l(o)}</span><span class="label">${f}</span></div><span class="separator">:</span>`,h+=`<div class="segment" part="minutes"><span class="value">${l(n)}</span><span class="label">${w}</span></div><span class="separator">:</span>`,h+=`<div class="segment" part="seconds"><span class="value">${l(c)}</span><span class="label">${k}</span></div>`,this._wrap&&(this._wrap.innerHTML=h);let C=`${s} days, ${o} hours, ${n} minutes, ${c} seconds remaining`;this.setAttribute("aria-label",C),i<=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",ee);var Nt=ee;var Ot=`
|
|
759
837
|
:host { display: inline-flex; align-items: center; justify-content: center; }
|
|
760
838
|
svg { transform: rotate(-90deg); }
|
|
761
839
|
.track { fill: none; stroke: var(--velin-color-border, #e5e5e5); }
|
|
@@ -773,13 +851,278 @@ var J=["a[href]","button:not([disabled])","input:not([disabled])","select:not([d
|
|
|
773
851
|
}
|
|
774
852
|
:host { position: relative; }
|
|
775
853
|
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
|
|
776
|
-
`,
|
|
777
|
-
<style>${
|
|
854
|
+
`,te=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),i=parseInt(this.getAttribute("stroke")||"8",10),s=(t-i)/2,o=2*Math.PI*s,n=o-e/100*o,c=this.getAttribute("color"),l=c?`stroke: var(--velin-color-${c}, ${c});`:"",d=this.getAttribute("label")!=="false";this.shadowRoot.innerHTML=`
|
|
855
|
+
<style>${Ot}</style>
|
|
778
856
|
<svg width="${t}" height="${t}" viewBox="0 0 ${t} ${t}" part="svg" role="progressbar" aria-valuenow="${e}" aria-valuemin="0" aria-valuemax="100">
|
|
779
|
-
<circle class="track" cx="${t/2}" cy="${t/2}" r="${
|
|
780
|
-
<circle class="fill" cx="${t/2}" cy="${t/2}" r="${
|
|
781
|
-
stroke-dasharray="${
|
|
782
|
-
style="${
|
|
857
|
+
<circle class="track" cx="${t/2}" cy="${t/2}" r="${s}" stroke-width="${i}" />
|
|
858
|
+
<circle class="fill" cx="${t/2}" cy="${t/2}" r="${s}" stroke-width="${i}"
|
|
859
|
+
stroke-dasharray="${o}" stroke-dashoffset="${n}"
|
|
860
|
+
style="${l}" part="fill" />
|
|
783
861
|
</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",
|
|
862
|
+
${d?`<span class="label" part="label">${e}%</span>`:""}
|
|
863
|
+
`,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",te);var Bt=te;var Pt=/^[a-zA-Z0-9_-]{1,64}$/;var ie=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-${Pt.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 i=t.name;i&&(t.type==="password"||t.type==="file"||(t.type==="checkbox"?e[i]=t.checked:t.type==="radio"?t.checked&&(e[i]=t.value):e[i]=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 i=t.name;i in e&&(t.type==="checkbox"?t.checked=!!e[i]:t.type==="radio"?t.checked=t.value===e[i]:t.value=e[i])}),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",ie);var jt=ie;var Yt=`
|
|
864
|
+
:host { display: inline-block; position: relative; }
|
|
865
|
+
.listbox {
|
|
866
|
+
position: absolute; z-index: var(--velin-z-dropdown, 100);
|
|
867
|
+
inset-block-start: 100%; inset-inline-start: 0;
|
|
868
|
+
min-inline-size: 100%; margin-block-start: var(--velin-space-1, 0.25rem);
|
|
869
|
+
padding-block: var(--velin-space-1, 0.25rem);
|
|
870
|
+
background: var(--velin-color-surface-bright, #fff);
|
|
871
|
+
border: 1px solid var(--velin-color-border, #ddd);
|
|
872
|
+
border-radius: var(--velin-radius-md, 0.5rem);
|
|
873
|
+
box-shadow: var(--velin-shadow-lg, 0 10px 15px rgba(0,0,0,0.08));
|
|
874
|
+
opacity: 0; visibility: hidden;
|
|
875
|
+
transition: opacity 150ms ease, visibility 150ms ease;
|
|
876
|
+
}
|
|
877
|
+
:host([open]) .listbox { opacity: 1; visibility: visible; }
|
|
878
|
+
::slotted([role="option"]) {
|
|
879
|
+
display: block; inline-size: 100%;
|
|
880
|
+
padding: var(--velin-space-2, 0.5rem) var(--velin-space-4, 1rem);
|
|
881
|
+
min-block-size: 2.5rem;
|
|
882
|
+
text-align: start; background: none; border: none;
|
|
883
|
+
cursor: pointer; font-size: var(--velin-text-base, 1rem);
|
|
884
|
+
}
|
|
885
|
+
::slotted([role="option"][aria-selected="true"]) {
|
|
886
|
+
background: var(--velin-color-surface-dim, #eee);
|
|
887
|
+
}
|
|
888
|
+
`,se=class extends HTMLElement{static get observedAttributes(){return["open","aria-label"]}constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._onDocClick=this._onDocClick.bind(this),this._onKey=this._onKey.bind(this)}connectedCallback(){let e=`velin-combobox-list-${Math.random().toString(36).slice(2,9)}`;this._listId=e;let t=a(this.getAttribute("aria-label")||"Options");this.shadowRoot.innerHTML=`
|
|
889
|
+
<style>${Yt}</style>
|
|
890
|
+
<slot name="trigger"></slot>
|
|
891
|
+
<div class="listbox" id="${e}" role="listbox" aria-label="${t}" part="listbox"><slot></slot></div>
|
|
892
|
+
`,this.shadowRoot.querySelector('slot[name="trigger"]').addEventListener("slotchange",()=>this._wireTrigger()),this.shadowRoot.querySelector("slot:not([name])")?.addEventListener("slotchange",()=>this._wireOptions()),this._wireTrigger(),this._wireOptions(),this.addEventListener("keydown",this._onKey)}_wireTrigger(){let e=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];if(!e)return;e.setAttribute("role","combobox"),e.setAttribute("aria-expanded",this.hasAttribute("open")?"true":"false"),e.setAttribute("aria-controls",this._listId),e.setAttribute("aria-autocomplete","list"),e.id||(e.id=`velin-combobox-trigger-${Math.random().toString(36).slice(2,9)}`);let t=this.shadowRoot.querySelector(".listbox");t&&t.setAttribute("aria-labelledby",e.id),e.dataset.velinComboWired||(e.dataset.velinComboWired="1",e.addEventListener("click",()=>this.toggle()),e.addEventListener("keydown",i=>{(i.key==="ArrowDown"||i.key==="Enter")&&(i.preventDefault(),this.open())}))}_wireOptions(){this._getOptions().forEach((t,i)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected",t.hasAttribute("selected")?"true":"false"),t.setAttribute("tabindex",i===0?"0":"-1")})}_getOptions(){let e=this.shadowRoot.querySelector("slot:not([name])");return e?e.assignedElements().filter(t=>!t.hidden):[]}toggle(){this.hasAttribute("open")?this.close():this.open()}open(){this.setAttribute("open","");let e=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];e&&e.setAttribute("aria-expanded","true"),document.addEventListener("click",this._onDocClick,!0),requestAnimationFrame(()=>{let t=this._getOptions();t.length&&t[0].focus()})}close(){this.removeAttribute("open");let e=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];e&&(e.setAttribute("aria-expanded","false"),e.focus()),document.removeEventListener("click",this._onDocClick,!0),this.dispatchEvent(new CustomEvent("velin-close",{bubbles:!0}))}_onDocClick(e){this.contains(e.target)||this.close()}_onKey(e){if(!this.hasAttribute("open"))return;if(e.key==="Escape"){this.close();return}let t=this._getOptions();t.length&&(b(this,t,e),e.key==="Enter"&&t.includes(e.target)&&(this._selectOption(e.target),this.close()))}_selectOption(e){this._getOptions().forEach(i=>i.setAttribute("aria-selected",i===e?"true":"false"));let t=this.shadowRoot.querySelector('slot[name="trigger"]')?.assignedElements()[0];t&&"value"in t&&(t.value=e.textContent?.trim()||""),this.dispatchEvent(new CustomEvent("velin-select",{bubbles:!0,detail:{option:e}}))}attributeChangedCallback(e){if(e==="open"&&this._wireTrigger(),e==="aria-label"){let t=this.shadowRoot?.querySelector(".listbox");t&&t.setAttribute("aria-label",a(this.getAttribute("aria-label")||"Options"))}}disconnectedCallback(){document.removeEventListener("click",this._onDocClick,!0)}};customElements.define("velin-combobox",se);var Vt=se;var Xt=`
|
|
893
|
+
:host { display: block; }
|
|
894
|
+
nav {
|
|
895
|
+
display: flex;
|
|
896
|
+
justify-content: space-around;
|
|
897
|
+
align-items: center;
|
|
898
|
+
padding: var(--velin-space-2, 0.5rem) var(--velin-space-4, 1rem);
|
|
899
|
+
padding-block-end: max(var(--velin-space-2, 0.5rem), env(safe-area-inset-bottom, 0px));
|
|
900
|
+
background: var(--velin-color-surface-bright, #fff);
|
|
901
|
+
border-block-start: 1px solid var(--velin-color-border, #ddd);
|
|
902
|
+
}
|
|
903
|
+
::slotted(a), ::slotted(button) {
|
|
904
|
+
display: flex;
|
|
905
|
+
flex-direction: column;
|
|
906
|
+
align-items: center;
|
|
907
|
+
gap: var(--velin-space-1, 0.25rem);
|
|
908
|
+
min-inline-size: 2.75rem;
|
|
909
|
+
min-block-size: 2.75rem;
|
|
910
|
+
padding: var(--velin-space-2, 0.5rem);
|
|
911
|
+
font-size: var(--velin-text-xs, 0.75rem);
|
|
912
|
+
color: var(--velin-color-text-muted, #666);
|
|
913
|
+
text-decoration: none;
|
|
914
|
+
background: none;
|
|
915
|
+
border: none;
|
|
916
|
+
cursor: pointer;
|
|
917
|
+
}
|
|
918
|
+
::slotted([current]) {
|
|
919
|
+
color: var(--velin-color-primary, #2563eb);
|
|
920
|
+
font-weight: var(--velin-weight-semibold, 600);
|
|
921
|
+
}
|
|
922
|
+
`,re=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._onSlot=this._onSlot.bind(this)}connectedCallback(){let e=a(this.getAttribute("aria-label")||"Bottom navigation");this.shadowRoot.innerHTML=`
|
|
923
|
+
<style>${Xt}</style>
|
|
924
|
+
<nav role="navigation" aria-label="${e}"><slot></slot></nav>
|
|
925
|
+
`,this.shadowRoot.querySelector("slot").addEventListener("slotchange",this._onSlot),this._onSlot()}_onSlot(){this._syncCurrent()}_syncCurrent(){let e=this.shadowRoot?.querySelector("slot");if(!e)return;let t=this.getAttribute("current");e.assignedElements().forEach(i=>{i.hasAttribute("current")||t&&(i.dataset.nav===t||i.getAttribute("data-nav")===t)?(i.setAttribute("current",""),i.setAttribute("aria-current","page")):(i.removeAttribute("current"),i.removeAttribute("aria-current"))})}static get observedAttributes(){return["aria-label","current"]}attributeChangedCallback(e){if(e==="aria-label"){let t=this.shadowRoot?.querySelector("nav");t&&t.setAttribute("aria-label",a(this.getAttribute("aria-label")||"Bottom navigation"))}e==="current"&&this._syncCurrent()}};customElements.define("velin-bottom-nav",re);var Ut=re;var x=`
|
|
926
|
+
:host { display: block; }
|
|
927
|
+
button, [role="button"] {
|
|
928
|
+
min-inline-size: 2.75rem;
|
|
929
|
+
min-block-size: 2.75rem;
|
|
930
|
+
cursor: pointer;
|
|
931
|
+
}
|
|
932
|
+
button:focus-visible, [role="button"]:focus-visible {
|
|
933
|
+
outline: 3px solid var(--velin-color-focus, #2563eb);
|
|
934
|
+
outline-offset: 2px;
|
|
935
|
+
}
|
|
936
|
+
@media (forced-colors: active) {
|
|
937
|
+
button, [role="button"] {
|
|
938
|
+
border: 1px solid ButtonText;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
`;var Wt=`
|
|
942
|
+
${x}
|
|
943
|
+
:host { display: contents; }
|
|
944
|
+
.overlay {
|
|
945
|
+
position: fixed; inset: 0; z-index: var(--velin-z-overlay, 400);
|
|
946
|
+
background: var(--velin-color-overlay, rgba(0,0,0,0.4));
|
|
947
|
+
opacity: 0; visibility: hidden;
|
|
948
|
+
transition: opacity 200ms ease, visibility 200ms ease;
|
|
949
|
+
}
|
|
950
|
+
:host([open]) .overlay { opacity: 1; visibility: visible; }
|
|
951
|
+
.sheet {
|
|
952
|
+
position: fixed; inset-inline: 0; inset-block-end: 0;
|
|
953
|
+
z-index: var(--velin-z-modal, 500);
|
|
954
|
+
max-block-size: min(85vh, 32rem);
|
|
955
|
+
background: var(--velin-color-surface-bright, #fff);
|
|
956
|
+
border-radius: var(--velin-radius-lg, 0.75rem) var(--velin-radius-lg, 0.75rem) 0 0;
|
|
957
|
+
box-shadow: var(--velin-shadow-xl, 0 -4px 24px rgba(0,0,0,0.12));
|
|
958
|
+
display: flex; flex-direction: column;
|
|
959
|
+
transform: translateY(100%);
|
|
960
|
+
transition: transform 250ms ease;
|
|
961
|
+
padding-block-end: env(safe-area-inset-bottom, 0px);
|
|
962
|
+
}
|
|
963
|
+
:host([open]) .sheet { transform: translateY(0); }
|
|
964
|
+
.header {
|
|
965
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
966
|
+
padding: var(--velin-space-4, 1rem) var(--velin-space-5, 1.25rem);
|
|
967
|
+
border-bottom: 1px solid var(--velin-color-border, #ddd);
|
|
968
|
+
}
|
|
969
|
+
.title { font-size: var(--velin-text-lg, 1.25rem); font-weight: 600; margin: 0; }
|
|
970
|
+
.body { flex: 1; overflow-y: auto; padding: var(--velin-space-5, 1.25rem); }
|
|
971
|
+
@media (prefers-reduced-motion: reduce) { .overlay, .sheet { transition: none; } }
|
|
972
|
+
`,oe=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=a(this.getAttribute("title")||this.getAttribute("label")||""),t="velin-sheet-title";this.shadowRoot.innerHTML=`
|
|
973
|
+
<style>${Wt}</style>
|
|
974
|
+
<div class="overlay" part="overlay"></div>
|
|
975
|
+
<div class="sheet" role="dialog" aria-modal="true" aria-labelledby="${t}" part="sheet">
|
|
976
|
+
<div class="header" part="header">
|
|
977
|
+
<h2 class="title" id="${t}">${e}</h2>
|
|
978
|
+
<button class="close-btn" aria-label="Close" part="close">×</button>
|
|
979
|
+
</div>
|
|
980
|
+
<div class="body" part="body"><slot></slot></div>
|
|
981
|
+
</div>
|
|
982
|
+
`,this.shadowRoot.querySelector(".close-btn").addEventListener("click",()=>this.close()),this.shadowRoot.querySelector(".overlay").addEventListener("click",()=>this.close()),this.hasAttribute("open")&&this._open()}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=g(),A(this),document.addEventListener("keydown",this._onKey),document.body.style.overflow="hidden",requestAnimationFrame(()=>{let e=_(this.shadowRoot);e.length&&e[0].focus()})}_close(){document.removeEventListener("keydown",this._onKey),document.body.style.overflow="",E(),y(this._prev)}_onKey(e){if(e.key==="Escape"){this.close();return}v(this.shadowRoot,e)}disconnectedCallback(){document.removeEventListener("keydown",this._onKey),document.body.style.overflow=""}};customElements.define("velin-sheet",oe);var Gt=oe;var Zt=`
|
|
983
|
+
${x}
|
|
984
|
+
:host { display: block; }
|
|
985
|
+
.group {
|
|
986
|
+
display: inline-flex;
|
|
987
|
+
gap: var(--velin-space-1, 0.25rem);
|
|
988
|
+
padding: var(--velin-space-1, 0.25rem);
|
|
989
|
+
background: var(--velin-color-surface-dim, #eee);
|
|
990
|
+
border-radius: var(--velin-radius-md, 0.5rem);
|
|
991
|
+
}
|
|
992
|
+
::slotted(button) {
|
|
993
|
+
min-inline-size: 2.75rem;
|
|
994
|
+
min-block-size: 2.75rem;
|
|
995
|
+
padding: var(--velin-space-2, 0.5rem) var(--velin-space-4, 1rem);
|
|
996
|
+
border: none;
|
|
997
|
+
border-radius: var(--velin-radius-sm, 0.25rem);
|
|
998
|
+
background: transparent;
|
|
999
|
+
color: var(--velin-color-text-muted, #666);
|
|
1000
|
+
cursor: pointer;
|
|
1001
|
+
font-size: var(--velin-text-sm, 0.875rem);
|
|
1002
|
+
}
|
|
1003
|
+
::slotted(button[aria-pressed="true"]) {
|
|
1004
|
+
background: var(--velin-color-surface-bright, #fff);
|
|
1005
|
+
color: var(--velin-color-text, #111);
|
|
1006
|
+
font-weight: var(--velin-weight-semibold, 600);
|
|
1007
|
+
box-shadow: var(--velin-shadow-sm, 0 1px 2px rgba(0,0,0,0.06));
|
|
1008
|
+
}
|
|
1009
|
+
`,ne=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._onClick=this._onClick.bind(this),this._onKey=this._onKey.bind(this)}connectedCallback(){let e=a(this.getAttribute("aria-label")||"Segmented control");this.shadowRoot.innerHTML=`
|
|
1010
|
+
<style>${Zt}</style>
|
|
1011
|
+
<div class="group" role="group" aria-label="${e}"><slot></slot></div>
|
|
1012
|
+
`,this.addEventListener("click",this._onClick),this.addEventListener("keydown",this._onKey),this.shadowRoot.querySelector("slot")?.addEventListener("slotchange",()=>this._init()),this._init()}_getButtons(){let e=this.shadowRoot.querySelector("slot");return e?e.assignedElements().filter(t=>t.tagName==="BUTTON"):[]}_init(){let e=this._getButtons(),t=e.find(i=>i.hasAttribute("selected"))||e[0];e.forEach((i,s)=>{i.setAttribute("aria-pressed",i===t?"true":"false"),i.setAttribute("tabindex",i===t?"0":"-1")})}_onClick(e){let t=e.target.closest("button");!t||!this.contains(t)||this._select(t)}_select(e){this._getButtons().forEach(t=>{t.setAttribute("aria-pressed",t===e?"true":"false"),t.setAttribute("tabindex",t===e?"0":"-1")}),this.dispatchEvent(new CustomEvent("velin-change",{bubbles:!0,detail:{value:e.value||e.textContent?.trim()}}))}_onKey(e){let t=this._getButtons();if(t.includes(e.target)&&(b(this,t,e),["ArrowLeft","ArrowRight","Home","End"].includes(e.key))){let i=t.find(s=>s.getAttribute("tabindex")==="0");i&&this._select(i)}}static get observedAttributes(){return["aria-label"]}attributeChangedCallback(e){if(e==="aria-label"){let t=this.shadowRoot?.querySelector(".group");t&&t.setAttribute("aria-label",a(this.getAttribute("aria-label")||"Segmented control"))}}disconnectedCallback(){this.removeEventListener("click",this._onClick),this.removeEventListener("keydown",this._onKey)}};customElements.define("velin-segmented-control",ne);var Jt=ne;var Qt=`
|
|
1013
|
+
${x}
|
|
1014
|
+
:host { display: inline-block; }
|
|
1015
|
+
.stars { display: inline-flex; gap: var(--velin-space-1, 0.25rem); }
|
|
1016
|
+
button {
|
|
1017
|
+
background: none; border: none; padding: var(--velin-space-1, 0.25rem);
|
|
1018
|
+
font-size: 1.5rem; line-height: 1; cursor: pointer;
|
|
1019
|
+
color: var(--velin-color-border, #ccc);
|
|
1020
|
+
}
|
|
1021
|
+
button[aria-checked="true"] { color: var(--velin-color-warning, #f59e0b); }
|
|
1022
|
+
`,Se=5,ae=class extends HTMLElement{static get observedAttributes(){return["value"]}constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._onClick=this._onClick.bind(this),this._onKey=this._onKey.bind(this)}connectedCallback(){this.shadowRoot.innerHTML=`<style>${Qt}</style><div class="stars" role="radiogroup"></div>`,this._render(),this.shadowRoot.querySelector(".stars").addEventListener("click",this._onClick),this.shadowRoot.querySelector(".stars").addEventListener("keydown",this._onKey)}_value(){let e=parseInt(this.getAttribute("value")||"0",10);return Math.min(Se,Math.max(0,Number.isNaN(e)?0:e))}_render(){let e=this.shadowRoot.querySelector(".stars"),t=this._value(),i=a(this.getAttribute("aria-label")||"Rating");e.setAttribute("aria-label",i),e.innerHTML="";for(let s=1;s<=Se;s++){let o=document.createElement("button");o.type="button",o.setAttribute("role","radio"),o.setAttribute("aria-checked",s<=t?"true":"false"),o.setAttribute("aria-label",a(`${s} star${s>1?"s":""}`)),o.setAttribute("tabindex",s===(t||1)?"0":"-1"),o.dataset.value=String(s),o.textContent=s<=t?"\u2605":"\u2606",e.appendChild(o)}}_getButtons(){return[...this.shadowRoot.querySelectorAll('button[role="radio"]')]}_onClick(e){let t=e.target.closest("button");t&&this._setValue(parseInt(t.dataset.value,10))}_onKey(e){let t=this._getButtons();if(t.includes(e.target)&&(b(this,t,e),["ArrowLeft","ArrowRight","Home","End"].includes(e.key))){let i=t.find(s=>s.getAttribute("tabindex")==="0");i&&this._setValue(parseInt(i.dataset.value,10))}}_setValue(e){this.setAttribute("value",String(e)),this.dispatchEvent(new CustomEvent("velin-change",{bubbles:!0,detail:{value:e}}))}attributeChangedCallback(e){e==="value"&&this.shadowRoot?.querySelector(".stars")&&this._render()}};customElements.define("velin-rating",ae);var ei=ae;var ti=`
|
|
1023
|
+
${x}
|
|
1024
|
+
:host { display: block; }
|
|
1025
|
+
.menubar {
|
|
1026
|
+
display: flex;
|
|
1027
|
+
flex-wrap: wrap;
|
|
1028
|
+
gap: var(--velin-space-1, 0.25rem);
|
|
1029
|
+
padding: var(--velin-space-2, 0.5rem);
|
|
1030
|
+
background: var(--velin-color-surface-bright, #fff);
|
|
1031
|
+
border-bottom: 1px solid var(--velin-color-border, #ddd);
|
|
1032
|
+
}
|
|
1033
|
+
::slotted([role="menuitem"]) {
|
|
1034
|
+
min-inline-size: 2.75rem;
|
|
1035
|
+
min-block-size: 2.75rem;
|
|
1036
|
+
padding: var(--velin-space-2, 0.5rem) var(--velin-space-4, 1rem);
|
|
1037
|
+
background: none;
|
|
1038
|
+
border: none;
|
|
1039
|
+
border-radius: var(--velin-radius-sm, 0.25rem);
|
|
1040
|
+
cursor: pointer;
|
|
1041
|
+
font-size: var(--velin-text-base, 1rem);
|
|
1042
|
+
color: var(--velin-color-text, #111);
|
|
1043
|
+
}
|
|
1044
|
+
::slotted([role="menuitem"]:hover) {
|
|
1045
|
+
background: var(--velin-color-surface-dim, #eee);
|
|
1046
|
+
}
|
|
1047
|
+
`,le=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this._onKey=this._onKey.bind(this)}connectedCallback(){let e=a(this.getAttribute("aria-label")||"Menu bar");this.shadowRoot.innerHTML=`
|
|
1048
|
+
<style>${ti}</style>
|
|
1049
|
+
<div class="menubar" role="menubar" aria-label="${e}"><slot></slot></div>
|
|
1050
|
+
`,this.addEventListener("keydown",this._onKey),this.shadowRoot.querySelector("slot")?.addEventListener("slotchange",()=>this._init()),this._init()}_getItems(){let e=this.shadowRoot.querySelector("slot");return e?e.assignedElements().filter(t=>!t.hasAttribute("disabled")):[]}_init(){this._getItems().forEach((t,i)=>{t.hasAttribute("role")||t.setAttribute("role","menuitem"),t.setAttribute("tabindex",i===0?"0":"-1")})}_onKey(e){let t=this._getItems();t.includes(e.target)&&b(this,t,e)}static get observedAttributes(){return["aria-label"]}attributeChangedCallback(e){if(e==="aria-label"){let t=this.shadowRoot?.querySelector(".menubar");t&&t.setAttribute("aria-label",a(this.getAttribute("aria-label")||"Menu bar"))}}disconnectedCallback(){this.removeEventListener("keydown",this._onKey)}};customElements.define("velin-menubar",le);var ii=le;var si=`
|
|
1051
|
+
${x}
|
|
1052
|
+
:host { display: contents; }
|
|
1053
|
+
.overlay {
|
|
1054
|
+
position: fixed; inset: 0; z-index: var(--velin-z-modal, 500);
|
|
1055
|
+
display: flex; align-items: flex-start; justify-content: center;
|
|
1056
|
+
padding: 10vh var(--velin-space-4, 1rem) var(--velin-space-4, 1rem);
|
|
1057
|
+
background: var(--velin-color-overlay, rgba(0,0,0,0.4));
|
|
1058
|
+
opacity: 0; visibility: hidden;
|
|
1059
|
+
transition: opacity 150ms ease, visibility 150ms ease;
|
|
1060
|
+
}
|
|
1061
|
+
:host([open]) .overlay { opacity: 1; visibility: visible; }
|
|
1062
|
+
.panel {
|
|
1063
|
+
inline-size: min(32rem, 100%);
|
|
1064
|
+
background: var(--velin-color-surface-bright, #fff);
|
|
1065
|
+
border-radius: var(--velin-radius-lg, 0.75rem);
|
|
1066
|
+
box-shadow: var(--velin-shadow-xl, 0 20px 25px rgba(0,0,0,0.1));
|
|
1067
|
+
overflow: hidden;
|
|
1068
|
+
}
|
|
1069
|
+
.search {
|
|
1070
|
+
inline-size: 100%; padding: var(--velin-space-4, 1rem);
|
|
1071
|
+
border: none; border-bottom: 1px solid var(--velin-color-border, #ddd);
|
|
1072
|
+
font-size: var(--velin-text-base, 1rem);
|
|
1073
|
+
background: transparent;
|
|
1074
|
+
color: var(--velin-color-text, #111);
|
|
1075
|
+
}
|
|
1076
|
+
.results { max-block-size: 20rem; overflow-y: auto; padding: var(--velin-space-2, 0.5rem); }
|
|
1077
|
+
::slotted(button) {
|
|
1078
|
+
display: flex; inline-size: 100%;
|
|
1079
|
+
padding: var(--velin-space-3, 0.75rem) var(--velin-space-4, 1rem);
|
|
1080
|
+
min-block-size: 2.5rem;
|
|
1081
|
+
border: none; background: none; text-align: start;
|
|
1082
|
+
cursor: pointer; font-size: var(--velin-text-base, 1rem);
|
|
1083
|
+
border-radius: var(--velin-radius-sm, 0.25rem);
|
|
1084
|
+
}
|
|
1085
|
+
::slotted(button[hidden]) { display: none; }
|
|
1086
|
+
::slotted(button:focus-visible) {
|
|
1087
|
+
background: var(--velin-color-surface-dim, #eee);
|
|
1088
|
+
}
|
|
1089
|
+
`,ce=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),this._onInput=this._onInput.bind(this)}connectedCallback(){let e=a(this.getAttribute("placeholder")||"Search commands\u2026");this.shadowRoot.innerHTML=`
|
|
1090
|
+
<style>${si}</style>
|
|
1091
|
+
<div class="overlay" part="overlay">
|
|
1092
|
+
<div class="panel" role="dialog" aria-modal="true" aria-label="Command palette" part="panel">
|
|
1093
|
+
<input class="search" type="search" autocomplete="off" placeholder="${e}" aria-label="Search" part="search" />
|
|
1094
|
+
<div class="results" part="results"><slot></slot></div>
|
|
1095
|
+
</div>
|
|
1096
|
+
</div>
|
|
1097
|
+
`,this.shadowRoot.querySelector(".search").addEventListener("input",this._onInput),this.shadowRoot.querySelector("slot")?.addEventListener("slotchange",()=>this._filter("")),this._filter("")}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=g(),A(this),document.addEventListener("keydown",this._onKey),requestAnimationFrame(()=>{this.shadowRoot.querySelector(".search")?.focus(),this._filter("")})}_close(){document.removeEventListener("keydown",this._onKey),E(),y(this._prev);let e=this.shadowRoot.querySelector(".search");e&&(e.value=""),this._filter("")}_onInput(e){this._filter(e.target.value)}_filter(e){let t=e.trim().toLowerCase();this.shadowRoot.querySelector("slot")?.assignedElements().forEach(s=>{let o=s.textContent?.trim().toLowerCase()||"",n=!t||o.includes(t);s.hidden=!n})}_onKey(e){if(e.key==="Escape"){this.close();return}v(this.shadowRoot,e)}disconnectedCallback(){document.removeEventListener("keydown",this._onKey)}};customElements.define("velin-command",ce);var ri=ce;var oi=`
|
|
1098
|
+
:host { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
|
|
1099
|
+
`,de=class extends HTMLElement{connectedCallback(){this.shadowRoot||this.attachShadow({mode:"open"});let e=this.getAttribute("polite")==="false"?"assertive":"polite";this.shadowRoot.innerHTML="<style>"+oi+'</style><div role="status" aria-live="'+e+'" aria-atomic="true" part="region"></div>',this._region=this.shadowRoot.querySelector('[role="status"]')}announce(e,{assertive:t=!1}={}){this._region||this.connectedCallback(),this._region.setAttribute("aria-live",t?"assertive":"polite"),this._region.textContent="",requestAnimationFrame(()=>{this._region.textContent=typeof e=="string"?e:""})}static announceGlobal(e,t){let i=document.querySelector("velin-announcer");i||(i=document.createElement("velin-announcer"),document.body.appendChild(i)),i.announce(e,t)}};customElements.define("velin-announcer",de);var ni=de;var L="http://www.w3.org/2000/svg";function ai(r){if(!r)return[];let e=String(r).trim();if(e.startsWith("["))try{let t=JSON.parse(e);return Array.isArray(t)?t.map(Number).filter(i=>Number.isFinite(i)):[]}catch{return[]}return e.split(/[\s,]+/).map(t=>Number.parseFloat(t)).filter(t=>Number.isFinite(t))}function li(r,e,t,i,s){let o=r.length;if(o===0)return[];if(o===1)return[[0,t/2],[e,t/2]];let n=Math.max(s-i,1e-6),c=e/(o-1);return r.map((l,d)=>{let u=d*c,f=t-(l-i)/n*t;return[u,f]})}function Le(r){return r.length?r.map(([e,t],i)=>`${i===0?"M":"L"}${e.toFixed(2)},${t.toFixed(2)}`).join(" "):""}function ci(r,e){if(!r.length)return"";let t=Le(r),i=r[r.length-1][0],s=r[0][0];return`${t} L${i.toFixed(2)},${e} L${s.toFixed(2)},${e} Z`}var ue=class extends HTMLElement{static get observedAttributes(){return["values","width","height","min","max","area","glow","animate","label"]}constructor(){super(),this._values=[],this._gradientId=`velin-spark-grad-${Math.random().toString(36).slice(2,8)}`}connectedCallback(){this._render()}attributeChangedCallback(){this.isConnected&&this._render()}get values(){return this._values.slice()}set values(e){Array.isArray(e)&&(this._values=e.filter(t=>Number.isFinite(Number(t))).map(Number),this.setAttribute("values",this._values.join(",")))}update(e){Array.isArray(e)&&(this._values=e.filter(t=>Number.isFinite(Number(t))).map(Number),this._render({tick:!0}))}_render({tick:e=!1}={}){let t=Number.parseFloat(this.getAttribute("width"))||320,i=Number.parseFloat(this.getAttribute("height"))||96,s=this._values.length?this._values:ai(this.getAttribute("values"));if(this._values=s,!s.length){this.innerHTML="";return}let o=Number.parseFloat(this.getAttribute("min")),n=Number.parseFloat(this.getAttribute("max")),c=Number.isFinite(o)?o:Math.min(...s),l=Number.isFinite(n)?n:Math.max(...s),d=this.hasAttribute("area")&&this.getAttribute("area")!=="false",u=this.hasAttribute("glow")&&this.getAttribute("glow")!=="false",f=(this.getAttribute("animate")||"draw").toLowerCase(),w=this.getAttribute("label"),k=li(s,t,i,c,l),h=Le(k),C=d?ci(k,i):"";this.innerHTML="";let p=document.createElementNS(L,"svg");if(p.setAttribute("viewBox",`0 0 ${t} ${i}`),p.setAttribute("preserveAspectRatio","none"),p.style.display="block",p.style.width="100%",p.style.height="100%",w?(p.setAttribute("role","img"),p.setAttribute("aria-label",w)):p.setAttribute("aria-hidden","true"),d){let R=document.createElementNS(L,"defs"),S=document.createElementNS(L,"linearGradient");S.setAttribute("id",this._gradientId),S.setAttribute("x1","0"),S.setAttribute("x2","0"),S.setAttribute("y1","0"),S.setAttribute("y2","1"),[["0%","currentColor","0.35"],["100%","currentColor","0"]].forEach(([Ne,Oe,Be])=>{let $=document.createElementNS(L,"stop");$.setAttribute("offset",Ne),$.setAttribute("stop-color",Oe),$.setAttribute("stop-opacity",Be),S.appendChild($)}),R.appendChild(S),p.appendChild(R);let T=document.createElementNS(L,"path");T.setAttribute("d",C),T.setAttribute("fill",`url(#${this._gradientId})`),T.setAttribute("stroke","none"),T.classList.add("velin-chart-area"),p.appendChild(T)}let m=document.createElementNS(L,"path");if(m.setAttribute("d",h),m.setAttribute("fill","none"),m.setAttribute("stroke","currentColor"),m.setAttribute("stroke-width","2"),m.setAttribute("stroke-linecap","round"),m.setAttribute("stroke-linejoin","round"),m.setAttribute("vector-effect","non-scaling-stroke"),p.appendChild(m),u&&p.classList.add("velin-chart-glow"),this.appendChild(p),f!=="none"){let R=typeof m.getTotalLength=="function"&&m.getTotalLength()||t;m.style.setProperty("--velin-chart-len",R.toFixed(2)),m.classList.add("velin-chart-line")}else m.style.strokeDasharray="",m.style.strokeDashoffset="";e&&(this.classList.remove("velin-spark-tick"),this.offsetWidth,this.classList.add("velin-spark-tick"))}};typeof customElements<"u"&&!customElements.get("velin-sparkline")&&customElements.define("velin-sparkline",ue);var di=ue;var ui=r=>r===1?1:1-Math.pow(2,-10*r);function hi(r){let e=(r.getAttribute("format")||"number").toLowerCase(),t=r.getAttribute("locale")||void 0,i=r.getAttribute("decimals"),s=i!=null?Math.max(0,Number.parseInt(i,10)||0):null,o={};s!=null&&(o.minimumFractionDigits=s,o.maximumFractionDigits=s),e==="currency"?(o.style="currency",o.currency=r.getAttribute("currency")||"EUR"):e==="percent"&&(o.style="percent");try{return new Intl.NumberFormat(t,o)}catch{return new Intl.NumberFormat(void 0,o)}}var he=class extends HTMLElement{static get observedAttributes(){return["from","to","duration","decimals","prefix","suffix","format","currency","locale"]}constructor(){super(),this._rafId=0,this._started=!1,this._observer=null}connectedCallback(){this._render(this._fromValue()),this.getAttribute("autostart")!=="false"&&this._scheduleStart()}disconnectedCallback(){cancelAnimationFrame(this._rafId),this._observer?.disconnect()}attributeChangedCallback(e){this.isConnected&&(e==="to"||e==="from"?this.start():this._render(this._lastValue??this._toValue()))}_fromValue(){return Number.parseFloat(this.getAttribute("from"))||0}_toValue(){return Number.parseFloat(this.getAttribute("to"))||0}_duration(){return Math.max(0,Number.parseFloat(this.getAttribute("duration"))||900)}_scheduleStart(){if(!this._started){if(typeof IntersectionObserver>"u"){this.start();return}this._observer=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){this.start(),this._observer.disconnect(),this._observer=null;break}},{threshold:.2}),this._observer.observe(this)}}start(){cancelAnimationFrame(this._rafId),this._started=!0;let e=this._fromValue(),t=this._toValue(),i=this._duration();if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||i===0){this._render(t);return}let o=performance.now(),n=c=>{let l=Math.min(1,(c-o)/i),d=e+(t-e)*ui(l);this._render(d),l<1&&(this._rafId=requestAnimationFrame(n))};this._rafId=requestAnimationFrame(n)}reset(){cancelAnimationFrame(this._rafId),this._started=!1,this._render(this._fromValue())}_render(e){this._lastValue=e;let t=hi(this),i=this.getAttribute("prefix")||"",s=this.getAttribute("suffix")||"";this.textContent=`${i}${t.format(e)}${s}`}};typeof customElements<"u"&&!customElements.get("velin-counter")&&customElements.define("velin-counter",he);var pi=he;var Ce={live:"var(--velin-color-success, oklch(60% 0.16 145))",paused:"var(--velin-color-text-muted, oklch(60% 0.02 240))",warning:"var(--velin-color-warning, oklch(75% 0.16 80))",error:"var(--velin-color-danger, oklch(60% 0.2 25))",muted:"var(--velin-color-border, oklch(85% 0.01 240))"},mi=`
|
|
1100
|
+
:host {
|
|
1101
|
+
display: inline-flex;
|
|
1102
|
+
align-items: center;
|
|
1103
|
+
gap: var(--velin-space-2, 0.5rem);
|
|
1104
|
+
font-size: inherit;
|
|
1105
|
+
color: inherit;
|
|
1106
|
+
line-height: 1.2;
|
|
1107
|
+
}
|
|
1108
|
+
.dot {
|
|
1109
|
+
inline-size: 0.55rem;
|
|
1110
|
+
block-size: 0.55rem;
|
|
1111
|
+
border-radius: 50%;
|
|
1112
|
+
background: var(--velin-live-color);
|
|
1113
|
+
flex-shrink: 0;
|
|
1114
|
+
}
|
|
1115
|
+
:host([pulse="false"]) .dot { animation: none; }
|
|
1116
|
+
:host(:not([pulse="false"])) .dot { animation: velin-live-pulse 1.8s var(--velin-ease-out, ease-out) infinite; }
|
|
1117
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1118
|
+
.dot { animation: none !important; }
|
|
1119
|
+
}
|
|
1120
|
+
`,vi=`
|
|
1121
|
+
@keyframes velin-live-pulse {
|
|
1122
|
+
0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--velin-live-color) 65%, transparent); }
|
|
1123
|
+
70% { box-shadow: 0 0 0 0.6rem color-mix(in oklch, var(--velin-live-color) 0%, transparent); }
|
|
1124
|
+
100% { box-shadow: 0 0 0 0 transparent; }
|
|
1125
|
+
}`,pe=class extends HTMLElement{static get observedAttributes(){return["status","pulse"]}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this._render()}attributeChangedCallback(){this.shadowRoot&&this._render()}_render(){let e=this.getAttribute("status")||"live",t=Ce[e]||Ce.live;this.style.setProperty("--velin-live-color",t),this.shadowRoot.innerHTML=`
|
|
1126
|
+
<style>${mi}${vi}</style>
|
|
1127
|
+
<span class="dot" aria-hidden="true"></span><slot></slot>
|
|
1128
|
+
`}};typeof customElements<"u"&&!customElements.get("velin-live-dot")&&customElements.define("velin-live-dot",pe);var bi=pe;var fi={selector:".velin-animate-on-scroll",threshold:.1,rootMargin:"0px 0px -40px 0px",once:!0,visibleClass:"is-visible"},ye=new WeakMap;function Te(r={}){if(typeof document>"u")return()=>{};let e={...fi,...r},t=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=Array.from(document.querySelectorAll(e.selector));if(t||typeof IntersectionObserver>"u")return i.forEach(o=>o.classList.add(e.visibleClass)),()=>{};let s=new IntersectionObserver(o=>{for(let n of o)n.isIntersecting&&(n.target.classList.add(e.visibleClass),e.once&&s.unobserve(n.target))},{threshold:e.threshold,rootMargin:e.rootMargin});return i.forEach(o=>{ye.has(o)||(ye.set(o,s),s.observe(o))}),()=>{s.disconnect(),i.forEach(o=>ye.delete(o))}}if(typeof document<"u"){let r=()=>{document.documentElement&&document.documentElement.hasAttribute("data-velin-reveal-auto")&&Te()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r,{once:!0}):r()}var Me=typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-reduced-motion: reduce)"):null,ze={duration:250,easing:"var(--velin-ease-expo-out, cubic-bezier(0.16, 1, 0.3, 1))",itemSelector:":scope > *"};function _e(r,e){return Array.from(r.querySelectorAll(e))}function He(r,e,t={}){if(!r||typeof e!="function")return;let i={...ze,...t},s=Me&&Me.matches,o=_e(r,i.itemSelector),n=new Map;if(o.forEach(l=>{l.hidden||n.set(l,l.getBoundingClientRect())}),e(),s)return;_e(r,i.itemSelector).forEach(l=>{if(l.hidden)return;let d=n.get(l),u=l.getBoundingClientRect();if(!d){if(typeof l.animate!="function")return;l.animate([{opacity:0,transform:"scale(0.96)"},{opacity:1,transform:"scale(1)"}],{duration:i.duration,easing:i.easing,fill:"both"});return}let f=d.left-u.left,w=d.top-u.top;f===0&&w===0||typeof l.animate=="function"&&l.animate([{transform:`translate(${f}px, ${w}px)`},{transform:"translate(0, 0)"}],{duration:i.duration,easing:i.easing,fill:"both"})})}function De(r,e,t={}){if(!r||typeof e!="function")return;let i={...ze,...t};He(r,()=>{_e(r,i.itemSelector).forEach(s=>{s.hidden=!e(s)})},i)}function Re(r){return r?String(r).toLowerCase().split(/[\s,|]+/).map(e=>e.trim()).filter(Boolean):[]}function gi(r,e,t){return e.length?t==="all"?e.every(i=>r.includes(i)):e.some(i=>r.includes(i)):!0}function yi(r,e){return e?((r.getAttribute("data-tags")||"")+" "+(r.getAttribute("data-search")||"")+" "+(r.textContent||"")).toLowerCase().includes(e.toLowerCase()):!0}var xe=class{constructor(e){this.container=e,this.tag="",this.search="",this.matchMode=e.getAttribute("data-velin-filter-mode")==="all"?"all":"any",this.itemSelector=e.getAttribute("data-velin-filter-item")||":scope > *"}apply(){let e=Re(this.tag),t=this.search;De(this.container,i=>{let s=Re(i.getAttribute("data-tags"));return gi(s,e,this.matchMode)&&yi(i,t)},{itemSelector:this.itemSelector})}},$e=new WeakMap;function qe(r){let e=$e.get(r);return e||(e=new xe(r),$e.set(r,e)),e}function Ie(r){let e=r.getAttribute("data-velin-filter-target");if(!e)return null;try{return document.querySelector(e)}catch{return null}}function _i(r,e){r&&r.querySelectorAll("[data-velin-filter-value]").forEach(t=>{t===e?t.setAttribute("data-velin-filter-active",""):t.removeAttribute("data-velin-filter-active")})}function Fe(){if(typeof document>"u")return;document.addEventListener("click",e=>{let t=e.target.closest("[data-velin-filter-value]");if(!t)return;let i=Ie(t);if(!i)return;let s=t.closest("[data-velin-filter-group]")||t.parentElement;_i(s,t);let o=qe(i);o.tag=t.getAttribute("data-velin-filter-value")||"",(o.tag.toLowerCase()==="all"||o.tag==="*")&&(o.tag=""),o.apply()});let r=e=>{let t=e.target.closest("[data-velin-filter-input]");if(!t)return;let i=Ie(t);if(!i)return;let s=qe(i),o=t.value||(typeof t.getAttribute=="function"?t.getAttribute("value"):"");s.search=(o||"").trim(),s.apply()};document.addEventListener("input",r),document.addEventListener("change",r)}typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Fe,{once:!0}):Fe());var we={tap:[10],"double-tap":[10,50,10],success:[50],error:[100,30,100],warning:[30,20,30],long:[200]};function Ke(r){if(typeof navigator>"u"||!navigator.vibrate||window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches)return;let t=typeof r=="string"?we[r]||we.tap:r;navigator.vibrate(t)}function me(r){let e=r.getAttribute("haptic")||"tap";r.addEventListener("click",()=>Ke(e))}var M=class{constructor(){this._observer=null}start(e=document.body){e.querySelectorAll("[haptic]").forEach(me),this._observer=new MutationObserver(i=>{for(let s of i)for(let o of s.addedNodes)o.nodeType===1&&(o.hasAttribute?.("haptic")&&me(o),o.querySelectorAll?.("[haptic]").forEach(me))}),this._observer.observe(e,{childList:!0,subtree:!0})}stop(){this._observer?.disconnect()}};if(typeof document<"u"){let r=()=>{new M().start(document.body)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r()}export{we as HapticPatterns,it as VelinAccordion,ni as VelinAnnouncer,Ut as VelinBottomNav,At as VelinCarousel,Ct as VelinCollapse,Vt as VelinCombobox,ri as VelinCommand,_t as VelinCopy,Nt as VelinCountdown,pi as VelinCounter,Dt as VelinDialog,dt as VelinDrawer,et as VelinDropdown,M as VelinHapticObserver,lt as VelinIcon,It as VelinLightbox,bi as VelinLiveDot,ii as VelinMenubar,Je as VelinModal,jt as VelinPersist,gt as VelinPopover,Bt as VelinProgressRing,ei as VelinRating,wt as VelinScrollTop,Tt as VelinScrollspy,Jt as VelinSegmentedControl,Gt as VelinSheet,di as VelinSparkline,zt as VelinStepperWC,rt as VelinTabs,vt as VelinThemeToggle,nt as VelinToast,$t as VelinTooltipWC,me as applyHaptic,E as clearBackgroundInert,Ge as createSafeHTML,a as escapeHTML,We as escapeHTMLAttribute,De as filterList,He as flipReorder,_ as getFocusableElements,Ae as getTrustedPolicy,Te as initReveal,y as restoreFocus,b as rovingTabindex,be as sanitizeURL,g as saveFocus,A as setBackgroundInert,ve as stripControlChars,v as trapFocus,Ke as vibrate};
|