amateras 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -38
- package/build/core.js +1 -1
- package/build/css-keyframes.js +1 -0
- package/build/css-property.js +1 -0
- package/build/css-variable.js +1 -0
- package/build/for.js +1 -1
- package/build/i18n.js +1 -1
- package/build/if.js +1 -1
- package/build/import-map.js +1 -1
- package/build/match.js +1 -1
- package/build/meta.js +1 -1
- package/build/prefetch.js +1 -1
- package/build/router.js +1 -1
- package/build/signal.js +1 -1
- package/build/store.js +1 -1
- package/build/ui.js +1 -1
- package/build/utils.js +1 -1
- package/build/widget.js +1 -1
- package/package.json +3 -2
- package/packages/core/src/index.ts +86 -31
- package/packages/core/src/lib/hmr.ts +4 -4
- package/packages/core/src/structure/ElementProto.ts +33 -11
- package/packages/core/src/structure/GlobalState.ts +13 -4
- package/packages/core/src/structure/NodeProto.ts +2 -4
- package/packages/core/src/structure/Proto.ts +37 -23
- package/packages/core/src/structure/TextProto.ts +1 -2
- package/packages/css/README.md +18 -15
- package/packages/css/src/ext/property.ts +2 -3
- package/packages/css/src/index.ts +1 -1
- package/packages/css/src/structure/$CSSProperty.ts +4 -0
- package/packages/css/src/structure/$CSSVariable.ts +1 -1
- package/packages/css/src/types.ts +5 -0
- package/packages/for/src/global.ts +12 -3
- package/packages/for/src/structure/For.ts +5 -3
- package/packages/i18n/README.md +16 -24
- package/packages/i18n/src/index.ts +26 -5
- package/packages/i18n/src/structure/I18n.ts +2 -4
- package/packages/i18n/src/structure/I18nSession.ts +4 -2
- package/packages/i18n/src/structure/I18nTranslation.ts +15 -26
- package/packages/idb/src/structure/$IDBStore.ts +2 -2
- package/packages/if/src/global.ts +15 -4
- package/packages/if/src/index.ts +18 -8
- package/packages/if/src/structure/Condition.ts +16 -13
- package/packages/if/src/structure/ConditionStatement.ts +9 -9
- package/packages/match/src/global.ts +9 -3
- package/packages/match/src/structure/Match.ts +1 -1
- package/packages/meta/src/index.ts +4 -5
- package/packages/prefetch/src/index.ts +30 -9
- package/packages/router/src/global.ts +17 -4
- package/packages/router/src/index.ts +25 -18
- package/packages/router/src/structure/Route.ts +2 -1
- package/packages/router/src/structure/RouteNode.ts +8 -6
- package/packages/router/src/structure/RouteSlot.ts +15 -2
- package/packages/router/src/structure/Router.ts +28 -19
- package/packages/router/src/structure/RouterConstructor.ts +5 -5
- package/packages/router/src/types.ts +2 -2
- package/packages/signal/README.md +28 -48
- package/packages/signal/src/index.ts +61 -38
- package/packages/signal/src/structure/Signal.ts +40 -7
- package/packages/store/src/structure/Store.ts +1 -1
- package/packages/ui/package.json +2 -1
- package/packages/ui/src/icon/check.svg.ts +1 -0
- package/packages/ui/src/icon/x.svg.ts +1 -0
- package/packages/ui/src/index.ts +9 -2
- package/packages/ui/src/lib/combobox_style.ts +20 -0
- package/packages/ui/src/lib/hover.ts +2 -0
- package/packages/ui/src/structure/Badge.ts +10 -1
- package/packages/ui/src/structure/Button.ts +54 -27
- package/packages/ui/src/structure/Card.ts +3 -4
- package/packages/ui/src/structure/Combobox/Combobox.ts +312 -0
- package/packages/ui/src/structure/Combobox/ComboboxChips.ts +178 -0
- package/packages/ui/src/structure/Combobox/ComboboxList.ts +209 -0
- package/packages/ui/src/structure/ContextMenu.ts +89 -0
- package/packages/ui/src/structure/Field.ts +109 -0
- package/packages/ui/src/structure/Input.ts +29 -0
- package/packages/ui/src/structure/Select/Select.ts +18 -8
- package/packages/ui/src/structure/Select/SelectContent.ts +6 -1
- package/packages/ui/src/structure/Select/SelectItem.ts +2 -1
- package/packages/ui/src/structure/Slideshow.ts +2 -2
- package/packages/ui/src/structure/Switch.ts +45 -0
- package/packages/ui/src/structure/Tabs.ts +3 -3
- package/packages/ui/src/structure/Toggle.ts +155 -0
- package/packages/ui/src/structure/Waterfall.ts +1 -1
- package/packages/ui/src/structure/WaterfallItem.ts +1 -1
- package/packages/utils/src/lib/utils.ts +30 -8
- package/packages/utils/src/structure/UID.ts +1 -1
- package/packages/widget/src/index.ts +29 -9
- package/packages/widget/src/structure/Widget.ts +7 -3
- package/packages/ui/src/structure/TextBlock.ts +0 -11
package/README.md
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
# Amateras
|
|
2
|
-
Amateras is a JavaScript library for building user interface
|
|
2
|
+
Amateras is a JavaScript library for building user interface. Its gold is to allow writing and running code directly without a compiler, enabling developers to build user interfaces efficiently using only JavaScript or TypeScript syntax.
|
|
3
3
|
|
|
4
|
-
##
|
|
5
|
-
- **
|
|
6
|
-
- **Fast Performance**:No
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
4
|
+
## Advantages
|
|
5
|
+
- **Minimalist Development**: No JSX, no compiler, zero setup.
|
|
6
|
+
- **Fast Performance**:No diffing overhead, a fine-grained reactive framework.
|
|
7
|
+
- **Type Safety**:Provides a TypeScript type-safe coding experience.
|
|
8
|
+
- **Execute Everywhere**:Capable of running on both the client and server sides。
|
|
9
|
+
- **Lightweight Size**:Extremely small bundle size with high modularity design, only import the code that you need.
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
|
-
-
|
|
13
|
-
- Control
|
|
14
|
-
-
|
|
15
|
-
- Reactive
|
|
16
|
-
-
|
|
12
|
+
- Component-based modules (widget)
|
|
13
|
+
- Control flow support (if, match, for)
|
|
14
|
+
- SPA Router (router)
|
|
15
|
+
- Reactive data (signal)
|
|
16
|
+
- Internationalization (i18n)
|
|
17
17
|
- CSS-in-JS (css)
|
|
18
|
-
- Server-
|
|
18
|
+
- Server-Side Rendering ([tsukimi](https://github.com/defaultkavy/tsukimi))
|
|
19
19
|
|
|
20
|
-
##
|
|
21
|
-
Amateras
|
|
20
|
+
## How to Use
|
|
21
|
+
Amateras provides two ways to import the library.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
1. **Using Import Map**
|
|
24
|
+
|
|
25
|
+
This script will create a import map in your page, insert this line before your project code.
|
|
26
|
+
```html
|
|
27
|
+
<script src="https://unpkg.com/amateras"></script>
|
|
28
|
+
```
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
bun add amateras
|
|
32
|
-
```
|
|
30
|
+
2. **Install via Package Manager**
|
|
31
|
+
```sh
|
|
32
|
+
bun add amateras
|
|
33
|
+
```
|
|
33
34
|
|
|
34
35
|
## Example
|
|
35
36
|
```ts
|
|
@@ -63,19 +64,19 @@ $.render(Counter, 'body');
|
|
|
63
64
|
|
|
64
65
|
| Modules | Size | Gziped | Description |
|
|
65
66
|
| --- | --- | --- | --- |
|
|
66
|
-
| core | 7.
|
|
67
|
-
| widget | 0.
|
|
68
|
-
| signal |
|
|
69
|
-
| store | 0.
|
|
70
|
-
| css | 1.63 kB | 0.
|
|
71
|
-
| for | 1.
|
|
72
|
-
| if |
|
|
73
|
-
| match | 1.
|
|
74
|
-
| router | 6.
|
|
75
|
-
| i18n | 3.
|
|
76
|
-
| idb | 5.
|
|
67
|
+
| core | 7.94 kB | 3.14 kB | Core module |
|
|
68
|
+
| widget | 0.23 kB | 0.10 kB | Component module |
|
|
69
|
+
| signal | 3.03 kB | 1.13 kB | Reactive data module |
|
|
70
|
+
| store | 0.51 kB | 0.19 kB | Access data between widgets |
|
|
71
|
+
| css | 1.63 kB | 0.72 kB | CSS-in-JS module |
|
|
72
|
+
| for | 1.21 kB | 0.39 kB | For loop control-flow |
|
|
73
|
+
| if | 4.18 kB | 1.50 kB | If/Else/ElseIf control-flow |
|
|
74
|
+
| match | 1.42 kB | 0.42 kB | Match/Case/Default control-flow |
|
|
75
|
+
| router | 6.52 kB | 2.40 kB | Router module |
|
|
76
|
+
| i18n | 3.38 kB | 1.16 kB | Translation module |
|
|
77
|
+
| idb | 5.31 kB | 2.01 kB | IndexedDB module |
|
|
77
78
|
| markdown | 7.48 kB | 2.93 kB | Markdown to HTML module |
|
|
78
|
-
| prefetch | 0.
|
|
79
|
-
| meta | 0.
|
|
80
|
-
| ui |
|
|
79
|
+
| prefetch | 0.72 kB | 0.34 kB | SSR data prefetch |
|
|
80
|
+
| meta | 0.17 kB | 0.08 kB | SSR `meta` tag manager |
|
|
81
|
+
| ui | 0.00 kB | 0.00 kB | UI components |
|
|
81
82
|
| utils | 0.00 kB | 0.00 kB | Utilities module |
|
package/build/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{forEach as t,_Object_assign as e,_null as s,map as i,_Array_from as o,_Object_entries as r,isFunction as n,isUndefined as l,isNull as h,toArray as a,_instanceof as d,isString as p,isArray as c}from"@amateras/utils";const u=window,f=document,m=t=>!t||t(),b=t=>!1,g=/* @__PURE__ */Symbol("ProtoType"),P=/* @__PURE__ */Symbol("Statement"),y=/* @__PURE__ */Symbol("Signal");class v{static disposers=/* @__PURE__ */new Set;promises=/* @__PURE__ */new Set;root;static initials=/* @__PURE__ */new Set;constructor(s){t(v.initials,t=>{const s=t(this);s&&e(this,s)}),this.root=s,s.listen("dispose",()=>this.dispose())}dispose(){this.promises.clear(),this.root=s,t(v.disposers,t=>t(this))}static assign(t){this.initials.add(t)}asyncTask(t){return this.promises.add(t),t.finally(()=>this.promises.delete(t)),t}}class M{static proto=s;static[g]="Proto";static[P]=!1;layout;parent=s;global=M.proto?.global??new v(this);sibling=s;firstProto=s;lastProto=s;builded=!1;visible=!0;listeners=s;constructor(t){this.layout=t??s}dispose(){this.dispatch("dispose",[this]),t(this.protos,t=>t.dispose()),this.global=s,this.sibling=s,this.firstProto=s,this.lastProto=s,this.parent=s,this.layout=s}get children(){return i(Array.from(this.protos).filter(t=>t.visible),t=>t.constructor[P]?t.children:t).flat()}get protos(){let t=/* @__PURE__ */new Set,e=this.firstProto;if(e){let s=e;for(;s;)t.add(s),s=s.sibling}return t}append(...e){t(e,t=>{if(t.parent!==this&&t.parent?.removeProtos(t),this.lastProto){if(this.lastProto===t)return;this.firstProto===t&&(this.firstProto=t.sibling),t.sibling=s,this.lastProto.sibling=t,this.lastProto=t}else this.firstProto=t,this.lastProto=t;t.parent=this,t.global=this.global})}replaceProtos(...t){this.clear(),this.processProtos(...t)}insert(t,e=-1){if(0===e)this.firstProto&&(t.sibling=this.firstProto),this.firstProto=t;else{let s=o(this.protos),i=e<0?s.length+e+1:e;s.splice(i,0,t),this.processProtos(...s)}t.parent=this,t.global=this.global}remove(){this.parent?.removeProtos(this)}removeProtos(...e){let s=this.protos;t(e,t=>{t.parent=null,t.sibling=null,s.delete(t)}),this.processProtos(...s)}processProtos(...e){let i=s;e.length?t(e,(t,e)=>{0===e&&(this.firstProto=t),i&&(i.sibling=t),t.sibling=s,i=t,t.parent=this}):this.firstProto=s,this.lastProto=i}build(e=!0,s=!0){return s&&this.clear(!0),$.context(M,this,()=>this.layout?.(this)),this.builded=!0,e&&t(this.protos,t=>{t.build()}),this.dispatch("builded",[this]),this}toString(){return i(o(this.protos).filter(t=>t.visible),t=>`${t}`).join("")}toDOM(t=!0){return t?i(o(this.protos).filter(t=>t.visible),e=>e.toDOM(t)).flat():[]}ondispose(t){this.listen("dispose",t)}removeNode(){t(this.protos,t=>t.removeNode())}clear(e=!1){let s=this.protos;this.removeProtos(...s),e&&t(s,t=>t.dispose())}findAbove(t){let e=this.parent;return e?t(e)?e:e.findAbove(t):s}findBelow(t){for(let e of this.protos){if(t(e))return e;let s=e.findBelow(t);if(s)return s}return s}findBelowAll(t){let e=[];for(let s of this.protos)t(s)&&e.push(s),e.push(...s.findBelowAll(t));return e}mutate(){}get text(){return this.children.map(t=>t.text).join("")}dispatch(e,s,i){let o=this.listeners?.[e],r=!1;if(i?.bubbles){let t=this.parent?.dispatch(e,s,i);r||(r=t??!1)}return t(o,t=>{let e=t(...s)??!1;r||(r=e)}),r}listen(t,e){let s=this.listeners??{};this.listeners=s;let i=s[t]??/* @__PURE__ */new Set;this.listeners[t]=i,i.add(e)}}class w extends M{node=s;constructor(t){super(t)}ondom(t){this.listen("dom",t)}dispose(){super.dispose(),this.node=s}inDOM(){return!!m()&&document.contains(this.node)}removeNode(){this.node?.remove()}}const S=["img","hr","br","input","link","meta"];class _ extends w{tagname;#t={};#e="";__props__;constructor(t,e,s){super(()=>s?.(this)),this.tagname=t,this.__props__=e}dispose(){super.dispose(),this.layout=null}build(t){return this.__props__&&(this.props(this.__props__),this.__props__=s),super.build(t),this}props({...e}){let{class:s,...i}=e;s&&this.addClass(...s.split(" ")),t(r(i),([t,e])=>{t.startsWith("on")&&n(e)&&(this.on(t.replace("on",""),e),delete i[t])}),this.attrProcess(i)}on(t,e,s){let i=i=>{i.addEventListener(t,e,s),this.listen("dispose",()=>this.node?.removeEventListener(t,e))};this.node?i(this.node):this.listen("dom",i)}toString(){return this.parseHTML()}parseHTML(t){let e=this.tagname,s=t?.children??(this.#e||i(this.protos,t=>t.visible?`${t}`:"").join("")),o=t?.attr??i(r(this.#t),([t,e])=>e.length?`${t}="${e}"`:t).join(" "),n=o.length?" "+o:"";return S.includes(e)?`<${e}${n} />`:`<${e}${n}>${s}</${e}>`}toDOM(e=!0){let s=this.node??document.createElement(this.tagname);return this.node=s,this.#e&&this.node.innerHTML!==this.#e?this.node.innerHTML=this.#e:e&&this.DOMProcess(),t(r(this.#t),([t,e])=>s.setAttribute(t,e)),this.dispatch("dom",[this.node]),[s]}DOMProcess(){let e=this.node;if(e){let r=i(o(this.protos).filter(t=>t.visible),t=>t.toDOM()).flat(),n=s;t(r,(t,i)=>{let o=e.childNodes[i];o!==t&&(n=r.includes(o)?e.childNodes[i+1]??s:o??s,e.insertBefore(t,n))})}}attrProcess(e){t(r(e),([t,e])=>{for(let s of $.process.attr){let i=s(t,e,this);if(!l(i))return}this.attr(t,e)})}innerHTML(t){this.#e=t,this.node&&(this.node.innerHTML=t)}attr(t,e){return arguments.length?l(e)?this.#t[t]??s:(h(e)?(delete this.#t[t],this.node?.removeAttribute(t)):(this.#t[t]=e,this.node?.setAttribute(t,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(e,s,...i){let r=this.#t[s],n=new Set(r?.split(" ")??[]);t(i,t=>n[e](t)),this.#t[s]=o(n).join(" ")}}class T extends w{#s;constructor(t){super(),this.#s=t}get content(){return this.#s}set content(t){this.#s=t,this.node&&(this.node.textContent=t)}toString(){return this.#s}toDOM(){if(this.node)return[this.node];let t=new Text(this.#s);return this.node=t,this.dispatch("dom",[this.node]),[t]}get text(){return this.#s}}class L extends w{constructor(t){super(t),m()&&(this.node=new Text)}toDOM(){return[this.node,...super.toDOM()]}removeNode(){super.removeNode(),t(this.protos,t=>t.removeNode())}}function x(e,...i){const o=M.proto,r=[],h=t=>{e&&o?.append(t),r.push(t)};for(let t of H.process.craft){let e=t(...i);if(!l(e))return h(e),e}const[a,u,f]=i;if(d(a,M))return h(a),a;if(p(a)){let t=n(u)?[,u]:[u,f],e=new _(a,...t);return h(e),e}if(n(a)){let t=u?[u,f]:[f];d(a.prototype,_)&&(t=n(u)?[{},u]:[u,f]);let e=new a(...t);if(d(e,M))return h(e),e}if(c(a)){let e=t=>{for(let s of H.process.text){let e=s(t);if(!l(e))return h(e)}let e=l(t)?s:new T(`${t}`);e&&h(e)},[o,...n]=i;return o.raw?t(o,(t,i)=>{let o=t.length?new T(t):s,r=n[i];o&&h(o),e(r)}):t(o,t=>e(t)),r}}function H(...t){return x(!0,...t)}var D;(D=H||(H={})).process={craft:/* @__PURE__ */new Set,text:/* @__PURE__ */new Set,attr:/* @__PURE__ */new Set},D.craft=(...t)=>x(!1,...t),D.render=(t,e)=>{let s=D(t).build().toDOM();document.querySelector(e)?.replaceChildren(...s)},D.context=(t,e,s)=>{let i=t.proto;t.proto=e,s(),t.proto=i},D.call=t=>t(),D.match=(t,e)=>{var s=/* @__PURE__ */new Map,i=/* @__PURE__ */Symbol("default"),o={case:(t,e)=>(s.set(t,e),o),default:t=>(s.set(i,t),o)};return e(o),s.get(t)?.()??s.get(i)?.()},D.tuple=(...t)=>t,D.async=t=>M.proto?.global.asyncTask(t(M.proto))??t(M.proto),D.stylesheet=m()?new CSSStyleSheet:s,D.styleMap=/* @__PURE__ */new Map,D.style=(e,s)=>{let i=a(s);if(e){let s=D.styleMap.get(e)??/* @__PURE__ */new Set;t(i,t=>s.add(t)),D.styleMap.set(e,s)}D.stylesheet&&t(i,t=>D.stylesheet.insertRule(t))},D.stylesheet&&document.adoptedStyleSheets.push(D.stylesheet),m()&&document.querySelector("style#__ssr__")?.remove(),globalThis.$=H;export{H as $,_ as ElementProto,v as GlobalState,w as NodeProto,M as Proto,L as ProxyProto,T as TextProto,f as _document,u as _window,m as onclient,b as onserver,g as symbol_ProtoType,y as symbol_Signal,P as symbol_Statement};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_null as e,map as t,_Object_entries as s,isString as r,isNumber as a,_instanceof as l,_JSON_stringify as n,_Object_assign as c,_Object_fromEntries as o,UID as i}from"@amateras/utils";const p=/* @__PURE__ */new Set,u=$.call(()=>/* @__PURE__ */new Map);class f{}class h extends f{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e;css;constructor(e,t,s){super(),this.selector=e,this.parent=s,t&&m(this,t),this.css=t}toString(){let e=t(this.declarations,([e,t])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t};`),s=t(this.rules,([e,t])=>`${t}`);return`${this.selector} { ${[...e,...s].join(" ")} }`}}const m=(e,t)=>{for(let[n,c]of s(t))if("__selector__"!==n)if(r(c)||a(c)||l(c,f))e.declarations.set(n,`${c}`);else{let t=e.selector.startsWith("@")&&!e.parent?n:`${/^[@]|&/.test(n)?n:`& ${n}`}`;e.rules.set(t,new h(t,c,e))}};class w extends f{name;constructor(e){super(),this.name=e}toString(){return`${this.name.replace("@keyframes ","")}`}}const d="@keyframes ";c($.css,{keyframes:r=>o(t(s(r),([t,s])=>{let r=((t,s,r=!0)=>{let a=r?n(s):"";if(r){let e=u.get(a);if(e)return e}let l=new h(t(),s,e);return $.style(e,`${l}`),r&&u.set(a,l),l})(()=>`${d}${t}_${i.generate("css-keyframes")}`,s);return p.add(r),[t,new w(r.selector.replace(`${d} `,""))]}))});export{w as $CSSKeyframes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_null as e,map as t,_Object_entries as r,isString as s,isNumber as i,_instanceof as l,_JSON_stringify as a,_Object_assign as n,UID as o,isUndefined as c,forEach as p}from"@amateras/utils";const u=/* @__PURE__ */new Set,h=$.call(()=>/* @__PURE__ */new Map);class w{}class d extends w{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e;css;constructor(e,t,r){super(),this.selector=e,this.parent=r,t&&y(this,t),this.css=t}toString(){let e=t(this.declarations,([e,t])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t};`),r=t(this.rules,([e,t])=>`${t}`);return`${this.selector} { ${[...e,...r].join(" ")} }`}}const y=(e,t)=>{for(let[a,n]of r(t))if("__selector__"!==a)if(s(n)||i(n)||l(n,w))e.declarations.set(a,`${n}`);else{let t=e.selector.startsWith("@")&&!e.parent?a:`${/^[@]|&/.test(a)?a:`& ${a}`}`;e.rules.set(t,new d(t,n,e))}},f=(t,r,s=!0)=>{let i=s?a(r):"";if(s){let e=h.get(i);if(e)return e}let l=new d(t(),r,e);return $.style(e,`${l}`),s&&h.set(i,l),l};class g extends w{constructor(e){super(),n(this,e)}toString(){return`var(${this.name})`}declare(e){return{[this.name]:`${e??this.initialValue}`}}}n($.css,{property(e,t,i){let l=o.generate("css-property",{lettercase:"lower"});if(s(e)){if(c(t)||c(i))throw"Register CSS Property Error";let r=`--${l}`,s=new g({name:r,syntax:e,initialValue:`${t}`,inherits:i}),a=f(()=>`@property ${r}`,{syntax:`'${e}'`,inherits:`${i??!0}`,...t?{initialValue:t}:{}},!1);return u.add(a),s}{let t={};return p(r(e),([e,[r,s,i]])=>{let a=`--${o=e,o.replaceAll(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}-${l}`;var o;let $=new g({name:a,syntax:r,initialValue:`${s}`,inherits:i});n(t,{[e]:$});let c=f(()=>`@property ${a}`,{syntax:`'${r}'`,inherits:`${i??!0}`,...s?{initialValue:s}:{}},!1);u.add(c)}),t}}});export{g as $CSSProperty};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{onclient as e,_document as t}from"@amateras/core";import{_Object_assign as r,UID as a,isObject as s,_Object_fromEntries as n,map as o,_Object_entries as l}from"@amateras/utils";class u{}class m extends u{name;value;constructor(e,t){super(),this.name=e,this.value=t}set(r){return e()&&t.documentElement.style.setProperty(`${this.name}`,r),this}reset(){return e()&&t.documentElement.style.removeProperty(`${this.name}`),this}default(e){return`var(${this.name}, ${e})`}declare(e){return{[this.name]:`${e??this.value}`}}toString(){return`var(${this.name})`}}r($.css,{variable(e,t){let r=t?.unique?"_"+a.generate("css-variable",{lettercase:"lower"}):"";if(s(e)){const a=n(o(l(e),([e,a])=>{return[e,new m(`--${t?.prefix??""}${s=e,s.replaceAll(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}${r}`,`${a}`)];var s}));return $.CSS({":root":n(o(l(a),([e,{name:t,value:r}])=>[t,r]))}),a}{const t=new m(`--${r}`,e);return $.CSS({":root":{[t.name]:t.value}}),t}}});export{m as $CSSVariable};
|
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
|
|
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 l 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(),l=o(s.childNodes).indexOf(e),a=r;i(t,i=>{if(i!==e){let e=s.childNodes[l];e!==i&&(a=t.includes(e)?s.childNodes[l+1]??r:e??r,s.insertBefore(i,a))}l++})}this.parent?.mutate()};this.list$.subscribe(s),this.listen("dispose",()=>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 a(()=>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 a extends s{static[e]=!0}globalThis.For=l,$.process.craft.add((t,e,s)=>{if(t===l)return new l(e,s)});export{l as For,a as ForItem};
|
package/build/i18n.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{onclient as t,
|
|
1
|
+
import{onclient as t,Proto as e,GlobalState as s,ProxyProto as i}from"@amateras/core";import{isFunction as n,isAsyncFunction as o,isObject as a,map as r,forEach as l,isUndefined as h,_null as c,_Object_assign as u,_instanceof as d}from"@amateras/utils";class p{#t=null;#e=null;constructor(t){n(t)?this.#e=t:this.#t=t}async context(){let e=()=>t()&&window.dispatchEvent(new Event("i18ncontext"));if(this.#t)return o(this.#t)?await this.#t.finally(e):this.#t;if(!this.#e)throw"I18n Context Fetch Error";return this.#t=this.#e().then(t=>t.default).finally(e)}async find(t,e){e||(e=await this.context());const[s,...i]=t.split("."),n=e[s];return a(n)?i.length?this.find(i.join("."),n):n._:i.length?t:n}}class g{session;key;options;updating=!1;updaters=[];constructor(t,e,s){this.session=t,this.key=e,this.options=s,this.session.translations.add(this)}async update(){if(this.updating)return;this.updating=!0;const t=this.session.fetch(this.key,this.options);this.session.global.asyncTask(t);const{text:e,args:s}=await t,i=r(e,(t,e)=>e<s.length?[t,s[e]]:[t]).flat();return l(this.updaters,t=>t(i)),this.updating=!1,this}onupdate(t){this.updaters.push(t)}}class f{translations=/* @__PURE__ */new Set;i18n;#s;global;constructor(t,e){this.i18n=t,this.global=e,this.#s=t.locale(),t.sessions.add(this)}async fetch(t,e){const s=this.i18n.dictionaries.get(this.#s);if(!s)return{text:[t],args:[]};const i=await s.find(t);if(h(i))return{text:[t],args:[]};const n=i.split(/\$[a-zA-Z0-9_]+\$/);if(1===n.length||!e)return{text:[i],args:[]};const o=i.matchAll(/(\$([a-zA-Z0-9_]+)\$)/g);return{text:n,args:r(o,([,,t])=>e[t])}}locale(e){if(!arguments.length)return this.#s;if(e){if(!this.i18n.dictionaries.get(e)){let t=e.split("-");if(1===t.length)return;return this.locale(t[0])}}return e&&e!==this.#s?(this.#s=e,new Promise(async e=>{await Promise.all(r(this.translations,t=>t.update())),e(),t()&&dispatchEvent(new Event("localeupdate"))})):void 0}}class w{#s;dictionaries=/* @__PURE__ */new Map;defaultLocale;sessions=/* @__PURE__ */new Set;path="";static key="__locale__";constructor(t){this.defaultLocale=t,this.#s=t}add(t,e){return this.dictionaries.set(t,new p(e)),this}delete(t){return this.dictionaries.delete(t),this}t(t,e){return new g(this.getSession(),this.getFullPath(t),e)}async text(t,e){let s=await this.getSession().fetch(this.getFullPath(t),e);return s.text.reduce((t,e,i)=>t+e+(s.args[i]||""),"")}dir(t){let e=this;return{t:(s,i)=>e.t(`${t}.${s}`,i),text:(s,i)=>e.text(`${t}.${s}`,i),dir:s=>e.dir(`${t}.${s}`)}}locale(t){if(!arguments.length)return this.readStoreLocale(),this.#s;if(!t)return;if(!this.dictionaries.get(t)){let e=t.split("-");if(1===e.length)return;return this.locale(e[0])}return this.#s=t,this.writeStoreLocale(t),Promise.all(r(this.sessions,e=>e.locale(t)))}getFullPath(t){return this.path?`${this.path}.${t}`:t}getSession(){let t=e.proto;if(t){let e=t.global.i18n.session??new f(this,t.global);return t.global.i18n.session=e,e}throw"I18n.getSession(): session not found from Proto.proto"}readStoreLocale(){t()&&(this.#s=localStorage.getItem(w.key)??this.defaultLocale)}writeStoreLocale(e){t()&&localStorage.setItem(w.key,e)}}s.assign(()=>({i18n:{session:c}})),s.disposers.add(t=>{t.i18n.session=c}),u($,{i18n:t=>new w(t)}),$.process.text.add(t=>{if(d(t,g)){const e=new i;return t.onupdate(t=>{e.layout=()=>$([...t]),l(e.protos,t=>t.removeNode()),e.build(),e.node?.replaceWith(...e.toDOM()),e.dispatch("i18nupdate",[void 0],{bubbles:!0})}),t.update(),e}}),$.process.attr.add((t,e,s)=>{d(e,g)&&(e.onupdate(e=>{s.attr(t,e.join(""))}),e.update())});export{w as I18n,p as I18nDictionary,g as I18nTranslation};
|
package/build/if.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Proto as
|
|
1
|
+
import{Proto as s,symbol_Statement as e,ProxyProto as t}from"@amateras/core";import{_null as i,toArray as r,forEach as a,_instanceof as l,isIncluded as o,isArray as p}from"@amateras/utils";import{Signal as d}from"@amateras/signal";class n extends s{static[e]=!0;exps;constructor(s,e){super(()=>e(...this.exps??[])),this.exps=s?r(s):i}dispose(){super.dispose(),this.exps=i}validate(){return!this.exps||!this.exps.find(s=>!s.value)}}class u extends n{}class h extends n{}class f extends n{}class b extends t{static[e]=!0;statement=i;build(){super.build(!1,!1),this.validate()?.build();let s=()=>{let s=this.validate();s?.builded||s?.build(),this.statement!==s&&(this.statement=s??i,a(this.protos,s=>!s.visible&&s.removeNode()),this.node?.replaceWith(...this.toDOM()),this.parent?.mutate())};return a(this.protos,e=>{a(e.exps,t=>{t?.subscribe(s),e.listen("dispose",()=>{t?.unsubscribe(s)})})}),this}get protos(){return super.protos}dispose(){super.dispose(),this.statement=i}validate(){a(this.protos,s=>s.visible=!1);for(let s of this.protos)if(s.validate())return s.visible=!0,s}}globalThis.If=f,globalThis.Else=u,globalThis.ElseIf=h;let m=null;$.process.craft.add((s,e,t)=>{if(s===f&&(m=new b),l(m,b)){if(o(s,[f,u,h])){{let r=new s(...l(e,d)||p(e)?[e,t]:[i,e]);m.append(r)}return m}m=i}else if(o(s,[u,h]))throw"ElseIf/Else must be after If or ElseIf"});
|
package/build/import-map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e=`https://unpkg.com/amateras@${"0.14.0"}/build`,t={amateras:`${e}/core.js`},s=[{name:"core",description:"Core module",entry:"core/src/index.ts",mapped:!0,listed:!0},{name:"widget",description:"Component module",entry:"widget/src/index.ts",mapped:!0,listed:!0},{name:"signal",description:"Reactive data module",entry:"signal/src/index.ts",mapped:!0,listed:!0},{name:"store",description:"Access data between widgets",entry:"store/src/index.ts",mapped:!0,listed:!0},{name:"css",description:"CSS-in-JS module",entry:"css/src/index.ts",mapped:!0,listed:!0},{name:"css-variable",description:"CSS variable module",entry:"css/src/ext/variable.ts",mapped:!0,listed:!1},{name:"css-keyframes",description:"CSS keyframes module",entry:"css/src/ext/keyframes.ts",mapped:!0,listed:!1},{name:"css-property",description:"CSS property module",entry:"css/src/ext/property.ts",mapped:!0,listed:!1},{name:"for",description:"For loop control-flow",entry:"for/src/index.ts",mapped:!0,listed:!0},{name:"if",description:"If/Else/ElseIf control-flow",entry:"if/src/index.ts",mapped:!0,listed:!0},{name:"match",description:"Match/Case/Default control-flow",entry:"match/src/index.ts",mapped:!0,listed:!0},{name:"router",description:"Router module",entry:"router/src/index.ts",mapped:!0,listed:!0},{name:"i18n",description:"Translation module",entry:"i18n/src/index.ts",mapped:!0,listed:!0},{name:"idb",description:"IndexedDB module",entry:"idb/src/index.ts",mapped:!0,listed:!0},{name:"markdown",description:"Markdown to HTML module",codeInsert:'import { Markdown } from "amateras/markdown"; new Markdown();',entry:"markdown/src/index.ts",mapped:!0,listed:!0},{name:"prefetch",description:"SSR data prefetch",entry:"prefetch/src/index.ts",mapped:!0,listed:!0},{name:"meta",description:"SSR `meta` tag manager",entry:"meta/src/index.ts",mapped:!0,listed:!0},{name:"ui",description:"UI components",entry:"ui/src/index.ts",mapped:!0,listed:!0},{name:"utils",description:"Utilities module",entry:"utils/src/index.ts",mapped:!0,listed:!0}].map(e=>e.name),r={...t,...Object.fromEntries(s.map(t=>{const s=`amateras/${t}`,r=`${e}/${t}.js`;return[[s,r],[`@${s}`,r]]}).flat())},n=document.querySelector('script[type="importmap"]');if(n){const e=JSON.parse(n.innerHTML);e.imports={...e.imports,...r},n.innerHTML=JSON.stringify(e,null,"\t")}else{const e=document.createElement("script");e.setAttribute("type","importmap"),e.innerHTML=JSON.stringify({imports:r},null,"\t"),document.head.prepend(e)}
|
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 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.
|
|
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.listen("dispose",()=>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/meta.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_Object_entries as t,isString as o,isArray as e,forEach as r,_Object_assign as n,isNull as a,isObject as
|
|
1
|
+
import{_Object_entries as t,isString as o,isArray as e,forEach as r,_Object_assign as n,isNull as a,isObject as m}from"@amateras/utils";import{Proto as i,onclient as s,onserver as c}from"@amateras/core";const p=(n,a,m,i)=>{let s=t=>m?`${m}:${t}`:t,c=(t,o)=>a.push({[i]:s(t),content:o});for(const[f,l]of t(n))o(l)?c(f,l):e(l)?r(l,t=>{o(t)?c(f,t):p(t,a,s(f),i)}):p(l,a,s(f),i)};function f(o,e){for(const[r,n]of t(e))!a(n)&&m(n)&&o[r]?f(o[r],n):o[r]=n;return o}n($,{meta(t,o=i.proto){s()||o&&(o.global.meta=f(o.global.meta??{},t))}}),c()&&n($.meta,{resolve:function(t){let o=[],{description:e,og:r,twitter:n}=t;return e&&o.push({name:"description",content:e}),r&&p(r,o,"og","property"),n&&p(n,o,"twitter","name"),o}});
|
package/build/prefetch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GlobalState as e,Proto as
|
|
1
|
+
import{GlobalState as e,Proto as r,onclient as t,onserver as a}from"@amateras/core";import{_Object_assign as o,toURL as i,_null as c,isAsyncFunction as h}from"@amateras/utils";e.assign(()=>({prefetch:{caches:{},req:null}})),globalThis.prefetch||(globalThis.prefetch={}),o($,{async fetch(e,o,l=r.proto){e=i(e,$.fetch.origin);let s=t()?prefetch[e.href]:c,n=o?.then,f=new Promise(async t=>{if(s&&Date.now()<s.expired){let e=n?.(s.data);return void t({record:s.data,result:e})}let{origin:i,server:c}=$.fetch,f=l?.global.prefetch.req?.headers.get("cookie")||"",d=e.origin===i&&c?await c.fetch(new Request(e,{...o,headers:{...o?.headers,Cookie:f}})):await fetch(e,o),g=o?.record;if(g){let o,i=h(g)?await g(d):g(d);a()&&l&&(l.global.prefetch.caches[e.href]={data:i,expired:Date.now()+3e4}),$.context(r,l,()=>{o=n?.(i)}),t({record:i,result:o})}});return a()&&l?.global.asyncTask(f),f}}),o($.fetch,{origin:t()?location.origin:"http://localhost",server:null});
|
package/build/router.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ElementProto as t,
|
|
1
|
+
import{ElementProto as t,onclient as e,Proto as s,ProxyProto as r,symbol_ProtoType as o,GlobalState as i}from"@amateras/core";import{_undefined as l,toURL as a,_null as n,forEach as h,map as c,_JSON_parse as u,_Object_entries as p,_JSON_stringify as d,is as f,_instanceof as g,isUndefined as v,isFunction as w,isArray as y,_Object_assign as b}from"@amateras/utils";class m 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))})}}let P=0;const[k,x]=[1,2],[S,T]=["forward","back"],E="__scroll_history__",R=e()?sessionStorage:n,_=e()?window.addEventListener:n,A=e()?window.removeEventListener:n;e()&&(history.scrollRestoration="manual");const L=t=>{const e=M.scrollHistory;if(t){let s=t.target;"#document"===s.nodeName?e[P]={[s.nodeName]:{x:window.scrollX,y:window.scrollY}}:""!==s.id&&(e[P]={[s.id]:{x:s.scrollLeft,y:s.scrollTop}})}else h(p(e),([t])=>+t>=P&&delete e[+t]);R?.setItem(E,d(e))};class M extends s{static direction=S;prev=n;url=n;routes=/* @__PURE__ */new Map;slot=new Q;static routers=/* @__PURE__ */new Set;constructor(){super(()=>$(this.slot)),e()&&M.routers.add(this)}set href(t){this.global.router.href=t}build(){if(e()){const t=()=>{const t=history.state?.index??0;P>t&&(M.direction=T),P<t&&(M.direction=S),P=t,this.prev=this.href,this.href=a(location.href),this.resolve(location.href)};t(),_?.("popstate",t),_?.("scroll",L,{capture:!0,passive:!1}),this.listen("dispose",()=>{A?.("popstate",t),A?.("scroll",L,{capture:!0})})}return super.build()}async resolve(t){if(!t)return;let e=a(t);this.global.router.scrollQueue.clear();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=[];h(t,t=>(e=c(t.validPaths,t=>c(e,e=>e+t)).flat(),s.push(...e),e)),this.global.router.matchPaths=s;break}}this.url=e,h(this.global.router.navlinks,t=>t.checkActive()),M.dispatchEvent(),Promise.all(this.global.router.scrollQueue).then(()=>{e===this.url&&M.scrollRestoration()})}static open(t,e="_self"){a(t).origin!==origin?open(t,e):M.writeState(t,k,e)}static forward(){history.forward()}static back(){history.back()}static replace(t){M.writeState(t,x)}static get scrollData(){return this.scrollHistory[P]??{}}static get scrollHistory(){return u(R?.getItem(E)??"{}")}static scrollRestoration(){if(e()){let t=M.scrollData??{x:0,y:0},e=p(t);e.length?h(e,([t,{x:e,y:s}])=>{"#document"===t?window.scrollTo(e,s):document.getElementById(t)?.scrollTo(e,s)}):(document.querySelectorAll("*").forEach(t=>t.scrollTo(0,0)),window.scrollTo(0,0))}}static writeState(t,s,r){if(!t)return;let o=a(t);if(!e()||o.href!==location.href){if(r&&"_self"!==r)return open(o,r);s===k&&P++,e()&&L(),h(this.routers,r=>{M.direction=S,e()&&(r.prev=a(location.href),history[s===k?"pushState":"replaceState"]({index:P},"",o)),r.href=o,r.resolve(t)}),M.dispatchEvent()}}static dispatchEvent(){e()&&window.dispatchEvent(new Event("pathchange"))}}class Q extends r{page=n;prevPage=n;constructor(){super()}switch(t){this.page!==t&&(this.prevPage=this.page,this.clear(),this.layout=()=>$(t),this.append(t),this.page=t,t.builded||t.build(),t.updateTitle(),this.dispatch("pageswitch",[this,M.direction],{bubbles:!0})||this.render())}render(){if(e()){this.prevPage?.removeNode();let t=this.toDOM();this.node?.replaceWith(...t)}}dispose(){super.dispose(),this.page=n,this.prevPage=n}}class D extends s{slot=new Q;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=>f(t,D)?.title)?.title??n,s=t=>{e()&&(document.title=t),this.global.title=t};t&&(g(t,Promise)?t.then(t=>{this.title=t,s(t)}):s(t))}}class N{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(v(e))break e;if(v(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,...w(l)?l():l};break t}}if(!r)return;let o=N.resolvePath(this.path,s);return this.validPaths=c(this.paths,t=>N.resolvePath(t[0],s)),[o,r,s]}static resolvePath(t,e){return t.replaceAll(/:([^/]+)/g,(t,s)=>`${e[s]}`)}alias(t,e){return this.paths.set(t,e),this}}class H extends N{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 I extends N{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,r,i){let l=this.pages.get(t);if(!l){let a,n=this.#t;if(y(n)){let t=n[0]();e()&&t.catch(()=>location.reload());let s=await t.then(t=>t.default);a=()=>$(s,r,()=>$(l.slot))}else a="Widget"===this.#t[o]?()=>$(this.#t,r,()=>$(l.slot)):this.#t;$.context(s,i,()=>{l=new D(this,a,r)}),this.pages.set(t,l)}return this.page=l,i.switch(l),l}}const W=t=>class extends M{static[o]="Router";constructor(){super(),t(this)}};let K={route(t,e,s){let r=new I(t,e);return this.routes.set(t,r),s?.(r),this},group(t,e){let s=new H(t);return this.routes.set(t,s),e?.(s),this},notfound(){}};b(N.prototype,K),b(M.prototype,K),i.assign(()=>({router:{routers:/* @__PURE__ */new Set,resolve(t){return c(this.routers,e=>e.resolve(t))},href:new URL("http://localhost"),routes:[],matchPaths:[],navlinks:/* @__PURE__ */new Set,scrollQueue:/* @__PURE__ */new Set,postScrollRestoration(t){t.finally(()=>this.scrollQueue.delete(t)),this.scrollQueue.add(t)}}})),i.disposers.add(({router:t})=>{t.routers.clear(),t.routes=[],t.matchPaths=[],t.navlinks.clear()}),b($,{router:t=>W(t),open:M.open,replace:M.replace,back:M.back,forward:M.forward,scrollRestoration:M.scrollRestoration,title(t,e=s.proto){let r=e?.findAbove(t=>f(t,D));r&&(r.title=t,r.updateTitle())}}),globalThis.Link=m,globalThis.NavLink=class extends m{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(w(t)&&"Router"===t[o]){let e=s.proto,r=new t;return e?.global.router.routers.add(r),r}});export{m as Link,D as Page,N as Route,H as RouteGroup,I as RouteNode,Q as RouteSlot,M as Router};
|
package/build/signal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_null as e,
|
|
1
|
+
import{_null as e,_instanceof as s,isSymbol as t,isString as i,isObject as l,isNull as u,forEach as a,_Object_entries as r,isFunction as n,isUndefined as h,_Object_assign as o,isBoolean as c,isNumber as p,_undefined as d}from"@amateras/utils";import{symbol_Signal as b,Proto as m,GlobalState as v,ProxyProto as f}from"@amateras/core";let g=!1,k=/* @__PURE__ */new Set,w=e=>{g=!1;let s=e();return g=!0,s},x=e=>{g=!0;let s=e(w);return g=!1,s},_=new FinalizationRegistry(({signal:e,ref:s})=>{e.computes?.delete(s)});class y extends Function{[b]=!0;linked=e;_value;subs=e;map=e;exec=e;computes=e;constructor(e){return super(),m.proto?.global.signals.add(this),this._value=e,s(e,y)&&this.link(e),new Proxy(this,{apply:()=>this._exec(),get:(e,s)=>{if(t(s)||i(s)&&!s.endsWith("$"))return this[s];s=s.slice(0,-1),this.map||(this.map={});const a=this.map[s];if(a)return a;{const e=this.map[s]??new y(null);return this.map[s]=e,this.setPropValue(e,s),e.subscribe(e=>{l(this.value)&&!u(this.value)&&Object.getOwnPropertyDescriptor(this.value,s)?.writable&&(this.value[s]=e),u(this.value)||this.emit()}),this.subscribe(()=>this.setPropValue(e,s)),e}}})}_exec(){return g&&k.add(this),this.value}setPropValue(e,s){if(l(this.value)&&!u(this.value)){const t=this.value[s];e.set(t)}else e._value=null}get value(){return this.linked?this.linked.value:this._value}dispose(){this.subs=e,this.linked=e,a(this.computes,e=>e.deref()?.dispose()),this.computes=e,this.exec=e,this._value=e,this.map&&a(r(this.map),([e,s])=>s.dispose()),this.map=e}set(t){s(t,y)?this.link(t):n(t)?this.set(t(this.value)):this.value!==t&&(this._value=t,this.linked=e,this.emit())}modify(e){e(this.value),this.linked?.emit(),this.emit()}emit(){a(this.subs,e=>e(this.value)),a(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);h(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}`}}v.assign(()=>({signals:/* @__PURE__ */new Set})),v.disposers.add(e=>{a(e.signals,e=>e.dispose()),e.signals.clear()}),o($,{signal:e=>new y(e),effect(e,s=[]){x(e),a(s,e=>k.add(e)),a(k,s=>s.subscribe(s=>e(w))),k.clear()},compute(e){let s=x(e),t=$.signal(s),i=m.proto;return t.exec=()=>{$.context(m,i,()=>{t.set(e(w))})},a(k,e=>{e.computes=e.computes??/* @__PURE__ */new Set;let s=new WeakRef(t);e.computes.add(s),_.register(t,{signal:e,ref:s})}),k.clear(),t},optional:s=>s.value?s:e,resolve:(e,t)=>s(e,y)?(t&&(e.subscribe(t),t(e.value)),e.value):(t?.(e),e)});let P=e=>{if(s(e,y)){let s=new f,t=d,l=e=>{i(e)||c(e)||p(e)?(t?t.content=`${e}`:s.layout=()=>t=$([e]).at(0),s.builded||s.build()):(t=d,s.layout=()=>$([e]),a(s.protos,e=>e.removeNode()),s.clear(!0),s.builded&&s.build(),s.node?.replaceWith(...s.toDOM()))};return e.subscribe(l),s.listen("dispose",()=>e.unsubscribe(l)),l(e.value),s}};$.process.text.add(P),$.process.craft.add(P),$.process.attr.add((e,t,i)=>{if(s(t,y)){let s=()=>i.attr(e,t.value);return t.subscribe(s),s(),i.listen("dispose",()=>t.unsubscribe(s)),!0}});export{y as Signal};
|
package/build/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Proto as t}from"@amateras/core";import{isUndefined as o,_Object_assign as e}from"@amateras/utils";class r{init;map=/* @__PURE__ */new WeakMap;constructor(t){this.init=t}create(...o){const e=t.proto;if(!e)throw`Store.create(): ${i}`;const r=this.init(...o);return this.map.set(e,r),e.
|
|
1
|
+
import{Proto as t}from"@amateras/core";import{isUndefined as o,_Object_assign as e}from"@amateras/utils";class r{init;map=/* @__PURE__ */new WeakMap;constructor(t){this.init=t}create(...o){const e=t.proto;if(!e)throw`Store.create(): ${i}`;const r=this.init(...o);return this.map.set(e,r),e.listen("dispose",()=>this.map.delete(e)),r}get(){const e=t.proto;if(!e)throw`Store.get(): ${i}`;const r=this.getValueFromProto(e);if(o(r))throw"Store.get(): value not found";return r}getValueFromProto(t){if(!t)return;return this.map.get(t)??this.getValueFromProto(t.parent)}}const i="should be called inside proto layout function";e($,{store:t=>new r(t)});export{r as Store};
|
package/build/ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
1
|
+
var t,e,i,s,o,r,n,a,c,l,h=Object.defineProperty,d=t=>{throw TypeError(t)},u=(t,e,i)=>((t,e,i)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),p=(t,e,i)=>e.has(t)||d("Cannot "+i),g=(t,e,i)=>(p(t,e,"read from private field"),i?i.call(t):e.get(t)),b=(t,e,i)=>e.has(t)?d("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),m=(t,e,i,s)=>(p(t,e,"write to private field"),s?s.call(t,i):e.set(t,i),i);import{onclient as v,ElementProto as f,TextProto as x,Proto as k,ProxyProto as w}from"@amateras/core";import{_null as y,is as M,UID as z,forEach as I,_Object_entries as D,isObject as S,_instanceof as C,isUndefined as A,isEqual as O,_Object_assign as W,isNull as L,isString as H,_Array_from as E}from"@amateras/utils";const R=t=>(e,i,s)=>{if(e.slide=i,!v())return;let o=i.toDOM();e.node?.append(...o);let r={duration:t?.duration??500,easing:t?.easing??"ease"},n=$.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"]]));i.node?.animate({translate:n[0]},r);const a=s?.node?.animate({translate:n[1]},r);a&&(a.onfinish=()=>s?.node?.remove())},T=class extends f{constructor(t,e){super("slide",t,e)}};$.style(T,"slide{display:block;height:100%;width:100%;position:absolute}");let B=T;const F=class extends f{constructor({index:i,interval:s,autoplay:o,autopause:r,animation:n,...a},c){super("slideshow",a,c),u(this,"slide",y),u(this,"index"),u(this,"timer",y),u(this,"interval"),u(this,"autoplay"),u(this,"autopause"),u(this,"animation"),b(this,t,0),b(this,e,y),u(this,"playing",!1),this.index=i??0,this.interval=s??5,this.autoplay=o??!1,this.autopause=r??!0,this.animation=n??y,this.listen("dispose",()=>this.pause()),this.listen("dom",()=>{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&&!g(this,e)&&(m(this,e,new ResizeObserver(()=>{this.autopause&&(this.inDOM()?this.play():this.pause())})),g(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,i,s,o;(e=this,i=t,{set _(t){m(e,i,t,s)},get _(){return g(e,i,o)}})._++,g(this,t)>=100*this.interval&&(this.next(),m(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(F,"slideshow{display:block;position:relative;overflow:clip}");let _=F;const j=class extends f{value;constructor({value:t,...e},i){super("radio-group",e,i),this.value=t,this.on("input",t=>{this.value=M(t.target,HTMLInputElement)?.value})}};$.style(j,"radio-group{display:block}");let N=j;const U=class extends f{inputId;name;value;constructor({inputId:t,name:e,value:i,...s},o){super("radio-item",s,o),this.inputId=t??`input-${z.persistInProto(this,"radio-item")}`,this.name=e??y,this.value=i}};$.style(U,"radio-item{display:block}");let Y=U;class P extends f{constructor(t,e){super("input",{type:"radio",...t},e)}build(t){let e=this.findAbove(t=>M(t,Y));return e&&(this.attr("id",e.inputId),this.attr("name",e.name)),super.build(t)}}class q extends f{constructor(t,e){super("label",t,e)}build(t){let e=this.findAbove(t=>M(t,Y));return e&&this.attr("for",e.inputId),super.build(t)}}const[G,X,Z,J,K]=["accordion","accordion-item","accordion-trigger","accordion-content","accordion-container"],Q=class extends f{$trigger=y;$container=y;constructor(t,e){super(G,t,e)}open(){this.attr("opened","")}close(){this.attr("opened",null)}switch(){""===this.attr("opened")?this.close():this.open()}};$.style(Q,[`${G},${X},${Z}{display:block}`,`${K}{display:grid;grid-template-rows:0fr}`,`${G}[opened] ${K}{grid-template-rows:1fr}`,`${J}{overflow:hidden}`]);let V=Q;class tt extends f{constructor(t,e){super(K,t,e)}build(t){let e=this.findAbove(t=>M(t,V));return e&&(e.$container=this),super.build(t)}}class et extends f{constructor(t,e){super(J,t,e)}}class it extends f{constructor(t,e){super(Z,t,e)}build(t){let e=this.findAbove(t=>M(t,V));return e&&(e.$trigger=this,this.on("click",()=>e.switch())),super.build(t)}}const st=class extends f{gap;columns;size;observer=null;constructor({gap:t,columns:e,autosize:i,size:s,...o},r){super("waterfall",o,r),this.gap=t??0,this.columns=e??1,this.size=s??0,v()&&(this.observer=new ResizeObserver(()=>{this.inDOM()&&requestAnimationFrame(()=>this.refresh())}))}toDOM(t=!0){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 i=this.columns;this.size&&(i=Math.trunc(e/(this.size+this.gap))||1);const s=(e-this.gap*(i-1))/i;for(let o=0;o<i;o++)t.push({items:[],height:0,width:s,left:o*(s+this.gap)});I(this.children,e=>{if(!e.node)return;e.ratio||e.node.offsetHeight&&e.node.offsetWidth&&(e.ratio=e.node.offsetWidth/e.node.offsetHeight);const i=s/e.ratio,o=t.sort((t,e)=>t.height-e.height)[0];e.style({height:`${i}px`,width:`${s}px`,top:`${o.height}px`,left:`${o.left}px`}),o.height+=i+this.gap})}mutate(){this.refresh()}};$.style(st,"waterfall{display:block;position:relative;min-height:100dvh}");let ot=st;const rt=class extends f{ratio=0;constructor(t,e){super("waterfall-item",t,e)}toDOM(t=!0){super.toDOM(t);const e=this.findAbove(t=>M(t,ot));return this.node?.querySelectorAll("img").forEach(t=>e?.observer?.observe(t)),[this.node]}};$.style(rt,"waterfall-item{display:block;position:absolute}");let nt=rt;const at=class extends f{targetId;$container=y;triggers=/* @__PURE__ */new Map;constructor({targetId:t,...e},i){super("tabs",e,i),this.targetId=t??y}switch(t){this.targetId!==t&&(this.targetId=t,this.$container?.renderContent())}};$.style(at,"tabs{display:block;}");let ct=at;class lt extends f{tabId;tabs=y;constructor({tabId:t,...e},i){super("tab-trigger",e,i),this.tabId=t,this.on("click",()=>this.tabs?.switch(this.tabId))}build(t){return super.build(t),this.tabs=this.findAbove(t=>M(t,ct)),this.tabs?.triggers.set(this.tabId,this),this}}$.style(ct,"tab-trigger{cursor:pointer;}");class ht extends f{tabs=null;constructor({...t},e){super("tab-container",t,e)}build(t){return super.build(t),this.tabs=this.findAbove(t=>M(t,ct)),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,i=e?this.getContent(e):this.children.at(0);return t&&i&&(this.node?.replaceChildren(...i.toDOM()),this.tabs?.triggers.forEach(t=>{t.attr("active",t.tabId===i.tabId?"":y)})),i}}$.style(ct,"tab-container{display:block;}");class dt extends f{tabId;tabs=null;constructor({tabId:t,...e},i){super("tab-content",e,i),this.tabId=t}build(t){return super.build(t),this.tabs=this.findAbove(t=>M(t,ct)),this}}$.style(ct,"tab-content{display:block;}");const ut=(t,e)=>{let i=[];for(let[s,o]of D(e))S(o)?i.push(ut(s,o)):i.push(`${s.replaceAll(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}: ${o};`);return`${t} { ${i.join(" ")} }`},pt=class t extends f{$select=y;constructor(e,i){super(t.tagname,e,i)}build(t){return super.build(t),this.$select=this.findAbove(t=>C(t,xt)),this.$select&&(this.$select.$content=this),this}};u(pt,"tagname","select-content"),$.style(pt,ut(pt.tagname,{position:"absolute",top:"0",left:"0",maxHeight:"50dvh",overflowY:"auto",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",scrollbarWidth:"thin",scrollbarColor:"var(--input) transparent"}));let gt=pt;const bt=class t extends f{constructor(e,s){super(t.tagname,{tabindex:0,...e},s),u(this,"$select",y),u(this,"$content",y),b(this,i,y),this.on("click",()=>{this.$select?.close(),this.select()}),this.on("keydown",e=>{let i=i=>{if(e.preventDefault(),!this.$content)return;let s=this.$content?.findBelowAll(e=>C(e,t)),o=s.indexOf(this),r="up"===i?o-1:o+1;(r<0||r>=s.length)&&(r="up"===i?-1:0);let n=s.at(r);n?.node?.focus()};switch(e.key){case"ArrowDown":i("down");break;case"ArrowUp":i("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 g(this,i);A(t)||$.resolve(t,t=>{m(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=>C(t,xt)),this.$content=this.findAbove(t=>C(t,gt)),this.$select&&this.$select.value()===g(this,i)&&(this.$select.selected=this),this.$select?.itemMap.set(g(this,i),this),this}};i=new WeakMap,u(bt,"tagname","select-item"),$.style(bt,ut(bt.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 mt=bt;const vt=(t,e,i)=>{let s={top:0,left:0,height:0,width:0},o=new ResizeObserver(()=>ft(t,e,s)),r=()=>ft(t,e,s);return o.observe(t),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},ft=(t,{style:e},i)=>{let s=t.getBoundingClientRect(),o={top:s.top+window.scrollY,left:s.left+window.scrollX,width:s.width,height:s.height},{top:r,left:n,width:a,height:c}=o;O(i,o,["top","left","height","width"])||(W(i,{top:r,left:n,width:a,height:c}),e.top=`${c+r}px`,e.left=`${n}px`,e.width=`${a}px`)},$t=class t extends f{constructor(e,i){super(t.tagname,e,i),u(this,"$trigger",y),u(this,"$content",y),u(this,"clickListener",y),b(this,s,y),u(this,"selected",y),u(this,"itemMap",/* @__PURE__ */new Map),u(this,"$value",y),u(this,"disconnect",y),this.listen("i18nupdate",()=>this.$value?.render())}props({value:t,disabled:e,...i}){super.props(i),this.disabled(e),this.value(t)}disabled(t){if(!arguments.length)return""===this.attr("disabled");A(t)||$.resolve(t,t=>{this.attr("disabled",t?"":y)})}value(t){if(!arguments.length)return g(this,s);A(t)||($.resolve(t,t=>{m(this,s,t);let e=this.itemMap.get(t);this.selected=e??y,this.$value?.render(),this.dispatch("selectvalue",[this,t],{bubbles:!0})}),this.node?.dispatchEvent(new Event("select-value")))}open(){this.attr("opened",""),v()&&this.$content&&(this.disconnect=vt(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()??this.$content?.findBelow(t=>C(t,mt))?.node?.focus(),window.addEventListener("click",this.clickListener))}close(){this.attr("opened",y),v()&&(this.$content?.removeNode(),this.clickListener&&window.removeEventListener("click",this.clickListener),this.disconnect?.(),this.disconnect=y)}toDOM(t=!0){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,u($t,"tagname","select-proto"),$.style($t,ut($t.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let xt=$t;const kt=class t extends f{$select=y;constructor(e,i){super(t.tagname,{tabindex:0,...e},i),this.on("click",t=>L(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=>C(t,xt)),this.$select&&(this.$select.$trigger=this),this}};u(kt,"tagname","select-trigger"),$.style(kt,ut(kt.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 wt=kt;class yt extends f{static tagname="select-value";$select=y;$placeholder=y;$text=new x("");constructor(t,e){super(yt.tagname,t,e)}props({placeholder:t,...e}){super.props(e),this.placeholder(t??y)}build(t){return super.build(t),this.$select=this.findAbove(t=>C(t,xt)),this.$select&&(this.$select.$value=this),this}placeholder(t){$.resolve(t,t=>{H(t)?$.context(k,this,()=>this.$placeholder=new x(t)):this.$placeholder=t,this.render()})}render(){let t=y;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()))}}class Mt extends f{constructor(t,e){super("selector-group",t,e)}}const zt=class t extends f{constructor(e,i){super(t.tagname,e,i)}props({svg:t,...e}){super.props(e),this.svg(t)}svg(t){$.resolve(t,t=>{this.innerHTML(t)})}};u(zt,"tagname","icon"),$.style(zt,ut(zt.tagname,{display:"inline-block",verticalAlign:"middle",height:"1rem",width:"1rem",svg:{display:"block",height:"auto",width:"100%"}}));let It=zt;const Dt=class extends It{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(Dt,ut(`select-proto[opened] ${Dt.tagname}`,{rotate:"180deg"}));let St=Dt;const Ct="@media (hover: hover) and (pointer: fine)",At=class extends f{constructor(t,e){super("button",{ui:"button",...t},e)}};u(At,"tagname","button"),$.style(At,ut('button[ui="button"]',{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",lineHeight:"1rem",transition:"0.2s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",userSelect:"none",gap:"calc(var(--spacing) * 2.5)",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)"},"&:not([disabled]):active":{translate:"0 0.125rem"},[Ct]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)",[Ct]:{"&:not([disabled]):hover":{background:"oklch(from var(--primary-bg) l c h / .8)"}}},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)",[Ct]:{"&: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)",[Ct]:{"&: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)",[Ct]:{"&: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)",[Ct]:{"&: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)",lineHeight:"var(--text-xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",padding:"0",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)",padding:"0"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)",padding:"0"},"&[disabled]":{opacity:".5"}}));let Ot=At;const Wt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Wt,"tagname","badge"),$.style(Wt,ut(Wt.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)",lineHeight:"var(--text-xs)",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",gap:"var(--spacing)",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"}},'&[size="sm"]':{padding:"0 calc(var(--spacing) * 1)",fontSize:"var(--text-xs2)",lineHeight:"var(--text-xs2)",height:"calc(var(--spacing) * 4)"},"a[disabled] &":{opacity:".5"}}));let Lt=Wt;const Ht=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Ht,"tagname","card"),$.style(Ht,ut(Ht.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 Et=Ht;const Rt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Rt,"tagname","card-header"),$.style(Rt,ut(Rt.tagname,{display:"flex",width:"100%",flexDirection:"column",gap:"var(--spacing)",paddingInline:"calc(var(--spacing) * 4)"}));let Tt=Rt;const Bt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Bt,"tagname","card-content"),$.style(Bt,ut(Bt.tagname,{display:"block",paddingInline:"calc(var(--spacing) * 4)"}));let Ft=Bt;const _t=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(_t,"tagname","h3"),$.style(_t,ut(`card ${_t.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"1.375",fontSize:"var(--text-base)",color:"var(--fg)"}));let jt=_t;const Nt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Nt,"tagname","p"),$.style(Nt,ut(`card ${Nt.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"var(--line-height-sm)",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Ut=Nt;const Yt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Yt,"tagname","dl"),$.style(Yt,ut(Yt.tagname,{display:"flex",flexDirection:"column"}));let Pt=Yt;const qt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(qt,"tagname","dc"),$.style(qt,ut(qt.tagname,{paddingBlock:"1rem",borderBottom:"1px solid color-mix(in oklch, var(--input) 50%, transparent)","&:last-child":{borderBottom:"none"}}));let Gt=qt;const Xt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Xt,"tagname","dt"),$.style(Xt,ut(Xt.tagname,{fontSize:"var(--text-sm)",fontWeight:"var(--font-weight-medium)"}));let Zt=Xt;const Jt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Jt,"tagname","dd"),$.style(Jt,ut(Jt.tagname,{margin:"0",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Kt=Jt;const Qt=class t extends f{clickListener=y;constructor(e,i){super(t.tagname,e,i)}open(t){v()&&(this.build(),this.style({top:`${t.y}px`,left:`${t.x}px`}),this.clickListener=t=>{t.target!==this.node&&(t.target&&this.node?.contains(t.target)||this.close())},setTimeout(()=>window.addEventListener("click",this.clickListener),1),document.body.append(...this.toDOM()))}close(t=!0){this.removeNode(),this.clickListener&&window.removeEventListener("click",this.clickListener),this.clickListener=y,t&&this.dispose()}};u(Qt,"tagname","context-menu"),$.style(Qt,ut(Qt.tagname,{display:"block",position:"fixed",top:"0",left:"0",maxHeight:"50dvh",overflowY:"auto",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",scrollbarWidth:"thin",scrollbarColor:"var(--input) transparent"}));let Vt=Qt;const te=class t extends f{$menu=y;constructor(e,i){super(t.tagname,e,i),this.on("click",()=>this.$menu?.close())}build(t){return super.build(t),this.$menu=this.findAbove(t=>C(t,Vt)),this}};u(te,"tagname","context-menu-item"),$.style(te,ut(te.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 ee=te;const ie=class t extends f{constructor(e,i){super(t.tagname,{ui:"input",...e},i)}};u(ie,"tagname","input"),$.style(ie,ut('input[ui="input"]',{borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",transition:"0.2s all ease",fontFamily:"inherit",fontSize:"var(--text-sm)",padding:"0 calc(var(--spacing) * 2.5)",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)",outline:"0.2rem solid transparent","&:focus-visible":{outlineColor:"var(--border)"}}));let se=ie;const oe=class t extends f{constructor(e,i){super(t.tagname,e,i)}props({for:t,...e}){super.props(e),this.for(t)}build(t){return super.build(t),this.setFor(),this}for(t){if(!arguments.length)return this.attr("for");A(t)||$.resolve(t,t=>{this.attr("for",t),this.setFor()})}setFor(){const t=this.for();this.findBelow(e=>{C(e,f)&&("input"===e.tagname&&e.attr("id",t),"label"===e.tagname&&e.attr("for",t))})}};u(oe,"tagname","field"),$.style(oe,ut(oe.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing) * 2)",width:"100%",'&[direction="horizontal"]':{flexDirection:"row",placeItems:"center",width:"unset"}}));let re=oe;const ne=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(ne,"tagname","label"),$.style(ne,ut(ne.tagname,{"field &":{display:"block",userSelect:"none",color:"var(--fg)",fontWeight:"var(--font-weight-medium)",fontSize:"var(--text-sm)",lineHeight:"var(--text-sm)",flexShrink:"0"},"field[disabled] &":{pointerEvents:"none"}}));let ae=ne;const ce=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(ce,"tagname","field-description"),$.style(ce,ut(ce.tagname,{"field &":{display:"block",color:"var(--muted)",fontWeight:"var(--font-weight-medium)",fontSize:"var(--text-sm)"},"field[disabled] &":{pointerEvents:"none"}}));let le=ce;const he=class extends f{constructor(t,e){super("input",{type:"checkbox",ui:"switch",...t},e)}};u(he,"tagname","input"),$.style(he,ut('input[ui="switch"]',{appearance:"none",display:"inline-flex",height:"calc(var(--spacing) * 5)",width:"calc(var(--spacing) * 9)",background:"color-mix(in oklab, var(--input) 80%, transparent)",border:"none",placeItems:"center",borderRadius:"calc(var(--spacing) * 5)",transition:"all .3s ease",padding:"0","&::after":{content:'""',display:"block",height:"calc(var(--spacing) * 5)",width:"calc(var(--spacing) * 5)",background:"var(--fg)",borderRadius:"var(--radius-round)",transition:"all .3s ease"},"&:checked":{background:"var(--primary-bg)","&::after":{height:"calc(var(--spacing) * 4.5)",width:"calc(var(--spacing) * 4.5)",translate:"calc(115% - var(--spacing)) 0",background:"var(--bg)"}}}));let de=he;const ue=class extends f{constructor(t,e){super("button",{ui:"toggle",...t},e),this.on("click",t=>this.checked(!this.checked()))}props({checked:t,...e}){super.props(e),this.checked(t)}checked(t){if(!arguments.length)return!L(this.attr("checked"));A(t)||$.resolve(t,t=>{this.attr("checked",t?"":y),this.node?.dispatchEvent(new Event("input"))})}};u(ue,"tagname","button"),$.style(ue,ut('button[ui="toggle"]',{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",lineHeight:"1rem",transition:"0.1s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",userSelect:"none",gap:"calc(var(--spacing) * 2.5)",flexShrink:"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 / .8)",[Ct]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h)"}},"&[checked]":{color:"oklch(from var(--primary-fg) l c h)",background:"oklch(from var(--primary-bg) l c h / .8)",[Ct]:{"&:not([disabled]):hover":{background:"oklch(from var(--primary-bg) l c h)",color:"oklch(from var(--primary-fg) l c h)"}}},'&[variant="primary"]':{"&[checked]":{color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"}},'&[variant="secondary"]':{"&[checked]":{color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)"}},'&[variant="destructive"]':{"&[checked]":{color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&[checked]":{color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)"}},'&[size="icon"]':{width:"calc(var(--spacing) * 8)",padding:"0"},'&[size="xs"]':{padding:"calc(var(--spacing) * 2)",fontSize:"var(--text-xs)",lineHeight:"var(--text-xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",padding:"0",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)",padding:"0"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)",padding:"0"},"&[disabled]":{opacity:".5"}}));let pe=ue;const ge={display:"flex",gap:"calc(var(--spacing) * 1.25)",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"}};class be extends f{$combobox=y;$focusedItem=y;$createItem=y;constructor(t,e){super("combobox-list",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>C(t,ke)),this.$combobox&&(this.$combobox.$list=this),this}filter(t){if(!this.$combobox)return;const e=[];this.$createItem&&(this.$createItem.visible=!!t&&!this.$combobox.itemMap.has(t)),I(this.$combobox.itemMap,([i,s])=>{s.visible=!1,s.text.toLowerCase().includes(t.toLowerCase())&&(s.visible=!0,e.push(s))}),this.$combobox?.$content?.$empty&&(this.$combobox.$content.$empty.visible=!this.$createItem?.visible&&!e.length),this.$combobox.$content?.toDOM()}switch(t){const e=this.$focusedItem,i=this.children,s=e?i.indexOf(e):"up"===t?0:-1;let o="up"===t?s-1:s+1;(o<0||o>=i.length)&&(o="up"===t?-1:0),this.focus(o)}focus(t){let e=this.children.at(t);this.$focusedItem?.blur(),e?.focus()}focusFirstItem(){this.$createItem?.visible&&this.children[1]?this.focus(1):this.focus(0)}mutate(){}}const me=class extends f{constructor(t,e){super("combobox-item",t,()=>{e?e(this):$([g(this,r)]),$(It,{ui:"combobox-item-check",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-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>'})}),u(this,"$combobox",y),u(this,"$list",y),b(this,o,y),b(this,r,""),b(this,n,!1),this.on("mousedown",t=>t.preventDefault()),this.on("click",()=>{this.$combobox?.select(g(this,o),!this.selected())})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>C(t,ke)),this.$list=this.findAbove(t=>C(t,be)),this.$combobox?.itemMap.set(g(this,o),this),this}props({value:t,label:e,selected:i,...s}){super.props(s),this.value(t),this.label(e),this.selected(i)}value(t){if(!arguments.length)return g(this,o);A(t)||$.resolve(t,t=>{this.$combobox?.itemMap.delete(g(this,o)),this.$combobox?.itemMap.set(t,this),m(this,o,t)})}label(t){if(!arguments.length)return g(this,r);A(t)||$.resolve(t,t=>{m(this,r,t)})}selected(t){if(!arguments.length)return g(this,n);A(t)||$.resolve(t,t=>{m(this,n,t),this.attr("selected",t?"":null)})}focus(){this.attr("focus",""),this.$list&&(this.$list.$focusedItem=this)}blur(){this.attr("focus",y),this.$list&&(this.$list.$focusedItem=null)}};o=new WeakMap,r=new WeakMap,n=new WeakMap,u(me,"tagname","combobox-item"),$.style(me,ut(me.tagname,{...ge,'icon[ui="combobox-item-check"]':{visibility:"hidden",marginInlineStart:"auto"},'&[selected] icon[ui="combobox-item-check"]':{visibility:"visible"}}));let ve=me;const fe=class extends f{$combobox=y;$list=y;constructor(t,e){super("combobox-create-item",t,e),this.on("mousedown",t=>t.preventDefault()),this.on("click",()=>{})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>C(t,ke)),this.$list=this.findAbove(t=>C(t,be)),this.$list&&(this.$list.$createItem=this),this}focus(){this.attr("focus",""),this.$list&&(this.$list.$focusedItem=this)}blur(){this.attr("focus",y),this.$list&&(this.$list.$focusedItem=null)}};u(fe,"tagname","combobox-create-item"),$.style(fe,ut(fe.tagname,{...ge}));let $e=fe;const xe=class extends f{constructor(t,e){super("combobox",t,e),u(this,"$trigger",y),u(this,"$content",y),u(this,"$list",y),u(this,"$chips",y),u(this,"$input",y),u(this,"itemMap",/* @__PURE__ */new Map),b(this,a,/* @__PURE__ */new Set),u(this,"disconnect",y)}build(t){return super.build(t),I(g(this,a),t=>this.select(t)),this}toDOM(t=!0){return super.toDOM(!1),t&&this.$trigger&&(this.node?.append(...this.$trigger.toDOM()),this.$content?.toDOM()),[this.node]}props({values:t,...e}){super.props(e),this.values(t)}open(){this.attr("opened",""),v()&&this.$content&&(this.disconnect=vt(this.$trigger?.node,this.$content.node),document.body.append(...this.$content.toDOM()),this.$input&&this.$list?.filter(this.$input.node?.value??""))}close(){this.attr("opened",y),v()&&(this.$content?.removeNode(),this.disconnect?.(),this.disconnect=y)}select(t,e=!0){const i=this.itemMap.get(t);i&&(i.selected(e),e?(g(this,a).add(t),this.$chips?.appendChip(t),this.dispatch("combobox_select",[t])):(g(this,a).delete(t),this.$chips?.removeChip(t),this.dispatch("combobox_unselect",[t])),this.dispatch("combobox_input",[t]))}get selected(){return E(this.itemMap.values()).filter(t=>t.selected())}values(t){if(!arguments.length)return E(g(this,a));A(t)||$.resolve(t,t=>{m(this,a,new Set(t))})}};a=new WeakMap,u(xe,"tagname","combobox"),$.style(xe,ut(xe.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let ke=xe;const we=class extends f{$combobox=y;constructor(t,e){super("combobox-trigger",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>C(t,ke)),this.$combobox&&(this.$combobox.$trigger=this),this}};u(we,"tagname","combobox-trigger"),$.style(we,ut(we.tagname,{display:"flex",flexWrap:"wrap",columnGap:"calc(var(--spacing) * 1.25)",placeItems:"center",boxSizing:"border-box",border:"1px solid var(--input)",background:"color-mix(in oklch, var(--input) 30%, transparent)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",lineHeight:"1",padding:"0 calc(var(--spacing) * 1.25)","&:hover":{background:"color-mix(in oklch, var(--input) 50%, transparent)"},"&:focus-within":{outline:"0.1rem solid var(--border)"}}));let ye=we;const Me=class extends f{$combobox=y;constructor(t,e){super("input",{ui:"combobox-input",...t},e),this.on("focus",t=>L(this.$combobox?.attr("opened"))&&this.$combobox.open()),this.on("blur",t=>{this.$combobox?.close(),this.$combobox?.$chips?.$focusedChip?.blur()}),this.on("input",t=>{this.$combobox?.$list?.filter(t.currentTarget.value),this.$combobox?.$list?.focusFirstItem()}),this.on("keydown",t=>{switch(t.key){case"ArrowDown":return t.preventDefault(),void this.$combobox?.$list?.switch("down");case"ArrowUp":return t.preventDefault(),void this.$combobox?.$list?.switch("up");case"Backspace":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.children.at(-1)?.delete());case"ArrowRight":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.switch("right"));case"ArrowLeft":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.switch("left"))}}),this.on("keyup",t=>{switch(t.key){case"Escape":return t.preventDefault(),this.$combobox?.close(),void this.$combobox?.$trigger?.node?.focus();case"Delete":{const t=this.$combobox?.$chips?.$focusedChip;return this.$combobox?.$chips?.switch("right"),void t?.delete()}case"Tab":case"Enter":{t.preventDefault();const e=this.$combobox?.$list?.$focusedItem;if(!e)return;return C(e,ve)?this.$combobox?.select(e.value()):this.dispatch("combobox_create",[t.currentTarget.value],{bubbles:!0}),t.currentTarget.value="",void this.$combobox?.$list?.filter("")}}t.currentTarget.value.length&&this.$combobox?.$chips?.$focusedChip?.blur()})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>C(t,ke)),this.$combobox&&(this.$combobox.$input=this),this}};$.style(Me,ut('input[ui="combobox-input"]',{border:"unset",background:"unset",color:"oklch(from var(--fg) l c h / .9)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",lineHeight:"1",height:"calc(var(--spacing) * 8)",flex:"1",minWidth:"2rem",padding:"0 calc(var(--spacing) * 1.25)","&:focus":{outline:"unset"}}));let ze=Me;const Ie=class extends f{$combobox=y;$empty=y;constructor(t,e){super("combobox-content",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>C(t,ke)),this.$combobox&&(this.$combobox.$content=this),this}};u(Ie,"tagname","combobox-content"),$.style(Ie,ut(Ie.tagname,{position:"absolute",top:"0",left:"0",maxHeight:"50dvh",overflowY:"auto",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",scrollbarWidth:"thin",scrollbarColor:"var(--input) transparent"}));let De=Ie;const Se=class extends f{$content=y;constructor(t,e){super("combobox-empty",t,e)}build(t){return super.build(t),this.$content=this.findAbove(t=>C(t,De)),this.$content&&(this.$content.$empty=this),this}};u(Se,"tagname","combobox-empty"),$.style(Se,ut(Se.tagname,{...ge}));let Ce=Se;class Ae extends w{static tagname="combobox-chips";$combobox=y;chipMap=/* @__PURE__ */new Map;$focusedChip=y;constructor(t){super(t)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>C(t,ke)),this.$combobox&&(this.$combobox.$chips=this),this}appendChip(t){const e=this.$combobox?.itemMap.get(t);if(!e)throw"ComboboxChips.addChip: $item not found";const i=this.chipMap.get(t)??$(We,{value:t,label:e.label()});this.chipMap.set(t,i),this.protos.has(i)||(this.append(i),i.builded||i.build(),this.node?.replaceWith(...this.toDOM()))}removeChip(t){const e=this.chipMap.get(t);if(!e)throw"ComboboxChips.removeChip: $chip not found";e.remove(),e.removeNode()}switch(t){const e=this.$focusedChip,i=this.children,s=e?i.indexOf(e):"left"===t?0:-1;let o="left"===t?s-1:s+1;(o<0||o>=i.length)&&(o="left"===t?-1:0),this.focus(o)}focus(t){let e=this.children.at(t);this.$focusedChip?.blur(),e?.focus()}}const Oe=class extends f{constructor(t,e){super("combobox-chip",t,()=>{e?e(this):($([g(this,l)]),$(Le))}),u(this,"$chips",y),b(this,c),b(this,l,"")}build(t){return super.build(t),this.$chips=this.findAbove(t=>C(t,Ae)),this}props({value:t,label:e,...i}){super.props(i),this.value(t),this.label(e)}value(t){if(!arguments.length)return g(this,c);A(t)||$.resolve(t,t=>{this.$chips?.chipMap.delete(t),this.$chips?.chipMap.set(t,this),m(this,c,t)})}label(t){if(!arguments.length)return g(this,l);A(t)||$.resolve(t,t=>{m(this,l,t)})}delete(){this.$chips?.$combobox?.select(g(this,c),!1)}focus(){this.attr("focus",""),this.$chips&&(this.$chips.$focusedChip=this)}blur(){this.attr("focus",y),this.$chips&&(this.$chips.$focusedChip=y)}};c=new WeakMap,l=new WeakMap,u(Oe,"tagname","combobox-chip"),$.style(Oe,ut(Oe.tagname,{display:"inline-flex",placeItems:"center",fontSize:"var(--text-xs)",padding:"0 calc(var(--spacing) * 1.5)",background:"var(--secondary-bg)",borderRadius:"calc(var(--radius) * .6)",height:"calc(var(--spacing) * 5.25)",marginBlock:"calc(var(--spacing))","&[focus]":{outline:"2px solid var(--input)"},'button[ui="combobox-chip-remove"]':{background:"unset",border:"unset",color:"oklch(from var(--fg) l c h / .9)",paddingInlineStart:"calc(var(--spacing) * 1.5)",icon:{height:"calc(var(--spacing) * 3.25)",width:"calc(var(--spacing) * 3.25)"}}}));let We=Oe;class Le extends f{static tagname="button";$chip=y;constructor(t,e){super("button",{ui:"combobox-chip-remove",...t},()=>{e?e(this):$(It,{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-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>'})}),this.on("click",()=>{this.$chip?.$chips?.$combobox?.select(this.$chip.value(),!1)})}build(t){return super.build(t),this.$chip=this.findAbove(t=>C(t,We)),this}}export{V as Accordion,tt as AccordionContainer,et as AccordionContent,it as AccordionTrigger,Lt as Badge,Ot as Button,Et as Card,Ft as CardContent,Ut as CardDescription,Tt as CardHeader,jt as CardTitle,ke as Combobox,We as ComboboxChip,Le as ComboboxChipRemoveButton,Ae as ComboboxChips,De as ComboboxContent,$e as ComboboxCreateItem,Ce as ComboboxEmpty,ze as ComboboxInput,ve as ComboboxItem,be as ComboboxList,ye as ComboboxTrigger,Vt as ContextMenu,ee as ContextMenuItem,Gt as DescriptionContent,Kt as DescriptionDetail,Pt as DescriptionList,Zt as DescriptionTerm,re as Field,le as FieldDescription,ae as FieldLabel,It as Icon,se as Input,q as Label,P as Radio,N as RadioGroup,Y as RadioItem,xt as Select,St as SelectArrow,gt as SelectContent,Mt as SelectGroup,mt as SelectItem,wt as SelectTrigger,yt as SelectValue,B as Slide,_ as Slideshow,de as Switch,dt as TabContent,lt as TabTrigger,ct as Tabs,ht as TabsContainer,pe as Toggle,ot as Waterfall,nt as WaterfallItem,R as slideInOut};
|
package/build/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=null,t=void 0,r=Object,n=r.fromEntries,
|
|
1
|
+
const e=null,t=void 0,r=Object,n=r.fromEntries,s=r.entries,o=r.assign,i=r.values,a=r.defineProperty,c=r.getOwnPropertyDescriptors,l=Array,u=l.from,f=async(e,t)=>{if(!e)return;let r=0;return j(t)?(async()=>{for(let n of e)await t(n,r,e),r++})():(()=>{for(let n of e)t(n,r,e),r++})()},p=(e,t)=>u(e).map(t),g=(e,...t)=>e.filter(e=>!t.includes(e)),h=(e,t)=>typeof e===t,m=(e,t)=>t.includes(e),y=e=>h(e,"string"),d=e=>h(e,"boolean"),w=e=>h(e,"number"),b=e=>h(e,"object"),N=e=>h(e,"function"),P=e=>h(e,"symbol"),j=e=>T(e,(async()=>0).constructor),v=e=>void 0===e,O=t=>t===e,S=l.isArray,T=(e,...t)=>!!t.find(t=>e instanceof t),U=(t,r)=>T(t,r)?t:e,A=JSON.stringify,E=JSON.parse,M=(e,...t)=>!!t.find(t=>e.startsWith(t)),$=(e,t,r)=>e.slice(t,r),x=(e,t)=>e.bind(t),C=Promise,J=()=>{let e;return(t,r)=>{e&&clearTimeout(e),e=setTimeout(t,r)}},L="abcdefghijklmnopqrstuvwxyz",R=L.toUpperCase(),k=e=>{const t="any"===(e={length:5,lettercase:"any",...e}).lettercase?L+R:"lower"===e.lettercase?L:R;return u({length:e.length},(e,r)=>t[Math.round(Math.random()*t.length)]).join("")},q=async e=>new C(t=>setTimeout(t,e)),z=e=>T(e,Array)?e:[e],D=async t=>{try{const r=t();return T(r,Promise)?await r.then(t=>[t,e]):[r,e]}catch(r){return[e,T(r,Error)?r:new Error(A(r))]}},I=(e,t,r)=>`${$(e,0,t)}${$(e,t,r).toUpperCase()}${r?$(e,r):""}`,W=URL,B=(e,t=globalThis.origin??"http://localhost")=>T(e,W)?e:new URL(e,t),F=(t,r,n)=>{const o=n?new Set(n):e;for(let[e,i]of s(t)){if(o&&!o.has(e))continue;const t=r[e];if(t!==i){if(O(t)||O(i))return!1;if(Number.isNaN(t)&&Number.isNaN(i))continue;if(b(t)&&b(i)){if(S(i)&&S(t)&&i.length!==t.length)return!1;if(F(i,t))continue;return!1}return!1}}return!0};class G{static map=/* @__PURE__ */new Map;static generate(e,t){const r=G.map.get(e)??/* @__PURE__ */new Set,n=k(t);return r.has(n)?G.generate(e):n}static persistInProto(e,t,r){const n=G.generate(t,r);return e.listen("dispose",()=>G.map.get(t)?.delete(n)),n}}export{G as UID,u as _Array_from,E as _JSON_parse,A as _JSON_stringify,o as _Object_assign,a as _Object_defineProperty,s as _Object_entries,n as _Object_fromEntries,c as _Object_getOwnPropertyDescriptors,i as _Object_values,C as _Promise,x as _bind,T as _instanceof,e as _null,h as _typeof,t as _undefined,J as debounce,g as filterValue,f as forEach,U as is,S as isArray,j as isAsyncFunction,d as isBoolean,F as isEqual,N as isFunction,m as isIncluded,O as isNull,w as isNumber,b as isObject,y as isString,P as isSymbol,v as isUndefined,p as map,k as randomId,q as sleep,$ as slice,M as startsWith,z as toArray,B as toURL,D as trycatch,I as uppercase};
|
package/build/widget.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Proto as t,symbol_ProtoType as
|
|
1
|
+
import{Proto as t,symbol_ProtoType as e}from"@amateras/core";import{_Object_assign as r,isFunction as s}from"@amateras/utils";const a=r=>class extends t{static[e]="Widget";static name="Widget";constructor(t,e){super(()=>r(t,t=>e?.(t)))}};r($,{widget:t=>a(t)}),$.process.craft.add((t,...r)=>{if("Widget"===t[e]){let[e]=r;return r=s(e)?[{},e]:r,new t(...r)}});export{a as WidgetConstructor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amateras",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Amateras is a JavaScript library for building user interface.",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"unpkg": "./build/import-map.js",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "bun ./scripts/build.ts",
|
|
20
|
-
"size": "bun ./scripts/vite-bundler-size.ts"
|
|
20
|
+
"size": "bun ./scripts/vite-bundler-size.ts",
|
|
21
|
+
"publish": "bun ./scripts/publish.ts"
|
|
21
22
|
},
|
|
22
23
|
"exports": {
|
|
23
24
|
".": {
|