@salty-css/react 0.1.0-alpha.4 → 0.1.0-alpha.5

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 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("@salty-css/core/parsers"),C=require("@salty-css/core/cache/resolve-dynamic-config-cache"),S=require("@salty-css/core/util"),f=require("./clsx-C11secjj.cjs"),j=require("react"),l=e=>S.toHash(e),r=async(e,t)=>{const s=await C.resolveDynamicConfigCache();return(await g.parseStyles(e,t,s)).join(`
2
- `)},x=async({as:e,scope:t,styles:s,...c})=>{if(e){const a=o=>typeof e=="string"?j.createElement(e,o):e(o);if(!s)return n.jsx(a,{...c});const i=l(s),u=await r(s,t||`.${i}`),y={...c,className:f.clsx(i,c.className)};return n.jsxs(n.Fragment,{children:[n.jsx("style",{children:u}),n.jsx(a,{...y})]})}if(!s)return null;const m=await r(s,t);return n.jsx("style",{children:m})};exports.DynamicStyles=x;exports.getDynamicStylesClassName=l;exports.getDynamicStylesCss=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@salty-css/core/css/dynamic-styles"),u=require("./clsx-C11secjj.cjs"),g=require("react"),S=async({as:n,scope:r,styles:t,...c})=>{if(n){const a=l=>typeof n=="string"?g.createElement(n,l):n(l);if(!t)return e.jsx(a,{...c});const i=s.getDynamicStylesClassName(t),m=await s.getDynamicStylesCss(t,r||`.${i}`),o={...c,className:u.clsx(i,c.className)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:m}),e.jsx(a,{...o})]})}if(!t)return null;const y=await s.getDynamicStylesCss(t,r);return e.jsx("style",{children:y})};Object.defineProperty(exports,"getDynamicStylesClassName",{enumerable:!0,get:()=>s.getDynamicStylesClassName});Object.defineProperty(exports,"getDynamicStylesCss",{enumerable:!0,get:()=>s.getDynamicStylesCss});exports.DynamicStyles=S;
@@ -1,14 +1,7 @@
1
1
  import { BaseStyles } from '@salty-css/core/types';
2
+ import { getDynamicStylesClassName, getDynamicStylesCss } from '@salty-css/core/css/dynamic-styles';
2
3
  import { HTMLAttributes } from 'react';
3
- /**
4
- * Create a hash of the dynamic styles that then can be used as scope.
5
- */
6
- export declare const getDynamicStylesClassName: (styles: BaseStyles) => string;
7
- /**
8
- * Add any dynamic styles to your app with a custom scope.
9
- * Note: this works only with server components.
10
- */
11
- export declare const getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
4
+ export { getDynamicStylesClassName, getDynamicStylesCss };
12
5
  type AnyComponent = (...args: any[]) => React.ReactNode;
13
6
  interface DynamicStylesProps extends HTMLAttributes<HTMLElement> {
14
7
  styles?: BaseStyles;
@@ -20,4 +13,3 @@ interface DynamicStylesProps extends HTMLAttributes<HTMLElement> {
20
13
  * Note: this works only with server components.
21
14
  */
22
15
  export declare const DynamicStyles: ({ as, scope, styles, ...rest }: DynamicStylesProps) => Promise<import("react/jsx-runtime").JSX.Element | null>;
23
- export {};
package/dynamic-styles.js CHANGED
@@ -1,29 +1,24 @@
1
- import { jsx as s, jsxs as p, Fragment as y } from "react/jsx-runtime";
2
- import { parseStyles as u } from "@salty-css/core/parsers";
3
- import { resolveDynamicConfigCache as g } from "@salty-css/core/cache/resolve-dynamic-config-cache";
4
- import { toHash as d } from "@salty-css/core/util";
5
- import { c as h } from "./clsx-OuTLNxxd.js";
6
- import { createElement as C } from "react";
7
- const w = (t) => d(t), i = async (t, r) => {
8
- const n = await g();
9
- return (await u(t, r, n)).join(`
10
- `);
11
- }, E = async ({ as: t, scope: r, styles: n, ...o }) => {
12
- if (t) {
13
- const c = (a) => typeof t == "string" ? C(t, a) : t(a);
14
- if (!n) return /* @__PURE__ */ s(c, { ...o });
15
- const e = w(n), l = await i(n, r || `.${e}`), f = { ...o, className: h(e, o.className) };
16
- return /* @__PURE__ */ p(y, { children: [
17
- /* @__PURE__ */ s("style", { children: l }),
18
- /* @__PURE__ */ s(c, { ...f })
1
+ import { jsx as n, jsxs as f, Fragment as p } from "react/jsx-runtime";
2
+ import { getDynamicStylesClassName as g, getDynamicStylesCss as o } from "@salty-css/core/css/dynamic-styles";
3
+ import { getDynamicStylesClassName as w, getDynamicStylesCss as E } from "@salty-css/core/css/dynamic-styles";
4
+ import { c as u } from "./clsx-OuTLNxxd.js";
5
+ import { createElement as x } from "react";
6
+ const d = async ({ as: e, scope: r, styles: t, ...s }) => {
7
+ if (e) {
8
+ const c = (a) => typeof e == "string" ? x(e, a) : e(a);
9
+ if (!t) return /* @__PURE__ */ n(c, { ...s });
10
+ const m = g(t), l = await o(t, r || `.${m}`), y = { ...s, className: u(m, s.className) };
11
+ return /* @__PURE__ */ f(p, { children: [
12
+ /* @__PURE__ */ n("style", { children: l }),
13
+ /* @__PURE__ */ n(c, { ...y })
19
14
  ] });
20
15
  }
21
- if (!n) return null;
22
- const m = await i(n, r);
23
- return /* @__PURE__ */ s("style", { children: m });
16
+ if (!t) return null;
17
+ const i = await o(t, r);
18
+ return /* @__PURE__ */ n("style", { children: i });
24
19
  };
25
20
  export {
26
- E as DynamicStyles,
21
+ d as DynamicStyles,
27
22
  w as getDynamicStylesClassName,
28
- i as getDynamicStylesCss
23
+ E as getDynamicStylesCss
29
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/react",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -78,7 +78,7 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
- "@salty-css/core": "^0.1.0-alpha.4",
81
+ "@salty-css/core": "^0.1.0-alpha.5",
82
82
  "clsx": ">=2.x",
83
83
  "react": ">=19.x || >=18.3.x"
84
84
  },