amateras 0.13.0 → 0.13.2
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/build/core.js +1 -1
- package/build/for.js +1 -1
- package/build/if.js +1 -1
- package/build/import-map.js +1 -1
- package/build/match.js +1 -1
- package/build/router.js +1 -1
- package/build/signal.js +1 -1
- package/build/ui.js +1 -1
- package/package.json +1 -1
- package/packages/core/src/index.ts +4 -1
- package/packages/css/src/types.ts +6 -3
- package/packages/for/src/index.ts +1 -4
- package/packages/if/src/index.ts +0 -3
- package/packages/match/src/index.ts +1 -3
- package/packages/router/src/global.ts +3 -0
- package/packages/router/src/index.ts +0 -1
- package/packages/router/src/structure/Link.ts +1 -1
- package/packages/router/src/structure/NavLink.ts +2 -3
- package/packages/signal/src/index.ts +1 -3
- package/packages/signal/src/structure/Signal.ts +6 -19
- package/packages/ui/src/structure/DescriptionList.ts +3 -0
- package/packages/ui/src/structure/Icon.ts +5 -2
- package/packages/utils/src/global.ts +9 -0
package/build/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_null as t,forEach as s,_Object_assign as e,map as o,_Array_from as i,_Object_entries as r,isUndefined as n,isNull as l,toArray as h,_instanceof as a,isString as d,isFunction as p,isArray as u}from"@amateras/utils";const c=window,f=document,m=t=>!t||t(),g=t=>!1,b=/* @__PURE__ */Symbol("ProtoType"),y=/* @__PURE__ */Symbol("Statement"),P=/* @__PURE__ */Symbol("Signal");class w{static disposers=/* @__PURE__ */new Set;promises=/* @__PURE__ */new Set;root;constructor(t){this.root=t,t.ondispose(()=>this.dispose())}dispose(){this.promises.clear(),this.root=t,s(w.disposers,t=>t(this))}static assign(t){e(w.prototype,t)}asyncTask(t){this.promises.add(t),t.finally(()=>this.promises.delete(t))}}class S{static proto=t;static[b]="Proto";static[y]=!1;static disposer=[];disposers=t;layout;parent=t;global=S.proto?.global??new w(this);sibling=t;firstProto=t;lastProto=t;builded=!1;listeners=t;constructor(s){this.layout=s??t}dispose(){s(S.disposer,t=>t(this)),s(this.disposers,t=>t()),s(this.protos,t=>t.dispose()),this.global=t,this.sibling=t,this.firstProto=t,this.lastProto=t,this.disposers=t,this.parent=t,this.layout=t}get children(){return o(this.protos,t=>t.constructor[y]?t.children:t).flat()}get protos(){let t=/* @__PURE__ */new Set,s=this.firstProto;if(s){let e=s;for(;e;)t.add(e),e=e.sibling}return t}append(...e){s(e,s=>{if(s.parent!==this&&s.parent?.removeProtos(s),this.lastProto){if(this.lastProto===s)return;this.firstProto===s&&(this.firstProto=s.sibling),s.sibling=t,this.lastProto.sibling=s,this.lastProto=s}else this.firstProto=s,this.lastProto=s;s.parent=this,s.global=this.global})}replaceProtos(...t){this.clear(),this.processProtos(...t)}insert(t,s=-1){if(0===s)this.firstProto&&(t.sibling=this.firstProto),this.firstProto=t;else{let e=i(this.protos),o=s<0?e.length+s+1:s;e.splice(o,0,t),this.processProtos(...e)}t.parent=this,t.global=this.global}removeProtos(...t){let e=this.protos;s(t,t=>{t.parent=null,t.sibling=null,e.delete(t)}),this.processProtos(...e)}processProtos(...e){let o=null;e.length?s(e,(t,s)=>{0===s&&(this.firstProto=t),o&&(o.sibling=t),o=t,t.parent=this}):this.firstProto=t,this.lastProto=o}build(t=!0){return this.clear(!0),$.context(S,this,()=>this.layout?.(this)),this.builded=!0,t&&s(this.protos,t=>{t.build()}),this.dispatch("builded",this),this}toString(){return o(this.protos,t=>`${t}`).join("")}toDOM(t=!0){return t?o(this.protos,s=>s.toDOM(t)).flat():[]}ondispose(t){this.disposers=this.disposers??[],this.disposers.push(t)}removeNode(){s(this.protos,t=>t.removeNode())}clear(t=!1){let e=this.protos;this.removeProtos(...e),t&&s(e,t=>t.dispose())}findAbove(s){let e=this.parent;return e?s(e)?e:e.findAbove(s):t}findBelow(s){for(let t of this.protos){if(s(t))return t;let e=t.findBelow(s);if(e)return e}return t}findBelowAll(t){let s=[];for(let e of this.protos)t(e)&&s.push(e),s.push(...e.findBelowAll(t));return s}mutate(){}get text(){return this.children.map(t=>t.text).join("")}dispatch(t,e,o){o?.bubbles&&this.parent?.dispatch(t,e,o);let i=this.listeners?.[t];s(i,t=>t(e))}listen(t,s){let e=this.listeners??{};this.listeners=e;let o=e[t]??/* @__PURE__ */new Set;this.listeners[t]=o,o.add(s)}}class M extends S{node=t;modifiers=t;constructor(t){super(t)}ondom(t){this.modifiers=this.modifiers??[],this.modifiers.push(t)}dispose(){super.dispose(),this.node=t,this.modifiers=t}inDOM(){return!!m()&&document.contains(this.node)}removeNode(){this.node?.remove()}}const _=["img","hr","br","input","link","meta"];class v extends M{tagname;#t={};#s="";__props__;constructor(t,s,e){super(()=>e?.(this)),this.tagname=t,this.__props__=s}dispose(){super.dispose(),this.layout=null}build(s){return this.__props__&&(this.props(this.__props__),this.__props__=t),super.build(s),this}props({...t}){let{class:s,...e}=t;s&&this.addClass(...s.split(" ")),this.attrProcess(e)}on(t,s,e){let o=o=>{o.addEventListener(t,s,e),this.ondispose(()=>this.node?.removeEventListener(t,s))};this.node?o(this.node):this.ondom(o)}toString(){return this.parseHTML()}parseHTML(t){let s=this.tagname,e=t?.children??(this.#s||o(this.protos,t=>`${t}`).join("")),i=t?.attr??o(r(this.#t),([t,s])=>s.length?`${t}="${s}"`:t).join(" "),n=i.length?" "+i:"";return _.includes(s)?`<${s}${n} />`:`<${s}${n}>${e}</${s}>`}toDOM(t=!0){if(this.node)return[this.node];let e=document.createElement(this.tagname);return this.node=e,this.#s?this.node.innerHTML=this.#s:t&&e.append(...o(this.protos,s=>s.toDOM(t)).flat()),s(r(this.#t),([t,s])=>e.setAttribute(t,s)),s(this.modifiers,t=>t(e)),[e]}attrProcess(t){s(r(t),([t,s])=>{for(let e of $.process.attr){let o=e(t,s,this);if(!n(o))return}this.attr(t,s)})}innerHTML(t){this.#s=t,this.node&&(this.node.innerHTML=t)}attr(s,e){return arguments.length?n(e)?this.#t[s]??t:(l(e)?(delete this.#t[s],this.node?.removeAttribute(s)):(this.#t[s]=e,this.node?.setAttribute(s,e)),this):this.#t}addClass(...t){this.token("add","class",...t),this.node?.classList.add(...t)}removeClass(...t){this.token("delete","class",...t),this.node?.classList.remove(...t)}style(t){let s=()=>this.node&&e(this.node.style,t);s(),this.node||this.ondom(s)}token(t,e,...o){let r=this.#t[e],n=new Set(r?.split(" ")??[]);s(o,s=>n[t](s)),this.#t[e]=i(n).join(" ")}}class T extends M{#e;constructor(t){super(),this.#e=t}get content(){return this.#e}set content(t){this.#e=t,this.node&&(this.node.textContent=t)}toString(){return this.#e}toDOM(){if(this.node)return[this.node];let t=new Text(this.#e);return this.node=t,s(this.modifiers,s=>s(t)),[t]}get text(){return this.#e}}class x extends M{constructor(t){super(t),m()&&(this.node=new Text)}toDOM(){return[this.node,...super.toDOM()]}removeNode(){super.removeNode(),s(this.protos,t=>t.removeNode())}}function L(e,...o){const i=S.proto,r=[],l=t=>{e&&i?.append(t),r.push(t)};for(let t of H.process.craft){let s=t(...o);if(!n(s))return s}const[h,c,f]=o;if(a(h,S))return l(h),h;if(d(h)){let t=p(c)?[,c]:[c,f],s=new v(h,...t);return l(s),s}if(p(h)){let t=new h(...p(c)?[{},c]:[c,f]);if(a(t,S))return l(t),t}if(u(h)){let e=s=>{for(let t of H.process.text){let e=t(s);if(!n(e))return l(e)}let e=n(s)?t:new T(`${s}`);e&&l(e)},[i,...h]=o;return i.raw?s(i,(s,o)=>{let i=s.length?new T(s):t,r=h[o];i&&l(i),e(r)}):s(i,t=>e(t)),r}}function H(...t){return L(!0,...t)}var D;(D=H||(H={})).process={craft:/* @__PURE__ */new Set,text:/* @__PURE__ */new Set,attr:/* @__PURE__ */new Set},D.craft=(...t)=>L(!1,...t),D.dispose=t=>{S.proto?.ondispose(t)},D.render=(t,s)=>{let e=D(t).build().toDOM();document.querySelector(s)?.replaceChildren(...e)},D.context=(t,s,e)=>{let o=t.proto;t.proto=s,e(),t.proto=o},D.call=t=>t(),D.match=(t,s)=>{var e=/* @__PURE__ */new Map,o=/* @__PURE__ */Symbol("default"),i={case:(t,s)=>(e.set(t,s),i),default:t=>(e.set(o,t),i)};return s(i),e.get(t)?.()??e.get(o)?.()},D.async=t=>{S.proto?.global.asyncTask(t())},D.stylesheet=m()?new CSSStyleSheet:t,D.styleMap=/* @__PURE__ */new Map,D.style=(t,e)=>{let o=h(e);if(t){let e=D.styleMap.get(t)??/* @__PURE__ */new Set;s(o,t=>e.add(t)),D.styleMap.set(t,e)}D.stylesheet&&s(o,t=>D.stylesheet.insertRule(t))},D.stylesheet&&document.adoptedStyleSheets.push(D.stylesheet),m()&&document.querySelector("style#__ssr__")?.remove(),globalThis.$=H;export{H as $,v as ElementProto,w as GlobalState,M as NodeProto,S as Proto,x as ProxyProto,T as TextProto,f as _document,c as _window,m as onclient,g as onserver,b as symbol_ProtoType,P as symbol_Signal,y as symbol_Statement};
|
|
1
|
+
import{_null as t,forEach as s,_Object_assign as e,map as o,_Array_from as i,_Object_entries as r,isUndefined as n,isNull as l,toArray as h,_instanceof as a,isString as d,isFunction as p,isArray as u}from"@amateras/utils";const c=window,f=document,m=t=>!t||t(),g=t=>!1,b=/* @__PURE__ */Symbol("ProtoType"),y=/* @__PURE__ */Symbol("Statement"),P=/* @__PURE__ */Symbol("Signal");class w{static disposers=/* @__PURE__ */new Set;promises=/* @__PURE__ */new Set;root;constructor(t){this.root=t,t.ondispose(()=>this.dispose())}dispose(){this.promises.clear(),this.root=t,s(w.disposers,t=>t(this))}static assign(t){e(w.prototype,t)}asyncTask(t){this.promises.add(t),t.finally(()=>this.promises.delete(t))}}class S{static proto=t;static[b]="Proto";static[y]=!1;static disposer=[];disposers=t;layout;parent=t;global=S.proto?.global??new w(this);sibling=t;firstProto=t;lastProto=t;builded=!1;listeners=t;constructor(s){this.layout=s??t}dispose(){s(S.disposer,t=>t(this)),s(this.disposers,t=>t()),s(this.protos,t=>t.dispose()),this.global=t,this.sibling=t,this.firstProto=t,this.lastProto=t,this.disposers=t,this.parent=t,this.layout=t}get children(){return o(this.protos,t=>t.constructor[y]?t.children:t).flat()}get protos(){let t=/* @__PURE__ */new Set,s=this.firstProto;if(s){let e=s;for(;e;)t.add(e),e=e.sibling}return t}append(...e){s(e,s=>{if(s.parent!==this&&s.parent?.removeProtos(s),this.lastProto){if(this.lastProto===s)return;this.firstProto===s&&(this.firstProto=s.sibling),s.sibling=t,this.lastProto.sibling=s,this.lastProto=s}else this.firstProto=s,this.lastProto=s;s.parent=this,s.global=this.global})}replaceProtos(...t){this.clear(),this.processProtos(...t)}insert(t,s=-1){if(0===s)this.firstProto&&(t.sibling=this.firstProto),this.firstProto=t;else{let e=i(this.protos),o=s<0?e.length+s+1:s;e.splice(o,0,t),this.processProtos(...e)}t.parent=this,t.global=this.global}removeProtos(...t){let e=this.protos;s(t,t=>{t.parent=null,t.sibling=null,e.delete(t)}),this.processProtos(...e)}processProtos(...e){let o=null;e.length?s(e,(t,s)=>{0===s&&(this.firstProto=t),o&&(o.sibling=t),o=t,t.parent=this}):this.firstProto=t,this.lastProto=o}build(t=!0){return this.clear(!0),$.context(S,this,()=>this.layout?.(this)),this.builded=!0,t&&s(this.protos,t=>{t.build()}),this.dispatch("builded",this),this}toString(){return o(this.protos,t=>`${t}`).join("")}toDOM(t=!0){return t?o(this.protos,s=>s.toDOM(t)).flat():[]}ondispose(t){this.disposers=this.disposers??[],this.disposers.push(t)}removeNode(){s(this.protos,t=>t.removeNode())}clear(t=!1){let e=this.protos;this.removeProtos(...e),t&&s(e,t=>t.dispose())}findAbove(s){let e=this.parent;return e?s(e)?e:e.findAbove(s):t}findBelow(s){for(let t of this.protos){if(s(t))return t;let e=t.findBelow(s);if(e)return e}return t}findBelowAll(t){let s=[];for(let e of this.protos)t(e)&&s.push(e),s.push(...e.findBelowAll(t));return s}mutate(){}get text(){return this.children.map(t=>t.text).join("")}dispatch(t,e,o){o?.bubbles&&this.parent?.dispatch(t,e,o);let i=this.listeners?.[t];s(i,t=>t(e))}listen(t,s){let e=this.listeners??{};this.listeners=e;let o=e[t]??/* @__PURE__ */new Set;this.listeners[t]=o,o.add(s)}}class M extends S{node=t;modifiers=t;constructor(t){super(t)}ondom(t){this.modifiers=this.modifiers??[],this.modifiers.push(t)}dispose(){super.dispose(),this.node=t,this.modifiers=t}inDOM(){return!!m()&&document.contains(this.node)}removeNode(){this.node?.remove()}}const _=["img","hr","br","input","link","meta"];class v extends M{tagname;#t={};#s="";__props__;constructor(t,s,e){super(()=>e?.(this)),this.tagname=t,this.__props__=s}dispose(){super.dispose(),this.layout=null}build(s){return this.__props__&&(this.props(this.__props__),this.__props__=t),super.build(s),this}props({...t}){let{class:s,...e}=t;s&&this.addClass(...s.split(" ")),this.attrProcess(e)}on(t,s,e){let o=o=>{o.addEventListener(t,s,e),this.ondispose(()=>this.node?.removeEventListener(t,s))};this.node?o(this.node):this.ondom(o)}toString(){return this.parseHTML()}parseHTML(t){let s=this.tagname,e=t?.children??(this.#s||o(this.protos,t=>`${t}`).join("")),i=t?.attr??o(r(this.#t),([t,s])=>s.length?`${t}="${s}"`:t).join(" "),n=i.length?" "+i:"";return _.includes(s)?`<${s}${n} />`:`<${s}${n}>${e}</${s}>`}toDOM(t=!0){if(this.node)return[this.node];let e=document.createElement(this.tagname);return this.node=e,this.#s?this.node.innerHTML=this.#s:t&&e.append(...o(this.protos,s=>s.toDOM(t)).flat()),s(r(this.#t),([t,s])=>e.setAttribute(t,s)),s(this.modifiers,t=>t(e)),[e]}attrProcess(t){s(r(t),([t,s])=>{for(let e of $.process.attr){let o=e(t,s,this);if(!n(o))return}this.attr(t,s)})}innerHTML(t){this.#s=t,this.node&&(this.node.innerHTML=t)}attr(s,e){return arguments.length?n(e)?this.#t[s]??t:(l(e)?(delete this.#t[s],this.node?.removeAttribute(s)):(this.#t[s]=e,this.node?.setAttribute(s,e)),this):this.#t}addClass(...t){this.token("add","class",...t),this.node?.classList.add(...t)}removeClass(...t){this.token("delete","class",...t),this.node?.classList.remove(...t)}style(t){let s=()=>this.node&&e(this.node.style,t);s(),this.node||this.ondom(s)}token(t,e,...o){let r=this.#t[e],n=new Set(r?.split(" ")??[]);s(o,s=>n[t](s)),this.#t[e]=i(n).join(" ")}}class T extends M{#e;constructor(t){super(),this.#e=t}get content(){return this.#e}set content(t){this.#e=t,this.node&&(this.node.textContent=t)}toString(){return this.#e}toDOM(){if(this.node)return[this.node];let t=new Text(this.#e);return this.node=t,s(this.modifiers,s=>s(t)),[t]}get text(){return this.#e}}class x extends M{constructor(t){super(t),m()&&(this.node=new Text)}toDOM(){return[this.node,...super.toDOM()]}removeNode(){super.removeNode(),s(this.protos,t=>t.removeNode())}}function L(e,...o){const i=S.proto,r=[],l=t=>{e&&i?.append(t),r.push(t)};for(let t of H.process.craft){let s=t(...o);if(!n(s))return l(s),s}const[h,c,f]=o;if(a(h,S))return l(h),h;if(d(h)){let t=p(c)?[,c]:[c,f],s=new v(h,...t);return l(s),s}if(p(h)){let t=new h(...p(c)?[{},c]:[c,f]);if(a(t,S))return l(t),t}if(u(h)){let e=s=>{for(let t of H.process.text){let e=t(s);if(!n(e))return l(e)}let e=n(s)?t:new T(`${s}`);e&&l(e)},[i,...h]=o;return i.raw?s(i,(s,o)=>{let i=s.length?new T(s):t,r=h[o];i&&l(i),e(r)}):s(i,t=>e(t)),r}}function H(...t){return L(!0,...t)}var D;(D=H||(H={})).process={craft:/* @__PURE__ */new Set,text:/* @__PURE__ */new Set,attr:/* @__PURE__ */new Set},D.craft=(...t)=>L(!1,...t),D.dispose=t=>{S.proto?.ondispose(t)},D.render=(t,s)=>{let e=D(t).build().toDOM();document.querySelector(s)?.replaceChildren(...e)},D.context=(t,s,e)=>{let o=t.proto;t.proto=s,e(),t.proto=o},D.call=t=>t(),D.match=(t,s)=>{var e=/* @__PURE__ */new Map,o=/* @__PURE__ */Symbol("default"),i={case:(t,s)=>(e.set(t,s),i),default:t=>(e.set(o,t),i)};return s(i),e.get(t)?.()??e.get(o)?.()},D.async=t=>{S.proto?.global.asyncTask(t())},D.stylesheet=m()?new CSSStyleSheet:t,D.styleMap=/* @__PURE__ */new Map,D.style=(t,e)=>{let o=h(e);if(t){let e=D.styleMap.get(t)??/* @__PURE__ */new Set;s(o,t=>e.add(t)),D.styleMap.set(t,e)}D.stylesheet&&s(o,t=>D.stylesheet.insertRule(t))},D.stylesheet&&document.adoptedStyleSheets.push(D.stylesheet),m()&&document.querySelector("style#__ssr__")?.remove(),globalThis.$=H;export{H as $,v as ElementProto,w as GlobalState,M as NodeProto,S as Proto,x as ProxyProto,T as TextProto,f as _document,c as _window,m as onclient,g as onserver,b as symbol_ProtoType,P as symbol_Signal,y as symbol_Statement};
|
package/build/for.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ProxyProto as t,symbol_Statement as e,Proto as s}from"@amateras/core";import{forEach as i,_Array_from as o,_null as r}from"@amateras/utils";class a extends t{static[e]=!0;#t;list$;#e=/* @__PURE__ */new Map;constructor(t,e){super(),this.list$=t,this.#t=e;let s=()=>{const t=this.exec();i(this.protos,t=>t.builded||t.build()),i(t,t=>t.removeNode());let e=this.node,s=e?.parentNode;if(e&&s){let t=this.toDOM(),a=o(s.childNodes).indexOf(e);i(t,t=>{if(t!==e){if(s.childNodes[a]!==t){let e=s.childNodes[a+1]??r;s.insertBefore(t,e)}}a++})}this.parent?.mutate()};this.list$.subscribe(s),this.ondispose(()=>this.list$.unsubscribe(s))}build(){return this.#e=/* @__PURE__ */new Map,this.exec(),this.protos.forEach(t=>t.builded||t.build()),this}exec(){let t=this.protos,e=/* @__PURE__ */new Set;return i(this.list$.value,(i,o)=>{$.context(s,this,()=>{let s=this.#t,r=this.#e.get(i)??new l(()=>s(i,o));this.#e.set(i,r),t.delete(r),e.add(r)})}),this.replaceProtos(...e),t}removeNode(){this.node?.remove(),i(this.protos,t=>t.removeNode())}dispose(){super.dispose(),i(this.#e.values(),t=>t.dispose()),this.#e.clear()}}class l extends s{static[e]=!0}globalThis.For=a,$.process.craft.add((t,e,
|
|
1
|
+
import{ProxyProto as t,symbol_Statement as e,Proto as s}from"@amateras/core";import{forEach as i,_Array_from as o,_null as r}from"@amateras/utils";class a extends t{static[e]=!0;#t;list$;#e=/* @__PURE__ */new Map;constructor(t,e){super(),this.list$=t,this.#t=e;let s=()=>{const t=this.exec();i(this.protos,t=>t.builded||t.build()),i(t,t=>t.removeNode());let e=this.node,s=e?.parentNode;if(e&&s){let t=this.toDOM(),a=o(s.childNodes).indexOf(e);i(t,t=>{if(t!==e){if(s.childNodes[a]!==t){let e=s.childNodes[a+1]??r;s.insertBefore(t,e)}}a++})}this.parent?.mutate()};this.list$.subscribe(s),this.ondispose(()=>this.list$.unsubscribe(s))}build(){return this.#e=/* @__PURE__ */new Map,this.exec(),this.protos.forEach(t=>t.builded||t.build()),this}exec(){let t=this.protos,e=/* @__PURE__ */new Set;return i(this.list$.value,(i,o)=>{$.context(s,this,()=>{let s=this.#t,r=this.#e.get(i)??new l(()=>s(i,o));this.#e.set(i,r),t.delete(r),e.add(r)})}),this.replaceProtos(...e),t}removeNode(){this.node?.remove(),i(this.protos,t=>t.removeNode())}dispose(){super.dispose(),i(this.#e.values(),t=>t.dispose()),this.#e.clear()}}class l extends s{static[e]=!0}globalThis.For=a,$.process.craft.add((t,e,s)=>{if(t===a)return new a(e,s)});export{a as For,l as ForItem};
|
package/build/if.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Proto as t,symbol_Statement as
|
|
1
|
+
import{Proto as t,symbol_Statement as s,ProxyProto as e}from"@amateras/core";import{_null as i,forEach as a,_instanceof as l,isIncluded as r}from"@amateras/utils";import{Signal as n}from"@amateras/signal";class h extends t{static[s]=!0;exp$;constructor(t,s){super(()=>s(this.exp$)),this.exp$=t}dispose(){super.dispose(),this.exp$=i}validate(){return!this.exp$||!!this.exp$.value}}class o extends h{}class d extends h{}class p extends h{}class m extends e{static[s]=!0;statements=i;statement=i;build(){super.build(!1),this.validate()?.build();let t=()=>{let t=this.validate();t?.builded||t?.build(),this.statement!==t&&(this.statement=t??i,a(this.statements,s=>s!==t&&s.removeNode()),this.node?.replaceWith(...this.toDOM()),this.parent?.mutate())};return a(this.statements,s=>{s.exp$?.subscribe(t),s.ondispose(()=>{s.exp$?.unsubscribe(t)})}),this}dispose(){super.dispose(),a(this.statements,t=>t.dispose()),this.statement=i,this.statements=i}validate(){if(this.clear(),this.statements)for(let t of this.statements)if(t.validate())return this.append(t),t}}globalThis.If=p,globalThis.Else=o,globalThis.ElseIf=d;let u=null;$.process.craft.add((t,s,e)=>{if(t===p&&(u=new m),l(u,m)){if(r(t,[p,o,d])){{let a=new t(...l(s,n)?[s,e]:[i,s]);u.statements=u.statements??[],u.statements?.push(a)}return u}u=i}else if(r(t,[o,d]))throw"ElseIf/Else must be after If or ElseIf"});
|
package/build/import-map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=`https://unpkg.com/amateras@${"0.
|
|
1
|
+
const t=`https://unpkg.com/amateras@${"0.13.2"}/build`,e={...{amateras:`${t}/core.js`},...Object.fromEntries(["core","utils","signal","for","if","match","css","i18n","idb","meta","prefetch","router","widget"].map(e=>{const r=`amateras/${e}`,s=`${t}/${e}.js`;return[[r,s],[`@${r}`,s]]}).flat())},r=document.querySelector('script[type="importmap"]');if(r){const t=JSON.parse(r.innerHTML);t.imports={...t.imports,...e},r.innerHTML=JSON.stringify(t,null,"\t")}else{const t=document.createElement("script");t.setAttribute("type","importmap"),t.innerHTML=JSON.stringify({imports:e},null,"\t"),document.head.prepend(t)}
|
package/build/match.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Proto as t,symbol_Statement as e,ProxyProto as s}from"@amateras/core";import{isArray as i,_null as a,forEach as d,is as
|
|
1
|
+
import{Proto as t,symbol_Statement as e,ProxyProto as s}from"@amateras/core";import{isArray as i,_null as a,forEach as d,is as h}from"@amateras/utils";class l extends t{static[e]=!0;condition;constructor(t,e){super(e),this.condition=i(t)?t:[t]}}class r extends t{static[e]=!0;constructor(t){super(t)}}class c extends s{static[e]=!0;exp$;cases=/* @__PURE__ */new Set;matched=a;#t=a;constructor(t,e){super(()=>{e((t,e,s)=>{$(t,e,s)})}),this.exp$=t}dispose(){d(this.cases,t=>t.dispose()),this.#t?.dispose(),this.matched=a,this.#t=a,this.cases.clear()}build(){super.build(!1),this.validate();let t=()=>{let t=this.matched,e=this.validate();t!==e&&(d(this.cases,t=>t!==e&&t.removeNode()),e!==this.#t&&this.#t?.removeNode(),this.node?.replaceWith(...this.toDOM()),this.parent?.mutate())};return d(this.cases,e=>{this.exp$.subscribe(t),e.ondispose(()=>this.exp$.unsubscribe(t))}),this}case(t,e){let s=new l(t,e);return this.cases.add(s),s}default(t){let e=new r(t);return this.#t=e,e}validate(){this.clear();for(let t of this.cases)if(t.condition.includes(this.exp$.value))return this.append(t),t.builded||t.build(),this.matched=t;if(this.#t)return this.append(this.#t),this.#t.builded||this.#t.build(),this.matched=this.#t}}globalThis.Match=c,globalThis.Case=l,globalThis.Default=r,$.process.craft.add((e,s,i)=>e===c?new c(s,i):e===l?h(t.proto,c)?.case(s,i):e===r?h(t.proto,c)?.default(s):void 0);
|
package/build/router.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ElementProto as t,ProxyProto as e,onclient as s,Proto as r,symbol_ProtoType as o,GlobalState as i}from"@amateras/core";import{_undefined as l,toURL as a,_null as n,is as h,_instanceof as c,isUndefined as u,isFunction as p,map as d,isArray as f,forEach as w,_JSON_parse as v,_Object_entries as g,_JSON_stringify as y,_Object_assign as m}from"@amateras/utils";class b extends t{constructor(t,e){super("a",t,e),this.on("click",t=>{if(t.shiftKey||t.ctrlKey)return;t.preventDefault();let e=this.attr("target"),s=this.attr("href");s&&("_replace"===e?$.replace(s):$.open(s,e??l))})}}class k extends e{page=n;constructor(){super()}switch(t){if(this.page!==t&&(this.clear(),this.layout=()=>$(t),this.append(t),this.page!==t&&this.page?.removeNode(),this.page=t,t.builded||t.build(),t.updateTitle(),s())){let t=this.toDOM();this.node?.replaceWith(...t)}}}class x extends r{slot=new k;route;title=n;constructor(t,e,s){super(()=>e({params:s,slot:this.slot})),this.route=t}updateTitle(){let t=this.title??this.findAbove(t=>h(t,x)?.title)?.title??n,e=t=>{s()&&(document.title=t),this.global.title=t};t&&(c(t,Promise)?t.then(t=>{this.title=t,e(t)}):e(t))}}class P{routes=/* @__PURE__ */new Map;path;paths=/* @__PURE__ */new Map;validPaths=[];constructor(t){this.path=t,this.paths.set(t,l)}routing(t){let e=t.split("/"),s={},r="";t:for(let[i,l]of this.paths){s={};let t=i.split("/"),o=[];for(let s=0;s<Math.max(e.length,t.length);s++)o.push([t[s],e[s]]);e:for(let[e,i]of o){let t=()=>{r=""},o=()=>{r+=("/"!==r?"/":"")+i};if(u(e))break e;if(u(i)){t();continue t}if(e?.includes(":")){let[r,l]=e.split(":");if(!i.startsWith(r)){t();continue t}s[l]=i.replace(r,""),o();continue e}if(e!==i){t();continue t}o()}if(r){s={...s,...p(l)?l():l};break t}}if(!r)return;let o=P.resolvePath(this.path,s);return this.validPaths=d(this.paths,t=>P.resolvePath(t[0],s)),[o,r,s]}static resolvePath(t,e){return t.replaceAll(/:([^/]+)/g,(t,s)=>`${e[s]}`)}alias(t,e){this.paths.set(t,e)}}class S extends P{constructor(t){super(t)}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[,o,i]=r;s={...s,...i};let l=t.replace(o,"");for(let[a,n]of this.routes){let t=await n.resolve(l||"/",e,s);if(t)return[this,...t]}return[this]}}class T extends P{pages=/* @__PURE__ */new Map;page=n;#t;constructor(t,e){super(t),this.#t=e}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[o,i,l]=r;s={...s,...l};let a=await this.usePage(o,s,e),n=t.replace(i,"");for(let[h,c]of this.routes){let t=await c.resolve(n||"/",a.slot,s);if(t)return[this,...t]}return n?void 0:[this]}async usePage(t,e,s){let i=this.pages.get(t);if(!i){let l,a=this.#t;if(f(a)){let t=await a[0]().then(t=>t.default);l=()=>$(t,e,()=>$(i.slot))}else l="Widget"===this.#t[o]?()=>$(this.#t,e,()=>$(i.slot)):this.#t;$.context(r,s,()=>{i=new x(this,l,e)}),this.pages.set(t,i)}return this.page=i,s.switch(i),i}}let R=0;const[_,E]=[1,2],[L,M]=["forward","back"],A="__scroll_history__",D=s()?sessionStorage:n,N=s()?window.addEventListener:n,H=s()?window.removeEventListener:n;s()&&(history.scrollRestoration="manual");const W=t=>{const e=I.scrollHistory;if(t){let s=t.target;"#document"===s.nodeName?e[R]={[s.nodeName]:{x:window.scrollX,y:window.scrollY}}:""!==s.id&&(e[R]={[s.id]:{x:s.scrollLeft,y:s.scrollTop}})}else w(g(e),([t])=>+t>=R&&delete e[+t]);D?.setItem(A,y(e))};class I extends r{direction=L;prev=n;routes=/* @__PURE__ */new Map;slot=new k;static routers=/* @__PURE__ */new Set;constructor(){super(()=>$(this.slot)),s()&&I.routers.add(this)}set href(t){this.global.router.href=t}build(){if(s()){const t=()=>{const t=history.state?.index??0;R>t&&(this.direction=M),R<t&&(this.direction=L),R=t,this.prev=this.href,this.href=a(location.href),this.resolve(location.href)};t(),N?.("popstate",t),N?.("scroll",W,{capture:!0,passive:!1}),this.ondispose(()=>{H?.("popstate",t),H?.("scroll",W,{capture:!0})})}return super.build()}async resolve(t){if(!t)return;let e=a(t);for(let[,s]of this.routes){let t=await s.resolve(e.pathname,this.slot,{});if(t){this.global.router.routes=t;let e=[""],s=[];w(t,t=>(e=d(t.validPaths,t=>d(e,e=>e+t)).flat(),s.push(...e),e)),this.global.router.matchPaths=s;break}}w(this.global.router.navlinks,t=>t.checkActive()),I.dispatchEvent(),I.scrollRestoration()}static open(t,e="_self"){a(t).origin!==origin?open(t,e):I.writeState(t,_,e)}static forward(){history.forward()}static back(){history.back()}static replace(t){I.writeState(t,E)}static get scrollData(){return this.scrollHistory[R]??{}}static get scrollHistory(){return v(D?.getItem(A)??"{}")}static scrollRestoration(){if(s()){let t=I.scrollData??{x:0,y:0},e=g(t);e.length?w(e,([t,{x:e,y:s}])=>{"#document"===t?window.scrollTo(e,s):document.querySelector(`#${t}`)?.scrollTo(e,s)}):window.scrollTo(0,0)}}static writeState(t,e,r){if(!t)return;let o=a(t);if(!s()||o.href!==location.href){if(r&&"_self"!==r)return open(o,r);e===_&&R++,s()&&W(),w(this.routers,r=>{r.direction=L,s()&&(r.prev=a(location.href),history[e===_?"pushState":"replaceState"]({index:R},"",o)),r.href=o,r.resolve(t)}),I.dispatchEvent()}}static dispatchEvent(){s()&&window.dispatchEvent(new Event("pathchange"))}}const K=t=>class extends I{static[o]="Router";constructor(){super(),t(this)}};let q={route(t,e,s){let r=new T(t,e);return this.routes.set(t,r),s?.(r),this},group(t,e){let s=new S(t);return this.routes.set(t,s),e?.(s),this},notfound(){}};m(P.prototype,q),m(I.prototype,q),m(i.prototype,{router:{routers:/* @__PURE__ */new Set,resolve(t){return d(this.routers,e=>e.resolve(t))},href:new URL("http://localhost"),routes:[],matchPaths:[],navlinks:/* @__PURE__ */new Set}}),i.disposers.add(({router:t})=>{t.routers.clear(),t.routes=[],t.matchPaths=[],t.navlinks.clear()}),m($,{router:t=>K(t),open:I.open,replace:I.replace,back:I.back,forward:I.forward,scrollRestoration:I.scrollRestoration,title(t){let e=r.proto?.findAbove(t=>h(t,x));e&&(e.title=t,e.updateTitle())}}),globalThis.Link=b,globalThis.NavLink=class extends b{constructor(t,e){super(t,e),this.global.router.navlinks.add(this)}checkActive(){let t=this.attr("href");if(t){for(let e of this.global.router.matchPaths)if(a(e).href===a(t).href)return this.attr("active","");this.attr("active",n)}}},$.process.craft.add(t=>{if(p(t)&&"Router"===t[o]){let e=r.proto,s=new t;return e?.global.router.routers.add(s),
|
|
1
|
+
import{ElementProto as t,ProxyProto as e,onclient as s,Proto as r,symbol_ProtoType as o,GlobalState as i}from"@amateras/core";import{_undefined as l,toURL as a,_null as n,is as h,_instanceof as c,isUndefined as u,isFunction as p,map as d,isArray as f,forEach as w,_JSON_parse as v,_Object_entries as g,_JSON_stringify as y,_Object_assign as m}from"@amateras/utils";class b extends t{constructor(t,e){super("a",t,e),this.on("click",t=>{if(t.shiftKey||t.ctrlKey)return;t.preventDefault();let e=this.attr("target"),s=this.attr("href");s&&("_replace"===e?$.replace(s):$.open(s,e??l))})}}class k extends e{page=n;constructor(){super()}switch(t){if(this.page!==t&&(this.clear(),this.layout=()=>$(t),this.append(t),this.page!==t&&this.page?.removeNode(),this.page=t,t.builded||t.build(),t.updateTitle(),s())){let t=this.toDOM();this.node?.replaceWith(...t)}}}class x extends r{slot=new k;route;title=n;constructor(t,e,s){super(()=>e({params:s,slot:this.slot})),this.route=t}updateTitle(){let t=this.title??this.findAbove(t=>h(t,x)?.title)?.title??n,e=t=>{s()&&(document.title=t),this.global.title=t};t&&(c(t,Promise)?t.then(t=>{this.title=t,e(t)}):e(t))}}class P{routes=/* @__PURE__ */new Map;path;paths=/* @__PURE__ */new Map;validPaths=[];constructor(t){this.path=t,this.paths.set(t,l)}routing(t){let e=t.split("/"),s={},r="";t:for(let[i,l]of this.paths){s={};let t=i.split("/"),o=[];for(let s=0;s<Math.max(e.length,t.length);s++)o.push([t[s],e[s]]);e:for(let[e,i]of o){let t=()=>{r=""},o=()=>{r+=("/"!==r?"/":"")+i};if(u(e))break e;if(u(i)){t();continue t}if(e?.includes(":")){let[r,l]=e.split(":");if(!i.startsWith(r)){t();continue t}s[l]=i.replace(r,""),o();continue e}if(e!==i){t();continue t}o()}if(r){s={...s,...p(l)?l():l};break t}}if(!r)return;let o=P.resolvePath(this.path,s);return this.validPaths=d(this.paths,t=>P.resolvePath(t[0],s)),[o,r,s]}static resolvePath(t,e){return t.replaceAll(/:([^/]+)/g,(t,s)=>`${e[s]}`)}alias(t,e){this.paths.set(t,e)}}class S extends P{constructor(t){super(t)}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[,o,i]=r;s={...s,...i};let l=t.replace(o,"");for(let[a,n]of this.routes){let t=await n.resolve(l||"/",e,s);if(t)return[this,...t]}return[this]}}class T extends P{pages=/* @__PURE__ */new Map;page=n;#t;constructor(t,e){super(t),this.#t=e}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[o,i,l]=r;s={...s,...l};let a=await this.usePage(o,s,e),n=t.replace(i,"");for(let[h,c]of this.routes){let t=await c.resolve(n||"/",a.slot,s);if(t)return[this,...t]}return n?void 0:[this]}async usePage(t,e,s){let i=this.pages.get(t);if(!i){let l,a=this.#t;if(f(a)){let t=await a[0]().then(t=>t.default);l=()=>$(t,e,()=>$(i.slot))}else l="Widget"===this.#t[o]?()=>$(this.#t,e,()=>$(i.slot)):this.#t;$.context(r,s,()=>{i=new x(this,l,e)}),this.pages.set(t,i)}return this.page=i,s.switch(i),i}}let R=0;const[_,E]=[1,2],[L,M]=["forward","back"],A="__scroll_history__",D=s()?sessionStorage:n,N=s()?window.addEventListener:n,H=s()?window.removeEventListener:n;s()&&(history.scrollRestoration="manual");const W=t=>{const e=I.scrollHistory;if(t){let s=t.target;"#document"===s.nodeName?e[R]={[s.nodeName]:{x:window.scrollX,y:window.scrollY}}:""!==s.id&&(e[R]={[s.id]:{x:s.scrollLeft,y:s.scrollTop}})}else w(g(e),([t])=>+t>=R&&delete e[+t]);D?.setItem(A,y(e))};class I extends r{direction=L;prev=n;routes=/* @__PURE__ */new Map;slot=new k;static routers=/* @__PURE__ */new Set;constructor(){super(()=>$(this.slot)),s()&&I.routers.add(this)}set href(t){this.global.router.href=t}build(){if(s()){const t=()=>{const t=history.state?.index??0;R>t&&(this.direction=M),R<t&&(this.direction=L),R=t,this.prev=this.href,this.href=a(location.href),this.resolve(location.href)};t(),N?.("popstate",t),N?.("scroll",W,{capture:!0,passive:!1}),this.ondispose(()=>{H?.("popstate",t),H?.("scroll",W,{capture:!0})})}return super.build()}async resolve(t){if(!t)return;let e=a(t);for(let[,s]of this.routes){let t=await s.resolve(e.pathname,this.slot,{});if(t){this.global.router.routes=t;let e=[""],s=[];w(t,t=>(e=d(t.validPaths,t=>d(e,e=>e+t)).flat(),s.push(...e),e)),this.global.router.matchPaths=s;break}}w(this.global.router.navlinks,t=>t.checkActive()),I.dispatchEvent(),I.scrollRestoration()}static open(t,e="_self"){a(t).origin!==origin?open(t,e):I.writeState(t,_,e)}static forward(){history.forward()}static back(){history.back()}static replace(t){I.writeState(t,E)}static get scrollData(){return this.scrollHistory[R]??{}}static get scrollHistory(){return v(D?.getItem(A)??"{}")}static scrollRestoration(){if(s()){let t=I.scrollData??{x:0,y:0},e=g(t);e.length?w(e,([t,{x:e,y:s}])=>{"#document"===t?window.scrollTo(e,s):document.querySelector(`#${t}`)?.scrollTo(e,s)}):window.scrollTo(0,0)}}static writeState(t,e,r){if(!t)return;let o=a(t);if(!s()||o.href!==location.href){if(r&&"_self"!==r)return open(o,r);e===_&&R++,s()&&W(),w(this.routers,r=>{r.direction=L,s()&&(r.prev=a(location.href),history[e===_?"pushState":"replaceState"]({index:R},"",o)),r.href=o,r.resolve(t)}),I.dispatchEvent()}}static dispatchEvent(){s()&&window.dispatchEvent(new Event("pathchange"))}}const K=t=>class extends I{static[o]="Router";constructor(){super(),t(this)}};let q={route(t,e,s){let r=new T(t,e);return this.routes.set(t,r),s?.(r),this},group(t,e){let s=new S(t);return this.routes.set(t,s),e?.(s),this},notfound(){}};m(P.prototype,q),m(I.prototype,q),m(i.prototype,{router:{routers:/* @__PURE__ */new Set,resolve(t){return d(this.routers,e=>e.resolve(t))},href:new URL("http://localhost"),routes:[],matchPaths:[],navlinks:/* @__PURE__ */new Set}}),i.disposers.add(({router:t})=>{t.routers.clear(),t.routes=[],t.matchPaths=[],t.navlinks.clear()}),m($,{router:t=>K(t),open:I.open,replace:I.replace,back:I.back,forward:I.forward,scrollRestoration:I.scrollRestoration,title(t){let e=r.proto?.findAbove(t=>h(t,x));e&&(e.title=t,e.updateTitle())}}),globalThis.Link=b,globalThis.NavLink=class extends b{constructor(t,e){super(t,e),this.global.router.navlinks.add(this)}checkActive(){let t=this.attr("href");if(t){for(let e of this.global.router.matchPaths)if(a(e).href===a(t).href)return this.attr("active","");this.attr("active",n)}}},$.process.craft.add(t=>{if(p(t)&&"Router"===t[o]){let e=r.proto,s=new t;return e?.global.router.routers.add(s),s}});export{b as Link,x as Page,P as Route,S as RouteGroup,T as RouteNode,k as RouteSlot,I as RouterProto};
|
package/build/signal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_null as e,isSymbol as s,isString as t,forEach as i,_Object_entries as r,isFunction as
|
|
1
|
+
import{_null as e,isSymbol as s,isString as t,forEach as i,_Object_entries as r,isFunction as a,isUndefined as u,_Object_assign as l,_instanceof as n,isIncluded as h,isBoolean as c}from"@amateras/utils";import{symbol_Signal as o,Proto as p,GlobalState as d,TextProto as m}from"@amateras/core";let b=!1,v=/* @__PURE__ */new Set,f=e=>{b=!1;let s=e();return b=!0,s},g=e=>{b=!0;let s=e(f);return b=!1,s},k=new FinalizationRegistry(({signal:e,ref:s})=>{e.computes?.delete(s)});class x extends Function{[o]=!0;linked=e;_value;subs=e;map=e;exec=e;computes=e;constructor(e){return super(),p.proto?.global.signals.add(this),this._value=e,new Proxy(this,{apply:()=>this._exec(),get:(e,i)=>{if(s(i)||t(i)&&!i.endsWith("$"))return this[i];const r=this.value[i.slice(0,-1)];this.map||(this.map={});const a=this.map[i]??new x(r);return this.map[i]=a,a}})}_exec(){return b&&v.add(this),this.value}get value(){return this.linked?this.linked.value:this._value}dispose(){this.subs=e,this.linked=e,i(this.computes,e=>e.deref()?.dispose()),this.computes=e,this.exec=e,this._value=e,this.map&&i(r(this.map),([e,s])=>s.dispose()),this.map=e}set(e){this.linked?this.linked.set(e):a(e)?this.set(e(this.value)):this.value!==e&&(this._value=e,this.emit())}modify(e){e(this.value),this.emit()}emit(){i(this.subs,e=>e(this.value)),i(this.computes,e=>{let s=e.deref();s||this.computes?.delete(e),s?.exec?.()})}subscribe(e){this.subs=this.subs??[],this.subs.push(e)}unsubscribe(e){let s=this.subs?.indexOf(e);u(s)||-1===s||this.subs?.splice(s,1)}link(e){if(this===e)throw"Signal.link(): cannot link self";this.linked=e,this.emit(),e.subscribe(()=>this.emit())}is(e){return e(this)}toString(){return`${this.value}`}}d.assign({signals:/* @__PURE__ */new Set}),d.disposers.add(e=>{i(e.signals,e=>e.dispose()),e.signals.clear()}),l($,{signal:e=>new x(e),effect(e){g(e),i(v,s=>s.subscribe(s=>e(f))),v.clear()},compute(e){let s=g(e),t=$.signal(s);return t.exec=()=>t.set(e(f)),i(v,e=>{e.computes=e.computes??/* @__PURE__ */new Set;let s=new WeakRef(t);e.computes.add(s),k.register(t,{signal:e,ref:s})}),v.clear(),t},optional:s=>s.value?s:e,resolve:(e,s)=>n(e,x)?(s&&(e.subscribe(s),s(e)),e.value):(s?.(e),e)});let w=e=>{if(n(e,x)){let s=new m(`${e}`),t=e=>s.content=`${e}`;return e.subscribe(t),s.ondispose(()=>e.unsubscribe(t)),t(e.value),s}};$.process.text.add(w),$.process.craft.add(w),$.process.attr.add((e,s,t)=>{if(n(s,x)){if("input"===t.tagname){if(h(e,["value","checked"])){t.on("input",t=>s.set(t.currentTarget[e]));let i=s.value;c(i)?i&&t.attr(e,""):t.attr(e,`${i}`)}}else{let i=()=>t.attr(e,s.value);s.subscribe(i),i(),t.ondispose(()=>s.unsubscribe(i))}return!0}});export{x as Signal};
|
package/build/ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e,s,i,r=Object.defineProperty,n=t=>{throw TypeError(t)},a=(t,e,s)=>((t,e,s)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),o=(t,e,s)=>e.has(t)||n("Cannot "+s),l=(t,e,s)=>(o(t,e,"read from private field"),s?s.call(t):e.get(t)),c=(t,e,s)=>e.has(t)?n("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),h=(t,e,s,i)=>(o(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s);import{onclient as d,ElementProto as u,TextProto as p,Proto as g}from"@amateras/core";import{_null as v,is as b,UID as m,forEach as f,isEqual as k,_Object_assign as x,_Object_entries as y,isObject as w,isUndefined as M,isNull as D,_instanceof as z,isString as I}from"@amateras/utils";const O=t=>(e,s,i)=>{if(e.slide=s,!d())return;let r=s.toDOM();e.node?.append(...r);let n={duration:t?.duration??500,easing:t?.easing??"ease"},a=$.match(t?.direction,t=>t.case("up",()=>[["0 100%","0 0"],["0 0","0 -100%"]]).case("down",()=>[["0 -100%","0 0"],["0 0","0 100%"]]).case("left",()=>[["100% 0","0 0"],["0 0","-100% 0"]]).case("right",()=>[["-100% 0","0 0"],["0 0","100% 0"]]).default(()=>[["100% 0","0 0"],["0 0","-100% 0"]]));s.node?.animate({translate:a[0]},n);const o=i?.node?.animate({translate:a[1]},n);o&&(o.onfinish=()=>i?.node?.remove())},S=class extends u{constructor(t,e){super("slide",t,e)}};$.style(S,"slide{display:block;height:100%;width:100%;position:absolute}");let A=S;const C=class extends u{constructor({index:s,interval:i,autoplay:r,autopause:n,animation:o,...l},h){super("slideshow",l,h),a(this,"slide",v),a(this,"index"),a(this,"timer",v),a(this,"interval"),a(this,"autoplay"),a(this,"autopause"),a(this,"animation"),c(this,t,0),c(this,e,v),a(this,"playing",!1),this.index=s??0,this.interval=i??5,this.autoplay=r??!1,this.autopause=n??!0,this.animation=o??v,this.ondispose(()=>this.pause()),this.ondom(()=>{this.autoplay&&this.play()})}build(){return super.build(),this.switch(this.index),this}toString(){return this.parseHTML({children:this.slide?.toString()})}toDOM(t=!0){return super.toDOM(!1),this.node&&!l(this,e)&&(h(this,e,new ResizeObserver(()=>{this.autopause&&(this.inDOM()?this.play():this.pause())})),l(this,e).observe(this.node)),t&&this.slide&&this.node?.append(...this.slide.toDOM()),[this.node]}play(){this.playing||(this.playing=!0,this.timer=setInterval(()=>{var e,s,i,r;(e=this,s=t,{set _(t){h(e,s,t,i)},get _(){return l(e,s,r)}})._++,l(this,t)>=100*this.interval&&(this.next(),h(this,t,0))},10))}pause(){this.playing=!1,this.timer&&clearTimeout(this.timer)}next(){let t=this.children.length,e=this.index+1;e>=t&&(e=0),this.switch(e)}prev(){let t=this.children.length,e=this.index-1;e<=0&&(e=t-1),this.switch(e)}switch(t){this.index=t;let e=this.children.at(t);this.slide!==e&&e&&(this.animation?this.animation(this,e,this.slide):(this.append(e),this.slide=e,this.node?.replaceChildren(...e.toDOM())),e.node?.dispatchEvent(new Event("showslide")))}};t=new WeakMap,e=new WeakMap,$.style(C,"slideshow{display:block;position:relative;overflow:clip}");let E=C;const L=class extends u{value;constructor({value:t,...e},s){super("radio-group",e,s),this.value=t,this.on("input",t=>{this.value=b(t.target,HTMLInputElement)?.value})}};$.style(L,"radio-group{display:block}");let W=L;const H=class extends u{inputId;name;value;constructor({inputId:t,name:e,value:s,...i},r){super("radio-item",i,r),this.inputId=t??`input-${m.persistInProto(this,"radio-item")}`,this.name=e??v,this.value=s}};$.style(H,"radio-item{display:block}");let R=H;class T extends u{constructor(t,e){super("input",{type:"radio",...t},e)}build(t){let e=this.findAbove(t=>b(t,R));return e&&(this.attr("id",e.inputId),this.attr("name",e.name)),super.build(t)}}class B extends u{constructor(t,e){super("label",t,e)}build(t){let e=this.findAbove(t=>b(t,R));return e&&this.attr("for",e.inputId),super.build(t)}}const _=class extends u{constructor(t,e){super("text-block",t,e)}};$.style(_,"text-block{display:block}");let j=_;const[F,P,U,q,N]=["accordion","accordion-item","accordion-trigger","accordion-content","accordion-container"],X=class extends u{$trigger=v;$container=v;constructor(t,e){super(F,t,e)}open(){this.attr("opened","")}close(){this.attr("opened",null)}switch(){""===this.attr("opened")?this.close():this.open()}};$.style(X,[`${F},${P},${U}{display:block}`,`${N}{display:grid;grid-template-rows:0fr}`,`${F}[opened] ${N}{grid-template-rows:1fr}`,`${q}{overflow:hidden}`]);let Y=X;class Z extends u{constructor(t,e){super(N,t,e)}build(t){let e=this.findAbove(t=>b(t,Y));return e&&(e.$container=this),super.build(t)}}class G extends u{constructor(t,e){super(q,t,e)}}class J extends u{constructor(t,e){super(U,t,e)}build(t){let e=this.findAbove(t=>b(t,Y));return e&&(e.$trigger=this,this.on("click",()=>e.switch())),super.build(t)}}const K=class extends u{gap;columns;size;observer=null;constructor({gap:t,columns:e,autosize:s,size:i,...r},n){super("waterfall",r,n),this.gap=t??0,this.columns=e??1,this.size=i??0,d()&&(this.observer=new ResizeObserver(()=>{this.inDOM()&&requestAnimationFrame(()=>this.refresh())}))}toDOM(t){return super.toDOM(t),this.node&&this.observer?.observe(this.node),[this.node]}refresh(){if(!this.node)return;const t=[],e=this.node.offsetWidth;let s=this.columns;this.size&&(s=Math.trunc(e/(this.size+this.gap))||1);const i=(e-this.gap*(s-1))/s;for(let r=0;r<s;r++)t.push({items:[],height:0,width:i,left:r*(i+this.gap)});f(this.children,e=>{if(!e.node)return;e.ratio||e.node.offsetHeight&&e.node.offsetWidth&&(e.ratio=e.node.offsetWidth/e.node.offsetHeight);const s=i/e.ratio,r=t.sort((t,e)=>t.height-e.height)[0];e.style({height:`${s}px`,width:`${i}px`,top:`${r.height}px`,left:`${r.left}px`}),r.height+=s+this.gap})}mutate(){this.refresh()}};$.style(K,"waterfall{display:block;position:relative;min-height:100dvh}");let Q=K;const V=class extends u{ratio=0;constructor(t,e){super("waterfall-item",t,e)}toDOM(t){super.toDOM(t);const e=this.findAbove(t=>b(t,Q));return this.node?.querySelectorAll("img").forEach(t=>e?.observer?.observe(t)),[this.node]}};$.style(V,"waterfall-item{display:block;position:absolute}");let tt=V;const et=class extends u{targetId;$container=v;triggers=/* @__PURE__ */new Map;constructor({targetId:t,...e},s){super("tabs",e,s),this.targetId=t}switch(t){this.targetId!==t&&(this.targetId=t,this.$container?.renderContent())}};$.style(et,"tabs{display:block;}");let st=et;class it extends u{tabId;tabs=v;constructor({tabId:t,...e},s){super("tab-trigger",e,s),this.tabId=t,this.on("click",()=>this.tabs?.switch(this.tabId))}build(t){return super.build(t),this.tabs=this.findAbove(t=>b(t,st)),this.tabs?.triggers.set(this.tabId,this),this}}$.style(st,"tab-trigger{cursor:pointer;}");class rt extends u{tabs=null;constructor({...t},e){super("tab-container",t,e)}build(t){return super.build(t),this.tabs=this.findAbove(t=>b(t,st)),this.tabs&&(this.tabs.$container=this),this}toDOM(t=!0){return super.toDOM(!1),this.renderContent(t),[this.node]}toString(){return this.parseHTML({children:this.renderContent()?.toString()})}mutate(){this.renderContent()}getContent(t){return this.children.find(e=>e.tabId===t)}renderContent(t=!0){const e=this.tabs?.targetId,s=e?this.getContent(e):this.children.at(0);return t&&s&&(this.node?.replaceChildren(...s.toDOM()),this.tabs?.triggers.forEach(t=>{t.attr("active",t.tabId===s.tabId?"":v)})),s}}$.style(st,"tab-container{display:block;}");class nt extends u{tabId;tabs=null;constructor({tabId:t,...e},s){super("tab-content",e,s),this.tabId=t}build(t){return super.build(t),this.tabs=this.findAbove(t=>b(t,st)),this}}$.style(st,"tab-content{display:block;}");const at=(t,{style:e},s)=>{let i=t.getBoundingClientRect(),r={top:i.top+window.scrollY,left:i.left+window.scrollX,width:i.width,height:i.height},{top:n,left:a,width:o,height:l}=r;k(s,r,["top","left","height","width"])||(x(s,{top:n,left:a,width:o,height:l}),e.top=`${l+n}px`,e.left=`${a}px`,e.width=`${o}px`)},ot=(t,e)=>{let s=[];for(let[i,r]of y(e))w(r)?s.push(ot(i,r)):s.push(`${i.replaceAll(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}: ${r};`);return`${t} { ${s.join(" ")} }`},lt=class t extends u{constructor(e,i){super(t.tagname,e,i),a(this,"$trigger",v),a(this,"$content",v),a(this,"clickListener",v),c(this,s,v),a(this,"selected",v),a(this,"itemMap",/* @__PURE__ */new Map),a(this,"$value",v),a(this,"disconnect",v),this.listen("i18nupdate",()=>this.$value?.render())}props({value:t,disabled:e,...s}){super.props(s),e&&this.disabled(e),this.value(t)}disabled(t){if(!arguments.length)return""===this.attr("disabled");$.resolve(t,t=>{this.attr("disabled",t?"":v)})}value(t){if(!arguments.length)return l(this,s);M(t)||($.resolve(t,t=>{h(this,s,t);let e=this.itemMap.get(t);this.selected=e??v,this.$value?.render()}),this.node?.dispatchEvent(new Event("select-value")))}open(){this.attr("opened",""),d()&&this.$content&&(this.disconnect=((t,e)=>{let s={top:0,left:0,height:0,width:0},i=new ResizeObserver(()=>at(t,e,s)),r=()=>at(t,e,s);return i.observe(t),window.addEventListener("resize",r),()=>{i.disconnect(),window.removeEventListener("resize",r)}})(this.$trigger?.node,this.$content.node),document.body.append(...this.$content.toDOM()),this.clickListener=t=>{t.target!==this.$trigger?.node&&(t.target&&this.$content?.node?.contains(t.target)||this.close())},this.selected?.node?.focus(),window.addEventListener("click",this.clickListener))}close(){this.attr("opened",v),d()&&(this.$content?.removeNode(),this.clickListener&&window.removeEventListener("click",this.clickListener),this.disconnect?.(),this.disconnect=v)}toDOM(t){return super.toDOM(!1),t&&this.$trigger&&(this.node?.append(...this.$trigger.toDOM()),this.$content?.toDOM(),this.$value?.render()),[this.node]}toString(){let t=this.$trigger?.toString()??"";return this.parseHTML({children:t})}};s=new WeakMap,a(lt,"tagname","select-proto"),$.style(lt,ot(lt.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let ct=lt;const ht=class t extends u{$select=v;constructor(e,s){super(t.tagname,{tabindex:0,...e},s),this.on("click",t=>D(this.$select?.attr("opened"))?this.$select.open():this.$select?.close()),this.on("keydown",t=>{if(" "===t.key)t.preventDefault()}),this.on("keyup",t=>{switch(t.key){case" ":case"Enter":t.preventDefault(),this.$select?.open()}})}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$select&&(this.$select.$trigger=this),this}};a(ht,"tagname","select-trigger"),$.style(ht,ot(ht.tagname,{display:"flex",gap:"0.5rem",placeContent:"space-between",placeItems:"center",boxSizing:"border-box",border:"1px solid var(--input)",background:"color-mix(in oklch, var(--input) 30%, transparent)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",lineHeight:"1","&:hover":{background:"color-mix(in oklch, var(--input) 50%, transparent)"},"&:focus":{outline:"0.1rem solid var(--border)"},"*":{pointerEvents:"none"}}));let dt=ht;class ut extends u{static tagname="select-value";$select=v;$placeholder=v;$text=new p("");constructor(t,e){super(ut.tagname,t,e)}props({placeholder:t,...e}){super.props(e),this.placeholder(t??v)}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$select&&(this.$select.$value=this),this}placeholder(t){$.resolve(t,t=>{I(t)?$.context(g,this,()=>this.$placeholder=new p(t)):this.$placeholder=t,this.render()})}render(){let t=v;this.$select?.selected?(t=this.$text,this.$text.content=this.$select.selected.text):this.$placeholder&&(t=this.$placeholder),t&&(t.builded||t.build(),this.replaceProtos(t),this.node?.replaceChildren(...t.toDOM()))}}const pt=class t extends u{$select=v;constructor(e,s){super(t.tagname,e,s)}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$select&&(this.$select.$content=this),this}};a(pt,"tagname","select-content"),$.style(pt,ot(pt.tagname,{position:"absolute",top:"0",left:"0",display:"block",boxSizing:"border-box",border:"1px solid var(--input)",background:"oklch(from var(--bg) l c h)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",userSelect:"none"}));let gt=pt;const vt=class t extends u{constructor(e,s){super(t.tagname,{tabindex:0,...e},s),a(this,"$select",v),a(this,"$content",v),c(this,i,v),this.on("click",()=>{this.$select?.close(),this.select()}),this.on("keydown",e=>{let s=s=>{if(e.preventDefault(),!this.$content)return;let i=this.$content?.findBelowAll(e=>z(e,t)),r=i.indexOf(this),n="up"===s?r-1:r+1;(n<0||n>=i.length)&&(n="up"===s?-1:0);let a=i.at(n);a?.node?.focus()};switch(e.key){case"ArrowDown":s("down");break;case"ArrowUp":s("up");break;case" ":e.preventDefault()}}),this.on("keyup",t=>{switch(t.key){case"Escape":t.preventDefault(),this.$select?.close(),this.$select?.$trigger?.node?.focus();break;case" ":case"Enter":t.preventDefault(),this.select(),this.$select?.close(),this.$select?.$trigger?.node?.focus()}})}value(t){if(!arguments.length)return l(this,i);M(t)||$.resolve(t,t=>{h(this,i,t)})}select(){this.$select&&this.$select.value(this.value())}props({value:t,...e}){super.props(e),this.value(t)}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$content=this.findAbove(t=>z(t,gt)),this.$select?.itemMap.set(l(this,i),this),this}};i=new WeakMap,a(vt,"tagname","select-item"),$.style(vt,ot(vt.tagname,{display:"block",boxSizing:"border-box",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"500",lineHeight:"1","&:hover, :not(:has(select-item:hover)) &:focus":{background:"oklch(from var(--input) l c h / .1)"},"&:focus":{outline:"none"}}));let bt=vt;class mt extends u{constructor(t,e){super("selector-group",t,e)}}const ft=class t extends u{constructor(e,s){super(t.tagname,e,s)}props({svg:t,...e}){super.props(e),this.svg(t)}svg(t){$.resolve(t,t=>{this.innerHTML(t)})}};a(ft,"tagname","icon"),$.style(ft,ot(ft.tagname,{display:"inline-block",verticalAlign:"middle",svg:{display:"block",height:"1rem",width:"1rem"}}));let $t=ft;const kt=class extends $t{constructor(t){super({svg:'<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" class="lucide lucide-chevron-down-icon lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>',...t})}};$.style(kt,ot(`select-proto[opened] ${kt.tagname}`,{rotate:"180deg"}));let xt=kt;const yt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(yt,"tagname","button"),$.style(yt,ot(yt.tagname,{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",transition:"0.2s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"&:active":{translate:"0 0.125rem"},"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h / 1)"},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)","&:not([disabled]):hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)","&:not([disabled]):hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&:not([disabled]):hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}},'&[size="icon"]':{width:"calc(var(--spacing) * 8)",padding:"0"},'&[size="xs"]':{padding:"calc(var(--spacing) * 2)",fontSize:"var(--text_xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",svg:{width:"calc(var(--spacing) * 3)",height:"calc(var(--spacing) * 3)"}},'&[size="sm"]':{height:"calc(var(--spacing) * 7)"},'&[size="icon-sm"]':{width:"calc(var(--spacing) * 7)",height:"calc(var(--spacing) * 7)"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)"},"&[disabled]":{opacity:".5"}}));let wt=yt;const Mt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(Mt,"tagname","badge"),$.style(Mt,ot(Mt.tagname,{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2)",borderRadius:"calc(var(--radius) * 2.6)",height:"calc(var(--spacing) * 5)",transition:"0.2s all ease",fontSize:"var(--text-xs)",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",whiteSpace:"nowrap",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"a:not([disabled]) &:hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h / 1)"},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)","a:not([disabled]) &:hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)","a:not([disabled]) &:hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","a:not([disabled]) &:hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","a:not([disabled]) &:hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}},"a[disabled] &":{opacity:".5"}}));let Dt=Mt;const zt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(zt,"tagname","card"),$.style(zt,ot(zt.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing))",paddingBlock:"calc(var(--spacing) * 4)",background:"var(--secondary-bg)",borderRadius:"calc(var(--radius) * 1.4)"}));let It=zt;const Ot=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(Ot,"tagname","card-header"),$.style(Ot,ot(Ot.tagname,{display:"grid",width:"100%",gridTemplateRows:"auto auto",gap:"var(--spacing)",container:"card-header / inline-size ",paddingInline:"calc(var(--spacing) * 4)"}));let St=Ot;const At=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(At,"tagname","card-content"),$.style(At,ot(At.tagname,{paddingInline:"calc(var(--spacing) * 4)"}));let Ct=At;const Et=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(Et,"tagname","h3"),$.style(Et,ot(`card ${Et.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"1.375",fontSize:"var(--text-base)",color:"var(--fg)"}));let Lt=Et;const Wt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(Wt,"tagname","p"),$.style(Wt,ot(`card ${Wt.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"var(--line-height-sm)",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Ht=Wt;const Rt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(Rt,"tagname","dl"),$.style(Rt,ot(Rt.tagname,{display:"flex",flexDirection:"column"}));let Tt=Rt;const Bt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(Bt,"tagname","dc"),$.style(Bt,ot(Bt.tagname,{paddingBlock:"1rem",borderBottom:"1px solid color-mix(in oklch, var(--input) 50%, transparent)"}));let _t=Bt;const jt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(jt,"tagname","dt"),$.style(jt,ot(jt.tagname,{fontSize:"var(--text-sm)",fontWeight:"var(--font-weight-medium)"}));let Ft=jt;const Pt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};a(Pt,"tagname","dd"),$.style(Pt,ot(Pt.tagname,{margin:"0",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Ut=Pt;export{Y as Accordion,Z as AccordionContainer,G as AccordionContent,J as AccordionTrigger,Dt as Badge,wt as Button,It as Card,Ct as CardContent,Ht as CardDescription,St as CardHeader,Lt as CardTitle,_t as DescriptionContent,Ut as DescriptionDetail,Tt as DescriptionList,Ft as DescriptionTerm,$t as Icon,B as Label,T as Radio,W as RadioGroup,R as RadioItem,ct as Select,xt as SelectArrow,gt as SelectContent,mt as SelectGroup,bt as SelectItem,dt as SelectTrigger,ut as SelectValue,A as Slide,E as Slideshow,nt as TabContent,it as TabTrigger,st as Tabs,rt as TabsContainer,j as TextBlock,Q as Waterfall,tt as WaterfallItem,O as slideInOut};
|
|
1
|
+
var t,e,s,i,r=Object.defineProperty,n=t=>{throw TypeError(t)},o=(t,e,s)=>((t,e,s)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),a=(t,e,s)=>e.has(t)||n("Cannot "+s),l=(t,e,s)=>(a(t,e,"read from private field"),s?s.call(t):e.get(t)),c=(t,e,s)=>e.has(t)?n("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),h=(t,e,s,i)=>(a(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s);import{onclient as d,ElementProto as u,TextProto as p,Proto as g}from"@amateras/core";import{_null as v,is as b,UID as m,forEach as f,isEqual as k,_Object_assign as x,_Object_entries as y,isObject as w,isUndefined as M,isNull as D,_instanceof as z,isString as I}from"@amateras/utils";const O=t=>(e,s,i)=>{if(e.slide=s,!d())return;let r=s.toDOM();e.node?.append(...r);let n={duration:t?.duration??500,easing:t?.easing??"ease"},o=$.match(t?.direction,t=>t.case("up",()=>[["0 100%","0 0"],["0 0","0 -100%"]]).case("down",()=>[["0 -100%","0 0"],["0 0","0 100%"]]).case("left",()=>[["100% 0","0 0"],["0 0","-100% 0"]]).case("right",()=>[["-100% 0","0 0"],["0 0","100% 0"]]).default(()=>[["100% 0","0 0"],["0 0","-100% 0"]]));s.node?.animate({translate:o[0]},n);const a=i?.node?.animate({translate:o[1]},n);a&&(a.onfinish=()=>i?.node?.remove())},S=class extends u{constructor(t,e){super("slide",t,e)}};$.style(S,"slide{display:block;height:100%;width:100%;position:absolute}");let A=S;const C=class extends u{constructor({index:s,interval:i,autoplay:r,autopause:n,animation:a,...l},h){super("slideshow",l,h),o(this,"slide",v),o(this,"index"),o(this,"timer",v),o(this,"interval"),o(this,"autoplay"),o(this,"autopause"),o(this,"animation"),c(this,t,0),c(this,e,v),o(this,"playing",!1),this.index=s??0,this.interval=i??5,this.autoplay=r??!1,this.autopause=n??!0,this.animation=a??v,this.ondispose(()=>this.pause()),this.ondom(()=>{this.autoplay&&this.play()})}build(){return super.build(),this.switch(this.index),this}toString(){return this.parseHTML({children:this.slide?.toString()})}toDOM(t=!0){return super.toDOM(!1),this.node&&!l(this,e)&&(h(this,e,new ResizeObserver(()=>{this.autopause&&(this.inDOM()?this.play():this.pause())})),l(this,e).observe(this.node)),t&&this.slide&&this.node?.append(...this.slide.toDOM()),[this.node]}play(){this.playing||(this.playing=!0,this.timer=setInterval(()=>{var e,s,i,r;(e=this,s=t,{set _(t){h(e,s,t,i)},get _(){return l(e,s,r)}})._++,l(this,t)>=100*this.interval&&(this.next(),h(this,t,0))},10))}pause(){this.playing=!1,this.timer&&clearTimeout(this.timer)}next(){let t=this.children.length,e=this.index+1;e>=t&&(e=0),this.switch(e)}prev(){let t=this.children.length,e=this.index-1;e<=0&&(e=t-1),this.switch(e)}switch(t){this.index=t;let e=this.children.at(t);this.slide!==e&&e&&(this.animation?this.animation(this,e,this.slide):(this.append(e),this.slide=e,this.node?.replaceChildren(...e.toDOM())),e.node?.dispatchEvent(new Event("showslide")))}};t=new WeakMap,e=new WeakMap,$.style(C,"slideshow{display:block;position:relative;overflow:clip}");let E=C;const L=class extends u{value;constructor({value:t,...e},s){super("radio-group",e,s),this.value=t,this.on("input",t=>{this.value=b(t.target,HTMLInputElement)?.value})}};$.style(L,"radio-group{display:block}");let W=L;const H=class extends u{inputId;name;value;constructor({inputId:t,name:e,value:s,...i},r){super("radio-item",i,r),this.inputId=t??`input-${m.persistInProto(this,"radio-item")}`,this.name=e??v,this.value=s}};$.style(H,"radio-item{display:block}");let R=H;class T extends u{constructor(t,e){super("input",{type:"radio",...t},e)}build(t){let e=this.findAbove(t=>b(t,R));return e&&(this.attr("id",e.inputId),this.attr("name",e.name)),super.build(t)}}class B extends u{constructor(t,e){super("label",t,e)}build(t){let e=this.findAbove(t=>b(t,R));return e&&this.attr("for",e.inputId),super.build(t)}}const _=class extends u{constructor(t,e){super("text-block",t,e)}};$.style(_,"text-block{display:block}");let j=_;const[F,P,U,q,N]=["accordion","accordion-item","accordion-trigger","accordion-content","accordion-container"],X=class extends u{$trigger=v;$container=v;constructor(t,e){super(F,t,e)}open(){this.attr("opened","")}close(){this.attr("opened",null)}switch(){""===this.attr("opened")?this.close():this.open()}};$.style(X,[`${F},${P},${U}{display:block}`,`${N}{display:grid;grid-template-rows:0fr}`,`${F}[opened] ${N}{grid-template-rows:1fr}`,`${q}{overflow:hidden}`]);let Y=X;class Z extends u{constructor(t,e){super(N,t,e)}build(t){let e=this.findAbove(t=>b(t,Y));return e&&(e.$container=this),super.build(t)}}class G extends u{constructor(t,e){super(q,t,e)}}class J extends u{constructor(t,e){super(U,t,e)}build(t){let e=this.findAbove(t=>b(t,Y));return e&&(e.$trigger=this,this.on("click",()=>e.switch())),super.build(t)}}const K=class extends u{gap;columns;size;observer=null;constructor({gap:t,columns:e,autosize:s,size:i,...r},n){super("waterfall",r,n),this.gap=t??0,this.columns=e??1,this.size=i??0,d()&&(this.observer=new ResizeObserver(()=>{this.inDOM()&&requestAnimationFrame(()=>this.refresh())}))}toDOM(t){return super.toDOM(t),this.node&&this.observer?.observe(this.node),[this.node]}refresh(){if(!this.node)return;const t=[],e=this.node.offsetWidth;let s=this.columns;this.size&&(s=Math.trunc(e/(this.size+this.gap))||1);const i=(e-this.gap*(s-1))/s;for(let r=0;r<s;r++)t.push({items:[],height:0,width:i,left:r*(i+this.gap)});f(this.children,e=>{if(!e.node)return;e.ratio||e.node.offsetHeight&&e.node.offsetWidth&&(e.ratio=e.node.offsetWidth/e.node.offsetHeight);const s=i/e.ratio,r=t.sort((t,e)=>t.height-e.height)[0];e.style({height:`${s}px`,width:`${i}px`,top:`${r.height}px`,left:`${r.left}px`}),r.height+=s+this.gap})}mutate(){this.refresh()}};$.style(K,"waterfall{display:block;position:relative;min-height:100dvh}");let Q=K;const V=class extends u{ratio=0;constructor(t,e){super("waterfall-item",t,e)}toDOM(t){super.toDOM(t);const e=this.findAbove(t=>b(t,Q));return this.node?.querySelectorAll("img").forEach(t=>e?.observer?.observe(t)),[this.node]}};$.style(V,"waterfall-item{display:block;position:absolute}");let tt=V;const et=class extends u{targetId;$container=v;triggers=/* @__PURE__ */new Map;constructor({targetId:t,...e},s){super("tabs",e,s),this.targetId=t}switch(t){this.targetId!==t&&(this.targetId=t,this.$container?.renderContent())}};$.style(et,"tabs{display:block;}");let st=et;class it extends u{tabId;tabs=v;constructor({tabId:t,...e},s){super("tab-trigger",e,s),this.tabId=t,this.on("click",()=>this.tabs?.switch(this.tabId))}build(t){return super.build(t),this.tabs=this.findAbove(t=>b(t,st)),this.tabs?.triggers.set(this.tabId,this),this}}$.style(st,"tab-trigger{cursor:pointer;}");class rt extends u{tabs=null;constructor({...t},e){super("tab-container",t,e)}build(t){return super.build(t),this.tabs=this.findAbove(t=>b(t,st)),this.tabs&&(this.tabs.$container=this),this}toDOM(t=!0){return super.toDOM(!1),this.renderContent(t),[this.node]}toString(){return this.parseHTML({children:this.renderContent()?.toString()})}mutate(){this.renderContent()}getContent(t){return this.children.find(e=>e.tabId===t)}renderContent(t=!0){const e=this.tabs?.targetId,s=e?this.getContent(e):this.children.at(0);return t&&s&&(this.node?.replaceChildren(...s.toDOM()),this.tabs?.triggers.forEach(t=>{t.attr("active",t.tabId===s.tabId?"":v)})),s}}$.style(st,"tab-container{display:block;}");class nt extends u{tabId;tabs=null;constructor({tabId:t,...e},s){super("tab-content",e,s),this.tabId=t}build(t){return super.build(t),this.tabs=this.findAbove(t=>b(t,st)),this}}$.style(st,"tab-content{display:block;}");const ot=(t,{style:e},s)=>{let i=t.getBoundingClientRect(),r={top:i.top+window.scrollY,left:i.left+window.scrollX,width:i.width,height:i.height},{top:n,left:o,width:a,height:l}=r;k(s,r,["top","left","height","width"])||(x(s,{top:n,left:o,width:a,height:l}),e.top=`${l+n}px`,e.left=`${o}px`,e.width=`${a}px`)},at=(t,e)=>{let s=[];for(let[i,r]of y(e))w(r)?s.push(at(i,r)):s.push(`${i.replaceAll(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}: ${r};`);return`${t} { ${s.join(" ")} }`},lt=class t extends u{constructor(e,i){super(t.tagname,e,i),o(this,"$trigger",v),o(this,"$content",v),o(this,"clickListener",v),c(this,s,v),o(this,"selected",v),o(this,"itemMap",/* @__PURE__ */new Map),o(this,"$value",v),o(this,"disconnect",v),this.listen("i18nupdate",()=>this.$value?.render())}props({value:t,disabled:e,...s}){super.props(s),e&&this.disabled(e),this.value(t)}disabled(t){if(!arguments.length)return""===this.attr("disabled");$.resolve(t,t=>{this.attr("disabled",t?"":v)})}value(t){if(!arguments.length)return l(this,s);M(t)||($.resolve(t,t=>{h(this,s,t);let e=this.itemMap.get(t);this.selected=e??v,this.$value?.render()}),this.node?.dispatchEvent(new Event("select-value")))}open(){this.attr("opened",""),d()&&this.$content&&(this.disconnect=((t,e)=>{let s={top:0,left:0,height:0,width:0},i=new ResizeObserver(()=>ot(t,e,s)),r=()=>ot(t,e,s);return i.observe(t),window.addEventListener("resize",r),()=>{i.disconnect(),window.removeEventListener("resize",r)}})(this.$trigger?.node,this.$content.node),document.body.append(...this.$content.toDOM()),this.clickListener=t=>{t.target!==this.$trigger?.node&&(t.target&&this.$content?.node?.contains(t.target)||this.close())},this.selected?.node?.focus(),window.addEventListener("click",this.clickListener))}close(){this.attr("opened",v),d()&&(this.$content?.removeNode(),this.clickListener&&window.removeEventListener("click",this.clickListener),this.disconnect?.(),this.disconnect=v)}toDOM(t){return super.toDOM(!1),t&&this.$trigger&&(this.node?.append(...this.$trigger.toDOM()),this.$content?.toDOM(),this.$value?.render()),[this.node]}toString(){let t=this.$trigger?.toString()??"";return this.parseHTML({children:t})}};s=new WeakMap,o(lt,"tagname","select-proto"),$.style(lt,at(lt.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let ct=lt;const ht=class t extends u{$select=v;constructor(e,s){super(t.tagname,{tabindex:0,...e},s),this.on("click",t=>D(this.$select?.attr("opened"))?this.$select.open():this.$select?.close()),this.on("keydown",t=>{if(" "===t.key)t.preventDefault()}),this.on("keyup",t=>{switch(t.key){case" ":case"Enter":t.preventDefault(),this.$select?.open()}})}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$select&&(this.$select.$trigger=this),this}};o(ht,"tagname","select-trigger"),$.style(ht,at(ht.tagname,{display:"flex",gap:"0.5rem",placeContent:"space-between",placeItems:"center",boxSizing:"border-box",border:"1px solid var(--input)",background:"color-mix(in oklch, var(--input) 30%, transparent)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",lineHeight:"1","&:hover":{background:"color-mix(in oklch, var(--input) 50%, transparent)"},"&:focus":{outline:"0.1rem solid var(--border)"},"*":{pointerEvents:"none"}}));let dt=ht;class ut extends u{static tagname="select-value";$select=v;$placeholder=v;$text=new p("");constructor(t,e){super(ut.tagname,t,e)}props({placeholder:t,...e}){super.props(e),this.placeholder(t??v)}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$select&&(this.$select.$value=this),this}placeholder(t){$.resolve(t,t=>{I(t)?$.context(g,this,()=>this.$placeholder=new p(t)):this.$placeholder=t,this.render()})}render(){let t=v;this.$select?.selected?(t=this.$text,this.$text.content=this.$select.selected.text):this.$placeholder&&(t=this.$placeholder),t&&(t.builded||t.build(),this.replaceProtos(t),this.node?.replaceChildren(...t.toDOM()))}}const pt=class t extends u{$select=v;constructor(e,s){super(t.tagname,e,s)}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$select&&(this.$select.$content=this),this}};o(pt,"tagname","select-content"),$.style(pt,at(pt.tagname,{position:"absolute",top:"0",left:"0",display:"block",boxSizing:"border-box",border:"1px solid var(--input)",background:"oklch(from var(--bg) l c h)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",userSelect:"none"}));let gt=pt;const vt=class t extends u{constructor(e,s){super(t.tagname,{tabindex:0,...e},s),o(this,"$select",v),o(this,"$content",v),c(this,i,v),this.on("click",()=>{this.$select?.close(),this.select()}),this.on("keydown",e=>{let s=s=>{if(e.preventDefault(),!this.$content)return;let i=this.$content?.findBelowAll(e=>z(e,t)),r=i.indexOf(this),n="up"===s?r-1:r+1;(n<0||n>=i.length)&&(n="up"===s?-1:0);let o=i.at(n);o?.node?.focus()};switch(e.key){case"ArrowDown":s("down");break;case"ArrowUp":s("up");break;case" ":e.preventDefault()}}),this.on("keyup",t=>{switch(t.key){case"Escape":t.preventDefault(),this.$select?.close(),this.$select?.$trigger?.node?.focus();break;case" ":case"Enter":t.preventDefault(),this.select(),this.$select?.close(),this.$select?.$trigger?.node?.focus()}})}value(t){if(!arguments.length)return l(this,i);M(t)||$.resolve(t,t=>{h(this,i,t)})}select(){this.$select&&this.$select.value(this.value())}props({value:t,...e}){super.props(e),this.value(t)}build(t){return super.build(t),this.$select=this.findAbove(t=>z(t,ct)),this.$content=this.findAbove(t=>z(t,gt)),this.$select?.itemMap.set(l(this,i),this),this}};i=new WeakMap,o(vt,"tagname","select-item"),$.style(vt,at(vt.tagname,{display:"block",boxSizing:"border-box",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"500",lineHeight:"1","&:hover, :not(:has(select-item:hover)) &:focus":{background:"oklch(from var(--input) l c h / .1)"},"&:focus":{outline:"none"}}));let bt=vt;class mt extends u{constructor(t,e){super("selector-group",t,e)}}const ft=class t extends u{constructor(e,s){super(t.tagname,e,s)}props({svg:t,...e}){super.props(e),this.svg(t)}svg(t){$.resolve(t,t=>{this.innerHTML(t)})}};o(ft,"tagname","icon"),$.style(ft,at(ft.tagname,{display:"inline-block",verticalAlign:"middle",height:"1rem",width:"1rem",svg:{display:"block",height:"auto",width:"100%"}}));let $t=ft;const kt=class extends $t{constructor(t){super({svg:'<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" class="lucide lucide-chevron-down-icon lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>',...t})}};$.style(kt,at(`select-proto[opened] ${kt.tagname}`,{rotate:"180deg"}));let xt=kt;const yt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(yt,"tagname","button"),$.style(yt,at(yt.tagname,{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",transition:"0.2s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"&:active":{translate:"0 0.125rem"},"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h / 1)"},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)","&:not([disabled]):hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)","&:not([disabled]):hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&:not([disabled]):hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}},'&[size="icon"]':{width:"calc(var(--spacing) * 8)",padding:"0"},'&[size="xs"]':{padding:"calc(var(--spacing) * 2)",fontSize:"var(--text_xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",svg:{width:"calc(var(--spacing) * 3)",height:"calc(var(--spacing) * 3)"}},'&[size="sm"]':{height:"calc(var(--spacing) * 7)"},'&[size="icon-sm"]':{width:"calc(var(--spacing) * 7)",height:"calc(var(--spacing) * 7)"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)"},"&[disabled]":{opacity:".5"}}));let wt=yt;const Mt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(Mt,"tagname","badge"),$.style(Mt,at(Mt.tagname,{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2)",borderRadius:"calc(var(--radius) * 2.6)",height:"calc(var(--spacing) * 5)",transition:"0.2s all ease",fontSize:"var(--text-xs)",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",whiteSpace:"nowrap",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"a:not([disabled]) &:hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h / 1)"},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)","a:not([disabled]) &:hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)","a:not([disabled]) &:hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","a:not([disabled]) &:hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","a:not([disabled]) &:hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}},"a[disabled] &":{opacity:".5"}}));let Dt=Mt;const zt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(zt,"tagname","card"),$.style(zt,at(zt.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing))",paddingBlock:"calc(var(--spacing) * 4)",background:"var(--secondary-bg)",borderRadius:"calc(var(--radius) * 1.4)"}));let It=zt;const Ot=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(Ot,"tagname","card-header"),$.style(Ot,at(Ot.tagname,{display:"grid",width:"100%",gridTemplateRows:"auto auto",gap:"var(--spacing)",container:"card-header / inline-size ",paddingInline:"calc(var(--spacing) * 4)"}));let St=Ot;const At=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(At,"tagname","card-content"),$.style(At,at(At.tagname,{paddingInline:"calc(var(--spacing) * 4)"}));let Ct=At;const Et=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(Et,"tagname","h3"),$.style(Et,at(`card ${Et.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"1.375",fontSize:"var(--text-base)",color:"var(--fg)"}));let Lt=Et;const Wt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(Wt,"tagname","p"),$.style(Wt,at(`card ${Wt.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"var(--line-height-sm)",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Ht=Wt;const Rt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(Rt,"tagname","dl"),$.style(Rt,at(Rt.tagname,{display:"flex",flexDirection:"column"}));let Tt=Rt;const Bt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(Bt,"tagname","dc"),$.style(Bt,at(Bt.tagname,{paddingBlock:"1rem",borderBottom:"1px solid color-mix(in oklch, var(--input) 50%, transparent)","&:last-child":{borderBottom:"none"}}));let _t=Bt;const jt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(jt,"tagname","dt"),$.style(jt,at(jt.tagname,{fontSize:"var(--text-sm)",fontWeight:"var(--font-weight-medium)"}));let Ft=jt;const Pt=class t extends u{constructor(e,s){super(t.tagname,e,s)}};o(Pt,"tagname","dd"),$.style(Pt,at(Pt.tagname,{margin:"0",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Ut=Pt;export{Y as Accordion,Z as AccordionContainer,G as AccordionContent,J as AccordionTrigger,Dt as Badge,wt as Button,It as Card,Ct as CardContent,Ht as CardDescription,St as CardHeader,Lt as CardTitle,_t as DescriptionContent,Ut as DescriptionDetail,Tt as DescriptionList,Ft as DescriptionTerm,$t as Icon,B as Label,T as Radio,W as RadioGroup,R as RadioItem,ct as Select,xt as SelectArrow,gt as SelectContent,mt as SelectGroup,bt as SelectItem,dt as SelectTrigger,ut as SelectValue,A as Slide,E as Slideshow,nt as TabContent,it as TabTrigger,st as Tabs,rt as TabsContainer,j as TextBlock,Q as Waterfall,tt as WaterfallItem,O as slideInOut};
|
package/package.json
CHANGED
|
@@ -14,7 +14,10 @@ function createProto(insert: boolean, ...args: any) {
|
|
|
14
14
|
}
|
|
15
15
|
for (let process of $.process.craft) {
|
|
16
16
|
let result = process(...args);
|
|
17
|
-
if (!isUndefined(result))
|
|
17
|
+
if (!isUndefined(result)) {
|
|
18
|
+
addProtoToParent(result);
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
const [arg1, arg2, arg3] = args;
|
|
20
23
|
|
|
@@ -211,9 +211,9 @@ export interface $CSSDeclarationMap {
|
|
|
211
211
|
paintOrder: string;
|
|
212
212
|
perspective: string;
|
|
213
213
|
perspectiveOrigin: string;
|
|
214
|
-
placeContent:
|
|
215
|
-
placeItems:
|
|
216
|
-
placeSelf:
|
|
214
|
+
placeContent: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
|
215
|
+
placeItems: 'normal' | 'stretch' | 'center' | 'start' | 'end' | 'flex-start' | 'flex-end' | 'self-start' | 'self-end' | 'left' | 'right';
|
|
216
|
+
placeSelf: 'auto' | 'normal' | 'stretch' | 'center' | 'start' | 'end' | 'flex-start' | 'flex-end' | 'self-start' | 'self-end' | 'left' | 'right';
|
|
217
217
|
pointerEvents: 'auto' | 'none';
|
|
218
218
|
position: 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky';
|
|
219
219
|
quotes: string;
|
|
@@ -250,6 +250,9 @@ export interface $CSSDeclarationMap {
|
|
|
250
250
|
textAlign: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
251
251
|
textAlignLast: 'auto' | 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
252
252
|
textAnchor: 'start' | 'middle' | 'end';
|
|
253
|
+
textBox: OptionalStrings<['trim-both' | 'trim-end' | 'trim-start', 'cap' | 'ex' | 'text', 'alphabetic' | 'text']>;
|
|
254
|
+
textBoxEdge: 'auto' | 'text' | OptionalStrings<['text' | 'cap' | 'ex', 'text' | 'alphabetic']>;
|
|
255
|
+
textBoxTrim: 'trim-both' | 'trim-end' | 'trim-start';
|
|
253
256
|
textCombineUpright: 'none' | 'all';
|
|
254
257
|
textDecoration: 'none' | 'underline' | 'overline' | 'line-through' | 'grammar-error' | 'spelling-error' | 'solid' | 'double' | 'dotted' | 'dashed' | 'wavy';
|
|
255
258
|
textDecorationColor: string;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { For } from "#structure/For";
|
|
2
|
-
import { Proto } from '@amateras/core';
|
|
3
2
|
import './global';
|
|
4
3
|
|
|
5
4
|
globalThis.For = For;
|
|
6
5
|
|
|
7
6
|
$.process.craft.add((value, list, layout) => {
|
|
8
7
|
if (value === For) {
|
|
9
|
-
|
|
10
|
-
Proto.proto?.append(forProto);
|
|
11
|
-
return forProto;
|
|
8
|
+
return new For(list, layout);
|
|
12
9
|
}
|
|
13
10
|
})
|
|
14
11
|
|
package/packages/if/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import './global';
|
|
2
2
|
import { If } from "#structure/If";
|
|
3
|
-
import { Proto } from "@amateras/core";
|
|
4
3
|
import { _instanceof, _null, isIncluded } from "@amateras/utils";
|
|
5
4
|
import { Signal, type SignalObject, type SignalTypes } from '@amateras/signal';
|
|
6
5
|
import { ElseIf } from '#structure/ElseIf';
|
|
@@ -25,11 +24,9 @@ export type IfLayout<T> = (value: T extends SignalTypes<infer V>
|
|
|
25
24
|
let condition: Condition | null = null;
|
|
26
25
|
// add condition statement craft function
|
|
27
26
|
$.process.craft.add((value, arg1, arg2) => {
|
|
28
|
-
let parentProto = Proto.proto;
|
|
29
27
|
// when value equal If, mean this is a new start of condition statement
|
|
30
28
|
if (value === If) {
|
|
31
29
|
condition = new Condition();
|
|
32
|
-
parentProto?.append(condition);
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
// if condition is null, mean this is not a condition statement code
|
|
@@ -20,9 +20,7 @@ $.process.craft.add((value, arg1, arg2) => {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
if (value === Match) {
|
|
23
|
-
|
|
24
|
-
Proto.proto?.append(proto);
|
|
25
|
-
return proto
|
|
23
|
+
return new Match(arg1, arg2);
|
|
26
24
|
}
|
|
27
25
|
if (value === Case) {
|
|
28
26
|
return is(Proto.proto, Match)?.case(arg1, arg2)
|
|
@@ -8,6 +8,9 @@ declare global {
|
|
|
8
8
|
export var NavLink: typeof _NavLink.NavLink;
|
|
9
9
|
export function $(Router: Router): _Router.RouterProto;
|
|
10
10
|
|
|
11
|
+
export type Link = _Link.Link;
|
|
12
|
+
export type NavLink = _NavLink.NavLink;
|
|
13
|
+
|
|
11
14
|
export namespace $ {
|
|
12
15
|
export function router(handle: RouterHandle): Router;
|
|
13
16
|
|
|
@@ -2,7 +2,7 @@ import { ElementProto } from "@amateras/core";
|
|
|
2
2
|
import { _undefined } from "@amateras/utils";
|
|
3
3
|
|
|
4
4
|
export class Link extends ElementProto<HTMLAnchorElement> {
|
|
5
|
-
constructor(attr: $.Props | null, layout?: $.Layout<
|
|
5
|
+
constructor(attr: $.Props | null, layout?: $.Layout<Link>) {
|
|
6
6
|
super('a', attr, layout);
|
|
7
7
|
this.on('click', e => {
|
|
8
8
|
if (e.shiftKey || e.ctrlKey) return;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Link } from "#structure/Link";
|
|
2
|
-
import type { ElementProto } from "@amateras/core";
|
|
3
2
|
import { _null, toURL } from "@amateras/utils";
|
|
4
3
|
|
|
5
4
|
export class NavLink extends Link {
|
|
6
|
-
constructor(attr: $.Props | null, layout?: $.Layout<
|
|
7
|
-
super(attr, layout);
|
|
5
|
+
constructor(attr: $.Props | null, layout?: $.Layout<NavLink>) {
|
|
6
|
+
super(attr, layout as any);
|
|
8
7
|
this.global.router.navlinks.add(this);
|
|
9
8
|
}
|
|
10
9
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _null,
|
|
1
|
+
import { _null, _Object_entries, forEach, isFunction, isString, isSymbol, isUndefined } from "@amateras/utils";
|
|
2
2
|
import { ontrack, trackSet } from "#lib/track";
|
|
3
3
|
import { Proto, symbol_Signal } from "@amateras/core";
|
|
4
4
|
import type { SignalTypes } from "..";
|
|
@@ -12,21 +12,18 @@ export class Signal<T = any> extends Function {
|
|
|
12
12
|
private linked: Signal | null = _null;
|
|
13
13
|
private _value: T
|
|
14
14
|
private subs: null | ((value: T) => void)[] = _null;
|
|
15
|
-
private converts: Record<string, (value: any) => Signal> | null;
|
|
16
15
|
private map: null | Record<string, Signal> = _null;
|
|
17
16
|
exec: null | Function = _null;
|
|
18
17
|
computes: Set<WeakRef<Signal>> | null = _null;
|
|
19
|
-
constructor(value: T
|
|
18
|
+
constructor(value: T) {
|
|
20
19
|
super()
|
|
21
20
|
Proto.proto?.global.signals.add(this);
|
|
22
21
|
this._value = value;
|
|
23
|
-
this.converts = convert;
|
|
24
|
-
// this.assignProperties();
|
|
25
22
|
return new Proxy(this, {
|
|
26
23
|
apply: () => this._exec(),
|
|
27
24
|
get: (target, propName) => {
|
|
28
25
|
if (isSymbol(propName) || (isString(propName) && !propName.endsWith('$'))) return this[propName as keyof this];
|
|
29
|
-
const value = this.
|
|
26
|
+
const value = this.value[propName.slice(0, -1) as keyof T];
|
|
30
27
|
if (!this.map) this.map = {};
|
|
31
28
|
const signal = this.map[propName] ?? new Signal(value);
|
|
32
29
|
this.map[propName] = signal;
|
|
@@ -57,7 +54,8 @@ export class Signal<T = any> extends Function {
|
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
set(resolver: T | ((oldValue: T) => T),) {
|
|
60
|
-
if (
|
|
57
|
+
if (this.linked) this.linked.set(resolver);
|
|
58
|
+
else if (isFunction(resolver)) this.set(resolver(this.value));
|
|
61
59
|
else if (this.value !== resolver) {
|
|
62
60
|
this._value = resolver;
|
|
63
61
|
this.emit();
|
|
@@ -89,9 +87,8 @@ export class Signal<T = any> extends Function {
|
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
link(target$: Signal) {
|
|
90
|
+
if (this === target$) throw 'Signal.link(): cannot link self'
|
|
92
91
|
this.linked = target$;
|
|
93
|
-
this.converts = target$.converts;
|
|
94
|
-
// this.assignProperties(target$);
|
|
95
92
|
this.emit();
|
|
96
93
|
target$.subscribe(() => this.emit());
|
|
97
94
|
}
|
|
@@ -100,16 +97,6 @@ export class Signal<T = any> extends Function {
|
|
|
100
97
|
return validator(this)
|
|
101
98
|
}
|
|
102
99
|
|
|
103
|
-
private assignProperties(target$?: Signal) {
|
|
104
|
-
if (!isObject(this.value) || isNull(this.value)) return;
|
|
105
|
-
|
|
106
|
-
if (this.converts) forEach(_Object_entries(this.converts), ([propName, resolve]) => {
|
|
107
|
-
//@ts-ignore
|
|
108
|
-
let prop$ = target$?.[`${propName}$`] ?? resolve(this.value[propName]);
|
|
109
|
-
_Object_assign(this, { [`${propName}$`]: prop$ });
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
100
|
override toString(): string {
|
|
114
101
|
return `${this.value}`
|
|
115
102
|
}
|
|
@@ -25,6 +25,9 @@ export class DescriptionContent extends ElementProto {
|
|
|
25
25
|
$.style(this, toCSS(this.tagname, {
|
|
26
26
|
paddingBlock: '1rem',
|
|
27
27
|
borderBottom: `1px solid color-mix(in oklch, var(--input) 50%, transparent)`,
|
|
28
|
+
'&:last-child': {
|
|
29
|
+
borderBottom: 'none'
|
|
30
|
+
}
|
|
28
31
|
}))
|
|
29
32
|
}
|
|
30
33
|
}
|
|
@@ -15,10 +15,13 @@ export class Icon extends ElementProto {
|
|
|
15
15
|
$.style(this, toCSS(this.tagname, {
|
|
16
16
|
display: 'inline-block',
|
|
17
17
|
verticalAlign: 'middle',
|
|
18
|
+
height: '1rem',
|
|
19
|
+
width: '1rem',
|
|
20
|
+
|
|
18
21
|
'svg': {
|
|
19
22
|
display: 'block',
|
|
20
|
-
height: '
|
|
21
|
-
width: '
|
|
23
|
+
height: 'auto',
|
|
24
|
+
width: '100%'
|
|
22
25
|
}
|
|
23
26
|
}))
|
|
24
27
|
}
|
|
@@ -43,4 +43,13 @@ declare global {
|
|
|
43
43
|
? false
|
|
44
44
|
: true
|
|
45
45
|
: never;
|
|
46
|
+
type OptionalStrings<Arr extends string[], First = true> = Arr extends [infer S1, ...infer Rest]
|
|
47
|
+
? S1 extends string
|
|
48
|
+
? Rest extends [string, ...any]
|
|
49
|
+
? First extends true
|
|
50
|
+
? `${S1}${OptionalStrings<Rest, false> | ''}`
|
|
51
|
+
: ` ${S1}${OptionalStrings<Rest, false>}`
|
|
52
|
+
: ` ${S1}` | ''
|
|
53
|
+
: never
|
|
54
|
+
: never;
|
|
46
55
|
}
|