@salty-css/react 0.0.1-alpha.276 → 0.0.1-alpha.278

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("@salty-css/core/parsers"),m=require("@salty-css/core/util"),S=require("./clsx-C11secjj.cjs"),i=s=>m.toHash(s),r=async(s,a)=>(await o.parseStyles(s,a)).join(`
2
- `),j=async({as:s,scope:a,styles:e,...n})=>{if(s){if(!e)return t.jsx(s,{...n});const c=i(e),u=await r(e,a||`.${c}`),y={...n,className:S.clsx(c,n.className)};return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:u}),t.jsx(s,{...y})]})}if(!e)return null;const l=await r(e,a);return t.jsx("style",{children:l})};exports.DynamicStyles=j;exports.getDynamicStylesClassName=i;exports.getDynamicStylesCss=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),S=require("@salty-css/core/parsers"),g=require("@salty-css/core/util"),j=require("./clsx-C11secjj.cjs"),x=require("react"),o=e=>g.toHash(e),c=async(e,n)=>(await S.parseStyles(e,n)).join(`
2
+ `),d=async({as:e,scope:n,styles:s,...r})=>{if(e){const a=l=>typeof e=="string"?x.createElement(e,l):e(l);if(!s)return t.jsx(a,{...r});const i=o(s),m=await c(s,n||`.${i}`),y={...r,className:j.clsx(i,r.className)};return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:m}),t.jsx(a,{...y})]})}if(!s)return null;const u=await c(s,n);return t.jsx("style",{children:u})};exports.DynamicStyles=d;exports.getDynamicStylesClassName=o;exports.getDynamicStylesCss=c;
@@ -9,14 +9,15 @@ export declare const getDynamicStylesClassName: (styles: BaseStyles) => string;
9
9
  * Note: this works only with server components.
10
10
  */
11
11
  export declare const getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
12
+ type AnyComponent = (...args: any[]) => React.ReactNode;
12
13
  interface DynamicStylesProps extends HTMLAttributes<HTMLElement> {
13
14
  styles?: BaseStyles;
14
15
  scope?: string;
15
- as?: (...args: any[]) => React.ReactNode;
16
+ as?: string | AnyComponent;
16
17
  }
17
18
  /**
18
19
  * Add any dynamic styles to your app with a custom scope.
19
20
  * Note: this works only with server components.
20
21
  */
21
- export declare const DynamicStyles: ({ as: Component, scope, styles, ...rest }: DynamicStylesProps) => Promise<import("react/jsx-runtime").JSX.Element | null>;
22
+ export declare const DynamicStyles: ({ as, scope, styles, ...rest }: DynamicStylesProps) => Promise<import("react/jsx-runtime").JSX.Element | null>;
22
23
  export {};
