@salty-css/react 0.0.1-alpha.24 → 0.0.1-alpha.241

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/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./keyframes.cjs"),n=require("./media.cjs"),u=r=>`{${r}}`,a=(...r)=>r.flat().reduce((t,e)=>e!=null&&e._current?{...t,...e._current}:{...t,...e},{}),o=(...r)=>r.flat().reduce((t,e)=>({...t,...e._children}),{});exports.keyframes=c.keyframes;exports.MediaQueryFactory=n.MediaQueryFactory;exports.media=n.media;exports.mergeFactories=o;exports.mergeObjects=a;exports.token=u;
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@salty-css/core/css';
package/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { keyframes as f } from "./keyframes.js";
2
+ import { MediaQueryFactory as d, media as i } from "./media.js";
3
+ const n = (e) => `{${e}}`, o = (...e) => e.flat().reduce((t, r) => r != null && r._current ? { ...t, ...r._current } : { ...t, ...r }, {}), u = (...e) => e.flat().reduce((t, r) => ({ ...t, ...r._children }), {});
4
+ export {
5
+ d as MediaQueryFactory,
6
+ f as keyframes,
7
+ i as media,
8
+ u as mergeFactories,
9
+ o as mergeObjects,
10
+ n as token
11
+ };
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 i=require("./parse-styles-E95SeoXv.cjs"),w=async({animationName:l,params:u,appendInitialStyles:y,...t})=>{const e=l||i.toHash(t),r=async(n={})=>{const{duration:s="500ms",easing:o="ease-in-out",delay:c="0s",iterationCount:S="1",direction:p="normal",fillMode:g="forwards",playState:b="running"}={...u,...n},a=`${e} ${s} ${o} ${c} ${S} ${p} ${g} ${b}`;if(!y)return a;const m=t.from||t["0%"];if(!m)return a;const j=await i.parseAndJoinStyles(m,"");return`${a};${j}`},$=Object.entries(t).map(async([n,s])=>{if(!s)return"";const o=await i.parseAndJoinStyles(s,"");return`${typeof n=="number"?`${n}%`:n}{${o}}`}),d=(await Promise.all($)).join(""),f=`@keyframes ${e} {${d}}`;return Object.assign(r,{toString:r,isKeyframes:!0,animationName:e,css:f,keyframes:t}),r};exports.keyframes=w;
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-WRUkAmCD.js";
2
+ const h = async ({ animationName: $, params: l, appendInitialStyles: u, ...t }) => {
3
+ const r = $ || j(t), e = async (n = {}) => {
4
4
  const {
5
- duration: n = "500ms",
5
+ duration: s = "500ms",
6
6
  easing: o = "ease-in-out",
7
- delay: a = "0s",
8
- iterationCount: i = "1",
9
- direction: d = "normal",
10
- fillMode: y = "forwards",
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}}`;
7
+ delay: i = "0s",
8
+ iterationCount: d = "1",
9
+ direction: S = "normal",
10
+ fillMode: g = "forwards",
11
+ playState: w = "running"
12
+ } = { ...l, ...n }, a = `${r} ${s} ${o} ${i} ${d} ${S} ${g} ${w}`;
13
+ if (!u) return a;
14
+ const c = t.from || t["0%"];
15
+ if (!c) return a;
16
+ const b = await m(c, "");
17
+ return `${a};${b}`;
18
+ }, f = Object.entries(t).map(async ([n, s]) => {
19
+ if (!s) return "";
20
+ const o = await m(s, "");
21
+ return `${typeof n == "number" ? `${n}%` : n}{${o}}`;
22
+ }), y = (await Promise.all(f)).join(""), p = `@keyframes ${r} {${y}}`;
20
23
  return Object.assign(e, {
21
24
  toString: e,
22
25
  isKeyframes: !0,
23
- animationName: s,
26
+ animationName: r,
24
27
  css: p,
25
28
  keyframes: t
26
29
  }), e;
27
30
  };
28
31
  export {
29
- C as keyframes
32
+ h 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.24",
3
+ "version": "0.0.1-alpha.241",
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
  },
@@ -23,6 +28,10 @@
23
28
  "name": "react"
24
29
  },
25
30
  "exports": {
31
+ ".": {
32
+ "import": "./index.js",
33
+ "require": "./index.cjs"
34
+ },
26
35
  "./styled": {
27
36
  "import": "./styled.js",
28
37
  "require": "./styled.cjs"
@@ -31,6 +40,14 @@
31
40
  "import": "./styled-client.js",
32
41
  "require": "./styled-client.cjs"
33
42
  },
43
+ "./class-name": {
44
+ "import": "./class-name.js",
45
+ "require": "./class-name.cjs"
46
+ },
47
+ "./class-name-client": {
48
+ "import": "./class-name-client.js",
49
+ "require": "./class-name-client.cjs"
50
+ },
34
51
  "./keyframes": {
35
52
  "import": "./keyframes.js",
36
53
  "require": "./keyframes.cjs"
@@ -38,11 +55,19 @@
38
55
  "./media": {
39
56
  "import": "./media.js",
40
57
  "require": "./media.cjs"
58
+ },
59
+ "./config": {
60
+ "import": "./config.js",
61
+ "require": "./config.cjs"
62
+ },
63
+ "./helpers": {
64
+ "import": "./helpers.js",
65
+ "require": "./helpers.cjs"
41
66
  }
42
67
  },
43
68
  "dependencies": {
44
- "@salty-css/core": "^0.0.1-alpha.24",
69
+ "@salty-css/core": "^0.0.1-alpha.241",
45
70
  "clsx": ">=2.x",
46
- "react": ">=18.3.x"
71
+ "react": ">=19.x || >=18.3.x"
47
72
  }
48
73
  }
@@ -0,0 +1,5 @@
1
+ "use strict";const N=require("./parse-tokens-DfRKmjt1.cjs"),M=e=>s=>{if(typeof s!="string"||!e)return;let t=s;const i=[];return Object.values(e).forEach(o=>{const{pattern:S,transform:$}=o;t=t.replace(S,j=>{const{value:A,css:b}=$(j);return b&&i.push(b),A})}),{transformed:t,additionalCss:i}},H=e=>String.fromCharCode(e+(e>25?39:97)),T=(e,s)=>{let t="",i;for(i=Math.abs(e);i>52;i=i/52|0)t=H(i%52)+t;return t=H(i%52)+t,t.length<s?t=t.padStart(s,"a"):t.length>s&&(t=t.slice(-s)),t},U=(e,s)=>{let t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return e},q=(e,s=5)=>{const t=U(5381,JSON.stringify(e))>>>0;return T(t,s)},Q=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],_=(e,s,t)=>{if(Q.some(o=>typeof o=="string"?o===e:o.test(e))){const o=(t==null?void 0:t.defaultUnit)||"px";return`${s}${o}`}return`${s}`},F=["Webkit","Moz","ms","O"],I=e=>e.startsWith("-")?e:F.some(s=>e.startsWith(s))?`-${N.dashCase(e)}`:N.dashCase(e),y=async(e,s="",t,i=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,S=Object.entries(e),$=async([p,r])=>{var C;const n=p.trim(),w=I(n),l=(d,c=";")=>`${w}:${d}${c}`,P={scope:s,config:t};if(typeof r=="function")return $([p,r(P)]);if(r instanceof Promise)return $([p,await r]);if(t!=null&&t.templates&&t.templatePaths[n])try{const[d,c]=t.templatePaths[n].split(";;"),a=await import(c),f=c.includes("salty.config"),u=f?a[d].templates:a[d],h=f?u[n]:u.params[n];if(u&&typeof h=="function"){const E=await h(r),[m]=await y(E,"");return m}}catch(d){console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`,d);return}if(t!=null&&t.templates&&t.templates[n]){if(i)return;const c=r.split(".").reduce((a,f)=>a[f],t.templates[n]);if(c){const[a]=await y(c,"");return a}console.warn(`Template "${n}" with path of "${r}" was not found in config!`);return}if(typeof r=="object"){if(!r)return;if(r.isColor)return l(r.toString());if(n==="defaultVariants")return;if(n==="variants"){const a=Object.entries(r);for(const[f,u]of a){if(!u)return;const h=Object.entries(u);for(const[E,m]of h){if(!m)return;const x=`${s}.${f}-${E}`;(await y(m,x,t)).forEach(J=>o.add(J))}}return}if(n==="compoundVariants"){for(const a of r){const{css:f,...u}=a,h=Object.entries(u).reduce((m,[x,z])=>`${m}.${x}-${z}`,s);(await y(f,h,t)).forEach(m=>o.add(m))}return}if(n.startsWith("@")){const a=((C=t==null?void 0:t.mediaQueries)==null?void 0:C[n])||n,f=await W(r,s,t),u=`${a} { ${f} }`;o.add(u);return}const d=p.includes("&")?n.replace("&",s):n.startsWith(":")?`${s}${n}`:`${s} ${n}`;(await y(r,d,t)).forEach(a=>o.add(a));return}if(typeof r=="number"){const d=_(w,r,t);return l(d)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${w}`);return l(r)},j=S.map($),{modifiers:A}=t||{},b=[N.parseValueTokens(),M(A)],O=(await Promise.all(j).then(p=>Promise.all(p.map(r=>b.reduce(async(n,w)=>{const l=await n;if(!l)return l;const P=await w(l);if(!P)return l;const{transformed:C,additionalCss:d}=P;let c="";if(d)for(const a of d)c+=await W(a,"");return`${c}${C}`},Promise.resolve(r)))))).filter(p=>p!==void 0).join(`
2
+ `);if(!O.trim())return Array.from(o);const V=s?`${s} {
3
+ ${O}
4
+ }`:O;return o.has(V)?Array.from(o):[V,...o]},W=async(e,s,t,i=!1)=>(await y(e,s,t,i)).join(`
5
+ `);exports.parseAndJoinStyles=W;exports.toHash=q;
@@ -0,0 +1,145 @@
1
+ import { d as V, a as H } from "./parse-tokens-CssTiO78.js";
2
+ const J = (e) => (s) => {
3
+ if (typeof s != "string" || !e) return;
4
+ let t = s;
5
+ const i = [];
6
+ return Object.values(e).forEach((o) => {
7
+ const { pattern: j, transform: y } = o;
8
+ t = t.replace(j, (S) => {
9
+ const { value: x, css: b } = y(S);
10
+ return b && i.push(b), x;
11
+ });
12
+ }), { transformed: t, additionalCss: i };
13
+ }, z = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), Q = (e, s) => {
14
+ let t = "", i;
15
+ for (i = Math.abs(e); i > 52; i = i / 52 | 0) t = z(i % 52) + t;
16
+ return t = z(i % 52) + t, t.length < s ? t = t.padStart(s, "a") : t.length > s && (t = t.slice(-s)), t;
17
+ }, T = (e, s) => {
18
+ let t = s.length;
19
+ for (; t; ) e = e * 33 ^ s.charCodeAt(--t);
20
+ return e;
21
+ }, K = (e, s = 5) => {
22
+ const t = T(5381, JSON.stringify(e)) >>> 0;
23
+ return Q(t, s);
24
+ }, _ = [
25
+ "top",
26
+ "right",
27
+ "bottom",
28
+ "left",
29
+ "min-width",
30
+ /.*width.*/,
31
+ /^[^line]*height.*/,
32
+ // Exclude line-height
33
+ /padding.*/,
34
+ /margin.*/,
35
+ /border.*/,
36
+ /inset.*/,
37
+ /.*radius.*/,
38
+ /.*spacing.*/,
39
+ /.*gap.*/,
40
+ /.*indent.*/,
41
+ /.*offset.*/,
42
+ /.*size.*/,
43
+ /.*thickness.*/,
44
+ /.*font-size.*/
45
+ ], q = (e, s, t) => {
46
+ if (_.some((o) => typeof o == "string" ? o === e : o.test(e))) {
47
+ const o = (t == null ? void 0 : t.defaultUnit) || "px";
48
+ return `${s}${o}`;
49
+ }
50
+ return `${s}`;
51
+ }, F = ["Webkit", "Moz", "ms", "O"], I = (e) => e.startsWith("-") ? e : F.some((s) => e.startsWith(s)) ? `-${V(e)}` : V(e), $ = async (e, s = "", t, i = !1) => {
52
+ if (!e) throw new Error("No styles provided to parseStyles function!");
53
+ const o = /* @__PURE__ */ new Set(), j = Object.entries(e), y = async ([u, r]) => {
54
+ var E;
55
+ const n = u.trim(), w = I(n), l = (d, c = ";") => `${w}:${d}${c}`, P = { scope: s, config: t };
56
+ if (typeof r == "function") return y([u, r(P)]);
57
+ if (r instanceof Promise) return y([u, await r]);
58
+ if (t != null && t.templates && t.templatePaths[n])
59
+ try {
60
+ const [d, c] = t.templatePaths[n].split(";;"), a = await import(c), f = c.includes("salty.config"), p = f ? a[d].templates : a[d], h = f ? p[n] : p.params[n];
61
+ if (p && typeof h == "function") {
62
+ const C = await h(r), [m] = await $(C, "");
63
+ return m;
64
+ }
65
+ } catch (d) {
66
+ console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`, d);
67
+ return;
68
+ }
69
+ if (t != null && t.templates && t.templates[n]) {
70
+ if (i) return;
71
+ const c = r.split(".").reduce((a, f) => a[f], t.templates[n]);
72
+ if (c) {
73
+ const [a] = await $(c, "");
74
+ return a;
75
+ }
76
+ console.warn(`Template "${n}" with path of "${r}" was not found in config!`);
77
+ return;
78
+ }
79
+ if (typeof r == "object") {
80
+ if (!r) return;
81
+ if (r.isColor) return l(r.toString());
82
+ if (n === "defaultVariants") return;
83
+ if (n === "variants") {
84
+ const a = Object.entries(r);
85
+ for (const [f, p] of a) {
86
+ if (!p) return;
87
+ const h = Object.entries(p);
88
+ for (const [C, m] of h) {
89
+ if (!m) return;
90
+ const A = `${s}.${f}-${C}`;
91
+ (await $(m, A, t)).forEach((U) => o.add(U));
92
+ }
93
+ }
94
+ return;
95
+ }
96
+ if (n === "compoundVariants") {
97
+ for (const a of r) {
98
+ const { css: f, ...p } = a, h = Object.entries(p).reduce((m, [A, W]) => `${m}.${A}-${W}`, s);
99
+ (await $(f, h, t)).forEach((m) => o.add(m));
100
+ }
101
+ return;
102
+ }
103
+ if (n.startsWith("@")) {
104
+ const a = ((E = t == null ? void 0 : t.mediaQueries) == null ? void 0 : E[n]) || n, f = await M(r, s, t), p = `${a} { ${f} }`;
105
+ o.add(p);
106
+ return;
107
+ }
108
+ const d = u.includes("&") ? n.replace("&", s) : n.startsWith(":") ? `${s}${n}` : `${s} ${n}`;
109
+ (await $(r, d, t)).forEach((a) => o.add(a));
110
+ return;
111
+ }
112
+ if (typeof r == "number") {
113
+ const d = q(w, r, t);
114
+ return l(d);
115
+ }
116
+ if (typeof r != "string")
117
+ if ("toString" in r) r = r.toString();
118
+ else throw new Error(`Invalid value type for property ${w}`);
119
+ return l(r);
120
+ }, S = j.map(y), { modifiers: x } = t || {}, b = [H(), J(x)], O = (await Promise.all(S).then((u) => Promise.all(
121
+ u.map((r) => b.reduce(async (n, w) => {
122
+ const l = await n;
123
+ if (!l) return l;
124
+ const P = await w(l);
125
+ if (!P) return l;
126
+ const { transformed: E, additionalCss: d } = P;
127
+ let c = "";
128
+ if (d)
129
+ for (const a of d)
130
+ c += await M(a, "");
131
+ return `${c}${E}`;
132
+ }, Promise.resolve(r)))
133
+ ))).filter((u) => u !== void 0).join(`
134
+ `);
135
+ if (!O.trim()) return Array.from(o);
136
+ const N = s ? `${s} {
137
+ ${O}
138
+ }` : O;
139
+ return o.has(N) ? Array.from(o) : [N, ...o];
140
+ }, M = async (e, s, t, i = !1) => (await $(e, s, t, i)).join(`
141
+ `);
142
+ export {
143
+ M as p,
144
+ K as t
145
+ };
@@ -0,0 +1,9 @@
1
+ function a(e) {
2
+ return e ? typeof e != "string" ? a(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
+ const s = (e) => (r) => typeof r != "string" || !/\{[^{}]+\}/g.test(r) ? void 0 : { transformed: r.replace(/\{([^{}]+)\}/g, (...t) => `var(--${a(t[1].replaceAll(".", "-"))})`) }, f = s();
5
+ export {
6
+ s as a,
7
+ a as d,
8
+ f as p
9
+ };
@@ -0,0 +1 @@
1
+ "use strict";function n(e){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,a)=>(a>0?"-":"")+r.toLowerCase()):""}const s=e=>r=>typeof r!="string"||!/\{[^{}]+\}/g.test(r)?void 0:{transformed:r.replace(/\{([^{}]+)\}/g,(...t)=>`var(--${n(t[1].replaceAll(".","-"))})`)},o=s();exports.dashCase=n;exports.parseValueTokens=s;exports.parseVariableTokens=o;
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-DjYdX8Jd.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 { StyledGeneratorClientProps } from '@salty-css/core/generators';
2
+ import { Tag } from '@salty-css/core/types';
3
+ export declare const styledClient: (tagName: Tag<any>, className: string, generatorProps: StyledGeneratorClientProps) => 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-B1PSIJV4.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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./styles-generator-CD8r4Qz6.cjs"),h=require("./element-factory-DjYdX8Jd.cjs");class g extends m.StylesGenerator{constructor(e,t){super(t),this.tagName=e,this._params=t}get priority(){var e;return this.params.priority?this.params.priority:typeof this.tagName=="function"||typeof this.tagName=="object"?(((e=this.tagName.generator)==null?void 0:e.priority)||0)+1:0}get clientProps(){const{element:e,variants:t={},compoundVariants:s=[],defaultVariants:d={},defaultProps:l={},passProps:u}=this.params,{callerName:y,isProduction:f}=this.buildContext,o=new Set([]),i=r=>{const a=d[r];a!==void 0?o.add(`${r}=${String(a)}`):o.add(r)};Object.keys(t).forEach(i),s.map(r=>Object.keys(r).forEach(i));const c=new Set([]);if(this.params.base){const r=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);r&&r.forEach(a=>{const p=a.replace(/\{props\.([\w\d]+)\}/gi,"$1");p&&c.add(p)})}return{element:e,variantKeys:[...o],propValueKeys:[...c],passProps:u,defaultProps:l,attr:{"data-component-name":f?void 0:y}}}}const b=(n,e)=>{const t=new g(n,e),s=h.elementFactory(n,t.cssClassName,t.clientProps,{"data-unoptimized-client-component":!0});return Object.assign(s,{generator:t}),s};exports.styled=b;
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,70 +1,47 @@
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) {
9
- c(this, "_callerName");
10
- c(this, "_context");
11
- this.tagName = t, this.params = s;
12
- }
13
- get hash() {
14
- return l(this.params.base || this.params);
1
+ import { S as y } from "./styles-generator-CFUD8Yyz.js";
2
+ import { e as h } from "./element-factory-B1PSIJV4.js";
3
+ class g extends y {
4
+ constructor(e, t) {
5
+ super(t), this.tagName = e, this._params = t;
15
6
  }
16
7
  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
- }
20
- get classNames() {
21
- const t = [this.hash], { className: s } = this.params;
22
- return s && t.push(s), t.join(" ");
23
- }
24
- get cssClassName() {
25
- return this.hash;
26
- }
27
- get cssDisplayNameVar() {
28
- return `--${this.hash}-display-name: ${this._callerName};`;
8
+ var e;
9
+ return this.params.priority ? this.params.priority : typeof this.tagName == "function" || typeof this.tagName == "object" ? (((e = this.tagName.generator) == null ? void 0 : e.priority) || 0) + 1 : 0;
29
10
  }
30
- get templateKeys() {
31
- var t;
32
- return (t = this._context) != null && t.config.templates ? y(this._context.config.templates) : [];
33
- }
34
- 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);
38
- }
39
- 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]
11
+ get clientProps() {
12
+ const { element: e, variants: t = {}, compoundVariants: r = [], defaultVariants: d = {}, defaultProps: m = {}, passProps: f } = this.params, { callerName: l, isProduction: u } = this.buildContext, o = /* @__PURE__ */ new Set([]), i = (a) => {
13
+ const s = d[a];
14
+ s !== void 0 ? o.add(`${a}=${String(s)}`) : o.add(a);
15
+ };
16
+ Object.keys(t).forEach(i), r.map((a) => Object.keys(a).forEach(i));
17
+ const c = /* @__PURE__ */ new Set([]);
18
+ if (this.params.base) {
19
+ const a = JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);
20
+ a && a.forEach((s) => {
21
+ const p = s.replace(/\{props\.([\w\d]+)\}/gi, "$1");
22
+ p && c.add(p);
23
+ });
24
+ }
25
+ return {
26
+ element: e,
27
+ variantKeys: [...o],
28
+ propValueKeys: [...c],
29
+ passProps: f,
30
+ defaultProps: m,
31
+ attr: {
32
+ "data-component-name": u ? void 0 : l
33
+ }
52
34
  };
