@salty-css/react 0.0.1-alpha.126 → 0.0.1-alpha.128
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 +5 -5
- package/package.json +2 -2
- package/styled.cjs +1 -1
- package/styled.js +21 -17
package/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-

|
2
2
|
|
3
3
|
# Salty CSS - CSS-in-JS library that is kinda sweet
|
4
4
|
|
@@ -19,7 +19,9 @@ Fastest way to get started with any framework is `npx salty-css init [directory]
|
|
19
19
|
- Next.js → [Next.js guide](#nextjs) + [Next.js example app](https://github.com/margarita-form/salty-css-website)
|
20
20
|
- React + Vite → [React + Vite guide](#react--vite) + [React example code](#code-examples)
|
21
21
|
- React + Webpack → Guide coming soon
|
22
|
-
|
22
|
+
|
23
|
+
## Useful commands
|
24
|
+
|
23
25
|
- Create component: `npx salty-css generate [filePath]`
|
24
26
|
- Build: `npx salty-css build [directory]`
|
25
27
|
- Update Salty CSS packages: `npx salty-css up`
|
@@ -61,8 +63,6 @@ In your existing repository you can use `npx salty-css [command]` to initialize
|
|
61
63
|
- Generate component → `npx salty-css update [version]` - Update @salty-css packages in your repository. Default version is "latest". Additional options like `--dir`, `--tag`, `--name` and `--className` are also supported.
|
62
64
|
- Build files → `npx salty-css build [directory]` - Compile Salty CSS related files in your project. This should not be needed if you are using tools like Next.js or Vite
|
63
65
|
|
64
|
-
|
65
|
-
|
66
66
|
## Usage
|
67
67
|
|
68
68
|
### Next.js
|
@@ -118,7 +118,7 @@ And note: steps 2 & 3 are just to show how get new components up and running, st
|
|
118
118
|
|
119
119
|
[Check out react example code](#code-examples)
|
120
120
|
|
121
|
-
|
121
|
+
---
|
122
122
|
|
123
123
|
### Create components
|
124
124
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/react",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.128",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
}
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
|
-
"@salty-css/core": "^0.0.1-alpha.
|
49
|
+
"@salty-css/core": "^0.0.1-alpha.128",
|
50
50
|
"clsx": ">=2.x",
|
51
51
|
"react": ">=19.x || >=18.3.x"
|
52
52
|
}
|
package/styled.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var y=Object.defineProperty;var g=(
|
1
|
+
"use strict";var y=Object.defineProperty;var g=(e,t,s)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var c=(e,t,s)=>g(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./parse-styles-CyIjlKB3.cjs"),f=require("./parse-tokens-p68muVgG.cjs"),N=require("./element-factory-D4kpeFoW.cjs"),_=e=>Object.keys(e);class b{constructor(t,s){c(this,"_isProd");c(this,"_callerName");c(this,"_context");this.tagName=t,this.params=s}get hash(){return d.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:s}=this.params;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get cssFileName(){return this._callerName?`c_${f.dashCase(this._callerName)}-${this.hash}-${this.priority}.css`:`${this.hash}-${this.priority}.css`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?_(this._context.config.templates):[]}get css(){var n;const{base:t={},variants:s={},compoundVariants:r=[]}=this.params,i={...t,variants:s,compoundVariants:r};return d.parseStyles(i,`.${this.cssClassName}`,this.priority,(n=this._context)==null?void 0:n.config)}get props(){const{element:t,variants:s={},compoundVariants:r=[],defaultVariants:i={},defaultProps:n={},passProps:u}=this.params,h=new Set([]),p=a=>{const o=i[a];o!==void 0?h.add(`${a}=${String(o)}`):h.add(a)};Object.keys(s).forEach(p),r.map(a=>Object.keys(a).forEach(p));const l=new Set([]);if(this.params.base){const a=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);a&&a.forEach(o=>{const m=o.replace(/\{props\.([\w\d]+)\}/gi,"$1");m&&l.add(m)})}return{element:t,variantKeys:[...h],propValueKeys:[...l],passProps:u,defaultProps:n,attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:s,config:r,prod:i}=t;return this._isProd=i,this._callerName=s,this}}const $=(e,t)=>{const s=new b(e,t),r=N.elementFactory(e,s.cssClassName,s.props,{"data-unoptimized-client-component":!0});return Object.assign(r,{generator:s}),r};exports.styled=$;
|
package/styled.js
CHANGED
@@ -37,26 +37,30 @@ class b {
|
|
37
37
|
return (t = this._context) != null && t.config.templates ? $(this._context.config.templates) : [];
|
38
38
|
}
|
39
39
|
get css() {
|
40
|
-
var
|
41
|
-
const { base: t = {}, variants: s = {}, compoundVariants:
|
42
|
-
return g(i, `.${this.cssClassName}`, this.priority, (
|
40
|
+
var n;
|
41
|
+
const { base: t = {}, variants: s = {}, compoundVariants: r = [] } = this.params, i = { ...t, variants: s, compoundVariants: r };
|
42
|
+
return g(i, `.${this.cssClassName}`, this.priority, (n = this._context) == null ? void 0 : n.config);
|
43
43
|
}
|
44
44
|
get props() {
|
45
|
-
const { element: t, variants: s = {}, compoundVariants:
|
46
|
-
const
|
47
|
-
|
45
|
+
const { element: t, variants: s = {}, compoundVariants: r = [], defaultVariants: i = {}, defaultProps: n = {}, passProps: d } = this.params, h = /* @__PURE__ */ new Set([]), p = (a) => {
|
46
|
+
const o = i[a];
|
47
|
+
o !== void 0 ? h.add(`${a}=${String(o)}`) : h.add(a);
|
48
48
|
};
|
49
|
-
Object.keys(s).forEach(p),
|
50
|
-
const m = /* @__PURE__ */ new Set([])
|
51
|
-
|
52
|
-
const
|
53
|
-
|
54
|
-
|
49
|
+
Object.keys(s).forEach(p), r.map((a) => Object.keys(a).forEach(p));
|
50
|
+
const m = /* @__PURE__ */ new Set([]);
|
51
|
+
if (this.params.base) {
|
52
|
+
const a = JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);
|
53
|
+
a && a.forEach((o) => {
|
54
|
+
const l = o.replace(/\{props\.([\w\d]+)\}/gi, "$1");
|
55
|
+
l && m.add(l);
|
56
|
+
});
|
57
|
+
}
|
58
|
+
return {
|
55
59
|
element: t,
|
56
60
|
variantKeys: [...h],
|
57
61
|
propValueKeys: [...m],
|
58
62
|
passProps: d,
|
59
|
-
defaultProps:
|
63
|
+
defaultProps: n,
|
60
64
|
attr: {
|
61
65
|
"data-component-name": this._isProd ? void 0 : this._callerName
|
62
66
|
}
|
@@ -64,17 +68,17 @@ class b {
|
|
64
68
|
}
|
65
69
|
_withBuildContext(t) {
|
66
70
|
this._context = t;
|
67
|
-
const { name: s, config:
|
71
|
+
const { name: s, config: r, prod: i } = t;
|
68
72
|
return this._isProd = i, this._callerName = s, this;
|
69
73
|
}
|
70
74
|
}
|
71
75
|
const j = (e, t) => {
|
72
|
-
const s = new b(e, t),
|
76
|
+
const s = new b(e, t), r = _(e, s.cssClassName, s.props, {
|
73
77
|
"data-unoptimized-client-component": !0
|
74
78
|
});
|
75
|
-
return Object.assign(
|
79
|
+
return Object.assign(r, {
|
76
80
|
generator: s
|
77
|
-
}),
|
81
|
+
}), r;
|
78
82
|
};
|
79
83
|
export {
|
80
84
|
j as styled
|