@salty-css/react 0.0.1-alpha.8 → 0.0.1-alpha.9
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +22 -18
- package/element-factory-CKZth7Mh.cjs +1 -0
- package/element-factory-DjCaPhwl.js +45 -0
- package/element-factory.d.ts +1 -1
- package/package.json +1 -1
- package/styled-client.cjs +1 -1
- package/styled-client.d.ts +1 -1
- package/styled-client.js +1 -1
- package/styled.cjs +1 -1
- package/styled.d.ts +5 -3
- package/styled.js +21 -20
- package/element-factory-CHdv47Y_.js +0 -52
- package/element-factory-DvBlAL2I.cjs +0 -1
package/README.md
CHANGED
@@ -54,8 +54,10 @@ export const IndexPage = () => {
|
|
54
54
|
import { styled } from '@salty-css/react/styled';
|
55
55
|
|
56
56
|
export const Wrapper = styled('div', {
|
57
|
-
|
58
|
-
|
57
|
+
base: {
|
58
|
+
display: 'block',
|
59
|
+
padding: '2vw',
|
60
|
+
},
|
59
61
|
});
|
60
62
|
```
|
61
63
|
|
@@ -65,22 +67,24 @@ export const Wrapper = styled('div', {
|
|
65
67
|
import { styled } from '@salty-css/react/styled';
|
66
68
|
|
67
69
|
export const Button = styled('button', {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
70
|
+
base: {
|
71
|
+
display: 'block',
|
72
|
+
padding: `0.6em 1.2em`,
|
73
|
+
border: '1px solid currentColor',
|
74
|
+
background: 'transparent',
|
75
|
+
color: 'currentColor/40',
|
76
|
+
cursor: 'pointer',
|
77
|
+
transition: '200ms',
|
78
|
+
textDecoration: 'none',
|
79
|
+
'&:hover': {
|
80
|
+
background: 'black',
|
81
|
+
borderColor: 'black',
|
82
|
+
color: 'white',
|
83
|
+
},
|
84
|
+
'&:disabled': {
|
85
|
+
opacity: 0.25,
|
86
|
+
pointerEvents: 'none',
|
87
|
+
},
|
84
88
|
},
|
85
89
|
variants: {
|
86
90
|
variant: {
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";const j=require("react");function w(t){var n,s,e="";if(typeof t=="string"||typeof t=="number")e+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(n=0;n<r;n++)t[n]&&(s=w(t[n]))&&(e&&(e+=" "),e+=s)}else for(s in t)t[s]&&(e&&(e+=" "),e+=s);return e}function V(){for(var t,n,s=0,e="",r=arguments.length;s<r;s++)(t=arguments[s])&&(n=w(t))&&(e&&(e+=" "),e+=n);return e}const v=["passVariantProps"],A=(t,n,s,e,r)=>{const p=({extend:f=t,element:m=s,className:E="",children:$,passVariantProps:S,_vks:c=new Set,...d},O)=>{const o={passVariantProps:S};r&&Object.assign(o,r),d&&Object.assign(o,d);const u=new Set(E.split(" ")),a=typeof f=="function"||typeof f=="object",y=a&&"isStyled"in f,b=a?f:m||f;if(!b)throw new Error("No element provided");e&&e.forEach(l=>{const[i,h]=l.split("=");d[i]!==void 0?(u.add(`${i}-${d[i]}`),a?c&&c.add(i):delete o[i]):h!==void 0&&u.add(`${i}-${h}`)}),c&&(!a||!y&&!S)?c.forEach(l=>delete o[l]):y&&Object.assign(o,{_vks:c}),y||v.forEach(l=>delete o[l]);const C=V(n,...u);return j.createElement(b,{element:a?m:void 0,className:C,ref:O,...o},$)},g=j.forwardRef(p);return Object.assign(g,{isStyled:!0,className:n,toString:()=>`.${n}`}),g};exports.elementFactory=A;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { forwardRef as O, createElement as C } from "react";
|
2
|
+
function j(t) {
|
3
|
+
var n, o, e = "";
|
4
|
+
if (typeof t == "string" || typeof t == "number") e += t;
|
5
|
+
else if (typeof t == "object") if (Array.isArray(t)) {
|
6
|
+
var r = t.length;
|
7
|
+
for (n = 0; n < r; n++) t[n] && (o = j(t[n])) && (e && (e += " "), e += o);
|
8
|
+
} else for (o in t) t[o] && (e && (e += " "), e += o);
|
9
|
+
return e;
|
10
|
+
}
|
11
|
+
function V() {
|
12
|
+
for (var t, n, o = 0, e = "", r = arguments.length; o < r; o++) (t = arguments[o]) && (n = j(t)) && (e && (e += " "), e += n);
|
13
|
+
return e;
|
14
|
+
}
|
15
|
+
const v = ["passVariantProps"], R = (t, n, o, e, r) => {
|
16
|
+
const m = O(({ extend: f = t, element: g = o, className: p = "", children: w, passVariantProps: S, _vks: c = /* @__PURE__ */ new Set(), ...d }, E) => {
|
17
|
+
const s = { passVariantProps: S };
|
18
|
+
r && Object.assign(s, r), d && Object.assign(s, d);
|
19
|
+
const u = new Set(p.split(" ")), a = typeof f == "function" || typeof f == "object", y = a && "isStyled" in f, b = a ? f : g || f;
|
20
|
+
if (!b) throw new Error("No element provided");
|
21
|
+
e && e.forEach((l) => {
|
22
|
+
const [i, h] = l.split("=");
|
23
|
+
d[i] !== void 0 ? (u.add(`${i}-${d[i]}`), a ? c && c.add(i) : delete s[i]) : h !== void 0 && u.add(`${i}-${h}`);
|
24
|
+
}), c && (!a || !y && !S) ? c.forEach((l) => delete s[l]) : y && Object.assign(s, { _vks: c }), y || v.forEach((l) => delete s[l]);
|
25
|
+
const $ = V(n, ...u);
|
26
|
+
return C(
|
27
|
+
b,
|
28
|
+
{
|
29
|
+
element: a ? g : void 0,
|
30
|
+
className: $,
|
31
|
+
ref: E,
|
32
|
+
...s
|
33
|
+
},
|
34
|
+
w
|
35
|
+
);
|
36
|
+
});
|
37
|
+
return Object.assign(m, {
|
38
|
+
isStyled: !0,
|
39
|
+
className: n,
|
40
|
+
toString: () => `.${n}`
|
41
|
+
}), m;
|
42
|
+
};
|
43
|
+
export {
|
44
|
+
R as e
|
45
|
+
};
|
package/element-factory.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import { StyledComponentProps, Tag } from '../../core/src/types';
|
2
|
-
export declare const elementFactory: (tagName: Tag<any>, _className: string, _element?: string, _variantKeys?: string[], _additionalProps?: Record<PropertyKey, any>) =>
|
2
|
+
export declare const elementFactory: (tagName: Tag<any>, _className: string, _element?: string, _variantKeys?: string[], _additionalProps?: Record<PropertyKey, any>) => import('react').ForwardRefExoticComponent<Omit<StyledComponentProps, "ref"> & import('react').RefAttributes<any>>;
|
package/package.json
CHANGED
package/styled-client.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./element-factory-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./element-factory-CKZth7Mh.cjs"),a=(e,t,n,o,r)=>l.elementFactory(e,t,o,r,{"data-component-name":n});exports.styledClient=a;
|
package/styled-client.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Tag } from '../../core/src/types';
|
2
|
-
export declare const styledClient: (tagName: Tag<any>, className: string, callerName?: string, element?: string, variantKeys?: string[]) => (
|
2
|
+
export declare const styledClient: (tagName: Tag<any>, className: string, callerName?: string, element?: string, variantKeys?: string[]) => import('react').ForwardRefExoticComponent<Omit<import('../../core/src/types').StyledComponentProps, "ref"> & import('react').RefAttributes<any>>;
|
package/styled-client.js
CHANGED
package/styled.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./parse-styles-PkK9Yzyn.cjs"),o=require("./element-factory-CKZth7Mh.cjs"),c=a=>Object.keys(a);class p{constructor(t,s){this.tagName=t,this.params=s}get hash(){return i.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 templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?c(this._context.config.templates):[]}get css(){var r;const{base:t={},variants:s={},compoundVariants:e=[]}=this.params,n={...t,variants:s,compoundVariants:e};return i.parseStyles(n,`.${this.cssClassName}`,this.priority,(r=this._context)==null?void 0:r.config)}get props(){const{element:t}=this.params,s=this.params.variants?Object.keys(this.params.variants).map(e=>{var r;const n=(r=this.params.defaultVariants)==null?void 0:r[e];return n!==void 0?`${e}=${String(n)}`:e}):void 0;return{element:t,variantKeys:s}}_withBuildContext(t){this._context=t;const{name:s,config:e}=t;return this._callerName=s,this}}const h=(a,t)=>{const s=new p(a,t),e=o.elementFactory(a,s.cssClassName,s.props.element,s.props.variantKeys,{"data-unoptimized-client-component":!0});return Object.assign(e,{generator:s}),e};exports.styled=h;
|
package/styled.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import { Tag, StyledComponentProps,
|
3
|
-
export declare const styled: <const PROPS extends StyledComponentProps, const TAG extends Tag<Required<PROPS>>, const
|
1
|
+
import { AllHTMLAttributes, ReactDOM, ReactNode } from 'react';
|
2
|
+
import { Tag, StyledComponentProps, CreateElementProps, VariantProps, ParentComponentProps, StyledParams } from '../../core/src/types';
|
3
|
+
export declare const styled: <const PROPS extends StyledComponentProps, const TAG extends Tag<Required<PROPS>>, const STYLE_PARAMS extends StyledParams>(tagName: TAG, params: STYLE_PARAMS) => ((props: (CreateElementProps & ParentComponentProps<TAG>) | (TAG extends string ? {
|
4
|
+
ref: any;
|
5
|
+
} : never) | VariantProps<STYLE_PARAMS> | (TAG extends keyof ReactDOM ? ReactDOM[TAG] extends (...props: infer R) => any ? R[0] : TAG extends string ? AllHTMLAttributes<HTMLElement> : never : TAG extends string ? AllHTMLAttributes<HTMLElement> : never)) => ReactNode) & string;
|
package/styled.js
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
import { t as
|
2
|
-
import { e as c } from "./element-factory-
|
3
|
-
const
|
4
|
-
class
|
5
|
-
constructor(t, s
|
6
|
-
this.tagName = t, this.
|
1
|
+
import { t as i, p as o } from "./parse-styles-BRv2UFN0.js";
|
2
|
+
import { e as c } from "./element-factory-DjCaPhwl.js";
|
3
|
+
const p = (a) => Object.keys(a);
|
4
|
+
class m {
|
5
|
+
constructor(t, s) {
|
6
|
+
this.tagName = t, this.params = s;
|
7
7
|
}
|
8
8
|
get hash() {
|
9
|
-
return
|
9
|
+
return i(this.params.base || this.params);
|
10
10
|
}
|
11
11
|
get priority() {
|
12
12
|
var t;
|
13
|
-
return typeof this.tagName == "function" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
13
|
+
return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
14
14
|
}
|
15
15
|
get classNames() {
|
16
|
-
const t = [this.hash], { className: s } = this.
|
16
|
+
const t = [this.hash], { className: s } = this.params;
|
17
17
|
return s && t.push(s), t.join(" ");
|
18
18
|
}
|
19
19
|
get cssClassName() {
|
@@ -24,16 +24,17 @@ class l {
|
|
24
24
|
}
|
25
25
|
get templateKeys() {
|
26
26
|
var t;
|
27
|
-
return (t = this._context) != null && t.config.templates ?
|
27
|
+
return (t = this._context) != null && t.config.templates ? p(this._context.config.templates) : [];
|
28
28
|
}
|
29
29
|
get css() {
|
30
|
-
var
|
31
|
-
|
30
|
+
var r;
|
31
|
+
const { base: t = {}, variants: s = {}, compoundVariants: e = [] } = this.params, n = { ...t, variants: s, compoundVariants: e };
|
32
|
+
return o(n, `.${this.cssClassName}`, this.priority, (r = this._context) == null ? void 0 : r.config);
|
32
33
|
}
|
33
34
|
get props() {
|
34
|
-
const { element: t } = this.
|
35
|
-
var
|
36
|
-
const n = (
|
35
|
+
const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((e) => {
|
36
|
+
var r;
|
37
|
+
const n = (r = this.params.defaultVariants) == null ? void 0 : r[e];
|
37
38
|
return n !== void 0 ? `${e}=${String(n)}` : e;
|
38
39
|
}) : void 0;
|
39
40
|
return {
|
@@ -47,13 +48,13 @@ class l {
|
|
47
48
|
return this._callerName = s, this;
|
48
49
|
}
|
49
50
|
}
|
50
|
-
const u = (
|
51
|
-
const
|
51
|
+
const u = (a, t) => {
|
52
|
+
const s = new m(a, t), e = c(a, s.cssClassName, s.props.element, s.props.variantKeys, {
|
52
53
|
"data-unoptimized-client-component": !0
|
53
54
|
});
|
54
|
-
return Object.assign(
|
55
|
-
generator:
|
56
|
-
}),
|
55
|
+
return Object.assign(e, {
|
56
|
+
generator: s
|
57
|
+
}), e;
|
57
58
|
};
|
58
59
|
export {
|
59
60
|
u as styled
|
@@ -1,52 +0,0 @@
|
|
1
|
-
import { createElement as w } from "react";
|
2
|
-
function j(t) {
|
3
|
-
var n, s, e = "";
|
4
|
-
if (typeof t == "string" || typeof t == "number") e += t;
|
5
|
-
else if (typeof t == "object") if (Array.isArray(t)) {
|
6
|
-
var i = t.length;
|
7
|
-
for (n = 0; n < i; n++) t[n] && (s = j(t[n])) && (e && (e += " "), e += s);
|
8
|
-
} else for (s in t) t[s] && (e && (e += " "), e += s);
|
9
|
-
return e;
|
10
|
-
}
|
11
|
-
function O() {
|
12
|
-
for (var t, n, s = 0, e = "", i = arguments.length; s < i; s++) (t = arguments[s]) && (n = j(t)) && (e && (e += " "), e += n);
|
13
|
-
return e;
|
14
|
-
}
|
15
|
-
const C = ["passVariantProps"], A = (t, n, s, e, i) => {
|
16
|
-
const m = ({
|
17
|
-
extend: c = t,
|
18
|
-
element: g = s,
|
19
|
-
className: p = "",
|
20
|
-
children: E,
|
21
|
-
passVariantProps: S,
|
22
|
-
_vks: f = /* @__PURE__ */ new Set(),
|
23
|
-
...d
|
24
|
-
}) => {
|
25
|
-
const o = { passVariantProps: S };
|
26
|
-
d && Object.assign(o, d), i && Object.assign(o, i);
|
27
|
-
const u = new Set(p.split(" ")), l = typeof c == "function", y = l && "isStyled" in c, b = l ? c : g || c;
|
28
|
-
if (!b) throw new Error("No element provided");
|
29
|
-
e && e.forEach((a) => {
|
30
|
-
const [r, h] = a.split("=");
|
31
|
-
d[r] !== void 0 ? (u.add(`${r}-${d[r]}`), l ? f && f.add(r) : delete o[r]) : h !== void 0 && u.add(`${r}-${h}`);
|
32
|
-
}), f && (!l || !y && !S) ? f.forEach((a) => delete o[a]) : y && Object.assign(o, { _vks: f }), y || C.forEach((a) => delete o[a]);
|
33
|
-
const $ = O(n, ...u);
|
34
|
-
return w(
|
35
|
-
b,
|
36
|
-
{
|
37
|
-
element: l ? g : void 0,
|
38
|
-
className: $,
|
39
|
-
...o
|
40
|
-
},
|
41
|
-
E
|
42
|
-
);
|
43
|
-
};
|
44
|
-
return Object.assign(m, {
|
45
|
-
isStyled: !0,
|
46
|
-
className: n,
|
47
|
-
toString: () => `.${n}`
|
48
|
-
}), m;
|
49
|
-
};
|
50
|
-
export {
|
51
|
-
A as e
|
52
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";const w=require("react");function j(t){var n,s,e="";if(typeof t=="string"||typeof t=="number")e+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(s=j(t[n]))&&(e&&(e+=" "),e+=s)}else for(s in t)t[s]&&(e&&(e+=" "),e+=s);return e}function O(){for(var t,n,s=0,e="",o=arguments.length;s<o;s++)(t=arguments[s])&&(n=j(t))&&(e&&(e+=" "),e+=n);return e}const C=["passVariantProps"],V=(t,n,s,e,o)=>{const g=({extend:a=t,element:m=s,className:E="",children:$,passVariantProps:S,_vks:c=new Set,...d})=>{const i={passVariantProps:S};d&&Object.assign(i,d),o&&Object.assign(i,o);const u=new Set(E.split(" ")),f=typeof a=="function",y=f&&"isStyled"in a,b=f?a:m||a;if(!b)throw new Error("No element provided");e&&e.forEach(l=>{const[r,h]=l.split("=");d[r]!==void 0?(u.add(`${r}-${d[r]}`),f?c&&c.add(r):delete i[r]):h!==void 0&&u.add(`${r}-${h}`)}),c&&(!f||!y&&!S)?c.forEach(l=>delete i[l]):y&&Object.assign(i,{_vks:c}),y||C.forEach(l=>delete i[l]);const p=O(n,...u);return w.createElement(b,{element:f?m:void 0,className:p,...i},$)};return Object.assign(g,{isStyled:!0,className:n,toString:()=>`.${n}`}),g};exports.elementFactory=V;
|