package/dynamic-styles.js CHANGED
@@ -1,23 +1,25 @@
1
- import { jsx as t, jsxs as l, Fragment as f } from "react/jsx-runtime";
2
- import { parseStyles as p } from "@salty-css/core/parsers";
3
- import { toHash as u } from "@salty-css/core/util";
4
- import { c as y } from "./clsx-OuTLNxxd.js";
5
- const d = (s) => u(s), e = async (s, a) => (await p(s, a)).join(`
6
- `), g = async ({ as: s, scope: a, styles: r, ...c }) => {
7
- if (s) {
8
- if (!r) return /* @__PURE__ */ t(s, { ...c });
9
- const n = d(r), o = await e(r, a || `.${n}`), m = { ...c, className: y(n, c.className) };
10
- return /* @__PURE__ */ l(f, { children: [
11
- /* @__PURE__ */ t("style", { children: o }),
12
- /* @__PURE__ */ t(s, { ...m })
1
+ import { jsx as s, jsxs as f, Fragment as y } from "react/jsx-runtime";
2
+ import { parseStyles as u } from "@salty-css/core/parsers";
3
+ import { toHash as d } from "@salty-css/core/util";
4
+ import { c as g } from "./clsx-OuTLNxxd.js";
5
+ import { createElement as h } from "react";
6
+ const x = (t) => d(t), m = async (t, r) => (await u(t, r)).join(`
7
+ `), D = async ({ as: t, scope: r, styles: n, ...e }) => {
8
+ if (t) {
9
+ const c = (a) => typeof t == "string" ? h(t, a) : t(a);
10
+ if (!n) return /* @__PURE__ */ s(c, { ...e });
11
+ const o = x(n), l = await m(n, r || `.${o}`), p = { ...e, className: g(o, e.className) };
12
+ return /* @__PURE__ */ f(y, { children: [
13
+ /* @__PURE__ */ s("style", { children: l }),
14
+ /* @__PURE__ */ s(c, { ...p })
13
15
  ] });
14
16
  }
15
- if (!r) return null;
16
- const i = await e(r, a);
17
- return /* @__PURE__ */ t("style", { children: i });
17
+ if (!n) return null;
18
+ const i = await m(n, r);
19
+ return /* @__PURE__ */ s("style", { children: i });
18
20
  };
19
21
  export {
20
- g as DynamicStyles,
21
- d as getDynamicStylesClassName,
22
- e as getDynamicStylesCss
22
+ D as DynamicStyles,
23
+ x as getDynamicStylesClassName,
24
+ m as getDynamicStylesCss
23
25
  };
@@ -2,42 +2,42 @@ import { forwardRef as V, createElement as C } from "react";
2
2
  import { c as N } from "./clsx-OuTLNxxd.js";
3
3
  import { dashCase as R } from "@salty-css/core/util";
4
4
  import { parseVariableTokens as p } from "@salty-css/core/parsers";
5
- const q = ["passProps"], B = (S, m = "", t = {}, y) => {
5
+ const q = ["passProps"], D = (S, m = "", t = {}, y) => {
6
6
  const b = V(({
7
7
  extend: c = S,
8
8
  element: h = t.element,
9
9
  className: E = "",
10
10
  children: K,
11
11
  passProps: l = t.passProps,
12
- _vks: n = /* @__PURE__ */ new Set(),
12
+ _vks: f = /* @__PURE__ */ new Set(),
13
13
  ...a
14
14
  }, O) => {
15
15
  const s = { passProps: l };
16
16
  t.attr && Object.assign(s, t.attr), y && Object.assign(s, y), t.defaultProps && Object.assign(a, t.defaultProps), a && Object.assign(s, a);
17
- const r = /* @__PURE__ */ new Set([...m.split(" "), ...E.split(" ")]), o = typeof c == "function" || typeof c == "object", u = o && "isStyled" in c, j = o ? c : h || c;
17
+ const u = /* @__PURE__ */ new Set([...m.split(" "), ...E.split(" ")]), d = typeof c == "function" || typeof c == "object", r = d && "isStyled" in c, j = d ? c : h || c;
18
18
  if (!j) throw new Error("No element provided");
19
- const d = s.style || {};
20
- s.style || (s.style = d), Object.entries(d).forEach(([e, i]) => {
21
- const f = p(i);
22
- f && (d[e] = f.transformed);
19
+ const o = s.style || {};
20
+ s.style || (s.style = o), Object.entries(o).forEach(([e, i]) => {
21
+ const n = p(i);
22
+ n && (o[e] = n.transformed);
23
23
  }), t.propValueKeys && t.propValueKeys.forEach((e) => {
24
- const i = `css-${e}`, f = a[i];
25
- if (f === void 0) return;
24
+ const i = `css-${e}`, n = a[i];
25
+ if (n === void 0) return;
26
26
  const w = `--props-${R(e)}`;
27
- d[w] = f, n && n.add(i);
27
+ o[w] = n, f && f.add(i);
28
28
  }), t.variantKeys && t.variantKeys.forEach((e) => {
29
- const [i, f] = e.split("=");
30
- a[i] !== void 0 ? (r.add(`${i}-${a[i]}`), n && n.add(i)) : f !== void 0 && r.add(`${i}-${f}`);
31
- }), n && (!o || !u) ? n.forEach((e) => {
29
+ const [i, n] = e.split("=");
30
+ a[i] !== void 0 ? (u.add(`${i}-${a[i]}`), f && f.add(i)) : n !== void 0 && u.add(`${i}-${n}`);
31
+ }), f && (!d || !r) ? f.forEach((e) => {
32
32
  if (!l) return delete s[e];
33
33
  if (l !== !0 && !l.includes(e))
34
34
  return delete s[e];
35
- }) : u && Object.assign(s, { _vks: n }), u || q.forEach((e) => delete s[e]);
36
- const $ = N(...r);
35
+ }) : r && Object.assign(s, { _vks: f }), r || q.forEach((e) => delete s[e]);
36
+ const $ = N(...u);
37
37
  return C(
38
38
  j,
39
39
  {
40
- element: o ? h : void 0,
40
+ element: d ? h : void 0,
41
41
  className: $,
42
42
  ref: O,
43
43
  ...s
@@ -52,5 +52,5 @@ const q = ["passProps"], B = (S, m = "", t = {}, y) => {
52
52
  }), b;
53
53
  };
54
54
  export {
55
- B as e
55
+ D as e
56
56
  };
@@ -0,0 +1 @@
1
+ "use strict";const S=require("react"),C=require("./clsx-C11secjj.cjs"),N=require("@salty-css/core/util"),F=require("@salty-css/core/parsers"),R=["passProps"],T=(E,y="",t={},m)=>{const K=({extend:a=E,element:h=t.element,className:O="",children:$,passProps:l=t.passProps,_vks:c=new Set,...f},w)=>{const s={passProps:l};t.attr&&Object.assign(s,t.attr),m&&Object.assign(s,m),t.defaultProps&&Object.assign(f,t.defaultProps),f&&Object.assign(s,f);const r=new Set([...y.split(" "),...O.split(" ")]),d=typeof a=="function"||typeof a=="object",o=d&&"isStyled"in a,j=d?a:h||a;if(!j)throw new Error("No element provided");const u=s.style||{};s.style||(s.style=u),Object.entries(u).forEach(([e,n])=>{const i=F.parseVariableTokens(n);i&&(u[e]=i.transformed)}),t.propValueKeys&&t.propValueKeys.forEach(e=>{const n=`css-${e}`,i=f[n];if(i===void 0)return;const q=`--props-${N.dashCase(e)}`;u[q]=i,c&&c.add(n)}),t.variantKeys&&t.variantKeys.forEach(e=>{const[n,i]=e.split("=");f[n]!==void 0?(r.add(`${n}-${f[n]}`),c&&c.add(n)):i!==void 0&&r.add(`${n}-${i}`)}),c&&(!d||!o)?c.forEach(e=>{if(!l)return delete s[e];if(l!==!0&&!l.includes(e))return delete s[e]}):o&&Object.assign(s,{_vks:c}),o||R.forEach(e=>delete s[e]);const V=C.clsx(...r);return S.createElement(j,{element:d?h:void 0,className:V,ref:w,...s},$)},b=S.forwardRef(K);return Object.assign(b,{isStyled:!0,className:y,toString:()=>`.${t.hash}`}),b};exports.elementFactory=T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/react",
3
- "version": "0.0.1-alpha.276",
3
+ "version": "0.0.1-alpha.278",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -70,7 +70,7 @@
70
70
  }
71
71
  },
72
72
  "dependencies": {
73
- "@salty-css/core": "^0.0.1-alpha.276",
73
+ "@salty-css/core": "^0.0.1-alpha.278",
74
74
  "clsx": ">=2.x",
75
75
  "react": ">=19.x || >=18.3.x"
76
76
  }
package/styled-client.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./element-factory-BPI0pGIH.cjs"),n=(e,t,r)=>l.elementFactory(e,t,r);exports.styledClient=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./element-factory-CvLrXNeg.cjs"),n=(e,t,r)=>l.elementFactory(e,t,r);exports.styledClient=n;
package/styled-client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { e as o } from "./element-factory-D5vMsSwp.js";
1
+ import { e as o } from "./element-factory-Bs1HmAhv.js";
2
2
  const l = (e, t, r) => o(e, t, r);
3
3
  export {
4
4
  l as styledClient
package/styled.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@salty-css/core/generators"),s=require("./element-factory-BPI0pGIH.cjs"),c=(t,r)=>{const e=new o.StyledGenerator(t,r),n=s.elementFactory(t,e.cssClassName,e.clientProps,{"data-unoptimized-client-component":!0});return Object.assign(n,{generator:e}),n};exports.styled=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@salty-css/core/generators"),s=require("./element-factory-CvLrXNeg.cjs"),c=(t,r)=>{const e=new o.StyledGenerator(t,r),n=s.elementFactory(t,e.cssClassName,e.clientProps,{"data-unoptimized-client-component":!0});return Object.assign(n,{generator:e}),n};exports.styled=c;
package/styled.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { StyledGenerator as r } from "@salty-css/core/generators";
2
- import { e as s } from "./element-factory-D5vMsSwp.js";
2
+ import { e as s } from "./element-factory-Bs1HmAhv.js";
3
3
  const i = (t, o) => {
4
4
  const e = new r(t, o), n = s(t, e.cssClassName, e.clientProps, {
5
5
  "data-unoptimized-client-component": !0
@@ -1 +0,0 @@
1
- "use strict";const S=require("react"),C=require("./clsx-C11secjj.cjs"),N=require("@salty-css/core/util"),F=require("@salty-css/core/parsers"),R=["passProps"],v=(E,y="",t={},m)=>{const K=({extend:l=E,element:h=t.element,className:O="",children:$,passProps:f=t.passProps,_vks:c=new Set,...a},w)=>{const s={passProps:f};t.attr&&Object.assign(s,t.attr),m&&Object.assign(s,m),t.defaultProps&&Object.assign(a,t.defaultProps),a&&Object.assign(s,a);const o=new Set([...y.split(" "),...O.split(" ")]),d=typeof l=="function"||typeof l=="object",r=d&&"isStyled"in l,j=d?l:h||l;if(!j)throw new Error("No element provided");const u=s.style||{};s.style||(s.style=u),Object.entries(u).forEach(([e,i])=>{const n=F.parseVariableTokens(i);n&&(u[e]=n.transformed)}),t.propValueKeys&&t.propValueKeys.forEach(e=>{const i=`css-${e}`,n=a[i];if(n===void 0)return;const q=`--props-${N.dashCase(e)}`;u[q]=n,c&&c.add(i)}),t.variantKeys&&t.variantKeys.forEach(e=>{const[i,n]=e.split("=");a[i]!==void 0?(o.add(`${i}-${a[i]}`),c&&c.add(i)):n!==void 0&&o.add(`${i}-${n}`)}),c&&(!d||!r)?c.forEach(e=>{if(!f)return delete s[e];if(f!==!0&&!f.includes(e))return delete s[e]}):r&&Object.assign(s,{_vks:c}),r||R.forEach(e=>delete s[e]);const V=C.clsx(...o);return S.createElement(j,{element:d?h:void 0,className:V,ref:w,...s},$)},b=S.forwardRef(K);return Object.assign(b,{isStyled:!0,className:y,toString:()=>`.${t.hash}`}),b};exports.elementFactory=v;