@tenoxui/moxie 0.4.3 → 0.4.4

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,j=Object.prototype.propertyIsEnumerable;var V=(x,t,e)=>t in x?Z(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,v=(x,t)=>{for(var e in t||(t={}))_.call(t,e)&&V(x,e,t[e]);if(W)for(var e of W(t))j.call(t,e)&&V(x,e,t[e]);return x};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:t={},values:e={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=v({moxie:({key:r})=>r},t),this.values=e,this.classes=s,this.useHyphens=n}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const e=t.match(/^(webkit|moz|ms|o)/);if(e){const s=e[0];return`-${s}${t.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/([ #{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const e=new Set;return Object.entries(t).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{e.add(r)})}),Array.from(e)}getTypePrefixes(t=[]){const e=this.property,s=this.classes,n=Object.keys(e);if(!s)return[...n,...t].sort((l,i)=>i.length-l.length);const a=[...this.getAllClassNames(s)];return[...n,...a,...t].sort((l,i)=>i.length-l.length)}regexp(t){const e=this.getTypePrefixes(t).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",a="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,l=`(${e}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",h="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:a,type:l,separator:i,value:u,unit:h,secondValuePattern:c,all:"(?:("+a+"):)?"+l+i+u+h+c}}generateClassNameRegEx(t=[]){return new RegExp(this.regexp(t).all)}parse(t,e){if(Object.values(this.classes).some(o=>o==null?void 0:o[t]))return[void 0,t,"","",void 0,void 0,t];const s=this.generateClassNameRegEx(e),n=(t+"-dummy").match(s);if(!n)return null;const[,r,a,l,i,u,h]=n,c=l?l==="dummy"?"":l.replace("-dummy",""):"",f=u?u==="dummy"?"":u.replace("-dummy",""):"";return[r,a,c,i||"",f,h,t]}processValue(t,e,s){if(!t)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(a,l)=>{const i=this.values,u=i!==null?typeof i[s]=="object"?i[s][l]:i[l]:void 0;return typeof u=="string"?u:a});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][t]||this.values[t]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(e||"")}processShorthand(t="",e="",s="",n,r="",a="",l=!0){const i=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let h=null,c=e||"";const f=c.match(u);f&&(h=f[1].trim(),c=f[2].trim());let o;e.includes(h+":")?o=e.startsWith("(")?`(${c})`:`[${c}]`:o=e;const p=this.processValue(o,s,t),g=this.processValue(r,a,t);if(t.startsWith("[")&&t.endsWith("]")){const C=t.slice(1,-1).split(",").map(y=>y.trim()).map(y=>`${y.startsWith("--")?String(y):this.toKebabCase(String(y))}: ${p}`).join("; ");return{className:`${`[${t.slice(1,-1)}]${l?"-":""}${e}${s}`}`,cssRules:C,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const C=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?e:p,y=typeof i.property=="function"?i.property({value:e.startsWith("[")?p:C,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":a?r:g,secondUnit:e.startsWith("[")?"":a,key:h}):i.property,m=i.value||"{0}";let P;if(typeof m=="function")P=m({value:C,unit:s,secondValue:a?r:g,secondUnit:a,key:h});else if(typeof m=="string"){const $=i.group||t,b=this.processValue(o,s,$);this.values[$]&&typeof this.values[$]=="object"&&this.values[$][o]?P=this.values[$][o]:m.includes("{")?P=this.parseValuePattern($,m,b,"",g,""):P=p}else P=null;return{className:`${t}${e?`${l&&l?"-":""}${e}${s}`:""}${r?`/${r}${a}`:""}`,cssRules:Array.isArray(y)?y:typeof y=="string"&&(y.includes(":")||y.includes("value:"))?y.includes("value:")?y.slice(6):this.toKebabCase(String(y)):this.toKebabCase(String(y)),value:m===null||y.includes("value:")?null:e.startsWith("[")?p:P,prefix:n}}const d=typeof i=="function"?i({value:e.startsWith("[")?p:s?e:p,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":a?r:g,secondUnit:e.startsWith("[")?"":a,key:h}):i;return{className:`${t}${e?(l?"-":"")+e+s:""}${r?`/${r}${a}`:""}`,cssRules:Array.isArray(i)?d:typeof d=="string"&&d.startsWith("value:")?d.slice(6):this.toKebabCase(String(d)),value:typeof d=="string"&&d.startsWith("value:")?null:p,prefix:n}}return null}parseValuePattern(t,e,s,n,r,a){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[l,i]=e.split("||").map(c=>c.trim()),u=this.processValue(s,n,t),h=this.processValue(r,a,t);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let c=l;if(s&&(c=c.replace("{0}",u)),e.includes("{1")){const f=c.match(/{1([^}]*)}/);if(e.includes("{1}"))r?c=r.startsWith("[")?h:c.replace("{1}",h):c=i;else if(f){const o=f[0],p=f[1].trim();let g=h;!g&&p.includes("|")?g=p.split("|")[1].trim():g||(g=""),c=s.startsWith("[")?u:c.replace(o,g)}}return s?c:i||l}else return s?s.startsWith("[")?u:l.replace("{0}",u):i||l}getParentClass(t){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],t))}processCustomClass(t,e="",s="",n="",r="",a="",l=!0){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const u=i.map(f=>{const o=this.classes[f];if(!o||e&&!o[t].includes("||")||e&&!o[t].includes("|"))return"";const p=this.parseValuePattern(t,o[t]||"",e,s,r,a);return`${this.toKebabCase(String(f))}: ${p}`}).filter(Boolean).join("; "),h=t.slice(-(e+s).length),c=`${t}${e?`${l?"-":""}${e}${s}`:""}${r?`/${r}${a}`:""}`;return{className:e===h?t:c,cssRules:u,value:null,prefix:n}}return null}process(t){const e=Array.isArray(t)?t:t.split(/\s+/),s=[];return e.forEach(n=>{if(!n)return this;const[r,a]=n.split(":"),l=a||r,i=a?r:void 0,u=this.parse(n),h=u||[i,l,"",""];if(!h)return this;const[c,f,o,p,g,d]=h,C=!n.includes((f||"")+(o||"")),y=this.getParentClass(`${f}${C?"-":""}${o}`).length>0?`${f}${C?"-":""}${o}`:f,m=this.processCustomClass(y,o,p,c,g,d,C);if(m){const{className:A,cssRules:$,prefix:b}=m;if(!$||$==="null")return;s.push({className:A,cssRules:$,value:null,prefix:b,raw:h});return}const P=this.processShorthand(f,o,p,c,g,d,C);if(P){const{className:A,cssRules:$,value:b,prefix:R}=P;if(!$||$==="null")return;s.push({className:A,cssRules:$,value:b,prefix:R,raw:h})}}),s}}exports.TenoxUI=S;exports.default=S;
1
+ "use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var V=(A,t,e)=>t in A?Z(A,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):A[t]=e,S=(A,t)=>{for(var e in t||(t={}))_.call(t,e)&&V(A,e,t[e]);if(W)for(var e of W(t))j.call(t,e)&&V(A,e,t[e]);return A};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class v{constructor({property:t={},values:e={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=S({moxie:({key:r,secondValue:l})=>l?null:r},t),this.values=e,this.classes=s,this.useHyphens=n}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const e=t.match(/^(webkit|moz|ms|o)/);if(e){const s=e[0];return`-${s}${t.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const e=new Set;return Object.entries(t).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{e.add(r)})}),Array.from(e)}getTypePrefixes(t=[]){const e=this.property,s=this.classes,n=Object.keys(e);if(!s)return[...n,...t].sort((a,i)=>i.length-a.length);const l=[...this.getAllClassNames(s)];return[...n,...l,...t].sort((a,i)=>i.length-a.length)}regexp(t){const e=this.getTypePrefixes(t).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",l="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,a=`(${e}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",y="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:l,type:a,separator:i,value:h,unit:y,secondValuePattern:c,all:"(?:("+l+"):)?"+a+i+h+y+c}}generateClassNameRegEx(t=[]){return new RegExp(this.regexp(t).all)}parse(t,e){if(Object.values(this.classes).some(o=>o==null?void 0:o[t]))return[void 0,t,"","",void 0,void 0,t];const s=this.generateClassNameRegEx(e),n=(t+"-dummy").match(s);if(!n)return null;const[,r,l,a,i,h,y]=n,c=a?a==="dummy"?"":a.replace("-dummy",""):"",f=h?h==="dummy"?"":h.replace("-dummy",""):"";return[r,l,c,i||"",f,y,t]}processValue(t,e,s){if(!t)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(l,a)=>{const i=this.values,h=i!==null?typeof i[s]=="object"?i[s][a]:i[a]:void 0;return typeof h=="string"?h:l});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][t]||this.values[t]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(e||"")}processShorthand(t="",e="",s="",n,r="",l="",a=!0){const i=this.property[t],h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let y=null,c=e||"";const f=c.match(h);f&&(y=f[1].trim(),c=f[2].trim());let o;e.includes(y+":")?o=e.startsWith("(")?`(${c})`:`[${c}]`:o=e;const p=this.processValue(o,s,t),g=this.processValue(r,l,t);if(t.startsWith("[")&&t.endsWith("]")){const C=t.slice(1,-1).split(",").map(u=>u.trim()).map(u=>`${u?u.startsWith("--")?String(u):this.toKebabCase(String(u)):null}: ${p}`).join("; ");return{className:`${`[${t.slice(1,-1)}]${a?"-":""}${e}${s}`}`,cssRules:C,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const C=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?e:p,u=typeof i.property=="function"?i.property({value:e.startsWith("[")?p:C,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i.property,m=i.value||"{0}";let b;if(typeof m=="function")b=m({value:C,unit:s,secondValue:l?r:g,secondUnit:l,key:y});else if(typeof m=="string"){const d=i.group||t,P=this.processValue(o,s,d);this.values[d]&&typeof this.values[d]=="object"&&this.values[d][o]?b=this.values[d][o]:m.includes("{")?b=this.parseValuePattern(d,m,P,"",g,""):b=p}else b=null;const x=`${t}${e?`${a&&a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return typeof i.property=="string"&&typeof m=="string"&&!m.includes("{1")&&r?null:{className:x,cssRules:u?Array.isArray(u)?u:typeof u=="string"&&(u.includes(":")||u.includes("value:"))?u.includes("value:")?u.slice(6):this.toKebabCase(String(u)):this.toKebabCase(String(u)):null,value:m===null||u===null||u.includes(":")||u.includes("value:")?null:e.startsWith("[")?p:b,prefix:n}}const $=typeof i=="function"?i({value:e.startsWith("[")?p:s?e:p,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i;return(typeof i=="string"||Array.isArray(i))&&r?null:{className:`${t}${e?(a?"-":"")+e+s:""}${r?`/${r}${l}`:""}`,cssRules:$?Array.isArray(i)?$:typeof $=="string"&&($.includes(":")||$.startsWith("value:"))?$.startsWith("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:typeof $=="string"&&$.includes(":")?null:p,prefix:n}}return null}parseValuePattern(t,e,s,n,r,l){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[a,i]=e.split("||").map(c=>c.trim()),h=this.processValue(s,n,t),y=this.processValue(r,l,t);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let c=a;if(s&&(c=c.replace("{0}",h)),e.includes("{1")){const f=c.match(/{1([^}]*)}/);if(e.includes("{1}"))r?c=r.startsWith("[")?y:c.replace("{1}",y):c=i;else if(f){const o=f[0],p=f[1].trim();let g=y;!g&&p.includes("|")?g=p.split("|")[1].trim():g||(g=""),c=s.startsWith("[")?h:c.replace(o,g)}}return s?c:i||a}else return s?s.startsWith("[")?h:a.replace("{0}",h):i||a}getParentClass(t){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],t))}processCustomClass(t,e="",s="",n="",r="",l="",a=!0){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const h=i.map(f=>{const o=this.classes[f];if(!o||e&&!o[t].includes("||")||e&&!o[t].includes("|"))return"";const p=this.parseValuePattern(t,o[t]||"",e,s,r,l);return`${this.toKebabCase(String(f))}: ${p}`}).filter(Boolean).join("; "),y=t.slice(-(e+s).length),c=`${t}${e?`${a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return{className:e===y?t:c,cssRules:h,value:null,prefix:n}}return null}process(t){const e=Array.isArray(t)?t:t.split(/\s+/),s=[];return e.forEach(n=>{if(!n)return this;const[r,l]=n.split(":"),a=l||r,i=l?r:void 0,h=this.parse(n),y=h||[i,a,"",""];if(!y)return this;const[c,f,o,p,g,$]=y,C=!n.includes((f||"")+(o||"")),u=this.getParentClass(`${f}${C?"-":""}${o}`).length>0?`${f}${C?"-":""}${o}`:f,m=this.processCustomClass(u,o,p,c,g,$,C);if(m){const{className:x,cssRules:d,prefix:P}=m;if(!d||d==="null")return;s.push({className:x,cssRules:d,value:null,prefix:P,raw:[P,f,o,p,g,$]});return}const b=this.processShorthand(f,o,p,c,g,$,C);if(b){const{className:x,cssRules:d,value:P,prefix:R}=b;if(!d||d==="null")return;s.push({className:x,cssRules:d,value:P,prefix:R,raw:[c,f,o,p,g,$]})}}),s}}exports.TenoxUI=v;exports.default=v;
package/dist/index.es.js CHANGED
@@ -1,18 +1,20 @@
1
- var S = Object.defineProperty;
2
- var b = Object.getOwnPropertySymbols;
1
+ var R = Object.defineProperty;
2
+ var W = Object.getOwnPropertySymbols;
3
3
  var Z = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
