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