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