53
- }
54
- _withBuildContext(t) {
55
- this._context = t;
56
- const { name: s, config: a } = t;
57
- return this._callerName = s, this;
58
35
  }
59
36
  }
60
- const _ = (e, t) => {
61
- const s = new f(e, t), a = g(e, s.cssClassName, s.props, {
37
+ const v = (n, e) => {
38
+ const t = new g(n, e), r = h(n, t.cssClassName, t.clientProps, {
62
39
  "data-unoptimized-client-component": !0
63
40
  });
64
- return Object.assign(a, {
65
- generator: s
66
- }), a;
41
+ return Object.assign(r, {
42
+ generator: t
43
+ }), r;
67
44
  };
68
45
  export {
69
- _ as styled
46
+ v as styled
70
47
  };
@@ -0,0 +1 @@
1
+ "use strict";var c=Object.defineProperty;var l=(a,s,t)=>s in a?c(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var h=(a,s,t)=>l(a,typeof s!="symbol"?s+"":s,t);const n=require("./parse-styles-E95SeoXv.cjs"),o=require("./parse-tokens-DfRKmjt1.cjs");class u{constructor(s){h(this,"buildContext",{});this.params=s}get priority(){return 0}get isRoot(){return this.priority===0}get hash(){return n.toHash(this.params.base||this.params)}get cssClassName(){return this.hash}get classNames(){const s=new Set([this.cssClassName]),{className:t}=this.params;return typeof t=="string"&&s.add(t),typeof t=="object"&&t.forEach(e=>s.add(e)),this.getTemplateClasses().forEach(e=>s.add(e)),this.buildContext.classNames&&this.buildContext.classNames.forEach(e=>s.add(e)),[...s].join(" ")}get cssFileName(){const{callerName:s}=this.buildContext;return s?`cl_${o.dashCase(s)}-${this.hash}.css`:`${this.hash}.css`}get css(){const{base:s={},variants:t={},compoundVariants:e=[]}=this.params,{config:r}=this.buildContext,i={...s,variants:t,compoundVariants:e};return n.parseAndJoinStyles(i,`.${this.cssClassName}`,r,this.isRoot)}getTemplateClasses(s=this.buildContext.config){if(!(s!=null&&s.templates)||!this.params.base||this.priority>0)return[];const t=Object.keys(s.templates);return Object.entries(this.params.base).reduce((e,[r,i])=>(t.includes(r)&&e.push("t_"+n.toHash(o.dashCase(`${r}-${i}`),4)),e),[])}_withBuildContext(s){return this.buildContext=s,this}}exports.StylesGenerator=u;