@symbo.ls/element 3.14.18 → 3.14.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/src/create.js +3 -3
- package/dist/esm/src/create.js +3 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @symbo.ls/element
|
|
2
2
|
|
|
3
|
+
## 3.14.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Auto-generated cross-repo patch release.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- attrs-in-props@3.14.9
|
|
10
|
+
- css-in-props@3.14.9
|
|
11
|
+
- @symbo.ls/utils@3.14.19
|
|
12
|
+
|
|
13
|
+
## 3.14.19
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Auto-generated cross-repo patch release.
|
|
18
|
+
|
|
3
19
|
## 3.14.18
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var H=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ut=(t,c)=>{for(var n in c)H(t,n,{get:c[n],enumerable:!0})},pt=(t,c,n,i)=>{if(c&&typeof c=="object"||typeof c=="function")for(let s of et(c))!dt.call(t,s)&&s!==n&&H(t,s,{get:()=>c[s],enumerable:!(i=at(c,s))||i.enumerable});return t};var yt=t=>pt(H({},"__esModule",{value:!0}),t);var kt={};ut(kt,{create:()=>N,default:()=>Ct});module.exports=yt(kt);var O=require("@symbo.ls/signal"),v=require("@symbo.ls/signal"),R=require("./cache.js"),S=require("./registry.js"),nt=require("./delegate.js"),it=require("./extends.js"),rt=require("./methods.js"),wt=require("./dispose.js"),V=require("@symbo.ls/utils"),J=require("@symbo.ls/utils/function.js"),I=require("@symbo.ls/state"),g=require("css-in-props"),ft=require("@symbo.ls/css"),A=require("@symbo.ls/scratch"),K=require("attrs-in-props");let lt=1;function F(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function ht(t){return t.charAt(2).toLowerCase()+t.slice(3)}function xt(t){return t.toLowerCase()}function Z(t,c){const n={...t};for(const i in c){const s=n[i],o=c[i];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[i]=Z(s,o):n[i]=o}return n}function N(t,c,n,i={},s){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=n||t.key||`_${lt++}`,o.parent=c||null,o.context=t.context||c?.context||i.context||{},o.context.__create||(o.context.__create=N);const r=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:c?.__ref?.root||o,path:c?.__ref?.path?[...c.__ref.path,o.key]:[o.key]};if(n&&!t.extends&&!t.extend){const y=n.indexOf("_");if(y>0){const u=n.substring(0,y),b=o.context?.components;b&&(b[u]||b["smbls."+u])&&(t={extends:u,...t})}}(0,it.applyExtends)(o,t,i);const f=new Set(["childProps","attr","style","scope","data"]),a=o.props&&typeof o.props=="object"?o.props:null;for(const y in t){if(y==="parent"||y==="node"||y==="__ref"||y==="extends"||y==="context"||y==="props")continue;const u=t[y],b=o[y],_=b&&u&&typeof b=="object"&&typeof u=="object"&&!Array.isArray(b)&&!Array.isArray(u)&&typeof b!="function"&&typeof u!="function";_&&y.charCodeAt(0)>=65&&y.charCodeAt(0)<=90?o[y]=Z(b,u):_&&f.has(y)?o[y]={...b,...u}:o[y]=u}function e(y){for(const u in y){const b=y[u],_=o[u],M=_&&b&&typeof _=="object"&&typeof b=="object"&&!Array.isArray(_)&&!Array.isArray(b)&&typeof _!="function"&&typeof b!="function";M&&u.charCodeAt(0)>=65&&u.charCodeAt(0)<=90?o[u]=Z(_,b):M&&f.has(u)?o[u]={..._,...b}:o[u]=b}}a&&e(a),t.props&&typeof t.props=="object"&&e(t.props),t.data!==void 0&&(o.data=t.data),t.classlist!==void 0&&(o.classlist=t.classlist),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html);const d=o.scope&&typeof o.scope=="object"?o.scope:null,h=c?.scope,x=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,p=h||x||null;if(t.scope!==void 0||d){const y={};d&&Object.assign(y,d),t.scope!==void 0&&Object.assign(y,t.scope),o.scope=(0,O.createScopeStore)(y,p)}else p&&(o.scope=p);if(t.if!==void 0&&(o.if=t.if),(0,rt.addMethods)(o),bt(o,c,t),o.if!=null){const y=typeof o.if=="function"?o.if(o,o.state,o.context):o.if;r.__if=!!y}if(r.__if)typeof t.if=="function"&&(r.__ifInitialized=!0);else return c&&(c[o.key]=o),typeof t.if=="function"&&
|
|
1
|
+
"use strict";var H=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ut=(t,c)=>{for(var n in c)H(t,n,{get:c[n],enumerable:!0})},pt=(t,c,n,i)=>{if(c&&typeof c=="object"||typeof c=="function")for(let s of et(c))!dt.call(t,s)&&s!==n&&H(t,s,{get:()=>c[s],enumerable:!(i=at(c,s))||i.enumerable});return t};var yt=t=>pt(H({},"__esModule",{value:!0}),t);var kt={};ut(kt,{create:()=>N,default:()=>Ct});module.exports=yt(kt);var O=require("@symbo.ls/signal"),v=require("@symbo.ls/signal"),R=require("./cache.js"),S=require("./registry.js"),nt=require("./delegate.js"),it=require("./extends.js"),rt=require("./methods.js"),wt=require("./dispose.js"),V=require("@symbo.ls/utils"),J=require("@symbo.ls/utils/function.js"),I=require("@symbo.ls/state"),g=require("css-in-props"),ft=require("@symbo.ls/css"),A=require("@symbo.ls/scratch"),K=require("attrs-in-props");let lt=1;function F(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function ht(t){return t.charAt(2).toLowerCase()+t.slice(3)}function xt(t){return t.toLowerCase()}function Z(t,c){const n={...t};for(const i in c){const s=n[i],o=c[i];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[i]=Z(s,o):n[i]=o}return n}function N(t,c,n,i={},s){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=n||t.key||`_${lt++}`,o.parent=c||null,o.context=t.context||c?.context||i.context||{},o.context.__create||(o.context.__create=N);const r=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:c?.__ref?.root||o,path:c?.__ref?.path?[...c.__ref.path,o.key]:[o.key]};if(n&&!t.extends&&!t.extend){const y=n.indexOf("_");if(y>0){const u=n.substring(0,y),b=o.context?.components;b&&(b[u]||b["smbls."+u])&&(t={extends:u,...t})}}(0,it.applyExtends)(o,t,i);const f=new Set(["childProps","attr","style","scope","data"]),a=o.props&&typeof o.props=="object"?o.props:null;for(const y in t){if(y==="parent"||y==="node"||y==="__ref"||y==="extends"||y==="context"||y==="props")continue;const u=t[y],b=o[y],_=b&&u&&typeof b=="object"&&typeof u=="object"&&!Array.isArray(b)&&!Array.isArray(u)&&typeof b!="function"&&typeof u!="function";_&&y.charCodeAt(0)>=65&&y.charCodeAt(0)<=90?o[y]=Z(b,u):_&&f.has(y)?o[y]={...b,...u}:o[y]=u}function e(y){for(const u in y){const b=y[u],_=o[u],M=_&&b&&typeof _=="object"&&typeof b=="object"&&!Array.isArray(_)&&!Array.isArray(b)&&typeof _!="function"&&typeof b!="function";M&&u.charCodeAt(0)>=65&&u.charCodeAt(0)<=90?o[u]=Z(_,b):M&&f.has(u)?o[u]={..._,...b}:o[u]=b}}a&&e(a),t.props&&typeof t.props=="object"&&e(t.props),t.data!==void 0&&(o.data=t.data),t.classlist!==void 0&&(o.classlist=t.classlist),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html);const d=o.scope&&typeof o.scope=="object"?o.scope:null,h=c?.scope,x=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,p=h||x||null;if(t.scope!==void 0||d){const y={};d&&Object.assign(y,d),t.scope!==void 0&&Object.assign(y,t.scope),o.scope=(0,O.createScopeStore)(y,p)}else p&&(o.scope=p);if(t.if!==void 0&&(o.if=t.if),(0,rt.addMethods)(o),bt(o,c,t),o.if!=null){const y=typeof o.if=="function"?o.if(o,o.state,o.context):o.if;r.__if=!!y}if(r.__if)typeof t.if=="function"&&(r.__ifInitialized=!0);else return c&&(c[o.key]=o),typeof t.if=="function"&&z(o,{if:t.if}),o;o.tag||(o.tag=(0,R.detectTag)(o)),$("Init",o,i);const l=o.node=(0,R.cacheNode)(o);if(!l)return o;$("AttachNode",o,i),l.setAttribute&&o.key&&l.setAttribute("data-key",o.key),l.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&l.setAttribute("data-smbls-app",o.context.key),o.id&&l.setAttribute&&(l.id=o.id),z(o,t),Y(o),ot(o),st(o,i);try{ct(o,i)}catch(y){if(typeof console<"u"&&console.error){const u=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${u}:`,y?.message||y,y?.stack?`
|
|
2
2
|
`+y.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(U(o,c,s),c&&(c[o.key]=o,c.__ref?.__children&&(c.__ref.__children.includes(o.key)||c.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const y=o.context?.designSystem;y&&(0,A.pushConfig)(y);try{const u=o.html(o,o.state,o.context);u!=null&&typeof u!="function"&&(o.node.innerHTML=u)}catch{}finally{y&&(0,A.popConfig)()}}if($("Create",o,i),$("Complete",o,i),$("Render",o,i),$("RenderRouter",o,i),typeof o.onFrame=="function"){const y=o.onFrame,u=o.context?.designSystem,b=()=>{if(o.node){if(o.node.isConnected){u&&(0,A.pushConfig)(u);try{y(o,o.state,o.context)}catch(_){console.error("[DOMQL] onFrame error:",_)}finally{u&&(0,A.popConfig)()}}requestAnimationFrame(b)}};requestAnimationFrame(b)}return o}function bt(t,c,n){const i=!c,s=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=i&&s&&t.context?.state,r=n.state!==void 0&&!o?n.state:t.state&&!(0,O.isStore)(t.state)?t.state:void 0;if(r==null){if(c?.state)t.state=c.state,(0,I.applyStateMethods)(t,t.state);else if(t.context?.state){const f=t.context.state,a={...f},e=t.context?.polyglot;if(e?.translations){const d=f.lang||e.defaultLang||"en",h=e.translations[d];if(h&&typeof h=="object")for(const p in h)a[p]===void 0&&(a[p]=h[p]);const x=new Set(e.languages||[]);for(const p in e.translations)!x.has(p)&&a[p]===void 0&&(a[p]=e.translations[p])}t.state=(0,O.isStore)(a)?a:(0,O.createStore)(a),t.state.__element=t,t.state.root=t.state,(0,I.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,I.applyStateMethods)(t,t.state);return}if(typeof r=="string"){if(t.state=tt(r,c),t.state&&typeof t.state=="object"&&!(0,O.isStore)(t.state)){const f=c?.state?.root||c?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}(0,I.applyStateMethods)(t,t.state);return}if(typeof r=="function"){const f=r(t,c?.state);t.state=(0,O.createStore)(f||{})}else t.state=(0,O.createStore)({...r});t.state.__element=t,c?.state?(t.state.parent=c.state,t.state.root=c.state.root||c.state):t.state.root=t.state,(0,I.applyStateMethods)(t,t.state)}function z(t,c){if(!c)return t;const n=c.split("/");let i=t;for(const s of n){if(i==null)return{};i=i[s]}return i??{}}function tt(t,c){if(!c)return{};if(t===".")return c.state||{};if(t.startsWith("../")){const s=t.slice(3);return s?z(c.state,s):c.state??{}}if(t.startsWith("~/")){const s=c.state?.root||c.state,o=t.slice(2);return o?z(s,o):s??{}}if(c.state?.[t]!==void 0)return c.state[t];const n=z(c.state,t);if(n!=null&&Object.keys(n).length>0)return n;const i=c.context?.polyglot;if(i?.translations){const s=c.state?.root?.lang||i.defaultLang||"en",o=i.translations[s];if(o?.[t]!==void 0)return o[t];if(i.translations[t]!==void 0)return i.translations[t]}return{}}function gt(t){const c=t.__ref,n=t.tag||"div",i=t.context?.designSystem,s=[],o=Object.keys(t);for(let r=0;r<o.length;r++){const f=o[r];if(typeof t[f]!="function"||S.REGISTRY.has(f))continue;const a=f.charCodeAt(0);a>=65&&a<=90||F(f)||g.CSS_PROPS_REGISTRY[f]||g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(f)||(0,K.checkAttributeByTagName)(n,f)||s.push({prop:f,fn:t[f]})}for(let r=0;r<s.length;r++){const{prop:f,fn:a}=s[r];c.__exec[f]=a,Object.defineProperty(t,f,{get(){i&&(0,A.pushConfig)(i);try{return a(t,t.state,t.context)}catch{return}finally{i&&(0,A.popConfig)()}},set(e){delete c.__exec[f],Object.defineProperty(t,f,{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function B(t,c){const n=t.__ref;if(gt(t),typeof t.text=="function"){const s=t.text,o=(0,v.createEffect)(()=>{if(!n.contentManaged)try{let r=s(t,t.state,t.context);t.node&&r!=null&&typeof r!="function"&&typeof r!="object"&&(typeof r=="string"&&r.includes("{{")&&(r=V.replaceLiteralsWithObjectFields.call(t,r,t.state)),t.tag==="string"?t.node.nodeValue=r:t.node.textContent=r)}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}else if(typeof t.text=="string"&&t.text.includes("{{")){const s=t.text,o=(0,v.createEffect)(()=>{if(n.contentManaged)return;const r=V.replaceLiteralsWithObjectFields.call(t,s,t.state);r!=null&&(t.text=r),t.node&&(t.tag==="string"?t.node.nodeValue=r??"":t.node.textContent=r??"")},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&typeof t[s]=="function"&&!S.REGISTRY.has(s)&&!F(s)&&!n.__exec[s]){if(g.CSS_PROPS_REGISTRY[s]){const o=t[s],r=s,f=(0,v.createEffect)(()=>{const a=t.context?.designSystem;a&&(0,A.pushConfig)(a);try{const e=o(t,t.state,t.context),d=g.CSS_PROPS_REGISTRY[r](e,t,t.state,t.context);d&&t.node?D(t.node,d):t.node&&(r==="show"||r==="hide")&&(t.node.style.display="")}finally{a&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}else if(g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(s)){const o=t[s],r=s,f=(0,v.createEffect)(()=>{const a=t.context?.designSystem;a&&(0,A.pushConfig)(a);try{const e=o(t,t.state,t.context);t.node&&(e!=null?D(t.node,{[r]:e}):t.node.style[r]="")}finally{a&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}}if(typeof c.html=="function"){const s=c.html,o=(0,v.createEffect)(()=>{const r=t.context?.designSystem;r&&(0,A.pushConfig)(r);try{const f=s(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{r&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(o),n.__exec.html=s}if(typeof c.value=="function"){const s=c.value,o=(0,v.createEffect)(()=>{try{const r=s(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=r==null?"":String(r);if(t.node.value===f)return;const a=typeof document<"u"&&document.activeElement===t.node,e=a&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,d=a&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,a&&e!=null&&d!=null)try{t.node.setSelectionRange(e,d)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.value=s}if(typeof c.style=="function"){const s=c.style,o=(0,v.createEffect)(()=>{const r=s(t,t.state,t.context);D(t.node,r)},{depth:n.path.length});n.__effects.push(o),n.__exec.style=s}else if(t.style&&typeof t.style=="object")for(const s in t.style){const o=t.style[s];if(typeof o!="function")continue;const r=(0,v.createEffect)(()=>{try{const f=o(t,t.state,t.context);t.node&&D(t.node,{[s]:f})}catch{}},{depth:n.path.length});n.__effects.push(r)}if(t.attr&&typeof t.attr=="object"){for(const s in t.attr)if(typeof t.attr[s]=="function"){const o=t.attr[s],r=s,f=(0,v.createEffect)(()=>{try{const a=o(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(r):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(r,a===!0?"":a))}catch{}},{depth:n.path.length});n.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o!="function")continue;const r="aria-"+s.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),f=(0,v.createEffect)(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(r):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(r,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const s in t.data){const o=t.data[s];if(typeof o!="function")continue;const f="data-"+s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),a=(0,v.createEffect)(()=>{try{const e=o(t,t.state,t.context);if(!t.node?.setAttribute)return;e==null||e===!1?t.node.removeAttribute(f):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(f,e===!0?"":e)}catch{}},{depth:n.path.length});n.__effects.push(a)}const i=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(i)for(const s in i){const o=i[s];if(typeof o!="function")continue;const r=(0,v.createEffect)(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(s):t.node.classList.remove(s)}catch{}},{depth:n.path.length});n.__effects.push(r)}if(typeof c.if=="function"){const s=c.if,o=(0,v.createEffect)(()=>{const r=s(t,t.state,t.context),f=n.__if;if(n.__if=!!r,f&&!n.__if&&t.node)t.node.remove();else if(!f&&n.__if)if(n.__ifInitialized){t.node||(t.node=(0,R.cacheNode)(t));const a=t.parent,e=a?.node;if(e&&t.node){let d=null;const h=Object.keys(a),x=h.indexOf(t.key);for(let p=x+1;p<h.length;p++){const l=a[h[p]];if(l?.node?.parentNode===e){d=l.node;break}}d?e.insertBefore(t.node,d):e.appendChild(t.node)}else U(t,t.parent);Y(t)}else{if(n.__ifInitialized=!0,t.tag||(t.tag=(0,R.detectTag)(t)),$("Init",t,{}),t.node||(t.node=(0,R.cacheNode)(t)),!t.node)return;$("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id);const a=c.if;delete c.if;try{B(t,c)}finally{c.if=a}Y(t),ot(t),st(t,{}),ct(t,{}),U(t,t.parent)}},{depth:n.path.length});n.__effects.push(o)}for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||S.REGISTRY.has(s)||typeof t[s]!="function")continue;const o=s.charCodeAt(0);if(o>=65&&o<=90||F(s))continue;const r=t[s];n.__exec[s]=r;const f=t.tag||"div";if((0,K.checkAttributeByTagName)(f,s)&&!g.CSS_PROPS_REGISTRY[s]&&!(g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(s))){const a=s,e=(0,v.createEffect)(()=>{try{const d=r(t,t.state,t.context);t.node?.setAttribute&&(d==null||d===!1?t.node.removeAttribute(a):typeof d!="function"&&typeof d!="object"&&(a==="src"&&"src"in t.node?t.node.src=d:t.node.setAttribute(a,d===!0?"":d)))}catch{}},{depth:n.path.length});n.__effects.push(e)}}jt(t)}function Y(t){const{node:c}=t;if(c){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?c.nodeValue=t.text:c.textContent=t.text:typeof t.text=="number"&&(c.textContent=t.text),vt(t),typeof t.html=="string"&&(c.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in c){const n=String(t.value);c.value!==n&&(c.value=n)}if(t.style&&typeof t.style=="object"&&D(c,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const i=t.attr[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.setAttribute&&c.setAttribute(n,i===!0?"":i)}if(t.data&&typeof t.data=="object")for(const n in t.data){const i=t.data[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.dataset&&(c.dataset[n]=i===!0?"":i)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(i=>i&&c.classList.add(i));else if(typeof n=="object")for(const i in n){const s=typeof n[i]=="function"?n[i](t,t.state,t.context):n[i];s&&c.classList.add(typeof s=="string"?s:i)}}}}function D(t,c){if(!t||!c||!t.style)return;let n=null;for(const i in c){const s=c[i];if(s!=null){if(i.charAt(0)==="&"&&typeof s=="object"){n||(n={}),n[i]=s;continue}try{const o=String(s),r=i.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),f=o.trim(),a=/\s*!important\s*$/.test(f),e=f.replace(/\s*!important\s*$/,"");t.style.setProperty(r,e,a?"important":"")}catch{}}}n&&At(t,n)}let _t=0;function At(t,c){const n=`_ds${_t++}`;t.classList.add(n);const i=t.ownerDocument;let s=i.querySelector("style[data-smbls-scoped]");s||(s=i.createElement("style"),s.setAttribute("data-smbls-scoped",""),i.head.appendChild(s));let o="";for(const r in c){const f="."+n,a=r.replace(/&/g,f).split(",").map(d=>{const h=d.trim();return h.includes(f)?h:f+h}).join(", "),e=c[r];if(typeof e=="object"){let d="",h="";for(const x in e){const p=e[x];if(typeof p=="object"){const l=x.includes("&")?a.split(", ").map(u=>x.replace(/&/g,u)).join(", "):a.split(", ").map(u=>`${u} ${x}`).join(", ");let y="";for(const u in p)y+=`${u.replace(/[A-Z]/g,b=>"-"+b.toLowerCase())}: ${p[u]};`;h+=`${l} { ${y} }
|
|
4
|
+
`):"")}}if(U(o,c,s),c&&(c[o.key]=o,c.__ref?.__children&&(c.__ref.__children.includes(o.key)||c.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const y=o.context?.designSystem;y&&(0,A.pushConfig)(y);try{const u=o.html(o,o.state,o.context);u!=null&&typeof u!="function"&&(o.node.innerHTML=u)}catch{}finally{y&&(0,A.popConfig)()}}if($("Create",o,i),$("Complete",o,i),$("Render",o,i),$("RenderRouter",o,i),typeof o.onFrame=="function"){const y=o.onFrame,u=o.context?.designSystem,b=()=>{if(o.node){if(o.node.isConnected){u&&(0,A.pushConfig)(u);try{y(o,o.state,o.context)}catch(_){console.error("[DOMQL] onFrame error:",_)}finally{u&&(0,A.popConfig)()}}requestAnimationFrame(b)}};requestAnimationFrame(b)}return o}function bt(t,c,n){const i=!c,s=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=i&&s&&t.context?.state,r=n.state!==void 0&&!o?n.state:t.state&&!(0,O.isStore)(t.state)?t.state:void 0;if(r==null){if(c?.state)t.state=c.state,(0,I.applyStateMethods)(t,t.state);else if(t.context?.state){const f=t.context.state,a={...f},e=t.context?.polyglot;if(e?.translations){const d=f.lang||e.defaultLang||"en",h=e.translations[d];if(h&&typeof h=="object")for(const p in h)a[p]===void 0&&(a[p]=h[p]);const x=new Set(e.languages||[]);for(const p in e.translations)!x.has(p)&&a[p]===void 0&&(a[p]=e.translations[p])}t.state=(0,O.isStore)(a)?a:(0,O.createStore)(a),t.state.__element=t,t.state.root=t.state,(0,I.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,I.applyStateMethods)(t,t.state);return}if(typeof r=="string"){if(t.state=tt(r,c),t.state&&typeof t.state=="object"&&!(0,O.isStore)(t.state)){const f=c?.state?.root||c?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}(0,I.applyStateMethods)(t,t.state);return}if(typeof r=="function"){const f=r(t,c?.state);t.state=(0,O.createStore)(f||{})}else t.state=(0,O.createStore)({...r});t.state.__element=t,c?.state?(t.state.parent=c.state,t.state.root=c.state.root||c.state):t.state.root=t.state,(0,I.applyStateMethods)(t,t.state)}function B(t,c){if(!c)return t;const n=c.split("/");let i=t;for(const s of n){if(i==null)return{};i=i[s]}return i??{}}function tt(t,c){if(!c)return{};if(t===".")return c.state||{};if(t.startsWith("../")){const s=t.slice(3);return s?B(c.state,s):c.state??{}}if(t.startsWith("~/")){const s=c.state?.root||c.state,o=t.slice(2);return o?B(s,o):s??{}}if(c.state?.[t]!==void 0)return c.state[t];const n=B(c.state,t);if(n!=null&&Object.keys(n).length>0)return n;const i=c.context?.polyglot;if(i?.translations){const s=c.state?.root?.lang||i.defaultLang||"en",o=i.translations[s];if(o?.[t]!==void 0)return o[t];if(i.translations[t]!==void 0)return i.translations[t]}return{}}function gt(t){const c=t.__ref,n=t.tag||"div",i=t.context?.designSystem,s=[],o=Object.keys(t);for(let r=0;r<o.length;r++){const f=o[r];if(typeof t[f]!="function"||S.REGISTRY.has(f))continue;const a=f.charCodeAt(0);a>=65&&a<=90||F(f)||g.CSS_PROPS_REGISTRY[f]||g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(f)||(0,K.checkAttributeByTagName)(n,f)||s.push({prop:f,fn:t[f]})}for(let r=0;r<s.length;r++){const{prop:f,fn:a}=s[r];c.__exec[f]=a,Object.defineProperty(t,f,{get(){i&&(0,A.pushConfig)(i);try{return a(t,t.state,t.context)}catch{return}finally{i&&(0,A.popConfig)()}},set(e){delete c.__exec[f],Object.defineProperty(t,f,{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function z(t,c){const n=t.__ref;if(gt(t),typeof t.text=="function"){const s=t.text,o=(0,v.createEffect)(()=>{if(!n.contentManaged)try{let r=s(t,t.state,t.context);t.node&&r!=null&&typeof r!="function"&&typeof r!="object"&&(typeof r=="string"&&r.includes("{{")&&(r=V.replaceLiteralsWithObjectFields.call(t,r,t.state)),t.tag==="string"?t.node.nodeValue=r:t.node.textContent=r)}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}else if(typeof t.text=="string"&&t.text.includes("{{")){const s=t.text,o=(0,v.createEffect)(()=>{if(n.contentManaged)return;const r=V.replaceLiteralsWithObjectFields.call(t,s,t.state);r!=null&&(t.text=r),t.node&&(t.tag==="string"?t.node.nodeValue=r??"":t.node.textContent=r??"")},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&typeof t[s]=="function"&&!S.REGISTRY.has(s)&&!F(s)&&!n.__exec[s]){if(g.CSS_PROPS_REGISTRY[s]){const o=t[s],r=s,f=(0,v.createEffect)(()=>{const a=t.context?.designSystem;a&&(0,A.pushConfig)(a);try{const e=o(t,t.state,t.context),d=g.CSS_PROPS_REGISTRY[r](e,t,t.state,t.context);d&&t.node?D(t.node,d):t.node&&(r==="show"||r==="hide")&&(t.node.style.display="")}finally{a&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}else if(g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(s)){const o=t[s],r=s,f=(0,v.createEffect)(()=>{const a=t.context?.designSystem;a&&(0,A.pushConfig)(a);try{const e=o(t,t.state,t.context);t.node&&(e!=null?D(t.node,{[r]:e}):t.node.style[r]="")}finally{a&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}}if(typeof c.html=="function"){const s=c.html,o=(0,v.createEffect)(()=>{const r=t.context?.designSystem;r&&(0,A.pushConfig)(r);try{const f=s(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{r&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(o),n.__exec.html=s}if(typeof c.value=="function"){const s=c.value,o=(0,v.createEffect)(()=>{try{const r=s(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=r==null?"":String(r);if(t.node.value===f)return;const a=typeof document<"u"&&document.activeElement===t.node,e=a&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,d=a&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,a&&e!=null&&d!=null)try{t.node.setSelectionRange(e,d)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.value=s}if(typeof c.style=="function"){const s=c.style,o=(0,v.createEffect)(()=>{const r=s(t,t.state,t.context);D(t.node,r)},{depth:n.path.length});n.__effects.push(o),n.__exec.style=s}else if(t.style&&typeof t.style=="object")for(const s in t.style){const o=t.style[s];if(typeof o!="function")continue;const r=(0,v.createEffect)(()=>{try{const f=o(t,t.state,t.context);t.node&&D(t.node,{[s]:f})}catch{}},{depth:n.path.length});n.__effects.push(r)}if(t.attr&&typeof t.attr=="object"){for(const s in t.attr)if(typeof t.attr[s]=="function"){const o=t.attr[s],r=s,f=(0,v.createEffect)(()=>{try{const a=o(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(r):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(r,a===!0?"":a))}catch{}},{depth:n.path.length});n.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o!="function")continue;const r="aria-"+s.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),f=(0,v.createEffect)(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(r):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(r,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const s in t.data){const o=t.data[s];if(typeof o!="function")continue;const f="data-"+s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),a=(0,v.createEffect)(()=>{try{const e=o(t,t.state,t.context);if(!t.node?.setAttribute)return;e==null||e===!1?t.node.removeAttribute(f):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(f,e===!0?"":e)}catch{}},{depth:n.path.length});n.__effects.push(a)}const i=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(i)for(const s in i){const o=i[s];if(typeof o!="function")continue;const r=(0,v.createEffect)(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(s):t.node.classList.remove(s)}catch{}},{depth:n.path.length});n.__effects.push(r)}if(typeof c.if=="function"){const s=c.if,o=(0,v.createEffect)(()=>{const r=s(t,t.state,t.context),f=n.__if;if(n.__if=!!r,f&&!n.__if&&t.node)t.node.remove();else if(!f&&n.__if)if(n.__ifInitialized){t.node||(t.node=(0,R.cacheNode)(t));const a=t.parent,e=a?.node;if(e&&t.node){let d=null;const h=Object.keys(a),x=h.indexOf(t.key);for(let p=x+1;p<h.length;p++){const l=a[h[p]];if(l?.node?.parentNode===e){d=l.node;break}}d?e.insertBefore(t.node,d):e.appendChild(t.node)}else U(t,t.parent);Y(t)}else{if(n.__ifInitialized=!0,t.tag||(t.tag=(0,R.detectTag)(t)),$("Init",t,{}),t.node||(t.node=(0,R.cacheNode)(t)),!t.node)return;$("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id);const a=c.if;delete c.if;try{z(t,c)}finally{c.if=a}Y(t),ot(t),st(t,{}),ct(t,{}),U(t,t.parent)}},{depth:n.path.length});n.__effects.push(o)}for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||S.REGISTRY.has(s)||typeof t[s]!="function")continue;const o=s.charCodeAt(0);if(o>=65&&o<=90||F(s))continue;const r=t[s];n.__exec[s]=r;const f=t.tag||"div";if((0,K.checkAttributeByTagName)(f,s)&&!g.CSS_PROPS_REGISTRY[s]&&!(g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(s))){const a=s,e=(0,v.createEffect)(()=>{try{const d=r(t,t.state,t.context);t.node?.setAttribute&&(d==null||d===!1?t.node.removeAttribute(a):typeof d!="function"&&typeof d!="object"&&(a==="src"&&"src"in t.node?t.node.src=d:t.node.setAttribute(a,d===!0?"":d)))}catch{}},{depth:n.path.length});n.__effects.push(e)}}jt(t)}function Y(t){const{node:c}=t;if(c){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?c.nodeValue=t.text:c.textContent=t.text:typeof t.text=="number"&&(c.textContent=t.text),vt(t),typeof t.html=="string"&&(c.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in c){const n=String(t.value);c.value!==n&&(c.value=n)}if(t.style&&typeof t.style=="object"&&D(c,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const i=t.attr[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.setAttribute&&c.setAttribute(n,i===!0?"":i)}if(t.data&&typeof t.data=="object")for(const n in t.data){const i=t.data[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.dataset&&(c.dataset[n]=i===!0?"":i)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(i=>i&&c.classList.add(i));else if(typeof n=="object")for(const i in n){const s=typeof n[i]=="function"?n[i](t,t.state,t.context):n[i];s&&c.classList.add(typeof s=="string"?s:i)}}}}function D(t,c){if(!t||!c||!t.style)return;let n=null;for(const i in c){const s=c[i];if(s!=null){if(i.charAt(0)==="&"&&typeof s=="object"){n||(n={}),n[i]=s;continue}try{const o=String(s),r=i.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),f=o.trim(),a=/\s*!important\s*$/.test(f),e=f.replace(/\s*!important\s*$/,"");t.style.setProperty(r,e,a?"important":"")}catch{}}}n&&At(t,n)}let _t=0;function At(t,c){const n=`_ds${_t++}`;t.classList.add(n);const i=t.ownerDocument;let s=i.querySelector("style[data-smbls-scoped]");s||(s=i.createElement("style"),s.setAttribute("data-smbls-scoped",""),i.head.appendChild(s));let o="";for(const r in c){const f="."+n,a=r.replace(/&/g,f).split(",").map(d=>{const h=d.trim();return h.includes(f)?h:f+h}).join(", "),e=c[r];if(typeof e=="object"){let d="",h="";for(const x in e){const p=e[x];if(typeof p=="object"){const l=x.includes("&")?a.split(", ").map(u=>x.replace(/&/g,u)).join(", "):a.split(", ").map(u=>`${u} ${x}`).join(", ");let y="";for(const u in p)y+=`${u.replace(/[A-Z]/g,b=>"-"+b.toLowerCase())}: ${p[u]};`;h+=`${l} { ${y} }
|
|
5
5
|
`}else d+=`${x.replace(/[A-Z]/g,l=>"-"+l.toLowerCase())}: ${p};`}d&&(o+=`${a} { ${d} }
|
|
6
|
-
`),h&&(o+=h)}}o&&(s.textContent+=o)}function jt(t){const c=t.__ref;c.__conditionalRunners=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const i=n.charAt(0);if(i!=="."&&i!=="!")continue;const s=n.slice(1);if(!s)continue;const o=t[n];if(!o||typeof o!="object")continue;const r=i==="!",f={lastMatch:!1,appliedKeys:null},a=()=>{if(!t.node)return;let d;const h=t[s];if(h===void 0)if(t.state&&s in t.state)d=t.state[s];else{const l=t.context?.cases?.[s];if(l===void 0)return;d=typeof l=="function"?l.call(t,t):l}else typeof h=="function"?d=h(t,t.state,t.context):d=h;const x=r?!d:!!d;if(x===f.lastMatch)return;f.lastMatch=x;const p=t.context?.designSystem;p&&(0,A.pushConfig)(p);try{if(x){const l={};for(const u in o){if(!Object.prototype.hasOwnProperty.call(o,u))continue;const b=typeof o[u]=="function"?o[u](t,t.state,t.context):o[u];if(b!=null)if(g.CSS_PROPS_REGISTRY[u]){const _=g.CSS_PROPS_REGISTRY[u](b,t,t.state,t.context);if(_){const M=Array.isArray(_)?_:[_];for(const L of M)L&&Object.assign(l,L)}}else g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(u)&&(l[u]=b)}const y=Object.keys(l);y.length?(D(t.node,l),f.appliedKeys=y):f.appliedKeys=null}else if(f.appliedKeys){for(const l of f.appliedKeys)t.node.style[l]="";f.appliedKeys=null}}finally{p&&(0,A.popConfig)()}};c.__conditionalRunners.push(a);const e=(0,v.createEffect)(a,{depth:c.path.length});c.__effects.push(e)}}const q=new WeakSet;function vt(t){const{node:c}=t;if(!c)return;if(q.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}q.add(t);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{const i={};let s=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||S.REGISTRY.has(o))continue;const r=o.charCodeAt(0);if(!(r>=65&&r<=90)&&!F(o)){if(g.CSS_PROPS_REGISTRY[o]){const f=t[o],a=g.CSS_PROPS_REGISTRY[o](f,t,t.state,t.context);if(a){if(Array.isArray(a))for(const e of a)e&&Object.assign(i,e);else Object.assign(i,a);s=!0}}else if(g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const a={};for(const e in f){let d=f[e];if(typeof d=="function"&&(d=d(t,t.state,t.context)),!(d==null||typeof d=="function"))if(g.CSS_PROPS_REGISTRY[e]){const h=g.CSS_PROPS_REGISTRY[e](d,t,t.state,t.context);if(h)if(Array.isArray(h))for(const x of h)x&&Object.assign(a,x);else Object.assign(a,h)}else a[e]=d}if(Object.keys(a).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const d={};for(const x in a){const p=a[x];d[x]=typeof p=="string"&&!p.includes("!important")?p+" !important":p}const h=o.slice(1);i[`[data-theme="${h}"] &`]=d}else{let d=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const x=o.slice(1),p=t.context?.designSystem?.media?.[x]||t.context?.designSystem?.media?.[x];p&&(d=`@media ${p}`)}const h={};for(const x in a){const p=a[x];if(p&&typeof p=="object"&&!Array.isArray(p)){const l={};for(const u in p)if(g.CSS_PROPS_REGISTRY[u]){const b=g.CSS_PROPS_REGISTRY[u](p[u],t,t.state,t.context);if(b)if(Array.isArray(b))for(const _ of b)_&&Object.assign(l,_);else Object.assign(l,b)}else l[u]=p[u];const y=x.startsWith(":")?"":" ";if(d.includes(",")){const u=d.split(",").map(b=>`${b.trim()}${y}${x}`).join(", ");i[u]=l}else i[`${d}${y}${x}`]=l}else h[x]=p}Object.keys(h).length&&(i[d]=h)}s=!0}s=!0}}}}if(s){i.display&&String(i.display).includes("!important")&&(c.style.setProperty("display",String(i.display).replace(/\s*!important\s*$/,""),"important"),delete i.display);const o=(0,ft.css)(i,null,t.context?.cssPrefix);o&&c.classList&&o.split(" ").forEach(f=>f&&c.classList.add(f));const r=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(r!=null){const f=i.display;if(f&&f!==r)if(r==="none"){const a=[];for(const e of c.classList)e.startsWith("_d-")&&e!=="_d-none"&&a.push(e);for(const e of a)c.classList.remove(e);c.classList.add("_d-none")}else c.style.display=t.display}}}finally{n&&(0,A.popConfig)(),q.delete(t)}}function ot(t){const{node:c}=t;if(!c||!c.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const r="aria-"+s.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());c.setAttribute(r,o===!0?"":o)}const n=(0,K.applyAttrTransforms)(t);for(const s in n){const o=n[s];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&c.setAttribute(s,o===!0?"":o)}const i=t.tag||"div";for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||typeof t[s]=="function"||S.REGISTRY.has(s)||s==="on"||n[s]!==void 0)continue;const o=s.charCodeAt(0);if(!(o>=65&&o<=90)&&!F(s)&&!(g.CSS_PROPS_REGISTRY[s]||g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(s))&&(0,K.checkAttributeByTagName)(i,s)){let r=t[s];if(r==null||r===!1||(typeof r=="string"&&r.includes("{{")&&(r=(0,V.replaceLiteralsWithObjectFields)(r,t,t.state,t.context),t[s]=r),r==null||r===!1||typeof r=="function"||typeof r=="object"))continue;c.setAttribute(s,r===!0?"":r)}}}function st(t,c){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!F(n))continue;let i=t[n];if(typeof i=="string"&&/^[A-Za-z_$][\w$]*$/.test(i)){const o=i;i=function(f){return t.call(o,f)}}if(typeof i!="function")continue;const s=ht(n);S.LIFECYCLE_EVENTS.has(s)||(0,nt.registerEvent)(xt(s),t,i)}}function G(t,c){const n={...t};for(const i in c){const s=n[i],o=c[i];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[i]=G(s,o):n[i]=o}return n}function Q(t,c,n){if(!c||!t.node)return;const i=t.childExtends;if(Array.isArray(c)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const r=t.childProps,f=t.childrenAs;for(let a=0;a<c.length;a++){let e=c[a];const d=e;(typeof e=="string"||typeof e=="number")&&(e={text:e});let h=r;if(typeof r=="function")try{h=r(t,e)}catch{h=null}if(f==="state"){let l=d;(typeof d=="string"||typeof d=="number")&&(l={value:d,text:d}),e=h?{...h,state:l}:{state:l}}else h&&(e=G(h,e));if(i&&!e.ignoreChildExtends)if(e.extends){const l=Array.isArray(e.extends)?e.extends:[e.extends],y=Array.isArray(i)?i:[i];e={...e,extends:[...y,...l]}}else e={extends:i,...e};const x=e?.key||`${a}`,p=N(e,t,x,n);p?.node&&o.appendChild(p.node)}t.node.appendChild(o);return}if(typeof c=="string"){const s=tt(c,t);if(Array.isArray(s)){Q(t,s,n);return}}if(typeof c=="object")for(const s in c){if(S.REGISTRY.has(s))continue;let o=c[s];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=G(t.childProps,o)),i&&!o.ignoreChildExtends)if(o.extends){const r=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(i)?i:[i];o={...o,extends:[...f,...r]}}else o={extends:i,...o};N(o,t,s,n)}}}function ct(t,c){let{children:n,content:i}=t;const s=t.childExtends;if(typeof n=="function"){const r=n;n=r(t,t.state,t.context),t.children=n;const f=t.__ref;let a=!1;const e=(0,v.createEffect)(()=>{const d=r(t,t.state,t.context);if(!a){a=!0;return}if(d===t.children)return;if(t.children=d,Array.isArray(d)&&t.childrenAs==="state"){const p=t.childProps,l=[],y=new Map;for(let C=0;C<d.length;C++){const P=d[C];let j=p;if(typeof p=="function")try{j=p(t,P)}catch{j=null}const T=j&&j.key||P&&P.key||`${C}`;l.push(T),y.set(T,{rawChild:P,childProps:j})}const u=new Set(l),b=f.__children.slice();for(const C of b)if(!u.has(C)){const P=t[C];P?.remove&&P.remove(),delete t[C]}const _=t.childExtends,L=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const C of l){const P=y.get(C),j=P.rawChild,T=t[C];if(T&&T.state){if(j&&typeof j=="object"){const E=T.state;if(typeof E.replace=="function")E.replace(j);else if(typeof E.update=="function"){for(const k in E)if(!(k==="__element"||k==="root"||k==="parent"||k==="update")&&!Object.prototype.hasOwnProperty.call(j,k))try{E[k]=void 0}catch{}E.update(j)}else for(const k in j)E[k]=j[k]}continue}let W=j;(typeof j=="string"||typeof j=="number")&&(W={value:j,text:j});const X=P.childProps;let w=X?{...X,state:W}:{state:W};if(_&&!w.ignoreChildExtends)if(w.extends){const E=Array.isArray(w.extends)?w.extends:[w.extends],k=Array.isArray(_)?_:[_];w={...w,extends:[...k,...E]}}else w={extends:_,...w};const m=N(w,t,C,c);m?.node&&L&&L.appendChild(m.node)}L&&L.childNodes.length&&t.node&&t.node.appendChild(L),f.__children=l;return}for(const p of[...f.__children]){const l=t[p];l?.remove&&l.remove(),delete t[p]}f.__children=[],Q(t,d,c)},{depth:f.path.length});f.__effects.push(e)}if(Q(t,n||i,c),n||i)return;const o=t.context?.components||{};{const r=Object.keys(t);for(let f=0;f<r.length;f++){const a=r[f];if(!a.endsWith("Extends")||typeof t[a]!="string")continue;const e=a.slice(0,-7);if(!e||e.charCodeAt(0)<65||e.charCodeAt(0)>90)continue;const d={extends:t[a]};delete t[a];for(let h=f+1;h<r.length;h++){const x=r[h],p=x.charCodeAt(0);if(p>=65&&p<=90||S.REGISTRY.has(x)||typeof t[x]=="function"&&(x.startsWith("on")||x.startsWith(".")))break;const l=t[x];l!==void 0&&(d[x]=l,delete t[x])}t[e]&&typeof t[e]=="object"?t[e]={...d,...t[e]}:t[e]=d}}for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||S.REGISTRY.has(r)||typeof t[r]!="object"||t[r]===null)continue;const f=r.charCodeAt(0);if(f<65||f>90)continue;let a=t[r];if(!a.__ref){if(!a.extends&&!a.extend){const e=o[r]||o[`smbls.${r}`];e&&(a={extends:e,...a})}if(t.childProps&&(a={...t.childProps,...a}),s&&!a.ignoreChildExtends)if(a.extends){const e=Array.isArray(a.extends)?a.extends:[a.extends],d=Array.isArray(s)?s:[s];a={...a,extends:[...d,...e]}}else a={extends:s,...a};N(a,t,r,c)}}}function U(t,c,n){const{node:i}=t;if(!i)return;const s=c?.node||(c?.nodeType?c:null);if(s)if(n?.position==="before"&&n.node)s.insertBefore(i,n.node);else if(n?.position==="after"&&n.node){const o=n.node.nextSibling;o?s.insertBefore(i,o):s.appendChild(i)}else s.appendChild(i)}function $(t,c,n){const i=t.charAt(0).toLowerCase()+t.slice(1);c.context?.plugins?.length&&(0,J.runPluginHook)(i,c,n);const s="on"+t,o=c[s];if(typeof o=="function"){const r=c.context?.designSystem;r&&(0,A.pushConfig)(r);try{if(o(c,c.state,c.context,n)===!1)return!1}catch(f){if(c.context?.plugins?.length&&(0,J.runPluginHook)("error",c,{hook:s,error:f})||console.error(`[DOMQL] Lifecycle "${s}" error:`,f),c.context?.strictMode)throw f}finally{r&&(0,A.popConfig)()}}return!0}var Ct=N;
|
|
6
|
+
`),h&&(o+=h)}}o&&(s.textContent+=o)}function jt(t){const c=t.__ref;c.__conditionalRunners=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const i=n.charAt(0);if(i!=="."&&i!=="!")continue;const s=n.slice(1);if(!s)continue;const o=t[n];if(!o||typeof o!="object")continue;const r=i==="!",f={lastMatch:!1,appliedKeys:null},a=()=>{if(!t.node)return;let d;const h=t[s];if(h===void 0)if(t.state&&s in t.state)d=t.state[s];else{const l=t.context?.cases?.[s];if(l===void 0)return;d=typeof l=="function"?l.call(t,t):l}else typeof h=="function"?d=h(t,t.state,t.context):d=h;const x=r?!d:!!d;if(x===f.lastMatch)return;f.lastMatch=x;const p=t.context?.designSystem;p&&(0,A.pushConfig)(p);try{if(x){const l={};for(const u in o){if(!Object.prototype.hasOwnProperty.call(o,u))continue;const b=typeof o[u]=="function"?o[u](t,t.state,t.context):o[u];if(b!=null)if(g.CSS_PROPS_REGISTRY[u]){const _=g.CSS_PROPS_REGISTRY[u](b,t,t.state,t.context);if(_){const M=Array.isArray(_)?_:[_];for(const L of M)L&&Object.assign(l,L)}}else g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(u)&&(l[u]=b)}const y=Object.keys(l);y.length?(D(t.node,l),f.appliedKeys=y):f.appliedKeys=null}else if(f.appliedKeys){for(const l of f.appliedKeys)t.node.style[l]="";f.appliedKeys=null}}finally{p&&(0,A.popConfig)()}};c.__conditionalRunners.push(a);const e=(0,v.createEffect)(a,{depth:c.path.length});c.__effects.push(e)}}const q=new WeakSet;function vt(t){const{node:c}=t;if(!c)return;if(q.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}q.add(t);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{const i={};let s=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||S.REGISTRY.has(o))continue;const r=o.charCodeAt(0);if(!(r>=65&&r<=90)&&!F(o)){if(g.CSS_PROPS_REGISTRY[o]){const f=t[o],a=g.CSS_PROPS_REGISTRY[o](f,t,t.state,t.context);if(a){if(Array.isArray(a))for(const e of a)e&&Object.assign(i,e);else Object.assign(i,a);s=!0}}else if(g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const a={};for(const e in f){let d=f[e];if(typeof d=="function"&&(d=d(t,t.state,t.context)),!(d==null||typeof d=="function"))if(g.CSS_PROPS_REGISTRY[e]){const h=g.CSS_PROPS_REGISTRY[e](d,t,t.state,t.context);if(h)if(Array.isArray(h))for(const x of h)x&&Object.assign(a,x);else Object.assign(a,h)}else a[e]=d}if(Object.keys(a).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const d={};for(const x in a){const p=a[x];d[x]=typeof p=="string"&&!p.includes("!important")?p+" !important":p}const h=o.slice(1);i[`[data-theme="${h}"] &`]=d}else{let d=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const x=o.slice(1),p=t.context?.designSystem?.media?.[x]||t.context?.designSystem?.media?.[x];p&&(d=`@media ${p}`)}const h={};for(const x in a){const p=a[x];if(p&&typeof p=="object"&&!Array.isArray(p)){const l={};for(const u in p)if(g.CSS_PROPS_REGISTRY[u]){const b=g.CSS_PROPS_REGISTRY[u](p[u],t,t.state,t.context);if(b)if(Array.isArray(b))for(const _ of b)_&&Object.assign(l,_);else Object.assign(l,b)}else l[u]=p[u];const y=x.startsWith(":")?"":" ";if(d.includes(",")){const u=d.split(",").map(b=>`${b.trim()}${y}${x}`).join(", ");i[u]=l}else i[`${d}${y}${x}`]=l}else h[x]=p}Object.keys(h).length&&(i[d]=h)}s=!0}s=!0}}}}if(s){i.display&&String(i.display).includes("!important")&&(c.style.setProperty("display",String(i.display).replace(/\s*!important\s*$/,""),"important"),delete i.display);const o=(0,ft.css)(i,null,t.context?.cssPrefix);if(o&&c.classList){const f=o.split(" ").filter(Boolean);let a=!1;for(const e of f)c.classList.add(e),a||(e.charCodeAt(0)===95&&e.charCodeAt(1)===99||e.charCodeAt(0)===95&&e.indexOf("_c",1)!==-1)&&(a=!0);a&&typeof c.offsetWidth=="number"&&c.offsetWidth}const r=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(r!=null){const f=i.display;if(f&&f!==r)if(r==="none"){const a=[];for(const e of c.classList)e.startsWith("_d-")&&e!=="_d-none"&&a.push(e);for(const e of a)c.classList.remove(e);c.classList.add("_d-none")}else c.style.display=t.display}}}finally{n&&(0,A.popConfig)(),q.delete(t)}}function ot(t){const{node:c}=t;if(!c||!c.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const r="aria-"+s.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());c.setAttribute(r,o===!0?"":o)}const n=(0,K.applyAttrTransforms)(t);for(const s in n){const o=n[s];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&c.setAttribute(s,o===!0?"":o)}const i=t.tag||"div";for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||typeof t[s]=="function"||S.REGISTRY.has(s)||s==="on"||n[s]!==void 0)continue;const o=s.charCodeAt(0);if(!(o>=65&&o<=90)&&!F(s)&&!(g.CSS_PROPS_REGISTRY[s]||g.DEFAULT_CSS_PROPERTIES_LIST&&g.DEFAULT_CSS_PROPERTIES_LIST.has(s))&&(0,K.checkAttributeByTagName)(i,s)){let r=t[s];if(r==null||r===!1||(typeof r=="string"&&r.includes("{{")&&(r=(0,V.replaceLiteralsWithObjectFields)(r,t,t.state,t.context),t[s]=r),r==null||r===!1||typeof r=="function"||typeof r=="object"))continue;c.setAttribute(s,r===!0?"":r)}}}function st(t,c){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!F(n))continue;let i=t[n];if(typeof i=="string"&&/^[A-Za-z_$][\w$]*$/.test(i)){const o=i;i=function(f){return t.call(o,f)}}if(typeof i!="function")continue;const s=ht(n);S.LIFECYCLE_EVENTS.has(s)||(0,nt.registerEvent)(xt(s),t,i)}}function G(t,c){const n={...t};for(const i in c){const s=n[i],o=c[i];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[i]=G(s,o):n[i]=o}return n}function Q(t,c,n){if(!c||!t.node)return;const i=t.childExtends;if(Array.isArray(c)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const r=t.childProps,f=t.childrenAs;for(let a=0;a<c.length;a++){let e=c[a];const d=e;(typeof e=="string"||typeof e=="number")&&(e={text:e});let h=r;if(typeof r=="function")try{h=r(t,e)}catch{h=null}if(f==="state"){let l=d;(typeof d=="string"||typeof d=="number")&&(l={value:d,text:d}),e=h?{...h,state:l}:{state:l}}else h&&(e=G(h,e));if(i&&!e.ignoreChildExtends)if(e.extends){const l=Array.isArray(e.extends)?e.extends:[e.extends],y=Array.isArray(i)?i:[i];e={...e,extends:[...y,...l]}}else e={extends:i,...e};const x=e?.key||`${a}`,p=N(e,t,x,n);p?.node&&o.appendChild(p.node)}t.node.appendChild(o);return}if(typeof c=="string"){const s=tt(c,t);if(Array.isArray(s)){Q(t,s,n);return}}if(typeof c=="object")for(const s in c){if(S.REGISTRY.has(s))continue;let o=c[s];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=G(t.childProps,o)),i&&!o.ignoreChildExtends)if(o.extends){const r=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(i)?i:[i];o={...o,extends:[...f,...r]}}else o={extends:i,...o};N(o,t,s,n)}}}function ct(t,c){let{children:n,content:i}=t;const s=t.childExtends;if(typeof n=="function"){const r=n;n=r(t,t.state,t.context),t.children=n;const f=t.__ref;let a=!1;const e=(0,v.createEffect)(()=>{const d=r(t,t.state,t.context);if(!a){a=!0;return}if(d===t.children)return;if(t.children=d,Array.isArray(d)&&t.childrenAs==="state"){const p=t.childProps,l=[],y=new Map;for(let C=0;C<d.length;C++){const P=d[C];let j=p;if(typeof p=="function")try{j=p(t,P)}catch{j=null}const T=j&&j.key||P&&P.key||`${C}`;l.push(T),y.set(T,{rawChild:P,childProps:j})}const u=new Set(l),b=f.__children.slice();for(const C of b)if(!u.has(C)){const P=t[C];P?.remove&&P.remove(),delete t[C]}const _=t.childExtends,L=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const C of l){const P=y.get(C),j=P.rawChild,T=t[C];if(T&&T.state){if(j&&typeof j=="object"){const E=T.state;if(typeof E.replace=="function")E.replace(j);else if(typeof E.update=="function"){for(const k in E)if(!(k==="__element"||k==="root"||k==="parent"||k==="update")&&!Object.prototype.hasOwnProperty.call(j,k))try{E[k]=void 0}catch{}E.update(j)}else for(const k in j)E[k]=j[k]}continue}let W=j;(typeof j=="string"||typeof j=="number")&&(W={value:j,text:j});const X=P.childProps;let w=X?{...X,state:W}:{state:W};if(_&&!w.ignoreChildExtends)if(w.extends){const E=Array.isArray(w.extends)?w.extends:[w.extends],k=Array.isArray(_)?_:[_];w={...w,extends:[...k,...E]}}else w={extends:_,...w};const m=N(w,t,C,c);m?.node&&L&&L.appendChild(m.node)}L&&L.childNodes.length&&t.node&&t.node.appendChild(L),f.__children=l;return}for(const p of[...f.__children]){const l=t[p];l?.remove&&l.remove(),delete t[p]}f.__children=[],Q(t,d,c)},{depth:f.path.length});f.__effects.push(e)}if(Q(t,n||i,c),n||i)return;const o=t.context?.components||{};{const r=Object.keys(t);for(let f=0;f<r.length;f++){const a=r[f];if(!a.endsWith("Extends")||typeof t[a]!="string")continue;const e=a.slice(0,-7);if(!e||e.charCodeAt(0)<65||e.charCodeAt(0)>90)continue;const d={extends:t[a]};delete t[a];for(let h=f+1;h<r.length;h++){const x=r[h],p=x.charCodeAt(0);if(p>=65&&p<=90||S.REGISTRY.has(x)||typeof t[x]=="function"&&(x.startsWith("on")||x.startsWith(".")))break;const l=t[x];l!==void 0&&(d[x]=l,delete t[x])}t[e]&&typeof t[e]=="object"?t[e]={...d,...t[e]}:t[e]=d}}for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||S.REGISTRY.has(r)||typeof t[r]!="object"||t[r]===null)continue;const f=r.charCodeAt(0);if(f<65||f>90)continue;let a=t[r];if(!a.__ref){if(!a.extends&&!a.extend){const e=o[r]||o[`smbls.${r}`];e&&(a={extends:e,...a})}if(t.childProps&&(a={...t.childProps,...a}),s&&!a.ignoreChildExtends)if(a.extends){const e=Array.isArray(a.extends)?a.extends:[a.extends],d=Array.isArray(s)?s:[s];a={...a,extends:[...d,...e]}}else a={extends:s,...a};N(a,t,r,c)}}}function U(t,c,n){const{node:i}=t;if(!i)return;const s=c?.node||(c?.nodeType?c:null);if(s)if(n?.position==="before"&&n.node)s.insertBefore(i,n.node);else if(n?.position==="after"&&n.node){const o=n.node.nextSibling;o?s.insertBefore(i,o):s.appendChild(i)}else s.appendChild(i)}function $(t,c,n){const i=t.charAt(0).toLowerCase()+t.slice(1);c.context?.plugins?.length&&(0,J.runPluginHook)(i,c,n);const s="on"+t,o=c[s];if(typeof o=="function"){const r=c.context?.designSystem;r&&(0,A.pushConfig)(r);try{if(o(c,c.state,c.context,n)===!1)return!1}catch(f){if(c.context?.plugins?.length&&(0,J.runPluginHook)("error",c,{hook:s,error:f})||console.error(`[DOMQL] Lifecycle "${s}" error:`,f),c.context?.strictMode)throw f}finally{r&&(0,A.popConfig)()}}return!0}var Ct=N;
|
package/dist/esm/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{createStore as V,createScopeStore as ft,isStore as W}from"@symbo.ls/signal";import{createEffect as A}from"@symbo.ls/signal";import{cacheNode as H,detectTag as ot}from"./cache.js";import{REGISTRY as $,LIFECYCLE_EVENTS as at}from"./registry.js";import{registerEvent as et}from"./delegate.js";import{applyExtends as dt}from"./extends.js";import{addMethods as ut}from"./methods.js";import"./dispose.js";import{replaceLiteralsWithObjectFields as Z}from"@symbo.ls/utils";import{runPluginHook as st}from"@symbo.ls/utils/function.js";import{applyStateMethods as K}from"@symbo.ls/state";import{CSS_PROPS_REGISTRY as j,DEFAULT_CSS_PROPERTIES_LIST as C}from"css-in-props";import{css as pt}from"@symbo.ls/css";import{pushConfig as O,popConfig as E}from"@symbo.ls/scratch";import{checkAttributeByTagName as
|
|
1
|
+
import{createStore as V,createScopeStore as ft,isStore as W}from"@symbo.ls/signal";import{createEffect as A}from"@symbo.ls/signal";import{cacheNode as H,detectTag as ot}from"./cache.js";import{REGISTRY as $,LIFECYCLE_EVENTS as at}from"./registry.js";import{registerEvent as et}from"./delegate.js";import{applyExtends as dt}from"./extends.js";import{addMethods as ut}from"./methods.js";import"./dispose.js";import{replaceLiteralsWithObjectFields as Z}from"@symbo.ls/utils";import{runPluginHook as st}from"@symbo.ls/utils/function.js";import{applyStateMethods as K}from"@symbo.ls/state";import{CSS_PROPS_REGISTRY as j,DEFAULT_CSS_PROPERTIES_LIST as C}from"css-in-props";import{css as pt}from"@symbo.ls/css";import{pushConfig as O,popConfig as E}from"@symbo.ls/scratch";import{checkAttributeByTagName as B,applyAttrTransforms as yt}from"attrs-in-props";let lt=1;function T(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function ht(t){return t.charAt(2).toLowerCase()+t.slice(3)}function xt(t){return t.toLowerCase()}function z(t,n){const c={...t};for(const r in n){const s=c[r],o=n[r];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?c[r]=z(s,o):c[r]=o}return c}function F(t,n,c,r={},s){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=c||t.key||`_${lt++}`,o.parent=n||null,o.context=t.context||n?.context||r.context||{},o.context.__create||(o.context.__create=F);const i=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:n?.__ref?.root||o,path:n?.__ref?.path?[...n.__ref.path,o.key]:[o.key]};if(c&&!t.extends&&!t.extend){const y=c.indexOf("_");if(y>0){const u=c.substring(0,y),b=o.context?.components;b&&(b[u]||b["smbls."+u])&&(t={extends:u,...t})}}dt(o,t,r);const f=new Set(["childProps","attr","style","scope","data"]),a=o.props&&typeof o.props=="object"?o.props:null;for(const y in t){if(y==="parent"||y==="node"||y==="__ref"||y==="extends"||y==="context"||y==="props")continue;const u=t[y],b=o[y],g=b&&u&&typeof b=="object"&&typeof u=="object"&&!Array.isArray(b)&&!Array.isArray(u)&&typeof b!="function"&&typeof u!="function";g&&y.charCodeAt(0)>=65&&y.charCodeAt(0)<=90?o[y]=z(b,u):g&&f.has(y)?o[y]={...b,...u}:o[y]=u}function e(y){for(const u in y){const b=y[u],g=o[u],I=g&&b&&typeof g=="object"&&typeof b=="object"&&!Array.isArray(g)&&!Array.isArray(b)&&typeof g!="function"&&typeof b!="function";I&&u.charCodeAt(0)>=65&&u.charCodeAt(0)<=90?o[u]=z(g,b):I&&f.has(u)?o[u]={...g,...b}:o[u]=b}}a&&e(a),t.props&&typeof t.props=="object"&&e(t.props),t.data!==void 0&&(o.data=t.data),t.classlist!==void 0&&(o.classlist=t.classlist),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html);const d=o.scope&&typeof o.scope=="object"?o.scope:null,h=n?.scope,x=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,p=h||x||null;if(t.scope!==void 0||d){const y={};d&&Object.assign(y,d),t.scope!==void 0&&Object.assign(y,t.scope),o.scope=ft(y,p)}else p&&(o.scope=p);if(t.if!==void 0&&(o.if=t.if),ut(o),bt(o,n,t),o.if!=null){const y=typeof o.if=="function"?o.if(o,o.state,o.context):o.if;i.__if=!!y}if(i.__if)typeof t.if=="function"&&(i.__ifInitialized=!0);else return n&&(n[o.key]=o),typeof t.if=="function"&&q(o,{if:t.if}),o;o.tag||(o.tag=ot(o)),N("Init",o,r);const l=o.node=H(o);if(!l)return o;N("AttachNode",o,r),l.setAttribute&&o.key&&l.setAttribute("data-key",o.key),l.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&l.setAttribute("data-smbls-app",o.context.key),o.id&&l.setAttribute&&(l.id=o.id),q(o,t),G(o),nt(o),it(o,r);try{rt(o,r)}catch(y){if(typeof console<"u"&&console.error){const u=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${u}:`,y?.message||y,y?.stack?`
|
|
2
2
|
`+y.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(X(o,n,s),n&&(n[o.key]=o,n.__ref?.__children&&(n.__ref.__children.includes(o.key)||n.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const y=o.context?.designSystem;y&&O(y);try{const u=o.html(o,o.state,o.context);u!=null&&typeof u!="function"&&(o.node.innerHTML=u)}catch{}finally{y&&E()}}if(N("Create",o,r),N("Complete",o,r),N("Render",o,r),N("RenderRouter",o,r),typeof o.onFrame=="function"){const y=o.onFrame,u=o.context?.designSystem,b=()=>{if(o.node){if(o.node.isConnected){u&&O(u);try{y(o,o.state,o.context)}catch(g){console.error("[DOMQL] onFrame error:",g)}finally{u&&E()}}requestAnimationFrame(b)}};requestAnimationFrame(b)}return o}function bt(t,n,c){const r=!n,s=c.state&&typeof c.state=="object"&&!Array.isArray(c.state)&&Object.keys(c.state).length===0,o=r&&s&&t.context?.state,i=c.state!==void 0&&!o?c.state:t.state&&!W(t.state)?t.state:void 0;if(i==null){if(n?.state)t.state=n.state,K(t,t.state);else if(t.context?.state){const f=t.context.state,a={...f},e=t.context?.polyglot;if(e?.translations){const d=f.lang||e.defaultLang||"en",h=e.translations[d];if(h&&typeof h=="object")for(const p in h)a[p]===void 0&&(a[p]=h[p]);const x=new Set(e.languages||[]);for(const p in e.translations)!x.has(p)&&a[p]===void 0&&(a[p]=e.translations[p])}t.state=W(a)?a:V(a),t.state.__element=t,t.state.root=t.state,K(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),K(t,t.state);return}if(typeof i=="string"){if(t.state=ct(i,n),t.state&&typeof t.state=="object"&&!W(t.state)){const f=n?.state?.root||n?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}K(t,t.state);return}if(typeof i=="function"){const f=i(t,n?.state);t.state=V(f||{})}else t.state=V({...i});t.state.__element=t,n?.state?(t.state.parent=n.state,t.state.root=n.state.root||n.state):t.state.root=t.state,K(t,t.state)}function Y(t,n){if(!n)return t;const c=n.split("/");let r=t;for(const s of c){if(r==null)return{};r=r[s]}return r??{}}function ct(t,n){if(!n)return{};if(t===".")return n.state||{};if(t.startsWith("../")){const s=t.slice(3);return s?Y(n.state,s):n.state??{}}if(t.startsWith("~/")){const s=n.state?.root||n.state,o=t.slice(2);return o?Y(s,o):s??{}}if(n.state?.[t]!==void 0)return n.state[t];const c=Y(n.state,t);if(c!=null&&Object.keys(c).length>0)return c;const r=n.context?.polyglot;if(r?.translations){const s=n.state?.root?.lang||r.defaultLang||"en",o=r.translations[s];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}function gt(t){const n=t.__ref,c=t.tag||"div",r=t.context?.designSystem,s=[],o=Object.keys(t);for(let i=0;i<o.length;i++){const f=o[i];if(typeof t[f]!="function"||$.has(f))continue;const a=f.charCodeAt(0);a>=65&&a<=90||T(f)||j[f]||C&&C.has(f)||z(c,f)||s.push({prop:f,fn:t[f]})}for(let i=0;i<s.length;i++){const{prop:f,fn:a}=s[i];n.__exec[f]=a,Object.defineProperty(t,f,{get(){r&&O(r);try{return a(t,t.state,t.context)}catch{return}finally{r&&E()}},set(e){delete n.__exec[f],Object.defineProperty(t,f,{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function q(t,n){const c=t.__ref;if(gt(t),typeof t.text=="function"){const s=t.text,o=A(()=>{if(!c.contentManaged)try{let i=s(t,t.state,t.context);t.node&&i!=null&&typeof i!="function"&&typeof i!="object"&&(typeof i=="string"&&i.includes("{{")&&(i=Z.call(t,i,t.state)),t.tag==="string"?t.node.nodeValue=i:t.node.textContent=i)}catch{}},{depth:c.path.length});c.__effects.push(o),c.__exec.text=s}else if(typeof t.text=="string"&&t.text.includes("{{")){const s=t.text,o=A(()=>{if(c.contentManaged)return;const i=Z.call(t,s,t.state);i!=null&&(t.text=i),t.node&&(t.tag==="string"?t.node.nodeValue=i??"":t.node.textContent=i??"")},{depth:c.path.length});c.__effects.push(o),c.__exec.text=s}for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&typeof t[s]=="function"&&!$.has(s)&&!T(s)&&!c.__exec[s]){if(j[s]){const o=t[s],i=s,f=A(()=>{const a=t.context?.designSystem;a&&O(a);try{const e=o(t,t.state,t.context),d=j[i](e,t,t.state,t.context);d&&t.node?D(t.node,d):t.node&&(i==="show"||i==="hide")&&(t.node.style.display="")}finally{a&&E()}},{depth:c.path.length});c.__effects.push(f),c.__exec[s]=o}else if(C&&C.has(s)){const o=t[s],i=s,f=A(()=>{const a=t.context?.designSystem;a&&O(a);try{const e=o(t,t.state,t.context);t.node&&(e!=null?D(t.node,{[i]:e}):t.node.style[i]="")}finally{a&&E()}},{depth:c.path.length});c.__effects.push(f),c.__exec[s]=o}}if(typeof n.html=="function"){const s=n.html,o=A(()=>{const i=t.context?.designSystem;i&&O(i);try{const f=s(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{i&&E()}},{depth:c.path.length});c.__effects.push(o),c.__exec.html=s}if(typeof n.value=="function"){const s=n.value,o=A(()=>{try{const i=s(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=i==null?"":String(i);if(t.node.value===f)return;const a=typeof document<"u"&&document.activeElement===t.node,e=a&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,d=a&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,a&&e!=null&&d!=null)try{t.node.setSelectionRange(e,d)}catch{}}catch{}},{depth:c.path.length});c.__effects.push(o),c.__exec.value=s}if(typeof n.style=="function"){const s=n.style,o=A(()=>{const i=s(t,t.state,t.context);D(t.node,i)},{depth:c.path.length});c.__effects.push(o),c.__exec.style=s}else if(t.style&&typeof t.style=="object")for(const s in t.style){const o=t.style[s];if(typeof o!="function")continue;const i=A(()=>{try{const f=o(t,t.state,t.context);t.node&&D(t.node,{[s]:f})}catch{}},{depth:c.path.length});c.__effects.push(i)}if(t.attr&&typeof t.attr=="object"){for(const s in t.attr)if(typeof t.attr[s]=="function"){const o=t.attr[s],i=s,f=A(()=>{try{const a=o(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(i):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(i,a===!0?"":a))}catch{}},{depth:c.path.length});c.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o!="function")continue;const i="aria-"+s.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),f=A(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(i):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(i,a===!0?"":a)}catch{}},{depth:c.path.length});c.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const s in t.data){const o=t.data[s];if(typeof o!="function")continue;const f="data-"+s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),a=A(()=>{try{const e=o(t,t.state,t.context);if(!t.node?.setAttribute)return;e==null||e===!1?t.node.removeAttribute(f):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(f,e===!0?"":e)}catch{}},{depth:c.path.length});c.__effects.push(a)}const r=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(r)for(const s in r){const o=r[s];if(typeof o!="function")continue;const i=A(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(s):t.node.classList.remove(s)}catch{}},{depth:c.path.length});c.__effects.push(i)}if(typeof n.if=="function"){const s=n.if,o=A(()=>{const i=s(t,t.state,t.context),f=c.__if;if(c.__if=!!i,f&&!c.__if&&t.node)t.node.remove();else if(!f&&c.__if)if(c.__ifInitialized){t.node||(t.node=H(t));const a=t.parent,e=a?.node;if(e&&t.node){let d=null;const h=Object.keys(a),x=h.indexOf(t.key);for(let p=x+1;p<h.length;p++){const l=a[h[p]];if(l?.node?.parentNode===e){d=l.node;break}}d?e.insertBefore(t.node,d):e.appendChild(t.node)}else X(t,t.parent);G(t)}else{if(c.__ifInitialized=!0,t.tag||(t.tag=ot(t)),N("Init",t,{}),t.node||(t.node=H(t)),!t.node)return;N("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id);const a=n.if;delete n.if;try{q(t,n)}finally{n.if=a}G(t),nt(t),it(t,{}),rt(t,{}),X(t,t.parent)}},{depth:c.path.length});c.__effects.push(o)}for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||$.has(s)||typeof t[s]!="function")continue;const o=s.charCodeAt(0);if(o>=65&&o<=90||T(s))continue;const i=t[s];c.__exec[s]=i;const f=t.tag||"div";if(z(f,s)&&!j[s]&&!(C&&C.has(s))){const a=s,e=A(()=>{try{const d=i(t,t.state,t.context);t.node?.setAttribute&&(d==null||d===!1?t.node.removeAttribute(a):typeof d!="function"&&typeof d!="object"&&(a==="src"&&"src"in t.node?t.node.src=d:t.node.setAttribute(a,d===!0?"":d)))}catch{}},{depth:c.path.length});c.__effects.push(e)}}jt(t)}function G(t){const{node:n}=t;if(n){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?n.nodeValue=t.text:n.textContent=t.text:typeof t.text=="number"&&(n.textContent=t.text),vt(t),typeof t.html=="string"&&(n.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in n){const c=String(t.value);n.value!==c&&(n.value=c)}if(t.style&&typeof t.style=="object"&&D(n,t.style),t.attr&&typeof t.attr=="object")for(const c in t.attr){const r=t.attr[c];typeof r=="function"||typeof r=="object"||r==null||r===!1||n.setAttribute&&n.setAttribute(c,r===!0?"":r)}if(t.data&&typeof t.data=="object")for(const c in t.data){const r=t.data[c];typeof r=="function"||typeof r=="object"||r==null||r===!1||n.dataset&&(n.dataset[c]=r===!0?"":r)}if(t.classlist||t.class){const c=t.classlist||t.class;if(typeof c=="string")c.split(" ").forEach(r=>r&&n.classList.add(r));else if(typeof c=="object")for(const r in c){const s=typeof c[r]=="function"?c[r](t,t.state,t.context):c[r];s&&n.classList.add(typeof s=="string"?s:r)}}}}function D(t,n){if(!t||!n||!t.style)return;let c=null;for(const r in n){const s=n[r];if(s!=null){if(r.charAt(0)==="&"&&typeof s=="object"){c||(c={}),c[r]=s;continue}try{const o=String(s),i=r.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),f=o.trim(),a=/\s*!important\s*$/.test(f),e=f.replace(/\s*!important\s*$/,"");t.style.setProperty(i,e,a?"important":"")}catch{}}}c&&At(t,c)}let _t=0;function At(t,n){const c=`_ds${_t++}`;t.classList.add(c);const r=t.ownerDocument;let s=r.querySelector("style[data-smbls-scoped]");s||(s=r.createElement("style"),s.setAttribute("data-smbls-scoped",""),r.head.appendChild(s));let o="";for(const i in n){const f="."+c,a=i.replace(/&/g,f).split(",").map(d=>{const h=d.trim();return h.includes(f)?h:f+h}).join(", "),e=n[i];if(typeof e=="object"){let d="",h="";for(const x in e){const p=e[x];if(typeof p=="object"){const l=x.includes("&")?a.split(", ").map(u=>x.replace(/&/g,u)).join(", "):a.split(", ").map(u=>`${u} ${x}`).join(", ");let y="";for(const u in p)y+=`${u.replace(/[A-Z]/g,b=>"-"+b.toLowerCase())}: ${p[u]};`;h+=`${l} { ${y} }
|
|
4
|
+
`):"")}}if(X(o,n,s),n&&(n[o.key]=o,n.__ref?.__children&&(n.__ref.__children.includes(o.key)||n.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const y=o.context?.designSystem;y&&O(y);try{const u=o.html(o,o.state,o.context);u!=null&&typeof u!="function"&&(o.node.innerHTML=u)}catch{}finally{y&&E()}}if(N("Create",o,r),N("Complete",o,r),N("Render",o,r),N("RenderRouter",o,r),typeof o.onFrame=="function"){const y=o.onFrame,u=o.context?.designSystem,b=()=>{if(o.node){if(o.node.isConnected){u&&O(u);try{y(o,o.state,o.context)}catch(g){console.error("[DOMQL] onFrame error:",g)}finally{u&&E()}}requestAnimationFrame(b)}};requestAnimationFrame(b)}return o}function bt(t,n,c){const r=!n,s=c.state&&typeof c.state=="object"&&!Array.isArray(c.state)&&Object.keys(c.state).length===0,o=r&&s&&t.context?.state,i=c.state!==void 0&&!o?c.state:t.state&&!W(t.state)?t.state:void 0;if(i==null){if(n?.state)t.state=n.state,K(t,t.state);else if(t.context?.state){const f=t.context.state,a={...f},e=t.context?.polyglot;if(e?.translations){const d=f.lang||e.defaultLang||"en",h=e.translations[d];if(h&&typeof h=="object")for(const p in h)a[p]===void 0&&(a[p]=h[p]);const x=new Set(e.languages||[]);for(const p in e.translations)!x.has(p)&&a[p]===void 0&&(a[p]=e.translations[p])}t.state=W(a)?a:V(a),t.state.__element=t,t.state.root=t.state,K(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),K(t,t.state);return}if(typeof i=="string"){if(t.state=ct(i,n),t.state&&typeof t.state=="object"&&!W(t.state)){const f=n?.state?.root||n?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}K(t,t.state);return}if(typeof i=="function"){const f=i(t,n?.state);t.state=V(f||{})}else t.state=V({...i});t.state.__element=t,n?.state?(t.state.parent=n.state,t.state.root=n.state.root||n.state):t.state.root=t.state,K(t,t.state)}function Y(t,n){if(!n)return t;const c=n.split("/");let r=t;for(const s of c){if(r==null)return{};r=r[s]}return r??{}}function ct(t,n){if(!n)return{};if(t===".")return n.state||{};if(t.startsWith("../")){const s=t.slice(3);return s?Y(n.state,s):n.state??{}}if(t.startsWith("~/")){const s=n.state?.root||n.state,o=t.slice(2);return o?Y(s,o):s??{}}if(n.state?.[t]!==void 0)return n.state[t];const c=Y(n.state,t);if(c!=null&&Object.keys(c).length>0)return c;const r=n.context?.polyglot;if(r?.translations){const s=n.state?.root?.lang||r.defaultLang||"en",o=r.translations[s];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}function gt(t){const n=t.__ref,c=t.tag||"div",r=t.context?.designSystem,s=[],o=Object.keys(t);for(let i=0;i<o.length;i++){const f=o[i];if(typeof t[f]!="function"||$.has(f))continue;const a=f.charCodeAt(0);a>=65&&a<=90||T(f)||j[f]||C&&C.has(f)||B(c,f)||s.push({prop:f,fn:t[f]})}for(let i=0;i<s.length;i++){const{prop:f,fn:a}=s[i];n.__exec[f]=a,Object.defineProperty(t,f,{get(){r&&O(r);try{return a(t,t.state,t.context)}catch{return}finally{r&&E()}},set(e){delete n.__exec[f],Object.defineProperty(t,f,{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function q(t,n){const c=t.__ref;if(gt(t),typeof t.text=="function"){const s=t.text,o=A(()=>{if(!c.contentManaged)try{let i=s(t,t.state,t.context);t.node&&i!=null&&typeof i!="function"&&typeof i!="object"&&(typeof i=="string"&&i.includes("{{")&&(i=Z.call(t,i,t.state)),t.tag==="string"?t.node.nodeValue=i:t.node.textContent=i)}catch{}},{depth:c.path.length});c.__effects.push(o),c.__exec.text=s}else if(typeof t.text=="string"&&t.text.includes("{{")){const s=t.text,o=A(()=>{if(c.contentManaged)return;const i=Z.call(t,s,t.state);i!=null&&(t.text=i),t.node&&(t.tag==="string"?t.node.nodeValue=i??"":t.node.textContent=i??"")},{depth:c.path.length});c.__effects.push(o),c.__exec.text=s}for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&typeof t[s]=="function"&&!$.has(s)&&!T(s)&&!c.__exec[s]){if(j[s]){const o=t[s],i=s,f=A(()=>{const a=t.context?.designSystem;a&&O(a);try{const e=o(t,t.state,t.context),d=j[i](e,t,t.state,t.context);d&&t.node?D(t.node,d):t.node&&(i==="show"||i==="hide")&&(t.node.style.display="")}finally{a&&E()}},{depth:c.path.length});c.__effects.push(f),c.__exec[s]=o}else if(C&&C.has(s)){const o=t[s],i=s,f=A(()=>{const a=t.context?.designSystem;a&&O(a);try{const e=o(t,t.state,t.context);t.node&&(e!=null?D(t.node,{[i]:e}):t.node.style[i]="")}finally{a&&E()}},{depth:c.path.length});c.__effects.push(f),c.__exec[s]=o}}if(typeof n.html=="function"){const s=n.html,o=A(()=>{const i=t.context?.designSystem;i&&O(i);try{const f=s(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{i&&E()}},{depth:c.path.length});c.__effects.push(o),c.__exec.html=s}if(typeof n.value=="function"){const s=n.value,o=A(()=>{try{const i=s(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=i==null?"":String(i);if(t.node.value===f)return;const a=typeof document<"u"&&document.activeElement===t.node,e=a&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,d=a&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,a&&e!=null&&d!=null)try{t.node.setSelectionRange(e,d)}catch{}}catch{}},{depth:c.path.length});c.__effects.push(o),c.__exec.value=s}if(typeof n.style=="function"){const s=n.style,o=A(()=>{const i=s(t,t.state,t.context);D(t.node,i)},{depth:c.path.length});c.__effects.push(o),c.__exec.style=s}else if(t.style&&typeof t.style=="object")for(const s in t.style){const o=t.style[s];if(typeof o!="function")continue;const i=A(()=>{try{const f=o(t,t.state,t.context);t.node&&D(t.node,{[s]:f})}catch{}},{depth:c.path.length});c.__effects.push(i)}if(t.attr&&typeof t.attr=="object"){for(const s in t.attr)if(typeof t.attr[s]=="function"){const o=t.attr[s],i=s,f=A(()=>{try{const a=o(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(i):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(i,a===!0?"":a))}catch{}},{depth:c.path.length});c.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o!="function")continue;const i="aria-"+s.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),f=A(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(i):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(i,a===!0?"":a)}catch{}},{depth:c.path.length});c.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const s in t.data){const o=t.data[s];if(typeof o!="function")continue;const f="data-"+s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),a=A(()=>{try{const e=o(t,t.state,t.context);if(!t.node?.setAttribute)return;e==null||e===!1?t.node.removeAttribute(f):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(f,e===!0?"":e)}catch{}},{depth:c.path.length});c.__effects.push(a)}const r=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(r)for(const s in r){const o=r[s];if(typeof o!="function")continue;const i=A(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(s):t.node.classList.remove(s)}catch{}},{depth:c.path.length});c.__effects.push(i)}if(typeof n.if=="function"){const s=n.if,o=A(()=>{const i=s(t,t.state,t.context),f=c.__if;if(c.__if=!!i,f&&!c.__if&&t.node)t.node.remove();else if(!f&&c.__if)if(c.__ifInitialized){t.node||(t.node=H(t));const a=t.parent,e=a?.node;if(e&&t.node){let d=null;const h=Object.keys(a),x=h.indexOf(t.key);for(let p=x+1;p<h.length;p++){const l=a[h[p]];if(l?.node?.parentNode===e){d=l.node;break}}d?e.insertBefore(t.node,d):e.appendChild(t.node)}else X(t,t.parent);G(t)}else{if(c.__ifInitialized=!0,t.tag||(t.tag=ot(t)),N("Init",t,{}),t.node||(t.node=H(t)),!t.node)return;N("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id);const a=n.if;delete n.if;try{q(t,n)}finally{n.if=a}G(t),nt(t),it(t,{}),rt(t,{}),X(t,t.parent)}},{depth:c.path.length});c.__effects.push(o)}for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||$.has(s)||typeof t[s]!="function")continue;const o=s.charCodeAt(0);if(o>=65&&o<=90||T(s))continue;const i=t[s];c.__exec[s]=i;const f=t.tag||"div";if(B(f,s)&&!j[s]&&!(C&&C.has(s))){const a=s,e=A(()=>{try{const d=i(t,t.state,t.context);t.node?.setAttribute&&(d==null||d===!1?t.node.removeAttribute(a):typeof d!="function"&&typeof d!="object"&&(a==="src"&&"src"in t.node?t.node.src=d:t.node.setAttribute(a,d===!0?"":d)))}catch{}},{depth:c.path.length});c.__effects.push(e)}}jt(t)}function G(t){const{node:n}=t;if(n){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?n.nodeValue=t.text:n.textContent=t.text:typeof t.text=="number"&&(n.textContent=t.text),vt(t),typeof t.html=="string"&&(n.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in n){const c=String(t.value);n.value!==c&&(n.value=c)}if(t.style&&typeof t.style=="object"&&D(n,t.style),t.attr&&typeof t.attr=="object")for(const c in t.attr){const r=t.attr[c];typeof r=="function"||typeof r=="object"||r==null||r===!1||n.setAttribute&&n.setAttribute(c,r===!0?"":r)}if(t.data&&typeof t.data=="object")for(const c in t.data){const r=t.data[c];typeof r=="function"||typeof r=="object"||r==null||r===!1||n.dataset&&(n.dataset[c]=r===!0?"":r)}if(t.classlist||t.class){const c=t.classlist||t.class;if(typeof c=="string")c.split(" ").forEach(r=>r&&n.classList.add(r));else if(typeof c=="object")for(const r in c){const s=typeof c[r]=="function"?c[r](t,t.state,t.context):c[r];s&&n.classList.add(typeof s=="string"?s:r)}}}}function D(t,n){if(!t||!n||!t.style)return;let c=null;for(const r in n){const s=n[r];if(s!=null){if(r.charAt(0)==="&"&&typeof s=="object"){c||(c={}),c[r]=s;continue}try{const o=String(s),i=r.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),f=o.trim(),a=/\s*!important\s*$/.test(f),e=f.replace(/\s*!important\s*$/,"");t.style.setProperty(i,e,a?"important":"")}catch{}}}c&&At(t,c)}let _t=0;function At(t,n){const c=`_ds${_t++}`;t.classList.add(c);const r=t.ownerDocument;let s=r.querySelector("style[data-smbls-scoped]");s||(s=r.createElement("style"),s.setAttribute("data-smbls-scoped",""),r.head.appendChild(s));let o="";for(const i in n){const f="."+c,a=i.replace(/&/g,f).split(",").map(d=>{const h=d.trim();return h.includes(f)?h:f+h}).join(", "),e=n[i];if(typeof e=="object"){let d="",h="";for(const x in e){const p=e[x];if(typeof p=="object"){const l=x.includes("&")?a.split(", ").map(u=>x.replace(/&/g,u)).join(", "):a.split(", ").map(u=>`${u} ${x}`).join(", ");let y="";for(const u in p)y+=`${u.replace(/[A-Z]/g,b=>"-"+b.toLowerCase())}: ${p[u]};`;h+=`${l} { ${y} }
|
|
5
5
|
`}else d+=`${x.replace(/[A-Z]/g,l=>"-"+l.toLowerCase())}: ${p};`}d&&(o+=`${a} { ${d} }
|
|
6
|
-
`),h&&(o+=h)}}o&&(s.textContent+=o)}function jt(t){const n=t.__ref;n.__conditionalRunners=[];for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;const r=c.charAt(0);if(r!=="."&&r!=="!")continue;const s=c.slice(1);if(!s)continue;const o=t[c];if(!o||typeof o!="object")continue;const i=r==="!",f={lastMatch:!1,appliedKeys:null},a=()=>{if(!t.node)return;let d;const h=t[s];if(h===void 0)if(t.state&&s in t.state)d=t.state[s];else{const l=t.context?.cases?.[s];if(l===void 0)return;d=typeof l=="function"?l.call(t,t):l}else typeof h=="function"?d=h(t,t.state,t.context):d=h;const x=i?!d:!!d;if(x===f.lastMatch)return;f.lastMatch=x;const p=t.context?.designSystem;p&&O(p);try{if(x){const l={};for(const u in o){if(!Object.prototype.hasOwnProperty.call(o,u))continue;const b=typeof o[u]=="function"?o[u](t,t.state,t.context):o[u];if(b!=null)if(j[u]){const g=j[u](b,t,t.state,t.context);if(g){const I=Array.isArray(g)?g:[g];for(const L of I)L&&Object.assign(l,L)}}else C&&C.has(u)&&(l[u]=b)}const y=Object.keys(l);y.length?(D(t.node,l),f.appliedKeys=y):f.appliedKeys=null}else if(f.appliedKeys){for(const l of f.appliedKeys)t.node.style[l]="";f.appliedKeys=null}}finally{p&&E()}};n.__conditionalRunners.push(a);const e=A(a,{depth:n.path.length});n.__effects.push(e)}}const Q=new WeakSet;function vt(t){const{node:n}=t;if(!n)return;if(Q.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}Q.add(t);const c=t.context?.designSystem;c&&O(c);try{const r={};let s=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||$.has(o))continue;const i=o.charCodeAt(0);if(!(i>=65&&i<=90)&&!T(o)){if(j[o]){const f=t[o],a=j[o](f,t,t.state,t.context);if(a){if(Array.isArray(a))for(const e of a)e&&Object.assign(r,e);else Object.assign(r,a);s=!0}}else if(C&&C.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,s=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,s=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(r[o]=f,s=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const a={};for(const e in f){let d=f[e];if(typeof d=="function"&&(d=d(t,t.state,t.context)),!(d==null||typeof d=="function"))if(j[e]){const h=j[e](d,t,t.state,t.context);if(h)if(Array.isArray(h))for(const x of h)x&&Object.assign(a,x);else Object.assign(a,h)}else a[e]=d}if(Object.keys(a).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const d={};for(const x in a){const p=a[x];d[x]=typeof p=="string"&&!p.includes("!important")?p+" !important":p}const h=o.slice(1);r[`[data-theme="${h}"] &`]=d}else{let d=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const x=o.slice(1),p=t.context?.designSystem?.media?.[x]||t.context?.designSystem?.media?.[x];p&&(d=`@media ${p}`)}const h={};for(const x in a){const p=a[x];if(p&&typeof p=="object"&&!Array.isArray(p)){const l={};for(const u in p)if(j[u]){const b=j[u](p[u],t,t.state,t.context);if(b)if(Array.isArray(b))for(const g of b)g&&Object.assign(l,g);else Object.assign(l,b)}else l[u]=p[u];const y=x.startsWith(":")?"":" ";if(d.includes(",")){const u=d.split(",").map(b=>`${b.trim()}${y}${x}`).join(", ");r[u]=l}else r[`${d}${y}${x}`]=l}else h[x]=p}Object.keys(h).length&&(r[d]=h)}s=!0}s=!0}}}}if(s){r.display&&String(r.display).includes("!important")&&(n.style.setProperty("display",String(r.display).replace(/\s*!important\s*$/,""),"important"),delete r.display);const o=pt(r,null,t.context?.cssPrefix);o&&n.classList&&o.split(" ").forEach(f=>f&&n.classList.add(f));const i=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(i!=null){const f=r.display;if(f&&f!==i)if(i==="none"){const a=[];for(const e of n.classList)e.startsWith("_d-")&&e!=="_d-none"&&a.push(e);for(const e of a)n.classList.remove(e);n.classList.add("_d-none")}else n.style.display=t.display}}}finally{c&&E(),Q.delete(t)}}function nt(t){const{node:n}=t;if(!n||!n.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const i="aria-"+s.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());n.setAttribute(i,o===!0?"":o)}const c=yt(t);for(const s in c){const o=c[s];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&n.setAttribute(s,o===!0?"":o)}const r=t.tag||"div";for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||typeof t[s]=="function"||$.has(s)||s==="on"||c[s]!==void 0)continue;const o=s.charCodeAt(0);if(!(o>=65&&o<=90)&&!T(s)&&!(j[s]||C&&C.has(s))&&z(r,s)){let i=t[s];if(i==null||i===!1||(typeof i=="string"&&i.includes("{{")&&(i=Z(i,t,t.state,t.context),t[s]=i),i==null||i===!1||typeof i=="function"||typeof i=="object"))continue;n.setAttribute(s,i===!0?"":i)}}}function it(t,n){for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||!T(c))continue;let r=t[c];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(f){return t.call(o,f)}}if(typeof r!="function")continue;const s=ht(c);at.has(s)||et(xt(s),t,r)}}function U(t,n){const c={...t};for(const r in n){const s=c[r],o=n[r];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?c[r]=U(s,o):c[r]=o}return c}function J(t,n,c){if(!n||!t.node)return;const r=t.childExtends;if(Array.isArray(n)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const i=t.childProps,f=t.childrenAs;for(let a=0;a<n.length;a++){let e=n[a];const d=e;(typeof e=="string"||typeof e=="number")&&(e={text:e});let h=i;if(typeof i=="function")try{h=i(t,e)}catch{h=null}if(f==="state"){let l=d;(typeof d=="string"||typeof d=="number")&&(l={value:d,text:d}),e=h?{...h,state:l}:{state:l}}else h&&(e=U(h,e));if(r&&!e.ignoreChildExtends)if(e.extends){const l=Array.isArray(e.extends)?e.extends:[e.extends],y=Array.isArray(r)?r:[r];e={...e,extends:[...y,...l]}}else e={extends:r,...e};const x=e?.key||`${a}`,p=F(e,t,x,c);p?.node&&o.appendChild(p.node)}t.node.appendChild(o);return}if(typeof n=="string"){const s=ct(n,t);if(Array.isArray(s)){J(t,s,c);return}}if(typeof n=="object")for(const s in n){if($.has(s))continue;let o=n[s];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=U(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const i=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(r)?r:[r];o={...o,extends:[...f,...i]}}else o={extends:r,...o};F(o,t,s,c)}}}function rt(t,n){let{children:c,content:r}=t;const s=t.childExtends;if(typeof c=="function"){const i=c;c=i(t,t.state,t.context),t.children=c;const f=t.__ref;let a=!1;const e=A(()=>{const d=i(t,t.state,t.context);if(!a){a=!0;return}if(d===t.children)return;if(t.children=d,Array.isArray(d)&&t.childrenAs==="state"){const p=t.childProps,l=[],y=new Map;for(let v=0;v<d.length;v++){const S=d[v];let _=p;if(typeof p=="function")try{_=p(t,S)}catch{_=null}const R=_&&_.key||S&&S.key||`${v}`;l.push(R),y.set(R,{rawChild:S,childProps:_})}const u=new Set(l),b=f.__children.slice();for(const v of b)if(!u.has(v)){const S=t[v];S?.remove&&S.remove(),delete t[v]}const g=t.childExtends,L=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const v of l){const S=y.get(v),_=S.rawChild,R=t[v];if(R&&R.state){if(_&&typeof _=="object"){const w=R.state;if(typeof w.replace=="function")w.replace(_);else if(typeof w.update=="function"){for(const k in w)if(!(k==="__element"||k==="root"||k==="parent"||k==="update")&&!Object.prototype.hasOwnProperty.call(_,k))try{w[k]=void 0}catch{}w.update(_)}else for(const k in _)w[k]=_[k]}continue}let M=_;(typeof _=="string"||typeof _=="number")&&(M={value:_,text:_});const m=S.childProps;let P=m?{...m,state:M}:{state:M};if(g&&!P.ignoreChildExtends)if(P.extends){const w=Array.isArray(P.extends)?P.extends:[P.extends],k=Array.isArray(g)?g:[g];P={...P,extends:[...k,...w]}}else P={extends:g,...P};const tt=F(P,t,v,n);tt?.node&&L&&L.appendChild(tt.node)}L&&L.childNodes.length&&t.node&&t.node.appendChild(L),f.__children=l;return}for(const p of[...f.__children]){const l=t[p];l?.remove&&l.remove(),delete t[p]}f.__children=[],J(t,d,n)},{depth:f.path.length});f.__effects.push(e)}if(J(t,c||r,n),c||r)return;const o=t.context?.components||{};{const i=Object.keys(t);for(let f=0;f<i.length;f++){const a=i[f];if(!a.endsWith("Extends")||typeof t[a]!="string")continue;const e=a.slice(0,-7);if(!e||e.charCodeAt(0)<65||e.charCodeAt(0)>90)continue;const d={extends:t[a]};delete t[a];for(let h=f+1;h<i.length;h++){const x=i[h],p=x.charCodeAt(0);if(p>=65&&p<=90||$.has(x)||typeof t[x]=="function"&&(x.startsWith("on")||x.startsWith(".")))break;const l=t[x];l!==void 0&&(d[x]=l,delete t[x])}t[e]&&typeof t[e]=="object"?t[e]={...d,...t[e]}:t[e]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||$.has(i)||typeof t[i]!="object"||t[i]===null)continue;const f=i.charCodeAt(0);if(f<65||f>90)continue;let a=t[i];if(!a.__ref){if(!a.extends&&!a.extend){const e=o[i]||o[`smbls.${i}`];e&&(a={extends:e,...a})}if(t.childProps&&(a={...t.childProps,...a}),s&&!a.ignoreChildExtends)if(a.extends){const e=Array.isArray(a.extends)?a.extends:[a.extends],d=Array.isArray(s)?s:[s];a={...a,extends:[...d,...e]}}else a={extends:s,...a};F(a,t,i,n)}}}function X(t,n,c){const{node:r}=t;if(!r)return;const s=n?.node||(n?.nodeType?n:null);if(s)if(c?.position==="before"&&c.node)s.insertBefore(r,c.node);else if(c?.position==="after"&&c.node){const o=c.node.nextSibling;o?s.insertBefore(r,o):s.appendChild(r)}else s.appendChild(r)}function N(t,n,c){const r=t.charAt(0).toLowerCase()+t.slice(1);n.context?.plugins?.length&&st(r,n,c);const s="on"+t,o=n[s];if(typeof o=="function"){const i=n.context?.designSystem;i&&O(i);try{if(o(n,n.state,n.context,c)===!1)return!1}catch(f){if(n.context?.plugins?.length&&st("error",n,{hook:s,error:f})||console.error(`[DOMQL] Lifecycle "${s}" error:`,f),n.context?.strictMode)throw f}finally{i&&E()}}return!0}var Wt=F;export{F as create,Wt as default};
|
|
6
|
+
`),h&&(o+=h)}}o&&(s.textContent+=o)}function jt(t){const n=t.__ref;n.__conditionalRunners=[];for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;const r=c.charAt(0);if(r!=="."&&r!=="!")continue;const s=c.slice(1);if(!s)continue;const o=t[c];if(!o||typeof o!="object")continue;const i=r==="!",f={lastMatch:!1,appliedKeys:null},a=()=>{if(!t.node)return;let d;const h=t[s];if(h===void 0)if(t.state&&s in t.state)d=t.state[s];else{const l=t.context?.cases?.[s];if(l===void 0)return;d=typeof l=="function"?l.call(t,t):l}else typeof h=="function"?d=h(t,t.state,t.context):d=h;const x=i?!d:!!d;if(x===f.lastMatch)return;f.lastMatch=x;const p=t.context?.designSystem;p&&O(p);try{if(x){const l={};for(const u in o){if(!Object.prototype.hasOwnProperty.call(o,u))continue;const b=typeof o[u]=="function"?o[u](t,t.state,t.context):o[u];if(b!=null)if(j[u]){const g=j[u](b,t,t.state,t.context);if(g){const I=Array.isArray(g)?g:[g];for(const L of I)L&&Object.assign(l,L)}}else C&&C.has(u)&&(l[u]=b)}const y=Object.keys(l);y.length?(D(t.node,l),f.appliedKeys=y):f.appliedKeys=null}else if(f.appliedKeys){for(const l of f.appliedKeys)t.node.style[l]="";f.appliedKeys=null}}finally{p&&E()}};n.__conditionalRunners.push(a);const e=A(a,{depth:n.path.length});n.__effects.push(e)}}const Q=new WeakSet;function vt(t){const{node:n}=t;if(!n)return;if(Q.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}Q.add(t);const c=t.context?.designSystem;c&&O(c);try{const r={};let s=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||$.has(o))continue;const i=o.charCodeAt(0);if(!(i>=65&&i<=90)&&!T(o)){if(j[o]){const f=t[o],a=j[o](f,t,t.state,t.context);if(a){if(Array.isArray(a))for(const e of a)e&&Object.assign(r,e);else Object.assign(r,a);s=!0}}else if(C&&C.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,s=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,s=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(r[o]=f,s=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const a={};for(const e in f){let d=f[e];if(typeof d=="function"&&(d=d(t,t.state,t.context)),!(d==null||typeof d=="function"))if(j[e]){const h=j[e](d,t,t.state,t.context);if(h)if(Array.isArray(h))for(const x of h)x&&Object.assign(a,x);else Object.assign(a,h)}else a[e]=d}if(Object.keys(a).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const d={};for(const x in a){const p=a[x];d[x]=typeof p=="string"&&!p.includes("!important")?p+" !important":p}const h=o.slice(1);r[`[data-theme="${h}"] &`]=d}else{let d=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const x=o.slice(1),p=t.context?.designSystem?.media?.[x]||t.context?.designSystem?.media?.[x];p&&(d=`@media ${p}`)}const h={};for(const x in a){const p=a[x];if(p&&typeof p=="object"&&!Array.isArray(p)){const l={};for(const u in p)if(j[u]){const b=j[u](p[u],t,t.state,t.context);if(b)if(Array.isArray(b))for(const g of b)g&&Object.assign(l,g);else Object.assign(l,b)}else l[u]=p[u];const y=x.startsWith(":")?"":" ";if(d.includes(",")){const u=d.split(",").map(b=>`${b.trim()}${y}${x}`).join(", ");r[u]=l}else r[`${d}${y}${x}`]=l}else h[x]=p}Object.keys(h).length&&(r[d]=h)}s=!0}s=!0}}}}if(s){r.display&&String(r.display).includes("!important")&&(n.style.setProperty("display",String(r.display).replace(/\s*!important\s*$/,""),"important"),delete r.display);const o=pt(r,null,t.context?.cssPrefix);if(o&&n.classList){const f=o.split(" ").filter(Boolean);let a=!1;for(const e of f)n.classList.add(e),a||(e.charCodeAt(0)===95&&e.charCodeAt(1)===99||e.charCodeAt(0)===95&&e.indexOf("_c",1)!==-1)&&(a=!0);a&&typeof n.offsetWidth=="number"&&n.offsetWidth}const i=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(i!=null){const f=r.display;if(f&&f!==i)if(i==="none"){const a=[];for(const e of n.classList)e.startsWith("_d-")&&e!=="_d-none"&&a.push(e);for(const e of a)n.classList.remove(e);n.classList.add("_d-none")}else n.style.display=t.display}}}finally{c&&E(),Q.delete(t)}}function nt(t){const{node:n}=t;if(!n||!n.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const i="aria-"+s.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());n.setAttribute(i,o===!0?"":o)}const c=yt(t);for(const s in c){const o=c[s];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&n.setAttribute(s,o===!0?"":o)}const r=t.tag||"div";for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||typeof t[s]=="function"||$.has(s)||s==="on"||c[s]!==void 0)continue;const o=s.charCodeAt(0);if(!(o>=65&&o<=90)&&!T(s)&&!(j[s]||C&&C.has(s))&&B(r,s)){let i=t[s];if(i==null||i===!1||(typeof i=="string"&&i.includes("{{")&&(i=Z(i,t,t.state,t.context),t[s]=i),i==null||i===!1||typeof i=="function"||typeof i=="object"))continue;n.setAttribute(s,i===!0?"":i)}}}function it(t,n){for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||!T(c))continue;let r=t[c];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(f){return t.call(o,f)}}if(typeof r!="function")continue;const s=ht(c);at.has(s)||et(xt(s),t,r)}}function U(t,n){const c={...t};for(const r in n){const s=c[r],o=n[r];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?c[r]=U(s,o):c[r]=o}return c}function J(t,n,c){if(!n||!t.node)return;const r=t.childExtends;if(Array.isArray(n)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const i=t.childProps,f=t.childrenAs;for(let a=0;a<n.length;a++){let e=n[a];const d=e;(typeof e=="string"||typeof e=="number")&&(e={text:e});let h=i;if(typeof i=="function")try{h=i(t,e)}catch{h=null}if(f==="state"){let l=d;(typeof d=="string"||typeof d=="number")&&(l={value:d,text:d}),e=h?{...h,state:l}:{state:l}}else h&&(e=U(h,e));if(r&&!e.ignoreChildExtends)if(e.extends){const l=Array.isArray(e.extends)?e.extends:[e.extends],y=Array.isArray(r)?r:[r];e={...e,extends:[...y,...l]}}else e={extends:r,...e};const x=e?.key||`${a}`,p=F(e,t,x,c);p?.node&&o.appendChild(p.node)}t.node.appendChild(o);return}if(typeof n=="string"){const s=ct(n,t);if(Array.isArray(s)){J(t,s,c);return}}if(typeof n=="object")for(const s in n){if($.has(s))continue;let o=n[s];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=U(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const i=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(r)?r:[r];o={...o,extends:[...f,...i]}}else o={extends:r,...o};F(o,t,s,c)}}}function rt(t,n){let{children:c,content:r}=t;const s=t.childExtends;if(typeof c=="function"){const i=c;c=i(t,t.state,t.context),t.children=c;const f=t.__ref;let a=!1;const e=A(()=>{const d=i(t,t.state,t.context);if(!a){a=!0;return}if(d===t.children)return;if(t.children=d,Array.isArray(d)&&t.childrenAs==="state"){const p=t.childProps,l=[],y=new Map;for(let v=0;v<d.length;v++){const S=d[v];let _=p;if(typeof p=="function")try{_=p(t,S)}catch{_=null}const R=_&&_.key||S&&S.key||`${v}`;l.push(R),y.set(R,{rawChild:S,childProps:_})}const u=new Set(l),b=f.__children.slice();for(const v of b)if(!u.has(v)){const S=t[v];S?.remove&&S.remove(),delete t[v]}const g=t.childExtends,L=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const v of l){const S=y.get(v),_=S.rawChild,R=t[v];if(R&&R.state){if(_&&typeof _=="object"){const w=R.state;if(typeof w.replace=="function")w.replace(_);else if(typeof w.update=="function"){for(const k in w)if(!(k==="__element"||k==="root"||k==="parent"||k==="update")&&!Object.prototype.hasOwnProperty.call(_,k))try{w[k]=void 0}catch{}w.update(_)}else for(const k in _)w[k]=_[k]}continue}let M=_;(typeof _=="string"||typeof _=="number")&&(M={value:_,text:_});const m=S.childProps;let P=m?{...m,state:M}:{state:M};if(g&&!P.ignoreChildExtends)if(P.extends){const w=Array.isArray(P.extends)?P.extends:[P.extends],k=Array.isArray(g)?g:[g];P={...P,extends:[...k,...w]}}else P={extends:g,...P};const tt=F(P,t,v,n);tt?.node&&L&&L.appendChild(tt.node)}L&&L.childNodes.length&&t.node&&t.node.appendChild(L),f.__children=l;return}for(const p of[...f.__children]){const l=t[p];l?.remove&&l.remove(),delete t[p]}f.__children=[],J(t,d,n)},{depth:f.path.length});f.__effects.push(e)}if(J(t,c||r,n),c||r)return;const o=t.context?.components||{};{const i=Object.keys(t);for(let f=0;f<i.length;f++){const a=i[f];if(!a.endsWith("Extends")||typeof t[a]!="string")continue;const e=a.slice(0,-7);if(!e||e.charCodeAt(0)<65||e.charCodeAt(0)>90)continue;const d={extends:t[a]};delete t[a];for(let h=f+1;h<i.length;h++){const x=i[h],p=x.charCodeAt(0);if(p>=65&&p<=90||$.has(x)||typeof t[x]=="function"&&(x.startsWith("on")||x.startsWith(".")))break;const l=t[x];l!==void 0&&(d[x]=l,delete t[x])}t[e]&&typeof t[e]=="object"?t[e]={...d,...t[e]}:t[e]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||$.has(i)||typeof t[i]!="object"||t[i]===null)continue;const f=i.charCodeAt(0);if(f<65||f>90)continue;let a=t[i];if(!a.__ref){if(!a.extends&&!a.extend){const e=o[i]||o[`smbls.${i}`];e&&(a={extends:e,...a})}if(t.childProps&&(a={...t.childProps,...a}),s&&!a.ignoreChildExtends)if(a.extends){const e=Array.isArray(a.extends)?a.extends:[a.extends],d=Array.isArray(s)?s:[s];a={...a,extends:[...d,...e]}}else a={extends:s,...a};F(a,t,i,n)}}}function X(t,n,c){const{node:r}=t;if(!r)return;const s=n?.node||(n?.nodeType?n:null);if(s)if(c?.position==="before"&&c.node)s.insertBefore(r,c.node);else if(c?.position==="after"&&c.node){const o=c.node.nextSibling;o?s.insertBefore(r,o):s.appendChild(r)}else s.appendChild(r)}function N(t,n,c){const r=t.charAt(0).toLowerCase()+t.slice(1);n.context?.plugins?.length&&st(r,n,c);const s="on"+t,o=n[s];if(typeof o=="function"){const i=n.context?.designSystem;i&&O(i);try{if(o(n,n.state,n.context,c)===!1)return!1}catch(f){if(n.context?.plugins?.length&&st("error",n,{hook:s,error:f})||console.error(`[DOMQL] Lifecycle "${s}" error:`,f),n.context?.strictMode)throw f}finally{i&&E()}}return!0}var Wt=F;export{F as create,Wt as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/element",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.20",
|
|
4
4
|
"description": "Core element creation, update, and disposal engine for smbls v3.14",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@symbo.ls/signal": "^3.14.12",
|
|
25
25
|
"@symbo.ls/state": "^3.14.14",
|
|
26
|
-
"@symbo.ls/utils": "^3.14.
|
|
27
|
-
"css-in-props": "^3.14.
|
|
28
|
-
"attrs-in-props": "^3.14.
|
|
26
|
+
"@symbo.ls/utils": "^3.14.19",
|
|
27
|
+
"css-in-props": "^3.14.9",
|
|
28
|
+
"attrs-in-props": "^3.14.9"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|