@tenoxui/moxie 0.5.0-alpha.0 → 0.5.0-alpha.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 Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var x=(d,s,t)=>s in d?Z(d,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[s]=t,P=(d,s)=>{for(var t in s||(s={}))_.call(s,t)&&x(d,t,s[t]);if(W)for(var t of W(s))z.call(s,t)&&x(d,t,s[t]);return d};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:s={},values:t={},classes:e={}}={}){this.property=P({moxie:({key:i,secondValue:r})=>r?null:i},s),this.values=t,this.classes=e}toKebabCase(s){if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const t=s.match(/^(webkit|moz|ms|o)/);if(t){const e=t[0];return`-${e}${s.slice(e.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(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(s=[]){const t=this.property,e=this.classes,i=Object.keys(t);if(!e)return[...i,...s].sort((l,n)=>n.length-l.length);const c=[...this.getAllClassNames(e)];return[...i,...c,...s].sort((l,n)=>n.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${t}|\\[[^\\]]+\\])`,n="(?:-)",o="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",a="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:n,value:o,unit:u,secondValuePattern:a,all:"(?:("+c+"):)?"+l+n+o+u+a}}generateClassNameRegEx(s=[]){return new RegExp(this.regexp(s).all)}parse(s,t){if(Object.values(this.classes).some(f=>f==null?void 0:f[s]))return[void 0,s,"","",void 0,void 0,s];const e=this.generateClassNameRegEx(t),i=(s+"-dummy").match(e);if(!i)return null;const[,r,c,l,n,o,u]=i,a=l?l==="dummy"?"":l.replace("-dummy",""):"",$=o?o==="dummy"?"":o.replace("-dummy",""):"",h=`${r?`${r}:`:""}${c}-${a}${n}${o?`/${$}${u}`:""}`;return[r,c,a,n||"",$,u,h]}processValue(s,t,e){if(!s)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,o=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof o=="string"?o:c});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][s]||this.values[s]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const r=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",i,r="",c="",l){const n=this.property[s],o=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,a=t||"";const $=a.match(o);if($&&(u=$[1].trim(),a=$[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(u+":")||r))return null;let h;t.includes(u+":")?h=t.startsWith("(")?`(${a})`:`[${a}]`:h=t;const f=this.processValue(h,e,s),y=this.processValue(r,c,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const p=s.slice(1,-1).split(",").map(m=>m.trim().startsWith("--")?String(m.trim()):this.toKebabCase(String(m.trim())));return{className:`${s}-${t}${e}`,cssRules:p.length===1?p[0]:p,value:f,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const m=n.group&&this.values[n.group][f]?this.values[n.group][f]:e?t:f,g=typeof n.property=="function"?n.property({value:t.startsWith("[")?f:m,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n.property,C=n.value||"{0}";let b;if(typeof C=="function")b=C({value:m,unit:e,secondValue:c?r:y,secondUnit:c,key:u,raw:l});else if(typeof C=="string"){const A=n.group||s,R=this.processValue(h,e,A);this.values[A]&&typeof this.values[A]=="object"&&this.values[A][h]?b=this.values[A][h]:C.includes("{")?b=this.parseValuePattern(A,C,R,"",y,""):b=f}else b=null;const V=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof C=="string"&&(t.includes(u+":")||!C.includes("{1")&&r)?null:{className:V,cssRules:g?Array.isArray(g)?g:typeof g=="string"&&(g.includes(":")||g.includes("value:"))?g.includes("value:")?g.slice(6):this.toKebabCase(String(g)):this.toKebabCase(String(g)):null,value:C===null||g===null||g.includes(":")||g.includes("value:")?null:t.startsWith("[")?f:b,prefix:i}}const p=typeof n=="function"?n({value:t.startsWith("[")?f:e?t:f,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n;return{className:`${s}${t?"-"+t+e:""}${r?`/${r}${c}`:""}`,cssRules:p?Array.isArray(n)?p:typeof p=="string"&&(p.includes(":")||p.startsWith("value:"))?p.startsWith("value:")?p.slice(6):this.toKebabCase(String(p)):this.toKebabCase(String(p)):null,value:typeof p=="string"&&p.includes(":")?null:f,prefix:i}}return null}parseValuePattern(s,t,e,i,r,c){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,n]=t.split("||").map(a=>a.trim()),o=this.processValue(e,i,s),u=this.processValue(r,c,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let a=l;if(e&&(a=a.replace("{0}",o)),t.includes("{1")){const $=a.match(/{1([^}]*)}/);if(t.includes("{1}"))r?a=r.startsWith("[")?u:a.replace("{1}",u):a=n;else if($){const h=$[0],f=$[1].trim();let y=u;!y&&f.includes("|")?y=f.split("|")[1].trim():y||(y=""),a=e.startsWith("[")?o:a.replace(h,y)}}return e?a:n||l}else return e?e.startsWith("[")?o:l.replace("{0}",o):n||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",e="",i="",r="",c=""){if(!s)return null;const l=this.getParentClass(s);if(l.length>0){const n=l.map(a=>{const $=this.classes[a];if(!$||t&&!$[s].includes("||")||t&&!$[s].includes("|"))return null;const h=this.parseValuePattern(s,$[s]||"",t,e,r,c);return`${this.toKebabCase(String(a))}: ${h}`}).filter(Boolean).join("; "),o=s.slice(-(t+e).length),u=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return{className:t===o?s:u,cssRules:n,value:null,prefix:i}}return null}process(s){try{const t=Array.isArray(s)?s:s.split(/\s+/),e=[];for(const i of t)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[c,l,n,o,u,a]=r;if(!l)continue;const $=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass($,n,o,c,u,a);if(h){const{className:f,cssRules:y,prefix:p}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:null,prefix:p,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,o,c,u,a,r);if(h){const{className:f,cssRules:y,value:p,prefix:m}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:p,prefix:m,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(t){return console.error("Critical error in process method:",t),[]}}}exports.TenoxUI=S;exports.default=S;
1
+ "use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var x=(d,s,t)=>s in d?Z(d,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[s]=t,P=(d,s)=>{for(var t in s||(s={}))_.call(s,t)&&x(d,t,s[t]);if(W)for(var t of W(s))z.call(s,t)&&x(d,t,s[t]);return d};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:s={},values:t={},classes:e={}}={}){this.property=P({moxie:({key:i,secondValue:r})=>r?null:i},s),this.values=t,this.classes=e}toKebabCase(s){if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const t=s.match(/^(webkit|moz|ms|o)/);if(t){const e=t[0];return`-${e}${s.slice(e.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(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(s=[]){const t=this.property,e=this.classes,i=Object.keys(t);if(!e)return[...i,...s].sort((l,n)=>n.length-l.length);const c=[...this.getAllClassNames(e)];return[...i,...c,...s].sort((l,n)=>n.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${t}|\\[[^\\]]+\\])`,n="(?:-)",o="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",a="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:n,value:o,unit:u,secondValuePattern:a,all:"(?:("+c+"):)?"+l+n+o+u+a}}generateClassNameRegEx(s=[]){return new RegExp(this.regexp(s).all)}parse(s,t){if(Object.values(this.classes).some(f=>f==null?void 0:f[s]))return[void 0,s,"","",void 0,void 0,s];const e=this.generateClassNameRegEx(t),i=(s+"-dummy").match(e);if(!i)return null;const[,r,c,l,n,o,u]=i,a=l?l==="dummy"?"":l.replace("-dummy",""):"",$=o?o==="dummy"?"":o.replace("-dummy",""):"",h=`${r?`${r}:`:""}${c}${a?`-${a}`:""}${n}${o?`/${$}${u}`:""}`;return[r,c,a,n||"",$,u,h]}processValue(s,t,e){if(!s)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,o=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof o=="string"?o:c});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][s]||this.values[s]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const r=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",i,r="",c="",l){const n=this.property[s],o=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,a=t||"";const $=a.match(o);if($&&(u=$[1].trim(),a=$[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(u+":")||r))return null;let h;t.includes(u+":")?h=t.startsWith("(")?`(${a})`:`[${a}]`:h=t;const f=this.processValue(h,e,s),y=this.processValue(r,c,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const p=s.slice(1,-1).split(",").map(m=>m.trim().startsWith("--")?String(m.trim()):this.toKebabCase(String(m.trim())));return{className:`${s}-${t}${e}`,cssRules:p.length===1?p[0]:p,value:f,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const m=n.group&&this.values[n.group][f]?this.values[n.group][f]:e?t:f,g=typeof n.property=="function"?n.property({value:t.startsWith("[")?f:m,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n.property,C=n.value||"{0}";let b;if(typeof C=="function")b=C({value:m,unit:e,secondValue:c?r:y,secondUnit:c,key:u,raw:l});else if(typeof C=="string"){const A=n.group||s,R=this.processValue(h,e,A);this.values[A]&&typeof this.values[A]=="object"&&this.values[A][h]?b=this.values[A][h]:C.includes("{")?b=this.parseValuePattern(A,C,R,"",y,""):b=f}else b=null;const V=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof C=="string"&&(t.includes(u+":")||!C.includes("{1")&&r)?null:{className:V,cssRules:g?Array.isArray(g)?g:typeof g=="string"&&(g.includes(":")||g.includes("value:"))?g.includes("value:")?g.slice(6):this.toKebabCase(String(g)):this.toKebabCase(String(g)):null,value:C===null||g===null||g.includes(":")||g.includes("value:")?null:t.startsWith("[")?f:b,prefix:i}}const p=typeof n=="function"?n({value:t.startsWith("[")?f:e?t:f,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n;return{className:`${s}${t?"-"+t+e:""}${r?`/${r}${c}`:""}`,cssRules:p?Array.isArray(n)?p:typeof p=="string"&&(p.includes(":")||p.startsWith("value:"))?p.startsWith("value:")?p.slice(6):this.toKebabCase(String(p)):this.toKebabCase(String(p)):null,value:typeof p=="string"&&p.includes(":")?null:f,prefix:i}}return null}parseValuePattern(s,t,e,i,r,c){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,n]=t.split("||").map(a=>a.trim()),o=this.processValue(e,i,s),u=this.processValue(r,c,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let a=l;if(e&&(a=a.replace("{0}",o)),t.includes("{1")){const $=a.match(/{1([^}]*)}/);if(t.includes("{1}"))r?a=r.startsWith("[")?u:a.replace("{1}",u):a=n;else if($){const h=$[0],f=$[1].trim();let y=u;!y&&f.includes("|")?y=f.split("|")[1].trim():y||(y=""),a=e.startsWith("[")?o:a.replace(h,y)}}return e?a:n||l}else return e?e.startsWith("[")?o:l.replace("{0}",o):n||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",e="",i="",r="",c=""){if(!s)return null;const l=this.getParentClass(s);if(l.length>0){const n=l.map(a=>{const $=this.classes[a];if(!$||t&&!$[s].includes("||")||t&&!$[s].includes("|"))return null;const h=this.parseValuePattern(s,$[s]||"",t,e,r,c);return`${this.toKebabCase(String(a))}: ${h}`}).filter(Boolean).join("; "),o=s.slice(-(t+e).length),u=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return{className:t===o?s:u,cssRules:n,value:null,prefix:i}}return null}process(s){try{const t=Array.isArray(s)?s:s.split(/\s+/),e=[];for(const i of t)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[c,l,n,o,u,a]=r;if(!l)continue;const $=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass($,n,o,c,u,a);if(h){const{className:f,cssRules:y,prefix:p}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:null,prefix:p,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,o,c,u,a,r);if(h){const{className:f,cssRules:y,value:p,prefix:m}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:p,prefix:m,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(t){return console.error("Critical error in process method:",t),[]}}}exports.TenoxUI=S;exports.default=S;
package/dist/index.es.js CHANGED
@@ -73,7 +73,7 @@ class w {
73
73
  return [void 0, s, "", "", void 0, void 0, s];
74
74
  const e = this.generateClassNameRegEx(t), i = (s + "-dummy").match(e);
75
75
  if (!i) return null;
76
- const [, r, c, l, n, o, u] = i, a = l ? l === "dummy" ? "" : l.replace("-dummy", "") : "", $ = o ? o === "dummy" ? "" : o.replace("-dummy", "") : "", h = `${r ? `${r}:` : ""}${c}-${a}${n}${o ? `/${$}${u}` : ""}`;
76
+ const [, r, c, l, n, o, u] = i, a = l ? l === "dummy" ? "" : l.replace("-dummy", "") : "", $ = o ? o === "dummy" ? "" : o.replace("-dummy", "") : "", h = `${r ? `${r}:` : ""}${c}${a ? `-${a}` : ""}${n}${o ? `/${$}${u}` : ""}`;
77
77
  return [r, c, a, n || "", $, u, h];
78
78
  }
79
79
  // unique value parser
@@ -1 +1 @@
1
- var __tenoxui_moxie__=function(m){"use strict";var Z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var _=(m,g,C)=>g in m?Z(m,g,{enumerable:!0,configurable:!0,writable:!0,value:C}):m[g]=C,S=(m,g)=>{for(var C in g||(g={}))z.call(g,C)&&_(m,C,g[C]);if(x)for(var C of x(g))E.call(g,C)&&_(m,C,g[C]);return m};class g{constructor({property:s={},values:t={},classes:e={}}={}){this.property=S({moxie:({key:i,secondValue:r})=>r?null:i},s),this.values=t,this.classes=e}toKebabCase(s){if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const t=s.match(/^(webkit|moz|ms|o)/);if(t){const e=t[0];return`-${e}${s.slice(e.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(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(s=[]){const t=this.property,e=this.classes,i=Object.keys(t);if(!e)return[...i,...s].sort((l,n)=>n.length-l.length);const c=[...this.getAllClassNames(e)];return[...i,...c,...s].sort((l,n)=>n.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${t}|\\[[^\\]]+\\])`,n="(?:-)",o="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",a="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:n,value:o,unit:u,secondValuePattern:a,all:"(?:("+c+"):)?"+l+n+o+u+a}}generateClassNameRegEx(s=[]){return new RegExp(this.regexp(s).all)}parse(s,t){if(Object.values(this.classes).some(f=>f==null?void 0:f[s]))return[void 0,s,"","",void 0,void 0,s];const e=this.generateClassNameRegEx(t),i=(s+"-dummy").match(e);if(!i)return null;const[,r,c,l,n,o,u]=i,a=l?l==="dummy"?"":l.replace("-dummy",""):"",$=o?o==="dummy"?"":o.replace("-dummy",""):"",h=`${r?`${r}:`:""}${c}-${a}${n}${o?`/${$}${u}`:""}`;return[r,c,a,n||"",$,u,h]}processValue(s,t,e){if(!s)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,o=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof o=="string"?o:c});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][s]||this.values[s]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const r=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",i,r="",c="",l){const n=this.property[s],o=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,a=t||"";const $=a.match(o);if($&&(u=$[1].trim(),a=$[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(u+":")||r))return null;let h;t.includes(u+":")?h=t.startsWith("(")?`(${a})`:`[${a}]`:h=t;const f=this.processValue(h,e,s),y=this.processValue(r,c,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const p=s.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:`${s}-${t}${e}`,cssRules:p.length===1?p[0]:p,value:f,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const b=n.group&&this.values[n.group][f]?this.values[n.group][f]:e?t:f,d=typeof n.property=="function"?n.property({value:t.startsWith("[")?f:b,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n.property,A=n.value||"{0}";let W;if(typeof A=="function")W=A({value:b,unit:e,secondValue:c?r:y,secondUnit:c,key:u,raw:l});else if(typeof A=="string"){const P=n.group||s,R=this.processValue(h,e,P);this.values[P]&&typeof this.values[P]=="object"&&this.values[P][h]?W=this.values[P][h]:A.includes("{")?W=this.parseValuePattern(P,A,R,"",y,""):W=f}else W=null;const V=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof A=="string"&&(t.includes(u+":")||!A.includes("{1")&&r)?null:{className:V,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:A===null||d===null||d.includes(":")||d.includes("value:")?null:t.startsWith("[")?f:W,prefix:i}}const p=typeof n=="function"?n({value:t.startsWith("[")?f:e?t:f,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n;return{className:`${s}${t?"-"+t+e:""}${r?`/${r}${c}`:""}`,cssRules:p?Array.isArray(n)?p:typeof p=="string"&&(p.includes(":")||p.startsWith("value:"))?p.startsWith("value:")?p.slice(6):this.toKebabCase(String(p)):this.toKebabCase(String(p)):null,value:typeof p=="string"&&p.includes(":")?null:f,prefix:i}}return null}parseValuePattern(s,t,e,i,r,c){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,n]=t.split("||").map(a=>a.trim()),o=this.processValue(e,i,s),u=this.processValue(r,c,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let a=l;if(e&&(a=a.replace("{0}",o)),t.includes("{1")){const $=a.match(/{1([^}]*)}/);if(t.includes("{1}"))r?a=r.startsWith("[")?u:a.replace("{1}",u):a=n;else if($){const h=$[0],f=$[1].trim();let y=u;!y&&f.includes("|")?y=f.split("|")[1].trim():y||(y=""),a=e.startsWith("[")?o:a.replace(h,y)}}return e?a:n||l}else return e?e.startsWith("[")?o:l.replace("{0}",o):n||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",e="",i="",r="",c=""){if(!s)return null;const l=this.getParentClass(s);if(l.length>0){const n=l.map(a=>{const $=this.classes[a];if(!$||t&&!$[s].includes("||")||t&&!$[s].includes("|"))return null;const h=this.parseValuePattern(s,$[s]||"",t,e,r,c);return`${this.toKebabCase(String(a))}: ${h}`}).filter(Boolean).join("; "),o=s.slice(-(t+e).length),u=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return{className:t===o?s:u,cssRules:n,value:null,prefix:i}}return null}process(s){try{const t=Array.isArray(s)?s:s.split(/\s+/),e=[];for(const i of t)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[c,l,n,o,u,a]=r;if(!l)continue;const $=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass($,n,o,c,u,a);if(h){const{className:f,cssRules:y,prefix:p}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:null,prefix:p,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,o,c,u,a,r);if(h){const{className:f,cssRules:y,value:p,prefix:b}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:p,prefix:b,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(t){return console.error("Critical error in process method:",t),[]}}}return m.TenoxUI=g,m.default=g,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
1
+ var __tenoxui_moxie__=function(m){"use strict";var Z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var _=(m,g,C)=>g in m?Z(m,g,{enumerable:!0,configurable:!0,writable:!0,value:C}):m[g]=C,S=(m,g)=>{for(var C in g||(g={}))z.call(g,C)&&_(m,C,g[C]);if(x)for(var C of x(g))E.call(g,C)&&_(m,C,g[C]);return m};class g{constructor({property:s={},values:t={},classes:e={}}={}){this.property=S({moxie:({key:i,secondValue:r})=>r?null:i},s),this.values=t,this.classes=e}toKebabCase(s){if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const t=s.match(/^(webkit|moz|ms|o)/);if(t){const e=t[0];return`-${e}${s.slice(e.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(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(s=[]){const t=this.property,e=this.classes,i=Object.keys(t);if(!e)return[...i,...s].sort((l,n)=>n.length-l.length);const c=[...this.getAllClassNames(e)];return[...i,...c,...s].sort((l,n)=>n.length-l.length)}regexp(s){const t=this.getTypePrefixes(s).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${t}|\\[[^\\]]+\\])`,n="(?:-)",o="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",a="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:n,value:o,unit:u,secondValuePattern:a,all:"(?:("+c+"):)?"+l+n+o+u+a}}generateClassNameRegEx(s=[]){return new RegExp(this.regexp(s).all)}parse(s,t){if(Object.values(this.classes).some(f=>f==null?void 0:f[s]))return[void 0,s,"","",void 0,void 0,s];const e=this.generateClassNameRegEx(t),i=(s+"-dummy").match(e);if(!i)return null;const[,r,c,l,n,o,u]=i,a=l?l==="dummy"?"":l.replace("-dummy",""):"",$=o?o==="dummy"?"":o.replace("-dummy",""):"",h=`${r?`${r}:`:""}${c}${a?`-${a}`:""}${n}${o?`/${$}${u}`:""}`;return[r,c,a,n||"",$,u,h]}processValue(s,t,e){if(!s)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,o=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof o=="string"?o:c});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][s]||this.values[s]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const r=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return s+(t||"")}processShorthand(s="",t="",e="",i,r="",c="",l){const n=this.property[s],o=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,a=t||"";const $=a.match(o);if($&&(u=$[1].trim(),a=$[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!t||t.includes(u+":")||r))return null;let h;t.includes(u+":")?h=t.startsWith("(")?`(${a})`:`[${a}]`:h=t;const f=this.processValue(h,e,s),y=this.processValue(r,c,s);if(s.startsWith("[")&&s.endsWith("]")){if(!t||r)return null;const p=s.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:`${s}-${t}${e}`,cssRules:p.length===1?p[0]:p,value:f,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const b=n.group&&this.values[n.group][f]?this.values[n.group][f]:e?t:f,d=typeof n.property=="function"?n.property({value:t.startsWith("[")?f:b,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n.property,A=n.value||"{0}";let W;if(typeof A=="function")W=A({value:b,unit:e,secondValue:c?r:y,secondUnit:c,key:u,raw:l});else if(typeof A=="string"){const P=n.group||s,R=this.processValue(h,e,P);this.values[P]&&typeof this.values[P]=="object"&&this.values[P][h]?W=this.values[P][h]:A.includes("{")?W=this.parseValuePattern(P,A,R,"",y,""):W=f}else W=null;const V=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof A=="string"&&(t.includes(u+":")||!A.includes("{1")&&r)?null:{className:V,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:A===null||d===null||d.includes(":")||d.includes("value:")?null:t.startsWith("[")?f:W,prefix:i}}const p=typeof n=="function"?n({value:t.startsWith("[")?f:e?t:f,unit:t.startsWith("[")?"":e,secondValue:t.startsWith("[")?"":c?r:y,secondUnit:t.startsWith("[")?"":c,key:u,raw:l}):n;return{className:`${s}${t?"-"+t+e:""}${r?`/${r}${c}`:""}`,cssRules:p?Array.isArray(n)?p:typeof p=="string"&&(p.includes(":")||p.startsWith("value:"))?p.startsWith("value:")?p.slice(6):this.toKebabCase(String(p)):this.toKebabCase(String(p)):null,value:typeof p=="string"&&p.includes(":")?null:f,prefix:i}}return null}parseValuePattern(s,t,e,i,r,c){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,n]=t.split("||").map(a=>a.trim()),o=this.processValue(e,i,s),u=this.processValue(r,c,s);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let a=l;if(e&&(a=a.replace("{0}",o)),t.includes("{1")){const $=a.match(/{1([^}]*)}/);if(t.includes("{1}"))r?a=r.startsWith("[")?u:a.replace("{1}",u):a=n;else if($){const h=$[0],f=$[1].trim();let y=u;!y&&f.includes("|")?y=f.split("|")[1].trim():y||(y=""),a=e.startsWith("[")?o:a.replace(h,y)}}return e?a:n||l}else return e?e.startsWith("[")?o:l.replace("{0}",o):n||l}getParentClass(s){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],s))}processCustomClass(s,t="",e="",i="",r="",c=""){if(!s)return null;const l=this.getParentClass(s);if(l.length>0){const n=l.map(a=>{const $=this.classes[a];if(!$||t&&!$[s].includes("||")||t&&!$[s].includes("|"))return null;const h=this.parseValuePattern(s,$[s]||"",t,e,r,c);return`${this.toKebabCase(String(a))}: ${h}`}).filter(Boolean).join("; "),o=s.slice(-(t+e).length),u=`${s}${t?`-${t}${e}`:""}${r?`/${r}${c}`:""}`;return{className:t===o?s:u,cssRules:n,value:null,prefix:i}}return null}process(s){try{const t=Array.isArray(s)?s:s.split(/\s+/),e=[];for(const i of t)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[c,l,n,o,u,a]=r;if(!l)continue;const $=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass($,n,o,c,u,a);if(h){const{className:f,cssRules:y,prefix:p}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:null,prefix:p,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,o,c,u,a,r);if(h){const{className:f,cssRules:y,value:p,prefix:b}=h;if(!y||y==="null")continue;e.push({className:f,cssRules:y,value:p,prefix:b,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(t){return console.error("Critical error in process method:",t),[]}}}return m.TenoxUI=g,m.default=g,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function($,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):($=typeof globalThis!="undefined"?globalThis:$||self,y($.__tenoxui_moxie__={}))})(this,function($){"use strict";var Z=Object.defineProperty;var P=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=($,y,C)=>y in $?Z($,y,{enumerable:!0,configurable:!0,writable:!0,value:C}):$[y]=C,S=($,y)=>{for(var C in y||(y={}))j.call(y,C)&&_($,C,y[C]);if(P)for(var C of P(y))z.call(y,C)&&_($,C,y[C]);return $};class y{constructor({property:e={},values:s={},classes:t={}}={}){this.property=S({moxie:({key:i,secondValue:r})=>r?null:i},e),this.values=s,this.classes=t}toKebabCase(e){if(/^(webkit|moz|ms|o)[A-Z]/.test(e)){const s=e.match(/^(webkit|moz|ms|o)/);if(s){const t=s[0];return`-${t}${e.slice(t.length).replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`}}return e.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(e){return e.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(e){if(!e)return[];const s=new Set;return Object.entries(e).forEach(([t,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(e=[]){const s=this.property,t=this.classes,i=Object.keys(s);if(!t)return[...i,...e].sort((l,n)=>n.length-l.length);const c=[...this.getAllClassNames(t)];return[...i,...c,...e].sort((l,n)=>n.length-l.length)}regexp(e){const s=this.getTypePrefixes(e).join("|"),t="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+t+"|"+i+"|"+r+"))|"+t+"|"+i+"|"+r,l=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",a="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+t+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",o="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+t+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:n,value:a,unit:u,secondValuePattern:o,all:"(?:("+c+"):)?"+l+n+a+u+o}}generateClassNameRegEx(e=[]){return new RegExp(this.regexp(e).all)}parse(e,s){if(Object.values(this.classes).some(f=>f==null?void 0:f[e]))return[void 0,e,"","",void 0,void 0,e];const t=this.generateClassNameRegEx(s),i=(e+"-dummy").match(t);if(!i)return null;const[,r,c,l,n,a,u]=i,o=l?l==="dummy"?"":l.replace("-dummy",""):"",m=a?a==="dummy"?"":a.replace("-dummy",""):"",h=`${r?`${r}:`:""}${c}-${o}${n}${a?`/${m}${u}`:""}`;return[r,c,o,n||"",m,u,h]}processValue(e,s,t){if(!e)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,a=n!==null?typeof n[t]=="object"?n[t][l]:n[l]:void 0;return typeof a=="string"?a:c});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 r=e.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return e+(s||"")}processShorthand(e="",s="",t="",i,r="",c="",l){const n=this.property[e],a=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,o=s||"";const m=o.match(a);if(m&&(u=m[1].trim(),o=m[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(u+":")||r))return null;let h;s.includes(u+":")?h=s.startsWith("(")?`(${o})`:`[${o}]`:h=s;const f=this.processValue(h,t,e),d=this.processValue(r,c,e);if(e.startsWith("[")&&e.endsWith("]")){if(!s||r)return null;const p=e.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:`${e}-${s}${t}`,cssRules:p.length===1?p[0]:p,value:f,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const b=n.group&&this.values[n.group][f]?this.values[n.group][f]:t?s:f,g=typeof n.property=="function"?n.property({value:s.startsWith("[")?f:b,unit:s.startsWith("[")?"":t,secondValue:s.startsWith("[")?"":c?r:d,secondUnit:s.startsWith("[")?"":c,key:u,raw:l}):n.property,x=n.value||"{0}";let A;if(typeof x=="function")A=x({value:b,unit:t,secondValue:c?r:d,secondUnit:c,key:u,raw:l});else if(typeof x=="string"){const W=n.group||e,R=this.processValue(h,t,W);this.values[W]&&typeof this.values[W]=="object"&&this.values[W][h]?A=this.values[W][h]:x.includes("{")?A=this.parseValuePattern(W,x,R,"",d,""):A=f}else A=null;const V=`${e}${s?`-${s}${t}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof x=="string"&&(s.includes(u+":")||!x.includes("{1")&&r)?null:{className:V,cssRules:g?Array.isArray(g)?g:typeof g=="string"&&(g.includes(":")||g.includes("value:"))?g.includes("value:")?g.slice(6):this.toKebabCase(String(g)):this.toKebabCase(String(g)):null,value:x===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?f:A,prefix:i}}const p=typeof n=="function"?n({value:s.startsWith("[")?f:t?s:f,unit:s.startsWith("[")?"":t,secondValue:s.startsWith("[")?"":c?r:d,secondUnit:s.startsWith("[")?"":c,key:u,raw:l}):n;return{className:`${e}${s?"-"+s+t:""}${r?`/${r}${c}`:""}`,cssRules:p?Array.isArray(n)?p:typeof p=="string"&&(p.includes(":")||p.startsWith("value:"))?p.startsWith("value:")?p.slice(6):this.toKebabCase(String(p)):this.toKebabCase(String(p)):null,value:typeof p=="string"&&p.includes(":")?null:f,prefix:i}}return null}parseValuePattern(e,s,t,i,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[l,n]=s.split("||").map(o=>o.trim()),a=this.processValue(t,i,e),u=this.processValue(r,c,e);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let o=l;if(t&&(o=o.replace("{0}",a)),s.includes("{1")){const m=o.match(/{1([^}]*)}/);if(s.includes("{1}"))r?o=r.startsWith("[")?u:o.replace("{1}",u):o=n;else if(m){const h=m[0],f=m[1].trim();let d=u;!d&&f.includes("|")?d=f.split("|")[1].trim():d||(d=""),o=t.startsWith("[")?a:o.replace(h,d)}}return t?o:n||l}else return t?t.startsWith("[")?a:l.replace("{0}",a):n||l}getParentClass(e){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],e))}processCustomClass(e,s="",t="",i="",r="",c=""){if(!e)return null;const l=this.getParentClass(e);if(l.length>0){const n=l.map(o=>{const m=this.classes[o];if(!m||s&&!m[e].includes("||")||s&&!m[e].includes("|"))return null;const h=this.parseValuePattern(e,m[e]||"",s,t,r,c);return`${this.toKebabCase(String(o))}: ${h}`}).filter(Boolean).join("; "),a=e.slice(-(s+t).length),u=`${e}${s?`-${s}${t}`:""}${r?`/${r}${c}`:""}`;return{className:s===a?e:u,cssRules:n,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 r=this.parse(i);if(!r)continue;const[c,l,n,a,u,o]=r;if(!l)continue;const m=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass(m,n,a,c,u,o);if(h){const{className:f,cssRules:d,prefix:p}=h;if(!d||d==="null")continue;t.push({className:f,cssRules:d,value:null,prefix:p,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,a,c,u,o,r);if(h){const{className:f,cssRules:d,value:p,prefix:b}=h;if(!d||d==="null")continue;t.push({className:f,cssRules:d,value:p,prefix:b,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return t}catch(s){return console.error("Critical error in process method:",s),[]}}}$.TenoxUI=y,$.default=y,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(m,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(m=typeof globalThis!="undefined"?globalThis:m||self,y(m.__tenoxui_moxie__={}))})(this,function(m){"use strict";var Z=Object.defineProperty;var P=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(m,y,C)=>y in m?Z(m,y,{enumerable:!0,configurable:!0,writable:!0,value:C}):m[y]=C,S=(m,y)=>{for(var C in y||(y={}))j.call(y,C)&&_(m,C,y[C]);if(P)for(var C of P(y))z.call(y,C)&&_(m,C,y[C]);return m};class y{constructor({property:e={},values:s={},classes:t={}}={}){this.property=S({moxie:({key:i,secondValue:r})=>r?null:i},e),this.values=s,this.classes=t}toKebabCase(e){if(/^(webkit|moz|ms|o)[A-Z]/.test(e)){const s=e.match(/^(webkit|moz|ms|o)/);if(s){const t=s[0];return`-${t}${e.slice(t.length).replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`}}return e.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(e){return e.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(e){if(!e)return[];const s=new Set;return Object.entries(e).forEach(([t,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(e=[]){const s=this.property,t=this.classes,i=Object.keys(s);if(!t)return[...i,...e].sort((l,n)=>n.length-l.length);const c=[...this.getAllClassNames(t)];return[...i,...c,...e].sort((l,n)=>n.length-l.length)}regexp(e){const s=this.getTypePrefixes(e).join("|"),t="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+t+"|"+i+"|"+r+"))|"+t+"|"+i+"|"+r,l=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",a="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+t+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",o="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+t+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:l,separator:n,value:a,unit:u,secondValuePattern:o,all:"(?:("+c+"):)?"+l+n+a+u+o}}generateClassNameRegEx(e=[]){return new RegExp(this.regexp(e).all)}parse(e,s){if(Object.values(this.classes).some(f=>f==null?void 0:f[e]))return[void 0,e,"","",void 0,void 0,e];const t=this.generateClassNameRegEx(s),i=(e+"-dummy").match(t);if(!i)return null;const[,r,c,l,n,a,u]=i,o=l?l==="dummy"?"":l.replace("-dummy",""):"",$=a?a==="dummy"?"":a.replace("-dummy",""):"",h=`${r?`${r}:`:""}${c}${o?`-${o}`:""}${n}${a?`/${$}${u}`:""}`;return[r,c,o,n||"",$,u,h]}processValue(e,s,t){if(!e)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,a=n!==null?typeof n[t]=="object"?n[t][l]:n[l]:void 0;return typeof a=="string"?a:c});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 r=e.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?i(r):r.startsWith("--")?`var(${r})`:r}return e+(s||"")}processShorthand(e="",s="",t="",i,r="",c="",l){const n=this.property[e],a=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,o=s||"";const $=o.match(a);if($&&(u=$[1].trim(),o=$[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(u+":")||r))return null;let h;s.includes(u+":")?h=s.startsWith("(")?`(${o})`:`[${o}]`:h=s;const f=this.processValue(h,t,e),d=this.processValue(r,c,e);if(e.startsWith("[")&&e.endsWith("]")){if(!s||r)return null;const p=e.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:`${e}-${s}${t}`,cssRules:p.length===1?p[0]:p,value:f,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const b=n.group&&this.values[n.group][f]?this.values[n.group][f]:t?s:f,g=typeof n.property=="function"?n.property({value:s.startsWith("[")?f:b,unit:s.startsWith("[")?"":t,secondValue:s.startsWith("[")?"":c?r:d,secondUnit:s.startsWith("[")?"":c,key:u,raw:l}):n.property,x=n.value||"{0}";let A;if(typeof x=="function")A=x({value:b,unit:t,secondValue:c?r:d,secondUnit:c,key:u,raw:l});else if(typeof x=="string"){const W=n.group||e,R=this.processValue(h,t,W);this.values[W]&&typeof this.values[W]=="object"&&this.values[W][h]?A=this.values[W][h]:x.includes("{")?A=this.parseValuePattern(W,x,R,"",d,""):A=f}else A=null;const V=`${e}${s?`-${s}${t}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof x=="string"&&(s.includes(u+":")||!x.includes("{1")&&r)?null:{className:V,cssRules:g?Array.isArray(g)?g:typeof g=="string"&&(g.includes(":")||g.includes("value:"))?g.includes("value:")?g.slice(6):this.toKebabCase(String(g)):this.toKebabCase(String(g)):null,value:x===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?f:A,prefix:i}}const p=typeof n=="function"?n({value:s.startsWith("[")?f:t?s:f,unit:s.startsWith("[")?"":t,secondValue:s.startsWith("[")?"":c?r:d,secondUnit:s.startsWith("[")?"":c,key:u,raw:l}):n;return{className:`${e}${s?"-"+s+t:""}${r?`/${r}${c}`:""}`,cssRules:p?Array.isArray(n)?p:typeof p=="string"&&(p.includes(":")||p.startsWith("value:"))?p.startsWith("value:")?p.slice(6):this.toKebabCase(String(p)):this.toKebabCase(String(p)):null,value:typeof p=="string"&&p.includes(":")?null:f,prefix:i}}return null}parseValuePattern(e,s,t,i,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[l,n]=s.split("||").map(o=>o.trim()),a=this.processValue(t,i,e),u=this.processValue(r,c,e);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let o=l;if(t&&(o=o.replace("{0}",a)),s.includes("{1")){const $=o.match(/{1([^}]*)}/);if(s.includes("{1}"))r?o=r.startsWith("[")?u:o.replace("{1}",u):o=n;else if($){const h=$[0],f=$[1].trim();let d=u;!d&&f.includes("|")?d=f.split("|")[1].trim():d||(d=""),o=t.startsWith("[")?a:o.replace(h,d)}}return t?o:n||l}else return t?t.startsWith("[")?a:l.replace("{0}",a):n||l}getParentClass(e){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],e))}processCustomClass(e,s="",t="",i="",r="",c=""){if(!e)return null;const l=this.getParentClass(e);if(l.length>0){const n=l.map(o=>{const $=this.classes[o];if(!$||s&&!$[e].includes("||")||s&&!$[e].includes("|"))return null;const h=this.parseValuePattern(e,$[e]||"",s,t,r,c);return`${this.toKebabCase(String(o))}: ${h}`}).filter(Boolean).join("; "),a=e.slice(-(s+t).length),u=`${e}${s?`-${s}${t}`:""}${r?`/${r}${c}`:""}`;return{className:s===a?e:u,cssRules:n,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 r=this.parse(i);if(!r)continue;const[c,l,n,a,u,o]=r;if(!l)continue;const $=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass($,n,a,c,u,o);if(h){const{className:f,cssRules:d,prefix:p}=h;if(!d||d==="null")continue;t.push({className:f,cssRules:d,value:null,prefix:p,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,a,c,u,o,r);if(h){const{className:f,cssRules:d,value:p,prefix:b}=h;if(!d||d==="null")continue;t.push({className:f,cssRules:d,value:p,prefix:b,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return t}catch(s){return console.error("Critical error in process method:",s),[]}}}m.TenoxUI=y,m.default=y,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenoxui/moxie",
3
- "version": "0.5.0-alpha.0",
3
+ "version": "0.5.0-alpha.1",
4
4
  "description": "Very lightweight utility-first CSS engine for style generation",
5
5
  "author": "NOuSantx <nousantx@gmail.com>",
6
6
  "license": "MIT",