@adia-ai/web-components 0.7.21 → 0.7.23

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.
@@ -56,7 +56,7 @@ ${i.join(`
56
56
  '../node_modules/@phosphor-icons/core/assets/regular/*.svg',
57
57
  { query: '?raw', import: 'default', eager: true }
58
58
  ),
59
- });`),Bl(zu)):import("./icons-manifest.js").then(({default:t})=>{let{cdn:e,...i}=t,n=Object.fromEntries(Object.entries(i).map(([r,o])=>{let a=e?`${e}${r}/`:`/node_modules/@phosphor-icons/core/assets/${r}/`,l=o.map(h=>{let c=a+h;return[c,()=>fetch(c).then(d=>d.ok?d.text():Promise.reject(new Error(`icon fetch failed: ${c}`)))]});return[r,Object.fromEntries(l)]}));Bl(n)}).catch(()=>{});var JO=new WeakSet,ga=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!JO.has(e)&&e!==s&&(JO.add(e),e.schema||console.warn(`AdiaUI: ${e.name} extends BaseController without static schema`),this.getState===s.prototype.getState&&console.error(`AdiaUI: ${e.schema?.name??e.name} must implement getState()`)),this.#t&&this.#t!==t&&console.warn(`AdiaUI: ${e.schema?.name??e.name} already connected to a different host`),this.#t=t,this.onConnect(t),this.reflect()}disconnect(t){let e=t??this.#t;e&&(this.onDisconnect(e),this.#t=null)}subscribe(t){return this.#e.add(t),()=>this.#e.delete(t)}notify(){this.reflect();for(let t of this.#e)t()}onConnect(t){}onDisconnect(t){}reflect(){}getState(){throw new Error(`${this.constructor.schema?.name??this.constructor.name}: getState() not implemented`)}},tb=class extends ga{static schema={name:"route",state:{path:"string",params:"object",route:"object",previous:"string"},commands:["navigate","replace","back","forward","setRoutes"],attributes:["data-route-path"]};#t=[];#e="";#i="";#s={};#n=null;#r=!0;#a=null;constructor({routes:t=[],initial:e,historySync:i=!0}={}){super(),this.#t=t,this.#r=i,this.#e=e??location.pathname,this.#o()}getState(){return{path:this.#e,params:{...this.#s},route:this.#n,previous:this.#i}}reflect(){let t=this.host;t&&t.setAttribute("data-route-path",this.#e)}onConnect(t){this.#r&&(this.#a=()=>{this.#i=this.#e,this.#e=location.pathname,this.#o(),this.notify()},window.addEventListener("popstate",this.#a))}onDisconnect(){this.#a&&(window.removeEventListener("popstate",this.#a),this.#a=null)}#o(){this.#s={},this.#n=null;for(let t of this.#t){let e=this.#l(t.path,this.#e);if(e){this.#s=e.params,this.#n=t;return}}}#l(t,e){let i=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(!t.includes(":"))return t===e?{params:{}}:null;if(i.length!==n.length)return null;let r={};for(let o=0;o<i.length;o++)if(i[o].startsWith(":"))r[i[o].slice(1)]=n[o];else if(i[o]!==n[o])return null;return{params:r}}commands={navigate:t=>{t!==this.#e&&(this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.pushState(null,"",t),this.notify())},replace:t=>{this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.replaceState(null,"",t),this.notify()},back:()=>{this.#r&&history.back()},forward:()=>{this.#r&&history.forward()},setRoutes:t=>{this.#t=t,this.#o(),this.notify()}}};P();var Hu=class extends k{static template=()=>null;#t=null;get abort(){return this.#t||(this.#t=new AbortController),this.#t}get signal(){return this.abort.signal}emit(t,e){this.dispatchEvent(e!==void 0?new CustomEvent(t,{bubbles:!0,detail:e}):new Event(t,{bubbles:!0}))}disconnected(){this.#t?.abort(),this.#t=null}},Ku=class extends ga{static schema={name:"route",state:{path:"string",params:"object",route:"object",previous:"string"},commands:["navigate","replace","back","forward","setRoutes"],attributes:["data-route-path"]};#t=[];#e="";#i="";#s={};#n=null;#r=!0;#a=null;constructor({routes:t=[],initial:e,historySync:i=!0}={}){super(),this.#t=t,this.#r=i,this.#e=e??location.pathname,this.#o()}getState(){return{path:this.#e,params:{...this.#s},route:this.#n,previous:this.#i}}reflect(){let t=this.host;t&&t.setAttribute("data-route-path",this.#e)}onConnect(t){this.#r&&(this.#a=()=>{this.#i=this.#e,this.#e=location.pathname,this.#o(),this.notify()},window.addEventListener("popstate",this.#a))}onDisconnect(){this.#a&&(window.removeEventListener("popstate",this.#a),this.#a=null)}#o(){this.#s={},this.#n=null;for(let t of this.#t){let e=this.#l(t.path,this.#e);if(e){this.#s=e.params,this.#n=t;return}}}#l(t,e){let i=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(!t.includes(":"))return t===e?{params:{}}:null;if(i.length!==n.length)return null;let r={};for(let o=0;o<i.length;o++)if(i[o].startsWith(":"))r[i[o].slice(1)]=n[o];else if(i[o]!==n[o])return null;return{params:r}}commands={navigate:t=>{t!==this.#e&&(this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.pushState(null,"",t),this.notify())},replace:t=>{this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.replaceState(null,"",t),this.notify()},back:()=>{this.#r&&history.back()},forward:()=>{this.#r&&history.forward()},setRoutes:t=>{this.#t=t,this.#o(),this.notify()}}},Ju=class extends Hu{#t=new Map;#e=null;#i=null;get#s(){return this.#e||this.controller}set routes(t){this.#e?this.#e.commands.setRoutes(t):(this.#e=new Ku({routes:t}),this.controller=this.#e,this.#e.notify())}navigate(t){this.#s?.commands.navigate(t)}replace(t){this.#s?.commands.replace(t)}connected(){super.connected(),document.addEventListener("click",this.#n)}disconnected(){super.disconnected(),document.removeEventListener("click",this.#n)}#n=t=>{let e=this.#s;if(!e)return;let i=t.target.closest("a[href]");if(!i||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||i.target&&i.target!=="_self")return;let n=i.getAttribute("href");n.startsWith("http")||n.startsWith("//")||n.startsWith("#")||(t.preventDefault(),e.commands.navigate(n))};render(){let t=this.#s;if(!t)return;let{path:e,route:i}=t.getState();e!==this.#i&&(this.#i=e,i?.content&&this.#r(i,t))}async#r(t,e){let i;if(this.#t.has(t.content))i=this.#t.get(t.content);else try{let r=await fetch(t.content,{signal:this.signal});if(!r.ok)return;i=await r.text(),this.#t.set(t.content,i)}catch(r){r.name!=="AbortError"&&console.error("Router fetch error:",r);return}this.templateResolver&&(i=await this.templateResolver(i,t)),this.innerHTML=i;for(let r of this.querySelectorAll("script")){let o=r.getAttribute("type")||"";if(o==="application/json"||o==="application/ld+json")continue;let a=document.createElement("script");o&&(a.type=o),r.src?a.src=r.src:a.textContent=r.textContent,r.replaceWith(a)}if(this.scrollTo(0,0),(this.closest("section")||this.parentElement)?.scrollTo(0,0),t.title&&(document.title=t.title),t.content?.endsWith(".content.html")){let r=t.content.replace(".content.html",".setup.js");try{let o=await import(r);o.default&&o.default(this)}catch{}}let n=e.getState();this.emit("route-loaded",{path:n.path,params:n.params,title:t.title||"",section:t.section||""})}};customElements.define("router-ui",Ju);function BI(s,t){customElements.define(s,t)}function x(s,t){return customElements.get(s)?!1:(customElements.define(s,t),!0)}function zI(s){return!!customElements.get(s)}P();var tn=class extends k{static properties={name:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},weight:{type:String,default:"regular",reflect:!0}};#t=this.signal(0);#e=null;connected(){this.setAttribute("role",this.label?"img":"presentation"),this.label||this.setAttribute("aria-hidden","true"),this.#e=new AbortController;let t=this.#e;Nl.then(()=>{t.signal.aborted||this.#t.value++})}disconnected(){this.#e?.abort(),this.#e=null}render(){this.#t.value,this.label&&this.setAttribute("aria-label",this.label);let t=ZO(this.name,this.weight||"regular");t&&this.innerHTML!==t&&(this.innerHTML=t),this.size&&this.#i(this.size)?this.style.setProperty("--icon-size",this.#s(this.size)):this.style.getPropertyValue("--icon-size")&&this.style.removeProperty("--icon-size")}#i(t){return/^\d+(\.\d+)?(px|rem|em)?$/.test(t)}#s(t){return/^\d+(\.\d+)?$/.test(t)?`${t}px`:t}};x("icon-ui",tn);P();var SA={plus:["+","\uFF0B"],minus:["-","\u2212","\u2013"],x:["\xD7","x ","X "],check:["\u2713","\u2714"],"arrow-right":["\u2192",">"],"arrow-left":["\u2190","<"]},en=class s extends k{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"solid",reflect:!0},color:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},stretch:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0},iconTrailing:{type:String,default:"",reflect:!0,attribute:"icon-trailing"},type:{type:String,default:"button",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let t=this.querySelector(":scope > icon-ui:not([slot])");if(!t||t.name!==this.icon){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),this.prepend(e)}}if(this.iconTrailing){let t=this.querySelector(':scope > icon-ui[slot="icon-trailing"]');if(!t||t.name!==this.iconTrailing){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.iconTrailing),e.setAttribute("slot","icon-trailing"),this.appendChild(e)}}if(this.icon&&this.text){let t=SA[this.icon];t&&t.some(e=>this.text.startsWith(e))&&(s.#e.has(this)||(s.#e.add(this),console.warn(`[button-ui] text="${this.text}" begins with a symbol that icon="${this.icon}" already renders \u2014 the glyph appears twice. Drop the leading symbol from text= (the icon provides it).`,this)))}if(this.icon&&!this.text){let t=this.getAttribute("aria-label"),e=this.getAttribute("aria-labelledby"),i=this.getAttribute("title");!t&&!e&&i?this.setAttribute("aria-label",i):!t&&!e&&!i&&(s.#t.has(this)||(s.#t.add(this),console.warn(`[button-ui] Icon-only button is missing an accessible name.
59
+ });`),Bl(zu)):import("./icons-manifest.js").then(({default:t})=>{let{cdn:e,...i}=t,n=Object.fromEntries(Object.entries(i).map(([r,o])=>{let a=e?`${e}${r}/`:`/node_modules/@phosphor-icons/core/assets/${r}/`,l=o.map(h=>{let c=a+h;return[c,()=>fetch(c).then(d=>d.ok?d.text():Promise.reject(new Error(`icon fetch failed: ${c}`)))]});return[r,Object.fromEntries(l)]}));Bl(n)}).catch(()=>{});var JO=new WeakSet,ga=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!JO.has(e)&&e!==s&&(JO.add(e),e.schema||console.warn(`AdiaUI: ${e.name} extends BaseController without static schema`),this.getState===s.prototype.getState&&console.error(`AdiaUI: ${e.schema?.name??e.name} must implement getState()`)),this.#t&&this.#t!==t&&console.warn(`AdiaUI: ${e.schema?.name??e.name} already connected to a different host`),this.#t=t,this.onConnect(t),this.reflect()}disconnect(t){let e=t??this.#t;e&&(this.onDisconnect(e),this.#t=null)}subscribe(t){return this.#e.add(t),()=>this.#e.delete(t)}notify(){this.reflect();for(let t of this.#e)t()}onConnect(t){}onDisconnect(t){}reflect(){}getState(){throw new Error(`${this.constructor.schema?.name??this.constructor.name}: getState() not implemented`)}},tb=class extends ga{static schema={name:"route",state:{path:"string",params:"object",route:"object",previous:"string"},commands:["navigate","replace","back","forward","setRoutes"],attributes:["data-route-path"]};#t=[];#e="";#i="";#s={};#n=null;#r=!0;#a=null;constructor({routes:t=[],initial:e,historySync:i=!0}={}){super(),this.#t=t,this.#r=i,this.#e=e??location.pathname,this.#o()}getState(){return{path:this.#e,params:{...this.#s},route:this.#n,previous:this.#i}}reflect(){let t=this.host;t&&t.setAttribute("data-route-path",this.#e)}onConnect(t){this.#r&&(this.#a=()=>{this.#i=this.#e,this.#e=location.pathname,this.#o(),this.notify()},window.addEventListener("popstate",this.#a))}onDisconnect(){this.#a&&(window.removeEventListener("popstate",this.#a),this.#a=null)}#o(){this.#s={},this.#n=null;for(let t of this.#t){let e=this.#l(t.path,this.#e);if(e){this.#s=e.params,this.#n=t;return}}}#l(t,e){let i=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(!t.includes(":"))return t===e?{params:{}}:null;if(i.length!==n.length)return null;let r={};for(let o=0;o<i.length;o++)if(i[o].startsWith(":"))r[i[o].slice(1)]=n[o];else if(i[o]!==n[o])return null;return{params:r}}commands={navigate:t=>{t!==this.#e&&(this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.pushState(null,"",t),this.notify())},replace:t=>{this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.replaceState(null,"",t),this.notify()},back:()=>{this.#r&&history.back()},forward:()=>{this.#r&&history.forward()},setRoutes:t=>{this.#t=t,this.#o(),this.notify()}}};P();var Hu=class extends k{static template=()=>null;#t=null;get abort(){return this.#t||(this.#t=new AbortController),this.#t}get signal(){return this.abort.signal}emit(t,e){this.dispatchEvent(e!==void 0?new CustomEvent(t,{bubbles:!0,detail:e}):new Event(t,{bubbles:!0}))}disconnected(){this.#t?.abort(),this.#t=null}},Ku=class extends ga{static schema={name:"route",state:{path:"string",params:"object",route:"object",previous:"string"},commands:["navigate","replace","back","forward","setRoutes"],attributes:["data-route-path"]};#t=[];#e="";#i="";#s={};#n=null;#r=!0;#a=null;constructor({routes:t=[],initial:e,historySync:i=!0}={}){super(),this.#t=t,this.#r=i,this.#e=e??location.pathname,this.#o()}getState(){return{path:this.#e,params:{...this.#s},route:this.#n,previous:this.#i}}reflect(){let t=this.host;t&&t.setAttribute("data-route-path",this.#e)}onConnect(t){this.#r&&(this.#a=()=>{this.#i=this.#e,this.#e=location.pathname,this.#o(),this.notify()},window.addEventListener("popstate",this.#a))}onDisconnect(){this.#a&&(window.removeEventListener("popstate",this.#a),this.#a=null)}#o(){this.#s={},this.#n=null;for(let t of this.#t){let e=this.#l(t.path,this.#e);if(e){this.#s=e.params,this.#n=t;return}}}#l(t,e){let i=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(!t.includes(":"))return t===e?{params:{}}:null;if(i.length!==n.length)return null;let r={};for(let o=0;o<i.length;o++)if(i[o].startsWith(":"))r[i[o].slice(1)]=n[o];else if(i[o]!==n[o])return null;return{params:r}}commands={navigate:t=>{t!==this.#e&&(this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.pushState(null,"",t),this.notify())},replace:t=>{this.#i=this.#e,this.#e=t,this.#o(),this.#r&&history.replaceState(null,"",t),this.notify()},back:()=>{this.#r&&history.back()},forward:()=>{this.#r&&history.forward()},setRoutes:t=>{this.#t=t,this.#o(),this.notify()}}},Ju=class extends Hu{#t=new Map;#e=null;#i=null;get#s(){return this.#e||this.controller}set routes(t){this.#e?this.#e.commands.setRoutes(t):(this.#e=new Ku({routes:t}),this.controller=this.#e,this.#e.notify())}navigate(t){this.#s?.commands.navigate(t)}replace(t){this.#s?.commands.replace(t)}connected(){super.connected(),document.addEventListener("click",this.#n)}disconnected(){super.disconnected(),document.removeEventListener("click",this.#n)}#n=t=>{let e=this.#s;if(!e)return;let i=t.target.closest("a[href]");if(!i||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||i.target&&i.target!=="_self")return;let n=i.getAttribute("href");n.startsWith("http")||n.startsWith("//")||n.startsWith("#")||(t.preventDefault(),e.commands.navigate(n))};render(){let t=this.#s;if(!t)return;let{path:e,route:i}=t.getState();e!==this.#i&&(this.#i=e,i?.content&&this.#r(i,t))}async#r(t,e){let i;if(this.#t.has(t.content))i=this.#t.get(t.content);else try{let r=await fetch(t.content,{signal:this.signal});if(!r.ok)return;i=await r.text(),this.#t.set(t.content,i)}catch(r){r.name!=="AbortError"&&console.error("Router fetch error:",r);return}this.templateResolver&&(i=await this.templateResolver(i,t)),this.innerHTML=i;for(let r of this.querySelectorAll("script")){let o=r.getAttribute("type")||"";if(o==="application/json"||o==="application/ld+json")continue;let a=document.createElement("script");o&&(a.type=o),r.src?a.src=r.src:a.textContent=r.textContent,r.replaceWith(a)}if(this.scrollTo(0,0),(this.closest("section")||this.parentElement)?.scrollTo(0,0),t.title&&(document.title=t.title),t.content?.endsWith(".content.html")){let r=t.content.replace(".content.html",".setup.js");try{let o=await import(r);o.default&&o.default(this)}catch{}}let n=e.getState();this.emit("route-loaded",{path:n.path,params:n.params,title:t.title||"",section:t.section||""})}};customElements.define("router-ui",Ju);function BI(s,t){customElements.define(s,t)}function x(s,t){return customElements.get(s)?!1:(customElements.define(s,t),!0)}function zI(s){return!!customElements.get(s)}P();var tn=class extends k{static properties={name:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},weight:{type:String,default:"regular",reflect:!0}};#t=this.signal(0);#e=null;connected(){this.setAttribute("role",this.label?"img":"presentation"),this.label||this.setAttribute("aria-hidden","true"),this.#e=new AbortController;let t=this.#e;Nl.then(()=>{t.signal.aborted||this.#t.value++})}disconnected(){this.#e?.abort(),this.#e=null}render(){this.#t.value,this.label&&this.setAttribute("aria-label",this.label);let t=ZO(this.name,this.weight||"regular");t&&this.innerHTML!==t&&(this.innerHTML=t),this.size&&this.#i(this.size)?this.style.setProperty("--icon-size",this.#s(this.size)):this.style.getPropertyValue("--icon-size")&&this.style.removeProperty("--icon-size")}#i(t){return/^\d+(\.\d+)?(px|rem|em)?$/.test(t)}#s(t){return/^\d+(\.\d+)?$/.test(t)?`${t}px`:t}};x("icon-ui",tn);P();var SA={plus:["+","\uFF0B"],minus:["-","\u2212","\u2013"],x:["\xD7","x ","X "],check:["\u2713","\u2714"],"arrow-right":["\u2192",">"],"arrow-left":["\u2190","<"]},en=class s extends k{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"solid",reflect:!0},color:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},stretch:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0},iconTrailing:{type:String,default:"",reflect:!0,attribute:"icon-trailing"},type:{type:String,default:"button",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let e=this.querySelector(":scope > icon-ui:not([slot])");if(!e||e.name!==this.icon){e&&e.remove();let i=document.createElement("icon-ui");i.setAttribute("name",this.icon),this.prepend(i)}}if(this.iconTrailing){let e=this.querySelector(':scope > icon-ui[slot="icon-trailing"]');if(!e||e.name!==this.iconTrailing){e&&e.remove();let i=document.createElement("icon-ui");i.setAttribute("name",this.iconTrailing),i.setAttribute("slot","icon-trailing"),this.appendChild(i)}}let t=Array.from(this.childNodes).some(e=>e.nodeType===3&&e.textContent.trim()!=="");if(this.toggleAttribute("data-icon-only",!this.text&&!t),this.icon&&this.text){let e=SA[this.icon];e&&e.some(i=>this.text.startsWith(i))&&(s.#e.has(this)||(s.#e.add(this),console.warn(`[button-ui] text="${this.text}" begins with a symbol that icon="${this.icon}" already renders \u2014 the glyph appears twice. Drop the leading symbol from text= (the icon provides it).`,this)))}if(this.icon&&!this.text&&!t){let e=this.getAttribute("aria-label"),i=this.getAttribute("aria-labelledby"),n=this.getAttribute("title");!e&&!i&&n?this.setAttribute("aria-label",n):!e&&!i&&!n&&(s.#t.has(this)||(s.#t.add(this),console.warn(`[button-ui] Icon-only button is missing an accessible name.
60
60
  Element: <button-ui icon="${this.icon}">
61
61
  Add one of:
62
62
  aria-label="Undo" \u2190 explicit accessible name