@tenoxui/moxie 0.6.8 → 0.7.1

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