4
- var V = (P, t, s) => t in P ? S(P, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : P[t] = s, v = (P, t) => {
4
+ var V = (x, t, s) => t in x ? R(x, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : x[t] = s, S = (x, t) => {
5
5
  for (var s in t || (t = {}))
6
- Z.call(t, s) && V(P, s, t[s]);
7
- if (b)
8
- for (var s of b(t))
9
- z.call(t, s) && V(P, s, t[s]);
10
- return P;
6
+ Z.call(t, s) && V(x, s, t[s]);
7
+ if (W)
8
+ for (var s of W(t))
9
+ z.call(t, s) && V(x, s, t[s]);
10
+ return x;
11
11
  };
12
12
  class _ {
13
13
  constructor({ property: t = {}, values: s = {}, classes: e = {}, alwaysUseHyphens: n = !0 } = {}) {
14
- this.property = v({
15
- moxie: ({ key: r }) => r
14
+ this.property = S({
15
+ // use moxie-* 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: r, secondValue: l }) => l ? null : r
16
18
  }, t), this.values = s, this.classes = e, this.useHyphens = n;
17
19
  }
18
20
  toKebabCase(t) {
@@ -26,7 +28,7 @@ class _ {
26
28
  return t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
27
29
  }
28
30
  escapeCSSSelector(t) {
29
- return t.replace(/([ #{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
31
+ return t.replace(/^(\d)/, "\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
30
32
  }
31
33
  getAllClassNames(t) {
32
34
  if (!t) return [];
@@ -40,27 +42,27 @@ class _ {
40
42
  getTypePrefixes(t = []) {
41
43
  const s = this.property, e = this.classes, n = Object.keys(s);
42
44
  if (!e)
43
- return [...n, ...t].sort((l, i) => i.length - l.length);
44
- const a = [...this.getAllClassNames(e)];
45
- return [...n, ...a, ...t].sort((l, i) => i.length - l.length);
45
+ return [...n, ...t].sort((a, i) => i.length - a.length);
46
+ const l = [...this.getAllClassNames(e)];
47
+ return [...n, ...l, ...t].sort((a, i) => i.length - a.length);
46
48
  }
47
49
  regexp(t) {
48
- const s = this.getTypePrefixes(t).join("|"), e = "\\[[^\\]]+\\]", n = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", a = (
50
+ const s = this.getTypePrefixes(t).join("|"), e = "\\[[^\\]]+\\]", n = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", l = (
49
51
  // Simple prefix (hover, md, focus, etc.)
50
52
  "[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:" + e + "|" + n + "|" + r + "))|" + // Direct bracket, parenthesis, or brace content
51
53
  e + "|" + n + "|" + r
52
- ), l = `(${s}|\\[[^\\]]+\\])`, i = this.useHyphens ? "(?:-)" : "(?:-)?", u = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
54
+ ), a = `(${s}|\\[[^\\]]+\\])`, i = this.useHyphens ? "(?:-)" : "(?:-)?", h = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
53
55
  e + "|" + // Bracket content
54
56
  r + "|" + // Curly brace content
55
- n + "|(?:\\$[^\\s\\/]+))", h = "([a-zA-Z%]*)", c = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + e + "|" + r + "|" + n + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
57
+ n + "|(?:\\$[^\\s\\/]+))", y = "([a-zA-Z%]*)", c = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + e + "|" + r + "|" + n + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
56
58
  return {
57
- prefix: a,
58
- type: l,
59
+ prefix: l,
60
+ type: a,
59
61
  separator: i,
60
- value: u,
61
- unit: h,
62
+ value: h,
63
+ unit: y,
62
64
  secondValuePattern: c,
63
- all: "(?:(" + a + "):)?" + l + i + u + h + c
65
+ all: "(?:(" + l + "):)?" + a + i + h + y + c
64
66
  };
65
67
  }
66
68
  generateClassNameRegEx(t = []) {
@@ -71,15 +73,15 @@ class _ {
71
73
  return [void 0, t, "", "", void 0, void 0, t];
72
74
  const e = this.generateClassNameRegEx(s), n = (t + "-dummy").match(e);
73
75
  if (!n) return null;
74
- const [, r, a, l, i, u, h] = n, c = l ? l === "dummy" ? "" : l.replace("-dummy", "") : "", f = u ? u === "dummy" ? "" : u.replace("-dummy", "") : "";
75
- return [r, a, c, i || "", f, h, t];
76
+ const [, r, l, a, i, h, y] = n, c = a ? a === "dummy" ? "" : a.replace("-dummy", "") : "", f = h ? h === "dummy" ? "" : h.replace("-dummy", "") : "";
77
+ return [r, l, c, i || "", f, y, t];
76
78
  }
77
79
  // unique value parser
78
80
  processValue(t, s, e) {
79
81
  if (!t) return "";
80
- const n = (r) => r.replace(/\{([^}]+)\}/g, (a, l) => {
81
- const i = this.values, u = i !== null ? typeof i[e] == "object" ? i[e][l] : i[l] : void 0;
82
- return typeof u == "string" ? u : a;
82
+ const n = (r) => r.replace(/\{([^}]+)\}/g, (l, a) => {
83
+ const i = this.values, h = i !== null ? typeof i[e] == "object" ? i[e][a] : i[a] : void 0;
84
+ return typeof h == "string" ? h : l;
83
85
  });
84
86
  if (typeof this.values == "object" && this.values !== null && (this.values[e] && typeof this.values[e] == "object" && this.values[e][t] || this.values[t]))
85
87
  return typeof this.values[e] == "object" && this.values[e] !== null ? this.values[e][t] : this.values[t];
@@ -91,18 +93,18 @@ class _ {
91
93
  }
92
94
  return t + (s || "");
93
95
  }
94
- processShorthand(t = "", s = "", e = "", n, r = "", a = "", l = !0) {
95
- const i = this.property[t], u = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
96
- let h = null, c = s || "";
97
- const f = c.match(u);
98
- f && (h = f[1].trim(), c = f[2].trim());
96
+ processShorthand(t = "", s = "", e = "", n, r = "", l = "", a = !0) {
97
+ const i = this.property[t], h = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
98
+ let y = null, c = s || "";
99
+ const f = c.match(h);
100
+ f && (y = f[1].trim(), c = f[2].trim());
99
101
  let o;
100
- s.includes(h + ":") ? o = s.startsWith("(") ? `(${c})` : `[${c}]` : o = s;
101
- const p = this.processValue(o, e, t), g = this.processValue(r, a, t);
102
+ s.includes(y + ":") ? o = s.startsWith("(") ? `(${c})` : `[${c}]` : o = s;
103
+ const p = this.processValue(o, e, t), g = this.processValue(r, l, t);
102
104
  if (t.startsWith("[") && t.endsWith("]")) {
103
- const C = t.slice(1, -1).split(",").map((y) => y.trim()).map((y) => `${y.startsWith("--") ? String(y) : this.toKebabCase(String(y))}: ${p}`).join("; ");
105
+ const C = t.slice(1, -1).split(",").map((u) => u.trim()).map((u) => `${u ? u.startsWith("--") ? String(u) : this.toKebabCase(String(u)) : null}: ${p}`).join("; ");
104
106
  return {
105
- className: `${`[${t.slice(1, -1)}]${l ? "-" : ""}${s}${e}`}`,
107
+ className: `${`[${t.slice(1, -1)}]${a ? "-" : ""}${s}${e}`}`,
106
108
  cssRules: C,
107
109
  // return css rules directly
108
110
  value: null,
@@ -112,75 +114,76 @@ class _ {
112
114
  }
113
115
  if (i) {
114
116
  if (typeof i == "object" && "property" in i) {
115
- const C = i.group && this.values[i.group][p] ? this.values[i.group][p] : e ? s : p, y = typeof i.property == "function" ? i.property({
117
+ const C = i.group && this.values[i.group][p] ? this.values[i.group][p] : e ? s : p, u = typeof i.property == "function" ? i.property({
116
118
  value: s.startsWith("[") ? p : C,
117
119
  unit: s.startsWith("[") ? "" : e,
118
- secondValue: s.startsWith("[") ? "" : a ? r : g,
119
- secondUnit: s.startsWith("[") ? "" : a,
120
- key: h
121
- }) : i.property, d = i.value || "{0}";
122
- let x;
123
- if (typeof d == "function")
124
- x = d({
120
+ secondValue: s.startsWith("[") ? "" : l ? r : g,
121
+ secondUnit: s.startsWith("[") ? "" : l,
122
+ key: y
123
+ }) : i.property, m = i.value || "{0}";
124
+ let A;
125
+ if (typeof m == "function")
126
+ A = m({
125
127
  value: C,
126
128
  unit: e,
127
- secondValue: a ? r : g,
128
- secondUnit: a,
129
- key: h
129
+ secondValue: l ? r : g,
130
+ secondUnit: l,
131
+ key: y
130
132
  });
131
- else if (typeof d == "string") {
132
- const $ = i.group || t, A = this.processValue(o, e, $);
133
- this.values[$] && typeof this.values[$] == "object" && this.values[$][o] ? x = this.values[$][o] : d.includes("{") ? x = this.parseValuePattern(
134
- $,
133
+ else if (typeof m == "string") {
134
+ const d = i.group || t, P = this.processValue(o, e, d);
135
+ this.values[d] && typeof this.values[d] == "object" && this.values[d][o] ? A = this.values[d][o] : m.includes("{") ? A = this.parseValuePattern(
135
136
  d,
136
- A,
137
+ m,
138
+ P,
137
139
  "",
138
140
  g,
139
141
  ""
140
- ) : x = p;
141
- } else x = null;
142
- return {
143
- className: `${t}${s ? `${l && l ? "-" : ""}${s}${e}` : ""}${r ? `/${r}${a}` : ""}`,
144
- cssRules: Array.isArray(y) ? y : typeof y == "string" && (y.includes(":") || y.includes("value:")) ? y.includes("value:") ? y.slice(6) : this.toKebabCase(String(y)) : this.toKebabCase(String(y)),
145
- value: d === null || y.includes("value:") ? null : s.startsWith("[") ? p : x,
142
+ ) : A = p;
143
+ } else A = null;
144
+ const b = `${t}${s ? `${a && a ? "-" : ""}${s}${e}` : ""}${r ? `/${r}${l}` : ""}`;
145
+ return typeof i.property == "string" && typeof m == "string" && !m.includes("{1") && r ? null : {
146
+ className: b,
147
+ cssRules: u ? Array.isArray(u) ? u : typeof u == "string" && (u.includes(":") || u.includes("value:")) ? u.includes("value:") ? u.slice(6) : this.toKebabCase(String(u)) : this.toKebabCase(String(u)) : null,
148
+ value: m === null || u === null || u.includes(":") || u.includes("value:") ? null : s.startsWith("[") ? p : A,
146
149
  prefix: n
147
150
  };
148
151
  }
149
- const m = typeof i == "function" ? i({
152
+ const $ = typeof i == "function" ? i({
150
153
  value: s.startsWith("[") ? p : e ? s : p,
151
154
  unit: s.startsWith("[") ? "" : e,
152
- secondValue: s.startsWith("[") ? "" : a ? r : g,
153
- secondUnit: s.startsWith("[") ? "" : a,
154
- key: h
155
+ secondValue: s.startsWith("[") ? "" : l ? r : g,
156
+ secondUnit: s.startsWith("[") ? "" : l,
157
+ key: y
155
158
  }) : i;
156
- return {
157
- className: `${t}${s ? (l ? "-" : "") + s + e : ""}${r ? `/${r}${a}` : ""}`,
158
- cssRules: Array.isArray(i) ? m : typeof m == "string" && m.startsWith("value:") ? m.slice(6) : this.toKebabCase(String(m)),
159
- value: typeof m == "string" && m.startsWith("value:") ? null : p,
159
+ return (typeof i == "string" || Array.isArray(i)) && r ? null : {
160
+ className: `${t}${s ? (a ? "-" : "") + s + e : ""}${r ? `/${r}${l}` : ""}`,
161
+ cssRules: $ ? Array.isArray(i) ? $ : typeof $ == "string" && ($.includes(":") || $.startsWith("value:")) ? $.startsWith("value:") ? $.slice(6) : this.toKebabCase(String($)) : this.toKebabCase(String($)) : null,
162
+ value: typeof $ == "string" && $.includes(":") ? null : p,
160
163
  prefix: n
161
164
  };
162
165
  }
163
166
  return null;
164
167
  }
165
- parseValuePattern(t, s, e, n, r, a) {
168
+ parseValuePattern(t, s, e, n, r, l) {
166
169
  if (!s.includes("{0}") && !s.includes("{1") && !s.includes("||"))
167
170
  return s;
168
- const [l, i] = s.split("||").map((c) => c.trim()), u = this.processValue(e, n, t), h = this.processValue(r, a, t);
171
+ const [a, i] = s.split("||").map((c) => c.trim()), h = this.processValue(e, n, t), y = this.processValue(r, l, t);
169
172
  if (s.includes("{0}") && s.includes("{1") || s.includes("{1")) {
170
- let c = l;
171
- if (e && (c = c.replace("{0}", u)), s.includes("{1")) {
173
+ let c = a;
174
+ if (e && (c = c.replace("{0}", h)), s.includes("{1")) {
172
175
  const f = c.match(/{1([^}]*)}/);
173
176
  if (s.includes("{1}"))
174
- r ? c = r.startsWith("[") ? h : c.replace("{1}", h) : c = i;
177
+ r ? c = r.startsWith("[") ? y : c.replace("{1}", y) : c = i;
175
178
  else if (f) {
176
179
  const o = f[0], p = f[1].trim();
177
- let g = h;
178
- !g && p.includes("|") ? g = p.split("|")[1].trim() : g || (g = ""), c = e.startsWith("[") ? u : c.replace(o, g);
180
+ let g = y;
181
+ !g && p.includes("|") ? g = p.split("|")[1].trim() : g || (g = ""), c = e.startsWith("[") ? h : c.replace(o, g);
179
182
  }
180
183
  }
181
- return e ? c : i || l;
184
+ return e ? c : i || a;
182
185
  } else
183
- return e ? e.startsWith("[") ? u : l.replace("{0}", u) : i || l;
186
+ return e ? e.startsWith("[") ? h : a.replace("{0}", h) : i || a;
184
187
  }
185
188
  getParentClass(t) {
186
189
  return Object.keys(this.classes).filter(
@@ -190,11 +193,11 @@ class _ {
190
193
  )
191
194
  );
192
195
  }
193
- processCustomClass(t, s = "", e = "", n = "", r = "", a = "", l = !0) {
196
+ processCustomClass(t, s = "", e = "", n = "", r = "", l = "", a = !0) {
194
197
  if (!t) return null;
195
198
  const i = this.getParentClass(t);
196
199
  if (i.length > 0) {
197
- const u = i.map((f) => {
200
+ const h = i.map((f) => {
198
201
  const o = this.classes[f];
199
202
  if (!o || s && !o[t].includes("||") || s && !o[t].includes("|"))
200
203
  return "";
@@ -204,13 +207,13 @@ class _ {
204
207
  s,
205
208
  e,
206
209
  r,
207
- a
210
+ l
208
211
  );
209
212
  return `${this.toKebabCase(String(f))}: ${p}`;
210
- }).filter(Boolean).join("; "), h = t.slice(-(s + e).length), c = `${t}${s ? `${l ? "-" : ""}${s}${e}` : ""}${r ? `/${r}${a}` : ""}`;
213
+ }).filter(Boolean).join("; "), y = t.slice(-(s + e).length), c = `${t}${s ? `${a ? "-" : ""}${s}${e}` : ""}${r ? `/${r}${l}` : ""}`;
211
214
  return {
212
- className: s === h ? t : c,
213
- cssRules: u,
215
+ className: s === y ? t : c,
216
+ cssRules: h,
214
217
  value: null,
215
218
  prefix: n
216
219
  };
@@ -221,39 +224,39 @@ class _ {
221
224
  const s = Array.isArray(t) ? t : t.split(/\s+/), e = [];
222
225
  return s.forEach((n) => {
223
226
  if (!n) return this;
224
- const [r, a] = n.split(":"), l = a || r, i = a ? r : void 0, u = this.parse(n), h = u || [i, l, "", ""];
225
- if (!h) return this;
226
- const [c, f, o, p, g, m] = h, C = !n.includes((f || "") + (o || "")), y = this.getParentClass(`${f}${C ? "-" : ""}${o}`).length > 0 ? `${f}${C ? "-" : ""}${o}` : f, d = this.processCustomClass(
227
- y,
227
+ const [r, l] = n.split(":"), a = l || r, i = l ? r : void 0, h = this.parse(n), y = h || [i, a, "", ""];
228
+ if (!y) return this;
229
+ const [c, f, o, p, g, $] = y, C = !n.includes((f || "") + (o || "")), u = this.getParentClass(`${f}${C ? "-" : ""}${o}`).length > 0 ? `${f}${C ? "-" : ""}${o}` : f, m = this.processCustomClass(
230
+ u,
228
231
  o,
229
232
  p,
230
233
  c,
231
234
  g,
232
- m,
235
+ $,
233
236
  C
234
237
  );
235
- if (d) {
236
- const { className: W, cssRules: $, prefix: A } = d;
237
- if (!$ || $ === "null") return;
238
+ if (m) {
239
+ const { className: b, cssRules: d, prefix: P } = m;
240
+ if (!d || d === "null") return;
238
241
  e.push({
239
- className: W,
240
- cssRules: $,
242
+ className: b,
243
+ cssRules: d,
241
244
  value: null,
242
- prefix: A,
243
- raw: h
245
+ prefix: P,
246
+ raw: [P, f, o, p, g, $]
244
247
  });
245
248
  return;
246
249
  }
247
- const x = this.processShorthand(f, o, p, c, g, m, C);
248
- if (x) {
249
- const { className: W, cssRules: $, value: A, prefix: R } = x;
250
- if (!$ || $ === "null") return;
250
+ const A = this.processShorthand(f, o, p, c, g, $, C);
251
+ if (A) {
252
+ const { className: b, cssRules: d, value: P, prefix: v } = A;
253
+ if (!d || d === "null") return;
251
254
  e.push({
252
- className: W,
253
- cssRules: $,
254
- value: A,
255
- prefix: R,
256
- raw: h
255
+ className: b,
256
+ cssRules: d,
257
+ value: P,
258
+ prefix: v,
259
+ raw: [c, f, o, p, g, $]
257
260
  });
258
261
  }
259
262
  }), e;
@@ -1 +1 @@
1
- var __tenoxui_moxie__=function(m){"use strict";var Z=Object.defineProperty;var _=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var v=(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={}))j.call(g,C)&&v(m,C,g[C]);if(_)for(var C of _(g))z.call(g,C)&&v(m,C,g[C]);return m};class g{constructor({property:t={},values:e={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=S({moxie:({key:r})=>r},t),this.values=e,this.classes=s,this.useHyphens=n}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const e=t.match(/^(webkit|moz|ms|o)/);if(e){const s=e[0];return`-${s}${t.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/([ #{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const e=new Set;return Object.entries(t).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{e.add(r)})}),Array.from(e)}getTypePrefixes(t=[]){const e=this.property,s=this.classes,n=Object.keys(e);if(!s)return[...n,...t].sort((l,i)=>i.length-l.length);const a=[...this.getAllClassNames(s)];return[...n,...a,...t].sort((l,i)=>i.length-l.length)}regexp(t){const e=this.getTypePrefixes(t).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",a="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,l=`(${e}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",h="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:a,type:l,separator:i,value:u,unit:h,secondValuePattern:c,all:"(?:("+a+"):)?"+l+i+u+h+c}}generateClassNameRegEx(t=[]){return new RegExp(this.regexp(t).all)}parse(t,e){if(Object.values(this.classes).some(o=>o==null?void 0:o[t]))return[void 0,t,"","",void 0,void 0,t];const s=this.generateClassNameRegEx(e),n=(t+"-dummy").match(s);if(!n)return null;const[,r,a,l,i,u,h]=n,c=l?l==="dummy"?"":l.replace("-dummy",""):"",f=u?u==="dummy"?"":u.replace("-dummy",""):"";return[r,a,c,i||"",f,h,t]}processValue(t,e,s){if(!t)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(a,l)=>{const i=this.values,u=i!==null?typeof i[s]=="object"?i[s][l]:i[l]:void 0;return typeof u=="string"?u:a});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][t]||this.values[t]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(e||"")}processShorthand(t="",e="",s="",n,r="",a="",l=!0){const i=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let h=null,c=e||"";const f=c.match(u);f&&(h=f[1].trim(),c=f[2].trim());let o;e.includes(h+":")?o=e.startsWith("(")?`(${c})`:`[${c}]`:o=e;const p=this.processValue(o,s,t),d=this.processValue(r,a,t);if(t.startsWith("[")&&t.endsWith("]")){const x=t.slice(1,-1).split(",").map(y=>y.trim()).map(y=>`${y.startsWith("--")?String(y):this.toKebabCase(String(y))}: ${p}`).join("; ");return{className:`${`[${t.slice(1,-1)}]${l?"-":""}${e}${s}`}`,cssRules:x,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const x=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?e:p,y=typeof i.property=="function"?i.property({value:e.startsWith("[")?p:x,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":a?r:d,secondUnit:e.startsWith("[")?"":a,key:h}):i.property,b=i.value||"{0}";let A;if(typeof b=="function")A=b({value:x,unit:s,secondValue:a?r:d,secondUnit:a,key:h});else if(typeof b=="string"){const $=i.group||t,W=this.processValue(o,s,$);this.values[$]&&typeof this.values[$]=="object"&&this.values[$][o]?A=this.values[$][o]:b.includes("{")?A=this.parseValuePattern($,b,W,"",d,""):A=p}else A=null;return{className:`${t}${e?`${l&&l?"-":""}${e}${s}`:""}${r?`/${r}${a}`:""}`,cssRules:Array.isArray(y)?y:typeof y=="string"&&(y.includes(":")||y.includes("value:"))?y.includes("value:")?y.slice(6):this.toKebabCase(String(y)):this.toKebabCase(String(y)),value:b===null||y.includes("value:")?null:e.startsWith("[")?p:A,prefix:n}}const P=typeof i=="function"?i({value:e.startsWith("[")?p:s?e:p,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":a?r:d,secondUnit:e.startsWith("[")?"":a,key:h}):i;return{className:`${t}${e?(l?"-":"")+e+s:""}${r?`/${r}${a}`:""}`,cssRules:Array.isArray(i)?P:typeof P=="string"&&P.startsWith("value:")?P.slice(6):this.toKebabCase(String(P)),value:typeof P=="string"&&P.startsWith("value:")?null:p,prefix:n}}return null}parseValuePattern(t,e,s,n,r,a){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[l,i]=e.split("||").map(c=>c.trim()),u=this.processValue(s,n,t),h=this.processValue(r,a,t);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let c=l;if(s&&(c=c.replace("{0}",u)),e.includes("{1")){const f=c.match(/{1([^}]*)}/);if(e.includes("{1}"))r?c=r.startsWith("[")?h:c.replace("{1}",h):c=i;else if(f){const o=f[0],p=f[1].trim();let d=h;!d&&p.includes("|")?d=p.split("|")[1].trim():d||(d=""),c=s.startsWith("[")?u:c.replace(o,d)}}return s?c:i||l}else return s?s.startsWith("[")?u:l.replace("{0}",u):i||l}getParentClass(t){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],t))}processCustomClass(t,e="",s="",n="",r="",a="",l=!0){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const u=i.map(f=>{const o=this.classes[f];if(!o||e&&!o[t].includes("||")||e&&!o[t].includes("|"))return"";const p=this.parseValuePattern(t,o[t]||"",e,s,r,a);return`${this.toKebabCase(String(f))}: ${p}`}).filter(Boolean).join("; "),h=t.slice(-(e+s).length),c=`${t}${e?`${l?"-":""}${e}${s}`:""}${r?`/${r}${a}`:""}`;return{className:e===h?t:c,cssRules:u,value:null,prefix:n}}return null}process(t){const e=Array.isArray(t)?t:t.split(/\s+/),s=[];return e.forEach(n=>{if(!n)return this;const[r,a]=n.split(":"),l=a||r,i=a?r:void 0,u=this.parse(n),h=u||[i,l,"",""];if(!h)return this;const[c,f,o,p,d,P]=h,x=!n.includes((f||"")+(o||"")),y=this.getParentClass(`${f}${x?"-":""}${o}`).length>0?`${f}${x?"-":""}${o}`:f,b=this.processCustomClass(y,o,p,c,d,P,x);if(b){const{className:V,cssRules:$,prefix:W}=b;if(!$||$==="null")return;s.push({className:V,cssRules:$,value:null,prefix:W,raw:h});return}const A=this.processShorthand(f,o,p,c,d,P,x);if(A){const{className:V,cssRules:$,value:W,prefix:R}=A;if(!$||$==="null")return;s.push({className:V,cssRules:$,value:W,prefix:R,raw:h})}}),s}}return m.TenoxUI=g,m.default=g,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
1
+ var __tenoxui_moxie__=function(C){"use strict";var Z=Object.defineProperty;var V=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var v=(C,m,A)=>m in C?Z(C,m,{enumerable:!0,configurable:!0,writable:!0,value:A}):C[m]=A,S=(C,m)=>{for(var A in m||(m={}))j.call(m,A)&&v(C,A,m[A]);if(V)for(var A of V(m))z.call(m,A)&&v(C,A,m[A]);return C};class m{constructor({property:t={},values:e={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=S({moxie:({key:r,secondValue:l})=>l?null:r},t),this.values=e,this.classes=s,this.useHyphens=n}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const e=t.match(/^(webkit|moz|ms|o)/);if(e){const s=e[0];return`-${s}${t.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const e=new Set;return Object.entries(t).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{e.add(r)})}),Array.from(e)}getTypePrefixes(t=[]){const e=this.property,s=this.classes,n=Object.keys(e);if(!s)return[...n,...t].sort((a,i)=>i.length-a.length);const l=[...this.getAllClassNames(s)];return[...n,...l,...t].sort((a,i)=>i.length-a.length)}regexp(t){const e=this.getTypePrefixes(t).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",l="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,a=`(${e}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",y="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:l,type:a,separator:i,value:h,unit:y,secondValuePattern:c,all:"(?:("+l+"):)?"+a+i+h+y+c}}generateClassNameRegEx(t=[]){return new RegExp(this.regexp(t).all)}parse(t,e){if(Object.values(this.classes).some(o=>o==null?void 0:o[t]))return[void 0,t,"","",void 0,void 0,t];const s=this.generateClassNameRegEx(e),n=(t+"-dummy").match(s);if(!n)return null;const[,r,l,a,i,h,y]=n,c=a?a==="dummy"?"":a.replace("-dummy",""):"",f=h?h==="dummy"?"":h.replace("-dummy",""):"";return[r,l,c,i||"",f,y,t]}processValue(t,e,s){if(!t)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(l,a)=>{const i=this.values,h=i!==null?typeof i[s]=="object"?i[s][a]:i[a]:void 0;return typeof h=="string"?h:l});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][t]||this.values[t]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(e||"")}processShorthand(t="",e="",s="",n,r="",l="",a=!0){const i=this.property[t],h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let y=null,c=e||"";const f=c.match(h);f&&(y=f[1].trim(),c=f[2].trim());let o;e.includes(y+":")?o=e.startsWith("(")?`(${c})`:`[${c}]`:o=e;const p=this.processValue(o,s,t),g=this.processValue(r,l,t);if(t.startsWith("[")&&t.endsWith("]")){const P=t.slice(1,-1).split(",").map(u=>u.trim()).map(u=>`${u?u.startsWith("--")?String(u):this.toKebabCase(String(u)):null}: ${p}`).join("; ");return{className:`${`[${t.slice(1,-1)}]${a?"-":""}${e}${s}`}`,cssRules:P,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const P=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?e:p,u=typeof i.property=="function"?i.property({value:e.startsWith("[")?p:P,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i.property,b=i.value||"{0}";let x;if(typeof b=="function")x=b({value:P,unit:s,secondValue:l?r:g,secondUnit:l,key:y});else if(typeof b=="string"){const d=i.group||t,W=this.processValue(o,s,d);this.values[d]&&typeof this.values[d]=="object"&&this.values[d][o]?x=this.values[d][o]:b.includes("{")?x=this.parseValuePattern(d,b,W,"",g,""):x=p}else x=null;const _=`${t}${e?`${a&&a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return typeof i.property=="string"&&typeof b=="string"&&!b.includes("{1")&&r?null:{className:_,cssRules:u?Array.isArray(u)?u:typeof u=="string"&&(u.includes(":")||u.includes("value:"))?u.includes("value:")?u.slice(6):this.toKebabCase(String(u)):this.toKebabCase(String(u)):null,value:b===null||u===null||u.includes(":")||u.includes("value:")?null:e.startsWith("[")?p:x,prefix:n}}const $=typeof i=="function"?i({value:e.startsWith("[")?p:s?e:p,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i;return(typeof i=="string"||Array.isArray(i))&&r?null:{className:`${t}${e?(a?"-":"")+e+s:""}${r?`/${r}${l}`:""}`,cssRules:$?Array.isArray(i)?$:typeof $=="string"&&($.includes(":")||$.startsWith("value:"))?$.startsWith("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:typeof $=="string"&&$.includes(":")?null:p,prefix:n}}return null}parseValuePattern(t,e,s,n,r,l){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[a,i]=e.split("||").map(c=>c.trim()),h=this.processValue(s,n,t),y=this.processValue(r,l,t);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let c=a;if(s&&(c=c.replace("{0}",h)),e.includes("{1")){const f=c.match(/{1([^}]*)}/);if(e.includes("{1}"))r?c=r.startsWith("[")?y:c.replace("{1}",y):c=i;else if(f){const o=f[0],p=f[1].trim();let g=y;!g&&p.includes("|")?g=p.split("|")[1].trim():g||(g=""),c=s.startsWith("[")?h:c.replace(o,g)}}return s?c:i||a}else return s?s.startsWith("[")?h:a.replace("{0}",h):i||a}getParentClass(t){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],t))}processCustomClass(t,e="",s="",n="",r="",l="",a=!0){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const h=i.map(f=>{const o=this.classes[f];if(!o||e&&!o[t].includes("||")||e&&!o[t].includes("|"))return"";const p=this.parseValuePattern(t,o[t]||"",e,s,r,l);return`${this.toKebabCase(String(f))}: ${p}`}).filter(Boolean).join("; "),y=t.slice(-(e+s).length),c=`${t}${e?`${a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return{className:e===y?t:c,cssRules:h,value:null,prefix:n}}return null}process(t){const e=Array.isArray(t)?t:t.split(/\s+/),s=[];return e.forEach(n=>{if(!n)return this;const[r,l]=n.split(":"),a=l||r,i=l?r:void 0,h=this.parse(n),y=h||[i,a,"",""];if(!y)return this;const[c,f,o,p,g,$]=y,P=!n.includes((f||"")+(o||"")),u=this.getParentClass(`${f}${P?"-":""}${o}`).length>0?`${f}${P?"-":""}${o}`:f,b=this.processCustomClass(u,o,p,c,g,$,P);if(b){const{className:_,cssRules:d,prefix:W}=b;if(!d||d==="null")return;s.push({className:_,cssRules:d,value:null,prefix:W,raw:[W,f,o,p,g,$]});return}const x=this.processShorthand(f,o,p,c,g,$,P);if(x){const{className:_,cssRules:d,value:W,prefix:R}=x;if(!d||d==="null")return;s.push({className:_,cssRules:d,value:W,prefix:R,raw:[c,f,o,p,g,$]})}}),s}}return C.TenoxUI=m,C.default=m,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),C}({});
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function($,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):($=typeof globalThis!="undefined"?globalThis:$||self,d($.__tenoxui_moxie__={}))})(this,function($){"use strict";var R=Object.defineProperty;var _=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var v=($,d,x)=>d in $?R($,d,{enumerable:!0,configurable:!0,writable:!0,value:x}):$[d]=x,S=($,d)=>{for(var x in d||(d={}))Z.call(d,x)&&v($,x,d[x]);if(_)for(var x of _(d))z.call(d,x)&&v($,x,d[x]);return $};class d{constructor({property:e={},values:t={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=S({moxie:({key:r})=>r},e),this.values=t,this.classes=s,this.useHyphens=n}toKebabCase(e){if(/^(webkit|moz|ms|o)[A-Z]/.test(e)){const t=e.match(/^(webkit|moz|ms|o)/);if(t){const s=t[0];return`-${s}${e.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}escapeCSSSelector(e){return e.replace(/([ #{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(e){if(!e)return[];const t=new Set;return Object.entries(e).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(e=[]){const t=this.property,s=this.classes,n=Object.keys(t);if(!s)return[...n,...e].sort((l,i)=>i.length-l.length);const a=[...this.getAllClassNames(s)];return[...n,...a,...e].sort((l,i)=>i.length-l.length)}regexp(e){const t=this.getTypePrefixes(e).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",a="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,l=`(${t}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",h="([a-zA-Z%]*)",o="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:a,type:l,separator:i,value:u,unit:h,secondValuePattern:o,all:"(?:("+a+"):)?"+l+i+u+h+o}}generateClassNameRegEx(e=[]){return new RegExp(this.regexp(e).all)}parse(e,t){if(Object.values(this.classes).some(c=>c==null?void 0:c[e]))return[void 0,e,"","",void 0,void 0,e];const s=this.generateClassNameRegEx(t),n=(e+"-dummy").match(s);if(!n)return null;const[,r,a,l,i,u,h]=n,o=l?l==="dummy"?"":l.replace("-dummy",""):"",f=u?u==="dummy"?"":u.replace("-dummy",""):"";return[r,a,o,i||"",f,h,e]}processValue(e,t,s){if(!e)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(a,l)=>{const i=this.values,u=i!==null?typeof i[s]=="object"?i[s][l]:i[l]:void 0;return typeof u=="string"?u:a});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][e]||this.values[e]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][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("{")?n(r):r.startsWith("--")?`var(${r})`:r}return e+(t||"")}processShorthand(e="",t="",s="",n,r="",a="",l=!0){const i=this.property[e],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let h=null,o=t||"";const f=o.match(u);f&&(h=f[1].trim(),o=f[2].trim());let c;t.includes(h+":")?c=t.startsWith("(")?`(${o})`:`[${o}]`:c=t;const p=this.processValue(c,s,e),g=this.processValue(r,a,e);if(e.startsWith("[")&&e.endsWith("]")){const b=e.slice(1,-1).split(",").map(y=>y.trim()).map(y=>`${y.startsWith("--")?String(y):this.toKebabCase(String(y))}: ${p}`).join("; ");return{className:`${`[${e.slice(1,-1)}]${l?"-":""}${t}${s}`}`,cssRules:b,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const b=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?t:p,y=typeof i.property=="function"?i.property({value:t.startsWith("[")?p:b,unit:t.startsWith("[")?"":s,secondValue:t.startsWith("[")?"":a?r:g,secondUnit:t.startsWith("[")?"":a,key:h}):i.property,P=i.value||"{0}";let A;if(typeof P=="function")A=P({value:b,unit:s,secondValue:a?r:g,secondUnit:a,key:h});else if(typeof P=="string"){const m=i.group||e,W=this.processValue(c,s,m);this.values[m]&&typeof this.values[m]=="object"&&this.values[m][c]?A=this.values[m][c]:P.includes("{")?A=this.parseValuePattern(m,P,W,"",g,""):A=p}else A=null;return{className:`${e}${t?`${l&&l?"-":""}${t}${s}`:""}${r?`/${r}${a}`:""}`,cssRules:Array.isArray(y)?y:typeof y=="string"&&(y.includes(":")||y.includes("value:"))?y.includes("value:")?y.slice(6):this.toKebabCase(String(y)):this.toKebabCase(String(y)),value:P===null||y.includes("value:")?null:t.startsWith("[")?p:A,prefix:n}}const C=typeof i=="function"?i({value:t.startsWith("[")?p:s?t:p,unit:t.startsWith("[")?"":s,secondValue:t.startsWith("[")?"":a?r:g,secondUnit:t.startsWith("[")?"":a,key:h}):i;return{className:`${e}${t?(l?"-":"")+t+s:""}${r?`/${r}${a}`:""}`,cssRules:Array.isArray(i)?C:typeof C=="string"&&C.startsWith("value:")?C.slice(6):this.toKebabCase(String(C)),value:typeof C=="string"&&C.startsWith("value:")?null:p,prefix:n}}return null}parseValuePattern(e,t,s,n,r,a){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[l,i]=t.split("||").map(o=>o.trim()),u=this.processValue(s,n,e),h=this.processValue(r,a,e);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let o=l;if(s&&(o=o.replace("{0}",u)),t.includes("{1")){const f=o.match(/{1([^}]*)}/);if(t.includes("{1}"))r?o=r.startsWith("[")?h:o.replace("{1}",h):o=i;else if(f){const c=f[0],p=f[1].trim();let g=h;!g&&p.includes("|")?g=p.split("|")[1].trim():g||(g=""),o=s.startsWith("[")?u:o.replace(c,g)}}return s?o:i||l}else return s?s.startsWith("[")?u:l.replace("{0}",u):i||l}getParentClass(e){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],e))}processCustomClass(e,t="",s="",n="",r="",a="",l=!0){if(!e)return null;const i=this.getParentClass(e);if(i.length>0){const u=i.map(f=>{const c=this.classes[f];if(!c||t&&!c[e].includes("||")||t&&!c[e].includes("|"))return"";const p=this.parseValuePattern(e,c[e]||"",t,s,r,a);return`${this.toKebabCase(String(f))}: ${p}`}).filter(Boolean).join("; "),h=e.slice(-(t+s).length),o=`${e}${t?`${l?"-":""}${t}${s}`:""}${r?`/${r}${a}`:""}`;return{className:t===h?e:o,cssRules:u,value:null,prefix:n}}return null}process(e){const t=Array.isArray(e)?e:e.split(/\s+/),s=[];return t.forEach(n=>{if(!n)return this;const[r,a]=n.split(":"),l=a||r,i=a?r:void 0,u=this.parse(n),h=u||[i,l,"",""];if(!h)return this;const[o,f,c,p,g,C]=h,b=!n.includes((f||"")+(c||"")),y=this.getParentClass(`${f}${b?"-":""}${c}`).length>0?`${f}${b?"-":""}${c}`:f,P=this.processCustomClass(y,c,p,o,g,C,b);if(P){const{className:V,cssRules:m,prefix:W}=P;if(!m||m==="null")return;s.push({className:V,cssRules:m,value:null,prefix:W,raw:h});return}const A=this.processShorthand(f,c,p,o,g,C,b);if(A){const{className:V,cssRules:m,value:W,prefix:j}=A;if(!m||m==="null")return;s.push({className:V,cssRules:m,value:W,prefix:j,raw:h})}}),s}}$.TenoxUI=d,$.default=d,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(g,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(g=typeof globalThis!="undefined"?globalThis:g||self,d(g.__tenoxui_moxie__={}))})(this,function(g){"use strict";var R=Object.defineProperty;var V=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var S=(g,d,C)=>d in g?R(g,d,{enumerable:!0,configurable:!0,writable:!0,value:C}):g[d]=C,v=(g,d)=>{for(var C in d||(d={}))Z.call(d,C)&&S(g,C,d[C]);if(V)for(var C of V(d))z.call(d,C)&&S(g,C,d[C]);return g};class d{constructor({property:e={},values:t={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=v({moxie:({key:r,secondValue:l})=>l?null:r},e),this.values=t,this.classes=s,this.useHyphens=n}toKebabCase(e){if(/^(webkit|moz|ms|o)[A-Z]/.test(e)){const t=e.match(/^(webkit|moz|ms|o)/);if(t){const s=t[0];return`-${s}${e.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}escapeCSSSelector(e){return e.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(e){if(!e)return[];const t=new Set;return Object.entries(e).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(e=[]){const t=this.property,s=this.classes,n=Object.keys(t);if(!s)return[...n,...e].sort((a,i)=>i.length-a.length);const l=[...this.getAllClassNames(s)];return[...n,...l,...e].sort((a,i)=>i.length-a.length)}regexp(e){const t=this.getTypePrefixes(e).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",l="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,a=`(${t}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",f="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",y="([a-zA-Z%]*)",o="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:l,type:a,separator:i,value:f,unit:y,secondValuePattern:o,all:"(?:("+l+"):)?"+a+i+f+y+o}}generateClassNameRegEx(e=[]){return new RegExp(this.regexp(e).all)}parse(e,t){if(Object.values(this.classes).some(c=>c==null?void 0:c[e]))return[void 0,e,"","",void 0,void 0,e];const s=this.generateClassNameRegEx(t),n=(e+"-dummy").match(s);if(!n)return null;const[,r,l,a,i,f,y]=n,o=a?a==="dummy"?"":a.replace("-dummy",""):"",h=f?f==="dummy"?"":f.replace("-dummy",""):"";return[r,l,o,i||"",h,y,e]}processValue(e,t,s){if(!e)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(l,a)=>{const i=this.values,f=i!==null?typeof i[s]=="object"?i[s][a]:i[a]:void 0;return typeof f=="string"?f:l});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][e]||this.values[e]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][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("{")?n(r):r.startsWith("--")?`var(${r})`:r}return e+(t||"")}processShorthand(e="",t="",s="",n,r="",l="",a=!0){const i=this.property[e],f=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let y=null,o=t||"";const h=o.match(f);h&&(y=h[1].trim(),o=h[2].trim());let c;t.includes(y+":")?c=t.startsWith("(")?`(${o})`:`[${o}]`:c=t;const p=this.processValue(c,s,e),m=this.processValue(r,l,e);if(e.startsWith("[")&&e.endsWith("]")){const A=e.slice(1,-1).split(",").map(u=>u.trim()).map(u=>`${u?u.startsWith("--")?String(u):this.toKebabCase(String(u)):null}: ${p}`).join("; ");return{className:`${`[${e.slice(1,-1)}]${a?"-":""}${t}${s}`}`,cssRules:A,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const A=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?t:p,u=typeof i.property=="function"?i.property({value:t.startsWith("[")?p:A,unit:t.startsWith("[")?"":s,secondValue:t.startsWith("[")?"":l?r:m,secondUnit:t.startsWith("[")?"":l,key:y}):i.property,b=i.value||"{0}";let P;if(typeof b=="function")P=b({value:A,unit:s,secondValue:l?r:m,secondUnit:l,key:y});else if(typeof b=="string"){const x=i.group||e,W=this.processValue(c,s,x);this.values[x]&&typeof this.values[x]=="object"&&this.values[x][c]?P=this.values[x][c]:b.includes("{")?P=this.parseValuePattern(x,b,W,"",m,""):P=p}else P=null;const _=`${e}${t?`${a&&a?"-":""}${t}${s}`:""}${r?`/${r}${l}`:""}`;return typeof i.property=="string"&&typeof b=="string"&&!b.includes("{1")&&r?null:{className:_,cssRules:u?Array.isArray(u)?u:typeof u=="string"&&(u.includes(":")||u.includes("value:"))?u.includes("value:")?u.slice(6):this.toKebabCase(String(u)):this.toKebabCase(String(u)):null,value:b===null||u===null||u.includes(":")||u.includes("value:")?null:t.startsWith("[")?p:P,prefix:n}}const $=typeof i=="function"?i({value:t.startsWith("[")?p:s?t:p,unit:t.startsWith("[")?"":s,secondValue:t.startsWith("[")?"":l?r:m,secondUnit:t.startsWith("[")?"":l,key:y}):i;return(typeof i=="string"||Array.isArray(i))&&r?null:{className:`${e}${t?(a?"-":"")+t+s:""}${r?`/${r}${l}`:""}`,cssRules:$?Array.isArray(i)?$:typeof $=="string"&&($.includes(":")||$.startsWith("value:"))?$.startsWith("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:typeof $=="string"&&$.includes(":")?null:p,prefix:n}}return null}parseValuePattern(e,t,s,n,r,l){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[a,i]=t.split("||").map(o=>o.trim()),f=this.processValue(s,n,e),y=this.processValue(r,l,e);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let o=a;if(s&&(o=o.replace("{0}",f)),t.includes("{1")){const h=o.match(/{1([^}]*)}/);if(t.includes("{1}"))r?o=r.startsWith("[")?y:o.replace("{1}",y):o=i;else if(h){const c=h[0],p=h[1].trim();let m=y;!m&&p.includes("|")?m=p.split("|")[1].trim():m||(m=""),o=s.startsWith("[")?f:o.replace(c,m)}}return s?o:i||a}else return s?s.startsWith("[")?f:a.replace("{0}",f):i||a}getParentClass(e){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],e))}processCustomClass(e,t="",s="",n="",r="",l="",a=!0){if(!e)return null;const i=this.getParentClass(e);if(i.length>0){const f=i.map(h=>{const c=this.classes[h];if(!c||t&&!c[e].includes("||")||t&&!c[e].includes("|"))return"";const p=this.parseValuePattern(e,c[e]||"",t,s,r,l);return`${this.toKebabCase(String(h))}: ${p}`}).filter(Boolean).join("; "),y=e.slice(-(t+s).length),o=`${e}${t?`${a?"-":""}${t}${s}`:""}${r?`/${r}${l}`:""}`;return{className:t===y?e:o,cssRules:f,value:null,prefix:n}}return null}process(e){const t=Array.isArray(e)?e:e.split(/\s+/),s=[];return t.forEach(n=>{if(!n)return this;const[r,l]=n.split(":"),a=l||r,i=l?r:void 0,f=this.parse(n),y=f||[i,a,"",""];if(!y)return this;const[o,h,c,p,m,$]=y,A=!n.includes((h||"")+(c||"")),u=this.getParentClass(`${h}${A?"-":""}${c}`).length>0?`${h}${A?"-":""}${c}`:h,b=this.processCustomClass(u,c,p,o,m,$,A);if(b){const{className:_,cssRules:x,prefix:W}=b;if(!x||x==="null")return;s.push({className:_,cssRules:x,value:null,prefix:W,raw:[W,h,c,p,m,$]});return}const P=this.processShorthand(h,c,p,o,m,$,A);if(P){const{className:_,cssRules:x,value:W,prefix:j}=P;if(!x||x==="null")return;s.push({className:_,cssRules:x,value:W,prefix:j,raw:[o,h,c,p,m,$]})}}),s}}g.TenoxUI=d,g.default=d,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -13,7 +13,7 @@ export type ValueParams = {
13
13
  secondValue?: string;
14
14
  secondUnit?: string;
15
15
  };
16
- export type PropertyParamValue = GetCSSProperty | ((params: PropertyParams) => GetCSSProperty);
16
+ export type PropertyParamValue = GetCSSProperty | ((params: PropertyParams) => null | GetCSSProperty);
17
17
  export type ValuePropType = string | ((params: ValueParams) => string | null) | null;
18
18
  export type PropertyValue = PropertyParamValue | {
19
19
  property?: PropertyParamValue;
@@ -32,7 +32,7 @@ export interface Config {
32
32
  export type Parsed = null | (string | undefined)[];
33
33
  export type ProcessedStyle = {
34
34
  className: string;
35
- cssRules: string | string[];
35
+ cssRules: string | string[] | null;
36
36
  value: string | null;
37
37
  prefix?: string | null;
38
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenoxui/moxie",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Very lightweight utility-first CSS engine for style generation",
5
5
  "author": "NOuSantx <nousantx@gmail.com>",
6
6
  "license": "MIT",
@@ -23,7 +23,6 @@
23
23
  "README.md",
24
24
  "LICENSE"
25
25
  ],
26
- "type": "module",
27
26
  "types": "./dist/index.d.ts",
28
27
  "main": "./dist/index.cjs.js",
29
28
  "module": "./dist/index.es.js",