@adia-ai/web-components 0.6.42 → 0.6.43
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/CHANGELOG.md +16 -0
- package/components/alert/alert.css +7 -1
- package/components/button/button.a2ui.json +5 -0
- package/components/button/button.class.js +13 -1
- package/components/button/button.css +13 -1
- package/components/button/button.yaml +4 -0
- package/components/card/card.css +36 -7
- package/components/list/list.a2ui.json +5 -0
- package/components/list/list.d.ts +7 -0
- package/components/list/list.yaml +9 -0
- package/dist/web-components.min.css +1 -1
- package/dist/web-components.min.js +1 -1
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ var z1=Object.defineProperty;var W=(s,t)=>()=>(s&&(t=s(s=0)),t);var Jt=(s,t)=>{f
|
|
|
46
46
|
`+c+" Compute the full attr value as a single expression and interpolate the whole.")}continue}let a=+o[1],l=r.name;l[0]==="@"?(n.removeAttribute(l),e[a]={t:"e",n,name:l.slice(1),c:void 0,_fx:null}):l[0]==="."?(n.removeAttribute(l),e[a]={t:"p",n,name:MO(n,l.slice(1)),c:void 0,_fx:null,_resolved:!1}):l[0]==="?"?(n.removeAttribute(l),console.warn(`[template] Lit-style boolean attribute "${l}=" is not supported.
|
|
47
47
|
Element: <${n.tagName.toLowerCase()}>
|
|
48
48
|
Use .${l.slice(1)}=\${value} (property binding) instead \u2014 the primitive reflects the property to the DOM attribute for you.
|
|
49
|
-
See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),e[a]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):e[a]={t:"a",n,name:l,c:void 0,_fx:null}}return e}function Dl(s){for(let t of s)t&&t._fx&&(t._fx(),t._fx=null)}function qu(s){if(s.n.nodeType===1&&s.n[Zu])return s.n;let t=document.createElement("span");return t.style.display="contents",t[Zu]=!0,s.n.replaceWith(t),s.n=t,t}var XO=s=>s!=null&&typeof s=="object"&&s.strings,DO=s=>typeof s=="function"||s!=null&&typeof s.handleEvent=="function";function Nu(s,t){if(t!==s.c){if(s.t==="n")if(t!=null&&t._directive)t._commit(qu(s));else if(XO(t))Fs(t,qu(s));else if(Array.isArray(t)){let e=qu(s);e.replaceChildren();for(let i of t)if(XO(i)){let n=document.createElement("span");n.style.display="contents",e.appendChild(n),Fs(i,n)}else e.appendChild(document.createTextNode(i??""))}else if(t instanceof Node)s.n.replaceWith(t),s.n=t;else if(s.n[Zu]){let e=document.createTextNode(t??"");s.n.replaceWith(e),s.n=e}else s.n.textContent=t??"";else if(s.t==="a")t==null||t===!1?s.n.removeAttribute(s.name):s.n.setAttribute(s.name,t===!0?"":t);else if(s.t==="p"){if(!s._resolved){let e=MO(s.n,s.name);e!==s.name&&(s.name=e),s._resolved=!0}s.n[s.name]=t}else s.t==="e"&&(DO(s.c)&&s.n.removeEventListener(s.name,s.c),DO(t)&&s.n.addEventListener(s.name,t));s.c=t}}function eA(s,t){for(let e=0;e<s.length;e++){let i=s[e];if(!i)continue;let n=t[e],r=i.t!=="e"&&typeof n=="function",o=!r&&i.t!=="e"&&Du(n);if(i._fx&&!r&&!o&&(i._fx(),i._fx=null),r){i._fx||(i._fx=ss(()=>Nu(i,n())));continue}if(o){i._fx||(i._fx=ss(()=>Nu(i,n.value)));continue}Nu(i,n)}}function iA(s,t,e){return{_directive:!0,_commit(i){let n=i[Gs]||new Map,r=new Map,o=[];for(let l=0;l<s.length;l++){let h=t(s[l],l);if(r.has(h))continue;o.push(h);let c=e(s[l],l);if(n.has(h)){let u=n.get(h);Fs(c,u),r.set(h,u)}else{let u=document.createElement("span");u.style.display="contents",Fs(c,u),r.set(h,u)}}for(let[l,h]of n)r.has(l)||(h._i&&Dl(h._i.p),h.remove());let a=null;for(let l=o.length-1;l>=0;l--){let h=r.get(o[l]);(h.nextSibling!==a||h.parentNode!==i)&&i.insertBefore(h,a),a=h}i[Gs]=r}}}var Zl=new Map,ZO=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function qO(s){if(!s.name)throw new Error("Trait requires a name");if(!s.setup)throw new Error(`Trait "${s.name}" requires a setup function`);if(!s.category)throw new Error(`Trait "${s.name}" requires a category`);if(!ZO.has(s.category))throw new Error(`Trait "${s.name}" has unknown category "${s.category}". Known: ${[...ZO].join(", ")}`);if(!s.description)throw new Error(`Trait "${s.name}" requires a description`);let t=Object.freeze({name:s.name,category:s.category,description:s.description,attributes:Object.freeze(s.attributes||[]),events:Object.freeze(s.events||[]),config:Object.freeze(s.config||[])});function e(){let i=null;return{schema:t,connect(n,r){i=s.setup({host:n,...r||{}})},disconnect(n){i&&(i(),i=null);for(let r of t.attributes)n.hasAttribute(r)&&(console.warn(`Trait "${t.name}": attribute "${r}" still present after disconnect`),n.removeAttribute(r))}}}return e.schema=t,Zl.set(s.name,e),e}function NO(s){return Zl.get(s)||null}function aI(s){return Zl.get(s)?.schema||null}function lI(){return[...Zl.keys()]}var Bu=Symbol(),ca=Symbol();function sA(s,t){s[ca]=new Map,s[Bu]=new Map;for(let[e,i]of Object.entries(t)){let n=i.attribute??e.toLowerCase(),r=i.type??String,o=Mi(i.default??void 0);s[Bu].set(e,o),Object.defineProperty(s,e,{get(){return o.value},set(a){let l=o.peek();Object.is(l,a)||(s[ca].set(e,l),o.value=a,i.reflect&&nA(s,n,a,r))},configurable:!0})}}function nA(s,t,e,i){i===Boolean?e?s.setAttribute(t,""):s.removeAttribute(t):e==null?s.removeAttribute(t):s.setAttribute(t,String(e))}var rA=(s,t)=>t===Boolean?s!==null:t===Number?s===null?null:+s:s;function oA(s){if(Object.hasOwn(s,"_sa"))return;s._sa=!0;let t=s.styles;if(!t)return;let e=Array.isArray(t)?t:[t];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...e.filter(i=>!document.adoptedStyleSheets.includes(i))]}function BO(s){if(Object.hasOwn(s,"_pp"))return;s._pp={};let t=s.parts;if(t)for(let[e,i]of Object.entries(t)){let n=document.createElement("template");n.innerHTML=i,s._pp[e]=n.content.firstElementChild}}var k=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let t=Object.entries(this.properties).map(([e,i])=>i.attribute??e.toLowerCase());return t.includes("traits")?t:[...t,"traits"]}#t=[];#e=[];#i=[];#s=null;#n=null;#r=null;#a=Mi(0);constructor(){super(),this.internals=this.attachInternals(),sA(this,this.constructor.properties)}connectedCallback(){let t=this.constructor;t._tag||(t._tag=this.localName),oA(t),BO(t),Qt(()=>this.connected()),this.#t.push(ss(()=>{for(let i of this[Bu].values())i.value;this.#a.value;let e=t.template(this);if(e&&Fs(e,this),this.render(),this[ca].size){let i=new Map(this[ca]);this[ca].clear(),this.updated(i)}},{host:this.localName,onError:this.onError?e=>this.onError(e):null})),this.#r||(this.#r=new Set);for(let e of t.traits)this.#l(e);this.#u(),this.#s&&this.#o()}disconnectedCallback(){this._i&&Dl(this._i.p);for(let t of this.#t)t();this.#t.length=0;for(let t of this.#i)t.value=void 0;this.#i.length=0;for(let t of this.#e)t.disconnect(this);this.#e.length=0,this.#r?.clear(),this.#n?.(),this.#n=null,this.#s?.disconnect?.(this),this.disconnected()}#o(){let t=this.#s;t.connect?.(this),this.#n=t.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#s}set controller(t){this.#n?.(),this.#n=null,this.#s?.disconnect?.(this),this.#s=t,t&&this.isConnected&&this.#o()}#l(t,{declarative:e=!1}={}){this.#r.add(t);let i=t();i.connect(this,{host:this,signal:Mi,computed:Xu,effect:ss}),e&&(i._declarative=!0),this.#e.push(i)}addTrait(t){return this.#r||(this.#r=new Set),this.#r.has(t)?this:(this.#l(t),this)}#u(){let t=this.getAttribute("traits");if(t)for(let e of t.split(/\s+/).filter(Boolean)){let i=NO(e);if(!i){console.warn(`<${this.localName}> traits="${e}" \u2014 trait not found. Did you forget to import it?`);continue}this.#r.has(i)||this.#l(i,{declarative:!0})}}#h(){if(!this.#r)return;let t=[];for(let e of this.#e)if(e._declarative){e.disconnect(this);for(let i of this.#r)if(i.schema?.name&&e.schema?.name===i.schema.name){this.#r.delete(i);break}}else t.push(e);this.#e.length=0,this.#e.push(...t),this.#u()}attributeChangedCallback(t,e,i){if(t==="traits"){this.isConnected&&this.#h();return}for(let[n,r]of Object.entries(this.constructor.properties))if((r.attribute??n.toLowerCase())===t){this[n]=rA(i,r.type??String);break}}static template=()=>null;static create(t={}){let e=this._tag??customElements.getName?.(this);if(!e)throw new Error("Component not registered");let i=document.createElement(e);for(let[n,r]of Object.entries(t))i[n]=r;return i}signal(t){let e=Mi(t);return this.#i.push(e),e}ensure(t){for(let r of this.children)if(r.getAttribute("slot")===t)return r;let e=this.#c(t);if(e)return e;BO(this.constructor);let i=this.constructor._pp?.[t];if(!i)return null;let n=i.cloneNode(!0);return n._uiPart=!0,this.appendChild(n),n}drop(t){for(let i of this.children)if(i.getAttribute("slot")===t){i.remove();return}let e=this.#c(t);e&&e.remove()}#c(t){for(let e of this.querySelectorAll(`[slot="${t}"]`)){let i=e.parentElement,n=!0;for(;i&&i!==this;){if(i.localName.includes("-")){n=!1;break}i=i.parentElement}if(n&&i===this)return e}return null}reconcile(t,e,i,n){let r=t[Gs]||new Map,o=new Map,a=[];for(let h=0;h<e.length;h++){let c=e[h],u=i(c,h);if(o.has(u))continue;let d=r.get(u);d?n(c,h,d):d=n(c,h,null),o.set(u,d),a.push(u)}for(let[h,c]of r)o.has(h)||c.remove();let l=null;for(let h=a.length-1;h>=0;h--){let c=o.get(a[h]);(c.nextSibling!==l||c.parentNode!==t)&&t.insertBefore(c,l),l=c}t[Gs]=o}connected(){}render(){}disconnected(){}updated(t){}};var zO=new WeakSet,ua=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!zO.has(e)&&e!==s&&(zO.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`)}},VO=class extends ua{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()}}};var zu=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}},Vu=class extends ua{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 zu{#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 Vu({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 vI(s,t){customElements.define(s,t)}function x(s,t){return customElements.get(s)?!1:(customElements.define(s,t),!0)}function xI(s){return!!customElements.get(s)}var Hs=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}};connected(){this.setAttribute("role",this.label?"img":"presentation"),this.label||this.setAttribute("aria-hidden","true")}render(){this.label&&this.setAttribute("aria-label",this.label);let t=$O(this.name,this.weight||"regular");t&&this.innerHTML!==t&&(this.innerHTML=t),this.size&&this.#t(this.size)?this.style.setProperty("--icon-size",this.#e(this.size)):this.style.getPropertyValue("--icon-size")&&this.style.removeProperty("--icon-size")}#t(t){return/^\d+(\.\d+)?(px|rem|em)?$/.test(t)}#e(t){return/^\d+(\.\d+)?$/.test(t)?`${t}px`:t}};x("icon-ui",Hs);var aA={plus:["+","\uFF0B"],minus:["-","\u2212","\u2013"],x:["\xD7","x ","X "],check:["\u2713","\u2714"],"arrow-right":["\u2192",">"],"arrow-left":["\u2190","<"]},Ks=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},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("icon-ui");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.icon&&this.text){let t=aA[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.
|
|
49
|
+
See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),e[a]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):e[a]={t:"a",n,name:l,c:void 0,_fx:null}}return e}function Dl(s){for(let t of s)t&&t._fx&&(t._fx(),t._fx=null)}function qu(s){if(s.n.nodeType===1&&s.n[Zu])return s.n;let t=document.createElement("span");return t.style.display="contents",t[Zu]=!0,s.n.replaceWith(t),s.n=t,t}var XO=s=>s!=null&&typeof s=="object"&&s.strings,DO=s=>typeof s=="function"||s!=null&&typeof s.handleEvent=="function";function Nu(s,t){if(t!==s.c){if(s.t==="n")if(t!=null&&t._directive)t._commit(qu(s));else if(XO(t))Fs(t,qu(s));else if(Array.isArray(t)){let e=qu(s);e.replaceChildren();for(let i of t)if(XO(i)){let n=document.createElement("span");n.style.display="contents",e.appendChild(n),Fs(i,n)}else e.appendChild(document.createTextNode(i??""))}else if(t instanceof Node)s.n.replaceWith(t),s.n=t;else if(s.n[Zu]){let e=document.createTextNode(t??"");s.n.replaceWith(e),s.n=e}else s.n.textContent=t??"";else if(s.t==="a")t==null||t===!1?s.n.removeAttribute(s.name):s.n.setAttribute(s.name,t===!0?"":t);else if(s.t==="p"){if(!s._resolved){let e=MO(s.n,s.name);e!==s.name&&(s.name=e),s._resolved=!0}s.n[s.name]=t}else s.t==="e"&&(DO(s.c)&&s.n.removeEventListener(s.name,s.c),DO(t)&&s.n.addEventListener(s.name,t));s.c=t}}function eA(s,t){for(let e=0;e<s.length;e++){let i=s[e];if(!i)continue;let n=t[e],r=i.t!=="e"&&typeof n=="function",o=!r&&i.t!=="e"&&Du(n);if(i._fx&&!r&&!o&&(i._fx(),i._fx=null),r){i._fx||(i._fx=ss(()=>Nu(i,n())));continue}if(o){i._fx||(i._fx=ss(()=>Nu(i,n.value)));continue}Nu(i,n)}}function iA(s,t,e){return{_directive:!0,_commit(i){let n=i[Gs]||new Map,r=new Map,o=[];for(let l=0;l<s.length;l++){let h=t(s[l],l);if(r.has(h))continue;o.push(h);let c=e(s[l],l);if(n.has(h)){let u=n.get(h);Fs(c,u),r.set(h,u)}else{let u=document.createElement("span");u.style.display="contents",Fs(c,u),r.set(h,u)}}for(let[l,h]of n)r.has(l)||(h._i&&Dl(h._i.p),h.remove());let a=null;for(let l=o.length-1;l>=0;l--){let h=r.get(o[l]);(h.nextSibling!==a||h.parentNode!==i)&&i.insertBefore(h,a),a=h}i[Gs]=r}}}var Zl=new Map,ZO=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function qO(s){if(!s.name)throw new Error("Trait requires a name");if(!s.setup)throw new Error(`Trait "${s.name}" requires a setup function`);if(!s.category)throw new Error(`Trait "${s.name}" requires a category`);if(!ZO.has(s.category))throw new Error(`Trait "${s.name}" has unknown category "${s.category}". Known: ${[...ZO].join(", ")}`);if(!s.description)throw new Error(`Trait "${s.name}" requires a description`);let t=Object.freeze({name:s.name,category:s.category,description:s.description,attributes:Object.freeze(s.attributes||[]),events:Object.freeze(s.events||[]),config:Object.freeze(s.config||[])});function e(){let i=null;return{schema:t,connect(n,r){i=s.setup({host:n,...r||{}})},disconnect(n){i&&(i(),i=null);for(let r of t.attributes)n.hasAttribute(r)&&(console.warn(`Trait "${t.name}": attribute "${r}" still present after disconnect`),n.removeAttribute(r))}}}return e.schema=t,Zl.set(s.name,e),e}function NO(s){return Zl.get(s)||null}function aI(s){return Zl.get(s)?.schema||null}function lI(){return[...Zl.keys()]}var Bu=Symbol(),ca=Symbol();function sA(s,t){s[ca]=new Map,s[Bu]=new Map;for(let[e,i]of Object.entries(t)){let n=i.attribute??e.toLowerCase(),r=i.type??String,o=Mi(i.default??void 0);s[Bu].set(e,o),Object.defineProperty(s,e,{get(){return o.value},set(a){let l=o.peek();Object.is(l,a)||(s[ca].set(e,l),o.value=a,i.reflect&&nA(s,n,a,r))},configurable:!0})}}function nA(s,t,e,i){i===Boolean?e?s.setAttribute(t,""):s.removeAttribute(t):e==null?s.removeAttribute(t):s.setAttribute(t,String(e))}var rA=(s,t)=>t===Boolean?s!==null:t===Number?s===null?null:+s:s;function oA(s){if(Object.hasOwn(s,"_sa"))return;s._sa=!0;let t=s.styles;if(!t)return;let e=Array.isArray(t)?t:[t];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...e.filter(i=>!document.adoptedStyleSheets.includes(i))]}function BO(s){if(Object.hasOwn(s,"_pp"))return;s._pp={};let t=s.parts;if(t)for(let[e,i]of Object.entries(t)){let n=document.createElement("template");n.innerHTML=i,s._pp[e]=n.content.firstElementChild}}var k=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let t=Object.entries(this.properties).map(([e,i])=>i.attribute??e.toLowerCase());return t.includes("traits")?t:[...t,"traits"]}#t=[];#e=[];#i=[];#s=null;#n=null;#r=null;#a=Mi(0);constructor(){super(),this.internals=this.attachInternals(),sA(this,this.constructor.properties)}connectedCallback(){let t=this.constructor;t._tag||(t._tag=this.localName),oA(t),BO(t),Qt(()=>this.connected()),this.#t.push(ss(()=>{for(let i of this[Bu].values())i.value;this.#a.value;let e=t.template(this);if(e&&Fs(e,this),this.render(),this[ca].size){let i=new Map(this[ca]);this[ca].clear(),this.updated(i)}},{host:this.localName,onError:this.onError?e=>this.onError(e):null})),this.#r||(this.#r=new Set);for(let e of t.traits)this.#l(e);this.#u(),this.#s&&this.#o()}disconnectedCallback(){this._i&&Dl(this._i.p);for(let t of this.#t)t();this.#t.length=0;for(let t of this.#i)t.value=void 0;this.#i.length=0;for(let t of this.#e)t.disconnect(this);this.#e.length=0,this.#r?.clear(),this.#n?.(),this.#n=null,this.#s?.disconnect?.(this),this.disconnected()}#o(){let t=this.#s;t.connect?.(this),this.#n=t.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#s}set controller(t){this.#n?.(),this.#n=null,this.#s?.disconnect?.(this),this.#s=t,t&&this.isConnected&&this.#o()}#l(t,{declarative:e=!1}={}){this.#r.add(t);let i=t();i.connect(this,{host:this,signal:Mi,computed:Xu,effect:ss}),e&&(i._declarative=!0),this.#e.push(i)}addTrait(t){return this.#r||(this.#r=new Set),this.#r.has(t)?this:(this.#l(t),this)}#u(){let t=this.getAttribute("traits");if(t)for(let e of t.split(/\s+/).filter(Boolean)){let i=NO(e);if(!i){console.warn(`<${this.localName}> traits="${e}" \u2014 trait not found. Did you forget to import it?`);continue}this.#r.has(i)||this.#l(i,{declarative:!0})}}#h(){if(!this.#r)return;let t=[];for(let e of this.#e)if(e._declarative){e.disconnect(this);for(let i of this.#r)if(i.schema?.name&&e.schema?.name===i.schema.name){this.#r.delete(i);break}}else t.push(e);this.#e.length=0,this.#e.push(...t),this.#u()}attributeChangedCallback(t,e,i){if(t==="traits"){this.isConnected&&this.#h();return}for(let[n,r]of Object.entries(this.constructor.properties))if((r.attribute??n.toLowerCase())===t){this[n]=rA(i,r.type??String);break}}static template=()=>null;static create(t={}){let e=this._tag??customElements.getName?.(this);if(!e)throw new Error("Component not registered");let i=document.createElement(e);for(let[n,r]of Object.entries(t))i[n]=r;return i}signal(t){let e=Mi(t);return this.#i.push(e),e}ensure(t){for(let r of this.children)if(r.getAttribute("slot")===t)return r;let e=this.#c(t);if(e)return e;BO(this.constructor);let i=this.constructor._pp?.[t];if(!i)return null;let n=i.cloneNode(!0);return n._uiPart=!0,this.appendChild(n),n}drop(t){for(let i of this.children)if(i.getAttribute("slot")===t){i.remove();return}let e=this.#c(t);e&&e.remove()}#c(t){for(let e of this.querySelectorAll(`[slot="${t}"]`)){let i=e.parentElement,n=!0;for(;i&&i!==this;){if(i.localName.includes("-")){n=!1;break}i=i.parentElement}if(n&&i===this)return e}return null}reconcile(t,e,i,n){let r=t[Gs]||new Map,o=new Map,a=[];for(let h=0;h<e.length;h++){let c=e[h],u=i(c,h);if(o.has(u))continue;let d=r.get(u);d?n(c,h,d):d=n(c,h,null),o.set(u,d),a.push(u)}for(let[h,c]of r)o.has(h)||c.remove();let l=null;for(let h=a.length-1;h>=0;h--){let c=o.get(a[h]);(c.nextSibling!==l||c.parentNode!==t)&&t.insertBefore(c,l),l=c}t[Gs]=o}connected(){}render(){}disconnected(){}updated(t){}};var zO=new WeakSet,ua=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!zO.has(e)&&e!==s&&(zO.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`)}},VO=class extends ua{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()}}};var zu=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}},Vu=class extends ua{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 zu{#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 Vu({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 vI(s,t){customElements.define(s,t)}function x(s,t){return customElements.get(s)?!1:(customElements.define(s,t),!0)}function xI(s){return!!customElements.get(s)}var Hs=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}};connected(){this.setAttribute("role",this.label?"img":"presentation"),this.label||this.setAttribute("aria-hidden","true")}render(){this.label&&this.setAttribute("aria-label",this.label);let t=$O(this.name,this.weight||"regular");t&&this.innerHTML!==t&&(this.innerHTML=t),this.size&&this.#t(this.size)?this.style.setProperty("--icon-size",this.#e(this.size)):this.style.getPropertyValue("--icon-size")&&this.style.removeProperty("--icon-size")}#t(t){return/^\d+(\.\d+)?(px|rem|em)?$/.test(t)}#e(t){return/^\d+(\.\d+)?$/.test(t)?`${t}px`:t}};x("icon-ui",Hs);var aA={plus:["+","\uFF0B"],minus:["-","\u2212","\u2013"],x:["\xD7","x ","X "],check:["\u2713","\u2714"],"arrow-right":["\u2192",">"],"arrow-left":["\u2190","<"]},Ks=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=aA[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.
|
|
50
50
|
Element: <button-ui icon="${this.icon}">
|
|
51
51
|
Add one of:
|
|
52
52
|
aria-label="Undo" \u2190 explicit accessible name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adia-ai/web-components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.43",
|
|
4
4
|
"description": "AdiaUI web components \u2014 vanilla custom elements. A2UI runtime (renderer, registry, streams, wiring) lives in @adia-ai/a2ui-runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./index.d.ts",
|