@salty-css/react 0.0.1-alpha.9 → 0.0.1-alpha.91

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,90 @@
1
- # Salty Css
1
+ # Salty CSS - Kinda sweet but yet spicy CSS-in-JS library
2
2
 
3
- ## Basic usage example with Button
3
+ In the world of frontend dev is there anything saltier than CSS? Salty CSS is built to provide better developer experience for developers looking for performant and feature rich CSS-in-JS solutions.
4
4
 
5
- ### Initial requirements
5
+ ## Features
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
+ - Build time compilation to achieve awesome runtime performance and minimal size
8
+ - Next.js, React Server Components, Vite and Webpack support
9
+ - Type safety with out of the box TypeScript and ESLint plugin
10
+ - Advanced CSS variables configuration to allow smooth token usage
11
+ - Style templates to create reusable styles easily
11
12
 
12
- ### Code examples
13
+ ## Get started
14
+
15
+ - Initialize: `npx salty-css init [directory]`
16
+ - Create component: `npx salty-css generate [filePath]`
17
+ - Build: `npx salty-css build [directory]`
18
+
19
+ ### Packages
20
+
21
+ Note: Fastest way to get started with any framework is [npx salty-css init [directory]](#initialize-salty-css-for-a-project) command
22
+
23
+ - [Next.js](#nextjs) → `npm install @salty-css/next` + [Next.js install guide](#nextjs) + [Next.js example app](https://github.com/margarita-form/salty-css-website)
24
+ - [React](#react) → `npm install @salty-css/react` + [React install guide](#react) + [React example code](#code-examples)
25
+ - [Vite](#vite) → `npm install @salty-css/vite` + [(Vite install guide)](#vite)
26
+ - [Webpack](https://www.npmjs.com/package/@salty-css/webpack) → `npm install @salty-css/webpack` + Guide coming soon
27
+ - [ESLint](https://www.npmjs.com/package/@salty-css/eslint-plugin-core) → `npm install @salty-css/eslint-plugin-core` + Guide coming soon
28
+ - [Core](https://www.npmjs.com/package/@salty-css/react) → `npm install @salty-css/core` (This package contains code for internal use)
29
+
30
+ ### Add Salty CSS to your project with `salty-css` CLI
31
+
32
+ #### Initialize Salty CSS for a project
33
+
34
+ In your existing repository run `npx salty-css init [directory]` which installs required salty-css packages to the current directory, detects framework in use (current support for vite and next.js) and creates project files to the provided directory. Directory can be left blank if you want files to be created to the current directory. Init will also create `.saltyrc.json` which contains some metadata for future CLI commands.
35
+
36
+ #### Create components
37
+
38
+ Components can be created with `npx salty-css generate [filePath]` which then creates a new Salty CSS component file to the specified path. Additional options like `--dir, --tag, --name and --className` are also supported. Read more about them with `npx salty-css generate --help`
39
+
40
+ #### Build / Compile Salty CSS
41
+
42
+ If you want to manually build your project that can be done by running `npx salty-css build [directory]`. Directory is not required as CLI can use default directory defined in `.saltyrc.json`. Note that build generates css files but Vite / Webpack plugin is still required for full support.
43
+
44
+ #### Update Salty CSS packages
45
+
46
+ To ease the pain of package updates all Salty CSS packages can be updated with `npx salty-css update`
47
+
48
+ ### Manual work
49
+
50
+ #### Next.js
51
+
52
+ 1. For Next.js support install `npm i @salty-css/next @salty-css/core @salty-css/react`
53
+ 2. Create `salty.config.ts` to your app directory
54
+ 3. Add Salty CSS plugin to next.js config
55
+
56
+ - **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);`
57
+ - **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);`
58
+
59
+ 4. Make sure that `salty.config.ts` and `next.config.ts` are in the same folder!
60
+ 5. Build `saltygen` directory by running your app once or with cli `npx salty-css build [directory]`
61
+ 6. Import global styles from `saltygen/index.css` to some global css file with `@import 'insert_path_to_index_css';`.
62
+
63
+ [Check out Next.js demo project](https://github.com/margarita-form/salty-css-website) or [react example code](#code-examples)
64
+
65
+ #### React
66
+
67
+ 1. Install related dependencies: `npm i @salty-css/core @salty-css/react`
68
+ 2. Create `salty.config.ts` to your app directory
69
+ 3. Configure your build tool to support Salty CSS ([Vite](#vite) or Webpack)
70
+
71
+ [Check out react example code](#code-examples)
72
+
73
+ #### Vite
74
+
75
+ 1. For Vite support install `npm i @salty-css/vite @salty-css/core`
76
+ 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
77
+ 3. Make sure that `salty.config.ts` and `vite.config.ts` are in the same folder!
78
+ 4. Build `saltygen` directory by running your app once or with cli `npx salty-css build [directory]`
79
+ 5. Import global styles from `saltygen/index.css` to some global css file with `@import 'insert_path_to_index_css';`.
80
+
81
+ ### Create components
82
+
83
+ 1. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
84
+
85
+ ## Code examples
86
+
87
+ ### Basic usage example with Button
13
88
 
14
89
  **Salty config**
15
90
 
@@ -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,(n,t)=>(t>0?"-":"")+n.toLowerCase()):""}exports.dashCase=r;
@@ -0,0 +1,6 @@
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
+ };
@@ -0,0 +1 @@
1
+ "use strict";const K=require("react"),O=require("./dash-case-B_odFlTl.cjs");function $(s){var i,e,t="";if(typeof s=="string"||typeof s=="number")t+=s;else if(typeof s=="object")if(Array.isArray(s)){var o=s.length;for(i=0;i<o;i++)s[i]&&(e=$(s[i]))&&(t&&(t+=" "),t+=e)}else for(e in s)s[e]&&(t&&(t+=" "),t+=e);return t}function V(){for(var s,i,e=0,t="",o=arguments.length;e<o;e++)(s=arguments[e])&&(i=$(s))&&(t&&(t+=" "),t+=i);return t}const p=["passVariantProps"],N=(s,i,e,t)=>{const o=({extend:r=s,element:b=e.element,className:v="",children:w,passVariantProps:j,_vks:f=new Set,...l},E)=>{const n={passVariantProps:j};e.attr&&Object.assign(n,e.attr),t&&Object.assign(n,t),l&&Object.assign(n,l);const u=new Set(v.split(" ")),y=typeof r=="function"||typeof r=="object",m=y&&"isStyled"in r,S=y?r:b||r;if(!S)throw new Error("No element provided");e.propValueKeys&&(n.style||(n.style={}),e.propValueKeys.forEach(a=>{const c=`css-${a}`,d=l[c];if(d===void 0)return;const C=`--props-${O.dashCase(a)}`;n.style[C]=d,f&&f.add(c)})),e.variantKeys&&e.variantKeys.forEach(a=>{const[c,d]=a.split("=");l[c]!==void 0?(u.add(`${c}-${l[c]}`),f&&f.add(c)):d!==void 0&&u.add(`${c}-${d}`)}),f&&(!y||!m&&!j)?f.forEach(a=>delete n[a]):m&&Object.assign(n,{_vks:f}),m||p.forEach(a=>delete n[a]);const g=V(i,...u);return K.createElement(S,{element:y?b:void 0,className:g,ref:E,...n},w)},h=K.forwardRef(o);return Object.assign(h,{isStyled:!0,className:i,toString:()=>`.${i}`}),h};exports.elementFactory=N;
@@ -0,0 +1,59 @@
1
+ import { forwardRef as g, createElement as O } from "react";
2
+ import { d as V } from "./dash-case-CGJ_UIZz.js";
3
+ function K(s) {
4
+ var i, t, e = "";
5
+ if (typeof s == "string" || typeof s == "number") e += s;
6
+ else if (typeof s == "object") if (Array.isArray(s)) {
7
+ var d = s.length;
8
+ for (i = 0; i < d; i++) s[i] && (t = K(s[i])) && (e && (e += " "), e += t);
9
+ } else for (t in s) s[t] && (e && (e += " "), e += t);
10
+ return e;
11
+ }
12
+ function C() {
13
+ for (var s, i, t = 0, e = "", d = arguments.length; t < d; t++) (s = arguments[t]) && (i = K(s)) && (e && (e += " "), e += i);
14
+ return e;
15
+ }
16
+ const N = ["passVariantProps"], q = (s, i, t, e) => {
17
+ const b = g(({
18
+ extend: c = s,
19
+ element: h = t.element,
20
+ className: $ = "",
21
+ children: p,
22
+ passVariantProps: j,
23
+ _vks: o = /* @__PURE__ */ new Set(),
24
+ ...l
25
+ }, v) => {
26
+ const n = { passVariantProps: j };
27
+ t.attr && Object.assign(n, t.attr), e && Object.assign(n, e), l && Object.assign(n, l);
28
+ const u = new Set($.split(" ")), y = typeof c == "function" || typeof c == "object", m = y && "isStyled" in c, S = y ? c : h || c;
29
+ if (!S) throw new Error("No element provided");
30
+ t.propValueKeys && (n.style || (n.style = {}), t.propValueKeys.forEach((a) => {
31
+ const f = `css-${a}`, r = l[f];
32
+ if (r === void 0) return;
33
+ const E = `--props-${V(a)}`;
34
+ n.style[E] = r, o && o.add(f);
35
+ })), t.variantKeys && t.variantKeys.forEach((a) => {
36
+ const [f, r] = a.split("=");
37
+ l[f] !== void 0 ? (u.add(`${f}-${l[f]}`), o && o.add(f)) : r !== void 0 && u.add(`${f}-${r}`);
38
+ }), o && (!y || !m && !j) ? o.forEach((a) => delete n[a]) : m && Object.assign(n, { _vks: o }), m || N.forEach((a) => delete n[a]);
39
+ const w = C(i, ...u);
40
+ return O(
41
+ S,
42
+ {
43
+ element: y ? h : void 0,
44
+ className: w,
45
+ ref: v,
46
+ ...n
47
+ },
48
+ p
49
+ );
50
+ });
51
+ return Object.assign(b, {
52
+ isStyled: !0,
53
+ className: i,
54
+ toString: () => `.${i}`
55
+ }), b;
56
+ };
57
+ export {
58
+ q as e
59
+ };
@@ -1,2 +1,3 @@
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>) => import('react').ForwardRefExoticComponent<Omit<StyledComponentProps, "ref"> & import('react').RefAttributes<any>>;
1
+ import { GeneratorProps } from '@salty-css/core/generator';
2
+ import { StyledComponentProps, Tag } from '@salty-css/core/types';
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-PkK9Yzyn.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-DbNZJMT5.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,7 +1,7 @@
1
- import { CssStyles, StyleValue } from '../../core/src/types';
1
+ import { CssStyles, StyleValue } from '@salty-css/core/types';
2
2
  type KeyframeKeys = number | 'from' | 'to' | `${number}%`;
3
3
  type Keyframes = {
4
- [key in KeyframeKeys]: CssStyles;
4
+ [key in KeyframeKeys]?: CssStyles;
5
5
  };
6
6
  interface KeyframesConfig {
7
7
  animationName?: string;
package/keyframes.js CHANGED
@@ -1,30 +1,33 @@
1
- import { t as b, p as c } from "./parse-styles-BRv2UFN0.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-DLe1Dr-N.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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class n{constructor(e="@media"){this.base=e,this.next=t=>{const s=new String(t);return Object.assign(s,{get and(){return new n(`${t} and`)},get or(){return new n(`${t},`)}}),s}}custom(e){return this.next(`${this.base} ${e}`)}minWidth(e){const t=typeof e=="number"?`${e}px`:e,s=`${this.base} (min-width: ${t})`;return this.next(s)}maxWidth(e){const t=typeof e=="number"?`${e}px`:e,s=`${this.base} (max-width: ${t})`;return this.next(s)}minHeight(e){const t=typeof e=="number"?`${e}px`:e,s=`${this.base} (min-height: ${t})`;return this.next(s)}maxHeight(e){const t=typeof e=="number"?`${e}px`:e,s=`${this.base} (max-height: ${t})`;return this.next(s)}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 r=new n;exports.MediaQueryFactory=n;exports.media=r;
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;
package/media.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { OrNumber, OrString } from '../../core/src/types/util-types';
1
+ import { OrNumber, OrString } from '@salty-css/core/types/util-types';
2
2
  export declare class MediaQueryFactory {
3
3
  private base;
4
4
  constructor(base?: string);
package/media.js CHANGED
@@ -1,35 +1,39 @@
1
- class n {
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);
4
+ class r {
2
5
  constructor(t = "@media") {
3
- this.base = t, this.next = (e) => {
4
- const s = new String(e);
5
- return Object.assign(s, {
6
+ i(this, "next", (t) => {
7
+ const e = new String(t);
8
+ return Object.assign(e, {
6
9
  get and() {
7
- return new n(`${e} and`);
10
+ return new r(`${t} and`);
8
11
  },
9
12
  get or() {
10
- return new n(`${e},`);
13
+ return new r(`${t},`);
11
14
  }
12
- }), s;
13
- };
15
+ }), e;
16
+ });
17
+ this.base = t;
14
18
  }
15
19
  custom(t) {
16
20
  return this.next(`${this.base} ${t}`);
17
21
  }
18
22
  minWidth(t) {
19
- const e = typeof t == "number" ? `${t}px` : t, s = `${this.base} (min-width: ${e})`;
20
- return this.next(s);
23
+ const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (min-width: ${e})`;
24
+ return this.next(n);
21
25
  }
22
26
  maxWidth(t) {
23
- const e = typeof t == "number" ? `${t}px` : t, s = `${this.base} (max-width: ${e})`;
24
- return this.next(s);
27
+ const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (max-width: ${e})`;
28
+ return this.next(n);
25
29
  }
26
30
  minHeight(t) {
27
- const e = typeof t == "number" ? `${t}px` : t, s = `${this.base} (min-height: ${e})`;
28
- return this.next(s);
31
+ const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (min-height: ${e})`;
32
+ return this.next(n);
29
33
  }
30
34
  maxHeight(t) {
31
- const e = typeof t == "number" ? `${t}px` : t, s = `${this.base} (max-height: ${e})`;
32
- return this.next(s);
35
+ const e = typeof t == "number" ? `${t}px` : t, n = `${this.base} (max-height: ${e})`;
36
+ return this.next(n);
33
37
  }
34
38
  get portrait() {
35
39
  const t = `${this.base} (orientation: portrait)`;
@@ -74,8 +78,8 @@ class n {
74
78
  return this.next(t);
75
79
  }
76
80
  }
77
- const r = new n();
81
+ const u = new r();
78
82
  export {
79
- n as MediaQueryFactory,
80
- r as media
83
+ r as MediaQueryFactory,
84
+ u as media
81
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/react",
3
- "version": "0.0.1-alpha.9",
3
+ "version": "0.0.1-alpha.91",
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
  },
@@ -19,6 +24,7 @@
19
24
  "!**/*.tsbuildinfo"
20
25
  ],
21
26
  "nx": {
27
+ "sourceRoot": "libs/react/src",
22
28
  "name": "react"
23
29
  },
24
30
  "exports": {
@@ -38,5 +44,10 @@
38
44
  "import": "./media.js",
39
45
  "require": "./media.cjs"
40
46
  }
47
+ },
48
+ "dependencies": {
49
+ "@salty-css/core": "^0.0.1-alpha.91",
50
+ "clsx": ">=2.x",
51
+ "react": ">=19.x || >=18.3.x"
41
52
  }
42
53
  }
@@ -0,0 +1,89 @@
1
+ import { d as E } from "./dash-case-CGJ_UIZz.js";
2
+ const g = (r) => String.fromCharCode(r + (r > 25 ? 39 : 97)), N = (r, s) => {
3
+ let t = "", n;
4
+ for (n = Math.abs(r); n > 52; n = n / 52 | 0) t = g(n % 52) + t;
5
+ return t = g(n % 52) + t, t.length < s ? t = t.padStart(s, "a") : t.length > s && (t = t.slice(-s)), t;
6
+ }, P = (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 = P(5381, JSON.stringify(r)) >>> 0;
12
+ return N(t, s);
13
+ }, W = (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
+ }, H = (r) => typeof r != "string" ? { result: r } : /\{[^{}]+\}/g.test(r) ? { result: r.replace(/\{([^{}]+)\}/g, (...n) => `var(--${E(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(([p, f]) => {
32
+ f && Object.entries(f).forEach(([b, l]) => {
33
+ if (!l) return;
34
+ const j = `${s}.${p}-${b}`, S = $(l, j, t);
35
+ c.push(S);
36
+ });
37
+ }), i;
38
+ if (o === "defaultVariants")
39
+ return i;
40
+ if (o === "compoundVariants")
41
+ return e.forEach((p) => {
42
+ const { css: f, ...b } = p, l = Object.entries(b).reduce((S, [T, k]) => `${S}.${T}-${k}`, s), j = $(f, l, t);
43
+ c.push(j);
44
+ }), i;
45
+ if (o.startsWith("@")) {
46
+ const p = $(e, s, t), f = `${o} {
47
+ ${p.replace(`
48
+ `, `
49
+ `)}
50
+ }`;
51
+ return c.push(f), 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, f) => p[f], n.templates[o]);
58
+ if (h) {
59
+ const p = $(h, "");
60
+ return `${i}${p}`;
61
+ }
62
+ return console.warn(`Template "${o}" with path of "${e}" was not found in config!`), i;
63
+ }
64
+ const V = o.startsWith("-") ? o : E(o), y = (u, h = ";") => i = `${i}${u}${h}`, O = (u) => y(`${V}:${u}`);
65
+ if (typeof e == "number") return O(e);
66
+ if (typeof e != "string")
67
+ if ("toString" in e) e = e.toString();
68
+ else return i;
69
+ const { modifiers: w } = n || {}, A = function* () {
70
+ yield H(e), yield W(e, w);
71
+ }();
72
+ for (const { result: u, additionalCss: h = [] } of A)
73
+ e = u, h.forEach((p) => {
74
+ const f = $(p, "");
75
+ y(f, "");
76
+ });
77
+ return O(e);
78
+ }, "");
79
+ if (!a) return c.join(`
80
+ `);
81
+ if (!s) return a;
82
+ let d = "";
83
+ return t !== void 0 ? d = `@layer l${t} { ${s} { ${a} } }` : d = `${s} { ${a} }`, [d, ...c].join(`
84
+ `);
85
+ };
86
+ export {
87
+ $ as p,
88
+ x as t
89
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";const E=require("./dash-case-B_odFlTl.cjs"),g=r=>String.fromCharCode(r+(r>25?39:97)),H=(r,s)=>{let t="",n;for(n=Math.abs(r);n>52;n=n/52|0)t=g(n%52)+t;return t=g(n%52)+t,t.length<s?t=t.padStart(s,"a"):t.length>s&&(t=t.slice(-s)),t},N=(r,s)=>{let t=s.length;for(;t;)r=r*33^s.charCodeAt(--t);return r},P=(r,s=3)=>{const t=N(5381,JSON.stringify(r))>>>0;return H(t,s)},W=(r,s)=>{if(typeof r!="string")return{result:r};if(!s)return{result:r};const t=[];return Object.values(s).forEach(n=>{const{pattern:c,transform:$}=n;r=r.replace(c,d=>{const{value:i,css:l}=$(d);return l&&t.push(l),i})}),{result:r,additionalCss:t}},q=r=>typeof r!="string"?{result:r}:/\{[^{}]+\}/g.test(r)?{result:r.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${E.dashCase(n[1].replaceAll(".","-"))})`)}:{result:r},a=(r,s,t,n)=>{if(!r)return"";const c=[],$=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(([p,f])=>{f&&Object.entries(f).forEach(([b,m])=>{if(!m)return;const S=`${s}.${p}-${b}`,j=a(m,S,t);c.push(j)})}),i;if(o==="defaultVariants")return i;if(o==="compoundVariants")return e.forEach(p=>{const{css:f,...b}=p,m=Object.entries(b).reduce((j,[T,k])=>`${j}.${T}-${k}`,s),S=a(f,m,t);c.push(S)}),i;if(o.startsWith("@")){const p=a(e,s,t),f=`${o} {
2
+ ${p.replace(`
3
+ `,`
4
+ `)}
5
+ }`;return c.push(f),i}const u=l.includes("&")?o.replace("&",s):o.startsWith(":")?`${s}${o}`:`${s} ${o}`,h=a(e,u,t);return c.push(h),i}if(n!=null&&n.templates&&n.templates[o]){const h=e.split(".").reduce((p,f)=>p[f],n.templates[o]);if(h){const p=a(h,"");return`${i}${p}`}return console.warn(`Template "${o}" with path of "${e}" was not found in config!`),i}const V=o.startsWith("-")?o:E.dashCase(o),y=(u,h=";")=>i=`${i}${u}${h}`,O=u=>y(`${V}:${u}`);if(typeof e=="number")return O(e);if(typeof e!="string")if("toString"in e)e=e.toString();else return i;const{modifiers:w}=n||{},A=function*(){yield q(e),yield W(e,w)}();for(const{result:u,additionalCss:h=[]}of A)e=u,h.forEach(p=>{const f=a(p,"");y(f,"")});return O(e)},"");if(!$)return c.join(`
6
+ `);if(!s)return $;let d="";return t!==void 0?d=`@layer l${t} { ${s} { ${$} } }`:d=`${s} { ${$} }`,[d,...c].join(`
7
+ `)};exports.parseStyles=a;exports.toHash=P;
package/styled-client.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./element-factory-JxDKzaxU.cjs"),n=(e,t,r)=>l.elementFactory(e,t,r);exports.styledClient=n;
@@ -1,2 +1,3 @@
1
- import { Tag } from '../../core/src/types';
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>>;
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 a } from "./element-factory-DjCaPhwl.js";
2
- const c = (e, t, n, o, r) => a(e, t, o, r, {
3
- "data-component-name": n
4
- });
1
+ import { e as o } from "./element-factory-U2CFtpB_.js";
2
+ const l = (e, t, r) => o(e, t, r);
5
3
  export {
6
- c as styledClient
4
+ l as styledClient
7
5
  };
package/styled.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";var m=Object.defineProperty;var l=(e,t,s)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var o=(e,t,s)=>l(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./parse-styles-DbNZJMT5.cjs"),u=require("./element-factory-JxDKzaxU.cjs"),y=e=>Object.keys(e);class g{constructor(t,s){o(this,"_isProd");o(this,"_callerName");o(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,i={...t,variants:s,compoundVariants:a};return h.parseStyles(i,`.${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 n;const c=(n=this.params.defaultVariants)==null?void 0:n[r];return c!==void 0?`${r}=${String(c)}`:r}):void 0,a=new Set([]),i=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return i&&i.forEach((r,c,n)=>{const p=n.at(1);p&&a.add(p)}),{element:t,variantKeys:s,propValueKeys:[...a],attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:s,config:a,prod:i}=t;return this._isProd=i,this._callerName=s,this}}const d=(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=d;
package/styled.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AllHTMLAttributes, ReactDOM, ReactNode } from 'react';
2
- import { Tag, StyledComponentProps, CreateElementProps, VariantProps, ParentComponentProps, StyledParams } from '../../core/src/types';
2
+ import { Tag, StyledComponentProps, CreateElementProps, VariantProps, ParentComponentProps, StyledParams, ValueProps } from '@salty-css/core/types';
3
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
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;
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;
package/styled.js CHANGED
@@ -1,12 +1,18 @@
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 {
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 o = (e, t, s) => h(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { t as l, p as u } from "./parse-styles-DLe1Dr-N.js";
5
+ import { e as g } from "./element-factory-U2CFtpB_.js";
6
+ const y = (e) => Object.keys(e);
7
+ class d {
5
8
  constructor(t, s) {
9
+ o(this, "_isProd");
10
+ o(this, "_callerName");
11
+ o(this, "_context");
6
12
  this.tagName = t, this.params = s;
7
13
  }
8
14
  get hash() {
9
- return i(this.params.base || this.params);
15
+ return l(this.params.base || this.params);
10
16
  }
11
17
  get priority() {
12
18
  var t;
@@ -24,38 +30,45 @@ class m {
24
30
  }
25
31
  get templateKeys() {
26
32
  var t;
27
- return (t = this._context) != null && t.config.templates ? p(this._context.config.templates) : [];
33
+ return (t = this._context) != null && t.config.templates ? y(this._context.config.templates) : [];
28
34
  }
29
35
  get css() {
30
36
  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);
37
+ const { base: t = {}, variants: s = {}, compoundVariants: a = [] } = this.params, i = { ...t, variants: s, compoundVariants: a };
38
+ return u(i, `.${this.cssClassName}`, this.priority, (r = this._context) == null ? void 0 : r.config);
33
39
  }
34
40
  get props() {
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];
38
- return n !== void 0 ? `${e}=${String(n)}` : e;
39
- }) : void 0;
40
- return {
41
+ const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((r) => {
42
+ var n;
43
+ const c = (n = this.params.defaultVariants) == null ? void 0 : n[r];
44
+ return c !== void 0 ? `${r}=${String(c)}` : r;
45
+ }) : void 0, a = /* @__PURE__ */ new Set([]), i = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
46
+ return i && i.forEach((r, c, n) => {
47
+ const p = n.at(1);
48
+ p && a.add(p);
49
+ }), {
41
50
  element: t,
42
- variantKeys: s
51
+ variantKeys: s,
52
+ propValueKeys: [...a],
53
+ attr: {
54
+ "data-component-name": this._isProd ? void 0 : this._callerName
55
+ }
43
56
  };
44
57
  }
45
58
  _withBuildContext(t) {
46
59
  this._context = t;
47
- const { name: s, config: e } = t;
48
- return this._callerName = s, this;
60
+ const { name: s, config: a, prod: i } = t;
61
+ return this._isProd = i, this._callerName = s, this;
49
62
  }
50
63
  }
51
- const u = (a, t) => {
52
- const s = new m(a, t), e = c(a, s.cssClassName, s.props.element, s.props.variantKeys, {
64
+ const v = (e, t) => {
65
+ const s = new d(e, t), a = g(e, s.cssClassName, s.props, {
53
66
  "data-unoptimized-client-component": !0
54
67
  });
55
- return Object.assign(e, {
68
+ return Object.assign(a, {
56
69
  generator: s
57
- }), e;
70
+ }), a;
58
71
  };
59
72
  export {
60
- u as styled
73
+ v as styled
61
74
  };
@@ -1 +0,0 @@
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;
@@ -1,45 +0,0 @@
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
- };
@@ -1,87 +0,0 @@
1
- const j = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), P = (t, e) => {
2
- let r = "", n;
3
- for (n = Math.abs(t); n > 52; n = n / 52 | 0) r = j(n % 52) + r;
4
- return r = j(n % 52) + r, r.length < e ? r = r.padStart(e, "a") : r.length > e && (r = r.slice(-e)), r;
5
- }, T = (t, e) => {
6
- let r = e.length;
7
- for (; r; ) t = t * 33 ^ e.charCodeAt(--r);
8
- return t;
9
- }, M = (t, e = 3) => {
10
- const r = T(5381, JSON.stringify(t)) >>> 0;
11
- return P(r, e);
12
- };
13
- function O(t) {
14
- return t ? typeof t != "string" ? String(t) : t.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, r) => (r > 0 ? "-" : "") + e.toLowerCase()) : "";
15
- }
16
- const W = (t, e) => {
17
- if (typeof t != "string") return { result: t };
18
- if (!e) return { result: t };
19
- const r = [];
20
- return Object.values(e).forEach((n) => {
21
- const { pattern: c, transform: h } = n;
22
- t = t.replace(c, (d) => {
23
- const { value: i, css: l } = h(d);
24
- return l && r.push(l), i;
25
- });
26
- }), { result: t, additionalCss: r };
27
- }, w = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${O(n[1].replaceAll(".", "-"))})`) } : { result: t }, $ = (t, e, r, n) => {
28
- const c = [], h = Object.entries(t).reduce((i, [l, s]) => {
29
- const o = l.trim();
30
- if (typeof s == "function" && (s = s()), typeof s == "object") {
31
- if (!s) return i;
32
- if (o === "variants")
33
- return Object.entries(s).forEach(([f, p]) => {
34
- p && Object.entries(p).forEach(([m, b]) => {
35
- if (!b) return;
36
- const y = `${e}.${f}-${m}`, A = $(b, y, r);
37
- c.push(A);
38
- });
39
- }), i;
40
- if (o === "defaultVariants")
41
- return i;
42
- if (o === "compoundVariants")
43
- return s.forEach((f) => {
44
- const { css: p, ...m } = f, b = Object.entries(m).reduce((A, [k, N]) => `${A}.${k}-${N}`, e), y = $(p, b, r);
45
- c.push(y);
46
- }), i;
47
- if (o.startsWith("@")) {
48
- const f = $(s, e, r), p = `${o} {
49
- ${f.replace(`
50
- `, `
51
- `)}
52
- }`;
53
- return c.push(p), i;
54
- }
55
- const u = l.includes("&") ? o.replace("&", e) : o.startsWith(":") ? `${e}${o}` : `${e} ${o}`, a = $(s, u, r);
56
- return c.push(a), i;
57
- }
58
- if (n != null && n.templates && n.templates[o]) {
59
- const a = s.split(".").reduce((p, m) => p[m], n.templates[o]), f = $(a, "");
60
- return `${i}${f}`;
61
- }
62
- const E = o.startsWith("-") ? o : O(o), S = (u, a = ";") => i = `${i}${u}${a}`, g = (u) => S(`${E}:${u}`);
63
- if (typeof s == "number") return g(s);
64
- if (typeof s != "string")
65
- if ("toString" in s) s = s.toString();
66
- else return i;
67
- const { modifiers: V } = n || {}, Z = function* () {
68
- yield w(s), yield W(s, V);
69
- }();
70
- for (const { result: u, additionalCss: a = [] } of Z)
71
- s = u, a.forEach((f) => {
72
- const p = $(f, "");
73
- S(p, "");
74
- });
75
- return g(s);
76
- }, "");
77
- if (!h) return c.join(`
78
- `);
79
- if (!e) return h;
80
- let d = "";
81
- return r !== void 0 ? d = `@layer l${r} { ${e} { ${h} } }` : d = `${e} { ${h} }`, [d, ...c].join(`
82
- `);
83
- };
84
- export {
85
- $ as p,
86
- M as t
87
- };
@@ -1,7 +0,0 @@
1
- "use strict";const j=t=>String.fromCharCode(t+(t>25?39:97)),N=(t,e)=>{let r="",n;for(n=Math.abs(t);n>52;n=n/52|0)r=j(n%52)+r;return r=j(n%52)+r,r.length<e?r=r.padStart(e,"a"):r.length>e&&(r=r.slice(-e)),r},P=(t,e)=>{let r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return t},T=(t,e=3)=>{const r=P(5381,JSON.stringify(t))>>>0;return N(r,e)};function O(t){return t?typeof t!="string"?String(t):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,r)=>(r>0?"-":"")+e.toLowerCase()):""}const W=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const r=[];return Object.values(e).forEach(n=>{const{pattern:c,transform:$}=n;t=t.replace(c,d=>{const{value:i,css:l}=$(d);return l&&r.push(l),i})}),{result:t,additionalCss:r}},w=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${O(n[1].replaceAll(".","-"))})`)}:{result:t},a=(t,e,r,n)=>{const c=[],$=Object.entries(t).reduce((i,[l,s])=>{const o=l.trim();if(typeof s=="function"&&(s=s()),typeof s=="object"){if(!s)return i;if(o==="variants")return Object.entries(s).forEach(([f,p])=>{p&&Object.entries(p).forEach(([m,b])=>{if(!b)return;const y=`${e}.${f}-${m}`,S=a(b,y,r);c.push(S)})}),i;if(o==="defaultVariants")return i;if(o==="compoundVariants")return s.forEach(f=>{const{css:p,...m}=f,b=Object.entries(m).reduce((S,[k,H])=>`${S}.${k}-${H}`,e),y=a(p,b,r);c.push(y)}),i;if(o.startsWith("@")){const f=a(s,e,r),p=`${o} {
2
- ${f.replace(`
3
- `,`
4
- `)}
5
- }`;return c.push(p),i}const u=l.includes("&")?o.replace("&",e):o.startsWith(":")?`${e}${o}`:`${e} ${o}`,h=a(s,u,r);return c.push(h),i}if(n!=null&&n.templates&&n.templates[o]){const h=s.split(".").reduce((p,m)=>p[m],n.templates[o]),f=a(h,"");return`${i}${f}`}const E=o.startsWith("-")?o:O(o),A=(u,h=";")=>i=`${i}${u}${h}`,g=u=>A(`${E}:${u}`);if(typeof s=="number")return g(s);if(typeof s!="string")if("toString"in s)s=s.toString();else return i;const{modifiers:V}=n||{},Z=function*(){yield w(s),yield W(s,V)}();for(const{result:u,additionalCss:h=[]}of Z)s=u,h.forEach(f=>{const p=a(f,"");A(p,"")});return g(s)},"");if(!$)return c.join(`
6
- `);if(!e)return $;let d="";return r!==void 0?d=`@layer l${r} { ${e} { ${$} } }`:d=`${e} { ${$} }`,[d,...c].join(`
7
- `)};exports.parseStyles=a;exports.toHash=T;