@tenoxui/moxie 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var x=(m,t,s)=>t in m?Z(m,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):m[t]=s,P=(m,t)=>{for(var s in t||(t={}))_.call(t,s)&&x(m,s,t[s]);if(W)for(var s of W(t))w.call(t,s)&&x(m,s,t[s]);return m};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:t={},values:s={},classes:e={}}={}){this.property=P({moxie:({key:n,secondValue:r})=>r?null:n},t),this.values=s,this.classes=e}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const s=t.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${t.slice(e.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const s=new Set;return Object.entries(t).forEach(([e,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,n=Object.keys(s);if(!e)return[...n,...t].sort((i,l)=>l.length-i.length);const c=[...this.getAllClassNames(e)];return[...n,...c,...t].sort((i,l)=>l.length-i.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+n+"|"+r+"))|"+e+"|"+n+"|"+r,i=`(${s}|\\[[^\\]]+\\])`,l="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",a="([a-zA-Z%]*)",o="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:i,separator:l,value:u,unit:a,secondValuePattern:o,all:"(?:("+c+"):)?"+i+l+u+a+o}}parse(t,s){const e=this.regexp(s),n=t.match(new RegExp(e.all));if(n){const[,c,i,l,u,a,o]=n,$=`${c?`${c}:`:""}${i}-${l}${u}${a?`/${a}${o}`:""}`;return[c,i,l,u||"",a,o,$]}const r=t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}processValue(t,s,e){if(!t)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(c,i)=>{const l=this.values,u=l!==null?typeof l[e]=="object"?l[e][i]:l[i]:void 0;return typeof u=="string"?u:c});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][t]||this.values[t]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",n,r="",c="",i){const l=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let a=null,o=s||"";const $=o.match(u);if($&&(a=$[1].trim(),o=$[2].trim()),(typeof l=="string"||Array.isArray(l))&&(!s||s.includes(a+":")||r))return null;let h;s.includes(a+":")?h=s.startsWith("(")?`(${o})`:`[${o}]`:h=s;const y=this.processValue(h,e,t),p=this.processValue(r,c,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const f=t.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:y,prefix:n}}if(l){if(typeof l=="object"&&"property"in l){const b=l.group&&this.values[l.group][y]?this.values[l.group][y]:e?s:y,g=typeof l.property=="function"?l.property({value:s.startsWith("[")?y:b,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):l.property,d=l.value||"{0}";let C;if(typeof d=="function")C=d({value:b,unit:e,secondValue:c?r:p,secondUnit:c,key:a,raw:i});else if(typeof d=="string"){const A=l.group||t,V=this.processValue(h,e,A);this.values[A]&&typeof this.values[A]=="object"&&this.values[A][h]?C=this.values[A][h]:d.includes("{")?C=this.parseValuePattern(A,d,V,"",p,""):C=y}else if(Array.isArray(d)){if(!d.includes(s+e)||r)return null;C=s+e}else C=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof l.property=="string"&&typeof d=="string"&&(s.includes(a+":")||!d.includes("{1")&&r)?null:{className:j,cssRules:g?Array.isArray(g)?g:typeof g=="string"&&(g.includes(":")||g.includes("value:"))?g.includes("value:")?g.slice(6):this.toKebabCase(String(g)):this.toKebabCase(String(g)):null,value:d===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?y:C,prefix:n}}const f=typeof l=="function"?l({value:s.startsWith("[")?y:e?s:y,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):l;return{className:`${t}${s?"-"+s+e:""}${r?`/${r}${c}`:""}`,cssRules:f?Array.isArray(l)?f:typeof f=="string"&&(f.includes(":")||f.startsWith("value:"))?f.startsWith("value:")?f.slice(6):this.toKebabCase(String(f)):this.toKebabCase(String(f)):null,value:typeof f=="string"&&f.includes(":")?null:y,prefix:n}}return null}parseValuePattern(t,s,e,n,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[i,l]=s.split("||").map(o=>o.trim()),u=this.processValue(e,n,t),a=this.processValue(r,c,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let o=i;if(e&&(o=o.replace("{0}",u)),s.includes("{1")){const $=o.match(/{1([^}]*)}/);if(s.includes("{1}"))r?o=r.startsWith("[")?a:o.replace("{1}",a):o=l;else if($){const h=$[0],y=$[1].trim();let p=a;!p&&y.includes("|")?p=y.split("|")[1].trim():p||(p=""),o=e.startsWith("[")?u:o.replace(h,p)}}return e?o:l||i}else return e?e.startsWith("[")?u:i.replace("{0}",u):l||i}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",n="",r="",c=""){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const l=i.map(o=>{const $=this.classes[o];if(!$||s&&!$[t].includes("||")||s&&!$[t].includes("|"))return null;const h=this.parseValuePattern(t,$[t]||"",s,e,r,c);return`${this.toKebabCase(String(o))}: ${h}`}).filter(Boolean).join("; "),u=t.slice(-(s+e).length),a=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return{className:s===u?t:a,cssRules:l,value:null,prefix:n}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const n of s)try{if(!n)continue;const r=this.parse(n);if(!r)continue;const[c,i,l,u,a,o]=r;if(!i)continue;const $=this.getParentClass(`${i}-${l}`).length>0?`${i}-${l}`:i;try{const h=this.processCustomClass($,l,u,c,a,o);if(h){const{className:y,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:y,cssRules:p,value:null,prefix:f,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${n}":`,h)}try{const h=this.processShorthand(i,l,u,c,a,o,r);if(h){const{className:y,cssRules:p,value:f,prefix:b}=h;if(!p||p==="null")continue;e.push({className:y,cssRules:p,value:f,prefix:b,raw:r})}}catch(h){console.warn(`Error processing shorthand "${n}":`,h)}}catch(r){console.warn(`Failed to process class \`${n}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}exports.TenoxUI=S;exports.default=S;
1
+ "use strict";var R=Object.defineProperty;var W=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var P=($,s,t)=>s in $?R($,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):$[s]=t,x=($,s)=>{for(var t in s||(s={}))j.call(s,t)&&P($,t,s[t]);if(W)for(var t of W(s))V.call(s,t)&&P($,t,s[t]);return $};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:s={},values:t={},classes:e={}}={}){this.property=x({moxie:({key:l,secondValue:r})=>r?null:l},s),this.values=t,this.classes=e}toKebabCase(s){if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const t=s.match(/^(webkit|moz|ms|o)/);if(t){const e=t[0];return`-${e}${s.slice(e.length).replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`}}return s.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}escapeCSSSelector(s){return s.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(s){if(!s)return[];const t=new Set;return Object.entries(s).forEach(([e,l])=>{l&&typeof l=="object"&&Object.keys(l).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(s=[]){const t=this.property,e=this.classes,l=Object.keys(t);if(!e)return[...l,...s].sort((i,n)=>n.length-i.length);const o=[...this.getAllClassNames(e)];return[...l,...o,...s].sort((i,n)=>n.length-i.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",l="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",o="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+l+"|"+r+"))|"+e+"|"+l+"|"+r,i=`(${t}|\\[[^\\]]+\\])`,n="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:o,type:i,separator:n,value:h,unit:u,secondValuePattern:c,all:"(?:("+o+"):)?"+i+n+h+u+c}}parse(s,t){const e=this.regexp(t),l=s.match(new RegExp(e.all));if(l){const[,o,i,n,h,u,c]=l;return[o,i,n,h||"",u,c]}const r=s.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,s]:null}constructRaw(s,t,e,l,r,o){return`${s?`${s}:`:""}${t}${e?"-":""}${e}${l}${r?`/${r}${o}`:""}`}processValue(s,t,e){if(!s)return"";const l=r=>r.replace(/\{([^}]+)\}/g,(o,i)=>{const n=this.values,h=n!==null?typeof n[e]=="object"?n[e][i]:n[i]:void 0;return typeof h=="string"?h:o});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][s]||this.values[s]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const r=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?l(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",l,r="",o="",i){const n=this.property[s];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,c=t||"";const m=c.match(h);if(m&&(u=m[1].trim(),c=m[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(u+":")||r))return null;let f;t.includes(u+":")?f=t.startsWith("(")?`(${c})`:`[${c}]`:f=t;const p=this.processValue(f,e,s),y=this.processValue(r,o,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const a=s.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:this.constructRaw(l,s,t,e),cssRules:a.length===1?a[0]:a,value:p,prefix:l}}if(n){if(typeof n=="object"&&"property"in n){const b=n.group&&this.values[n.group][p]?this.values[n.group][p]:e?t:p,g=typeof n.property=="function"?n.property({value:t.startsWith("[")?p:b,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":o?r:y,secondUnit:t.startsWith("[")?"":o,key:u,raw:i}):n.property,d=n.value||"{0}";let A;if(typeof d=="function")A=d({value:b,unit:e,secondValue:o?r:y,secondUnit:o,key:u,raw:i});else if(typeof d=="string"){const C=n.group||s,w=this.processValue(f,e,C);this.values[C]&&typeof this.values[C]=="object"&&this.values[C][f]?A=this.values[C][f]:d.includes("{")?A=this.parseValuePattern(C,d,w,"",y,""):A=p}else if(Array.isArray(d)){if(!d.includes(t+e)||r)return null;A=t+e}else A=null;return typeof n.property=="string"&&typeof d=="string"&&(t.includes(u+":")||!d.includes("{1")&&r)?null:{className:this.constructRaw(l,s,t,e,r,o),cssRules:g?Array.isArray(g)?g:typeof g=="string"&&(g.includes(":")||g.includes("value:"))?g.includes("value:")?g.slice(6):this.toKebabCase(String(g)):this.toKebabCase(String(g)):null,value:d===null||g===null||g.includes(":")||g.includes("value:")?null:t.startsWith("[")?p:A,prefix:l}}const a=typeof n=="function"?n({value:t.startsWith("[")?p:e?t:p,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":o?r:y,secondUnit:t.startsWith("[")?"":o,key:u,raw:i}):n;return{className:this.constructRaw(l,s,t,e,r,o),cssRules:a?Array.isArray(n)?a:typeof a=="string"&&(a.includes(":")||a.startsWith("value:"))?a.startsWith("value:")?a.slice(6):this.toKebabCase(String(a)):this.toKebabCase(String(a)):null,value:typeof a=="string"&&a.includes(":")?null:p,prefix:l}}return null}parseValuePattern(s,t,e,l,r,o){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[i,n]=t.split("||").map(c=>c.trim()),h=this.processValue(e,l,s),u=this.processValue(r,o,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let c=i;if(e&&(c=c.replace(/\{0\}/g,h)),t.includes("{1")){t.includes("{1}")&&(r?c=r.startsWith("[")?u:c.replace(/\{1\}/g,u):c=n||i);const m=/\{1([^}]*)\}/g;let f;for(;(f=m.exec(c))!==null;){const p=f[0],y=f[1].trim();let a=u;!a&&y.includes("|")?a=y.split("|")[1].trim():a||(a=""),c=e.startsWith("[")?h:c.replace(p,a)}}return e?c:n||i}else return e?e.startsWith("[")?h:i.replace(/\{0\}/g,h):n||i}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",e="",l="",r="",o=""){if(!s)return null;const i=this.getParentClass(s);if(i.length>0){const n=i.map(u=>{const c=this.classes[u];if(!c||t&&!c[s].includes("||")||t&&!c[s].includes("|"))return null;const m=this.parseValuePattern(s,c[s]||"",t,e,r,o);return`${this.toKebabCase(String(u))}: ${m}`}).filter(Boolean).join("; "),h=s.slice(-(t+e).length);return{className:t===h?s:this.constructRaw(l,s,t,e,r,o),cssRules:n,value:null,prefix:l}}return null}process(s){try{const t=Array.isArray(s)?s:s.split(/\s+/),e=[];for(const l of t)try{if(!l)continue;const r=this.parse(l);if(!r)continue;const[o,i,n,h,u,c]=r;if(!i)continue;const m=this.getParentClass(`${i}-${n}`).length>0?`${i}-${n}`:i;try{const f=this.processCustomClass(m,n,h,o,u,c);if(f){const{className:p,cssRules:y,prefix:a}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:null,prefix:a,raw:[...r,this.constructRaw(a,i,n,h,u,c)]});continue}}catch(f){console.warn(`Error processing custom class "${l}":`,f)}try{const f=this.processShorthand(i,n,h,o,u,c,r);if(f){const{className:p,cssRules:y,value:a,prefix:b}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:a,prefix:b,raw:[...r,this.constructRaw(o,i,n,h,u,c)]})}}catch(f){console.warn(`Error processing shorthand "${l}":`,f)}}catch(r){console.warn(`Failed to process class \`${l}\`:`,r)}return e}catch(t){return console.error("Critical error in process method:",t),[]}}}exports.TenoxUI=S;exports.default=S;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export declare class TenoxUI {
18
18
  all: string;
19
19
  };
