@auvyx/ui 0.0.0-stage → 0.1.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/LICENSE +48 -0
- package/README.md +43 -2
- package/dist/auvyx.bundle.css +5941 -0
- package/dist/auvyx.chart.min.js +2 -0
- package/dist/auvyx.corners.min.js +2 -0
- package/dist/auvyx.css +10880 -0
- package/dist/auvyx.js +3222 -0
- package/dist/auvyx.min.css +2 -0
- package/dist/auvyx.min.js +19 -0
- package/dist/custom-elements.json +948 -0
- package/dist/elements/calendar.min.js +2 -0
- package/dist/elements/context-menu.min.js +2 -0
- package/dist/elements/data-table.min.js +2 -0
- package/dist/elements/date-picker.min.js +2 -0
- package/dist/elements/index.min.js +2 -0
- package/dist/elements/menu.min.js +2 -0
- package/dist/elements/resizable.min.js +2 -0
- package/dist/js/accordion.min.js +2 -0
- package/dist/js/calendar.min.js +2 -0
- package/dist/js/combobox.min.js +2 -0
- package/dist/js/command.min.js +2 -0
- package/dist/js/context-menu.min.js +2 -0
- package/dist/js/copy.min.js +2 -0
- package/dist/js/data-table.min.js +2 -0
- package/dist/js/date-picker.min.js +2 -0
- package/dist/js/drawer.min.js +2 -0
- package/dist/js/dropdown-menu.min.js +2 -0
- package/dist/js/manifest.json +114 -0
- package/dist/js/menu.min.js +2 -0
- package/dist/js/popover.min.js +2 -0
- package/dist/js/resizable.min.js +2 -0
- package/dist/js/select.min.js +2 -0
- package/dist/js/sidebar.min.js +2 -0
- package/dist/js/slider.min.js +2 -0
- package/dist/js/tabs.min.js +2 -0
- package/dist/js/toast.min.js +19 -0
- package/dist/styles/auvyx-luma.min.css +3 -0
- package/dist/styles/auvyx-lyra.min.css +3 -0
- package/dist/styles/auvyx-maia.min.css +3 -0
- package/dist/styles/auvyx-mira.min.css +3 -0
- package/dist/styles/auvyx-nova.min.css +3 -0
- package/dist/styles/auvyx-rhea.min.css +3 -0
- package/dist/styles/auvyx-sera.min.css +3 -0
- package/dist/styles/auvyx-vega.min.css +3 -0
- package/dist/types/elements.d.ts +262 -0
- package/dist/types/react.d.ts +181 -0
- package/dist/types/vue.d.ts +155 -0
- package/dist/ui/accordion.css +91 -0
- package/dist/ui/accordion.js +249 -0
- package/dist/ui/accordion.native.css +24 -0
- package/dist/ui/alert.css +119 -0
- package/dist/ui/aspect-ratio.css +38 -0
- package/dist/ui/attachment.css +211 -0
- package/dist/ui/avatar.css +204 -0
- package/dist/ui/badge.css +183 -0
- package/dist/ui/base.css +1200 -0
- package/dist/ui/breadcrumb.css +90 -0
- package/dist/ui/bubble.css +171 -0
- package/dist/ui/button-group.css +110 -0
- package/dist/ui/button.css +328 -0
- package/dist/ui/calendar.css +260 -0
- package/dist/ui/calendar.js +317 -0
- package/dist/ui/card.css +126 -0
- package/dist/ui/carousel.css +172 -0
- package/dist/ui/chart.css +130 -0
- package/dist/ui/checkbox.css +119 -0
- package/dist/ui/code-block.css +235 -0
- package/dist/ui/combobox.css +500 -0
- package/dist/ui/combobox.js +757 -0
- package/dist/ui/command.css +366 -0
- package/dist/ui/command.js +382 -0
- package/dist/ui/context-menu.css +17 -0
- package/dist/ui/context-menu.js +52 -0
- package/dist/ui/copy.js +56 -0
- package/dist/ui/data-table.css +114 -0
- package/dist/ui/data-table.js +140 -0
- package/dist/ui/date-picker.css +14 -0
- package/dist/ui/date-picker.js +101 -0
- package/dist/ui/dialog.css +363 -0
- package/dist/ui/dialog.native.css +6 -0
- package/dist/ui/drawer.css +238 -0
- package/dist/ui/drawer.js +265 -0
- package/dist/ui/dropdown-menu.css +193 -0
- package/dist/ui/dropdown-menu.js +388 -0
- package/dist/ui/empty.css +111 -0
- package/dist/ui/field.css +293 -0
- package/dist/ui/hover-card.css +85 -0
- package/dist/ui/input-group.css +269 -0
- package/dist/ui/input-otp.css +101 -0
- package/dist/ui/input.css +117 -0
- package/dist/ui/item.css +223 -0
- package/dist/ui/kbd.css +50 -0
- package/dist/ui/label.css +48 -0
- package/dist/ui/manifest.json +667 -0
- package/dist/ui/marker.css +66 -0
- package/dist/ui/menu.js +161 -0
- package/dist/ui/menubar.css +55 -0
- package/dist/ui/message-scroller.css +83 -0
- package/dist/ui/message.css +69 -0
- package/dist/ui/native-select.css +130 -0
- package/dist/ui/navigation-menu.css +166 -0
- package/dist/ui/popover.css +154 -0
- package/dist/ui/popover.js +268 -0
- package/dist/ui/popover.native.css +84 -0
- package/dist/ui/progress.css +29 -0
- package/dist/ui/questionnaire.css +188 -0
- package/dist/ui/radio-group.css +115 -0
- package/dist/ui/resizable.css +94 -0
- package/dist/ui/resizable.js +95 -0
- package/dist/ui/scroll-area.css +43 -0
- package/dist/ui/select.css +289 -0
- package/dist/ui/select.js +646 -0
- package/dist/ui/sheet.css +219 -0
- package/dist/ui/sidebar.css +716 -0
- package/dist/ui/sidebar.js +287 -0
- package/dist/ui/skeleton.css +13 -0
- package/dist/ui/slider.css +184 -0
- package/dist/ui/slider.js +206 -0
- package/dist/ui/switch.css +156 -0
- package/dist/ui/table.css +157 -0
- package/dist/ui/tabs.css +240 -0
- package/dist/ui/tabs.js +288 -0
- package/dist/ui/textarea.css +91 -0
- package/dist/ui/toast.css +110 -0
- package/dist/ui/toast.js +378 -0
- package/dist/ui/toggle-group.css +42 -0
- package/dist/ui/toggle.css +150 -0
- package/dist/ui/tooltip.css +319 -0
- package/dist/ui/trace.css +142 -0
- package/dist/ui/typography.css +184 -0
- package/dist/wc/accordion.min.js +2 -0
- package/dist/wc/combobox.min.js +2 -0
- package/dist/wc/command.min.js +2 -0
- package/dist/wc/drawer.min.js +2 -0
- package/dist/wc/dropdown-menu.min.js +2 -0
- package/dist/wc/manifest.json +154 -0
- package/dist/wc/popover.min.js +2 -0
- package/dist/wc/select.min.js +2 -0
- package/dist/wc/sidebar.min.js +2 -0
- package/dist/wc/slider.min.js +2 -0
- package/dist/wc/tabs.min.js +2 -0
- package/dist/wc/toast.min.js +19 -0
- package/package.json +62 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const b={};let x=null;const c=(s,l,p)=>{const f=typeof l=="object"?l:{selector:l,init:p};b[s]={selector:f.selector,init:f.init,refresh:f.refresh}},d=(s,l)=>{const p=b[l];if(p)try{p.init(s),s.hasAttribute(`data-${l}-initialized`)&&(s.dataset.basecoatComponent=l)}catch(f){if(console.error(`Failed to initialize ${l}:`,f),typeof s._destroy=="function")try{s._destroy()}catch(v){console.error(`Failed to clean up ${l} after initialization error:`,v)}delete s._destroy,s.removeAttribute(`data-${l}-initialized`),delete s.dataset.basecoatComponent}},E=s=>{if(!s||s.nodeType!==Node.ELEMENT_NODE)return;const l=s.dataset?.basecoatComponent;if(typeof s._destroy=="function")try{s._destroy()}catch(p){console.error("Failed to destroy Basecoat component:",p)}delete s._destroy,l&&s.removeAttribute(`data-${l}-initialized`),delete s.dataset.basecoatComponent},T=s=>{s.nodeType===Node.ELEMENT_NODE&&(s.isConnected||(s.dataset?.basecoatComponent&&E(s),s.querySelectorAll("[data-basecoat-component]").forEach(E)))},q=s=>Array.from(new Set(s)),A=(s,l,p=!1)=>{const f=Array.from(document.querySelectorAll(l));return p&&f.push(...document.querySelectorAll(`[data-basecoat-component="${s}"]`)),q(f)},w=(s={})=>{const l=s.force===!0;Object.entries(b).forEach(([p,{selector:f}])=>{A(p,f,l).forEach(v=>{const S=v.dataset?.basecoatComponent===p;l&&E(v),(S||v.matches(f))&&d(v,p)})})},B=s=>{s.nodeType===Node.ELEMENT_NODE&&Object.entries(b).forEach(([l,{selector:p}])=>{s.matches(p)&&d(s,l),s.querySelectorAll(p).forEach(f=>d(f,l))})},g=s=>{if(!s)return;if(typeof s.refresh=="function"){s.refresh();return}const l=s.dataset?.basecoatComponent,p=l?b[l]:null;p?.refresh&&p.refresh(s)},L=()=>{x||(x=new MutationObserver(s=>{s.forEach(l=>{l.addedNodes.forEach(B),l.removedNodes.forEach(T)})}),x.observe(document.body,{childList:!0,subtree:!0}))},I=()=>{x&&(x.disconnect(),x=null)},D=(s,l={})=>{const p=b[s];if(!p){console.warn(`Component '${s}' not found in registry`);return}const f=l.force===!0;A(s,p.selector,f).forEach(v=>{const S=v.dataset?.basecoatComponent===s;f&&E(v),(S||v.matches(p.selector))&&d(v,s)})},N=(s={})=>{w(s)},_=s=>{const l=s==="dark";document.documentElement.classList.toggle("dark",l);try{localStorage.setItem("themeMode",l?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:l?"dark":"light"}}))},O=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:c,init:D,initAll:N,refresh:g,start:L,stop:I,theme:{get:O,set:_,toggle:()=>_(O()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{w(),L()})})(),(()=>{const b=new WeakMap,x=e=>{const t=e.querySelector(":scope > [data-popover]"),i=e.querySelector(':scope > input[role="combobox"], :scope > .input-group input[role="combobox"], :scope > .combobox-chips input[role="combobox"]')||t?.querySelector('input[role="combobox"]'),n=e.querySelector(":scope > .combobox-chips"),r=e.querySelector(':scope > button[aria-haspopup="listbox"]'),o=r||e.querySelector(':scope > .input-group button[aria-haspopup="listbox"]'),a=e.querySelector("[data-clear]"),h=r?.querySelector("[data-value]")||(r?.matches("[data-value]")?r:null),y=t?t.querySelector('[role="listbox"]'):null,k=e.querySelector(':scope > input[type="hidden"]');return{input:i,chips:n,trigger:o,clearButton:a,valueTarget:h,popover:t,listbox:y,hiddenInput:k}},c=(e,t)=>{if(t.listbox?.getAttribute("aria-multiselectable")!=="true"||t.chips||!t.input||t.input.parentElement!==e)return t;const i=document.createElement("div");return i.className="combobox-chips",e.insertBefore(i,t.input),i.appendChild(t.input),x(e)},d=e=>e.dataset.value??e.textContent.trim(),E=e=>e.dataset.label||e.textContent.trim(),T=e=>e.dataset.format==="object"?"object":"value",q=e=>e.getAttribute("aria-disabled")==="true",A=e=>({value:d(e),label:E(e)}),w=e=>{if(e&&typeof e=="object"){const i=e.value==null?"":String(e.value);return i?{value:i,label:String(e.label??e.value)}:null}const t=e==null?"":String(e);return t?{value:t,label:t}:null},B=e=>{const t=Array.from(e.querySelectorAll('[role="option"]'));return{allOptions:t,options:t.filter(i=>!q(i))}},g=e=>Array.from(e.selected.values()),L=e=>e.isMultiple?g(e).map(t=>t.value):g(e)[0]?.value||"",I=e=>e.isMultiple?g(e):g(e)[0]||null,D=e=>{const t=g(e);if(e.format==="object")return JSON.stringify(e.isMultiple?t:t[0]||null);const i=t.map(n=>n.value);return e.isMultiple?JSON.stringify(i):i[0]||""},N=(e,t,i)=>{if(i.isMultiple){let o=[];try{o=JSON.parse(e||"[]")}catch{o=[]}return Array.isArray(o)?o.map(a=>{const h=w(i.format==="object"?a:{value:a,label:i.selected.get(String(a))?.label??a});if(!h)return null;const y=i.options.find(k=>d(k)===h.value);return y?A(y):h}).filter(Boolean):[]}if(i.format==="object")try{const o=w(JSON.parse(e||"null"));if(!o)return[];const a=i.options.find(h=>d(h)===o.value);return[a?A(a):o]}catch{return[]}const n=e||"";if(!n)return[];const r=i.options.find(o=>d(o)===n);return[r?A(r):{value:n,label:i.selected.get(n)?.label||t||n}]},_=(e,t)=>{const i=t.getBoundingClientRect(),n=e.listbox.getBoundingClientRect();i.top<n.top?e.listbox.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.listbox.scrollTop+=i.bottom-n.bottom)},O=(e,t)=>{if(e.activeIndex>-1&&e.options[e.activeIndex]&&e.options[e.activeIndex].classList.remove("active"),e.activeIndex=t,e.activeIndex>-1){const i=e.options[e.activeIndex];i.classList.add("active"),i.id||(i.id=`${e.listbox.id||e.root.id||"combobox"}-option-${e.activeIndex}`),e.input.setAttribute("aria-activedescendant",i.id)}else e.input.removeAttribute("aria-activedescendant")},s=e=>{e.popover.dataset.empty=String(e.visibleOptions.length===0)},l=(e,{preserveActive:t=!1,search:i}={})=>{const n=e.activeIndex>-1?e.options[e.activeIndex]:null;if(e.visibleOptions=[],e.manualFilter){e.visibleOptions=e.options.filter(o=>o.getAttribute("aria-hidden")!=="true"),t&&n&&e.visibleOptions.includes(n)?O(e,e.options.indexOf(n)):O(e,e.autoHighlight&&e.visibleOptions.length>0?e.options.indexOf(e.visibleOptions[0]):-1),s(e);return}const r=(i??e.input.value).trim().toLowerCase();e.allOptions.forEach(o=>{if(o.hasAttribute("data-force")){o.setAttribute("aria-hidden","false"),e.options.includes(o)&&e.visibleOptions.push(o);return}const a=(o.dataset.filter||o.dataset.label||o.textContent).trim().toLowerCase(),h=(o.dataset.keywords||"").toLowerCase().split(/[\s,]+/).filter(Boolean),y=!r||a.includes(r)||h.some(k=>k.includes(r));o.setAttribute("aria-hidden",String(!y)),y&&e.options.includes(o)&&e.visibleOptions.push(o)}),t&&n&&e.visibleOptions.includes(n)?O(e,e.options.indexOf(n)):O(e,e.autoHighlight&&e.visibleOptions.length>0?e.options.indexOf(e.visibleOptions[0]):-1),s(e)},p=e=>{const t=b.get(e);t.chips&&(t.chips.querySelectorAll(".combobox-chip").forEach(i=>i.remove()),g(t).forEach(i=>{const n=document.createElement("span");n.className="combobox-chip",n.dataset.value=i.value;const r=document.createElement("span");r.textContent=i.label;const o=document.createElement("button");o.type="button",o.className="combobox-chip-remove btn",o.dataset.variant="ghost",o.dataset.size="icon-xs",o.setAttribute("aria-label",`Remove ${i.label}`),o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',o.addEventListener("click",a=>{a.stopPropagation(),e.deselect(i.value),t.input.focus()}),n.appendChild(r),n.appendChild(o),t.chips.insertBefore(n,t.input)}))},f=e=>{if(!e.valueTarget)return;const t=g(e);e.valueTarget.textContent=e.isMultiple?t.map(i=>i.label).join(", "):t[0]?.label||e.valueTarget.dataset.placeholder||""},v=e=>{e.clearButton&&(e.clearButton.hidden=g(e).length===0&&e.input.value==="")},S=e=>{e.options.forEach(t=>{e.selected.has(d(t))?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected")})},C=(e,t,i=!0)=>{const n=b.get(e),r=(Array.isArray(t)?t:[t]).map(w).filter(Boolean);n.selected.clear(),n.isMultiple?(r.forEach(o=>n.selected.set(o.value,o)),n.input.value=""):r[0]?(n.selected.set(r[0].value,r[0]),n.input.value=n.valueTarget?"":r[0].label):n.input.value="",n.hiddenInput.value=D(n),S(n),n.isMultiple&&(p(e),l(n,{preserveActive:!0})),f(n),v(n),i&&e.dispatchEvent(new CustomEvent("change",{detail:{value:L(n),selected:I(n)},bubbles:!0}))},R=(e,t=!1)=>{e.popover.getAttribute("aria-hidden")!=="true"&&(e.popover.setAttribute("aria-hidden","true"),e.input.setAttribute("aria-expanded","false"),e.trigger?.setAttribute("aria-expanded","false"),O(e,-1),t&&(e.skipOpenOnFocus=!0,e.input.focus(),requestAnimationFrame(()=>{e.skipOpenOnFocus=!1})))},M=e=>{const{root:t}=e;if(e.popover.getAttribute("aria-hidden")==="false")return;document.dispatchEvent(new CustomEvent("basecoat:popover",{detail:{source:t}})),t.refresh();const i=g(e)[0];e.valueTarget&&(e.input.value="");const n=!e.isMultiple&&i&&e.input.value===i.label?"":void 0;l(e,{search:n}),e.popover.setAttribute("aria-hidden","false"),e.input.setAttribute("aria-expanded","true"),e.trigger?.setAttribute("aria-expanded","true"),e.trigger&&e.input.focus()},j=e=>{const t=b.get(e);if(!t)return;let i=x(e);if(!i.input||!i.popover||!i.listbox||!i.hiddenInput){const a=[];i.input||a.push("input"),i.popover||a.push("popover"),i.listbox||a.push("listbox"),i.hiddenInput||a.push("hidden input"),console.error(`Combobox refresh failed. Missing element(s): ${a.join(", ")}`,e);return}i=c(e,i);const n=i.hiddenInput.value,r=i.input.value;Object.assign(t,i,B(i.listbox)),t.isMultiple=t.listbox.getAttribute("aria-multiselectable")==="true",t.closeOnSelect=e.dataset.closeOnSelect==="true",t.autoHighlight=e.dataset.autoHighlight==="true",t.manualFilter=e.dataset.filter==="manual",t.format=T(e);const o=N(n,r,t);if(o.length>0)C(e,o,!1);else{const a=t.options.filter(h=>h.getAttribute("aria-selected")==="true").map(A);a.length>0?C(e,t.isMultiple?a:a[0],!1):t.isMultiple?C(e,[],!1):(t.input.value=r,t.selected.clear(),t.hiddenInput.value="",S(t),l(t,{preserveActive:!0}))}f(t),v(t)},V=(e,t)=>{if(t&&typeof t=="object"){const r=w(t);if(!r)return null;const o=e.options.find(a=>d(a)===r.value);return o?A(o):r}const i=e.options.find(r=>d(r)===t);return i?A(i):e.selected.get(String(t))||null},J=(e,t)=>{const i=b.get(e),n=V(i,t);n&&(i.isMultiple?(C(e,[...g(i).filter(r=>r.value!==n.value),n]),i.closeOnSelect&&e.close(!0)):(C(e,n),e.close(!i.trigger),i.trigger?.focus()))},U=(e,t)=>{const i=b.get(e);if(!i.isMultiple)return;const n=String(t);i.selected.has(n)&&C(e,g(i).filter(r=>r.value!==n))},z=e=>{const t=b.get(e);C(e,[],!0),t.input.value="",l(t),v(t),t.popover.getAttribute("aria-hidden")==="false"&&t.input.focus()},K=(e,t)=>{const i=b.get(t);if(!["ArrowDown","ArrowUp","Enter","Home","End","Escape","Backspace"].includes(e.key))return;const n=i.popover.getAttribute("aria-hidden")==="false";if(e.key==="Backspace"&&i.isMultiple&&i.input.value===""){const h=g(i),y=h[h.length-1];y&&t.deselect(y.value);return}if(e.key==="Escape"){n&&(e.preventDefault(),e.stopPropagation(),t.close(!0));return}if(!n&&["ArrowDown","ArrowUp","Home","End"].includes(e.key)&&(e.preventDefault(),M(i)),i.popover.getAttribute("aria-hidden")==="true")return;if(e.key==="Enter"){if(i.activeIndex>-1){e.preventDefault();const h=i.options[i.activeIndex];i.isMultiple?t.toggle(d(h)):t.select(d(h))}return}if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key)||i.visibleOptions.length===0)return;e.preventDefault();const r=i.activeIndex>-1?i.visibleOptions.indexOf(i.options[i.activeIndex]):-1;let o=r;e.key==="ArrowDown"&&(o=Math.min(r+1,i.visibleOptions.length-1)),e.key==="ArrowUp"&&(o=r<=0?0:r-1),e.key==="Home"&&(o=0),e.key==="End"&&(o=i.visibleOptions.length-1);const a=i.visibleOptions[o];O(i,i.options.indexOf(a)),_(i,a)},W=e=>{if(e.dataset.comboboxInitialized)return;const t={root:e,activeIndex:-1,allOptions:[],options:[],visibleOptions:[],selected:new Map,format:"value",manualFilter:!1,skipOpenOnFocus:!1};if(b.set(e,t),e.refresh=()=>j(e),j(e),!t.input||!t.popover||!t.listbox||!t.hiddenInput){b.delete(e),delete e.refresh;return}e.close=(u=!1)=>R(t,u),e.select=u=>J(e,u),e.selectByValue=e.select,e.setValue=u=>{const H=(t.isMultiple?Array.isArray(u)?u:u==null?[]:[u]:[u]).map(P=>V(t,P)||w(P)).filter(Boolean);C(e,t.isMultiple?H:H[0])},t.isMultiple&&(e.deselect=u=>U(e,u),e.toggle=u=>{const m=V(t,u);m&&(t.selected.has(m.value)?e.deselect(m.value):e.select(m))},e.selectAll=()=>C(e,t.options.map(A)),e.selectNone=()=>C(e,[]));const i=()=>{t.skipOpenOnFocus||M(t)},n=()=>M(t),r=()=>{M(t),l(t),t.isMultiple||(t.hiddenInput.value="",t.selected.clear(),S(t),f(t),v(t))},o=()=>{t.popover.getAttribute("aria-hidden")==="false"?e.close(!1):M(t)},a=u=>{u.preventDefault(),u.stopPropagation(),z(e)},h=u=>K(u,e),y=u=>{const m=u.target.closest('[role="option"]');m&&t.visibleOptions.includes(m)&&O(t,t.options.indexOf(m))},k=u=>{const m=u.target.closest('[role="option"]');!m||!t.options.includes(m)||(t.isMultiple?e.toggle(d(m)):e.select(d(m)),t.isMultiple&&!t.closeOnSelect&&t.input.focus())},$=u=>{e.contains(u.target)||e.close(!1)},F=u=>{e.contains(u.detail.source)||e.close(!1)};t.input.addEventListener("focus",i),t.input.addEventListener("click",n),t.input.addEventListener("input",r),t.input.addEventListener("keydown",h),t.trigger?.addEventListener("click",o),t.clearButton?.addEventListener("click",a),t.listbox.addEventListener("mousemove",y),t.listbox.addEventListener("click",k),document.addEventListener("click",$),document.addEventListener("basecoat:popover",F),e._destroy=()=>{t.input.removeEventListener("focus",i),t.input.removeEventListener("click",n),t.input.removeEventListener("input",r),t.input.removeEventListener("keydown",h),t.trigger?.removeEventListener("click",o),t.clearButton?.removeEventListener("click",a),t.listbox.removeEventListener("mousemove",y),t.listbox.removeEventListener("click",k),document.removeEventListener("click",$),document.removeEventListener("basecoat:popover",F),t.chips?.querySelectorAll(".combobox-chip").forEach(u=>u.remove()),b.delete(e),delete e.refresh,delete e.close,delete e.select,delete e.selectByValue,delete e.setValue,delete e.clear,delete e.deselect,delete e.toggle,delete e.selectAll,delete e.selectNone},t.popover.setAttribute("aria-hidden","true"),t.input.setAttribute("aria-expanded","false"),t.trigger?.setAttribute("aria-expanded","false"),e.clear=()=>z(e),Object.defineProperty(e,"value",{configurable:!0,get:()=>L(t),set:u=>e.setValue(u)}),Object.defineProperty(e,"selected",{configurable:!0,get:()=>I(t)}),e.dataset.comboboxInitialized="true",e.dispatchEvent(new CustomEvent("basecoat:initialized"))};window.basecoat&&window.basecoat.register("combobox",{selector:".combobox:not([data-combobox-initialized])",init:W,refresh:j})})(),(()=>{var b=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const c=this.root?this.snapshot():void 0;this.teardown(),this.setup(c)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(c){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=d=>{d.target!==this.root||!this.constructor.relayNative&&!(d instanceof CustomEvent)||(d.stopPropagation(),this._silent||this.emit(d.type,{value:this.value}))};for(const d of this.constructor.relayed)this.root.addEventListener(d,this._relay);this.attach?.(),c!==void 0?this.restore(c):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const c of this.constructor.relayed)this.root.removeEventListener(c,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(c,d)=>d.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const c=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,c!==null&&(this.value=c)}snapshot(){return this.value}restore(c){c!==null&&(this.value=c)}attributeChangedCallback(c,d,E){c==="value"&&this.root&&E!==null&&E!==this.value&&(this.value=E)}defer(c){return this.root?!1:(this._pending=c,!0)}silently(c){this._silent=!0;try{c()}finally{this._silent=!1}}emit(c,d){this.dispatchEvent(new CustomEvent(c,{detail:d,bubbles:!0}))}reportValue(){const c=this.value;JSON.stringify(c)!==JSON.stringify(this._last)&&(this._last=c,this._silent||this.emit("change",{value:c}))}},x=class extends b{static component="combobox";static rootSelector=".combobox";get value(){return this.root?this.root.value:null}set value(c){this.defer(c)||this.root.setValue&&this.silently(()=>this.root.setValue(c))}};customElements.get("auvyx-combobox")||customElements.define("auvyx-combobox",x)})();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const l={};let h=null;const n=(t,o,r)=>{const d=typeof o=="object"?o:{selector:o,init:r};l[t]={selector:d.selector,init:d.init,refresh:d.refresh}},a=(t,o)=>{const r=l[o];if(r)try{r.init(t),t.hasAttribute(`data-${o}-initialized`)&&(t.dataset.basecoatComponent=o)}catch(d){if(console.error(`Failed to initialize ${o}:`,d),typeof t._destroy=="function")try{t._destroy()}catch(m){console.error(`Failed to clean up ${o} after initialization error:`,m)}delete t._destroy,t.removeAttribute(`data-${o}-initialized`),delete t.dataset.basecoatComponent}},u=t=>{if(!t||t.nodeType!==Node.ELEMENT_NODE)return;const o=t.dataset?.basecoatComponent;if(typeof t._destroy=="function")try{t._destroy()}catch(r){console.error("Failed to destroy Basecoat component:",r)}delete t._destroy,o&&t.removeAttribute(`data-${o}-initialized`),delete t.dataset.basecoatComponent},f=t=>{t.nodeType===Node.ELEMENT_NODE&&(t.isConnected||(t.dataset?.basecoatComponent&&u(t),t.querySelectorAll("[data-basecoat-component]").forEach(u)))},g=t=>Array.from(new Set(t)),y=(t,o,r=!1)=>{const d=Array.from(document.querySelectorAll(o));return r&&d.push(...document.querySelectorAll(`[data-basecoat-component="${t}"]`)),g(d)},E=(t={})=>{const o=t.force===!0;Object.entries(l).forEach(([r,{selector:d}])=>{y(r,d,o).forEach(m=>{const C=m.dataset?.basecoatComponent===r;o&&u(m),(C||m.matches(d))&&a(m,r)})})},I=t=>{t.nodeType===Node.ELEMENT_NODE&&Object.entries(l).forEach(([o,{selector:r}])=>{t.matches(r)&&a(t,o),t.querySelectorAll(r).forEach(d=>a(d,o))})},e=t=>{if(!t)return;if(typeof t.refresh=="function"){t.refresh();return}const o=t.dataset?.basecoatComponent,r=o?l[o]:null;r?.refresh&&r.refresh(t)},i=()=>{h||(h=new MutationObserver(t=>{t.forEach(o=>{o.addedNodes.forEach(I),o.removedNodes.forEach(f)})}),h.observe(document.body,{childList:!0,subtree:!0}))},s=()=>{h&&(h.disconnect(),h=null)},c=(t,o={})=>{const r=l[t];if(!r){console.warn(`Component '${t}' not found in registry`);return}const d=o.force===!0;y(t,r.selector,d).forEach(m=>{const C=m.dataset?.basecoatComponent===t;d&&u(m),(C||m.matches(r.selector))&&a(m,t)})},p=(t={})=>{E(t)},b=t=>{const o=t==="dark";document.documentElement.classList.toggle("dark",o);try{localStorage.setItem("themeMode",o?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:o?"dark":"light"}}))},v=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:n,init:c,initAll:p,refresh:e,start:i,stop:s,theme:{get:v,set:b,toggle:()=>b(v()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{E(),i()})})(),(()=>{const l=new WeakMap,h=e=>e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"||e.getAttribute("data-disabled")==="true",n=e=>({input:e.querySelector("header input"),menu:e.querySelector('[role="menu"]')}),a=e=>{const i=Array.from(e.querySelectorAll('[role="menuitem"]'));return{allItems:i,items:i.filter(s=>!h(s))}},u=(e,i)=>{const s=i.getBoundingClientRect(),c=e.menu.getBoundingClientRect();s.top<c.top?e.menu.scrollTop-=c.top-s.top:s.bottom>c.bottom&&(e.menu.scrollTop+=s.bottom-c.bottom)},f=(e,i)=>{if(e.activeIndex>-1&&e.items[e.activeIndex]&&e.items[e.activeIndex].classList.remove("active"),e.activeIndex=i,e.activeIndex>-1){const s=e.items[e.activeIndex];s.classList.add("active"),s.id?e.input.setAttribute("aria-activedescendant",s.id):e.input.removeAttribute("aria-activedescendant")}else e.input.removeAttribute("aria-activedescendant")},g=e=>{if(e.manualFilter){f(e,-1),e.visibleItems=e.items.filter(s=>s.getAttribute("aria-hidden")!=="true"),e.visibleItems.length>0&&f(e,e.items.indexOf(e.visibleItems[0]));return}const i=e.input.value.trim().toLowerCase();f(e,-1),e.visibleItems=[],e.allItems.forEach(s=>{if(s.hasAttribute("data-force")){s.setAttribute("aria-hidden","false"),e.items.includes(s)&&e.visibleItems.push(s);return}const c=(s.dataset.filter||s.textContent).trim().toLowerCase(),b=(s.dataset.keywords||"").toLowerCase().split(/[\s,]+/).filter(Boolean).some(t=>t.includes(i)),v=c.includes(i)||b;s.setAttribute("aria-hidden",String(!v)),v&&e.items.includes(s)&&e.visibleItems.push(s)}),e.visibleItems.length>0&&(f(e,e.items.indexOf(e.visibleItems[0])),u(e,e.visibleItems[0]))},y=e=>{const i=l.get(e);if(!i)return;const s=n(e);if(!s.input||!s.menu){const c=[];s.input||c.push("input"),s.menu||c.push("menu"),console.error(`Command component refresh failed. Missing element(s): ${c.join(", ")}`,e);return}Object.assign(i,s,a(s.menu)),i.manualFilter=e.dataset.filter==="manual",g(i)},E=(e,i)=>{if(!["ArrowDown","ArrowUp","Enter","Home","End"].includes(e.key))return;if(e.key==="Enter"){e.preventDefault(),i.activeIndex>-1&&i.items[i.activeIndex]?.click();return}if(i.visibleItems.length===0)return;e.preventDefault();const s=i.activeIndex>-1?i.visibleItems.indexOf(i.items[i.activeIndex]):-1;let c=s;if(e.key==="ArrowDown"&&s<i.visibleItems.length-1&&(c=s+1),e.key==="ArrowUp"&&(c=s>0?s-1:0),e.key==="Home"&&(c=0),e.key==="End"&&(c=i.visibleItems.length-1),c!==s){const p=i.visibleItems[c];f(i,i.items.indexOf(p)),u(i,p)}},I=e=>{if(e.dataset.commandInitialized)return;const i={activeIndex:-1,allItems:[],items:[],visibleItems:[],manualFilter:!1};l.set(e,i),e.refresh=()=>y(e);const s=n(e);if(!s.input||!s.menu){const t=[];s.input||t.push("input"),s.menu||t.push("menu"),console.error(`Command component initialization failed. Missing element(s): ${t.join(", ")}`,e),l.delete(e),delete e.refresh;return}Object.assign(i,s);const c=()=>g(i),p=t=>E(t,i),b=t=>{const o=t.target.closest('[role="menuitem"]');if(o&&i.visibleItems.includes(o)){const r=i.items.indexOf(o);r!==i.activeIndex&&f(i,r)}},v=t=>{const o=t.target.closest('[role="menuitem"]');if(o&&i.visibleItems.includes(o)){const r=e.closest("dialog.command-dialog");r&&!o.hasAttribute("data-keep-command-open")&&r.close()}};i.input.addEventListener("input",c),i.input.addEventListener("keydown",p),i.menu.addEventListener("mousemove",b),i.menu.addEventListener("click",v),e._destroy=()=>{i.input.removeEventListener("input",c),i.input.removeEventListener("keydown",p),i.menu.removeEventListener("mousemove",b),i.menu.removeEventListener("click",v),l.delete(e),delete e.refresh},y(e),e.dataset.commandInitialized="true",e.dispatchEvent(new CustomEvent("basecoat:initialized"))};window.basecoat&&window.basecoat.register("command",{selector:".command:not([data-command-initialized])",init:I,refresh:y})})(),(()=>{var l=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const n=this.root?this.snapshot():void 0;this.teardown(),this.setup(n)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(n){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=a=>{a.target!==this.root||!this.constructor.relayNative&&!(a instanceof CustomEvent)||(a.stopPropagation(),this._silent||this.emit(a.type,{value:this.value}))};for(const a of this.constructor.relayed)this.root.addEventListener(a,this._relay);this.attach?.(),n!==void 0?this.restore(n):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const n of this.constructor.relayed)this.root.removeEventListener(n,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(n,a)=>a.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const n=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,n!==null&&(this.value=n)}snapshot(){return this.value}restore(n){n!==null&&(this.value=n)}attributeChangedCallback(n,a,u){n==="value"&&this.root&&u!==null&&u!==this.value&&(this.value=u)}defer(n){return this.root?!1:(this._pending=n,!0)}silently(n){this._silent=!0;try{n()}finally{this._silent=!1}}emit(n,a){this.dispatchEvent(new CustomEvent(n,{detail:a,bubbles:!0}))}reportValue(){const n=this.value;JSON.stringify(n)!==JSON.stringify(this._last)&&(this._last=n,this._silent||this.emit("change",{value:n}))}},h=class extends l{static component="command";static rootSelector=".command";static relayed=[];static observedAttributes=[];attach(){this._onClick=n=>{const a=n.target.closest('[role="menuitem"]');!a||!this.root.contains(a)||a.matches('[aria-disabled="true"], [data-disabled="true"], [disabled]')||this.emit("select",{value:a.dataset.value??a.textContent.trim()})},this.root.addEventListener("click",this._onClick)}detach(){this.root?.removeEventListener("click",this._onClick)}applyInitial(){}restore(){}get value(){return null}};customElements.get("auvyx-command")||customElements.define("auvyx-command",h)})();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const l={};let h=null;const f=(e,s,i)=>{const a=typeof s=="object"?s:{selector:s,init:i};l[e]={selector:a.selector,init:a.init,refresh:a.refresh}},o=(e,s)=>{const i=l[s];if(i)try{i.init(e),e.hasAttribute(`data-${s}-initialized`)&&(e.dataset.basecoatComponent=s)}catch(a){if(console.error(`Failed to initialize ${s}:`,a),typeof e._destroy=="function")try{e._destroy()}catch(d){console.error(`Failed to clean up ${s} after initialization error:`,d)}delete e._destroy,e.removeAttribute(`data-${s}-initialized`),delete e.dataset.basecoatComponent}},t=e=>{if(!e||e.nodeType!==Node.ELEMENT_NODE)return;const s=e.dataset?.basecoatComponent;if(typeof e._destroy=="function")try{e._destroy()}catch(i){console.error("Failed to destroy Basecoat component:",i)}delete e._destroy,s&&e.removeAttribute(`data-${s}-initialized`),delete e.dataset.basecoatComponent},n=e=>{e.nodeType===Node.ELEMENT_NODE&&(e.isConnected||(e.dataset?.basecoatComponent&&t(e),e.querySelectorAll("[data-basecoat-component]").forEach(t)))},r=e=>Array.from(new Set(e)),p=(e,s,i=!1)=>{const a=Array.from(document.querySelectorAll(s));return i&&a.push(...document.querySelectorAll(`[data-basecoat-component="${e}"]`)),r(a)},u=(e={})=>{const s=e.force===!0;Object.entries(l).forEach(([i,{selector:a}])=>{p(i,a,s).forEach(d=>{const g=d.dataset?.basecoatComponent===i;s&&t(d),(g||d.matches(a))&&o(d,i)})})},v=e=>{e.nodeType===Node.ELEMENT_NODE&&Object.entries(l).forEach(([s,{selector:i}])=>{e.matches(i)&&o(e,s),e.querySelectorAll(i).forEach(a=>o(a,s))})},y=e=>{if(!e)return;if(typeof e.refresh=="function"){e.refresh();return}const s=e.dataset?.basecoatComponent,i=s?l[s]:null;i?.refresh&&i.refresh(e)},c=()=>{h||(h=new MutationObserver(e=>{e.forEach(s=>{s.addedNodes.forEach(v),s.removedNodes.forEach(n)})}),h.observe(document.body,{childList:!0,subtree:!0}))},b=()=>{h&&(h.disconnect(),h=null)},m=(e,s={})=>{const i=l[e];if(!i){console.warn(`Component '${e}' not found in registry`);return}const a=s.force===!0;p(e,i.selector,a).forEach(d=>{const g=d.dataset?.basecoatComponent===e;a&&t(d),(g||d.matches(i.selector))&&o(d,e)})},_=(e={})=>{u(e)},E=e=>{const s=e==="dark";document.documentElement.classList.toggle("dark",s);try{localStorage.setItem("themeMode",s?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:s?"dark":"light"}}))},C=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:f,init:m,initAll:_,refresh:y,start:c,stop:b,theme:{get:C,set:E,toggle:()=>E(C()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{u(),c()})})(),(()=>{const l=o=>{if(!o)return 0;const t=o.trim();return t.endsWith("ms")?parseFloat(t)||0:t.endsWith("s")?(parseFloat(t)||0)*1e3:parseFloat(t)||0},h=o=>{if(!o)return 0;const t=getComputedStyle(o),n=t.transitionDuration.split(",").map(l),r=t.transitionDelay.split(",").map(l);return Math.max(0,...n.map((p,u)=>p+(r[u]||r[0]||0)))},f=o=>{if(o.dataset.drawerInitialized)return;const t=o.close.bind(o);let n=!1,r=null;const p=c=>{window.clearTimeout(r),r=null,o.removeAttribute("data-closing"),t(c)};o.close=(c="")=>{if(!o.open||o.dataset.closing)return;const b=o.firstElementChild,m=h(b);if(m===0||window.matchMedia("(prefers-reduced-motion: reduce)").matches){p(c);return}o.dataset.closing="true",r=window.setTimeout(()=>p(c),m+50)};const u=c=>{c.preventDefault(),o.close()},v=c=>{n=c.target===o},y=c=>{n&&c.target===o&&o.close(),n=!1};o.addEventListener("cancel",u),o.addEventListener("pointerdown",v),o.addEventListener("pointerup",y),o._destroy=()=>{window.clearTimeout(r),o.removeEventListener("cancel",u),o.removeEventListener("pointerdown",v),o.removeEventListener("pointerup",y),o.close=t,delete o._destroy},o.dataset.drawerInitialized="true",o.dispatchEvent(new CustomEvent("basecoat:initialized"))};window.basecoat&&window.basecoat.register("drawer",".drawer:not([data-drawer-initialized])",f)})(),(()=>{var l=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const t=this.root?this.snapshot():void 0;this.teardown(),this.setup(t)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(t){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=n=>{n.target!==this.root||!this.constructor.relayNative&&!(n instanceof CustomEvent)||(n.stopPropagation(),this._silent||this.emit(n.type,{value:this.value}))};for(const n of this.constructor.relayed)this.root.addEventListener(n,this._relay);this.attach?.(),t!==void 0?this.restore(t):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const t of this.constructor.relayed)this.root.removeEventListener(t,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(t,n)=>n.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const t=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,t!==null&&(this.value=t)}snapshot(){return this.value}restore(t){t!==null&&(this.value=t)}attributeChangedCallback(t,n,r){t==="value"&&this.root&&r!==null&&r!==this.value&&(this.value=r)}defer(t){return this.root?!1:(this._pending=t,!0)}silently(t){this._silent=!0;try{t()}finally{this._silent=!1}}emit(t,n){this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0}))}reportValue(){const t=this.value;JSON.stringify(t)!==JSON.stringify(this._last)&&(this._last=t,this._silent||this.emit("change",{value:t}))}},h=class extends l{static observedAttributes=["open"];static relayed=[];applyInitial(){const t=this._pending!==void 0?this._pending:this.hasAttribute("open")||null;this._pending=void 0,this._lastOpen=this.isOpen(),t!==null&&!!t!==this._lastOpen&&(this.open=t)}attributeChangedCallback(t,n,r){t==="open"&&this.root&&(this.open=r!==null)}snapshot(){return this.isOpen()}restore(t){this._lastOpen=this.isOpen(),this.open=t}get open(){return this.root?this.isOpen():!!this._pending}set open(t){this.defer(!!t)||!!t!==this.isOpen()&&this.setOpen(!!t)}reportOpen(){const t=this.isOpen();t!==this._lastOpen&&(this._lastOpen=t,this.emit("toggle",{open:t}))}};function f(t,n,r,p=!0){const u=new MutationObserver(r);return u.observe(t,{attributes:!0,attributeFilter:n,subtree:p}),()=>u.disconnect()}var o=class extends h{static component="drawer";static rootSelector="dialog.drawer";attach(){this._unwatch=f(this.root,["open"],()=>this.reportOpen(),!1)}detach(){this._unwatch?.()}isOpen(){return!!this.root?.open}setOpen(t){t?this.root.showModal():this.root.close()}};customElements.get("auvyx-drawer")||customElements.define("auvyx-drawer",o)})();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const l={};let u=null;const g=(r,i,s)=>{const a=typeof i=="object"?i:{selector:i,init:s};l[r]={selector:a.selector,init:a.init,refresh:a.refresh}},v=(r,i)=>{const s=l[i];if(s)try{s.init(r),r.hasAttribute(`data-${i}-initialized`)&&(r.dataset.basecoatComponent=i)}catch(a){if(console.error(`Failed to initialize ${i}:`,a),typeof r._destroy=="function")try{r._destroy()}catch(d){console.error(`Failed to clean up ${i} after initialization error:`,d)}delete r._destroy,r.removeAttribute(`data-${i}-initialized`),delete r.dataset.basecoatComponent}},h=r=>{if(!r||r.nodeType!==Node.ELEMENT_NODE)return;const i=r.dataset?.basecoatComponent;if(typeof r._destroy=="function")try{r._destroy()}catch(s){console.error("Failed to destroy Basecoat component:",s)}delete r._destroy,i&&r.removeAttribute(`data-${i}-initialized`),delete r.dataset.basecoatComponent},t=r=>{r.nodeType===Node.ELEMENT_NODE&&(r.isConnected||(r.dataset?.basecoatComponent&&h(r),r.querySelectorAll("[data-basecoat-component]").forEach(h)))},o=r=>Array.from(new Set(r)),p=(r,i,s=!1)=>{const a=Array.from(document.querySelectorAll(i));return s&&a.push(...document.querySelectorAll(`[data-basecoat-component="${r}"]`)),o(a)},m=(r={})=>{const i=r.force===!0;Object.entries(l).forEach(([s,{selector:a}])=>{p(s,a,i).forEach(d=>{const A=d.dataset?.basecoatComponent===s;i&&h(d),(A||d.matches(a))&&v(d,s)})})},e=r=>{r.nodeType===Node.ELEMENT_NODE&&Object.entries(l).forEach(([i,{selector:s}])=>{r.matches(s)&&v(r,i),r.querySelectorAll(s).forEach(a=>v(a,i))})},n=r=>{if(!r)return;if(typeof r.refresh=="function"){r.refresh();return}const i=r.dataset?.basecoatComponent,s=i?l[i]:null;s?.refresh&&s.refresh(r)},c=()=>{u||(u=new MutationObserver(r=>{r.forEach(i=>{i.addedNodes.forEach(e),i.removedNodes.forEach(t)})}),u.observe(document.body,{childList:!0,subtree:!0}))},f=()=>{u&&(u.disconnect(),u=null)},E=(r,i={})=>{const s=l[r];if(!s){console.warn(`Component '${r}' not found in registry`);return}const a=i.force===!0;p(r,s.selector,a).forEach(d=>{const A=d.dataset?.basecoatComponent===r;a&&h(d),(A||d.matches(s.selector))&&v(d,r)})},w=(r={})=>{m(r)},b=r=>{const i=r==="dark";document.documentElement.classList.toggle("dark",i);try{localStorage.setItem("themeMode",i?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:i?"dark":"light"}}))},y=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:g,init:E,initAll:w,refresh:n,start:c,stop:f,theme:{get:y,set:b,toggle:()=>b(y()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{m(),c()})})(),(()=>{const l=new WeakMap,u=e=>e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true",g=e=>{const n=e.querySelector(":scope > button"),c=e.querySelector(":scope > [data-popover]"),f=c?c.querySelector('[role="menu"]'):null;return{trigger:n,popover:c,menu:f}},v=e=>Array.from(e.querySelectorAll('[role^="menuitem"]')).filter(n=>!u(n)),h=(e,n)=>{if(e.activeIndex>-1&&e.items[e.activeIndex]&&e.items[e.activeIndex].classList.remove("active"),e.activeIndex=n,e.activeIndex>-1&&e.items[e.activeIndex]){const c=e.items[e.activeIndex];c.classList.add("active"),c.id&&e.trigger.setAttribute("aria-activedescendant",c.id)}else e.trigger.removeAttribute("aria-activedescendant")},t=e=>{const n=l.get(e);if(!n)return;const c=g(e);if(!c.trigger||!c.popover||!c.menu){const f=[];c.trigger||f.push("trigger"),c.popover||f.push("popover"),c.menu||f.push("menu"),console.error(`Dropdown menu refresh failed. Missing element(s): ${f.join(", ")}`,e);return}Object.assign(n,c),n.items=v(n.menu),n.activeIndex>-1&&!n.items[n.activeIndex]&&h(n,-1)},o=(e,n=!0)=>{e.trigger.getAttribute("aria-expanded")!=="false"&&(e.trigger.setAttribute("aria-expanded","false"),e.trigger.removeAttribute("aria-activedescendant"),e.popover.setAttribute("aria-hidden","true"),n&&e.trigger.focus(),h(e,-1))},p=(e,n,c=!1)=>{document.dispatchEvent(new CustomEvent("basecoat:popover",{detail:{source:e}})),e.refresh(),n.trigger.setAttribute("aria-expanded","true"),n.popover.setAttribute("aria-hidden","false"),n.items.length>0&&c&&h(n,c==="last"?n.items.length-1:0)},m=e=>{if(e.dataset.dropdownMenuInitialized)return;const n={activeIndex:-1,items:[]};if(l.set(e,n),e.refresh=()=>t(e),t(e),!n.trigger||!n.popover||!n.menu){l.delete(e),delete e.refresh;return}e.open=(i=!1)=>p(e,n,i),e.close=(i=!0)=>o(n,i),e.toggle=()=>n.trigger.getAttribute("aria-expanded")==="true"?e.close():e.open(!1);const c=e.toggle,f=i=>{const s=n.trigger.getAttribute("aria-expanded")==="true";if(i.key==="Escape"){s&&e.close();return}if(!s){["Enter"," "].includes(i.key)?(i.preventDefault(),e.open(!1)):i.key==="ArrowDown"?(i.preventDefault(),e.open("first")):i.key==="ArrowUp"&&(i.preventDefault(),e.open("last"));return}if(n.items.length===0)return;let a=n.activeIndex;if(i.key==="ArrowDown")i.preventDefault(),a=n.activeIndex===-1?0:Math.min(n.activeIndex+1,n.items.length-1);else if(i.key==="ArrowUp")i.preventDefault(),a=n.activeIndex===-1?n.items.length-1:Math.max(n.activeIndex-1,0);else if(i.key==="Home")i.preventDefault(),a=0;else if(i.key==="End")i.preventDefault(),a=n.items.length-1;else if(["Enter"," "].includes(i.key)){i.preventDefault(),n.items[n.activeIndex]?.click(),e.close();return}else return;a!==n.activeIndex&&h(n,a)},E=i=>{const s=i.target.closest('[role^="menuitem"]');if(s&&!u(s)&&n.items.includes(s)){const a=n.items.indexOf(s);a!==n.activeIndex&&h(n,a)}},w=()=>h(n,-1),b=i=>{const s=i.target.closest('[role^="menuitem"]');!s||u(s)||(s.getAttribute("role")==="menuitemcheckbox"?s.setAttribute("aria-checked",s.getAttribute("aria-checked")!=="true"):s.getAttribute("role")==="menuitemradio"&&s.closest('[role="group"], [role="menu"]')?.querySelectorAll('[role="menuitemradio"]').forEach(d=>{u(d)||d.setAttribute("aria-checked",d===s?"true":"false")}),e.close())},y=i=>{e.contains(i.target)||e.close(!1)},r=i=>{e.contains(i.detail.source)||e.close(!1)};n.trigger.addEventListener("click",c),e.addEventListener("keydown",f),n.menu.addEventListener("mousemove",E),n.menu.addEventListener("mouseleave",w),n.menu.addEventListener("click",b),document.addEventListener("click",y),document.addEventListener("basecoat:popover",r),e._destroy=()=>{n.trigger.removeEventListener("click",c),e.removeEventListener("keydown",f),n.menu.removeEventListener("mousemove",E),n.menu.removeEventListener("mouseleave",w),n.menu.removeEventListener("click",b),document.removeEventListener("click",y),document.removeEventListener("basecoat:popover",r),l.delete(e),delete e.refresh,delete e.open,delete e.close,delete e.toggle},n.trigger.setAttribute("aria-expanded","false"),n.popover.setAttribute("aria-hidden","true"),e.dataset.dropdownMenuInitialized="true",e.dispatchEvent(new CustomEvent("basecoat:initialized"))};window.basecoat&&window.basecoat.register("dropdown-menu",{selector:".dropdown-menu:not([data-dropdown-menu-initialized]):not(:has(> [data-popover][popover]))",init:m,refresh:t})})(),(()=>{var l=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const t=this.root?this.snapshot():void 0;this.teardown(),this.setup(t)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(t){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=o=>{o.target!==this.root||!this.constructor.relayNative&&!(o instanceof CustomEvent)||(o.stopPropagation(),this._silent||this.emit(o.type,{value:this.value}))};for(const o of this.constructor.relayed)this.root.addEventListener(o,this._relay);this.attach?.(),t!==void 0?this.restore(t):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const t of this.constructor.relayed)this.root.removeEventListener(t,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(t,o)=>o.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const t=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,t!==null&&(this.value=t)}snapshot(){return this.value}restore(t){t!==null&&(this.value=t)}attributeChangedCallback(t,o,p){t==="value"&&this.root&&p!==null&&p!==this.value&&(this.value=p)}defer(t){return this.root?!1:(this._pending=t,!0)}silently(t){this._silent=!0;try{t()}finally{this._silent=!1}}emit(t,o){this.dispatchEvent(new CustomEvent(t,{detail:o,bubbles:!0}))}reportValue(){const t=this.value;JSON.stringify(t)!==JSON.stringify(this._last)&&(this._last=t,this._silent||this.emit("change",{value:t}))}},u=class extends l{static observedAttributes=["open"];static relayed=[];applyInitial(){const t=this._pending!==void 0?this._pending:this.hasAttribute("open")||null;this._pending=void 0,this._lastOpen=this.isOpen(),t!==null&&!!t!==this._lastOpen&&(this.open=t)}attributeChangedCallback(t,o,p){t==="open"&&this.root&&(this.open=p!==null)}snapshot(){return this.isOpen()}restore(t){this._lastOpen=this.isOpen(),this.open=t}get open(){return this.root?this.isOpen():!!this._pending}set open(t){this.defer(!!t)||!!t!==this.isOpen()&&this.setOpen(!!t)}reportOpen(){const t=this.isOpen();t!==this._lastOpen&&(this._lastOpen=t,this.emit("toggle",{open:t}))}};function g(t,o,p,m=!0){const e=new MutationObserver(p);return e.observe(t,{attributes:!0,attributeFilter:o,subtree:m}),()=>e.disconnect()}var v=class extends u{get trigger(){return this.root?.querySelector(":scope > button")}get nativePanel(){return this.root?.querySelector(":scope > [data-popover][popover]")}attach(){const t=this.nativePanel;t?(this._onToggle=()=>this.reportOpen(),t.addEventListener("toggle",this._onToggle),this._unwatch=()=>t.removeEventListener("toggle",this._onToggle)):this._unwatch=g(this.trigger,["aria-expanded"],()=>this.reportOpen(),!1)}detach(){this._unwatch?.()}isOpen(){const t=this.nativePanel;return t?t.matches(":popover-open"):this.trigger?.getAttribute("aria-expanded")==="true"}setOpen(t){const o=this.nativePanel;if(o)return t?o.showPopover():o.hidePopover();this.setOpenJs(t)}},h=class extends v{static component="dropdown-menu";static rootSelector=".dropdown-menu";attach(){super.attach(),this._onClick=t=>{const o=t.target.closest('[role^="menuitem"]');!o||!this.root.contains(o)||o.matches('[aria-disabled="true"], :disabled')||this.emit("select",{value:o.dataset.value??o.textContent.trim()})},this.root.addEventListener("click",this._onClick)}detach(){super.detach(),this.root?.removeEventListener("click",this._onClick)}setOpenJs(t){t?this.root.open?.():this.root.close?.()}};customElements.get("auvyx-dropdown-menu")||customElements.define("auvyx-dropdown-menu",h)})();
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tabs": {
|
|
3
|
+
"file": "wc/tabs.min.js",
|
|
4
|
+
"tag": "auvyx-tabs",
|
|
5
|
+
"api": {
|
|
6
|
+
"props": {
|
|
7
|
+
"value": "The selected tab's data-value or id"
|
|
8
|
+
},
|
|
9
|
+
"events": {
|
|
10
|
+
"change": "The user selected a tab"
|
|
11
|
+
},
|
|
12
|
+
"methods": {}
|
|
13
|
+
},
|
|
14
|
+
"gzip": 2732
|
|
15
|
+
},
|
|
16
|
+
"select": {
|
|
17
|
+
"file": "wc/select.min.js",
|
|
18
|
+
"tag": "auvyx-select",
|
|
19
|
+
"api": {
|
|
20
|
+
"props": {
|
|
21
|
+
"value": "The selected option's data-value (an array when multiple)"
|
|
22
|
+
},
|
|
23
|
+
"events": {
|
|
24
|
+
"change": "The user picked an option"
|
|
25
|
+
},
|
|
26
|
+
"methods": {}
|
|
27
|
+
},
|
|
28
|
+
"gzip": 4499
|
|
29
|
+
},
|
|
30
|
+
"combobox": {
|
|
31
|
+
"file": "wc/combobox.min.js",
|
|
32
|
+
"tag": "auvyx-combobox",
|
|
33
|
+
"api": {
|
|
34
|
+
"props": {
|
|
35
|
+
"value": "The selected option's data-value (an array when multiple)"
|
|
36
|
+
},
|
|
37
|
+
"events": {
|
|
38
|
+
"change": "The user picked an option"
|
|
39
|
+
},
|
|
40
|
+
"methods": {}
|
|
41
|
+
},
|
|
42
|
+
"gzip": 5617
|
|
43
|
+
},
|
|
44
|
+
"command": {
|
|
45
|
+
"file": "wc/command.min.js",
|
|
46
|
+
"tag": "auvyx-command",
|
|
47
|
+
"api": {
|
|
48
|
+
"props": {},
|
|
49
|
+
"events": {
|
|
50
|
+
"select": "The user activated an item; detail.value is its data-value or text"
|
|
51
|
+
},
|
|
52
|
+
"methods": {}
|
|
53
|
+
},
|
|
54
|
+
"gzip": 3163
|
|
55
|
+
},
|
|
56
|
+
"dropdown-menu": {
|
|
57
|
+
"file": "wc/dropdown-menu.min.js",
|
|
58
|
+
"tag": "auvyx-dropdown-menu",
|
|
59
|
+
"api": {
|
|
60
|
+
"props": {
|
|
61
|
+
"open": "Whether the menu is shown"
|
|
62
|
+
},
|
|
63
|
+
"events": {
|
|
64
|
+
"toggle": "The menu opened or closed",
|
|
65
|
+
"select": "The user activated an item; detail.value is its data-value or text"
|
|
66
|
+
},
|
|
67
|
+
"methods": {}
|
|
68
|
+
},
|
|
69
|
+
"gzip": 3559
|
|
70
|
+
},
|
|
71
|
+
"popover": {
|
|
72
|
+
"file": "wc/popover.min.js",
|
|
73
|
+
"tag": "auvyx-popover",
|
|
74
|
+
"api": {
|
|
75
|
+
"props": {
|
|
76
|
+
"open": "Whether the panel is shown"
|
|
77
|
+
},
|
|
78
|
+
"events": {
|
|
79
|
+
"toggle": "The panel opened or closed"
|
|
80
|
+
},
|
|
81
|
+
"methods": {}
|
|
82
|
+
},
|
|
83
|
+
"gzip": 2644
|
|
84
|
+
},
|
|
85
|
+
"accordion": {
|
|
86
|
+
"file": "wc/accordion.min.js",
|
|
87
|
+
"tag": "auvyx-accordion",
|
|
88
|
+
"api": {
|
|
89
|
+
"props": {
|
|
90
|
+
"value": "The open item's data-value, id or position (an array with data-multiple)"
|
|
91
|
+
},
|
|
92
|
+
"events": {
|
|
93
|
+
"change": "The user opened or closed an item"
|
|
94
|
+
},
|
|
95
|
+
"methods": {}
|
|
96
|
+
},
|
|
97
|
+
"gzip": 2498
|
|
98
|
+
},
|
|
99
|
+
"sidebar": {
|
|
100
|
+
"file": "wc/sidebar.min.js",
|
|
101
|
+
"tag": "auvyx-sidebar",
|
|
102
|
+
"api": {
|
|
103
|
+
"props": {
|
|
104
|
+
"open": "Whether the sidebar is expanded"
|
|
105
|
+
},
|
|
106
|
+
"events": {
|
|
107
|
+
"toggle": "The sidebar expanded or collapsed"
|
|
108
|
+
},
|
|
109
|
+
"methods": {}
|
|
110
|
+
},
|
|
111
|
+
"gzip": 2799
|
|
112
|
+
},
|
|
113
|
+
"toast": {
|
|
114
|
+
"file": "wc/toast.min.js",
|
|
115
|
+
"tag": "auvyx-toaster",
|
|
116
|
+
"api": {
|
|
117
|
+
"props": {},
|
|
118
|
+
"events": {},
|
|
119
|
+
"methods": {
|
|
120
|
+
"toast(options: AuvyxToastOptions)": "Show a toast; same options as the HTML edition"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"gzip": 3359
|
|
124
|
+
},
|
|
125
|
+
"slider": {
|
|
126
|
+
"file": "wc/slider.min.js",
|
|
127
|
+
"tag": "auvyx-slider",
|
|
128
|
+
"api": {
|
|
129
|
+
"props": {
|
|
130
|
+
"value": "The input's value"
|
|
131
|
+
},
|
|
132
|
+
"events": {
|
|
133
|
+
"input": "The value is changing",
|
|
134
|
+
"change": "The user finished changing it"
|
|
135
|
+
},
|
|
136
|
+
"methods": {}
|
|
137
|
+
},
|
|
138
|
+
"gzip": 2128
|
|
139
|
+
},
|
|
140
|
+
"drawer": {
|
|
141
|
+
"file": "wc/drawer.min.js",
|
|
142
|
+
"tag": "auvyx-drawer",
|
|
143
|
+
"api": {
|
|
144
|
+
"props": {
|
|
145
|
+
"open": "Whether the drawer is shown"
|
|
146
|
+
},
|
|
147
|
+
"events": {
|
|
148
|
+
"toggle": "The drawer opened or closed"
|
|
149
|
+
},
|
|
150
|
+
"methods": {}
|
|
151
|
+
},
|
|
152
|
+
"gzip": 2586
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const p={};let r=null;const c=(e,o,i)=>{const a=typeof o=="object"?o:{selector:o,init:i};p[e]={selector:a.selector,init:a.init,refresh:a.refresh}},d=(e,o)=>{const i=p[o];if(i)try{i.init(e),e.hasAttribute(`data-${o}-initialized`)&&(e.dataset.basecoatComponent=o)}catch(a){if(console.error(`Failed to initialize ${o}:`,a),typeof e._destroy=="function")try{e._destroy()}catch(u){console.error(`Failed to clean up ${o} after initialization error:`,u)}delete e._destroy,e.removeAttribute(`data-${o}-initialized`),delete e.dataset.basecoatComponent}},h=e=>{if(!e||e.nodeType!==Node.ELEMENT_NODE)return;const o=e.dataset?.basecoatComponent;if(typeof e._destroy=="function")try{e._destroy()}catch(i){console.error("Failed to destroy Basecoat component:",i)}delete e._destroy,o&&e.removeAttribute(`data-${o}-initialized`),delete e.dataset.basecoatComponent},t=e=>{e.nodeType===Node.ELEMENT_NODE&&(e.isConnected||(e.dataset?.basecoatComponent&&h(e),e.querySelectorAll("[data-basecoat-component]").forEach(h)))},s=e=>Array.from(new Set(e)),l=(e,o,i=!1)=>{const a=Array.from(document.querySelectorAll(o));return i&&a.push(...document.querySelectorAll(`[data-basecoat-component="${e}"]`)),s(a)},f=(e={})=>{const o=e.force===!0;Object.entries(p).forEach(([i,{selector:a}])=>{l(i,a,o).forEach(u=>{const g=u.dataset?.basecoatComponent===i;o&&h(u),(g||u.matches(a))&&d(u,i)})})},v=e=>{e.nodeType===Node.ELEMENT_NODE&&Object.entries(p).forEach(([o,{selector:i}])=>{e.matches(i)&&d(e,o),e.querySelectorAll(i).forEach(a=>d(a,o))})},n=e=>{if(!e)return;if(typeof e.refresh=="function"){e.refresh();return}const o=e.dataset?.basecoatComponent,i=o?p[o]:null;i?.refresh&&i.refresh(e)},y=()=>{r||(r=new MutationObserver(e=>{e.forEach(o=>{o.addedNodes.forEach(v),o.removedNodes.forEach(t)})}),r.observe(document.body,{childList:!0,subtree:!0}))},_=()=>{r&&(r.disconnect(),r=null)},m=(e,o={})=>{const i=p[e];if(!i){console.warn(`Component '${e}' not found in registry`);return}const a=o.force===!0;l(e,i.selector,a).forEach(u=>{const g=u.dataset?.basecoatComponent===e;a&&h(u),(g||u.matches(i.selector))&&d(u,e)})},w=(e={})=>{f(e)},b=e=>{const o=e==="dark";document.documentElement.classList.toggle("dark",o);try{localStorage.setItem("themeMode",o?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:o?"dark":"light"}}))},E=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:c,init:m,initAll:w,refresh:n,start:y,stop:_,theme:{get:E,set:b,toggle:()=>b(E()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{f(),y()})})(),(()=>{const p=r=>{if(r.dataset.popoverInitialized)return;const c=r.querySelector(":scope > button"),d=r.querySelector(":scope > [data-popover]");if(!c||!d){const n=[];c||n.push("trigger"),d||n.push("content"),console.error(`Popover initialisation failed. Missing element(s): ${n.join(", ")}`,r);return}const h=(n=!0)=>{c.getAttribute("aria-expanded")!=="false"&&(c.setAttribute("aria-expanded","false"),d.setAttribute("aria-hidden","true"),n&&c.focus())},t=()=>{document.dispatchEvent(new CustomEvent("basecoat:popover",{detail:{source:r}}));const n=d.querySelector("[autofocus]");n&&d.addEventListener("transitionend",()=>{n.focus()},{once:!0}),c.setAttribute("aria-expanded","true"),d.setAttribute("aria-hidden","false")},s=()=>{c.getAttribute("aria-expanded")==="true"?h():t()},l=n=>{n.key==="Escape"&&h()},f=n=>{r.contains(n.target)||h()},v=n=>{r.contains(n.detail.source)||h(!1)};c.addEventListener("click",s),r.addEventListener("keydown",l),document.addEventListener("click",f),document.addEventListener("basecoat:popover",v),r._destroy=()=>{c.removeEventListener("click",s),r.removeEventListener("keydown",l),document.removeEventListener("click",f),document.removeEventListener("basecoat:popover",v)},r.dataset.popoverInitialized=!0,r.dispatchEvent(new CustomEvent("basecoat:initialized"))};window.basecoat&&window.basecoat.register("popover",".popover:not([data-popover-initialized]):not(:has(> [data-popover][popover]))",p)})(),(()=>{var p=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const t=this.root?this.snapshot():void 0;this.teardown(),this.setup(t)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(t){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=s=>{s.target!==this.root||!this.constructor.relayNative&&!(s instanceof CustomEvent)||(s.stopPropagation(),this._silent||this.emit(s.type,{value:this.value}))};for(const s of this.constructor.relayed)this.root.addEventListener(s,this._relay);this.attach?.(),t!==void 0?this.restore(t):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const t of this.constructor.relayed)this.root.removeEventListener(t,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(t,s)=>s.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const t=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,t!==null&&(this.value=t)}snapshot(){return this.value}restore(t){t!==null&&(this.value=t)}attributeChangedCallback(t,s,l){t==="value"&&this.root&&l!==null&&l!==this.value&&(this.value=l)}defer(t){return this.root?!1:(this._pending=t,!0)}silently(t){this._silent=!0;try{t()}finally{this._silent=!1}}emit(t,s){this.dispatchEvent(new CustomEvent(t,{detail:s,bubbles:!0}))}reportValue(){const t=this.value;JSON.stringify(t)!==JSON.stringify(this._last)&&(this._last=t,this._silent||this.emit("change",{value:t}))}},r=class extends p{static observedAttributes=["open"];static relayed=[];applyInitial(){const t=this._pending!==void 0?this._pending:this.hasAttribute("open")||null;this._pending=void 0,this._lastOpen=this.isOpen(),t!==null&&!!t!==this._lastOpen&&(this.open=t)}attributeChangedCallback(t,s,l){t==="open"&&this.root&&(this.open=l!==null)}snapshot(){return this.isOpen()}restore(t){this._lastOpen=this.isOpen(),this.open=t}get open(){return this.root?this.isOpen():!!this._pending}set open(t){this.defer(!!t)||!!t!==this.isOpen()&&this.setOpen(!!t)}reportOpen(){const t=this.isOpen();t!==this._lastOpen&&(this._lastOpen=t,this.emit("toggle",{open:t}))}};function c(t,s,l,f=!0){const v=new MutationObserver(l);return v.observe(t,{attributes:!0,attributeFilter:s,subtree:f}),()=>v.disconnect()}var d=class extends r{get trigger(){return this.root?.querySelector(":scope > button")}get nativePanel(){return this.root?.querySelector(":scope > [data-popover][popover]")}attach(){const t=this.nativePanel;t?(this._onToggle=()=>this.reportOpen(),t.addEventListener("toggle",this._onToggle),this._unwatch=()=>t.removeEventListener("toggle",this._onToggle)):this._unwatch=c(this.trigger,["aria-expanded"],()=>this.reportOpen(),!1)}detach(){this._unwatch?.()}isOpen(){const t=this.nativePanel;return t?t.matches(":popover-open"):this.trigger?.getAttribute("aria-expanded")==="true"}setOpen(t){const s=this.nativePanel;if(s)return t?s.showPopover():s.hidePopover();this.setOpenJs(t)}},h=class extends d{static component="popover";static rootSelector=".popover";setOpenJs(){this.trigger?.click()}};customElements.get("auvyx-popover")||customElements.define("auvyx-popover",h)})();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const f={};let E=null;const o=(n,c,u)=>{const b=typeof c=="object"?c:{selector:c,init:u};f[n]={selector:b.selector,init:b.init,refresh:b.refresh}},h=(n,c)=>{const u=f[c];if(u)try{u.init(n),n.hasAttribute(`data-${c}-initialized`)&&(n.dataset.basecoatComponent=c)}catch(b){if(console.error(`Failed to initialize ${c}:`,b),typeof n._destroy=="function")try{n._destroy()}catch(e){console.error(`Failed to clean up ${c} after initialization error:`,e)}delete n._destroy,n.removeAttribute(`data-${c}-initialized`),delete n.dataset.basecoatComponent}},x=n=>{if(!n||n.nodeType!==Node.ELEMENT_NODE)return;const c=n.dataset?.basecoatComponent;if(typeof n._destroy=="function")try{n._destroy()}catch(u){console.error("Failed to destroy Basecoat component:",u)}delete n._destroy,c&&n.removeAttribute(`data-${c}-initialized`),delete n.dataset.basecoatComponent},I=n=>{n.nodeType===Node.ELEMENT_NODE&&(n.isConnected||(n.dataset?.basecoatComponent&&x(n),n.querySelectorAll("[data-basecoat-component]").forEach(x)))},L=n=>Array.from(new Set(n)),_=(n,c,u=!1)=>{const b=Array.from(document.querySelectorAll(c));return u&&b.push(...document.querySelectorAll(`[data-basecoat-component="${n}"]`)),L(b)},A=(n={})=>{const c=n.force===!0;Object.entries(f).forEach(([u,{selector:b}])=>{_(u,b,c).forEach(e=>{const t=e.dataset?.basecoatComponent===u;c&&x(e),(t||e.matches(b))&&h(e,u)})})},w=n=>{n.nodeType===Node.ELEMENT_NODE&&Object.entries(f).forEach(([c,{selector:u}])=>{n.matches(u)&&h(n,c),n.querySelectorAll(u).forEach(b=>h(b,c))})},q=n=>{if(!n)return;if(typeof n.refresh=="function"){n.refresh();return}const c=n.dataset?.basecoatComponent,u=c?f[c]:null;u?.refresh&&u.refresh(n)},k=()=>{E||(E=new MutationObserver(n=>{n.forEach(c=>{c.addedNodes.forEach(w),c.removedNodes.forEach(I)})}),E.observe(document.body,{childList:!0,subtree:!0}))},O=()=>{E&&(E.disconnect(),E=null)},v=(n,c={})=>{const u=f[n];if(!u){console.warn(`Component '${n}' not found in registry`);return}const b=c.force===!0;_(n,u.selector,b).forEach(e=>{const t=e.dataset?.basecoatComponent===n;b&&x(e),(t||e.matches(u.selector))&&h(e,n)})},M=(n={})=>{A(n)},C=n=>{const c=n==="dark";document.documentElement.classList.toggle("dark",c);try{localStorage.setItem("themeMode",c?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:c?"dark":"light"}}))},S=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:o,init:v,initAll:M,refresh:q,start:k,stop:O,theme:{get:S,set:C,toggle:()=>C(S()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{A(),k()})})(),(()=>{const f=new WeakMap,E=e=>{const t=e.querySelector(":scope > button"),s=t?.querySelector(":scope > span")||null,i=e.querySelector(":scope > [data-popover]"),l=i?i.querySelector('[role="listbox"]'):null,a=e.querySelector(':scope > input[type="hidden"]');return{trigger:t,selectedLabel:s,popover:i,listbox:l,input:a}},o=e=>e.dataset.value??e.textContent.trim(),h=e=>e.dataset.label||e.textContent.trim(),x=e=>e.dataset.format==="object"?"object":"value",I=e=>e.getAttribute("aria-disabled")==="true",L=e=>({value:o(e),label:h(e)}),_=e=>{const t=Array.from(e.querySelectorAll('[role="option"]'));return{allOptions:t,options:t.filter(s=>!I(s))}},A=(e,{isMultiple:t,format:s})=>{if(t)try{const i=JSON.parse(e||"[]");return Array.isArray(i)?i.map(l=>s==="object"&&l&&typeof l=="object"?l.value:l).filter(l=>l!=null).map(String):[]}catch{return[]}if(s==="object")try{const i=JSON.parse(e||"null");return i&&typeof i=="object"&&i.value!=null?String(i.value):""}catch{return""}return e||""},w=(e,t)=>{if(e.format==="object")return JSON.stringify(e.isMultiple?t:t[0]||null);const s=t.map(i=>i.value);return e.isMultiple?JSON.stringify(s):s[0]||""},q=e=>{e.selectedLabel.textContent=e.placeholder||"",e.selectedLabel.classList.toggle("text-muted-foreground",!!e.placeholder),e.input.value=e.isMultiple?w(e,[]):""},k=(e,t)=>{const s=t.getBoundingClientRect(),i=e.listbox.getBoundingClientRect();s.top<i.top?e.listbox.scrollTop-=i.top-s.top:s.bottom>i.bottom&&(e.listbox.scrollTop+=s.bottom-i.bottom)},O=(e,t)=>{if(e.activeIndex>-1&&e.options[e.activeIndex]&&e.options[e.activeIndex].classList.remove("active"),e.activeIndex=t,e.activeIndex>-1){const s=e.options[e.activeIndex];s.classList.add("active"),s.id?e.trigger.setAttribute("aria-activedescendant",s.id):e.trigger.removeAttribute("aria-activedescendant")}else e.trigger.removeAttribute("aria-activedescendant")},v=(e,t,s=!0)=>{const i=f.get(e);let l,a;if(i.isMultiple){const d=Array.isArray(t)?t:[];i.selectedOptions.clear(),d.forEach(m=>i.selectedOptions.add(m));const g=i.options.filter(m=>i.selectedOptions.has(m));a=g.map(L),g.length===0?(i.selectedLabel.textContent=i.placeholder,i.selectedLabel.classList.add("text-muted-foreground")):(i.selectedLabel.textContent=a.map(m=>m.label).join(", "),i.selectedLabel.classList.remove("text-muted-foreground")),l=a.map(m=>m.value),i.input.value=w(i,a)}else{const d=t;d?(d.dataset.label?i.selectedLabel.textContent=d.dataset.label:i.selectedLabel.innerHTML=d.innerHTML,i.selectedLabel.classList.remove("text-muted-foreground"),a=L(d),l=a.value,i.input.value=w(i,[a])):(i.options.forEach(g=>g.removeAttribute("aria-selected")),q(i),a=null,l="")}i.options.forEach(d=>{(i.isMultiple?i.selectedOptions.has(d):t&&d===t)?d.setAttribute("aria-selected","true"):d.removeAttribute("aria-selected")}),s&&e.dispatchEvent(new CustomEvent("change",{detail:{value:l,selected:a},bubbles:!0}))},M=(e,t=!0)=>{e.popover.getAttribute("aria-hidden")!=="true"&&(t&&e.trigger.focus(),e.popover.setAttribute("aria-hidden","true"),e.trigger.setAttribute("aria-expanded","false"),O(e,-1))},C=e=>{const t=f.get(e);if(!t)return;const s=E(e);if(!s.trigger||!s.selectedLabel||!s.popover||!s.listbox||!s.input){const a=[];s.trigger||a.push("trigger"),s.selectedLabel||a.push("selected label"),s.popover||a.push("popover"),s.listbox||a.push("listbox"),s.input||a.push("input"),console.error(`Select component refresh failed. Missing element(s): ${a.join(", ")}`,e);return}const i=s.input.value;if(Object.assign(t,s,_(s.listbox)),t.visibleOptions=[...t.options],t.isMultiple=t.listbox.getAttribute("aria-multiselectable")==="true",t.format=x(e),t.placeholder=e.dataset.placeholder||"",t.closeOnSelect=e.dataset.closeOnSelect==="true",t.isMultiple){t.selectedOptions||(t.selectedOptions=new Set);const a=A(i,t),d=a.length?a.map(g=>t.options.find(m=>o(m)===g)).filter(Boolean):t.options.filter(g=>g.getAttribute("aria-selected")==="true");v(e,d,!1)}else{const a=A(i,t),d=a===""&&t.placeholder?null:t.options.find(g=>o(g)===a)||t.options.find(g=>g.getAttribute("aria-selected")==="true");t.options.forEach(g=>g.removeAttribute("aria-selected")),v(e,d||null,!1)}const l=t.listbox.querySelector('[role="option"][aria-selected="true"]');O(t,l?t.options.indexOf(l):-1)},S=(e,t)=>{const s=f.get(e);s.selectedOptions.has(t)?s.selectedOptions.delete(t):s.selectedOptions.add(t),v(e,s.options.filter(i=>s.selectedOptions.has(i)))},n=(e,t)=>{const s=f.get(e);if(s.isMultiple){const i=s.options.find(l=>o(l)===t&&!s.selectedOptions.has(l));if(!i)return;s.selectedOptions.add(i),v(e,s.options.filter(l=>s.selectedOptions.has(l)))}else{const i=s.options.find(l=>o(l)===t);if(!i)return;if(s.placeholder&&o(i)===""){v(e,null),M(s);return}e.value!==t&&v(e,i),M(s)}},c=(e,t)=>{const s=f.get(e);if(!s.isMultiple)return;const i=s.options.find(l=>o(l)===t&&s.selectedOptions.has(l));i&&(s.selectedOptions.delete(i),v(e,s.options.filter(l=>s.selectedOptions.has(l))))},u=(e,t)=>{const s=f.get(t),i=s.popover.getAttribute("aria-hidden")==="false";if(!["ArrowDown","ArrowUp","Enter","Home","End","Escape"].includes(e.key))return;if(!i){e.key!=="Enter"&&e.key!=="Escape"&&(e.preventDefault(),t.open());return}if(e.preventDefault(),e.key==="Escape"){t.close();return}if(e.key==="Enter"){if(s.activeIndex>-1){const d=s.options[s.activeIndex];s.isMultiple?(S(t,d),s.closeOnSelect&&t.close()):(s.placeholder&&o(d)===""?v(t,null):t.value!==o(d)&&v(t,d),t.close())}return}if(s.visibleOptions.length===0)return;const l=s.activeIndex>-1?s.visibleOptions.indexOf(s.options[s.activeIndex]):-1;let a=l;if(e.key==="ArrowDown"&&l<s.visibleOptions.length-1&&(a=l+1),e.key==="ArrowUp"&&(a=l>0?l-1:0),e.key==="Home"&&(a=0),e.key==="End"&&(a=s.visibleOptions.length-1),a!==l){const d=s.visibleOptions[a];O(s,s.options.indexOf(d)),k(s,d)}},b=e=>{if(e.dataset.selectInitialized)return;const t={activeIndex:-1,selectedOptions:null,options:[],allOptions:[],visibleOptions:[],format:"value"};if(f.set(e,t),e.refresh=()=>C(e),C(e),!t.trigger||!t.selectedLabel||!t.popover||!t.listbox||!t.input){f.delete(e),delete e.refresh;return}e.open=()=>{document.dispatchEvent(new CustomEvent("basecoat:popover",{detail:{source:e}})),e.refresh(),t.popover.setAttribute("aria-hidden","false"),t.trigger.setAttribute("aria-expanded","true");const r=t.listbox.querySelector('[role="option"][aria-selected="true"]');r&&(O(t,t.options.indexOf(r)),k(t,r))},e.close=(r=!0)=>M(t,r),e.togglePopover=()=>t.trigger.getAttribute("aria-expanded")==="true"?e.close():e.open();const s=r=>u(r,e),i=e.togglePopover,l=r=>{const y=r.target.closest('[role="option"]');if(y&&t.visibleOptions.includes(y)){const p=t.options.indexOf(y);p!==t.activeIndex&&O(t,p)}},a=()=>{const r=t.listbox.querySelector('[role="option"][aria-selected="true"]');O(t,r?t.options.indexOf(r):-1)},d=r=>{const y=r.target.closest('[role="option"]');if(!y)return;const p=t.options.find(N=>N===y);p&&(t.isMultiple?(S(e,p),t.closeOnSelect?e.close():(O(t,t.options.indexOf(p)),t.trigger.focus())):(t.placeholder&&o(p)===""?v(e,null):e.value!==o(p)&&v(e,p),e.close()))},g=r=>{e.contains(r.target)||e.close(!1)},m=r=>{e.contains(r.detail.source)||e.close(!1)};t.trigger.addEventListener("keydown",s),t.trigger.addEventListener("click",i),t.listbox.addEventListener("mousemove",l),t.listbox.addEventListener("mouseleave",a),t.listbox.addEventListener("click",d),document.addEventListener("click",g),document.addEventListener("basecoat:popover",m),e._destroy=()=>{t.trigger.removeEventListener("keydown",s),t.trigger.removeEventListener("click",i),t.listbox.removeEventListener("mousemove",l),t.listbox.removeEventListener("mouseleave",a),t.listbox.removeEventListener("click",d),document.removeEventListener("click",g),document.removeEventListener("basecoat:popover",m),f.delete(e),delete e.refresh,delete e.open,delete e.close,delete e.togglePopover,delete e.select,delete e.selectByValue,delete e.deselect,delete e.toggle,delete e.selectAll,delete e.selectNone},Object.defineProperty(e,"value",{configurable:!0,get:()=>t.isMultiple?t.options.filter(r=>t.selectedOptions.has(r)).map(o):A(t.input.value,t),set:r=>{if(t.isMultiple){const y=Array.isArray(r)?r:r!=null?[r]:[];v(e,y.map(p=>t.options.find(N=>o(N)===p)).filter(Boolean))}else{if(r==null||r===""){v(e,null),e.close();return}const y=t.options.find(p=>o(p)===r);y&&(v(e,y),e.close())}}}),Object.defineProperty(e,"selected",{configurable:!0,get:()=>{if(t.isMultiple)return t.options.filter(p=>t.selectedOptions.has(p)).map(L);const r=e.value,y=t.options.find(p=>o(p)===r);return y?L(y):null}}),e.select=r=>n(e,r),e.selectByValue=e.select,t.isMultiple&&(e.deselect=r=>c(e,r),e.toggle=r=>{const y=t.options.find(p=>o(p)===r);y&&S(e,y)},e.selectAll=()=>v(e,t.options),e.selectNone=()=>v(e,[])),t.popover.setAttribute("aria-hidden","true"),t.trigger.setAttribute("aria-expanded","false"),e.dataset.selectInitialized="true",e.dispatchEvent(new CustomEvent("basecoat:initialized"))};window.basecoat&&window.basecoat.register("select",{selector:"div.select:not([data-select-initialized])",init:b,refresh:C})})(),(()=>{var f=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const o=this.root?this.snapshot():void 0;this.teardown(),this.setup(o)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(o){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=h=>{h.target!==this.root||!this.constructor.relayNative&&!(h instanceof CustomEvent)||(h.stopPropagation(),this._silent||this.emit(h.type,{value:this.value}))};for(const h of this.constructor.relayed)this.root.addEventListener(h,this._relay);this.attach?.(),o!==void 0?this.restore(o):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const o of this.constructor.relayed)this.root.removeEventListener(o,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(o,h)=>h.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const o=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,o!==null&&(this.value=o)}snapshot(){return this.value}restore(o){o!==null&&(this.value=o)}attributeChangedCallback(o,h,x){o==="value"&&this.root&&x!==null&&x!==this.value&&(this.value=x)}defer(o){return this.root?!1:(this._pending=o,!0)}silently(o){this._silent=!0;try{o()}finally{this._silent=!1}}emit(o,h){this.dispatchEvent(new CustomEvent(o,{detail:h,bubbles:!0}))}reportValue(){const o=this.value;JSON.stringify(o)!==JSON.stringify(this._last)&&(this._last=o,this._silent||this.emit("change",{value:o}))}},E=class extends f{static component="select";static rootSelector=".select";get value(){return this.root?this.root.value:null}set value(o){this.defer(o)||this.root.select&&this.silently(()=>this.root.select(o))}};customElements.get("auvyx-select")||customElements.define("auvyx-select",E)})();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const d={};let c=null;const i=(e,s,o)=>{const n=typeof s=="object"?s:{selector:s,init:o};d[e]={selector:n.selector,init:n.init,refresh:n.refresh}},t=(e,s)=>{const o=d[s];if(o)try{o.init(e),e.hasAttribute(`data-${s}-initialized`)&&(e.dataset.basecoatComponent=s)}catch(n){if(console.error(`Failed to initialize ${s}:`,n),typeof e._destroy=="function")try{e._destroy()}catch(l){console.error(`Failed to clean up ${s} after initialization error:`,l)}delete e._destroy,e.removeAttribute(`data-${s}-initialized`),delete e.dataset.basecoatComponent}},r=e=>{if(!e||e.nodeType!==Node.ELEMENT_NODE)return;const s=e.dataset?.basecoatComponent;if(typeof e._destroy=="function")try{e._destroy()}catch(o){console.error("Failed to destroy Basecoat component:",o)}delete e._destroy,s&&e.removeAttribute(`data-${s}-initialized`),delete e.dataset.basecoatComponent},a=e=>{e.nodeType===Node.ELEMENT_NODE&&(e.isConnected||(e.dataset?.basecoatComponent&&r(e),e.querySelectorAll("[data-basecoat-component]").forEach(r)))},h=e=>Array.from(new Set(e)),p=(e,s,o=!1)=>{const n=Array.from(document.querySelectorAll(s));return o&&n.push(...document.querySelectorAll(`[data-basecoat-component="${e}"]`)),h(n)},y=(e={})=>{const s=e.force===!0;Object.entries(d).forEach(([o,{selector:n}])=>{p(o,n,s).forEach(l=>{const E=l.dataset?.basecoatComponent===o;s&&r(l),(E||l.matches(n))&&t(l,o)})})},g=e=>{e.nodeType===Node.ELEMENT_NODE&&Object.entries(d).forEach(([s,{selector:o}])=>{e.matches(o)&&t(e,s),e.querySelectorAll(o).forEach(n=>t(n,s))})},v=e=>{if(!e)return;if(typeof e.refresh=="function"){e.refresh();return}const s=e.dataset?.basecoatComponent,o=s?d[s]:null;o?.refresh&&o.refresh(e)},u=()=>{c||(c=new MutationObserver(e=>{e.forEach(s=>{s.addedNodes.forEach(g),s.removedNodes.forEach(a)})}),c.observe(document.body,{childList:!0,subtree:!0}))},f=()=>{c&&(c.disconnect(),c=null)},b=(e,s={})=>{const o=d[e];if(!o){console.warn(`Component '${e}' not found in registry`);return}const n=s.force===!0;p(e,o.selector,n).forEach(l=>{const E=l.dataset?.basecoatComponent===e;n&&r(l),(E||l.matches(o.selector))&&t(l,e)})},_=(e={})=>{y(e)},w=e=>{const s=e==="dark";document.documentElement.classList.toggle("dark",s);try{localStorage.setItem("themeMode",s?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:s?"dark":"light"}}))},O=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:i,init:b,initAll:_,refresh:v,start:u,stop:f,theme:{get:O,set:w,toggle:()=>w(O()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{y(),u()})})(),(()=>{const d=i=>{if(i.dataset.sidebarInitialized&&typeof i.toggle=="function")return;if(i.dataset.position==="static"){i.dataset.sidebarInitialized="true";return}const t=i.dataset.initialOpen!=="false",r=i.dataset.initialMobileOpen==="true",a=parseInt(i.dataset.breakpoint)||768;let h=a>0?window.innerWidth>=a?t:r:t;const p=()=>i.dataset.collapsible==="icon"&&(a<=0||window.innerWidth>=a),y=()=>{const u=p();i.setAttribute("aria-hidden",String(!h&&!u)),i.dataset.state=h?"open":"collapsed",h||u?i.removeAttribute("inert"):i.setAttribute("inert",""),i.id&&document.querySelectorAll(`[data-sidebar-toggle="${CSS.escape(i.id)}"]`).forEach(f=>f.setAttribute("aria-expanded",String(h))),i.dispatchEvent(new CustomEvent("basecoat:sidebar",{detail:{open:h}}))},g=u=>{h=!!u,y()};i.open=()=>g(!0),i.close=()=>g(!1),i.toggle=()=>g(!h);const v=u=>{const f=u.target,b=i.querySelector(":scope > nav");if(window.innerWidth<a&&f.closest("a, button")&&!f.closest("[data-keep-mobile-sidebar-open]")){document.activeElement&&document.activeElement.blur(),i.close();return}if(!h&&p()&&f.closest("summary")){u.preventDefault(),i.open(),f.closest("details").open=!0;return}(f===i||b&&!b.contains(f))&&(document.activeElement&&document.activeElement.blur(),i.close())};i.addEventListener("click",v),i._destroy=()=>{i.removeEventListener("click",v),delete i.open,delete i.close,delete i.toggle},y(),i.dataset.sidebarInitialized="true",i.dispatchEvent(new CustomEvent("basecoat:initialized"))},c=i=>i?document.getElementById(i):document.querySelector('.sidebar:not([data-position="static"])');document.addEventListener("click",i=>{const t=i.target.closest("[data-sidebar-toggle]");t&&c(t.getAttribute("data-sidebar-toggle"))?.toggle?.()}),document.addEventListener("keydown",i=>{if(i.key.toLowerCase()!=="b"||!(i.metaKey||i.ctrlKey)||i.altKey||i.shiftKey||i.target.closest("input, textarea, select, [contenteditable]"))return;const t=c("");!t||t.dataset.shortcut==="none"||typeof t.toggle!="function"||(i.preventDefault(),t.toggle())}),window.basecoat&&window.basecoat.register("sidebar",".sidebar",d)})(),(()=>{var d=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const t=this.root?this.snapshot():void 0;this.teardown(),this.setup(t)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(t){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=r=>{r.target!==this.root||!this.constructor.relayNative&&!(r instanceof CustomEvent)||(r.stopPropagation(),this._silent||this.emit(r.type,{value:this.value}))};for(const r of this.constructor.relayed)this.root.addEventListener(r,this._relay);this.attach?.(),t!==void 0?this.restore(t):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const t of this.constructor.relayed)this.root.removeEventListener(t,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(t,r)=>r.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const t=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,t!==null&&(this.value=t)}snapshot(){return this.value}restore(t){t!==null&&(this.value=t)}attributeChangedCallback(t,r,a){t==="value"&&this.root&&a!==null&&a!==this.value&&(this.value=a)}defer(t){return this.root?!1:(this._pending=t,!0)}silently(t){this._silent=!0;try{t()}finally{this._silent=!1}}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0}))}reportValue(){const t=this.value;JSON.stringify(t)!==JSON.stringify(this._last)&&(this._last=t,this._silent||this.emit("change",{value:t}))}},c=class extends d{static observedAttributes=["open"];static relayed=[];applyInitial(){const t=this._pending!==void 0?this._pending:this.hasAttribute("open")||null;this._pending=void 0,this._lastOpen=this.isOpen(),t!==null&&!!t!==this._lastOpen&&(this.open=t)}attributeChangedCallback(t,r,a){t==="open"&&this.root&&(this.open=a!==null)}snapshot(){return this.isOpen()}restore(t){this._lastOpen=this.isOpen(),this.open=t}get open(){return this.root?this.isOpen():!!this._pending}set open(t){this.defer(!!t)||!!t!==this.isOpen()&&this.setOpen(!!t)}reportOpen(){const t=this.isOpen();t!==this._lastOpen&&(this._lastOpen=t,this.emit("toggle",{open:t}))}},i=class extends c{static component="sidebar";static rootSelector=".sidebar";attach(){this._onState=()=>this.reportOpen(),this.root.addEventListener("basecoat:sidebar",this._onState)}detach(){this.root?.removeEventListener("basecoat:sidebar",this._onState)}isOpen(){return this.root?.dataset.state!=="collapsed"}setOpen(t){t?this.root.open?.():this.root.close?.()}};customElements.get("auvyx-sidebar")||customElements.define("auvyx-sidebar",i)})();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const a={};let d=null;const e=(t,o,s)=>{const i=typeof o=="object"?o:{selector:o,init:s};a[t]={selector:i.selector,init:i.init,refresh:i.refresh}},r=(t,o)=>{const s=a[o];if(s)try{s.init(t),t.hasAttribute(`data-${o}-initialized`)&&(t.dataset.basecoatComponent=o)}catch(i){if(console.error(`Failed to initialize ${o}:`,i),typeof t._destroy=="function")try{t._destroy()}catch(c){console.error(`Failed to clean up ${o} after initialization error:`,c)}delete t._destroy,t.removeAttribute(`data-${o}-initialized`),delete t.dataset.basecoatComponent}},n=t=>{if(!t||t.nodeType!==Node.ELEMENT_NODE)return;const o=t.dataset?.basecoatComponent;if(typeof t._destroy=="function")try{t._destroy()}catch(s){console.error("Failed to destroy Basecoat component:",s)}delete t._destroy,o&&t.removeAttribute(`data-${o}-initialized`),delete t.dataset.basecoatComponent},l=t=>{t.nodeType===Node.ELEMENT_NODE&&(t.isConnected||(t.dataset?.basecoatComponent&&n(t),t.querySelectorAll("[data-basecoat-component]").forEach(n)))},u=t=>Array.from(new Set(t)),f=(t,o,s=!1)=>{const i=Array.from(document.querySelectorAll(o));return s&&i.push(...document.querySelectorAll(`[data-basecoat-component="${t}"]`)),u(i)},p=(t={})=>{const o=t.force===!0;Object.entries(a).forEach(([s,{selector:i}])=>{f(s,i,o).forEach(c=>{const h=c.dataset?.basecoatComponent===s;o&&n(c),(h||c.matches(i))&&r(c,s)})})},b=t=>{t.nodeType===Node.ELEMENT_NODE&&Object.entries(a).forEach(([o,{selector:s}])=>{t.matches(s)&&r(t,o),t.querySelectorAll(s).forEach(i=>r(i,o))})},E=t=>{if(!t)return;if(typeof t.refresh=="function"){t.refresh();return}const o=t.dataset?.basecoatComponent,s=o?a[o]:null;s?.refresh&&s.refresh(t)},y=()=>{d||(d=new MutationObserver(t=>{t.forEach(o=>{o.addedNodes.forEach(b),o.removedNodes.forEach(l)})}),d.observe(document.body,{childList:!0,subtree:!0}))},C=()=>{d&&(d.disconnect(),d=null)},m=(t,o={})=>{const s=a[t];if(!s){console.warn(`Component '${t}' not found in registry`);return}const i=o.force===!0;f(t,s.selector,i).forEach(c=>{const h=c.dataset?.basecoatComponent===t;i&&n(c),(h||c.matches(s.selector))&&r(c,t)})},_=(t={})=>{p(t)},v=t=>{const o=t==="dark";document.documentElement.classList.toggle("dark",o);try{localStorage.setItem("themeMode",o?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:o?"dark":"light"}}))},g=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:e,init:m,initAll:_,refresh:E,start:y,stop:C,theme:{get:g,set:v,toggle:()=>v(g()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{p(),y()})})(),(()=>{function a(e){const r=parseFloat(e.min||"0"),n=parseFloat(e.max||"100"),l=parseFloat(e.value||"0"),u=n===r?0:(l-r)/(n-r)*100;e.style.setProperty("--slider-value",`${u}%`)}function d(e){if(e.dataset.rangeInitialized)return;a(e);const r=()=>a(e);e.addEventListener("input",r),e._destroy=()=>{e.removeEventListener("input",r)},e.dataset.rangeInitialized="true"}window.basecoat&&window.basecoat.register("range",'input[type="range"]:not([data-range-initialized])',d)})(),(()=>{var a=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const e=this.root?this.snapshot():void 0;this.teardown(),this.setup(e)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(e){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=r=>{r.target!==this.root||!this.constructor.relayNative&&!(r instanceof CustomEvent)||(r.stopPropagation(),this._silent||this.emit(r.type,{value:this.value}))};for(const r of this.constructor.relayed)this.root.addEventListener(r,this._relay);this.attach?.(),e!==void 0?this.restore(e):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const e of this.constructor.relayed)this.root.removeEventListener(e,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(e,r)=>r.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const e=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,e!==null&&(this.value=e)}snapshot(){return this.value}restore(e){e!==null&&(this.value=e)}attributeChangedCallback(e,r,n){e==="value"&&this.root&&n!==null&&n!==this.value&&(this.value=n)}defer(e){return this.root?!1:(this._pending=e,!0)}silently(e){this._silent=!0;try{e()}finally{this._silent=!1}}emit(e,r){this.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0}))}reportValue(){const e=this.value;JSON.stringify(e)!==JSON.stringify(this._last)&&(this._last=e,this._silent||this.emit("change",{value:e}))}},d=class extends a{static component="range";static rootSelector='input[type="range"]';static relayed=["input","change"];static relayNative=!0;get value(){return this.root?this.root.value:null}set value(e){if(this.defer(e))return;this.root.value=e;const{min:r,max:n}=this.root,l=parseFloat(r||"0"),u=parseFloat(n||"100");this.root.style.setProperty("--slider-value",`${u===l?0:(parseFloat(this.root.value)-l)/(u-l)*100}%`)}};customElements.get("auvyx-slider")||customElements.define("auvyx-slider",d)})();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const d={};let u=null;const E=(t,r,o)=>{const c=typeof r=="object"?r:{selector:r,init:o};d[t]={selector:c.selector,init:c.init,refresh:c.refresh}},p=(t,r)=>{const o=d[r];if(o)try{o.init(t),t.hasAttribute(`data-${r}-initialized`)&&(t.dataset.basecoatComponent=r)}catch(c){if(console.error(`Failed to initialize ${r}:`,c),typeof t._destroy=="function")try{t._destroy()}catch(y){console.error(`Failed to clean up ${r} after initialization error:`,y)}delete t._destroy,t.removeAttribute(`data-${r}-initialized`),delete t.dataset.basecoatComponent}},s=t=>{if(!t||t.nodeType!==Node.ELEMENT_NODE)return;const r=t.dataset?.basecoatComponent;if(typeof t._destroy=="function")try{t._destroy()}catch(o){console.error("Failed to destroy Basecoat component:",o)}delete t._destroy,r&&t.removeAttribute(`data-${r}-initialized`),delete t.dataset.basecoatComponent},e=t=>{t.nodeType===Node.ELEMENT_NODE&&(t.isConnected||(t.dataset?.basecoatComponent&&s(t),t.querySelectorAll("[data-basecoat-component]").forEach(s)))},i=t=>Array.from(new Set(t)),h=(t,r,o=!1)=>{const c=Array.from(document.querySelectorAll(r));return o&&c.push(...document.querySelectorAll(`[data-basecoat-component="${t}"]`)),i(c)},l=(t={})=>{const r=t.force===!0;Object.entries(d).forEach(([o,{selector:c}])=>{h(o,c,r).forEach(y=>{const C=y.dataset?.basecoatComponent===o;r&&s(y),(C||y.matches(c))&&p(y,o)})})},m=t=>{t.nodeType===Node.ELEMENT_NODE&&Object.entries(d).forEach(([r,{selector:o}])=>{t.matches(o)&&p(t,r),t.querySelectorAll(o).forEach(c=>p(c,r))})},n=t=>{if(!t)return;if(typeof t.refresh=="function"){t.refresh();return}const r=t.dataset?.basecoatComponent,o=r?d[r]:null;o?.refresh&&o.refresh(t)},g=()=>{u||(u=new MutationObserver(t=>{t.forEach(r=>{r.addedNodes.forEach(m),r.removedNodes.forEach(e)})}),u.observe(document.body,{childList:!0,subtree:!0}))},a=()=>{u&&(u.disconnect(),u=null)},f=(t,r={})=>{const o=d[t];if(!o){console.warn(`Component '${t}' not found in registry`);return}const c=r.force===!0;h(t,o.selector,c).forEach(y=>{const C=y.dataset?.basecoatComponent===t;c&&s(y),(C||y.matches(o.selector))&&p(y,t)})},v=(t={})=>{l(t)},b=t=>{const r=t==="dark";document.documentElement.classList.toggle("dark",r);try{localStorage.setItem("themeMode",r?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:r?"dark":"light"}}))},w=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:E,init:f,initAll:v,refresh:n,start:g,stop:a,theme:{get:w,set:b,toggle:()=>b(w()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{l(),g()})})(),(()=>{const d=new WeakMap,u=e=>e.disabled||e.getAttribute("aria-disabled")==="true",E=e=>{const i=e.querySelector('[role="tablist"]'),h=i?Array.from(i.querySelectorAll('[role="tab"]')):[],l=h.map(m=>document.getElementById(m.getAttribute("aria-controls"))).filter(Boolean);return{tablist:i,tabs:h,panels:l}},p=e=>{const i=d.get(e);if(!i||(Object.assign(i,E(e)),!i.tablist))return;const h=i.tabs.find(l=>l.getAttribute("aria-selected")==="true"&&!u(l))||i.tabs.find(l=>!u(l));h&&e.select(h,!1)},s=e=>{if(e.dataset.tabsInitialized)return;const i={};d.set(e,i),e.refresh=()=>p(e);const h=(n,g=!1)=>{if(!n||u(n))return;i.tabs.forEach(f=>{f.setAttribute("aria-selected","false"),f.setAttribute("tabindex","-1");const v=document.getElementById(f.getAttribute("aria-controls"));v&&(v.hidden=!0)}),n.setAttribute("aria-selected","true"),n.setAttribute("tabindex","0");const a=document.getElementById(n.getAttribute("aria-controls"));a&&(a.hidden=!1),g&&n.focus()};if(e.select=h,p(e),!i.tablist){d.delete(e),delete e.refresh,delete e.select;return}const l=n=>{const g=n.target.closest('[role="tab"]');g&&e.select(g)},m=n=>{const g=n.target;if(!i.tabs.includes(g))return;const a=i.tabs.filter(w=>!u(w)),f=a.indexOf(g),v=i.tablist.getAttribute("aria-orientation")||"horizontal";if(f===-1)return;let b;n.key==="ArrowRight"&&v==="horizontal"&&(b=a[(f+1)%a.length]),n.key==="ArrowLeft"&&v==="horizontal"&&(b=a[(f-1+a.length)%a.length]),n.key==="ArrowDown"&&v==="vertical"&&(b=a[(f+1)%a.length]),n.key==="ArrowUp"&&v==="vertical"&&(b=a[(f-1+a.length)%a.length]),n.key==="Home"&&(b=a[0]),n.key==="End"&&(b=a[a.length-1]),b&&(n.preventDefault(),e.select(b,!0))};i.tablist.addEventListener("click",l),i.tablist.addEventListener("keydown",m),e._destroy=()=>{i.tablist.removeEventListener("click",l),i.tablist.removeEventListener("keydown",m),d.delete(e),delete e.refresh,delete e.select},e.dataset.tabsInitialized="true",e.dispatchEvent(new CustomEvent("basecoat:initialized"))};window.basecoat&&window.basecoat.register("tabs",{selector:".tabs:not([data-tabs-initialized])",init:s,refresh:p})})(),(()=>{var d=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const s=this.root?this.snapshot():void 0;this.teardown(),this.setup(s)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(s){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=e=>{e.target!==this.root||!this.constructor.relayNative&&!(e instanceof CustomEvent)||(e.stopPropagation(),this._silent||this.emit(e.type,{value:this.value}))};for(const e of this.constructor.relayed)this.root.addEventListener(e,this._relay);this.attach?.(),s!==void 0?this.restore(s):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const s of this.constructor.relayed)this.root.removeEventListener(s,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(s,e)=>e.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const s=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,s!==null&&(this.value=s)}snapshot(){return this.value}restore(s){s!==null&&(this.value=s)}attributeChangedCallback(s,e,i){s==="value"&&this.root&&i!==null&&i!==this.value&&(this.value=i)}defer(s){return this.root?!1:(this._pending=s,!0)}silently(s){this._silent=!0;try{s()}finally{this._silent=!1}}emit(s,e){this.dispatchEvent(new CustomEvent(s,{detail:e,bubbles:!0}))}reportValue(){const s=this.value;JSON.stringify(s)!==JSON.stringify(this._last)&&(this._last=s,this._silent||this.emit("change",{value:s}))}};function u(s,e,i,h=!0){const l=new MutationObserver(i);return l.observe(s,{attributes:!0,attributeFilter:e,subtree:h}),()=>l.disconnect()}var E=s=>s.dataset.value??s.id,p=class extends d{static component="tabs";static rootSelector=".tabs";attach(){this._last=this.value,this._unwatch=u(this.root,["aria-selected"],()=>this.reportValue())}detach(){this._unwatch?.()}get value(){const s=this.root?.querySelector('[role="tab"][aria-selected="true"]');return s?E(s):null}set value(s){if(this.defer(s))return;const e=[...this.root.querySelectorAll('[role="tab"]')].find(i=>E(i)===String(s));!e||!this.root.select||(this.root.select(e),this._last=this.value)}};customElements.get("auvyx-tabs")||customElements.define("auvyx-tabs",p)})();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*! @auvyx/ui v0.1.0 | MIT | based on Basecoat (MIT) */
|
|
2
|
+
window.basecoat||(()=>{const r={};let c=null;const o=(t,i,n)=>{const a=typeof i=="object"?i:{selector:i,init:n};r[t]={selector:a.selector,init:a.init,refresh:a.refresh}},d=(t,i)=>{const n=r[i];if(n)try{n.init(t),t.hasAttribute(`data-${i}-initialized`)&&(t.dataset.basecoatComponent=i)}catch(a){if(console.error(`Failed to initialize ${i}:`,a),typeof t._destroy=="function")try{t._destroy()}catch(h){console.error(`Failed to clean up ${i} after initialization error:`,h)}delete t._destroy,t.removeAttribute(`data-${i}-initialized`),delete t.dataset.basecoatComponent}},p=t=>{if(!t||t.nodeType!==Node.ELEMENT_NODE)return;const i=t.dataset?.basecoatComponent;if(typeof t._destroy=="function")try{t._destroy()}catch(n){console.error("Failed to destroy Basecoat component:",n)}delete t._destroy,i&&t.removeAttribute(`data-${i}-initialized`),delete t.dataset.basecoatComponent},y=t=>{t.nodeType===Node.ELEMENT_NODE&&(t.isConnected||(t.dataset?.basecoatComponent&&p(t),t.querySelectorAll("[data-basecoat-component]").forEach(p)))},E=t=>Array.from(new Set(t)),b=(t,i,n=!1)=>{const a=Array.from(document.querySelectorAll(i));return n&&a.push(...document.querySelectorAll(`[data-basecoat-component="${t}"]`)),E(a)},v=(t={})=>{const i=t.force===!0;Object.entries(r).forEach(([n,{selector:a}])=>{b(n,a,i).forEach(h=>{const w=h.dataset?.basecoatComponent===n;i&&p(h),(w||h.matches(a))&&d(h,n)})})},g=t=>{t.nodeType===Node.ELEMENT_NODE&&Object.entries(r).forEach(([i,{selector:n}])=>{t.matches(n)&&d(t,i),t.querySelectorAll(n).forEach(a=>d(a,i))})},C=t=>{if(!t)return;if(typeof t.refresh=="function"){t.refresh();return}const i=t.dataset?.basecoatComponent,n=i?r[i]:null;n?.refresh&&n.refresh(t)},e=()=>{c||(c=new MutationObserver(t=>{t.forEach(i=>{i.addedNodes.forEach(g),i.removedNodes.forEach(y)})}),c.observe(document.body,{childList:!0,subtree:!0}))},s=()=>{c&&(c.disconnect(),c=null)},l=(t,i={})=>{const n=r[t];if(!n){console.warn(`Component '${t}' not found in registry`);return}const a=i.force===!0;b(t,n.selector,a).forEach(h=>{const w=h.dataset?.basecoatComponent===t;a&&p(h),(w||h.matches(n.selector))&&d(h,t)})},u=(t={})=>{v(t)},f=t=>{const i=t==="dark";document.documentElement.classList.toggle("dark",i);try{localStorage.setItem("themeMode",i?"dark":"light")}catch{}document.dispatchEvent(new CustomEvent("basecoat:themechange",{detail:{mode:i?"dark":"light"}}))},m=()=>document.documentElement.classList.contains("dark")?"dark":"light";window.basecoat={register:o,init:l,initAll:u,refresh:C,start:e,stop:s,theme:{get:m,set:f,toggle:()=>f(m()==="dark"?"light":"dark")}},document.addEventListener("DOMContentLoaded",()=>{v(),e()})})(),(()=>{let r;const c=new WeakMap;let o=!1;const d={success:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',error:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>',info:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',warning:'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>'};function p(e){if(e.dataset.toasterInitialized)return;r=e;const s=l=>{const u=l.target.closest(".toast footer a"),f=l.target.closest(".toast footer button");(u||f)&&v(l.target.closest(".toast"))};r.addEventListener("mouseenter",E),r.addEventListener("mouseleave",b),r.addEventListener("click",s),e.toast=(l={})=>{const u=C(l);return e.appendChild(u),y(u),u},e.closeAll=()=>{e.querySelectorAll('.toast:not([aria-hidden="true"])').forEach(v)},r.querySelectorAll(".toast:not([data-toast-initialized])").forEach(y),r._destroy=()=>{r.removeEventListener("mouseenter",E),r.removeEventListener("mouseleave",b),r.removeEventListener("click",s),r.querySelectorAll(".toast[data-toast-initialized]").forEach(l=>l._destroy?.()),delete r.toast,delete r.closeAll,r===e&&(r=null)},r.dataset.toasterInitialized="true",r.dispatchEvent(new CustomEvent("basecoat:initialized"))}function y(e){if(e.dataset.toastInitialized)return;const s=parseInt(e.dataset.duration),l=s!==-1?s||(e.dataset.category==="error"?5e3:3e3):-1,u={remainingTime:l,timeoutId:null,startTime:null};l!==-1&&(o?u.timeoutId=null:(u.startTime=Date.now(),u.timeoutId=setTimeout(()=>v(e),l))),c.set(e,u),e.close=()=>v(e),e._destroy=()=>{clearTimeout(u.timeoutId),c.delete(e),delete e.close},e.dataset.toastInitialized="true"}function E(){o||!r||(o=!0,r.querySelectorAll('.toast:not([aria-hidden="true"])').forEach(e=>{if(!c.has(e))return;const s=c.get(e);s.timeoutId&&(clearTimeout(s.timeoutId),s.timeoutId=null,s.remainingTime-=Date.now()-s.startTime)}))}function b(){!o||!r||(o=!1,r.querySelectorAll('.toast:not([aria-hidden="true"])').forEach(e=>{if(!c.has(e))return;const s=c.get(e);s.remainingTime!==-1&&!s.timeoutId&&(s.remainingTime>0?(s.startTime=Date.now(),s.timeoutId=setTimeout(()=>v(e),s.remainingTime)):v(e))}))}function v(e){if(!e||!c.has(e))return;const s=c.get(e);clearTimeout(s.timeoutId),c.delete(e),e.contains(document.activeElement)&&document.activeElement.blur(),e.setAttribute("aria-hidden","true"),e.addEventListener("transitionend",()=>e.remove(),{once:!0})}const g=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function C(e){const{category:s="info",title:l,description:u,action:f,cancel:m,duration:t,icon:i,html:n=!1}=e,a=$=>n?String($):g($),h=i||s&&d[s]||"",w=l?`<h2>${a(l)}</h2>`:"",A=u?`<p>${a(u)}</p>`:"",k=f?.href?`<a href="${g(f.href)}" class="btn" data-toast-action>${a(f.label)}</a>`:f?.onclick?`<button type="button" class="btn" data-toast-action onclick="${g(f.onclick)}">${a(f.label)}</button>`:"",T=m?`<button type="button" class="btn h-6 text-xs px-2.5 rounded-sm" data-variant="outline" data-toast-cancel onclick="${g(m?.onclick||"")}">${a(m.label)}</button>`:"",L=k||T?`<footer>${k}${T}</footer>`:"",S=`
|
|
3
|
+
<div
|
|
4
|
+
class="toast"
|
|
5
|
+
role="${s==="error"?"alert":"status"}"
|
|
6
|
+
aria-atomic="true"
|
|
7
|
+
${s?`data-category="${g(s)}"`:""}
|
|
8
|
+
${t!==void 0?`data-duration="${g(t)}"`:""}
|
|
9
|
+
>
|
|
10
|
+
<div class="toast-content">
|
|
11
|
+
${h}
|
|
12
|
+
<section>
|
|
13
|
+
${w}
|
|
14
|
+
${A}
|
|
15
|
+
</section>
|
|
16
|
+
${L}
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
`,_=document.createElement("template");return _.innerHTML=S.trim(),_.content.firstChild}window.basecoat&&(window.basecoat.register("toaster","#toaster:not([data-toaster-initialized])",p),window.basecoat.register("toast",".toast:not([data-toast-initialized])",y))})(),(()=>{var r=class extends HTMLElement{static observedAttributes=["value"];static relayed=["change"];static relayNative=!1;connectedCallback(){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this.setup(),this._children=new MutationObserver(()=>{if(this.querySelector(`:scope > ${this.constructor.rootSelector}`)===this.root)return;const o=this.root?this.snapshot():void 0;this.teardown(),this.setup(o)}),this._children.observe(this,{childList:!0})}disconnectedCallback(){this._children?.disconnect(),this.teardown()}setup(o){if(this.root=this.querySelector(`:scope > ${this.constructor.rootSelector}`),!!this.root){window.basecoat?.init(this.constructor.component),this._relay=d=>{d.target!==this.root||!this.constructor.relayNative&&!(d instanceof CustomEvent)||(d.stopPropagation(),this._silent||this.emit(d.type,{value:this.value}))};for(const d of this.constructor.relayed)this.root.addEventListener(d,this._relay);this.attach?.(),o!==void 0?this.restore(o):this.applyInitial()}}teardown(){if(this.detach?.(),!!this.root){for(const o of this.constructor.relayed)this.root.removeEventListener(o,this._relay);this.root._destroy?.(),delete this.root.dataset[`${this.constructor.component.replace(/-(\w)/g,(o,d)=>d.toUpperCase())}Initialized`],this.root=null}}applyInitial(){const o=this._pending!==void 0?this._pending:this.getAttribute("value");this._pending=void 0,o!==null&&(this.value=o)}snapshot(){return this.value}restore(o){o!==null&&(this.value=o)}attributeChangedCallback(o,d,p){o==="value"&&this.root&&p!==null&&p!==this.value&&(this.value=p)}defer(o){return this.root?!1:(this._pending=o,!0)}silently(o){this._silent=!0;try{o()}finally{this._silent=!1}}emit(o,d){this.dispatchEvent(new CustomEvent(o,{detail:d,bubbles:!0}))}reportValue(){const o=this.value;JSON.stringify(o)!==JSON.stringify(this._last)&&(this._last=o,this._silent||this.emit("change",{value:o}))}},c=class extends r{static component="toaster";static rootSelector=".toaster";static relayed=[];static observedAttributes=[];applyInitial(){}restore(){}get value(){return null}toast(o){return this.root?.toast?.(o)}};customElements.get("auvyx-toaster")||customElements.define("auvyx-toaster",c)})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auvyx/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Drop-in CSS design system (shadcn look, Basecoat-based). One CSS file, optional tiny JS.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"style": "dist/auvyx.min.css",
|
|
8
|
+
"main": "dist/auvyx.min.css",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/auvyx.min.css",
|
|
14
|
+
"./css": "./dist/auvyx.min.css",
|
|
15
|
+
"./auvyx.css": "./dist/auvyx.css",
|
|
16
|
+
"./js": "./dist/auvyx.min.js",
|
|
17
|
+
"./auvyx.js": "./dist/auvyx.js",
|
|
18
|
+
"./bundle": "./dist/auvyx.bundle.css",
|
|
19
|
+
"./chart": "./dist/auvyx.chart.min.js",
|
|
20
|
+
"./corners": "./dist/auvyx.corners.min.js",
|
|
21
|
+
"./elements/*": "./dist/elements/*.min.js",
|
|
22
|
+
"./js/*": "./dist/js/*.min.js",
|
|
23
|
+
"./wc/*": "./dist/wc/*.min.js",
|
|
24
|
+
"./auvyx.bundle.css": "./dist/auvyx.bundle.css",
|
|
25
|
+
"./custom-elements.json": "./dist/custom-elements.json",
|
|
26
|
+
"./types": {
|
|
27
|
+
"types": "./dist/types/elements.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./types/react": {
|
|
30
|
+
"types": "./dist/types/react.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./types/vue": {
|
|
33
|
+
"types": "./dist/types/vue.d.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node ./build.mjs",
|
|
38
|
+
"deps": "node ./tools/ui-deps.mjs",
|
|
39
|
+
"prepublishOnly": "node ./build.mjs"
|
|
40
|
+
},
|
|
41
|
+
"customElements": "dist/custom-elements.json",
|
|
42
|
+
"types": "dist/types/elements.d.ts",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/lamtanloc512/basecoat.git",
|
|
46
|
+
"directory": "packages/ui"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://auvyx-ui.vercel.app",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/lamtanloc512/basecoat/issues"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"css",
|
|
54
|
+
"design system",
|
|
55
|
+
"shadcn",
|
|
56
|
+
"tailwind",
|
|
57
|
+
"html",
|
|
58
|
+
"components",
|
|
59
|
+
"web components"
|
|
60
|
+
],
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
}
|
|
64
|
+
}
|