@tenoxui/moxie 0.6.5 → 0.6.7

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