20
20
  parse(className: string, safelist?: string[]): Parsed;
21
+ constructRaw(prefix: null | undefined | string, type: string, value?: null | string, unit?: null | string, secValue?: null | string, secUnit?: null | string): string;
21
22
  processValue(value: string, unit: string, group: string): string;
22
23
  processShorthand(type: string | undefined, value: string | undefined, unit: string | undefined, prefix: string | undefined, secondValue?: string | undefined, secondUnit?: string | undefined, raw?: Parsed): ProcessedStyle | null;
23
24
  private parseValuePattern;
package/dist/index.es.js CHANGED
@@ -1,20 +1,20 @@
1
- var V = Object.defineProperty;
1
+ var S = Object.defineProperty;
2
2
  var W = Object.getOwnPropertySymbols;
3
- var Z = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
4
- var x = (m, t, s) => t in m ? V(m, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : m[t] = s, P = (m, t) => {
3
+ var R = Object.prototype.hasOwnProperty, V = Object.prototype.propertyIsEnumerable;
4
+ var P = ($, t, s) => t in $ ? S($, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : $[t] = s, x = ($, t) => {
5
5
  for (var s in t || (t = {}))
6
- Z.call(t, s) && x(m, s, t[s]);
6
+ R.call(t, s) && P($, s, t[s]);
7
7
  if (W)
8
8
  for (var s of W(t))
9
- w.call(t, s) && x(m, s, t[s]);
10
- return m;
9
+ V.call(t, s) && P($, s, t[s]);
10
+ return $;
11
11
  };
12
- class R {
12
+ class Z {
13
13
  constructor({ property: t = {}, values: s = {}, classes: e = {} } = {}) {
14
- this.property = P({
14
+ this.property = x({
15
15
  // use moxie-* utility to access all properties and variables
16
16
  // e.g. `moxie-(color:red)` => `color: red`, `moxie-(--my-var:20px_1rem)` => `--my-var: 20px 1rem`
17
- moxie: ({ key: i, secondValue: r }) => r ? null : i
17
+ moxie: ({ key: l, secondValue: r }) => r ? null : l
18
18
  }, t), this.values = s, this.classes = e;
19
19
  }
20
20
  toKebabCase(t) {
@@ -22,7 +22,7 @@ class R {
22
22
  const s = t.match(/^(webkit|moz|ms|o)/);
23
23
  if (s) {
24
24
  const e = s[0];
25
- return `-${e}${t.slice(e.length).replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`)}`;
25
+ return `-${e}${t.slice(e.length).replace(/[A-Z]/g, (l) => `-${l.toLowerCase()}`)}`;
26
26
  }
27
27
  }
28
28
  return t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
@@ -33,53 +33,56 @@ class R {
33
33
  getAllClassNames(t) {
34
34
  if (!t) return [];
35
35
  const s = /* @__PURE__ */ new Set();
36
- return Object.entries(t).forEach(([e, i]) => {
37
- i && typeof i == "object" && Object.keys(i).forEach((r) => {
36
+ return Object.entries(t).forEach(([e, l]) => {
37
+ l && typeof l == "object" && Object.keys(l).forEach((r) => {
38
38
  s.add(r);
39
39
  });
40
40
  }), Array.from(s);
41
41
  }
42
42
  getTypePrefixes(t = []) {
43
- const s = this.property, e = this.classes, i = Object.keys(s);
43
+ const s = this.property, e = this.classes, l = Object.keys(s);
44
44
  if (!e)
45
- return [...i, ...t].sort((l, n) => n.length - l.length);
46
- const c = [...this.getAllClassNames(e)];
47
- return [...i, ...c, ...t].sort((l, n) => n.length - l.length);
45
+ return [...l, ...t].sort((i, n) => n.length - i.length);
46
+ const a = [...this.getAllClassNames(e)];
47
+ return [...l, ...a, ...t].sort((i, n) => n.length - i.length);
48
48
  }
49
49
  regexp(t) {
50
- const s = this.getTypePrefixes(t).join("|"), e = "\\[[^\\]]+\\]", i = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", c = (
50
+ const s = this.getTypePrefixes(t).join("|"), e = "\\[[^\\]]+\\]", l = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", a = (
51
51
  // Simple prefix (hover, md, focus, etc.)
52
- "[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:" + e + "|" + i + "|" + r + "))|" + // Direct bracket, parenthesis, or brace content
53
- e + "|" + i + "|" + r
54
- ), l = `(${s}|\\[[^\\]]+\\])`, n = "(?:-)", u = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
52
+ "[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:" + e + "|" + l + "|" + r + "))|" + // Direct bracket, parenthesis, or brace content
53
+ e + "|" + l + "|" + r
54
+ ), i = `(${s}|\\[[^\\]]+\\])`, n = "(?:-)", h = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
55
55
  e + "|" + // Bracket content
56
56
  r + "|" + // Curly brace content
57
- i + "|(?:\\$[^\\s\\/]+))", o = "([a-zA-Z%]*)", a = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + e + "|" + r + "|" + i + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
57
+ l + "|(?:\\$[^\\s\\/]+))", u = "([a-zA-Z%]*)", c = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + e + "|" + r + "|" + l + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
58
58
  return {
59
- prefix: c,
60
- type: l,
59
+ prefix: a,
60
+ type: i,
61
61
  separator: n,
62
- value: u,
63
- unit: o,
64
- secondValuePattern: a,
65
- all: "(?:(" + c + "):)?" + l + n + u + o + a
62
+ value: h,
63
+ unit: u,
64
+ secondValuePattern: c,
65
+ all: "(?:(" + a + "):)?" + i + n + h + u + c
66
66
  };
67
67
  }
68
68
  parse(t, s) {
69
- const e = this.regexp(s), i = t.match(new RegExp(e.all));
70
- if (i) {
71
- const [, c, l, n, u, o, a] = i, $ = `${c ? `${c}:` : ""}${l}-${n}${u}${o ? `/${o}${a}` : ""}`;
72
- return [c, l, n, u || "", o, a, $];
69
+ const e = this.regexp(s), l = t.match(new RegExp(e.all));
70
+ if (l) {
71
+ const [, a, i, n, h, u, c] = l;
72
+ return [a, i, n, h || "", u, c];
73
73
  }
74
74
  const r = t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));
75
75
  return r ? [r[1], r[2], "", "", void 0, void 0, t] : null;
76
76
  }
77
+ constructRaw(t, s, e, l, r, a) {
78
+ return `${t ? `${t}:` : ""}${s}${e ? "-" : ""}${e}${l}${r ? `/${r}${a}` : ""}`;
79
+ }
77
80
  // unique value parser
78
81
  processValue(t, s, e) {
79
82
  if (!t) return "";
80
- const i = (r) => r.replace(/\{([^}]+)\}/g, (c, l) => {
81
- const n = this.values, u = n !== null ? typeof n[e] == "object" ? n[e][l] : n[l] : void 0;
82
- return typeof u == "string" ? u : c;
83
+ const l = (r) => r.replace(/\{([^}]+)\}/g, (a, i) => {
84
+ const n = this.values, h = n !== null ? typeof n[e] == "object" ? n[e][i] : n[i] : void 0;
85
+ return typeof h == "string" ? h : a;
83
86
  });
84
87
  if (typeof this.values == "object" && this.values !== null && (this.values[e] && typeof this.values[e] == "object" && this.values[e][t] || this.values[t]))
85
88
  return typeof this.values[e] == "object" && this.values[e] !== null ? this.values[e][t] : this.values[t];
@@ -87,42 +90,45 @@ class R {
87
90
  return `var(--${t.slice(1)})`;
88
91
  if (t.startsWith("[") && t.endsWith("]") || t.startsWith("(") && t.endsWith(")")) {
89
92
  const r = t.slice(1, -1).replace(/\\\_/g, "m0x13c55").replace(/\_/g, " ").replace(/m0x13c55/g, "_");
90
- return r.includes("{") ? i(r) : r.startsWith("--") ? `var(${r})` : r;
93
+ return r.includes("{") ? l(r) : r.startsWith("--") ? `var(${r})` : r;
91
94
  }
92
95
  return t + (s || "");
93
96
  }
94
- processShorthand(t = "", s = "", e = "", i, r = "", c = "", l) {
95
- const n = this.property[t], u = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
96
- let o = null, a = s || "";
97
- const $ = a.match(u);
98
- if ($ && (o = $[1].trim(), a = $[2].trim()), (typeof n == "string" || Array.isArray(n)) && (!s || s.includes(o + ":") || r))
97
+ processShorthand(t = "", s = "", e = "", l, r = "", a = "", i) {
98
+ const n = this.property[t];
99
+ if (typeof n == "object" && !Array.isArray(n) && !("property" in n))
100
+ return null;
101
+ const h = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
102
+ let u = null, c = s || "";
103
+ const m = c.match(h);
104
+ if (m && (u = m[1].trim(), c = m[2].trim()), (typeof n == "string" || Array.isArray(n)) && (!s || s.includes(u + ":") || r))
99
105
  return null;
100
- let h;
101
- s.includes(o + ":") ? h = s.startsWith("(") ? `(${a})` : `[${a}]` : h = s;
102
- const y = this.processValue(h, e, t), p = this.processValue(r, c, t);
106
+ let f;
107
+ s.includes(u + ":") ? f = s.startsWith("(") ? `(${c})` : `[${c}]` : f = s;
108
+ const p = this.processValue(f, e, t), y = this.processValue(r, a, t);
103
109
  if (t.startsWith("[") && t.endsWith("]")) {
104
110
  if (!s || r) return null;
105
- const f = t.slice(1, -1).split(",").map(
106
- (C) => C.trim().startsWith("--") ? String(C.trim()) : this.toKebabCase(String(C.trim()))
111
+ const o = t.slice(1, -1).split(",").map(
112
+ (A) => A.trim().startsWith("--") ? String(A.trim()) : this.toKebabCase(String(A.trim()))
107
113
  );
108
114
  return {
109
- className: `${t}-${s}${e}`,
110
- cssRules: f.length === 1 ? f[0] : f,
111
- value: y,
112
- prefix: i
115
+ className: this.constructRaw(l, t, s, e),
116
+ cssRules: o.length === 1 ? o[0] : o,
117
+ value: p,
118
+ prefix: l
113
119
  };
114
120
  }
115
121
  if (n) {
116
122
  if (typeof n == "object" && "property" in n) {
117
- const C = n.group && this.values[n.group][y] ? this.values[n.group][y] : e ? s : y, g = (
123
+ const A = n.group && this.values[n.group][p] ? this.values[n.group][p] : e ? s : p, g = (
118
124
  // handle `properties.property` function
119
125
  typeof n.property == "function" ? n.property({
120
- value: s.startsWith("[") ? y : C,
126
+ value: s.startsWith("[") ? p : A,
121
127
  unit: s.startsWith("[") ? "" : e,
122
- secondValue: s.startsWith("[") ? "" : c ? r : p,
123
- secondUnit: s.startsWith("[") ? "" : c,
124
- key: o,
125
- raw: l
128
+ secondValue: s.startsWith("[") ? "" : a ? r : y,
129
+ secondUnit: s.startsWith("[") ? "" : a,
130
+ key: u,
131
+ raw: i
126
132
  }) : (
127
133
  // defaulting to string property
128
134
  // e.g. { property: { p: { property: 'padding', value: '{0} {1}' } }
@@ -134,30 +140,29 @@ class R {
134
140
  let b;
135
141
  if (typeof d == "function")
136
142
  b = d({
137
- value: C,
143
+ value: A,
138
144
  unit: e,
139
- secondValue: c ? r : p,
140
- secondUnit: c,
141
- key: o,
142
- raw: l
145
+ secondValue: a ? r : y,
146
+ secondUnit: a,
147
+ key: u,
148
+ raw: i
143
149
  });
144
150
  else if (typeof d == "string") {
145
- const A = n.group || t, S = this.processValue(h, e, A);
146
- this.values[A] && typeof this.values[A] == "object" && this.values[A][h] ? b = this.values[A][h] : d.includes("{") ? b = this.parseValuePattern(
147
- A,
151
+ const C = n.group || t, w = this.processValue(f, e, C);
152
+ this.values[C] && typeof this.values[C] == "object" && this.values[C][f] ? b = this.values[C][f] : d.includes("{") ? b = this.parseValuePattern(
153
+ C,
148
154
  d,
149
- S,
155
+ w,
150
156
  "",
151
- p,
157
+ y,
152
158
  ""
153
- ) : b = y;
159
+ ) : b = p;
154
160
  } else if (Array.isArray(d)) {
155
161
  if (!d.includes(s + e) || r) return null;
156
162
  b = s + e;
157
163
  } else b = null;
158
- const j = `${t}${s ? `-${s}${e}` : ""}${r ? `/${r}${c}` : ""}`;
159
- return typeof n.property == "string" && typeof d == "string" && (s.includes(o + ":") || !d.includes("{1") && r) ? null : {
160
- className: j,
164
+ return typeof n.property == "string" && typeof d == "string" && (s.includes(u + ":") || !d.includes("{1") && r) ? null : {
165
+ className: this.constructRaw(l, t, s, e, r, a),
161
166
  cssRules: (
162
167
  // if not property, or when `properties.property` as function return null
163
168
  g ? Array.isArray(g) ? g : (
@@ -168,22 +173,22 @@ class R {
168
173
  )
169
174
  ) : null
170
175
  ),
171
- value: d === null || g === null || g.includes(":") || g.includes("value:") ? null : s.startsWith("[") ? y : b,
172
- prefix: i
176
+ value: d === null || g === null || g.includes(":") || g.includes("value:") ? null : s.startsWith("[") ? p : b,
177
+ prefix: l
173
178
  };
174
179
  }
175
- const f = (
180
+ const o = (
176
181
  // handle `properties` as function
177
182
  // e.g. m: ({ value, unit }) => `margin: ${value}${unit || 'px'}`
178
183
  // m-4 => margin: 4px
179
184
  // m-4rem => margin: 4rem
180
185
  typeof n == "function" ? n({
181
- value: s.startsWith("[") ? y : e ? s : y,
186
+ value: s.startsWith("[") ? p : e ? s : p,
182
187
  unit: s.startsWith("[") ? "" : e,
183
- secondValue: s.startsWith("[") ? "" : c ? r : p,
184
- secondUnit: s.startsWith("[") ? "" : c,
185
- key: o,
186
- raw: l
188
+ secondValue: s.startsWith("[") ? "" : a ? r : y,
189
+ secondUnit: s.startsWith("[") ? "" : a,
190
+ key: u,
191
+ raw: i
187
192
  }) : (
188
193
  // e.g. { property: { bg: 'background' } }
189
194
  // the `bg` is the type or the shorthand for `background` property
@@ -191,33 +196,33 @@ class R {
191
196
  )
192
197
  );
193
198
  return {
194
- className: `${t}${s ? "-" + s + e : ""}${r ? `/${r}${c}` : ""}`,
195
- cssRules: f ? Array.isArray(n) ? f : typeof f == "string" && (f.includes(":") || f.startsWith("value:")) ? f.startsWith("value:") ? f.slice(6) : this.toKebabCase(String(f)) : this.toKebabCase(String(f)) : null,
196
- value: typeof f == "string" && f.includes(":") ? null : y,
197
- prefix: i
199
+ className: this.constructRaw(l, t, s, e, r, a),
200
+ cssRules: o ? Array.isArray(n) ? o : typeof o == "string" && (o.includes(":") || o.startsWith("value:")) ? o.startsWith("value:") ? o.slice(6) : this.toKebabCase(String(o)) : this.toKebabCase(String(o)) : null,
201
+ value: typeof o == "string" && o.includes(":") ? null : p,
202
+ prefix: l
198
203
  };
199
204
  }
200
205
  return null;
201
206
  }
202
- parseValuePattern(t, s, e, i, r, c) {
207
+ parseValuePattern(t, s, e, l, r, a) {
203
208
  if (!s.includes("{0}") && !s.includes("{1") && !s.includes("||"))
204
209
  return s;
205
- const [l, n] = s.split("||").map((a) => a.trim()), u = this.processValue(e, i, t), o = this.processValue(r, c, t);
210
+ const [i, n] = s.split("||").map((c) => c.trim()), h = this.processValue(e, l, t), u = this.processValue(r, a, t);
206
211
  if (s.includes("{0}") && s.includes("{1") || s.includes("{1")) {
207
- let a = l;
208
- if (e && (a = a.replace("{0}", u)), s.includes("{1")) {
209
- const $ = a.match(/{1([^}]*)}/);
210
- if (s.includes("{1}"))
211
- r ? a = r.startsWith("[") ? o : a.replace("{1}", o) : a = n;
212
- else if ($) {
213
- const h = $[0], y = $[1].trim();
214
- let p = o;
215
- !p && y.includes("|") ? p = y.split("|")[1].trim() : p || (p = ""), a = e.startsWith("[") ? u : a.replace(h, p);
212
+ let c = i;
213
+ if (e && (c = c.replace(/\{0\}/g, h)), s.includes("{1")) {
214
+ s.includes("{1}") && (r ? c = r.startsWith("[") ? u : c.replace(/\{1\}/g, u) : c = n || i);
215
+ const m = /\{1([^}]*)\}/g;
216
+ let f;
217
+ for (; (f = m.exec(c)) !== null; ) {
218
+ const p = f[0], y = f[1].trim();
219
+ let o = u;
220
+ !o && y.includes("|") ? o = y.split("|")[1].trim() : o || (o = ""), c = e.startsWith("[") ? h : c.replace(p, o);
216
221
  }
217
222
  }
218
- return e ? a : n || l;
223
+ return e ? c : n || i;
219
224
  } else
220
- return e ? e.startsWith("[") ? u : l.replace("{0}", u) : n || l;
225
+ return e ? e.startsWith("[") ? h : i.replace(/\{0\}/g, h) : n || i;
221
226
  }
222
227
  getParentClass(t) {
223
228
  return Object.keys(this.classes).filter(
@@ -227,29 +232,29 @@ class R {
227
232
  )
228
233
  );
229
234
  }
230
- processCustomClass(t, s = "", e = "", i = "", r = "", c = "") {
235
+ processCustomClass(t, s = "", e = "", l = "", r = "", a = "") {
231
236
  if (!t) return null;
232
- const l = this.getParentClass(t);
233
- if (l.length > 0) {
234
- const n = l.map((a) => {
235
- const $ = this.classes[a];
236
- if (!$ || s && !$[t].includes("||") || s && !$[t].includes("|"))
237
+ const i = this.getParentClass(t);
238
+ if (i.length > 0) {
239
+ const n = i.map((u) => {
240
+ const c = this.classes[u];
241
+ if (!c || s && !c[t].includes("||") || s && !c[t].includes("|"))
237
242
  return null;
238
- const h = this.parseValuePattern(
243
+ const m = this.parseValuePattern(
239
244
  t,
240
- $[t] || "",
245
+ c[t] || "",
241
246
  s,
242
247
  e,
243
248
  r,
244
- c
249
+ a
245
250
  );
246
- return `${this.toKebabCase(String(a))}: ${h}`;
247
- }).filter(Boolean).join("; "), u = t.slice(-(s + e).length), o = `${t}${s ? `-${s}${e}` : ""}${r ? `/${r}${c}` : ""}`;
251
+ return `${this.toKebabCase(String(u))}: ${m}`;
252
+ }).filter(Boolean).join("; "), h = t.slice(-(s + e).length);
248
253
  return {
249
- className: s === u ? t : o,
254
+ className: s === h ? t : this.constructRaw(l, t, s, e, r, a),
250
255
  cssRules: n,
251
256
  value: null,
252
- prefix: i
257
+ prefix: l
253
258
  };
254
259
  }
255
260
  return null;
@@ -257,64 +262,64 @@ class R {
257
262
  process(t) {
258
263
  try {
259
264
  const s = Array.isArray(t) ? t : t.split(/\s+/), e = [];
260
- for (const i of s)
265
+ for (const l of s)
261
266
  try {
262
- if (!i) continue;
263
- const r = this.parse(i);
264
- if (!r) continue;
265
- const [c, l, n, u, o, a] = r;
266
267
  if (!l) continue;
267
- const $ = this.getParentClass(`${l}-${n}`).length > 0 ? `${l}-${n}` : l;
268
+ const r = this.parse(l);
269
+ if (!r) continue;
270
+ const [a, i, n, h, u, c] = r;
271
+ if (!i) continue;
272
+ const m = this.getParentClass(`${i}-${n}`).length > 0 ? `${i}-${n}` : i;
268
273
  try {
269
- const h = this.processCustomClass(
270
- $,
274
+ const f = this.processCustomClass(
275
+ m,
271
276
  n,
277
+ h,
278
+ a,
272
279
  u,
273
- c,
274
- o,
275
- a
280
+ c
276
281
  );
277
- if (h) {
278
- const { className: y, cssRules: p, prefix: f } = h;
279
- if (!p || p === "null") continue;
282
+ if (f) {
283
+ const { className: p, cssRules: y, prefix: o } = f;
284
+ if (!y || y === "null") continue;
280
285
  e.push({
281
- className: y,
282
- cssRules: p,
286
+ className: this.escapeCSSSelector(p),
287
+ cssRules: y,
283
288
  value: null,
284
- prefix: f,
285
- raw: r
289
+ prefix: o,
290
+ raw: [...r, this.constructRaw(o, i, n, h, u, c)]
286
291
  });
287
292
  continue;
288
293
  }
289
- } catch (h) {
290
- console.warn(`Error processing custom class "${i}":`, h);
294
+ } catch (f) {
295
+ console.warn(`Error processing custom class "${l}":`, f);
291
296
  }
292
297
  try {
293
- const h = this.processShorthand(
294
- l,
298
+ const f = this.processShorthand(
299
+ i,
295
300
  n,
301
+ h,
302
+ a,
296
303
  u,
297
304
  c,
298
- o,
299
- a,
300
305
  r
301
306
  );
302
- if (h) {
303
- const { className: y, cssRules: p, value: f, prefix: C } = h;
304
- if (!p || p === "null") continue;
307
+ if (f) {
308
+ const { className: p, cssRules: y, value: o, prefix: A } = f;
309
+ if (!y || y === "null") continue;
305
310
  e.push({
306
- className: y,
307
- cssRules: p,
308
- value: f,
309
- prefix: C,
310
- raw: r
311
+ className: this.escapeCSSSelector(p),
312
+ cssRules: y,
313
+ value: o,
314
+ prefix: A,
315
+ raw: [...r, this.constructRaw(a, i, n, h, u, c)]
311
316
  });
312
317
  }
313
- } catch (h) {
314
- console.warn(`Error processing shorthand "${i}":`, h);
318
+ } catch (f) {
319
+ console.warn(`Error processing shorthand "${l}":`, f);
315
320
  }
316
321
  } catch (r) {
317
- console.warn(`Failed to process class \`${i}\`:`, r);
322
+ console.warn(`Failed to process class \`${l}\`:`, r);
318
323
  }
319
324
  return e;
320
325
  } catch (s) {
@@ -323,6 +328,6 @@ class R {
323
328
  }
324
329
  }
325
330
  export {
326
- R as TenoxUI,
327
- R as default
331
+ Z as TenoxUI,
332
+ Z as default
328
333
  };
@@ -1 +1 @@
1
- var __tenoxui_moxie__=function(m){"use strict";var Z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(m,g,b)=>g in m?Z(m,g,{enumerable:!0,configurable:!0,writable:!0,value:b}):m[g]=b,S=(m,g)=>{for(var b in g||(g={}))w.call(g,b)&&_(m,b,g[b]);if(x)for(var b of x(g))z.call(g,b)&&_(m,b,g[b]);return m};class g{constructor({property:t={},values:s={},classes:e={}}={}){this.property=S({moxie:({key:i,secondValue:r})=>r?null:i},t),this.values=s,this.classes=e}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const s=t.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${t.slice(e.length).replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const s=new Set;return Object.entries(t).forEach(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,i=Object.keys(s);if(!e)return[...i,...t].sort((l,n)=>n.length-l.length);const c=[...this.getAllClassNames(e)];return[...i,...c,...t].sort((l,n)=>n.length-l.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",o="([a-zA-Z%]*)",a="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:n,value:u,unit:o,secondValuePattern:a,all:"(?:("+c+"):)?"+l+n+u+o+a}}parse(t,s){const e=this.regexp(s),i=t.match(new RegExp(e.all));if(i){const[,c,l,n,u,o,a]=i,$=`${c?`${c}:`:""}${l}-${n}${u}${o?`/${o}${a}`:""}`;return[c,l,n,u||"",o,a,$]}const r=t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}processValue(t,s,e){if(!t)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof u=="string"?u:c});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][t]||this.values[t]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",i,r="",c="",l){const n=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let o=null,a=s||"";const $=a.match(u);if($&&(o=$[1].trim(),a=$[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(o+":")||r))return null;let h;s.includes(o+":")?h=s.startsWith("(")?`(${a})`:`[${a}]`:h=s;const y=this.processValue(h,e,t),p=this.processValue(r,c,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const f=t.slice(1,-1).split(",").map(A=>A.trim().startsWith("--")?String(A.trim()):this.toKebabCase(String(A.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:y,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const A=n.group&&this.values[n.group][y]?this.values[n.group][y]:e?s:y,d=typeof n.property=="function"?n.property({value:s.startsWith("[")?y:A,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:o,raw:l}):n.property,C=n.value||"{0}";let W;if(typeof C=="function")W=C({value:A,unit:e,secondValue:c?r:p,secondUnit:c,key:o,raw:l});else if(typeof C=="string"){const P=n.group||t,V=this.processValue(h,e,P);this.values[P]&&typeof this.values[P]=="object"&&this.values[P][h]?W=this.values[P][h]:C.includes("{")?W=this.parseValuePattern(P,C,V,"",p,""):W=y}else if(Array.isArray(C)){if(!C.includes(s+e)||r)return null;W=s+e}else W=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof C=="string"&&(s.includes(o+":")||!C.includes("{1")&&r)?null:{className:j,cssRules:d?Array.isArray(d)?d:typeof d=="string"&&(d.includes(":")||d.includes("value:"))?d.includes("value:")?d.slice(6):this.toKebabCase(String(d)):this.toKebabCase(String(d)):null,value:C===null||d===null||d.includes(":")||d.includes("value:")?null:s.startsWith("[")?y:W,prefix:i}}const f=typeof n=="function"?n({value:s.startsWith("[")?y:e?s:y,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:o,raw:l}):n;return{className:`${t}${s?"-"+s+e:""}${r?`/${r}${c}`:""}`,cssRules:f?Array.isArray(n)?f:typeof f=="string"&&(f.includes(":")||f.startsWith("value:"))?f.startsWith("value:")?f.slice(6):this.toKebabCase(String(f)):this.toKebabCase(String(f)):null,value:typeof f=="string"&&f.includes(":")?null:y,prefix:i}}return null}parseValuePattern(t,s,e,i,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[l,n]=s.split("||").map(a=>a.trim()),u=this.processValue(e,i,t),o=this.processValue(r,c,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let a=l;if(e&&(a=a.replace("{0}",u)),s.includes("{1")){const $=a.match(/{1([^}]*)}/);if(s.includes("{1}"))r?a=r.startsWith("[")?o:a.replace("{1}",o):a=n;else if($){const h=$[0],y=$[1].trim();let p=o;!p&&y.includes("|")?p=y.split("|")[1].trim():p||(p=""),a=e.startsWith("[")?u:a.replace(h,p)}}return e?a:n||l}else return e?e.startsWith("[")?u:l.replace("{0}",u):n||l}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",i="",r="",c=""){if(!t)return null;const l=this.getParentClass(t);if(l.length>0){const n=l.map(a=>{const $=this.classes[a];if(!$||s&&!$[t].includes("||")||s&&!$[t].includes("|"))return null;const h=this.parseValuePattern(t,$[t]||"",s,e,r,c);return`${this.toKebabCase(String(a))}: ${h}`}).filter(Boolean).join("; "),u=t.slice(-(s+e).length),o=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return{className:s===u?t:o,cssRules:n,value:null,prefix:i}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const i of s)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[c,l,n,u,o,a]=r;if(!l)continue;const $=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass($,n,u,c,o,a);if(h){const{className:y,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:y,cssRules:p,value:null,prefix:f,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,u,c,o,a,r);if(h){const{className:y,cssRules:p,value:f,prefix:A}=h;if(!p||p==="null")continue;e.push({className:y,cssRules:p,value:f,prefix:A,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}return m.TenoxUI=g,m.default=g,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
1
+ var __tenoxui_moxie__=function(m){"use strict";var _=Object.defineProperty;var S=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var w=(m,g,$)=>g in m?_(m,g,{enumerable:!0,configurable:!0,writable:!0,value:$}):m[g]=$,x=(m,g)=>{for(var $ in g||(g={}))j.call(g,$)&&w(m,$,g[$]);if(S)for(var $ of S(g))V.call(g,$)&&w(m,$,g[$]);return m};class g{constructor({property:s={},values:t={},classes:e={}}={}){this.property=x({moxie:({key:l,secondValue:r})=>r?null:l},s),this.values=t,this.classes=e}toKebabCase(s){if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const t=s.match(/^(webkit|moz|ms|o)/);if(t){const e=t[0];return`-${e}${s.slice(e.length).replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`}}return s.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}escapeCSSSelector(s){return s.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(s){if(!s)return[];const t=new Set;return Object.entries(s).forEach(([e,l])=>{l&&typeof l=="object"&&Object.keys(l).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(s=[]){const t=this.property,e=this.classes,l=Object.keys(t);if(!e)return[...l,...s].sort((i,n)=>n.length-i.length);const a=[...this.getAllClassNames(e)];return[...l,...a,...s].sort((i,n)=>n.length-i.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",l="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",a="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+l+"|"+r+"))|"+e+"|"+l+"|"+r,i=`(${t}|\\[[^\\]]+\\])`,n="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:a,type:i,separator:n,value:h,unit:u,secondValuePattern:c,all:"(?:("+a+"):)?"+i+n+h+u+c}}parse(s,t){const e=this.regexp(t),l=s.match(new RegExp(e.all));if(l){const[,a,i,n,h,u,c]=l;return[a,i,n,h||"",u,c]}const r=s.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,s]:null}constructRaw(s,t,e,l,r,a){return`${s?`${s}:`:""}${t}${e?"-":""}${e}${l}${r?`/${r}${a}`:""}`}processValue(s,t,e){if(!s)return"";const l=r=>r.replace(/\{([^}]+)\}/g,(a,i)=>{const n=this.values,h=n!==null?typeof n[e]=="object"?n[e][i]:n[i]:void 0;return typeof h=="string"?h:a});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][s]||this.values[s]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const r=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?l(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",l,r="",a="",i){const n=this.property[s];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,c=t||"";const A=c.match(h);if(A&&(u=A[1].trim(),c=A[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(u+":")||r))return null;let f;t.includes(u+":")?f=t.startsWith("(")?`(${c})`:`[${c}]`:f=t;const p=this.processValue(f,e,s),y=this.processValue(r,a,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const o=s.slice(1,-1).split(",").map(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.trim())));return{className:this.constructRaw(l,s,t,e),cssRules:o.length===1?o[0]:o,value:p,prefix:l}}if(n){if(typeof n=="object"&&"property"in n){const C=n.group&&this.values[n.group][p]?this.values[n.group][p]:e?t:p,d=typeof n.property=="function"?n.property({value:t.startsWith("[")?p:C,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":a?r:y,secondUnit:t.startsWith("[")?"":a,key:u,raw:i}):n.property,b=n.value||"{0}";let W;if(typeof b=="function")W=b({value:C,unit:e,secondValue:a?r:y,secondUnit:a,key:u,raw:i});else if(typeof b=="string"){const P=n.group||s,R=this.processValue(f,e,P);this.values[P]&&typeof this.values[P]=="object"&&this.values[P][f]?W=this.values[P][f]:b.includes("{")?W=this.parseValuePattern(P,b,R,"",y,""):W=p}else if(Array.isArray(b)){if(!b.includes(t+e)||r)return null;W=t+e}else W=null;return typeof n.property=="string"&&typeof b=="string"&&(t.includes(u+":")||!b.includes("{1")&&r)?null:{className:this.constructRaw(l,s,t,e,r,a),cssRules:d?Array.isArray(d)?d:typeof d=="string"&&(d.includes(":")||d.includes("value:"))?d.includes("value:")?d.slice(6):this.toKebabCase(String(d)):this.toKebabCase(String(d)):null,value:b===null||d===null||d.includes(":")||d.includes("value:")?null:t.startsWith("[")?p:W,prefix:l}}const o=typeof n=="function"?n({value:t.startsWith("[")?p:e?t:p,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":a?r:y,secondUnit:t.startsWith("[")?"":a,key:u,raw:i}):n;return{className:this.constructRaw(l,s,t,e,r,a),cssRules:o?Array.isArray(n)?o:typeof o=="string"&&(o.includes(":")||o.startsWith("value:"))?o.startsWith("value:")?o.slice(6):this.toKebabCase(String(o)):this.toKebabCase(String(o)):null,value:typeof o=="string"&&o.includes(":")?null:p,prefix:l}}return null}parseValuePattern(s,t,e,l,r,a){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[i,n]=t.split("||").map(c=>c.trim()),h=this.processValue(e,l,s),u=this.processValue(r,a,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let c=i;if(e&&(c=c.replace(/\{0\}/g,h)),t.includes("{1")){t.includes("{1}")&&(r?c=r.startsWith("[")?u:c.replace(/\{1\}/g,u):c=n||i);const A=/\{1([^}]*)\}/g;let f;for(;(f=A.exec(c))!==null;){const p=f[0],y=f[1].trim();let o=u;!o&&y.includes("|")?o=y.split("|")[1].trim():o||(o=""),c=e.startsWith("[")?h:c.replace(p,o)}}return e?c:n||i}else return e?e.startsWith("[")?h:i.replace(/\{0\}/g,h):n||i}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",e="",l="",r="",a=""){if(!s)return null;const i=this.getParentClass(s);if(i.length>0){const n=i.map(u=>{const c=this.classes[u];if(!c||t&&!c[s].includes("||")||t&&!c[s].includes("|"))return null;const A=this.parseValuePattern(s,c[s]||"",t,e,r,a);return`${this.toKebabCase(String(u))}: ${A}`}).filter(Boolean).join("; "),h=s.slice(-(t+e).length);return{className:t===h?s:this.constructRaw(l,s,t,e,r,a),cssRules:n,value:null,prefix:l}}return null}process(s){try{const t=Array.isArray(s)?s:s.split(/\s+/),e=[];for(const l of t)try{if(!l)continue;const r=this.parse(l);if(!r)continue;const[a,i,n,h,u,c]=r;if(!i)continue;const A=this.getParentClass(`${i}-${n}`).length>0?`${i}-${n}`:i;try{const f=this.processCustomClass(A,n,h,a,u,c);if(f){const{className:p,cssRules:y,prefix:o}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:null,prefix:o,raw:[...r,this.constructRaw(o,i,n,h,u,c)]});continue}}catch(f){console.warn(`Error processing custom class "${l}":`,f)}try{const f=this.processShorthand(i,n,h,a,u,c,r);if(f){const{className:p,cssRules:y,value:o,prefix:C}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:o,prefix:C,raw:[...r,this.constructRaw(a,i,n,h,u,c)]})}}catch(f){console.warn(`Error processing shorthand "${l}":`,f)}}catch(r){console.warn(`Failed to process class \`${l}\`:`,r)}return e}catch(t){return console.error("Critical error in process method:",t),[]}}}return m.TenoxUI=g,m.default=g,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(g,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(g=typeof globalThis!="undefined"?globalThis:g||self,y(g.__tenoxui_moxie__={}))})(this,function(g){"use strict";var Z=Object.defineProperty;var P=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(g,y,b)=>y in g?Z(g,y,{enumerable:!0,configurable:!0,writable:!0,value:b}):g[y]=b,j=(g,y)=>{for(var b in y||(y={}))w.call(y,b)&&_(g,b,y[b]);if(P)for(var b of P(y))z.call(y,b)&&_(g,b,y[b]);return g};class y{constructor({property:t={},values:s={},classes:e={}}={}){this.property=j({moxie:({key:i,secondValue:r})=>r?null:i},t),this.values=s,this.classes=e}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const s=t.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${t.slice(e.length).replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const s=new Set;return Object.entries(t).forEach(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,i=Object.keys(s);if(!e)return[...i,...t].sort((l,n)=>n.length-l.length);const o=[...this.getAllClassNames(e)];return[...i,...o,...t].sort((l,n)=>n.length-l.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",o="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",a="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:o,type:l,separator:n,value:u,unit:a,secondValuePattern:c,all:"(?:("+o+"):)?"+l+n+u+a+c}}parse(t,s){const e=this.regexp(s),i=t.match(new RegExp(e.all));if(i){const[,o,l,n,u,a,c]=i,d=`${o?`${o}:`:""}${l}-${n}${u}${a?`/${a}${c}`:""}`;return[o,l,n,u||"",a,c,d]}const r=t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}processValue(t,s,e){if(!t)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(o,l)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof u=="string"?u:o});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][t]||this.values[t]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",i,r="",o="",l){const n=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let a=null,c=s||"";const d=c.match(u);if(d&&(a=d[1].trim(),c=d[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(a+":")||r))return null;let h;s.includes(a+":")?h=s.startsWith("(")?`(${c})`:`[${c}]`:h=s;const $=this.processValue(h,e,t),p=this.processValue(r,o,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const f=t.slice(1,-1).split(",").map(A=>A.trim().startsWith("--")?String(A.trim()):this.toKebabCase(String(A.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:$,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const A=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,m=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:A,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:p,secondUnit:s.startsWith("[")?"":o,key:a,raw:l}):n.property,C=n.value||"{0}";let x;if(typeof C=="function")x=C({value:A,unit:e,secondValue:o?r:p,secondUnit:o,key:a,raw:l});else if(typeof C=="string"){const W=n.group||t,V=this.processValue(h,e,W);this.values[W]&&typeof this.values[W]=="object"&&this.values[W][h]?x=this.values[W][h]:C.includes("{")?x=this.parseValuePattern(W,C,V,"",p,""):x=$}else if(Array.isArray(C)){if(!C.includes(s+e)||r)return null;x=s+e}else x=null;const S=`${t}${s?`-${s}${e}`:""}${r?`/${r}${o}`:""}`;return typeof n.property=="string"&&typeof C=="string"&&(s.includes(a+":")||!C.includes("{1")&&r)?null:{className:S,cssRules:m?Array.isArray(m)?m:typeof m=="string"&&(m.includes(":")||m.includes("value:"))?m.includes("value:")?m.slice(6):this.toKebabCase(String(m)):this.toKebabCase(String(m)):null,value:C===null||m===null||m.includes(":")||m.includes("value:")?null:s.startsWith("[")?$:x,prefix:i}}const f=typeof n=="function"?n({value:s.startsWith("[")?$:e?s:$,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:p,secondUnit:s.startsWith("[")?"":o,key:a,raw:l}):n;return{className:`${t}${s?"-"+s+e:""}${r?`/${r}${o}`:""}`,cssRules:f?Array.isArray(n)?f:typeof f=="string"&&(f.includes(":")||f.startsWith("value:"))?f.startsWith("value:")?f.slice(6):this.toKebabCase(String(f)):this.toKebabCase(String(f)):null,value:typeof f=="string"&&f.includes(":")?null:$,prefix:i}}return null}parseValuePattern(t,s,e,i,r,o){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[l,n]=s.split("||").map(c=>c.trim()),u=this.processValue(e,i,t),a=this.processValue(r,o,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let c=l;if(e&&(c=c.replace("{0}",u)),s.includes("{1")){const d=c.match(/{1([^}]*)}/);if(s.includes("{1}"))r?c=r.startsWith("[")?a:c.replace("{1}",a):c=n;else if(d){const h=d[0],$=d[1].trim();let p=a;!p&&$.includes("|")?p=$.split("|")[1].trim():p||(p=""),c=e.startsWith("[")?u:c.replace(h,p)}}return e?c:n||l}else return e?e.startsWith("[")?u:l.replace("{0}",u):n||l}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",i="",r="",o=""){if(!t)return null;const l=this.getParentClass(t);if(l.length>0){const n=l.map(c=>{const d=this.classes[c];if(!d||s&&!d[t].includes("||")||s&&!d[t].includes("|"))return null;const h=this.parseValuePattern(t,d[t]||"",s,e,r,o);return`${this.toKebabCase(String(c))}: ${h}`}).filter(Boolean).join("; "),u=t.slice(-(s+e).length),a=`${t}${s?`-${s}${e}`:""}${r?`/${r}${o}`:""}`;return{className:s===u?t:a,cssRules:n,value:null,prefix:i}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const i of s)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[o,l,n,u,a,c]=r;if(!l)continue;const d=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass(d,n,u,o,a,c);if(h){const{className:$,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:null,prefix:f,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,u,o,a,c,r);if(h){const{className:$,cssRules:p,value:f,prefix:A}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:A,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}g.TenoxUI=y,g.default=y,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(d,p){typeof exports=="object"&&typeof module!="undefined"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(d=typeof globalThis!="undefined"?globalThis:d||self,p(d.__tenoxui_moxie__={}))})(this,function(d){"use strict";var _=Object.defineProperty;var P=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var S=(d,p,$)=>p in d?_(d,p,{enumerable:!0,configurable:!0,writable:!0,value:$}):d[p]=$,w=(d,p)=>{for(var $ in p||(p={}))j.call(p,$)&&S(d,$,p[$]);if(P)for(var $ of P(p))V.call(p,$)&&S(d,$,p[$]);return d};class p{constructor({property:s={},values:t={},classes:e={}}={}){this.property=w({moxie:({key:i,secondValue:r})=>r?null:i},s),this.values=t,this.classes=e}toKebabCase(s){if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const t=s.match(/^(webkit|moz|ms|o)/);if(t){const e=t[0];return`-${e}${s.slice(e.length).replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`}}return s.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}escapeCSSSelector(s){return s.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(s){if(!s)return[];const t=new Set;return Object.entries(s).forEach(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(s=[]){const t=this.property,e=this.classes,i=Object.keys(t);if(!e)return[...i,...s].sort((l,n)=>n.length-l.length);const o=[...this.getAllClassNames(e)];return[...i,...o,...s].sort((l,n)=>n.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",o="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${t}|\\[[^\\]]+\\])`,n="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:o,type:l,separator:n,value:h,unit:u,secondValuePattern:c,all:"(?:("+o+"):)?"+l+n+h+u+c}}parse(s,t){const e=this.regexp(t),i=s.match(new RegExp(e.all));if(i){const[,o,l,n,h,u,c]=i;return[o,l,n,h||"",u,c]}const r=s.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,s]:null}constructRaw(s,t,e,i,r,o){return`${s?`${s}:`:""}${t}${e?"-":""}${e}${i}${r?`/${r}${o}`:""}`}processValue(s,t,e){if(!s)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(o,l)=>{const n=this.values,h=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof h=="string"?h:o});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][s]||this.values[s]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const r=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",i,r="",o="",l){const n=this.property[s];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,c=t||"";const A=c.match(h);if(A&&(u=A[1].trim(),c=A[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(u+":")||r))return null;let f;t.includes(u+":")?f=t.startsWith("(")?`(${c})`:`[${c}]`:f=t;const y=this.processValue(f,e,s),g=this.processValue(r,o,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const a=s.slice(1,-1).split(",").map(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.trim())));return{className:this.constructRaw(i,s,t,e),cssRules:a.length===1?a[0]:a,value:y,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const C=n.group&&this.values[n.group][y]?this.values[n.group][y]:e?t:y,m=typeof n.property=="function"?n.property({value:t.startsWith("[")?y:C,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":o?r:g,secondUnit:t.startsWith("[")?"":o,key:u,raw:l}):n.property,b=n.value||"{0}";let W;if(typeof b=="function")W=b({value:C,unit:e,secondValue:o?r:g,secondUnit:o,key:u,raw:l});else if(typeof b=="string"){const x=n.group||s,R=this.processValue(f,e,x);this.values[x]&&typeof this.values[x]=="object"&&this.values[x][f]?W=this.values[x][f]:b.includes("{")?W=this.parseValuePattern(x,b,R,"",g,""):W=y}else if(Array.isArray(b)){if(!b.includes(t+e)||r)return null;W=t+e}else W=null;return typeof n.property=="string"&&typeof b=="string"&&(t.includes(u+":")||!b.includes("{1")&&r)?null:{className:this.constructRaw(i,s,t,e,r,o),cssRules:m?Array.isArray(m)?m:typeof m=="string"&&(m.includes(":")||m.includes("value:"))?m.includes("value:")?m.slice(6):this.toKebabCase(String(m)):this.toKebabCase(String(m)):null,value:b===null||m===null||m.includes(":")||m.includes("value:")?null:t.startsWith("[")?y:W,prefix:i}}const a=typeof n=="function"?n({value:t.startsWith("[")?y:e?t:y,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":o?r:g,secondUnit:t.startsWith("[")?"":o,key:u,raw:l}):n;return{className:this.constructRaw(i,s,t,e,r,o),cssRules:a?Array.isArray(n)?a:typeof a=="string"&&(a.includes(":")||a.startsWith("value:"))?a.startsWith("value:")?a.slice(6):this.toKebabCase(String(a)):this.toKebabCase(String(a)):null,value:typeof a=="string"&&a.includes(":")?null:y,prefix:i}}return null}parseValuePattern(s,t,e,i,r,o){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,n]=t.split("||").map(c=>c.trim()),h=this.processValue(e,i,s),u=this.processValue(r,o,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let c=l;if(e&&(c=c.replace(/\{0\}/g,h)),t.includes("{1")){t.includes("{1}")&&(r?c=r.startsWith("[")?u:c.replace(/\{1\}/g,u):c=n||l);const A=/\{1([^}]*)\}/g;let f;for(;(f=A.exec(c))!==null;){const y=f[0],g=f[1].trim();let a=u;!a&&g.includes("|")?a=g.split("|")[1].trim():a||(a=""),c=e.startsWith("[")?h:c.replace(y,a)}}return e?c:n||l}else return e?e.startsWith("[")?h:l.replace(/\{0\}/g,h):n||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",e="",i="",r="",o=""){if(!s)return null;const l=this.getParentClass(s);if(l.length>0){const n=l.map(u=>{const c=this.classes[u];if(!c||t&&!c[s].includes("||")||t&&!c[s].includes("|"))return null;const A=this.parseValuePattern(s,c[s]||"",t,e,r,o);return`${this.toKebabCase(String(u))}: ${A}`}).filter(Boolean).join("; "),h=s.slice(-(t+e).length);return{className:t===h?s:this.constructRaw(i,s,t,e,r,o),cssRules:n,value:null,prefix:i}}return null}process(s){try{const t=Array.isArray(s)?s:s.split(/\s+/),e=[];for(const i of t)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[o,l,n,h,u,c]=r;if(!l)continue;const A=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const f=this.processCustomClass(A,n,h,o,u,c);if(f){const{className:y,cssRules:g,prefix:a}=f;if(!g||g==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:g,value:null,prefix:a,raw:[...r,this.constructRaw(a,l,n,h,u,c)]});continue}}catch(f){console.warn(`Error processing custom class "${i}":`,f)}try{const f=this.processShorthand(l,n,h,o,u,c,r);if(f){const{className:y,cssRules:g,value:a,prefix:C}=f;if(!g||g==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:g,value:a,prefix:C,raw:[...r,this.constructRaw(o,l,n,h,u,c)]})}}catch(f){console.warn(`Error processing shorthand "${i}":`,f)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(t){return console.error("Critical error in process method:",t),[]}}}d.TenoxUI=p,d.default=p,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenoxui/moxie",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Very lightweight utility-first CSS engine for style generation",
5
5
  "author": "NOuSantx <nousantx@gmail.com>",
6
6
  "license": "MIT",