@salty-css/core 0.0.1-alpha.225 → 0.0.1-alpha.226
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/README.md +1 -0
- package/generators/index.cjs +1 -1
- package/generators/index.js +6 -6
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
package/README.md
CHANGED
@@ -88,6 +88,7 @@ export const Component = styled('div', {
|
|
88
88
|
// Add additional default props for the component (eg, id and other html element attributes)
|
89
89
|
},
|
90
90
|
passProps: true, // Pass variant props to the rendered element / parent component (default: false)
|
91
|
+
priority: 1, // Override automatic priotity layer with a custom value (0-8), higher is considered more important
|
91
92
|
});
|
92
93
|
```
|
93
94
|
|
package/generators/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var g=Object.defineProperty;var C=(a,t,s)=>t in a?g(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var m=(a,t,s)=>C(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("../parse-styles-3N79AOBO.cjs"),c=require("../dash-case-BJEkFEGQ.cjs");class
|
1
|
+
"use strict";var g=Object.defineProperty;var C=(a,t,s)=>t in a?g(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var m=(a,t,s)=>C(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("../parse-styles-3N79AOBO.cjs"),c=require("../dash-case-BJEkFEGQ.cjs");class y{constructor(t){m(this,"buildContext",{});this.params=t}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){return c.toHash(this.params.base||this.params)}get cssClassName(){return this.hash}get classNames(){const t=new Set([this.cssClassName]),{className:s}=this.params;return typeof s=="string"&&t.add(s),typeof s=="object"&&s.forEach(e=>t.add(e)),this.getTemplateClasses().forEach(e=>t.add(e)),this.buildContext.classNames&&this.buildContext.classNames.forEach(e=>t.add(e)),[...t].join(" ")}get cssFileName(){const{callerName:t}=this.buildContext;return t?`cl_${c.dashCase(t)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:t={},variants:s={},compoundVariants:e=[]}=this.params,{config:i}=this.buildContext,n={...t,variants:s,compoundVariants:e};return N.parseAndJoinStyles(n,`.${this.cssClassName}`,i,this.isRoot)}getTemplateClasses(t=this.buildContext.config){if(!(t!=null&&t.templates)||!this.params.base||this.priority>0)return[];const s=Object.keys(t.templates);return Object.entries(this.params.base).reduce((e,[i,n])=>(s.includes(i)&&e.push("t_"+c.toHash(c.dashCase(`${i}-${n}`),4)),e),[])}_withBuildContext(t){return this.buildContext=t,this}}class S extends y{constructor(t){super(t),this._params=t}}class x extends y{constructor(t,s){super(s),this.tagName=t,this._params=s}get priority(){var t;return this.params.priority?this.params.priority:typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get clientProps(){const{element:t,variants:s={},compoundVariants:e=[],defaultVariants:i={},defaultProps:n={},passProps:d}=this.params,{callerName:f,isProduction:b}=this.buildContext,h=new Set([]),l=r=>{const o=i[r];o!==void 0?h.add(`${r}=${String(o)}`):h.add(r)};Object.keys(s).forEach(l),e.map(r=>Object.keys(r).forEach(l));const p=new Set([]);if(this.params.base){const r=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);r&&r.forEach(o=>{const u=o.replace(/\{props\.([\w\d]+)\}/gi,"$1");u&&p.add(u)})}return{element:t,variantKeys:[...h],propValueKeys:[...p],passProps:d,defaultProps:n,attr:{"data-component-name":b?void 0:f}}}}exports.ClassNameGenerator=S;exports.StyledGenerator=x;
|
package/generators/index.js
CHANGED
@@ -52,26 +52,26 @@ class V extends y {
|
|
52
52
|
}
|
53
53
|
get priority() {
|
54
54
|
var t;
|
55
|
-
return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
55
|
+
return this.params.priority ? this.params.priority : typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
56
56
|
}
|
57
57
|
get clientProps() {
|
58
|
-
const { element: t, variants: s = {}, compoundVariants: e = [], defaultVariants: i = {}, defaultProps: n = {}, passProps: h } = this.params, { callerName: b, isProduction: g } = this.buildContext, c = /* @__PURE__ */ new Set([]),
|
58
|
+
const { element: t, variants: s = {}, compoundVariants: e = [], defaultVariants: i = {}, defaultProps: n = {}, passProps: h } = this.params, { callerName: b, isProduction: g } = this.buildContext, c = /* @__PURE__ */ new Set([]), p = (r) => {
|
59
59
|
const o = i[r];
|
60
60
|
o !== void 0 ? c.add(`${r}=${String(o)}`) : c.add(r);
|
61
61
|
};
|
62
|
-
Object.keys(s).forEach(
|
63
|
-
const
|
62
|
+
Object.keys(s).forEach(p), e.map((r) => Object.keys(r).forEach(p));
|
63
|
+
const d = /* @__PURE__ */ new Set([]);
|
64
64
|
if (this.params.base) {
|
65
65
|
const r = JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);
|
66
66
|
r && r.forEach((o) => {
|
67
67
|
const l = o.replace(/\{props\.([\w\d]+)\}/gi, "$1");
|
68
|
-
l &&
|
68
|
+
l && d.add(l);
|
69
69
|
});
|
70
70
|
}
|
71
71
|
return {
|
72
72
|
element: t,
|
73
73
|
variantKeys: [...c],
|
74
|
-
propValueKeys: [...
|
74
|
+
propValueKeys: [...d],
|
75
75
|
passProps: h,
|
76
76
|
defaultProps: n,
|
77
77
|
attr: {
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
@@ -80,6 +80,7 @@ export interface GeneratorOptions {
|
|
80
80
|
element?: string;
|
81
81
|
passProps?: boolean | string | string[];
|
82
82
|
defaultProps?: Record<PropertyKey, unknown>;
|
83
|
+
priority?: number;
|
83
84
|
}
|
84
85
|
interface Base extends CssProperties, CssStyles, CssPseudos, TemplateTokens, MediaQueryStyles {
|
85
86
|
}
|