@tenoxui/moxie 0.5.0 → 0.6.1

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=(d,t,s)=>t in d?Z(d,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[t]=s,P=(d,t)=>{for(var s in t||(t={}))_.call(t,s)&&x(d,s,t[s]);if(W)for(var s of W(t))w.call(t,s)&&x(d,s,t[s]);return d};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:t={},values:s={},classes:e={}}={}){this.property=P({moxie:({key:l,secondValue:r})=>r?null:l},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,l=>`-${l.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,l])=>{l&&typeof l=="object"&&Object.keys(l).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,l=Object.keys(s);if(!e)return[...l,...t].sort((i,n)=>n.length-i.length);const c=[...this.getAllClassNames(e)];return[...l,...c,...t].sort((i,n)=>n.length-i.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",l="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+l+"|"+r+"))|"+e+"|"+l+"|"+r,i=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\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+"|"+l+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:i,separator:n,value:u,unit:a,secondValuePattern:o,all:"(?:("+c+"):)?"+i+n+u+a+o}}parse(t,s){const e=this.regexp(s),l=t.match(new RegExp(e.all));if(l){const[,c,i,n,u,a,o]=l,y=`${c?`${c}:`:""}${i}-${n}${u}${a?`/${a}${o}`:""}`;return[c,i,n,u||"",a,o,y]}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 l=r=>r.replace(/\{([^}]+)\}/g,(c,i)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][i]:n[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("{")?l(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",l,r="",c="",i){const n=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let a=null,o=s||"";const y=o.match(u);if(y&&(a=y[1].trim(),o=y[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(a+":")||r))return null;let h;s.includes(a+":")?h=s.startsWith("(")?`(${o})`:`[${o}]`:h=s;const $=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(m=>m.trim().startsWith("--")?String(m.trim()):this.toKebabCase(String(m.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:$,prefix:l}}if(n){if(typeof n=="object"&&"property"in n){const m=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,g=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:m,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):n.property,b=n.value||"{0}";let C;if(typeof b=="function")C=b({value:m,unit:e,secondValue:c?r:p,secondUnit:c,key:a,raw:i});else if(typeof b=="string"){const A=n.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]:b.includes("{")?C=this.parseValuePattern(A,b,V,"",p,""):C=$}else C=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof b=="string"&&(s.includes(a+":")||!b.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:b===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?$:C,prefix:l}}const f=typeof n=="function"?n({value:s.startsWith("[")?$:e?s:$,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):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:$,prefix:l}}return null}parseValuePattern(t,s,e,l,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[i,n]=s.split("||").map(o=>o.trim()),u=this.processValue(e,l,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 y=o.match(/{1([^}]*)}/);if(s.includes("{1}"))r?o=r.startsWith("[")?a:o.replace("{1}",a):o=n;else if(y){const h=y[0],$=y[1].trim();let p=a;!p&&$.includes("|")?p=$.split("|")[1].trim():p||(p=""),o=e.startsWith("[")?u:o.replace(h,p)}}return e?o:n||i}else return e?e.startsWith("[")?u:i.replace("{0}",u):n||i}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",l="",r="",c=""){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const n=i.map(o=>{const y=this.classes[o];if(!y||s&&!y[t].includes("||")||s&&!y[t].includes("|"))return null;const h=this.parseValuePattern(t,y[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:n,value:null,prefix:l}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const l of s)try{if(!l)continue;const r=this.parse(l);if(!r)continue;const[c,i,n,u,a,o]=r;if(!i)continue;const y=this.getParentClass(`${i}-${n}`).length>0?`${i}-${n}`:i;try{const h=this.processCustomClass(y,n,u,c,a,o);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 "${l}":`,h)}try{const h=this.processShorthand(i,n,u,c,a,o,r);if(h){const{className:$,cssRules:p,value:f,prefix:m}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:m,raw:r})}}catch(h){console.warn(`Error processing shorthand "${l}":`,h)}}catch(r){console.warn(`Failed to process class \`${l}\`:`,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=($,t,s)=>t in $?R($,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):$[t]=s,S=($,t)=>{for(var s in t||(t={}))j.call(t,s)&&P($,s,t[s]);if(W)for(var s of W(t))V.call(t,s)&&P($,s,t[s]);return $};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class w{constructor({property:t={},values:s={},classes:e={}}={}){this.property=S({moxie:({key:l,secondValue:r})=>r?null:l},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,l=>`-${l.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,l])=>{l&&typeof l=="object"&&Object.keys(l).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,l=Object.keys(s);if(!e)return[...l,...t].sort((i,n)=>n.length-i.length);const a=[...this.getAllClassNames(e)];return[...l,...a,...t].sort((i,n)=>n.length-i.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",l="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",a="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+l+"|"+r+"))|"+e+"|"+l+"|"+r,i=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))",o="([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:u,unit:o,secondValuePattern:c,all:"(?:("+a+"):)?"+i+n+u+o+c}}parse(t,s){const e=this.regexp(s),l=t.match(new RegExp(e.all));if(l){const[,a,i,n,u,o,c]=l;return[a,i,n,u||"",o,c]}const r=t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}constructRaw(t,s,e,l,r,a){return`${t?`${t}:`:""}${s}${e?"-":""}${e}${l}${r?`/${r}${a}`:""}`}processValue(t,s,e){if(!t)return"";const l=r=>r.replace(/\{([^}]+)\}/g,(a,i)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][i]:n[i]:void 0;return typeof u=="string"?u:a});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("{")?l(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",l,r="",a="",i){const n=this.property[t];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let o=null,c=s||"";const d=c.match(u);if(d&&(o=d[1].trim(),c=d[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(o+":")||r))return null;let f;s.includes(o+":")?f=s.startsWith("(")?`(${c})`:`[${c}]`:f=s;const y=this.processValue(f,e,t),p=this.processValue(r,a,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const h=t.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:this.constructRaw(l,t,s,e),cssRules:h.length===1?h[0]:h,value:y,prefix:l}}if(n){if(typeof n=="object"&&"property"in n){const b=n.group&&this.values[n.group][y]?this.values[n.group][y]:e?s:y,g=typeof n.property=="function"?n.property({value:s.startsWith("[")?y:b,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":a?r:p,secondUnit:s.startsWith("[")?"":a,key:o,raw:i}):n.property,m=n.value||"{0}";let A;if(typeof m=="function")A=m({value:b,unit:e,secondValue:a?r:p,secondUnit:a,key:o,raw:i});else if(typeof m=="string"){const C=n.group||t,x=this.processValue(f,e,C);this.values[C]&&typeof this.values[C]=="object"&&this.values[C][f]?A=this.values[C][f]:m.includes("{")?A=this.parseValuePattern(C,m,x,"",p,""):A=y}else if(Array.isArray(m)){if(!m.includes(s+e)||r)return null;A=s+e}else A=null;return typeof n.property=="string"&&typeof m=="string"&&(s.includes(o+":")||!m.includes("{1")&&r)?null:{className:this.constructRaw(l,t,s,e,r,a),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:m===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?y:A,prefix:l}}const h=typeof n=="function"?n({value:s.startsWith("[")?y:e?s:y,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":a?r:p,secondUnit:s.startsWith("[")?"":a,key:o,raw:i}):n;return{className:this.constructRaw(l,t,s,e,r,a),cssRules:h?Array.isArray(n)?h:typeof h=="string"&&(h.includes(":")||h.startsWith("value:"))?h.startsWith("value:")?h.slice(6):this.toKebabCase(String(h)):this.toKebabCase(String(h)):null,value:typeof h=="string"&&h.includes(":")?null:y,prefix:l}}return null}parseValuePattern(t,s,e,l,r,a){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[i,n]=s.split("||").map(c=>c.trim()),u=this.processValue(e,l,t),o=this.processValue(r,a,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let c=i;if(e&&(c=c.replace("{0}",u)),s.includes("{1")){const d=c.match(/{1([^}]*)}/);if(s.includes("{1}"))r?c=r.startsWith("[")?o:c.replace("{1}",o):c=n;else if(d){const f=d[0],y=d[1].trim();let p=o;!p&&y.includes("|")?p=y.split("|")[1].trim():p||(p=""),c=e.startsWith("[")?u:c.replace(f,p)}}return e?c:n||i}else return e?e.startsWith("[")?u:i.replace("{0}",u):n||i}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",l="",r="",a=""){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const n=i.map(o=>{const c=this.classes[o];if(!c||s&&!c[t].includes("||")||s&&!c[t].includes("|"))return null;const d=this.parseValuePattern(t,c[t]||"",s,e,r,a);return`${this.toKebabCase(String(o))}: ${d}`}).filter(Boolean).join("; "),u=t.slice(-(s+e).length);return{className:s===u?t:this.constructRaw(l,t,s,e,r,a),cssRules:n,value:null,prefix:l}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const l of s)try{if(!l)continue;const r=this.parse(l);if(!r)continue;const[a,i,n,u,o,c]=r;if(!i)continue;const d=this.getParentClass(`${i}-${n}`).length>0?`${i}-${n}`:i;try{const f=this.processCustomClass(d,n,u,a,o,c);if(f){const{className:y,cssRules:p,prefix:h}=f;if(!p||p==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:p,value:null,prefix:h,raw:[...r,this.constructRaw(h,i,n,u,o,c)]});continue}}catch(f){console.warn(`Error processing custom class "${l}":`,f)}try{const f=this.processShorthand(i,n,u,a,o,c,r);if(f){const{className:y,cssRules:p,value:h,prefix:b}=f;if(!p||p==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:p,value:h,prefix:b,raw:[...r,this.constructRaw(a,i,n,u,o,c)]})}}catch(f){console.warn(`Error processing shorthand "${l}":`,f)}}catch(r){console.warn(`Failed to process class \`${l}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}exports.TenoxUI=w;exports.default=w;
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,17 +1,17 @@
1
1
  var S = Object.defineProperty;
2
2
  var W = Object.getOwnPropertySymbols;
3
- var Z = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
4
- var x = (d, t, s) => t in d ? S(d, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : d[t] = s, P = (d, 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, w = ($, t) => {
5
5
  for (var s in t || (t = {}))
6
- Z.call(t, s) && x(d, 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(d, s, t[s]);
10
- return d;
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 = w({
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
17
  moxie: ({ key: i, secondValue: r }) => r ? null : i
@@ -43,43 +43,46 @@ class R {
43
43
  const s = this.property, e = this.classes, i = Object.keys(s);
44
44
  if (!e)
45
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);
46
+ const a = [...this.getAllClassNames(e)];
47
+ return [...i, ...a, ...t].sort((l, n) => n.length - l.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 = "\\[[^\\]]+\\]", i = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", a = (
51
51
  // Simple prefix (hover, md, focus, etc.)
52
52
  "[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:" + e + "|" + i + "|" + r + "))|" + // Direct bracket, parenthesis, or brace content
53
53
  e + "|" + i + "|" + r
54
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
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
+ i + "|(?:\\$[^\\s\\/]+))", o = "([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%]*))?";
58
58
  return {
59
- prefix: c,
59
+ prefix: a,
60
60
  type: l,
61
61
  separator: n,
62
62
  value: u,
63
63
  unit: o,
64
- secondValuePattern: a,
65
- all: "(?:(" + c + "):)?" + l + n + u + o + a
64
+ secondValuePattern: c,
65
+ all: "(?:(" + a + "):)?" + l + n + u + o + c
66
66
  };
67
67
  }
68
68
  parse(t, s) {
69
69
  const e = this.regexp(s), i = t.match(new RegExp(e.all));
70
70
  if (i) {
71
- const [, c, l, n, u, o, a] = i, y = `${c ? `${c}:` : ""}${l}-${n}${u}${o ? `/${o}${a}` : ""}`;
72
- return [c, l, n, u || "", o, a, y];
71
+ const [, a, l, n, u, o, c] = i;
72
+ return [a, l, n, u || "", o, 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, i, r, a) {
78
+ return `${t ? `${t}:` : ""}${s}${e ? "-" : ""}${e}${i}${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) => {
83
+ const i = (r) => r.replace(/\{([^}]+)\}/g, (a, l) => {
81
84
  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;
85
+ return typeof u == "string" ? u : 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];
@@ -91,36 +94,39 @@ class 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 y = a.match(u);
98
- if (y && (o = y[1].trim(), a = y[2].trim()), (typeof n == "string" || Array.isArray(n)) && (!s || s.includes(o + ":") || r))
97
+ processShorthand(t = "", s = "", e = "", i, r = "", a = "", l) {
98
+ const n = this.property[t];
99
+ if (typeof n == "object" && !Array.isArray(n) && !("property" in n))
100
+ return null;
101
+ const u = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
102
+ let o = null, c = s || "";
103
+ const d = c.match(u);
104
+ if (d && (o = d[1].trim(), c = d[2].trim()), (typeof n == "string" || Array.isArray(n)) && (!s || s.includes(o + ":") || r))
99
105
  return null;
100
- let h;
101
- s.includes(o + ":") ? h = s.startsWith("(") ? `(${a})` : `[${a}]` : h = s;
102
- const $ = this.processValue(h, e, t), p = this.processValue(r, c, t);
106
+ let f;
107
+ s.includes(o + ":") ? f = s.startsWith("(") ? `(${c})` : `[${c}]` : f = s;
108
+ const y = this.processValue(f, e, t), p = 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
- (m) => m.trim().startsWith("--") ? String(m.trim()) : this.toKebabCase(String(m.trim()))
111
+ const h = 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: $,
115
+ className: this.constructRaw(i, t, s, e),
116
+ cssRules: h.length === 1 ? h[0] : h,
117
+ value: y,
112
118
  prefix: i
113
119
  };
114
120
  }
115
121
  if (n) {
116
122
  if (typeof n == "object" && "property" in n) {
117
- const m = n.group && this.values[n.group][$] ? this.values[n.group][$] : e ? s : $, g = (
123
+ const A = n.group && this.values[n.group][y] ? this.values[n.group][y] : e ? s : y, g = (
118
124
  // handle `properties.property` function
119
125
  typeof n.property == "function" ? n.property({
120
- value: s.startsWith("[") ? $ : m,
126
+ value: s.startsWith("[") ? y : A,
121
127
  unit: s.startsWith("[") ? "" : e,
122
- secondValue: s.startsWith("[") ? "" : c ? r : p,
123
- secondUnit: s.startsWith("[") ? "" : c,
128
+ secondValue: s.startsWith("[") ? "" : a ? r : p,
129
+ secondUnit: s.startsWith("[") ? "" : a,
124
130
  key: o,
125
131
  raw: l
126
132
  }) : (
@@ -130,31 +136,33 @@ class R {
130
136
  // and has support for second value
131
137
  n.property
132
138
  )
133
- ), C = n.value || "{0}";
139
+ ), m = n.value || "{0}";
134
140
  let b;
135
- if (typeof C == "function")
136
- b = C({
137
- value: m,
141
+ if (typeof m == "function")
142
+ b = m({
143
+ value: A,
138
144
  unit: e,
139
- secondValue: c ? r : p,
140
- secondUnit: c,
145
+ secondValue: a ? r : p,
146
+ secondUnit: a,
141
147
  key: o,
142
148
  raw: l
143
149
  });
144
- else if (typeof C == "string") {
145
- const A = n.group || t, j = this.processValue(h, e, A);
146
- this.values[A] && typeof this.values[A] == "object" && this.values[A][h] ? b = this.values[A][h] : C.includes("{") ? b = this.parseValuePattern(
147
- A,
150
+ else if (typeof m == "string") {
151
+ const C = n.group || t, x = this.processValue(f, e, C);
152
+ this.values[C] && typeof this.values[C] == "object" && this.values[C][f] ? b = this.values[C][f] : m.includes("{") ? b = this.parseValuePattern(
148
153
  C,
149
- j,
154
+ m,
155
+ x,
150
156
  "",
151
157
  p,
152
158
  ""
153
- ) : b = $;
159
+ ) : b = y;
160
+ } else if (Array.isArray(m)) {
161
+ if (!m.includes(s + e) || r) return null;
162
+ b = s + e;
154
163
  } else b = null;
155
- const V = `${t}${s ? `-${s}${e}` : ""}${r ? `/${r}${c}` : ""}`;
156
- return typeof n.property == "string" && typeof C == "string" && (s.includes(o + ":") || !C.includes("{1") && r) ? null : {
157
- className: V,
164
+ return typeof n.property == "string" && typeof m == "string" && (s.includes(o + ":") || !m.includes("{1") && r) ? null : {
165
+ className: this.constructRaw(i, t, s, e, r, a),
158
166
  cssRules: (
159
167
  // if not property, or when `properties.property` as function return null
160
168
  g ? Array.isArray(g) ? g : (
@@ -165,20 +173,20 @@ class R {
165
173
  )
166
174
  ) : null
167
175
  ),
168
- value: C === null || g === null || g.includes(":") || g.includes("value:") ? null : s.startsWith("[") ? $ : b,
176
+ value: m === null || g === null || g.includes(":") || g.includes("value:") ? null : s.startsWith("[") ? y : b,
169
177
  prefix: i
170
178
  };
171
179
  }
172
- const f = (
180
+ const h = (
173
181
  // handle `properties` as function
174
182
  // e.g. m: ({ value, unit }) => `margin: ${value}${unit || 'px'}`
175
183
  // m-4 => margin: 4px
176
184
  // m-4rem => margin: 4rem
177
185
  typeof n == "function" ? n({
178
- value: s.startsWith("[") ? $ : e ? s : $,
186
+ value: s.startsWith("[") ? y : e ? s : y,
179
187
  unit: s.startsWith("[") ? "" : e,
180
- secondValue: s.startsWith("[") ? "" : c ? r : p,
181
- secondUnit: s.startsWith("[") ? "" : c,
188
+ secondValue: s.startsWith("[") ? "" : a ? r : p,
189
+ secondUnit: s.startsWith("[") ? "" : a,
182
190
  key: o,
183
191
  raw: l
184
192
  }) : (
@@ -188,31 +196,31 @@ class R {
188
196
  )
189
197
  );
190
198
  return {
191
- className: `${t}${s ? "-" + s + e : ""}${r ? `/${r}${c}` : ""}`,
192
- 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,
193
- value: typeof f == "string" && f.includes(":") ? null : $,
199
+ className: this.constructRaw(i, t, s, e, r, a),
200
+ cssRules: h ? Array.isArray(n) ? h : typeof h == "string" && (h.includes(":") || h.startsWith("value:")) ? h.startsWith("value:") ? h.slice(6) : this.toKebabCase(String(h)) : this.toKebabCase(String(h)) : null,
201
+ value: typeof h == "string" && h.includes(":") ? null : y,
194
202
  prefix: i
195
203
  };
196
204
  }
197
205
  return null;
198
206
  }
199
- parseValuePattern(t, s, e, i, r, c) {
207
+ parseValuePattern(t, s, e, i, r, a) {
200
208
  if (!s.includes("{0}") && !s.includes("{1") && !s.includes("||"))
201
209
  return s;
202
- const [l, n] = s.split("||").map((a) => a.trim()), u = this.processValue(e, i, t), o = this.processValue(r, c, t);
210
+ const [l, n] = s.split("||").map((c) => c.trim()), u = this.processValue(e, i, t), o = this.processValue(r, a, t);
203
211
  if (s.includes("{0}") && s.includes("{1") || s.includes("{1")) {
204
- let a = l;
205
- if (e && (a = a.replace("{0}", u)), s.includes("{1")) {
206
- const y = a.match(/{1([^}]*)}/);
212
+ let c = l;
213
+ if (e && (c = c.replace("{0}", u)), s.includes("{1")) {
214
+ const d = c.match(/{1([^}]*)}/);
207
215
  if (s.includes("{1}"))
208
- r ? a = r.startsWith("[") ? o : a.replace("{1}", o) : a = n;
209
- else if (y) {
210
- const h = y[0], $ = y[1].trim();
216
+ r ? c = r.startsWith("[") ? o : c.replace("{1}", o) : c = n;
217
+ else if (d) {
218
+ const f = d[0], y = d[1].trim();
211
219
  let p = o;
212
- !p && $.includes("|") ? p = $.split("|")[1].trim() : p || (p = ""), a = e.startsWith("[") ? u : a.replace(h, p);
220
+ !p && y.includes("|") ? p = y.split("|")[1].trim() : p || (p = ""), c = e.startsWith("[") ? u : c.replace(f, p);
213
221
  }
214
222
  }
215
- return e ? a : n || l;
223
+ return e ? c : n || l;
216
224
  } else
217
225
  return e ? e.startsWith("[") ? u : l.replace("{0}", u) : n || l;
218
226
  }
@@ -224,26 +232,26 @@ class R {
224
232
  )
225
233
  );
226
234
  }
227
- processCustomClass(t, s = "", e = "", i = "", r = "", c = "") {
235
+ processCustomClass(t, s = "", e = "", i = "", r = "", a = "") {
228
236
  if (!t) return null;
229
237
  const l = this.getParentClass(t);
230
238
  if (l.length > 0) {
231
- const n = l.map((a) => {
232
- const y = this.classes[a];
233
- if (!y || s && !y[t].includes("||") || s && !y[t].includes("|"))
239
+ const n = l.map((o) => {
240
+ const c = this.classes[o];
241
+ if (!c || s && !c[t].includes("||") || s && !c[t].includes("|"))
234
242
  return null;
235
- const h = this.parseValuePattern(
243
+ const d = this.parseValuePattern(
236
244
  t,
237
- y[t] || "",
245
+ c[t] || "",
238
246
  s,
239
247
  e,
240
248
  r,
241
- c
249
+ a
242
250
  );
243
- return `${this.toKebabCase(String(a))}: ${h}`;
244
- }).filter(Boolean).join("; "), u = t.slice(-(s + e).length), o = `${t}${s ? `-${s}${e}` : ""}${r ? `/${r}${c}` : ""}`;
251
+ return `${this.toKebabCase(String(o))}: ${d}`;
252
+ }).filter(Boolean).join("; "), u = t.slice(-(s + e).length);
245
253
  return {
246
- className: s === u ? t : o,
254
+ className: s === u ? t : this.constructRaw(i, t, s, e, r, a),
247
255
  cssRules: n,
248
256
  value: null,
249
257
  prefix: i
@@ -259,56 +267,56 @@ class R {
259
267
  if (!i) continue;
260
268
  const r = this.parse(i);
261
269
  if (!r) continue;
262
- const [c, l, n, u, o, a] = r;
270
+ const [a, l, n, u, o, c] = r;
263
271
  if (!l) continue;
264
- const y = this.getParentClass(`${l}-${n}`).length > 0 ? `${l}-${n}` : l;
272
+ const d = this.getParentClass(`${l}-${n}`).length > 0 ? `${l}-${n}` : l;
265
273
  try {
266
- const h = this.processCustomClass(
267
- y,
274
+ const f = this.processCustomClass(
275
+ d,
268
276
  n,
269
277
  u,
270
- c,
278
+ a,
271
279
  o,
272
- a
280
+ c
273
281
  );
274
- if (h) {
275
- const { className: $, cssRules: p, prefix: f } = h;
282
+ if (f) {
283
+ const { className: y, cssRules: p, prefix: h } = f;
276
284
  if (!p || p === "null") continue;
277
285
  e.push({
278
- className: $,
286
+ className: this.escapeCSSSelector(y),
279
287
  cssRules: p,
280
288
  value: null,
281
- prefix: f,
282
- raw: r
289
+ prefix: h,
290
+ raw: [...r, this.constructRaw(h, l, n, u, o, c)]
283
291
  });
284
292
  continue;
285
293
  }
286
- } catch (h) {
287
- console.warn(`Error processing custom class "${i}":`, h);
294
+ } catch (f) {
295
+ console.warn(`Error processing custom class "${i}":`, f);
288
296
  }
289
297
  try {
290
- const h = this.processShorthand(
298
+ const f = this.processShorthand(
291
299
  l,
292
300
  n,
293
301
  u,
294
- c,
295
- o,
296
302
  a,
303
+ o,
304
+ c,
297
305
  r
298
306
  );
299
- if (h) {
300
- const { className: $, cssRules: p, value: f, prefix: m } = h;
307
+ if (f) {
308
+ const { className: y, cssRules: p, value: h, prefix: A } = f;
301
309
  if (!p || p === "null") continue;
302
310
  e.push({
303
- className: $,
311
+ className: this.escapeCSSSelector(y),
304
312
  cssRules: p,
305
- value: f,
306
- prefix: m,
307
- raw: r
313
+ value: h,
314
+ prefix: A,
315
+ raw: [...r, this.constructRaw(a, l, n, u, o, c)]
308
316
  });
309
317
  }
310
- } catch (h) {
311
- console.warn(`Error processing shorthand "${i}":`, h);
318
+ } catch (f) {
319
+ console.warn(`Error processing shorthand "${i}":`, f);
312
320
  }
313
321
  } catch (r) {
314
322
  console.warn(`Failed to process class \`${i}\`:`, r);
@@ -320,6 +328,6 @@ class R {
320
328
  }
321
329
  }
322
330
  export {
323
- R as TenoxUI,
324
- R as default
331
+ Z as TenoxUI,
332
+ Z as default
325
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,y=`${c?`${c}:`:""}${l}-${n}${u}${o?`/${o}${a}`:""}`;return[c,l,n,u||"",o,a,y]}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 y=a.match(u);if(y&&(o=y[1].trim(),a=y[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 $=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(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.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 C=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,d=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:C,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:o,raw:l}):n.property,A=n.value||"{0}";let W;if(typeof A=="function")W=A({value:C,unit:e,secondValue:c?r:p,secondUnit:c,key:o,raw:l});else if(typeof A=="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]:A.includes("{")?W=this.parseValuePattern(P,A,V,"",p,""):W=$}else W=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof A=="string"&&(s.includes(o+":")||!A.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:A===null||d===null||d.includes(":")||d.includes("value:")?null:s.startsWith("[")?$:W,prefix:i}}const f=typeof n=="function"?n({value:s.startsWith("[")?$:e?s:$,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:$,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 y=a.match(/{1([^}]*)}/);if(s.includes("{1}"))r?a=r.startsWith("[")?o:a.replace("{1}",o):a=n;else if(y){const h=y[0],$=y[1].trim();let p=o;!p&&$.includes("|")?p=$.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 y=this.classes[a];if(!y||s&&!y[t].includes("||")||s&&!y[t].includes("|"))return null;const h=this.parseValuePattern(t,y[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 y=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass(y,n,u,c,o,a);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,c,o,a,r);if(h){const{className:$,cssRules:p,value:f,prefix:C}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:C,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: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 a=[...this.getAllClassNames(e)];return[...i,...a,...s].sort((l,n)=>n.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",a="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${t}|\\[[^\\]]+\\])`,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%]*)",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:a,type:l,separator:n,value:u,unit:o,secondValuePattern:c,all:"(?:("+a+"):)?"+l+n+u+o+c}}parse(s,t){const e=this.regexp(t),i=s.match(new RegExp(e.all));if(i){const[,a,l,n,u,o,c]=i;return[a,l,n,u||"",o,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,a){return`${s?`${s}:`:""}${t}${e?"-":""}${e}${i}${r?`/${r}${a}`:""}`}processValue(s,t,e){if(!s)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(a,l)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof u=="string"?u: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("{")?i(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",i,r="",a="",l){const n=this.property[s];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let o=null,c=t||"";const b=c.match(u);if(b&&(o=b[1].trim(),c=b[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(o+":")||r))return null;let f;t.includes(o+":")?f=t.startsWith("(")?`(${c})`:`[${c}]`:f=t;const y=this.processValue(f,e,s),p=this.processValue(r,a,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const h=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:h.length===1?h[0]:h,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,d=typeof n.property=="function"?n.property({value:t.startsWith("[")?y:C,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":a?r:p,secondUnit:t.startsWith("[")?"":a,key:o,raw:l}):n.property,A=n.value||"{0}";let W;if(typeof A=="function")W=A({value:C,unit:e,secondValue:a?r:p,secondUnit:a,key:o,raw:l});else if(typeof A=="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]:A.includes("{")?W=this.parseValuePattern(P,A,R,"",p,""):W=y}else if(Array.isArray(A)){if(!A.includes(t+e)||r)return null;W=t+e}else W=null;return typeof n.property=="string"&&typeof A=="string"&&(t.includes(o+":")||!A.includes("{1")&&r)?null:{className:this.constructRaw(i,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:A===null||d===null||d.includes(":")||d.includes("value:")?null:t.startsWith("[")?y:W,prefix:i}}const h=typeof n=="function"?n({value:t.startsWith("[")?y:e?t:y,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":a?r:p,secondUnit:t.startsWith("[")?"":a,key:o,raw:l}):n;return{className:this.constructRaw(i,s,t,e,r,a),cssRules:h?Array.isArray(n)?h:typeof h=="string"&&(h.includes(":")||h.startsWith("value:"))?h.startsWith("value:")?h.slice(6):this.toKebabCase(String(h)):this.toKebabCase(String(h)):null,value:typeof h=="string"&&h.includes(":")?null:y,prefix:i}}return null}parseValuePattern(s,t,e,i,r,a){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,n]=t.split("||").map(c=>c.trim()),u=this.processValue(e,i,s),o=this.processValue(r,a,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let c=l;if(e&&(c=c.replace("{0}",u)),t.includes("{1")){const b=c.match(/{1([^}]*)}/);if(t.includes("{1}"))r?c=r.startsWith("[")?o:c.replace("{1}",o):c=n;else if(b){const f=b[0],y=b[1].trim();let p=o;!p&&y.includes("|")?p=y.split("|")[1].trim():p||(p=""),c=e.startsWith("[")?u:c.replace(f,p)}}return e?c:n||l}else return e?e.startsWith("[")?u:l.replace("{0}",u):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="",a=""){if(!s)return null;const l=this.getParentClass(s);if(l.length>0){const n=l.map(o=>{const c=this.classes[o];if(!c||t&&!c[s].includes("||")||t&&!c[s].includes("|"))return null;const b=this.parseValuePattern(s,c[s]||"",t,e,r,a);return`${this.toKebabCase(String(o))}: ${b}`}).filter(Boolean).join("; "),u=s.slice(-(t+e).length);return{className:t===u?s:this.constructRaw(i,s,t,e,r,a),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[a,l,n,u,o,c]=r;if(!l)continue;const b=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const f=this.processCustomClass(b,n,u,a,o,c);if(f){const{className:y,cssRules:p,prefix:h}=f;if(!p||p==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:p,value:null,prefix:h,raw:[...r,this.constructRaw(h,l,n,u,o,c)]});continue}}catch(f){console.warn(`Error processing custom class "${i}":`,f)}try{const f=this.processShorthand(l,n,u,a,o,c,r);if(f){const{className:y,cssRules:p,value:h,prefix:C}=f;if(!p||p==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:p,value:h,prefix:C,raw:[...r,this.constructRaw(a,l,n,u,o,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),[]}}}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(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.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 C=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,m=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:C,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:p,secondUnit:s.startsWith("[")?"":o,key:a,raw:l}):n.property,x=n.value||"{0}";let A;if(typeof x=="function")A=x({value:C,unit:e,secondValue:o?r:p,secondUnit:o,key:a,raw:l});else if(typeof x=="string"){const W=n.group||t,V=this.processValue(h,e,W);this.values[W]&&typeof this.values[W]=="object"&&this.values[W][h]?A=this.values[W][h]:x.includes("{")?A=this.parseValuePattern(W,x,V,"",p,""):A=$}else A=null;const S=`${t}${s?`-${s}${e}`:""}${r?`/${r}${o}`:""}`;return typeof n.property=="string"&&typeof x=="string"&&(s.includes(a+":")||!x.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:x===null||m===null||m.includes(":")||m.includes("value:")?null:s.startsWith("[")?$:A,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:C}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:C,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(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 _=Object.defineProperty;var x=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var S=(g,y,$)=>y in g?_(g,y,{enumerable:!0,configurable:!0,writable:!0,value:$}):g[y]=$,w=(g,y)=>{for(var $ in y||(y={}))j.call(y,$)&&S(g,$,y[$]);if(x)for(var $ of x(y))V.call(y,$)&&S(g,$,y[$]);return g};class y{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="(?:-)",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(s,t){const e=this.regexp(t),i=s.match(new RegExp(e.all));if(i){const[,o,l,n,u,a,c]=i;return[o,l,n,u||"",a,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,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][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 u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let a=null,c=t||"";const b=c.match(u);if(b&&(a=b[1].trim(),c=b[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(a+":")||r))return null;let f;t.includes(a+":")?f=t.startsWith("(")?`(${c})`:`[${c}]`:f=t;const d=this.processValue(f,e,s),p=this.processValue(r,o,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const h=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:h.length===1?h[0]:h,value:d,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const C=n.group&&this.values[n.group][d]?this.values[n.group][d]:e?t:d,m=typeof n.property=="function"?n.property({value:t.startsWith("[")?d:C,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":o?r:p,secondUnit:t.startsWith("[")?"":o,key:a,raw:l}):n.property,A=n.value||"{0}";let W;if(typeof A=="function")W=A({value:C,unit:e,secondValue:o?r:p,secondUnit:o,key:a,raw:l});else if(typeof A=="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]:A.includes("{")?W=this.parseValuePattern(P,A,R,"",p,""):W=d}else if(Array.isArray(A)){if(!A.includes(t+e)||r)return null;W=t+e}else W=null;return typeof n.property=="string"&&typeof A=="string"&&(t.includes(a+":")||!A.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:A===null||m===null||m.includes(":")||m.includes("value:")?null:t.startsWith("[")?d:W,prefix:i}}const h=typeof n=="function"?n({value:t.startsWith("[")?d:e?t:d,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":o?r:p,secondUnit:t.startsWith("[")?"":o,key:a,raw:l}):n;return{className:this.constructRaw(i,s,t,e,r,o),cssRules:h?Array.isArray(n)?h:typeof h=="string"&&(h.includes(":")||h.startsWith("value:"))?h.startsWith("value:")?h.slice(6):this.toKebabCase(String(h)):this.toKebabCase(String(h)):null,value:typeof h=="string"&&h.includes(":")?null:d,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()),u=this.processValue(e,i,s),a=this.processValue(r,o,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let c=l;if(e&&(c=c.replace("{0}",u)),t.includes("{1")){const b=c.match(/{1([^}]*)}/);if(t.includes("{1}"))r?c=r.startsWith("[")?a:c.replace("{1}",a):c=n;else if(b){const f=b[0],d=b[1].trim();let p=a;!p&&d.includes("|")?p=d.split("|")[1].trim():p||(p=""),c=e.startsWith("[")?u:c.replace(f,p)}}return e?c:n||l}else return e?e.startsWith("[")?u:l.replace("{0}",u):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(a=>{const c=this.classes[a];if(!c||t&&!c[s].includes("||")||t&&!c[s].includes("|"))return null;const b=this.parseValuePattern(s,c[s]||"",t,e,r,o);return`${this.toKebabCase(String(a))}: ${b}`}).filter(Boolean).join("; "),u=s.slice(-(t+e).length);return{className:t===u?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,u,a,c]=r;if(!l)continue;const b=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const f=this.processCustomClass(b,n,u,o,a,c);if(f){const{className:d,cssRules:p,prefix:h}=f;if(!p||p==="null")continue;e.push({className:this.escapeCSSSelector(d),cssRules:p,value:null,prefix:h,raw:[...r,this.constructRaw(h,l,n,u,a,c)]});continue}}catch(f){console.warn(`Error processing custom class "${i}":`,f)}try{const f=this.processShorthand(l,n,u,o,a,c,r);if(f){const{className:d,cssRules:p,value:h,prefix:C}=f;if(!p||p==="null")continue;e.push({className:this.escapeCSSSelector(d),cssRules:p,value:h,prefix:C,raw:[...r,this.constructRaw(o,l,n,u,a,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),[]}}}g.TenoxUI=y,g.default=y,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -8,7 +8,7 @@ export type PropertyParams = {
8
8
  raw?: Parsed;
9
9
  };
10
10
  export type PropertyParamValue = GetCSSProperty | ((params: PropertyParams) => null | GetCSSProperty);
11
- export type ValuePropType = string | ((params: PropertyParams) => string | null) | null;
11
+ export type ValuePropType = string | string[] | ((params: PropertyParams) => string | null) | null;
12
12
  export type PropertyValue = PropertyParamValue | {
13
13
  property?: PropertyParamValue;
14
14
  value?: ValuePropType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenoxui/moxie",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Very lightweight utility-first CSS engine for style generation",
5
5
  "author": "NOuSantx <nousantx@gmail.com>",
6
6
  "license": "MIT",