@salty-css/core 0.0.1-alpha.116 → 0.0.1-alpha.117
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/generator/index.cjs +1 -1
- package/generator/index.js +26 -24
- package/generator/style-generator.d.ts +2 -0
- package/package.json +1 -1
- package/types/index.d.ts +3 -1
package/generator/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var f=Object.defineProperty;var N=(s,t,e)=>t in s?f(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var o=(s,t,e)=>N(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../dash-case-8PdMJjFC.cjs"),u=require("../parse-templates-lpgqU05M.cjs");class S{constructor(t,e){o(this,"_isProd");o(this,"_callerName");o(this,"_context");this.tagName=t,this.params=e}get hash(){return _.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:e}=this.params;return e&&t.push(e),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?u.getTemplateKeys(this._context.config.templates):[]}get css(){var n;const{base:t={},variants:e={},compoundVariants:i=[]}=this.params,r={...t,variants:e,compoundVariants:i};return u.parseStyles(r,`.${this.cssClassName}`,this.priority,(n=this._context)==null?void 0:n.config)}get props(){const{element:t,variants:e={},compoundVariants:i=[],defaultVariants:r={},defaultProps:n={},passProps:y}=this.params,c=new Set([]),h=a=>{const p=r[a];p!==void 0?c.add(`${a}=${String(p)}`):c.add(a)};Object.keys(e).forEach(h),i.map(a=>Object.keys(a).forEach(h));const l=new Set([]),m=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return m&&m.forEach((a,p,g)=>{const d=g.at(1);d&&l.add(d)}),{element:t,variantKeys:[...c],propValueKeys:[...l],passProps:y,defaultProps:n,attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:e,config:i,prod:r}=t;return this._isProd=r,this._callerName=e,this}}exports.StyleComponentGenerator=S;
|
package/generator/index.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var o = (e, t, s) =>
|
4
|
-
import { t as
|
5
|
-
import { g as
|
6
|
-
class
|
1
|
+
var g = Object.defineProperty;
|
2
|
+
var y = (e, t, s) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
3
|
+
var o = (e, t, s) => y(e, typeof t != "symbol" ? t + "" : t, s);
|
4
|
+
import { t as N } from "../dash-case-D_tXuO4I.js";
|
5
|
+
import { g as _, p as x } from "../parse-templates-D1FebDfR.js";
|
6
|
+
class K {
|
7
7
|
constructor(t, s) {
|
8
8
|
o(this, "_isProd");
|
9
9
|
o(this, "_callerName");
|
@@ -11,7 +11,7 @@ class b {
|
|
11
11
|
this.tagName = t, this.params = s;
|
12
12
|
}
|
13
13
|
get hash() {
|
14
|
-
return
|
14
|
+
return N(this.params.base || this.params);
|
15
15
|
}
|
16
16
|
get priority() {
|
17
17
|
var t;
|
@@ -29,27 +29,29 @@ class b {
|
|
29
29
|
}
|
30
30
|
get templateKeys() {
|
31
31
|
var t;
|
32
|
-
return (t = this._context) != null && t.config.templates ?
|
32
|
+
return (t = this._context) != null && t.config.templates ? _(this._context.config.templates) : [];
|
33
33
|
}
|
34
34
|
get css() {
|
35
|
-
var
|
36
|
-
const { base: t = {}, variants: s = {}, compoundVariants:
|
37
|
-
return
|
35
|
+
var n;
|
36
|
+
const { base: t = {}, variants: s = {}, compoundVariants: i = [] } = this.params, r = { ...t, variants: s, compoundVariants: i };
|
37
|
+
return x(r, `.${this.cssClassName}`, this.priority, (n = this._context) == null ? void 0 : n.config);
|
38
38
|
}
|
39
39
|
get props() {
|
40
|
-
const { element: t, variants: s = {}, compoundVariants:
|
41
|
-
const
|
42
|
-
|
40
|
+
const { element: t, variants: s = {}, compoundVariants: i = [], defaultVariants: r = {}, defaultProps: n = {}, passProps: u } = this.params, c = /* @__PURE__ */ new Set([]), h = (a) => {
|
41
|
+
const p = r[a];
|
42
|
+
p !== void 0 ? c.add(`${a}=${String(p)}`) : c.add(a);
|
43
43
|
};
|
44
|
-
Object.keys(s).forEach(h),
|
45
|
-
const
|
46
|
-
return
|
47
|
-
const
|
48
|
-
|
44
|
+
Object.keys(s).forEach(h), i.map((a) => Object.keys(a).forEach(h));
|
45
|
+
const m = /* @__PURE__ */ new Set([]), l = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
|
46
|
+
return l && l.forEach((a, p, f) => {
|
47
|
+
const d = f.at(1);
|
48
|
+
d && m.add(d);
|
49
49
|
}), {
|
50
50
|
element: t,
|
51
|
-
variantKeys: [...
|
52
|
-
propValueKeys: [...
|
51
|
+
variantKeys: [...c],
|
52
|
+
propValueKeys: [...m],
|
53
|
+
passProps: u,
|
54
|
+
defaultProps: n,
|
53
55
|
attr: {
|
54
56
|
"data-component-name": this._isProd ? void 0 : this._callerName
|
55
57
|
}
|
@@ -57,10 +59,10 @@ class b {
|
|
57
59
|
}
|
58
60
|
_withBuildContext(t) {
|
59
61
|
this._context = t;
|
60
|
-
const { name: s, config:
|
61
|
-
return this._isProd =
|
62
|
+
const { name: s, config: i, prod: r } = t;
|
63
|
+
return this._isProd = r, this._callerName = s, this;
|
62
64
|
}
|
63
65
|
}
|
64
66
|
export {
|
65
|
-
|
67
|
+
K as StyleComponentGenerator
|
66
68
|
};
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
@@ -7,7 +7,7 @@ export type CreateElementProps = {
|
|
7
7
|
children?: ReactNode;
|
8
8
|
className?: string;
|
9
9
|
element?: string;
|
10
|
-
|
10
|
+
passProps?: boolean | string | string[];
|
11
11
|
style?: CssProperties | {
|
12
12
|
[key: string]: PropertyValueToken | NeverObj;
|
13
13
|
};
|
@@ -74,6 +74,8 @@ export interface GeneratorOptions {
|
|
74
74
|
className?: string;
|
75
75
|
displayName?: string;
|
76
76
|
element?: string;
|
77
|
+
passProps?: boolean | string | string[];
|
78
|
+
defaultProps?: Record<PropertyKey, unknown>;
|
77
79
|
}
|
78
80
|
interface Base extends CssProperties, CssStyles, CssPseudos, TemplateTokens {
|
79
81
|
}
|