@tenoxui/moxie 0.6.8 → 0.7.0

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