@tenoxui/moxie 0.6.7 → 0.6.8

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