@adia-ai/web-components 0.7.2 → 0.7.3
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 +20 -0
- package/components/card/card.css +1 -1
- package/components/col/col.a2ui.json +1 -1
- package/components/col/col.css +1 -1
- package/components/col/col.d.ts +1 -1
- package/components/col/col.yaml +6 -3
- package/components/grid/grid.a2ui.json +1 -1
- package/components/grid/grid.css +4 -3
- package/components/grid/grid.d.ts +1 -1
- package/components/grid/grid.yaml +5 -3
- package/components/row/row.a2ui.json +1 -1
- package/components/row/row.css +6 -4
- package/components/row/row.d.ts +1 -1
- package/components/row/row.yaml +4 -2
- package/components/stat/stat.css +1 -1
- package/components/swiper/swiper.css +1 -1
- package/components/tree/tree.class.js +89 -16
- package/components/tree/tree.test.js +49 -0
- package/dist/web-components.min.css +1 -1
- package/dist/web-components.min.js +1 -1
- package/package.json +1 -1
- package/styles/api/sizing.css +52 -16
- package/styles/foundation/space.css +20 -4
- package/styles/prose.css +7 -4
|
@@ -133,7 +133,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
133
133
|
<div slot="layer" data-layer="base">${t}</div>
|
|
134
134
|
<div slot="layer" data-layer="fill" aria-hidden="true">${t}</div>
|
|
135
135
|
</div>
|
|
136
|
-
`}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#c),this.addEventListener("keydown",this.#d)}render(){if(!this.#t)return;let t=this.#r(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,n=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${n}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.setAttribute("aria-label",this.label||""),this.syncValue(String(this.value))}#r(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#a(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#o(t){let e=this.#a(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#l(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#a(this.min+i*(this.max-this.min))}#c=t=>{this.disabled||(t.preventDefault(),this.#o(this.#l(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#n=this.value,this.setAttribute("data-dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u))};#h=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,n=this.max-this.min,r=e/i*n;this.#o(this.#n+r)};#u=t=>{this.#i=!1,this.removeAttribute("data-dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#h),this.#t.removeEventListener("pointerup",this.#u),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#d=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#o(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#t?.removeEventListener("pointerup",this.#u),this.removeEventListener("keydown",this.#d),this.#t=null,this.#e=null}};x("range-ui",pn);Q();var mn=class extends k{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(t instanceof Element)return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#n(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#n(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let n=e;for(;n.open&&n.hasChildren;){let r=n.querySelectorAll(":scope > tree-item-ui");n=r[r.length-1]}return n}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},gn=class extends k{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#t();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"))}#t(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.querySelector(':scope > [slot="caret"]');if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let n=document.createElement("span");n.setAttribute("slot","badge"),this.badge&&(n.textContent=this.badge),t.appendChild(n);let r=this.querySelectorAll(':scope > [slot="actions"]');if(r.length)for(let o of r)t.appendChild(o);else{let o=document.createElement("span");o.setAttribute("slot","actions"),t.appendChild(o)}this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}};x("tree-ui",mn),x("tree-item-ui",gn);Q();var On=class extends k{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},side:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#n=null;#r="";#a=!1;connected(){this.#a||(this.#a=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#o=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#n=t.pointerId,this.setAttribute("data-resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u,{once:!0}),this.#t.addEventListener("pointercancel",this.#u,{once:!0}),this.#r=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.side==="trailing"?-1:1,i=(t.clientX-this.#i)*e,n=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${n}px`};#u=()=>{if(this.#e){this.#e=!1,this.removeAttribute("data-resizing");try{this.#t?.releasePointerCapture(this.#n)}catch{}this.#n=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#r}};disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#r),this.#a=!1}};x("pane-ui",On);Q();var bn=class extends k{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),this.#e||(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};x("page-ui",bn);Q();var ma=class extends k{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=[];#r=[];#a=null;#o=null;#l=null;#c=()=>this.#o?.click();#h=()=>{this.#o?.files?.length&&this.#m(this.#o.files),this.#o&&(this.#o.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#r]}set models(t){this.#n=t||[],this.#i&&(this.#i.options=this.#n,this.model&&(this.#i.value=this.model))}get models(){return this.#n}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
|
|
136
|
+
`}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#c),this.addEventListener("keydown",this.#d)}render(){if(!this.#t)return;let t=this.#r(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,n=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${n}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.setAttribute("aria-label",this.label||""),this.syncValue(String(this.value))}#r(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#a(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#o(t){let e=this.#a(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#l(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#a(this.min+i*(this.max-this.min))}#c=t=>{this.disabled||(t.preventDefault(),this.#o(this.#l(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#n=this.value,this.setAttribute("data-dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u))};#h=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,n=this.max-this.min,r=e/i*n;this.#o(this.#n+r)};#u=t=>{this.#i=!1,this.removeAttribute("data-dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#h),this.#t.removeEventListener("pointerup",this.#u),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#d=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#o(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#t?.removeEventListener("pointerup",this.#u),this.removeEventListener("keydown",this.#d),this.#t=null,this.#e=null}};x("range-ui",pn);Q();var mn=class extends k{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(t instanceof Element)return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#n(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#n(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let n=e;for(;n.open&&n.hasChildren;){let r=n.querySelectorAll(":scope > tree-item-ui");n=r[r.length-1]}return n}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},gn=class extends k{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#i();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0")),this.#n(),this.#t=new MutationObserver(()=>this.#n()),this.#t.observe(this,{childList:!0,subtree:!0})}#i(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.#s("caret")[0];if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),o.dataset.treeCaretDefault="1",t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let n=document.createElement("span");n.setAttribute("slot","badge"),this.badge&&(n.textContent=this.badge),t.appendChild(n);let r=document.createElement("span");r.setAttribute("slot","actions"),r.dataset.treeActionsPlaceholder="1",t.appendChild(r),this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}#s(t){let e=[],i=n=>{for(let r of n.children)if(!r.matches("tree-item-ui")){if(r.getAttribute("slot")===t){e.push(r);continue}(r.matches('[role="presentation"]')||r.style?.display==="contents")&&i(r)}};return i(this),e}#n(){if(this.#e)return;let t=this.querySelector(':scope > [slot="row"]');if(t){this.#e=!0;try{let e=this.#s("actions").filter(n=>!n.dataset.treeActionsPlaceholder&&n.parentElement!==t);if(e.length){t.querySelector(':scope > [slot="actions"][data-tree-actions-placeholder]')?.remove();for(let n of e)t.appendChild(n)}let i=this.#s("caret").find(n=>!n.dataset.treeCaretDefault&&n.parentElement!==t);i&&(t.querySelector(':scope > [slot="caret"][data-tree-caret-default]')?.remove(),t.prepend(i))}finally{this.#t?.takeRecords(),this.#e=!1}}}disconnected(){this.#t?.disconnect(),this.#t=null}};x("tree-ui",mn),x("tree-item-ui",gn);Q();var On=class extends k{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},side:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#n=null;#r="";#a=!1;connected(){this.#a||(this.#a=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#o=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#n=t.pointerId,this.setAttribute("data-resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u,{once:!0}),this.#t.addEventListener("pointercancel",this.#u,{once:!0}),this.#r=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.side==="trailing"?-1:1,i=(t.clientX-this.#i)*e,n=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${n}px`};#u=()=>{if(this.#e){this.#e=!1,this.removeAttribute("data-resizing");try{this.#t?.releasePointerCapture(this.#n)}catch{}this.#n=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#r}};disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#r),this.#a=!1}};x("pane-ui",On);Q();var bn=class extends k{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),this.#e||(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};x("page-ui",bn);Q();var ma=class extends k{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=[];#r=[];#a=null;#o=null;#l=null;#c=()=>this.#o?.click();#h=()=>{this.#o?.files?.length&&this.#m(this.#o.files),this.#o&&(this.#o.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#r]}set models(t){this.#n=t||[],this.#i&&(this.#i.options=this.#n,this.model&&(this.#i.value=this.model))}get models(){return this.#n}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
|
|
137
137
|
<textarea-ui placeholder="${this.placeholder}" rows="1"></textarea-ui>
|
|
138
138
|
<div slot="toolbar">
|
|
139
139
|
<select-ui slot="model" placeholder="Model" aria-label="Select model" divider></select-ui>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adia-ai/web-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
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",
|
package/styles/api/sizing.css
CHANGED
|
@@ -117,54 +117,90 @@
|
|
|
117
117
|
--a-code-size: var(--a-code-lg);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/* ═══════════════════════════════════════════════════════════════
|
|
121
|
+
[gap] — the EXPLICIT per-element gap (a spatial Scale attr).
|
|
122
|
+
|
|
123
|
+
Sets --a-gap-self, a NON-inheriting token, so an explicit gap on a
|
|
124
|
+
parent does NOT leak into nested layout primitives. This is the
|
|
125
|
+
counterpart to --a-gap, the AMBIENT gap set by [size]/[prose]/:root
|
|
126
|
+
(which DOES inherit — `<div size="sm">` shifts the whole subtree).
|
|
127
|
+
Gap-reading components resolve `var(--a-gap-self, var(--a-gap))`:
|
|
128
|
+
explicit-if-present, else fall through to the inherited ambient.
|
|
129
|
+
Design: docs/specs/attribute-api-system.md §5.2 (ADR-0038 / D2).
|
|
130
|
+
|
|
131
|
+
syntax:"*" (NOT "<length>") is load-bearing: a universal-syntax
|
|
132
|
+
@property may omit initial-value, leaving the token genuinely
|
|
133
|
+
*unset-able* (guaranteed-invalid when not set) — so the fallback to
|
|
134
|
+
--a-gap fires for elements without [gap]. A typed @property carries a
|
|
135
|
+
mandatory initial-value that always-resolves and would mask the
|
|
136
|
+
ambient. inherits:false stops the leak (audit C3).
|
|
137
|
+
═══════════════════════════════════════════════════════════════ */
|
|
138
|
+
@property --a-gap-self {
|
|
139
|
+
syntax: "*";
|
|
140
|
+
inherits: false;
|
|
141
|
+
}
|
|
142
|
+
|
|
120
143
|
[gap="0"] {
|
|
121
|
-
--a-gap: 0;
|
|
144
|
+
--a-gap-self: 0;
|
|
122
145
|
}
|
|
123
146
|
[gap="1"] {
|
|
124
|
-
--a-gap: var(--a-space-1);
|
|
147
|
+
--a-gap-self: var(--a-space-1);
|
|
125
148
|
}
|
|
126
149
|
[gap="2"] {
|
|
127
|
-
--a-gap: var(--a-space-2);
|
|
150
|
+
--a-gap-self: var(--a-space-2);
|
|
128
151
|
}
|
|
129
152
|
[gap="3"] {
|
|
130
|
-
--a-gap: var(--a-space-3);
|
|
153
|
+
--a-gap-self: var(--a-space-3);
|
|
131
154
|
}
|
|
132
155
|
[gap="4"] {
|
|
133
|
-
--a-gap: var(--a-space-4);
|
|
156
|
+
--a-gap-self: var(--a-space-4);
|
|
134
157
|
}
|
|
135
158
|
[gap="5"] {
|
|
136
|
-
--a-gap: var(--a-space-5);
|
|
159
|
+
--a-gap-self: var(--a-space-5);
|
|
137
160
|
}
|
|
138
161
|
[gap="6"] {
|
|
139
|
-
--a-gap: var(--a-space-6);
|
|
162
|
+
--a-gap-self: var(--a-space-6);
|
|
140
163
|
}
|
|
141
164
|
[gap="7"] {
|
|
142
|
-
--a-gap: var(--a-space-7);
|
|
165
|
+
--a-gap-self: var(--a-space-7);
|
|
143
166
|
}
|
|
144
167
|
[gap="8"] {
|
|
145
|
-
--a-gap: var(--a-space-8);
|
|
168
|
+
--a-gap-self: var(--a-space-8);
|
|
146
169
|
}
|
|
147
170
|
[gap="9"] {
|
|
148
|
-
--a-gap: var(--a-space-9);
|
|
171
|
+
--a-gap-self: var(--a-space-9);
|
|
149
172
|
}
|
|
150
173
|
[gap="10"] {
|
|
151
|
-
--a-gap: var(--a-space-10);
|
|
174
|
+
--a-gap-self: var(--a-space-10);
|
|
152
175
|
}
|
|
153
176
|
[gap="12"] {
|
|
154
|
-
--a-gap: var(--a-space-12);
|
|
177
|
+
--a-gap-self: var(--a-space-12);
|
|
155
178
|
}
|
|
156
179
|
[gap="16"] {
|
|
157
|
-
--a-gap: var(--a-space-16);
|
|
180
|
+
--a-gap-self: var(--a-space-16);
|
|
158
181
|
}
|
|
159
182
|
|
|
183
|
+
/* Named scale — the semantic, parametric gap vocabulary (xs/sm/md/lg/xl).
|
|
184
|
+
References the --a-gap-* tokens (foundation/space.css) so explicit
|
|
185
|
+
[gap="md"] AGREES with the ambient ([size]) and responsive (JS _gapToCss)
|
|
186
|
+
paths — all resolve to --a-gap-md — and tracks the --a-gap-k knob. This is
|
|
187
|
+
distinct from the integer rules above, which are LITERAL space-rungs
|
|
188
|
+
(k-independent). At k=1 the two grammars coincide: xs=1, sm=2, md=3,
|
|
189
|
+
lg=4, xl=5. (C1/C2 resolution — two coherent grammars, not one deprecated.) */
|
|
190
|
+
[gap="xs"] {
|
|
191
|
+
--a-gap-self: var(--a-gap-xs);
|
|
192
|
+
}
|
|
160
193
|
[gap="sm"] {
|
|
161
|
-
--a-gap: var(--a-
|
|
194
|
+
--a-gap-self: var(--a-gap-sm);
|
|
162
195
|
}
|
|
163
196
|
[gap="md"] {
|
|
164
|
-
--a-gap: var(--a-
|
|
197
|
+
--a-gap-self: var(--a-gap-md);
|
|
165
198
|
}
|
|
166
199
|
[gap="lg"] {
|
|
167
|
-
--a-gap: var(--a-
|
|
200
|
+
--a-gap-self: var(--a-gap-lg);
|
|
201
|
+
}
|
|
202
|
+
[gap="xl"] {
|
|
203
|
+
--a-gap-self: var(--a-gap-xl);
|
|
168
204
|
}
|
|
169
205
|
|
|
170
206
|
/* ── Universal [padding] / [margin] — same scale as [gap]. Layout
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
initial-value: 1;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/* Gap-scale knob — scales the k-driven half of every named gap
|
|
15
|
+
(--a-gap-{xs,sm,md,lg,xl}). k=1 (default) = baseline scale; <1 tightens
|
|
16
|
+
toward the floor, >1 loosens. Inherits, so set it at a provider boundary
|
|
17
|
+
(e.g. style="--a-gap-k:1.5") to retune all named gaps in a subtree. */
|
|
18
|
+
@property --a-gap-k {
|
|
19
|
+
syntax: "<number>";
|
|
20
|
+
inherits: true;
|
|
21
|
+
initial-value: 1;
|
|
22
|
+
}
|
|
23
|
+
|
|
14
24
|
:root {
|
|
15
25
|
/* ── Spacing ── */
|
|
16
26
|
--a-space-0: 0;
|
|
@@ -39,9 +49,15 @@
|
|
|
39
49
|
--a-inset-lg: var(--a-space-6);
|
|
40
50
|
--a-inset: var(--a-inset-md);
|
|
41
51
|
|
|
42
|
-
/* ── Gaps
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
/* ── Gaps — parametric named scale (half + half·k). Each token is a
|
|
53
|
+
fixed floor (half its k=1 value) plus a k-scaled half, so --a-gap-k
|
|
54
|
+
loosens/tightens the whole named scale while never collapsing below the
|
|
55
|
+
floor. At k=1: 4 / 8 / 12 / 16 / 20px. Composes on top of --a-density
|
|
56
|
+
(baked into --a-space-*). See styles/api/sizing.css + spec §5.2. ── */
|
|
57
|
+
--a-gap-xs: calc(var(--a-space-0-5) + var(--a-space-0-5) * var(--a-gap-k)); /* 4px @k=1 */
|
|
58
|
+
--a-gap-sm: calc(var(--a-space-1) + var(--a-space-1) * var(--a-gap-k)); /* 8px @k=1 */
|
|
59
|
+
--a-gap-md: calc(var(--a-space-1-5) + var(--a-space-1-5) * var(--a-gap-k)); /* 12px @k=1 */
|
|
60
|
+
--a-gap-lg: calc(var(--a-space-2) + var(--a-space-2) * var(--a-gap-k)); /* 16px @k=1 */
|
|
61
|
+
--a-gap-xl: calc(var(--a-space-2-5) + var(--a-space-2-5) * var(--a-gap-k)); /* 20px @k=1 */
|
|
46
62
|
--a-gap: var(--a-gap-md);
|
|
47
63
|
}
|
package/styles/prose.css
CHANGED
|
@@ -29,10 +29,13 @@
|
|
|
29
29
|
--a-inset-lg: var(--a-space-10);
|
|
30
30
|
--a-inset: var(--a-inset-md);
|
|
31
31
|
|
|
32
|
-
/* ── Gaps —
|
|
33
|
-
|
|
34
|
-
--a-gap-
|
|
35
|
-
--a-gap-
|
|
32
|
+
/* ── Gaps — prose register, one rung up; same parametric (half + half·k)
|
|
33
|
+
form as foundation, tracking --a-gap-k. At k=1: 8/12/16/20/24px. ── */
|
|
34
|
+
--a-gap-xs: calc(var(--a-space-1) + var(--a-space-1) * var(--a-gap-k)); /* 8px @k=1 */
|
|
35
|
+
--a-gap-sm: calc(var(--a-space-1-5) + var(--a-space-1-5) * var(--a-gap-k)); /* 12px @k=1 */
|
|
36
|
+
--a-gap-md: calc(var(--a-space-2) + var(--a-space-2) * var(--a-gap-k)); /* 16px @k=1 */
|
|
37
|
+
--a-gap-lg: calc(var(--a-space-2-5) + var(--a-space-2-5) * var(--a-gap-k)); /* 20px @k=1 */
|
|
38
|
+
--a-gap-xl: calc(var(--a-space-3) + var(--a-space-3) * var(--a-gap-k)); /* 24px @k=1 */
|
|
36
39
|
--a-gap: var(--a-gap-md);
|
|
37
40
|
|
|
38
41
|
/* ── Sizing — larger controls ── */
|