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