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

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 e=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),c=async(s,t)=>(await o.parseStyles(s,t)).join(`
2
- `),d=async({as:s,scope:t,styles:a,...n})=>{if(s){const r=i(a),u=await c(a,t||r),y={...n,className:S.clsx(r,n.className)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:u}),e.jsx(s,{...y})]})}const l=await c(a,t);return e.jsx("style",{children:l})};exports.DynamicStyles=d;exports.useDynamicStyles=c;exports.useDynamicStylesClassName=i;
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;
@@ -3,20 +3,20 @@ import { HTMLAttributes } from 'react';
3
3
  /**
4
4
  * Create a hash of the dynamic styles that then can be used as scope.
5
5
  */
6
- export declare const useDynamicStylesClassName: (styles: BaseStyles) => string;
6
+ export declare const getDynamicStylesClassName: (styles: BaseStyles) => string;
7
7
  /**
8
8
  * Add any dynamic styles to your app with a custom scope.
9
9
  * Note: this works only with server components.
10
10
  */
11
- export declare const useDynamicStyles: (styles: BaseStyles, scope?: string) => Promise<string>;
11
+ export declare const getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
12
12
  interface DynamicStylesProps extends HTMLAttributes<HTMLElement> {
13
+ styles?: BaseStyles;
13
14
  scope?: string;
14
15
  as?: (...args: any[]) => React.ReactNode;
15
- styles: BaseStyles;
16
16
  }
17
17
  /**
18
18
  * Add any dynamic styles to your app with a custom scope.
19
19
  * Note: this works only with server components.
20
20
  */
21
- export declare const DynamicStyles: ({ as: Component, scope, styles, ...rest }: DynamicStylesProps) => Promise<import("react/jsx-runtime").JSX.Element>;
21
+ export declare const DynamicStyles: ({ as: Component, scope, styles, ...rest }: DynamicStylesProps) => Promise<import("react/jsx-runtime").JSX.Element | null>;
22
22
  export {};
package/dynamic-styles.js CHANGED
@@ -1,21 +1,23 @@
1
- import { jsxs as l, Fragment as y, jsx as t } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as l, Fragment as f } from "react/jsx-runtime";
2
2
  import { parseStyles as p } from "@salty-css/core/parsers";
3
3
  import { toHash as u } from "@salty-css/core/util";
4
- import { c as d } from "./clsx-OuTLNxxd.js";
5
- const f = (s) => u(s), e = async (s, a) => (await p(s, a)).join(`
6
- `), j = async ({ as: s, scope: a, styles: r, ...c }) => {
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
7
  if (s) {
8
- const n = f(r), i = await e(r, a || n), m = { ...c, className: d(n, c.className) };
9
- return /* @__PURE__ */ l(y, { children: [
10
- /* @__PURE__ */ t("style", { children: i }),
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 }),
11
12
  /* @__PURE__ */ t(s, { ...m })
12
13
  ] });
13
14
  }
14
- const o = await e(r, a);
15
- return /* @__PURE__ */ t("style", { children: o });
15
+ if (!r) return null;
16
+ const i = await e(r, a);
17
+ return /* @__PURE__ */ t("style", { children: i });
16
18
  };
17
19
  export {
18
- j as DynamicStyles,
19
- e as useDynamicStyles,
20
- f as useDynamicStylesClassName
20
+ g as DynamicStyles,
21
+ d as getDynamicStylesClassName,
22
+ e as getDynamicStylesCss
21
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/react",
3
- "version": "0.0.1-alpha.274",
3
+ "version": "0.0.1-alpha.276",
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.274",
73
+ "@salty-css/core": "^0.0.1-alpha.276",
74
74
  "clsx": ">=2.x",
75
75
  "react": ">=19.x || >=18.3.x"
76
76
  }