@tenoxui/moxie 0.6.6 → 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=(A,s,t)=>s in A?R(A,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):A[s]=t,x=(A,s)=>{for(var t in s||(s={}))j.call(s,t)&&P(A,t,s[t]);if(W)for(var t of W(s))V.call(s,t)&&P(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={}}={}){this.property=x({moxie:({key:i,secondValue:n})=>n?null:i},s),this.values=t,this.classes=r}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((l,e)=>e.length-l.length);const o=[...this.getAllClassNames(r)];return[...i,...o,...s].sort((l,e)=>e.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),r="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",n="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",o="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+r+"|"+i+"|"+n+"))|"+r+"|"+i+"|"+n,l=`(${t}|\\[[^\\]]+\\])`,e="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+r+"|"+n+"|"+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]+)|"+r+"|"+n+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:o,type:l,separator:e,value:h,unit:u,secondValuePattern:c,all:"^(?:("+o+"):)?"+l+e+h+u+c+"$"}}parse(s,t){const r=this.regexp(t),i=s.match(new RegExp(r.all));if(i){const[,o,l,e,h,u,c]=i;return[o,l,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,o){return`${s?`${s}:`:""}${t}${r?"-":""}${r}${i}${n?`/${n}${o}`:""}`}processValue(s,t,r){if(!s)return"";const i=n=>n.replace(/\{([^}]+)\}/g,(o,l)=>{const e=this.values,h=e!==null?typeof e[r]=="object"?e[r][l]:e[l]:void 0;return typeof h=="string"?h:o});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="",o="",l){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 $=c.match(h);if($&&(u=$[1].trim(),c=$[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 f=this.processValue(p,r,s),y=this.processValue(n,o,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||n)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(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 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("[")?"":o?n:y,secondUnit:t.startsWith("[")?"":o,key:u,raw:l}):e.property,g=e.value||"{0}";let b;if(typeof g=="function")b=g({value:m,unit:r,secondValue:o?n:y,secondUnit:o,key:u,raw:l});else if(typeof g=="string"){const C=e.group||s,w=this.processValue(p,r,C);this.values[C]&&typeof this.values[C]=="object"&&this.values[C][p]?b=this.values[C][p]:g.includes("{")?b=this.parseValuePattern(C,g,w,"",y,""):typeof g=="string"&&!g.includes("{")?b=g:b=f}else if(Array.isArray(g)){if(!g.includes(t+r)||n)return null;b=t+r}else b=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,o),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:b,prefix:i}}const a=typeof e=="function"?e({value:t.startsWith("[")?f:r?t:f,unit:t.startsWith("[")?"":r,secondValue:t.startsWith("[")?"":o?n:y,secondUnit:t.startsWith("[")?"":o,key:u,raw:l}):e;return{className:this.constructRaw(i,s,t,r,n,o),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,o){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,e]=t.split("||").map(c=>c.trim()),h=this.processValue(r,i,s),u=this.processValue(n,o,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let c=l;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||l);const $=/\{1([^}]*)\}/g;let p;for(;(p=$.exec(c))!==null;){const f=p[0],y=p[1].trim();let a=u;!a&&y.includes("|")?a=y.split("|")[1].trim():a||(a=""),c=r.startsWith("[")?h:c.replace(f,a)}}return r?c:e||l}else return r?r.startsWith("[")?h:l.replace(/\{0\}/g,h):e||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",r="",i="",n="",o=""){if(!s)return null;const l=this.getParentClass(s),e=t&&s.endsWith(`-${t}${r}`);if(l.length>0){const h=l.map(u=>{const c=this.classes[u];if(!c||t&&!e&&c[s]&&!c[s].includes("{0}")&&!c[s].includes("|"))return null;const $=this.parseValuePattern(s,c[s]||"",t,r,n,o);return`${this.toKebabCase(String(u))}: ${$}`}).filter(Boolean).join("; ");return{className:e?s:this.constructRaw(i,s,t,r,n,o),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[o,l,e,h,u,c]=n;if(!l)continue;const $=this.getParentClass(`${l}-${e}`).length>0?`${l}-${e}`:l;try{const p=this.processCustomClass($,e,h,o,u,c);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,l,e,h,u,c)]});continue}}catch(p){console.warn(`Error processing custom class "${i}":`,p)}try{const p=this.processShorthand(l,e,h,o,u,c,n);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:[...n,this.constructRaw(o,l,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),[]}}}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,118 +1,120 @@
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 = (A, s, t) => s in A ? S(A, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : A[s] = t, x = (A, s) => {
5
- for (var t in s || (s = {}))
6
- R.call(s, t) && P(A, 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(A, t, s[t]);
8
+ for (var s of W(t))
9
+ j.call(t, s) && x(A, s, t[s]);
10
10
  return A;
11
11
  };
12
12
  class Z {
13
- constructor({ property: s = {}, values: t = {}, classes: r = {} } = {}) {
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: i, secondValue: n }) => n ? null : i
18
- }, s), this.values = t, this.classes = r;
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 r = t[0];
25
- return `-${r}${s.slice(r.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 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(([r, i]) => {
33
+ getAllClassNames(t) {
34
+ if (!t) return [];
35
+ const s = /* @__PURE__ */ new Set();
36
+ return Object.entries(t).forEach(([r, i]) => {
37
37
  i && typeof i == "object" && Object.keys(i).forEach((n) => {
38
- t.add(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, r = this.classes, i = Object.keys(t);
42
+ getTypePrefixes(t = []) {
43
+ const s = this.property, r = this.classes, i = Object.keys(s);
44
44
  if (!r)
45
- return [...i, ...s].sort((l, e) => e.length - l.length);
46
- const o = [...this.getAllClassNames(r)];
47
- return [...i, ...o, ...s].sort((l, e) => e.length - l.length);
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("|"), r = "\\[[^\\]]+\\]", i = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", n = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", o = (
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_-]+(?:-(?:" + r + "|" + i + "|" + n + "))|" + // Direct bracket, parenthesis, or brace content
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
53
55
  r + "|" + i + "|" + n
54
- ), l = `(${t}|\\[[^\\]]+\\])`, e = "(?:-)", h = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
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
55
57
  r + "|" + // Bracket content
56
58
  n + "|" + // Curly brace content
57
- 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]+)|" + r + "|" + n + "|" + i + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
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: o,
60
- type: l,
61
- separator: e,
62
- value: h,
63
- unit: u,
64
- secondValuePattern: c,
65
- all: "^(?:(" + o + "):)?" + l + e + 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 r = this.regexp(t), i = s.match(new RegExp(r.all));
70
+ parse(t, s) {
71
+ const r = this.regexp(s), i = t.match(new RegExp(r.all));
70
72
  if (i) {
71
- const [, o, l, e, h, u, c] = i;
72
- return [o, l, e, h || "", u, c];
73
+ const [, l, c, e, h, u, o] = i;
74
+ return [l, c, e, h || "", u, o];
73
75
  }
74
- const n = s.match(new RegExp(`^(?:(${r.prefix}):)?${r.type}$`));
76
+ const n = t.match(new RegExp(`^(?:(${r.prefix}):)?${r.type}$`));
75
77
  return n ? [n[1], n[2], "", "", void 0, void 0] : null;
76
78
  }
77
- constructRaw(s, t, r, i, n, o) {
78
- return `${s ? `${s}:` : ""}${t}${r ? "-" : ""}${r}${i}${n ? `/${n}${o}` : ""}`;
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, r) {
82
- if (!s) return "";
83
- const i = (n) => n.replace(/\{([^}]+)\}/g, (o, l) => {
84
- const e = this.values, h = e !== null ? typeof e[r] == "object" ? e[r][l] : e[l] : void 0;
85
- return typeof h == "string" ? h : o;
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[r] && typeof this.values[r] == "object" && this.values[r][s] || this.values[s]))
88
- return typeof this.values[r] == "object" && this.values[r] !== null ? this.values[r][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 n = s.slice(1, -1).replace(/\\\_/g, "m0x13c55").replace(/\_/g, " ").replace(/m0x13c55/g, "_");
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, "_");
93
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 = "", r = "", i, n = "", o = "", l) {
98
- const e = this.property[s];
99
+ processShorthand(t = "", s = "", r = "", i, n = "", l = "", c) {
100
+ const e = this.property[t];
99
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 e == "string" && !e.includes(":") || Array.isArray(e)) && (!t || t.includes(u + ":") || n))
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
108
  let p;
107
- t.includes(u + ":") ? p = t.startsWith("(") ? `(${c})` : `[${c}]` : p = t;
108
- const f = this.processValue(p, r, s), y = this.processValue(n, o, s);
109
- if (s.startsWith("[") && s.endsWith("]")) {
110
- if (!t || n) return null;
111
- const a = s.slice(1, -1).split(",").map(
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(
112
114
  (m) => m.trim().startsWith("--") ? String(m.trim()) : this.toKebabCase(String(m.trim()))
113
115
  );
114
116
  return {
115
- className: this.constructRaw(i, s, t, r),
117
+ className: this.constructRaw(i, t, s, r),
116
118
  cssRules: a.length === 1 ? a[0] : a,
117
119
  value: f,
118
120
  prefix: i
@@ -120,15 +122,15 @@ class Z {
120
122
  }
121
123
  if (e) {
122
124
  if (typeof e == "object" && "property" in e) {
123
- const m = e.group && this.values[e.group][f] ? this.values[e.group][f] : r ? t : f, d = (
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
127
  typeof e.property == "function" ? e.property({
126
- value: t.startsWith("[") ? f : m,
127
- unit: t.startsWith("[") ? "" : r,
128
- secondValue: t.startsWith("[") ? "" : o ? n : y,
129
- secondUnit: t.startsWith("[") ? "" : o,
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: l
133
+ raw: c
132
134
  }) : (
133
135
  // defaulting to string property
134
136
  // e.g. { property: { p: { property: 'padding', value: '{0} {1}' } }
@@ -137,35 +139,35 @@ class Z {
137
139
  e.property
138
140
  )
139
141
  ), g = e.value || "{0}";
140
- let b;
142
+ let C;
141
143
  if (typeof g == "function")
142
- b = g({
144
+ C = g({
143
145
  value: m,
144
146
  unit: r,
145
- secondValue: o ? n : y,
146
- secondUnit: o,
147
+ secondValue: l ? n : y,
148
+ secondUnit: l,
147
149
  key: u,
148
- raw: l
150
+ raw: c
149
151
  });
150
152
  else if (typeof g == "string") {
151
- const C = e.group || s, w = this.processValue(p, r, C);
152
- this.values[C] && typeof this.values[C] == "object" && this.values[C][p] ? b = this.values[C][p] : g.includes("{") ? b = this.parseValuePattern(
153
- C,
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,
154
156
  g,
155
157
  w,
156
158
  "",
157
159
  y,
158
160
  ""
159
- ) : typeof g == "string" && !g.includes("{") ? b = g : b = f;
161
+ ) : typeof g == "string" && !g.includes("{") ? C = g : C = f;
160
162
  } else if (Array.isArray(g)) {
161
- if (!g.includes(t + r) || n) return null;
162
- b = t + r;
163
- } else b = null;
164
- return (typeof e.property == "string" || Array.isArray(e.property)) && typeof g == "string" && (t.includes(u + ":") || !g.includes("{1") && n) || // check if the property is string or array of properties
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
165
167
  // but the value is null
166
168
  (typeof e.property == "string" || Array.isArray(e.property)) && g === null || // check if the type is a direct rules but has `value` defined
167
- 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 : {
168
- className: this.constructRaw(i, s, t, r, n, o),
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),
169
171
  cssRules: (
170
172
  // if not property, or when `properties.property` as function return null
171
173
  d ? Array.isArray(d) ? d : (
@@ -176,7 +178,7 @@ class Z {
176
178
  )
177
179
  ) : null
178
180
  ),
179
- value: g === null || d === null || d.includes(":") || d.includes("value:") ? null : t.startsWith("[") ? f : b,
181
+ value: g === null || d === null || d.includes(":") || d.includes("value:") ? null : s.startsWith("[") ? f : C,
180
182
  prefix: i
181
183
  };
182
184
  }
@@ -186,12 +188,12 @@ class Z {
186
188
  // m-4 => margin: 4px
187
189
  // m-4rem => margin: 4rem
188
190
  typeof e == "function" ? e({
189
- value: t.startsWith("[") ? f : r ? t : f,
190
- unit: t.startsWith("[") ? "" : r,
191
- secondValue: t.startsWith("[") ? "" : o ? n : y,
192
- secondUnit: t.startsWith("[") ? "" : o,
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,
193
195
  key: u,
194
- raw: l
196
+ raw: c
195
197
  }) : (
196
198
  // e.g. { property: { bg: 'background' } }
197
199
  // the `bg` is the type or the shorthand for `background` property
@@ -199,7 +201,7 @@ class Z {
199
201
  )
200
202
  );
201
203
  return {
202
- className: this.constructRaw(i, s, t, r, n, o),
204
+ className: this.constructRaw(i, t, s, r, n, l),
203
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,
204
206
  value: typeof a == "string" && a.includes(":") ? null : f,
205
207
  prefix: i
@@ -207,54 +209,54 @@ class Z {
207
209
  }
208
210
  return null;
209
211
  }
210
- parseValuePattern(s, t, r, i, n, o) {
211
- if (!t.includes("{0}") && !t.includes("{1") && !t.includes("||"))
212
- return t;
213
- const [l, e] = t.split("||").map((c) => c.trim()), h = this.processValue(r, i, s), u = this.processValue(n, o, s);
214
- if (t.includes("{0}") && t.includes("{1") || t.includes("{1")) {
215
- let c = l;
216
- if (r && (c = c.replace(/\{0\}/g, h)), t.includes("{1")) {
217
- t.includes("{1}") && (n ? c = n.startsWith("[") ? u : c.replace(/\{1\}/g, u) : c = e || l);
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);
218
220
  const $ = /\{1([^}]*)\}/g;
219
221
  let p;
220
- for (; (p = $.exec(c)) !== null; ) {
222
+ for (; (p = $.exec(o)) !== null; ) {
221
223
  const f = p[0], y = p[1].trim();
222
224
  let a = u;
223
- !a && y.includes("|") ? a = y.split("|")[1].trim() : a || (a = ""), c = r.startsWith("[") ? h : c.replace(f, a);
225
+ !a && y.includes("|") ? a = y.split("|")[1].trim() : a || (a = ""), o = r.startsWith("[") ? h : o.replace(f, a);
224
226
  }
225
227
  }
226
- return r ? c : e || l;
228
+ return r ? o : e || c;
227
229
  } else
228
- return r ? r.startsWith("[") ? h : l.replace(/\{0\}/g, h) : e || l;
230
+ return r ? r.startsWith("[") ? h : c.replace(/\{0\}/g, h) : e || c;
229
231
  }
230
- getParentClass(s) {
232
+ getParentClass(t) {
231
233
  return Object.keys(this.classes).filter(
232
- (t) => Object.prototype.hasOwnProperty.call(
233
- this.classes[t],
234
- s
234
+ (s) => Object.prototype.hasOwnProperty.call(
235
+ this.classes[s],
236
+ t
235
237
  )
236
238
  );
237
239
  }
238
- processCustomClass(s, t = "", r = "", i = "", n = "", o = "") {
239
- if (!s) return null;
240
- const l = this.getParentClass(s), e = t && s.endsWith(`-${t}${r}`);
241
- if (l.length > 0) {
242
- const h = l.map((u) => {
243
- const c = this.classes[u];
244
- if (!c || t && !e && 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("|"))
245
247
  return null;
246
248
  const $ = this.parseValuePattern(
247
- s,
248
- c[s] || "",
249
249
  t,
250
+ o[t] || "",
251
+ s,
250
252
  r,
251
253
  n,
252
- o
254
+ l
253
255
  );
254
256
  return `${this.toKebabCase(String(u))}: ${$}`;
255
257
  }).filter(Boolean).join("; ");
256
258
  return {
257
- className: e ? s : this.constructRaw(i, s, t, r, n, o),
259
+ className: e ? t : this.constructRaw(i, t, s, r, n, l),
258
260
  cssRules: h,
259
261
  value: null,
260
262
  prefix: i
@@ -262,25 +264,25 @@ class Z {
262
264
  }
263
265
  return null;
264
266
  }
265
- process(s) {
267
+ process(t) {
266
268
  try {
267
- const t = Array.isArray(s) ? s : s.split(/\s+/), r = [];
268
- for (const i of t)
269
+ const s = Array.isArray(t) ? t : t.split(/\s+/), r = [];
270
+ for (const i of s)
269
271
  try {
270
272
  if (!i) continue;
271
273
  const n = this.parse(i);
272
274
  if (!n) continue;
273
- const [o, l, e, h, u, c] = n;
274
- if (!l) continue;
275
- const $ = this.getParentClass(`${l}-${e}`).length > 0 ? `${l}-${e}` : l;
275
+ const [l, c, e, h, u, o] = n;
276
+ if (!c) continue;
277
+ const $ = this.getParentClass(`${c}-${e}`).length > 0 ? `${c}-${e}` : c;
276
278
  try {
277
279
  const p = this.processCustomClass(
278
280
  $,
279
281
  e,
280
282
  h,
281
- o,
283
+ l,
282
284
  u,
283
- c
285
+ o
284
286
  );
285
287
  if (p) {
286
288
  const { className: f, cssRules: y, prefix: a } = p;
@@ -290,7 +292,7 @@ class Z {
290
292
  cssRules: y,
291
293
  value: null,
292
294
  prefix: a,
293
- raw: [...n, this.constructRaw(a, l, e, h, u, c)]
295
+ raw: [...n, this.constructRaw(a, c, e, h, u, o)]
294
296
  });
295
297
  continue;
296
298
  }
@@ -299,12 +301,12 @@ class Z {
299
301
  }
300
302
  try {
301
303
  const p = this.processShorthand(
302
- l,
304
+ c,
303
305
  e,
304
306
  h,
305
- o,
307
+ l,
306
308
  u,
307
- c,
309
+ o,
308
310
  n
309
311
  );
310
312
  if (p) {
@@ -315,7 +317,7 @@ class Z {
315
317
  cssRules: y,
316
318
  value: a,
317
319
  prefix: m,
318
- raw: [...n, this.constructRaw(o, l, e, h, u, c)]
320
+ raw: [...n, this.constructRaw(l, c, e, h, u, o)]
319
321
  });
320
322
  }
321
323
  } catch (p) {
@@ -325,8 +327,8 @@ class Z {
325
327
  console.warn(`Failed to process class \`${i}\`:`, n);
326
328
  }
327
329
  return r;
328
- } catch (t) {
329
- return console.error("Critical error in process method:", t), [];
330
+ } catch (s) {
331
+ return console.error("Critical error in process method:", s), [];
330
332
  }
331
333
  }
332
334
  }
