@salty-css/react 0.0.1-alpha.17 → 0.0.1-alpha.171

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 CHANGED
@@ -1,15 +1,132 @@
1
- # Salty Css
1
+ ![Salty CSS Banner](https://salty-css.dev/assets/banners/dvd.svg)
2
2
 
3
- ## Basic usage example with Button
3
+ # Salty CSS - CSS-in-JS library that is kinda sweet
4
4
 
5
- ### Initial requirements
5
+ Is there anything saltier than CSS in frontend web development? Salty CSS is built to provide better developer experience for developers looking for performant and feature rich CSS-in-JS solutions.
6
6
 
7
- 1. Add `saltyPlugin` to vite or webpack config from `@salty-css/vite` or `@salty-css/webpack`
8
- 2. Create `salty.config.ts` to the root of your project
9
- 3. Import global styles to any regular .css file from `saltygen/index.css` (does not exist during first run, cli command coming later)
10
- 4. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
7
+ ## Features
11
8
 
12
- ### Code examples
9
+ - Build time compilation to achieve awesome runtime performance and minimal size
10
+ - Next.js, React Server Components, Vite and Webpack support
11
+ - Type safety with out of the box TypeScript and ESLint plugin
12
+ - Advanced CSS variables configuration to allow smooth token usage
13
+ - Style templates to create reusable styles easily
14
+
15
+ ## Get started
16
+
17
+ Fastest way to get started with any framework is `npx salty-css init [directory]` command
18
+
19
+ - Next.js → [Next.js guide](#nextjs) + [Next.js example app](https://github.com/margarita-form/salty-css-website)
20
+ - React + Vite → [React + Vite guide](#react--vite) + [React example code](#code-examples)
21
+ - React + Webpack → Guide coming soon
22
+
23
+ ## Useful commands
24
+
25
+ - Create component: `npx salty-css generate [filePath]`
26
+ - Build: `npx salty-css build [directory]`
27
+ - Update Salty CSS packages: `npx salty-css up`
28
+
29
+ ## Salty CSS styled function
30
+
31
+ ```ts
32
+ // components/wrapper.css.ts
33
+ import { styled } from '@salty-css/react/styled';
34
+
35
+ // Define a component with styled function. First argument is the component name or existing component to extend and second argument is the object containing the styles and other options
36
+ export const Component = styled('div', {
37
+ className: 'wrapper', // Define custom class name that will be included for this component
38
+ element: 'section', // Define the html element that will be rendered for this component, overrides the first 'div' argument
39
+ base: {
40
+ // 👉 Add your CSS-in-JS base styles here! 👈
41
+ },
42
+ variants: {
43
+ // Define conditional styles that will be applied to the component based on the variant prop values
44
+ },
45
+ compoundVariants: [
46
+ // Define conditional styles that will be applied to the component based on the combination of variant prop values
47
+ ],
48
+ defaultVariants: {
49
+ // Set default variant prop values
50
+ },
51
+ defaultProps: {
52
+ // Add additional default props for the component (eg, id and other html element attributes)
53
+ },
54
+ passProps: true, // Pass variant props to the rendered element / parent component (default: false)
55
+ });
56
+ ```
57
+
58
+ ## Salty CSS CLI
59
+
60
+ In your existing repository you can use `npx salty-css [command]` to initialize a project, generate components, update related packages and build required files.
61
+
62
+ - Initialize project → `npx salty-css init [directory]` - Installs required packages, detects framework in use and creates project files to the provided directory. Directory can be left blank if you want files to be created to the current directory.
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.
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
65
+
66
+ ## Usage
67
+
68
+ ### Next.js
69
+
70
+ ![salty-next](https://github.com/user-attachments/assets/2cf6a93f-cdd5-4f5f-ab2e-3bc8bcfb83e8)
71
+
72
+ Salty CSS provides Next.js App & Pages router support with full React Server Components support.
73
+
74
+ ### Add Salty CSS to Next.js
75
+
76
+ 1. In your existing Next.js repository you can run `npx salty-css init` to automatically configure Salty CSS.
77
+ 2. Create your first Salty CSS component with `npx salty-css generate [filePath]` (e.g. src/custom-wrapper)
78
+ 3. Import your component for example to `page.tsx` and see it working!
79
+
80
+ And note: steps 2 & 3 are just to show how get new components up and running, step 1 does all of the important stuff 🤯
81
+
82
+ #### Manual configuration
83
+
84
+ 1. For Next.js support install `npm i @salty-css/next @salty-css/core @salty-css/react`
85
+ 2. Create `salty.config.ts` to your app directory
86
+ 3. Add Salty CSS plugin to next.js config
87
+
88
+ - **Next.js 15:** In `next.config.ts` add import for salty plugin `import { withSaltyCss } from '@salty-css/next';` and then add `withSaltyCss` to wrap your nextConfig export like so `export default withSaltyCss(nextConfig);`
89
+ - **Next.js 14 and older:** In `next.config.js` add import for salty plugin `const { withSaltyCss } = require('@salty-css/next');` and then add `withSaltyCss` to wrap your nextConfig export like so `module.exports = withSaltyCss(nextConfig);`
90
+
91
+ 4. Make sure that `salty.config.ts` and `next.config.ts` are in the same folder!
92
+ 5. Build `saltygen` directory by running your app once or with cli `npx salty-css build [directory]`
93
+ 6. Import global styles from `saltygen/index.css` to some global css file with `@import 'insert_path_to_index_css';`.
94
+
95
+ [Check out Next.js demo project](https://github.com/margarita-form/salty-css-website) or [react example code](#code-examples)
96
+
97
+ ---
98
+
99
+ ### React + Vite
100
+
101
+ ![salty-vite-react](https://github.com/user-attachments/assets/12ec5b6a-0dcc-48fa-afc1-d337fc8f800c)
102
+
103
+ ### Add Salty CSS to your React + Vite app
104
+
105
+ 1. In your existing Vite repository you can run `npx salty-css init` to automatically configure Salty CSS.
106
+ 2. Create your first Salty CSS component with `npx salty-css generate [filePath]` (e.g. src/custom-wrapper)
107
+ 3. Import your component for example to `main.tsx` and see it working!
108
+
109
+ And note: steps 2 & 3 are just to show how get new components up and running, step 1 does all of the important stuff 🤯
110
+
111
+ #### Manual configuration
112
+
113
+ 1. For Vite support install `npm i @salty-css/vite @salty-css/core`
114
+ 2. In `vite.config` add import for salty plugin `import { saltyPlugin } from '@salty-css/vite';` and then add `saltyPlugin(__dirname)` to your vite configuration plugins
115
+ 3. Make sure that `salty.config.ts` and `vite.config.ts` are in the same folder!
116
+ 4. Build `saltygen` directory by running your app once or with cli `npx salty-css build [directory]`
117
+ 5. Import global styles from `saltygen/index.css` to some global css file with `@import 'insert_path_to_index_css';`.
118
+
119
+ [Check out react example code](#code-examples)
120
+
121
+ ---
122
+
123
+ ### Create components
124
+
125
+ 1. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
126
+
127
+ ## Code examples
128
+
129
+ ### Basic usage example with Button
13
130
 
14
131
  **Salty config**
15
132
 
@@ -31,23 +148,6 @@ export const config = defineConfig({
31
148
  });
32
149
  ```
33
150
 
34
- **Your React component file**
35
-
36
- ```tsx
37
- import { Wrapper } from '../components/wrapper/wrapper.css';
38
- import { Button } from '../components/button/button.css';
39
-
40
- export const IndexPage = () => {
41
- return (
42
- <Wrapper>
43
- <Button variant="solid" onClick={() => alert('It is a button.')}>
44
- Outlined
45
- </Button>
46
- </Wrapper>
47
- );
48
- };
49
- ```
50
-
51
151
  **Wrapper** (`components/wrapper/wrapper.css.ts`)
52
152
 
53
153
  ```tsx
@@ -72,7 +172,7 @@ export const Button = styled('button', {
72
172
  padding: `0.6em 1.2em`,
73
173
  border: '1px solid currentColor',
74
174
  background: 'transparent',
75
- color: 'currentColor/40',
175
+ color: 'currentColor',
76
176
  cursor: 'pointer',
77
177
  transition: '200ms',
78
178
  textDecoration: 'none',
@@ -108,4 +208,21 @@ export const Button = styled('button', {
108
208
  });
109
209
  ```
110
210
 
211
+ **Your React component file**
212
+
213
+ ```tsx
214
+ import { Wrapper } from '../components/wrapper/wrapper.css';
215
+ import { Button } from '../components/button/button.css';
216
+
217
+ export const IndexPage = () => {
218
+ return (
219
+ <Wrapper>
220
+ <Button variant="solid" onClick={() => alert('It is a button.')}>
221
+ Outlined
222
+ </Button>
223
+ </Wrapper>
224
+ );
225
+ };
226
+ ```
227
+
111
228
  More examples coming soon
package/config.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=e=>e;class r{constructor(t){this._current=t}get isGlobalDefine(){return!0}}const a=e=>new r(e);class n{constructor(t){this._current=t}get isDefineVariables(){return!0}}const s=e=>new n(e),l=e=>new n({variables:e}),o=e=>new n({responsiveVariables:e}),c=e=>new n({conditionalVariables:e});exports.GlobalStylesFactory=r;exports.VariablesFactory=n;exports.defineConditionalVariables=c;exports.defineConfig=i;exports.defineGlobalStyles=a;exports.defineResponsiveVariables=o;exports.defineStaticVariables=l;exports.defineVariables=s;
package/config.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@salty-css/core/config';
package/config.js ADDED
@@ -0,0 +1,29 @@
1
+ const s = (e) => e;
2
+ class t {
3
+ constructor(r) {
4
+ this._current = r;
5
+ }
6
+ get isGlobalDefine() {
7
+ return !0;
8
+ }
9
+ }
10
+ const i = (e) => new t(e);
11
+ class n {
12
+ constructor(r) {
13
+ this._current = r;
14
+ }
15
+ get isDefineVariables() {
16
+ return !0;
17
+ }
18
+ }
19
+ const a = (e) => new n(e), o = (e) => new n({ variables: e }), c = (e) => new n({ responsiveVariables: e }), l = (e) => new n({ conditionalVariables: e });
20
+ export {
21
+ t as GlobalStylesFactory,
22
+ n as VariablesFactory,
23
+ l as defineConditionalVariables,
24
+ s as defineConfig,
25
+ i as defineGlobalStyles,
26
+ c as defineResponsiveVariables,
27
+ o as defineStaticVariables,
28
+ a as defineVariables
29
+ };
@@ -0,0 +1,67 @@
1
+ import { forwardRef as g, createElement as p } from "react";
2
+ import { p as N, d as A } from "./parse-tokens-YUi047xd.js";
3
+ function K(n) {
4
+ var s, e, t = "";
5
+ if (typeof n == "string" || typeof n == "number") t += n;
6
+ else if (typeof n == "object") if (Array.isArray(n)) {
7
+ var o = n.length;
8
+ for (s = 0; s < o; s++) n[s] && (e = K(n[s])) && (t && (t += " "), t += e);
9
+ } else for (e in n) n[e] && (t && (t += " "), t += e);
10
+ return t;
11
+ }
12
+ function R() {
13
+ for (var n, s, e = 0, t = "", o = arguments.length; e < o; e++) (n = arguments[e]) && (s = K(n)) && (t && (t += " "), t += s);
14
+ return t;
15
+ }
16
+ const F = ["passProps"], x = (n, s, e, t) => {
17
+ const j = g(({
18
+ extend: d = n,
19
+ element: S = e.element,
20
+ className: O = "",
21
+ children: $,
22
+ passProps: u = e.passProps,
23
+ _vks: c = /* @__PURE__ */ new Set(),
24
+ ...r
25
+ }, w) => {
26
+ const f = { passProps: u };
27
+ e.attr && Object.assign(f, e.attr), t && Object.assign(f, t), e.defaultProps && Object.assign(r, e.defaultProps), r && Object.assign(f, r);
28
+ const b = new Set(O.split(" ")), y = typeof d == "function" || typeof d == "object", h = y && "isStyled" in d, E = y ? d : S || d;
29
+ if (!E) throw new Error("No element provided");
30
+ const m = f.style || {};
31
+ f.style || (f.style = m), Object.entries(m).forEach(([i, a]) => {
32
+ const { result: l } = N(a);
33
+ m[i] = l;
34
+ }), e.propValueKeys && e.propValueKeys.forEach((i) => {
35
+ const a = `css-${i}`, l = r[a];
36
+ if (l === void 0) return;
37
+ const C = `--props-${A(i)}`;
38
+ m[C] = l, c && c.add(a);
39
+ }), e.variantKeys && e.variantKeys.forEach((i) => {
40
+ const [a, l] = i.split("=");
41
+ r[a] !== void 0 ? (b.add(`${a}-${r[a]}`), c && c.add(a)) : l !== void 0 && b.add(`${a}-${l}`);
42
+ }), c && (!y || !h) ? c.forEach((i) => {
43
+ if (!u) return delete f[i];
44
+ if (u !== !0 && !u.includes(i))
45
+ return delete f[i];
46
+ }) : h && Object.assign(f, { _vks: c }), h || F.forEach((i) => delete f[i]);
47
+ const V = R(s, ...b);
48
+ return p(
49
+ E,
50
+ {
51
+ element: y ? S : void 0,
52
+ className: V,
53
+ ref: w,
54
+ ...f
55
+ },
56
+ $
57
+ );
58
+ });
59
+ return Object.assign(j, {
60
+ isStyled: !0,
61
+ className: s,
62
+ toString: () => `.${s}`
63
+ }), j;
64
+ };
65
+ export {
66
+ x as e
67
+ };
@@ -0,0 +1 @@
1
+ "use strict";const K=require("react"),O=require("./parse-tokens-p68muVgG.cjs");function $(n){var s,e,t="";if(typeof n=="string"||typeof n=="number")t+=n;else if(typeof n=="object")if(Array.isArray(n)){var u=n.length;for(s=0;s<u;s++)n[s]&&(e=$(n[s]))&&(t&&(t+=" "),t+=e)}else for(e in n)n[e]&&(t&&(t+=" "),t+=e);return t}function q(){for(var n,s,e=0,t="",u=arguments.length;e<u;e++)(n=arguments[e])&&(s=$(n))&&(t&&(t+=" "),t+=s);return t}const A=["passProps"],F=(n,s,e,t)=>{const u=({extend:d=n,element:S=e.element,className:w="",children:V,passProps:o=e.passProps,_vks:c=new Set,...r},C)=>{const f={passProps:o};e.attr&&Object.assign(f,e.attr),t&&Object.assign(f,t),e.defaultProps&&Object.assign(r,e.defaultProps),r&&Object.assign(f,r);const b=new Set(w.split(" ")),y=typeof d=="function"||typeof d=="object",h=y&&"isStyled"in d,E=y?d:S||d;if(!E)throw new Error("No element provided");const m=f.style||{};f.style||(f.style=m),Object.entries(m).forEach(([i,a])=>{const{result:l}=O.parseValueTokens(a);m[i]=l}),e.propValueKeys&&e.propValueKeys.forEach(i=>{const a=`css-${i}`,l=r[a];if(l===void 0)return;const N=`--props-${O.dashCase(i)}`;m[N]=l,c&&c.add(a)}),e.variantKeys&&e.variantKeys.forEach(i=>{const[a,l]=i.split("=");r[a]!==void 0?(b.add(`${a}-${r[a]}`),c&&c.add(a)):l!==void 0&&b.add(`${a}-${l}`)}),c&&(!y||!h)?c.forEach(i=>{if(!o)return delete f[i];if(o!==!0&&!o.includes(i))return delete f[i]}):h&&Object.assign(f,{_vks:c}),h||A.forEach(i=>delete f[i]);const g=q(s,...b);return K.createElement(E,{element:y?S:void 0,className:g,ref:C,...f},V)},j=K.forwardRef(u);return Object.assign(j,{isStyled:!0,className:s,toString:()=>`.${s}`}),j};exports.elementFactory=F;
@@ -1,3 +1,3 @@
1
- import { GeneratorProps } from '../../core/src/generator';
2
- import { StyledComponentProps, Tag } from '../../core/src/types';
1
+ import { GeneratorProps } from '@salty-css/core/generator';
2
+ import { StyledComponentProps, Tag } from '@salty-css/core/types';
3
3
  export declare const elementFactory: (tagName: Tag<any>, _className: string, _generatorProps: GeneratorProps, _additionalProps?: Record<PropertyKey, any>) => import('react').ForwardRefExoticComponent<Omit<StyledComponentProps, "ref"> & import('react').RefAttributes<any>>;
package/keyframes.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./parse-styles-SPT4zc_H.cjs"),b=({animationName:u,params:l,appendInitialStyles:m,...t})=>{const s=u||c.toHash(t),n=(r={})=>{const{duration:e="500ms",easing:o="ease-in-out",delay:a="0s",iterationCount:i="1",direction:S="normal",fillMode:d="forwards",playState:p="running"}={...l,...r},$=`${s} ${e} ${o} ${a} ${i} ${S} ${d} ${p}`;if(!m)return $;const g=c.parseStyles(t.from||t["0%"],"");return`${$};${g}`},y=Object.entries(t).reduce((r,[e,o])=>{const a=c.parseStyles(o,""),i=typeof e=="number"?`${e}%`:e;return`${r}${i}{${a}}`},""),f=`@keyframes ${s} {${y}}`;return Object.assign(n,{toString:n,isKeyframes:!0,animationName:s,css:f,keyframes:t}),n};exports.keyframes=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./parse-styles-JzVmxd-u.cjs"),j=({animationName:m,params:l,appendInitialStyles:f,...t})=>{const r=m||u.toHash(t),o=(n={})=>{const{duration:e="500ms",easing:s="ease-in-out",delay:a="0s",iterationCount:i="1",direction:d="normal",fillMode:g="forwards",playState:p="running"}={...l,...n},c=`${r} ${e} ${s} ${a} ${i} ${d} ${g} ${p}`;if(!f)return c;const $=t.from||t["0%"];if(!$)return c;const b=u.parseStyles($,"");return`${c};${b}`},y=Object.entries(t).reduce((n,[e,s])=>{if(!s)return n;const a=u.parseStyles(s,""),i=typeof e=="number"?`${e}%`:e;return`${n}${i}{${a}}`},""),S=`@keyframes ${r} {${y}}`;return Object.assign(o,{toString:o,isKeyframes:!0,animationName:r,css:S,keyframes:t}),o};exports.keyframes=j;
package/keyframes.d.ts CHANGED
@@ -1,22 +1 @@
1
- import { CssStyles, StyleValue } from '../../core/src/types';
2
- type KeyframeKeys = number | 'from' | 'to' | `${number}%`;
3
- type Keyframes = {
4
- [key in KeyframeKeys]: CssStyles;
5
- };
6
- interface KeyframesConfig {
7
- animationName?: string;
8
- appendInitialStyles?: boolean;
9
- params?: KeyframesParams;
10
- }
11
- interface KeyframesParams {
12
- duration?: string;
13
- delay?: string;
14
- iterationCount?: string | number;
15
- easing?: StyleValue<'animationTimingFunction'>;
16
- direction?: StyleValue<'animationDirection'>;
17
- fillMode?: StyleValue<'animationFillMode'>;
18
- playState?: StyleValue<'animationPlayState'>;
19
- }
20
- type KeyframesProps = Keyframes & KeyframesConfig;
21
- export declare const keyframes: ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes }: KeyframesProps) => (params?: KeyframesParams) => string;
22
- export {};
1
+ export * from '@salty-css/core/css/keyframes';
package/keyframes.js CHANGED
@@ -1,30 +1,33 @@
1
- import { t as b, p as c } from "./parse-styles-T74HIH4_.js";
2
- const C = ({ animationName: m, params: u, appendInitialStyles: f, ...t }) => {
3
- const s = m || b(t), e = (r = {}) => {
1
+ import { t as j, p as m } from "./parse-styles-lB6EJuGj.js";
2
+ const N = ({ animationName: u, params: f, appendInitialStyles: l, ...t }) => {
3
+ const e = u || j(t), o = (s = {}) => {
4
4
  const {
5
5
  duration: n = "500ms",
6
- easing: o = "ease-in-out",
6
+ easing: r = "ease-in-out",
7
7
  delay: a = "0s",
8
8
  iterationCount: i = "1",
9
- direction: d = "normal",
10
- fillMode: y = "forwards",
9
+ direction: y = "normal",
10
+ fillMode: g = "forwards",
11
11
  playState: S = "running"
12
- } = { ...u, ...r }, $ = `${s} ${n} ${o} ${a} ${i} ${d} ${y} ${S}`;
13
- if (!f) return $;
14
- const g = c(t.from || t["0%"], "");
15
- return `${$};${g}`;
16
- }, l = Object.entries(t).reduce((r, [n, o]) => {
17
- const a = c(o, ""), i = typeof n == "number" ? `${n}%` : n;
18
- return `${r}${i}{${a}}`;
19
- }, ""), p = `@keyframes ${s} {${l}}`;
20
- return Object.assign(e, {
21
- toString: e,
12
+ } = { ...f, ...s }, $ = `${e} ${n} ${r} ${a} ${i} ${y} ${g} ${S}`;
13
+ if (!l) return $;
14
+ const c = t.from || t["0%"];
15
+ if (!c) return $;
16
+ const b = m(c, "");
17
+ return `${$};${b}`;
18
+ }, p = Object.entries(t).reduce((s, [n, r]) => {
19
+ if (!r) return s;
20
+ const a = m(r, ""), i = typeof n == "number" ? `${n}%` : n;
21
+ return `${s}${i}{${a}}`;
22
+ }, ""), d = `@keyframes ${e} {${p}}`;
23
+ return Object.assign(o, {
24
+ toString: o,
22
25
  isKeyframes: !0,
23
- animationName: s,
24
- css: p,
26
+ animationName: e,
27
+ css: d,
25
28
  keyframes: t
26
- }), e;
29
+ }), o;
27
30
  };
28
31
  export {
29
- C as keyframes
32
+ N as keyframes
30
33
  };
package/media.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var o=(s,e,t)=>e in s?a(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var i=(s,e,t)=>o(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r{constructor(e="@media"){i(this,"next",e=>{const t=new String(e);return Object.assign(t,{get and(){return new r(`${e} and`)},get or(){return new r(`${e},`)}}),t});this.base=e}custom(e){return this.next(`${this.base} ${e}`)}minWidth(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (min-width: ${t})`;return this.next(n)}maxWidth(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (max-width: ${t})`;return this.next(n)}minHeight(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (min-height: ${t})`;return this.next(n)}maxHeight(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (max-height: ${t})`;return this.next(n)}get portrait(){const e=`${this.base} (orientation: portrait)`;return this.next(e)}get landscape(){const e=`${this.base} (orientation: landscape)`;return this.next(e)}prefersColorScheme(e){const t=`${this.base} (prefers-color-scheme: ${e})`;return this.next(t)}get dark(){return this.prefersColorScheme("dark")}get light(){return this.prefersColorScheme("light")}get print(){const e=`${this.base} print`;return this.next(e)}get screen(){const e=`${this.base} screen`;return this.next(e)}get speech(){const e=`${this.base} speech`;return this.next(e)}get all(){const e=`${this.base} all`;return this.next(e)}get not(){const e=`${this.base} not`;return this.next(e)}get reducedMotion(){const e=`${this.base} (prefers-reduced-motion: reduce)`;return this.next(e)}}const h=new r;exports.MediaQueryFactory=r;exports.media=h;
1
+ "use strict";var a=Object.defineProperty;var o=(s,e,t)=>e in s?a(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var i=(s,e,t)=>o(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r{constructor(e="@media"){i(this,"next",e=>{const t=new String(e);return Object.assign(t,{get isMedia(){return!0},get and(){return new r(`${e} and`)},get or(){return new r(`${e},`)}}),t});this.base=e}custom(e){return this.next(`${this.base} ${e}`)}minWidth(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (min-width: ${t})`;return this.next(n)}maxWidth(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (max-width: ${t})`;return this.next(n)}minHeight(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (min-height: ${t})`;return this.next(n)}maxHeight(e){const t=typeof e=="number"?`${e}px`:e,n=`${this.base} (max-height: ${t})`;return this.next(n)}get portrait(){const e=`${this.base} (orientation: portrait)`;return this.next(e)}get landscape(){const e=`${this.base} (orientation: landscape)`;return this.next(e)}prefersColorScheme(e){const t=`${this.base} (prefers-color-scheme: ${e})`;return this.next(t)}get dark(){return this.prefersColorScheme("dark")}get light(){return this.prefersColorScheme("light")}get print(){const e=`${this.base} print`;return this.next(e)}get screen(){const e=`${this.base} screen`;return this.next(e)}get speech(){const e=`${this.base} speech`;return this.next(e)}get all(){const e=`${this.base} all`;return this.next(e)}get not(){const e=`${this.base} not`;return this.next(e)}get reducedMotion(){const e=`${this.base} (prefers-reduced-motion: reduce)`;return this.next(e)}}const u=new r;exports.MediaQueryFactory=r;exports.media=u;
package/media.d.ts CHANGED
@@ -1,71 +1 @@
1
- import { OrNumber, OrString } from '../../core/src/types/util-types';
2
- export declare class MediaQueryFactory {
3
- private base;
4
- constructor(base?: string);
5
- private next;
6
- custom(value: string): string & {
7
- and: MediaQueryFactory;
8
- or: MediaQueryFactory;
9
- };
10
- minWidth(width: OrString | OrNumber): string & {
11
- and: MediaQueryFactory;
12
- or: MediaQueryFactory;
13
- };
14
- maxWidth(width: OrString | OrNumber): string & {
15
- and: MediaQueryFactory;
16
- or: MediaQueryFactory;
17
- };
18
- minHeight(height: OrString | OrNumber): string & {
19
- and: MediaQueryFactory;
20
- or: MediaQueryFactory;
21
- };
22
- maxHeight(height: OrString | OrNumber): string & {
23
- and: MediaQueryFactory;
24
- or: MediaQueryFactory;
25
- };
26
- get portrait(): string & {
27
- and: MediaQueryFactory;
28
- or: MediaQueryFactory;
29
- };
30
- get landscape(): string & {
31
- and: MediaQueryFactory;
32
- or: MediaQueryFactory;
33
- };
34
- prefersColorScheme(scheme: 'dark' | 'light' | OrString): string & {
35
- and: MediaQueryFactory;
36
- or: MediaQueryFactory;
37
- };
38
- get dark(): string & {
39
- and: MediaQueryFactory;
40
- or: MediaQueryFactory;
41
- };
42
- get light(): string & {
43
- and: MediaQueryFactory;
44
- or: MediaQueryFactory;
45
- };
46
- get print(): string & {
47
- and: MediaQueryFactory;
48
- or: MediaQueryFactory;
49
- };
50
- get screen(): string & {
51
- and: MediaQueryFactory;
52
- or: MediaQueryFactory;
53
- };
54
- get speech(): string & {
55
- and: MediaQueryFactory;
56
- or: MediaQueryFactory;
57
- };
58
- get all(): string & {
59
- and: MediaQueryFactory;
60
- or: MediaQueryFactory;
61
- };
62
- get not(): string & {
63
- and: MediaQueryFactory;
64
- or: MediaQueryFactory;
65
- };
66
- get reducedMotion(): string & {
67
- and: MediaQueryFactory;
68
- or: MediaQueryFactory;
69
- };
70
- }
71
- export declare const media: MediaQueryFactory;
1
+ export * from '@salty-css/core/css/media';
package/media.js CHANGED
@@ -1,11 +1,14 @@
1
- var o = Object.defineProperty;
2
- var a = (s, t, e) => t in s ? o(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var i = (s, t, e) => a(s, typeof t != "symbol" ? t + "" : t, e);
1
+ var a = Object.defineProperty;
2
+ var o = (s, t, e) => t in s ? a(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var i = (s, t, e) => o(s, typeof t != "symbol" ? t + "" : t, e);
4
4
  class r {
5
5
  constructor(t = "@media") {
6
6
  i(this, "next", (t) => {
7
7
  const e = new String(t);
8
8
  return Object.assign(e, {
9
+ get isMedia() {
10
+ return !0;
11
+ },
9
12
  get and() {
10
13
  return new r(`${t} and`);
11
14
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/react",
3
- "version": "0.0.1-alpha.17",
3
+ "version": "0.0.1-alpha.171",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -10,7 +10,12 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "homepage": "https://github.com/margarita-form/salty-css",
13
+ "description": "React library for Salty CSS",
14
+ "homepage": "https://salty-css.dev/",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/margarita-form/salty-css.git"
18
+ },
14
19
  "bugs": {
15
20
  "url": "https://github.com/margarita-form/salty-css/issues"
16
21
  },
@@ -38,11 +43,15 @@
38
43
  "./media": {
39
44
  "import": "./media.js",
40
45
  "require": "./media.cjs"
46
+ },
47
+ "./config": {
48
+ "import": "./config.js",
49
+ "require": "./config.cjs"
41
50
  }
42
51
  },
43
52
  "dependencies": {
44
- "@salty-css/core": "^0.0.1-alpha.17",
53
+ "@salty-css/core": "^0.0.1-alpha.171",
45
54
  "clsx": ">=2.x",
46
- "react": ">=18.3.x"
55
+ "react": ">=19.x || >=18.3.x"
47
56
  }
48
57
  }
@@ -0,0 +1,7 @@
1
+ "use strict";const O=require("./parse-tokens-p68muVgG.cjs"),E=e=>String.fromCharCode(e+(e>25?39:97)),P=(e,s)=>{let t="",n;for(n=Math.abs(e);n>52;n=n/52|0)t=E(n%52)+t;return t=E(n%52)+t,t.length<s?t=t.padStart(s,"a"):t.length>s&&(t=t.slice(-s)),t},T=(e,s)=>{let t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return e},W=(e,s=5)=>{const t=T(5381,JSON.stringify(e))>>>0;return P(t,s)},k=(e,s)=>{if(typeof e!="string")return{result:e};if(!s)return{result:e};const t=[];return Object.values(s).forEach(n=>{const{pattern:a,transform:b}=n;e=e.replace(a,i=>{const{value:$,css:r}=b(i);return r&&t.push(r),$})}),{result:e,additionalCss:t}},h=(e,s,t)=>{if(!e)return"";const n=[],a=Object.entries(e).reduce((i,[$,r])=>{const o=$.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(o==="variants")return Object.entries(r).forEach(([p,c])=>{c&&Object.entries(c).forEach(([m,d])=>{if(!d)return;const l=`${s}.${p}-${m}`,y=h(d,l,t);n.push(y)})}),i;if(o==="defaultVariants")return i;if(o==="compoundVariants")return r.forEach(p=>{const{css:c,...m}=p,d=Object.entries(m).reduce((y,[H,N])=>`${y}.${H}-${N}`,s),l=h(c,d,t);n.push(l)}),i;if(o.startsWith("@")){const p=h(r,s,t),c=`${o} {
2
+ ${p.replace(`
3
+ `,`
4
+ `)}
5
+ }`;return n.push(c),i}const f=$.includes("&")?o.replace("&",s):o.startsWith(":")?`${s}${o}`:`${s} ${o}`,u=h(r,f,t);return n.push(u),i}if(t!=null&&t.templates&&t.templates[o]){const u=r.split(".").reduce((p,c)=>p[c],t.templates[o]);if(u){const p=h(u,"");return`${i}${p}`}return console.warn(`Template "${o}" with path of "${r}" was not found in config!`),i}const V=o.startsWith("-")?o:O.dashCase(o),S=(f,u=";")=>i=`${i}${f}${u}`,j=f=>S(`${V}:${f}`);if(typeof r=="number")return j(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:w}=t||{},A=function*(){yield O.parseValueTokens(r),yield k(r,w)}();for(const{result:f,additionalCss:u=[]}of A)r=f,u.forEach(p=>{const c=h(p,"");S(c,"")});return j(r)},"");return a?s?[`${s} { ${a} }`,...n].join(`
6
+ `):a:n.join(`
7
+ `)};exports.parseStyles=h;exports.toHash=W;
@@ -0,0 +1,86 @@
1
+ import { d as P, p as W } from "./parse-tokens-YUi047xd.js";
2
+ const O = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), H = (e, s) => {
3
+ let t = "", n;
4
+ for (n = Math.abs(e); n > 52; n = n / 52 | 0) t = O(n % 52) + t;
5
+ return t = O(n % 52) + t, t.length < s ? t = t.padStart(s, "a") : t.length > s && (t = t.slice(-s)), t;
6
+ }, M = (e, s) => {
7
+ let t = s.length;
8
+ for (; t; ) e = e * 33 ^ s.charCodeAt(--t);
9
+ return e;
10
+ }, x = (e, s = 5) => {
11
+ const t = M(5381, JSON.stringify(e)) >>> 0;
12
+ return H(t, s);
13
+ }, T = (e, s) => {
14
+ if (typeof e != "string") return { result: e };
15
+ if (!s) return { result: e };
16
+ const t = [];
17
+ return Object.values(s).forEach((n) => {
18
+ const { pattern: h, transform: y } = n;
19
+ e = e.replace(h, (i) => {
20
+ const { value: $, css: r } = y(i);
21
+ return r && t.push(r), $;
22
+ });
23
+ }), { result: e, additionalCss: t };
24
+ }, a = (e, s, t) => {
25
+ if (!e) return "";
26
+ const n = [], h = Object.entries(e).reduce((i, [$, r]) => {
27
+ const o = $.trim();
28
+ if (typeof r == "function" && (r = r()), typeof r == "object") {
29
+ if (!r) return i;
30
+ if (o === "variants")
31
+ return Object.entries(r).forEach(([p, f]) => {
32
+ f && Object.entries(f).forEach(([m, d]) => {
33
+ if (!d) return;
34
+ const b = `${s}.${p}-${m}`, l = a(d, b, t);
35
+ n.push(l);
36
+ });
37
+ }), i;
38
+ if (o === "defaultVariants")
39
+ return i;
40
+ if (o === "compoundVariants")
41
+ return r.forEach((p) => {
42
+ const { css: f, ...m } = p, d = Object.entries(m).reduce((l, [A, N]) => `${l}.${A}-${N}`, s), b = a(f, d, t);
43
+ n.push(b);
44
+ }), i;
45
+ if (o.startsWith("@")) {
46
+ const p = a(r, s, t), f = `${o} {
47
+ ${p.replace(`
48
+ `, `
49
+ `)}
50
+ }`;
51
+ return n.push(f), i;
52
+ }
53
+ const c = $.includes("&") ? o.replace("&", s) : o.startsWith(":") ? `${s}${o}` : `${s} ${o}`, u = a(r, c, t);
54
+ return n.push(u), i;
55
+ }
56
+ if (t != null && t.templates && t.templates[o]) {
57
+ const u = r.split(".").reduce((p, f) => p[f], t.templates[o]);
58
+ if (u) {
59
+ const p = a(u, "");
60
+ return `${i}${p}`;
61
+ }
62
+ return console.warn(`Template "${o}" with path of "${r}" was not found in config!`), i;
63
+ }
64
+ const E = o.startsWith("-") ? o : P(o), j = (c, u = ";") => i = `${i}${c}${u}`, S = (c) => j(`${E}:${c}`);
65
+ if (typeof r == "number") return S(r);
66
+ if (typeof r != "string")
67
+ if ("toString" in r) r = r.toString();
68
+ else return i;
69
+ const { modifiers: V } = t || {}, w = function* () {
70
+ yield W(r), yield T(r, V);
71
+ }();
72
+ for (const { result: c, additionalCss: u = [] } of w)
73
+ r = c, u.forEach((p) => {
74
+ const f = a(p, "");
75
+ j(f, "");
76
+ });
77
+ return S(r);
78
+ }, "");
79
+ return h ? s ? [`${s} { ${h} }`, ...n].join(`
80
+ `) : h : n.join(`
81
+ `);
82
+ };
83
+ export {
84
+ a as p,
85
+ x as t
86
+ };
@@ -0,0 +1,8 @@
1
+ function n(e) {
2
+ return e ? typeof e != "string" ? n(String(e)) : e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, t) => (t > 0 ? "-" : "") + r.toLowerCase()) : "";
3
+ }
4
+ const o = (e) => typeof e != "string" ? { result: e } : /\{[^{}]+\}/g.test(e) ? { result: e.replace(/\{([^{}]+)\}/g, (...s) => `var(--${n(s[1].replaceAll(".", "-"))})`) } : { result: e };
5
+ export {
6
+ n as d,
7
+ o as p
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";function r(e){return e?typeof e!="string"?r(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const a=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${r(n[1].replaceAll(".","-"))})`)}:{result:e};exports.dashCase=r;exports.parseValueTokens=a;
package/styled-client.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./element-factory-WgNOpLmJ.cjs"),l=(e,t,n="",o)=>r.elementFactory(e,t,o,{"data-component-name":n});exports.styledClient=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./element-factory-D4kpeFoW.cjs"),n=(e,t,r)=>l.elementFactory(e,t,r);exports.styledClient=n;
@@ -1,3 +1,3 @@
1
- import { GeneratorProps } from '../../core/src/generator';
2
- import { Tag } from '../../core/src/types';
3
- export declare const styledClient: (tagName: Tag<any>, className: string, callerName: string | undefined, generatorProps: GeneratorProps) => import('react').ForwardRefExoticComponent<Omit<import('../../core/src/types').StyledComponentProps, "ref"> & import('react').RefAttributes<any>>;
1
+ import { GeneratorProps } from '@salty-css/core/generator';
2
+ import { Tag } from '@salty-css/core/types';
3
+ export declare const styledClient: (tagName: Tag<any>, className: string, generatorProps: GeneratorProps) => import('react').ForwardRefExoticComponent<Omit<import('@salty-css/core/types').StyledComponentProps, "ref"> & import('react').RefAttributes<any>>;
package/styled-client.js CHANGED
@@ -1,7 +1,5 @@
1
- import { e as r } from "./element-factory-uEk4VrqP.js";
2
- const m = (e, t, n = "", o) => r(e, t, o, {
3
- "data-component-name": n
4
- });
1
+ import { e as o } from "./element-factory-C7JVLDq7.js";
2
+ const l = (e, t, r) => o(e, t, r);
5
3
  export {
6
- m as styledClient
4
+ l as styledClient
7
5
  };
package/styled.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var m=(e,t,s)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var c=(e,t,s)=>m(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./parse-styles-SPT4zc_H.cjs"),u=require("./element-factory-WgNOpLmJ.cjs"),y=e=>Object.keys(e);class g{constructor(t,s){c(this,"_callerName");c(this,"_context");this.tagName=t,this.params=s}get hash(){return h.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?y(this._context.config.templates):[]}get css(){var r;const{base:t={},variants:s={},compoundVariants:a=[]}=this.params,n={...t,variants:s,compoundVariants:a};return h.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(r=>{var i;const o=(i=this.params.defaultVariants)==null?void 0:i[r];return o!==void 0?`${r}=${String(o)}`:r}):void 0,a=new Set([]),n=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return n&&n.forEach((r,o,i)=>{const p=i.at(1);p&&a.add(p)}),{element:t,variantKeys:s,propValueKeys:[...a]}}_withBuildContext(t){this._context=t;const{name:s,config:a}=t;return this._callerName=s,this}}const f=(e,t)=>{const s=new g(e,t),a=u.elementFactory(e,s.cssClassName,s.props,{"data-unoptimized-client-component":!0});return Object.assign(a,{generator:s}),a};exports.styled=f;
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 u=require("./parse-styles-JzVmxd-u.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 u.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 u.parseStyles(i,`.${this.cssClassName}`,(n=this._context)==null?void 0:n.config)}get props(){const{element:t,variants:s={},compoundVariants:r=[],defaultVariants:i={},defaultProps:p={},passProps:n}=this.params,h=new Set([]),l=a=>{const o=i[a];o!==void 0?h.add(`${a}=${String(o)}`):h.add(a)};Object.keys(s).forEach(l),r.map(a=>Object.keys(a).forEach(l));const m=new Set([]);if(this.params.base){const a=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);a&&a.forEach(o=>{const d=o.replace(/\{props\.([\w\d]+)\}/gi,"$1");d&&m.add(d)})}return{element:t,variantKeys:[...h],propValueKeys:[...m],passProps:n,defaultProps:p,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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { AllHTMLAttributes, ReactDOM, ReactNode } from 'react';
2
- import { Tag, StyledComponentProps, CreateElementProps, VariantProps, ParentComponentProps, StyledParams, ValueProps } 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> | ValueProps | (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;
1
+ import { AllHTMLAttributes, JSX, ReactNode } from 'react';
2
+ import { Tag, StyledComponentProps, CreateElementProps, VariantProps, ParentComponentProps, StyledParams, ValueProps, Merge } from '@salty-css/core/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 & (TAG extends string ? {
4
+ ref?: any;
5
+ } : object) & Merge<ParentComponentProps<TAG> | VariantProps<STYLE_PARAMS>> & ValueProps & Omit<TAG extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[TAG] : TAG extends string ? AllHTMLAttributes<HTMLElement> : object, keyof CreateElementProps>) => ReactNode) & string;
package/styled.js CHANGED
@@ -1,25 +1,27 @@
1
- var m = Object.defineProperty;
2
- var h = (e, t, s) => t in e ? m(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var c = (e, t, s) => h(e, typeof t != "symbol" ? t + "" : t, s);
4
- import { t as l, p as u } from "./parse-styles-T74HIH4_.js";
5
- import { e as g } from "./element-factory-uEk4VrqP.js";
6
- const y = (e) => Object.keys(e);
7
- class f {
8
- constructor(t, s) {
1
+ var u = Object.defineProperty;
2
+ var f = (e, s, t) => s in e ? u(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var c = (e, s, t) => f(e, typeof s != "symbol" ? s + "" : s, t);
4
+ import { t as g, p as y } from "./parse-styles-lB6EJuGj.js";
5
+ import { d as N } from "./parse-tokens-YUi047xd.js";
6
+ import { e as _ } from "./element-factory-C7JVLDq7.js";
7
+ const $ = (e) => Object.keys(e);
8
+ class b {
9
+ constructor(s, t) {
10
+ c(this, "_isProd");
9
11
  c(this, "_callerName");
10
12
  c(this, "_context");
11
- this.tagName = t, this.params = s;
13
+ this.tagName = s, this.params = t;
12
14
  }
13
15
  get hash() {
14
- return l(this.params.base || this.params);
16
+ return g(this.params.base || this.params);
15
17
  }
16
18
  get priority() {
17
- var t;
18
- return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
19
+ var s;
20
+ return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((s = this.tagName.generator) == null ? void 0 : s.priority) || 0) + 1 : 0;
19
21
  }
20
22
  get classNames() {
21
- const t = [this.hash], { className: s } = this.params;
22
- return s && t.push(s), t.join(" ");
23
+ const s = [this.hash], { className: t } = this.params;
24
+ return t && s.push(t), s.join(" ");
23
25
  }
24
26
  get cssClassName() {
25
27
  return this.hash;
@@ -27,44 +29,57 @@ class f {
27
29
  get cssDisplayNameVar() {
28
30
  return `--${this.hash}-display-name: ${this._callerName};`;
29
31
  }
32
+ get cssFileName() {
33
+ return this._callerName ? `c_${N(this._callerName)}-${this.hash}-${this.priority}.css` : `${this.hash}-${this.priority}.css`;
34
+ }
30
35
  get templateKeys() {
31
- var t;
32
- return (t = this._context) != null && t.config.templates ? y(this._context.config.templates) : [];
36
+ var s;
37
+ return (s = this._context) != null && s.config.templates ? $(this._context.config.templates) : [];
33
38
  }
34
39
  get css() {
35
- var r;
36
- const { base: t = {}, variants: s = {}, compoundVariants: a = [] } = this.params, n = { ...t, variants: s, compoundVariants: a };
37
- return u(n, `.${this.cssClassName}`, this.priority, (r = this._context) == null ? void 0 : r.config);
40
+ var n;
41
+ const { base: s = {}, variants: t = {}, compoundVariants: r = [] } = this.params, i = { ...s, variants: t, compoundVariants: r };
42
+ return y(i, `.${this.cssClassName}`, (n = this._context) == null ? void 0 : n.config);
38
43
  }
39
44
  get props() {
40
- const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((r) => {
41
- var i;
42
- const o = (i = this.params.defaultVariants) == null ? void 0 : i[r];
43
- return o !== void 0 ? `${r}=${String(o)}` : r;
44
- }) : void 0, a = /* @__PURE__ */ new Set([]), n = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
45
- return n && n.forEach((r, o, i) => {
46
- const p = i.at(1);
47
- p && a.add(p);
48
- }), {
49
- element: t,
50
- variantKeys: s,
51
- propValueKeys: [...a]
45
+ const { element: s, variants: t = {}, compoundVariants: r = [], defaultVariants: i = {}, defaultProps: p = {}, passProps: n } = this.params, h = /* @__PURE__ */ new Set([]), m = (a) => {
46
+ const o = i[a];
47
+ o !== void 0 ? h.add(`${a}=${String(o)}`) : h.add(a);
48
+ };
49
+ Object.keys(t).forEach(m), r.map((a) => Object.keys(a).forEach(m));
50
+ const l = /* @__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 d = o.replace(/\{props\.([\w\d]+)\}/gi, "$1");
55
+ d && l.add(d);
56
+ });
57
+ }
58
+ return {
59
+ element: s,
60
+ variantKeys: [...h],
61
+ propValueKeys: [...l],
62
+ passProps: n,
63
+ defaultProps: p,
64
+ attr: {
65
+ "data-component-name": this._isProd ? void 0 : this._callerName
66
+ }
52
67
  };
53
68
  }
54
- _withBuildContext(t) {
55
- this._context = t;
56
- const { name: s, config: a } = t;
57
- return this._callerName = s, this;
69
+ _withBuildContext(s) {
70
+ this._context = s;
71
+ const { name: t, config: r, prod: i } = s;
72
+ return this._isProd = i, this._callerName = t, this;
58
73
  }
59
74
  }
60
- const _ = (e, t) => {
61
- const s = new f(e, t), a = g(e, s.cssClassName, s.props, {
75
+ const j = (e, s) => {
76
+ const t = new b(e, s), r = _(e, t.cssClassName, t.props, {
62
77
  "data-unoptimized-client-component": !0
63
78
  });
64
- return Object.assign(a, {
65
- generator: s
66
- }), a;
79
+ return Object.assign(r, {
80
+ generator: t
81
+ }), r;
67
82
  };
68
83
  export {
69
- _ as styled
84
+ j as styled
70
85
  };
@@ -1 +0,0 @@
1
- "use strict";function r(e){return e?typeof e!="string"?r(String(e)):e.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(n,t)=>(t>0?"-":"")+n.toLowerCase()):""}exports.dashCase=r;
@@ -1,6 +0,0 @@
1
- function t(e) {
2
- return e ? typeof e != "string" ? t(String(e)) : e.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, n) => (n > 0 ? "-" : "") + r.toLowerCase()) : "";
3
- }
4
- export {
5
- t as d
6
- };
@@ -1 +0,0 @@
1
- "use strict";const K=require("react"),C=require("./dash-case-B_odFlTl.cjs");function $(t){var n,s,e="";if(typeof t=="string"||typeof t=="number")e+=t;else if(typeof t=="object")if(Array.isArray(t)){var c=t.length;for(n=0;n<c;n++)t[n]&&(s=$(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="",c=arguments.length;s<c;s++)(t=arguments[s])&&(n=$(t))&&(e&&(e+=" "),e+=n);return e}const O=["passVariantProps"],N=(t,n,s,e)=>{const c=({extend:f=t,element:b=s.element,className:g="",children:v,passVariantProps:S,_vks:r=new Set,...l},w)=>{const i={passVariantProps:S};e&&Object.assign(i,e),l&&Object.assign(i,l);const u=new Set(g.split(" ")),y=typeof f=="function"||typeof f=="object",m=y&&"isStyled"in f,j=y?f:b||f;if(!j)throw new Error("No element provided");s.propValueKeys&&(i.style||(i.style={}),s.propValueKeys.forEach(a=>{const o=`css-${a}`,d=l[o];if(d===void 0)return;const p=`--props-${C.dashCase(a)}`;i.style[p]=d,r&&r.add(o)})),s.variantKeys&&s.variantKeys.forEach(a=>{const[o,d]=a.split("=");l[o]!==void 0?(u.add(`${o}-${l[o]}`),r&&r.add(o)):d!==void 0&&u.add(`${o}-${d}`)}),r&&(!y||!m&&!S)?r.forEach(a=>delete i[a]):m&&Object.assign(i,{_vks:r}),m||O.forEach(a=>delete i[a]);const E=V(n,...u);return K.createElement(j,{element:y?b:void 0,className:E,ref:w,...i},v)},h=K.forwardRef(c);return Object.assign(h,{isStyled:!0,className:n,toString:()=>`.${n}`}),h};exports.elementFactory=N;
@@ -1,59 +0,0 @@
1
- import { forwardRef as E, createElement as V } from "react";
2
- import { d as C } from "./dash-case-CGJ_UIZz.js";
3
- function j(t) {
4
- var n, s, e = "";
5
- if (typeof t == "string" || typeof t == "number") e += t;
6
- else if (typeof t == "object") if (Array.isArray(t)) {
7
- var d = t.length;
8
- for (n = 0; n < d; n++) t[n] && (s = j(t[n])) && (e && (e += " "), e += s);
9
- } else for (s in t) t[s] && (e && (e += " "), e += s);
10
- return e;
11
- }
12
- function O() {
13
- for (var t, n, s = 0, e = "", d = arguments.length; s < d; s++) (t = arguments[s]) && (n = j(t)) && (e && (e += " "), e += n);
14
- return e;
15
- }
16
- const N = ["passVariantProps"], q = (t, n, s, e) => {
17
- const h = E(({
18
- extend: r = t,
19
- element: b = s.element,
20
- className: K = "",
21
- children: $,
22
- passVariantProps: p,
23
- _vks: f = /* @__PURE__ */ new Set(),
24
- ...c
25
- }, g) => {
26
- const i = { passVariantProps: p };
27
- e && Object.assign(i, e), c && Object.assign(i, c);
28
- const u = new Set(K.split(" ")), y = typeof r == "function" || typeof r == "object", m = y && "isStyled" in r, S = y ? r : b || r;
29
- if (!S) throw new Error("No element provided");
30
- s.propValueKeys && (i.style || (i.style = {}), s.propValueKeys.forEach((o) => {
31
- const a = `css-${o}`, l = c[a];
32
- if (l === void 0) return;
33
- const w = `--props-${C(o)}`;
34
- i.style[w] = l, f && f.add(a);
35
- })), s.variantKeys && s.variantKeys.forEach((o) => {
36
- const [a, l] = o.split("=");
37
- c[a] !== void 0 ? (u.add(`${a}-${c[a]}`), f && f.add(a)) : l !== void 0 && u.add(`${a}-${l}`);
38
- }), f && (!y || !m && !p) ? f.forEach((o) => delete i[o]) : m && Object.assign(i, { _vks: f }), m || N.forEach((o) => delete i[o]);
39
- const v = O(n, ...u);
40
- return V(
41
- S,
42
- {
43
- element: y ? b : void 0,
44
- className: v,
45
- ref: g,
46
- ...i
47
- },
48
- $
49
- );
50
- });
51
- return Object.assign(h, {
52
- isStyled: !0,
53
- className: n,
54
- toString: () => `.${n}`
55
- }), h;
56
- };
57
- export {
58
- q as e
59
- };
@@ -1,7 +0,0 @@
1
- "use strict";const V=require("./dash-case-B_odFlTl.cjs"),E=r=>String.fromCharCode(r+(r>25?39:97)),P=(r,s)=>{let t="",n;for(n=Math.abs(r);n>52;n=n/52|0)t=E(n%52)+t;return t=E(n%52)+t,t.length<s?t=t.padStart(s,"a"):t.length>s&&(t=t.slice(-s)),t},T=(r,s)=>{let t=s.length;for(;t;)r=r*33^s.charCodeAt(--t);return r},W=(r,s=3)=>{const t=T(5381,JSON.stringify(r))>>>0;return P(t,s)},q=(r,s)=>{if(typeof r!="string")return{result:r};if(!s)return{result:r};const t=[];return Object.values(s).forEach(n=>{const{pattern:p,transform:$}=n;r=r.replace(p,d=>{const{value:i,css:l}=$(d);return l&&t.push(l),i})}),{result:r,additionalCss:t}},M=r=>typeof r!="string"?{result:r}:/\{[^{}]+\}/g.test(r)?{result:r.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V.dashCase(n[1].replaceAll(".","-"))})`)}:{result:r},a=(r,s,t,n)=>{if(!r)return"";const p=[],$=Object.entries(r).reduce((i,[l,e])=>{const o=l.trim();if(typeof e=="function"&&(e=e()),typeof e=="object"){if(!e)return i;if(o==="variants")return Object.entries(e).forEach(([f,c])=>{c&&Object.entries(c).forEach(([m,b])=>{if(!b)return;const S=`${s}.${f}-${m}`,j=a(b,S,t);p.push(j)})}),i;if(o==="defaultVariants")return i;if(o==="compoundVariants")return e.forEach(f=>{const{css:c,...m}=f,b=Object.entries(m).reduce((j,[H,N])=>`${j}.${H}-${N}`,s),S=a(c,b,t);p.push(S)}),i;if(o.startsWith("@")){const f=a(e,s,t),c=`${o} {
2
- ${f.replace(`
3
- `,`
4
- `)}
5
- }`;return p.push(c),i}const u=l.includes("&")?o.replace("&",s):o.startsWith(":")?`${s}${o}`:`${s} ${o}`,h=a(e,u,t);return p.push(h),i}if(n!=null&&n.templates&&n.templates[o]){const h=e.split(".").reduce((c,m)=>c[m],n.templates[o]),f=a(h,"");return`${i}${f}`}const g=o.startsWith("-")?o:V.dashCase(o),y=(u,h=";")=>i=`${i}${u}${h}`,O=u=>y(`${g}:${u}`);if(typeof e=="number")return O(e);if(typeof e!="string")if("toString"in e)e=e.toString();else return i;const{modifiers:A}=n||{},k=function*(){yield M(e),yield q(e,A)}();for(const{result:u,additionalCss:h=[]}of k)e=u,h.forEach(f=>{const c=a(f,"");y(c,"")});return O(e)},"");if(!$)return p.join(`
6
- `);if(!s)return $;let d="";return t!==void 0?d=`@layer l${t} { ${s} { ${$} } }`:d=`${s} { ${$} }`,[d,...p].join(`
7
- `)};exports.parseStyles=a;exports.toHash=W;
@@ -1,85 +0,0 @@
1
- import { d as V } from "./dash-case-CGJ_UIZz.js";
2
- const E = (r) => String.fromCharCode(r + (r > 25 ? 39 : 97)), T = (r, s) => {
3
- let t = "", n;
4
- for (n = Math.abs(r); n > 52; n = n / 52 | 0) t = E(n % 52) + t;
5
- return t = E(n % 52) + t, t.length < s ? t = t.padStart(s, "a") : t.length > s && (t = t.slice(-s)), t;
6
- }, W = (r, s) => {
7
- let t = s.length;
8
- for (; t; ) r = r * 33 ^ s.charCodeAt(--t);
9
- return r;
10
- }, x = (r, s = 3) => {
11
- const t = W(5381, JSON.stringify(r)) >>> 0;
12
- return T(t, s);
13
- }, H = (r, s) => {
14
- if (typeof r != "string") return { result: r };
15
- if (!s) return { result: r };
16
- const t = [];
17
- return Object.values(s).forEach((n) => {
18
- const { pattern: c, transform: a } = n;
19
- r = r.replace(c, (d) => {
20
- const { value: i, css: m } = a(d);
21
- return m && t.push(m), i;
22
- });
23
- }), { result: r, additionalCss: t };
24
- }, M = (r) => typeof r != "string" ? { result: r } : /\{[^{}]+\}/g.test(r) ? { result: r.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) } : { result: r }, $ = (r, s, t, n) => {
25
- if (!r) return "";
26
- const c = [], a = Object.entries(r).reduce((i, [m, e]) => {
27
- const o = m.trim();
28
- if (typeof e == "function" && (e = e()), typeof e == "object") {
29
- if (!e) return i;
30
- if (o === "variants")
31
- return Object.entries(e).forEach(([f, p]) => {
32
- p && Object.entries(p).forEach(([l, b]) => {
33
- if (!b) return;
34
- const j = `${s}.${f}-${l}`, S = $(b, j, t);
35
- c.push(S);
36
- });
37
- }), i;
38
- if (o === "defaultVariants")
39
- return i;
40
- if (o === "compoundVariants")
41
- return e.forEach((f) => {
42
- const { css: p, ...l } = f, b = Object.entries(l).reduce((S, [N, P]) => `${S}.${N}-${P}`, s), j = $(p, b, t);
43
- c.push(j);
44
- }), i;
45
- if (o.startsWith("@")) {
46
- const f = $(e, s, t), p = `${o} {
47
- ${f.replace(`
48
- `, `
49
- `)}
50
- }`;
51
- return c.push(p), i;
52
- }
53
- const u = m.includes("&") ? o.replace("&", s) : o.startsWith(":") ? `${s}${o}` : `${s} ${o}`, h = $(e, u, t);
54
- return c.push(h), i;
55
- }
56
- if (n != null && n.templates && n.templates[o]) {
57
- const h = e.split(".").reduce((p, l) => p[l], n.templates[o]), f = $(h, "");
58
- return `${i}${f}`;
59
- }
60
- const g = o.startsWith("-") ? o : V(o), y = (u, h = ";") => i = `${i}${u}${h}`, O = (u) => y(`${g}:${u}`);
61
- if (typeof e == "number") return O(e);
62
- if (typeof e != "string")
63
- if ("toString" in e) e = e.toString();
64
- else return i;
65
- const { modifiers: A } = n || {}, k = function* () {
66
- yield M(e), yield H(e, A);
67
- }();
68
- for (const { result: u, additionalCss: h = [] } of k)
69
- e = u, h.forEach((f) => {
70
- const p = $(f, "");
71
- y(p, "");
72
- });
73
- return O(e);
74
- }, "");
75
- if (!a) return c.join(`
76
- `);
77
- if (!s) return a;
78
- let d = "";
79
- return t !== void 0 ? d = `@layer l${t} { ${s} { ${a} } }` : d = `${s} { ${a} }`, [d, ...c].join(`
80
- `);
81
- };
82
- export {
83
- $ as p,
84
- x as t
85
- };