@@ -1 +1 @@
1
- var __tenoxui_moxie__=function(m){"use strict";var _=Object.defineProperty;var S=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var w=(m,d,A)=>d in m?_(m,d,{enumerable:!0,configurable:!0,writable:!0,value:A}):m[d]=A,x=(m,d)=>{for(var A in d||(d={}))j.call(d,A)&&w(m,A,d[A]);if(S)for(var A of S(d))V.call(d,A)&&w(m,A,d[A]);return m};class d{constructor({property:s={},values:t={},classes:r={}}={}){this.property=x({moxie:({key:i,secondValue:n})=>n?null:i},s),this.values=t,this.classes=r}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((l,e)=>e.length-l.length);const o=[...this.getAllClassNames(r)];return[...i,...o,...s].sort((l,e)=>e.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),r="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",n="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",o="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+r+"|"+i+"|"+n+"))|"+r+"|"+i+"|"+n,l=`(${t}|\\[[^\\]]+\\])`,e="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+r+"|"+n+"|"+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]+)|"+r+"|"+n+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:o,type:l,separator:e,value:h,unit:u,secondValuePattern:c,all:"^(?:("+o+"):)?"+l+e+h+u+c+"$"}}parse(s,t){const r=this.regexp(t),i=s.match(new RegExp(r.all));if(i){const[,o,l,e,h,u,c]=i;return[o,l,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,o){return`${s?`${s}:`:""}${t}${r?"-":""}${r}${i}${n?`/${n}${o}`:""}`}processValue(s,t,r){if(!s)return"";const i=n=>n.replace(/\{([^}]+)\}/g,(o,l)=>{const e=this.values,h=e!==null?typeof e[r]=="object"?e[r][l]:e[l]:void 0;return typeof h=="string"?h:o});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="",o="",l){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 b=c.match(h);if(b&&(u=b[1].trim(),c=b[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 f=this.processValue(p,r,s),y=this.processValue(n,o,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:f,prefix:i}}if(e){if(typeof e=="object"&&"property"in e){const C=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:C,unit:t.startsWith("[")?"":r,secondValue:t.startsWith("[")?"":o?n:y,secondUnit:t.startsWith("[")?"":o,key:u,raw:l}):e.property,g=e.value||"{0}";let W;if(typeof g=="function")W=g({value:C,unit:r,secondValue:o?n:y,secondUnit:o,key:u,raw:l});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,o),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("[")?"":o?n:y,secondUnit:t.startsWith("[")?"":o,key:u,raw:l}):e;return{className:this.constructRaw(i,s,t,r,n,o),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,o){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,e]=t.split("||").map(c=>c.trim()),h=this.processValue(r,i,s),u=this.processValue(n,o,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let c=l;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||l);const b=/\{1([^}]*)\}/g;let p;for(;(p=b.exec(c))!==null;){const f=p[0],y=p[1].trim();let a=u;!a&&y.includes("|")?a=y.split("|")[1].trim():a||(a=""),c=r.startsWith("[")?h:c.replace(f,a)}}return r?c:e||l}else return r?r.startsWith("[")?h:l.replace(/\{0\}/g,h):e||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",r="",i="",n="",o=""){if(!s)return null;const l=this.getParentClass(s),e=t&&s.endsWith(`-${t}${r}`);if(l.length>0){const h=l.map(u=>{const c=this.classes[u];if(!c||t&&!e&&c[s]&&!c[s].includes("{0}")&&!c[s].includes("|"))return null;const b=this.parseValuePattern(s,c[s]||"",t,r,n,o);return`${this.toKebabCase(String(u))}: ${b}`}).filter(Boolean).join("; ");return{className:e?s:this.constructRaw(i,s,t,r,n,o),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[o,l,e,h,u,c]=n;if(!l)continue;const b=this.getParentClass(`${l}-${e}`).length>0?`${l}-${e}`:l;try{const p=this.processCustomClass(b,e,h,o,u,c);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,l,e,h,u,c)]});continue}}catch(p){console.warn(`Error processing custom class "${i}":`,p)}try{const p=this.processShorthand(l,e,h,o,u,c,n);if(p){const{className:f,cssRules:y,value:a,prefix:C}=p;if(!y||y==="null")continue;r.push({className:this.escapeCSSSelector(f),cssRules:y,value:a,prefix:C,raw:[...n,this.constructRaw(o,l,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),[]}}}return m.TenoxUI=d,m.default=d,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
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,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,A)=>f in d?_(d,f,{enumerable:!0,configurable:!0,writable:!0,value:A}):d[f]=A,w=(d,f)=>{for(var A in f||(f={}))j.call(f,A)&&S(d,A,f[A]);if(P)for(var A of P(f))V.call(f,A)&&S(d,A,f[A]);return d};class f{constructor({property:s={},values:t={},classes:r={}}={}){this.property=w({moxie:({key:i,secondValue:n})=>n?null:i},s),this.values=t,this.classes=r}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((l,e)=>e.length-l.length);const c=[...this.getAllClassNames(r)];return[...i,...c,...s].sort((l,e)=>e.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),r="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",n="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+r+"|"+i+"|"+n+"))|"+r+"|"+i+"|"+n,l=`(${t}|\\[[^\\]]+\\])`,e="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+r+"|"+n+"|"+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]+)|"+r+"|"+n+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:e,value:h,unit:u,secondValuePattern:o,all:"^(?:("+c+"):)?"+l+e+h+u+o+"$"}}parse(s,t){const r=this.regexp(t),i=s.match(new RegExp(r.all));if(i){const[,c,l,e,h,u,o]=i;return[c,l,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,c){return`${s?`${s}:`:""}${t}${r?"-":""}${r}${i}${n?`/${n}${c}`:""}`}processValue(s,t,r){if(!s)return"";const i=n=>n.replace(/\{([^}]+)\}/g,(c,l)=>{const e=this.values,h=e!==null?typeof e[r]=="object"?e[r][l]:e[l]:void 0;return typeof h=="string"?h:c});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="",c="",l){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 b=o.match(h);if(b&&(u=b[1].trim(),o=b[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 y=this.processValue(p,r,s),g=this.processValue(n,c,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,$=typeof e.property=="function"?e.property({value:t.startsWith("[")?y:C,unit:t.startsWith("[")?"":r,secondValue:t.startsWith("[")?"":c?n:g,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):e.property,m=e.value||"{0}";let W;if(typeof m=="function")W=m({value:C,unit:r,secondValue:c?n:g,secondUnit:c,key:u,raw:l});else if(typeof m=="string"){const x=e.group||s,R=this.processValue(p,r,x);this.values[x]&&typeof this.values[x]=="object"&&this.values[x][p]?W=this.values[x][p]:m.includes("{")?W=this.parseValuePattern(x,m,R,"",g,""):typeof m=="string"&&!m.includes("{")?W=m:W=y}else if(Array.isArray(m)){if(!m.includes(t+r)||n)return null;W=t+r}else W=null;return(typeof e.property=="string"||Array.isArray(e.property))&&typeof m=="string"&&(t.includes(u+":")||!m.includes("{1")&&n)||(typeof e.property=="string"||Array.isArray(e.property))&&m===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,c),cssRules:$?Array.isArray($)?$:typeof $=="string"&&($.includes(":")||$.includes("value:"))?$.includes("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:m===null||$===null||$.includes(":")||$.includes("value:")?null:t.startsWith("[")?y:W,prefix:i}}const a=typeof e=="function"?e({value:t.startsWith("[")?y:r?t:y,unit:t.startsWith("[")?"":r,secondValue:t.startsWith("[")?"":c?n:g,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):e;return{className:this.constructRaw(i,s,t,r,n,c),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,c){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,e]=t.split("||").map(o=>o.trim()),h=this.processValue(r,i,s),u=this.processValue(n,c,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let o=l;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||l);const b=/\{1([^}]*)\}/g;let p;for(;(p=b.exec(o))!==null;){const y=p[0],g=p[1].trim();let a=u;!a&&g.includes("|")?a=g.split("|")[1].trim():a||(a=""),o=r.startsWith("[")?h:o.replace(y,a)}}return r?o:e||l}else return r?r.startsWith("[")?h:l.replace(/\{0\}/g,h):e||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",r="",i="",n="",c=""){if(!s)return null;const l=this.getParentClass(s),e=t&&s.endsWith(`-${t}${r}`);if(l.length>0){const h=l.map(u=>{const o=this.classes[u];if(!o||t&&!e&&o[s]&&!o[s].includes("{0}")&&!o[s].includes("|"))return null;const b=this.parseValuePattern(s,o[s]||"",t,r,n,c);return`${this.toKebabCase(String(u))}: ${b}`}).filter(Boolean).join("; ");return{className:e?s:this.constructRaw(i,s,t,r,n,c),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[c,l,e,h,u,o]=n;if(!l)continue;const b=this.getParentClass(`${l}-${e}`).length>0?`${l}-${e}`:l;try{const p=this.processCustomClass(b,e,h,c,u,o);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,l,e,h,u,o)]});continue}}catch(p){console.warn(`Error processing custom class "${i}":`,p)}try{const p=this.processShorthand(l,e,h,c,u,o,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(c,l,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),[]}}}d.TenoxUI=f,d.default=f,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.6",
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",