@gradient-ui/gradient-engine 0.5.0 → 0.6.0
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 +22 -2
- package/dist/animation.cjs +1 -1
- package/dist/animation.mjs +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +12 -9
- package/dist/{css-YuAJQW13.cjs → css-BVHXLMRl.cjs} +1 -1
- package/dist/{css-CaOuUhfh.js → css-DVaTTIqS.js} +1 -1
- package/dist/design-tokens.cjs +1 -0
- package/dist/design-tokens.mjs +8 -0
- package/dist/designTokens-BnzZfRES.js +116 -0
- package/dist/designTokens-C1WdzS3v.cjs +1 -0
- package/dist/effects.cjs +137 -32
- package/dist/effects.mjs +221 -104
- package/dist/formatters.cjs +1 -1
- package/dist/formatters.mjs +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +61 -41
- package/dist/material.cjs +9 -1
- package/dist/material.mjs +236 -4
- package/dist/presets-BBLdqUE4.cjs +316 -0
- package/dist/presets-DYXLx_nN.js +4025 -0
- package/dist/{svg-BVcl24Cf.cjs → svg-dGtLYnIJ.cjs} +1 -1
- package/dist/{svg-CZThYPKf.js → svg-hZus3ztj.js} +2 -2
- package/dist/types/color.d.ts +1 -0
- package/dist/types/colorSeeds.d.ts +22 -0
- package/dist/types/colorSystem.d.ts +20 -0
- package/dist/types/designTokens.d.ts +24 -0
- package/dist/types/effects/index.d.ts +1 -1
- package/dist/types/effects/morph.d.ts +4 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/material.d.ts +1 -1
- package/dist/types/palette.d.ts +7 -0
- package/dist/types/scheme.d.ts +3 -0
- package/dist/types/tokens.d.ts +9 -1
- package/dist/types/types.d.ts +10 -0
- package/dist/types-BFr1fN-7.js +22 -0
- package/dist/types-BMLEvdee.cjs +1 -0
- package/dist/utils-BzSNCfat.js +76 -0
- package/dist/utils-D83DMCMa.cjs +1 -0
- package/package.json +9 -1
- package/dist/presets-55krt4L_.js +0 -354
- package/dist/presets-UIJJyagu.cjs +0 -1
- package/dist/tokens-DMGI7_df.cjs +0 -9
- package/dist/tokens-OfSofVKl.js +0 -204
- package/dist/utils-6iJ6IpZZ.cjs +0 -1
- package/dist/utils-B_VQDGMy.js +0 -67
package/dist/material.mjs
CHANGED
|
@@ -1,6 +1,238 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as x, d as C, i as G, c as p, s as w, n as k, o as S } from "./presets-DYXLx_nN.js";
|
|
2
|
+
import { toGradientAnimationValue as T, toGradientAnimationKeyframes as V, toGradientAnimationCSS as j } from "./animation.mjs";
|
|
3
|
+
import { createGradientMorphBlobs as A, resolveGradientMorphBlendMode as E, toGradientMorphFilter as O, toGradientMorphFilterMarkup as L, toGradientDropShadow as P, toGradientBoxShadow as B } from "./effects.mjs";
|
|
4
|
+
import { t as I } from "./css-DVaTTIqS.js";
|
|
5
|
+
import { t as K } from "./svg-hZus3ztj.js";
|
|
6
|
+
const z = ["glare", "soft", "mesh"], N = 128;
|
|
7
|
+
let g = N;
|
|
8
|
+
const h = /* @__PURE__ */ new Map(), _ = (a) => a.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), D = (a) => _(a), F = (a, e, r) => `${a}-${e}`, y = (a) => Object.entries(a).map(([e, r]) => `${e}: ${r};`).join(`
|
|
9
|
+
`), H = (a) => a.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), J = (a) => Object.entries(a).map(([e, r]) => `${H(e)}: ${r};`).join(`
|
|
10
|
+
`), u = (a) => a === null || typeof a != "object" ? JSON.stringify(a) : Array.isArray(a) ? `[${a.map(u).join(",")}]` : `{${Object.entries(a).filter(([, e]) => e !== void 0).sort(([e], [r]) => e.localeCompare(r)).map(
|
|
11
|
+
([e, r]) => `${JSON.stringify(e)}:${u(r)}`
|
|
12
|
+
).join(",")}}`, R = (a) => {
|
|
13
|
+
let e = 5381;
|
|
14
|
+
for (let r = 0; r < a.length; r += 1)
|
|
15
|
+
e = e * 33 ^ a.charCodeAt(r);
|
|
16
|
+
return (e >>> 0).toString(36);
|
|
17
|
+
}, U = (a, e) => u({ options: e, seed: a }), Z = (a) => {
|
|
18
|
+
const e = h.get(a);
|
|
19
|
+
if (e)
|
|
20
|
+
return h.delete(a), h.set(a, e), e;
|
|
21
|
+
}, Q = (a, e) => {
|
|
22
|
+
if (g <= 0) return e;
|
|
23
|
+
for (h.set(a, e); h.size > g; ) {
|
|
24
|
+
const r = h.keys().next().value;
|
|
25
|
+
if (r === void 0) break;
|
|
26
|
+
h.delete(r);
|
|
27
|
+
}
|
|
28
|
+
return e;
|
|
29
|
+
}, ie = () => {
|
|
30
|
+
h.clear();
|
|
31
|
+
}, ce = (a) => {
|
|
32
|
+
for (g = Math.max(0, Math.floor(a)); h.size > g; ) {
|
|
33
|
+
const e = h.keys().next().value;
|
|
34
|
+
if (e === void 0) break;
|
|
35
|
+
h.delete(e);
|
|
36
|
+
}
|
|
37
|
+
}, de = () => ({
|
|
38
|
+
limit: g,
|
|
39
|
+
size: h.size
|
|
40
|
+
}), q = (a, e, r, t) => {
|
|
41
|
+
const i = y(e), c = J(r), s = [i, c].filter(Boolean).join(`
|
|
42
|
+
`);
|
|
43
|
+
return [`.${a} {
|
|
44
|
+
${s}
|
|
45
|
+
}`, t].filter(Boolean).join(`
|
|
46
|
+
|
|
47
|
+
`);
|
|
48
|
+
}, W = (a, e) => a in e, M = (a, e) => W(a, e) ? G(a, e) : a === "soft" ? {
|
|
49
|
+
label: "Soft",
|
|
50
|
+
description: "Quiet monochrome radial gradient.",
|
|
51
|
+
gradient: {
|
|
52
|
+
recipe: "monochrome",
|
|
53
|
+
type: "radial",
|
|
54
|
+
position: "center",
|
|
55
|
+
shape: "ellipse"
|
|
56
|
+
},
|
|
57
|
+
shadow: {
|
|
58
|
+
layers: 2,
|
|
59
|
+
opacity: 0.18,
|
|
60
|
+
blur: 18,
|
|
61
|
+
y: 7,
|
|
62
|
+
spread: -4
|
|
63
|
+
},
|
|
64
|
+
dropShadow: {
|
|
65
|
+
layers: 2,
|
|
66
|
+
opacity: 0.26,
|
|
67
|
+
blur: 16,
|
|
68
|
+
y: 6
|
|
69
|
+
},
|
|
70
|
+
animation: {
|
|
71
|
+
preset: "pulse",
|
|
72
|
+
duration: 7200,
|
|
73
|
+
easing: "ease-in-out"
|
|
74
|
+
}
|
|
75
|
+
} : a === "mesh" ? null : {
|
|
76
|
+
label: a,
|
|
77
|
+
gradient: {
|
|
78
|
+
recipe: a,
|
|
79
|
+
type: "linear",
|
|
80
|
+
direction: a === "glare" ? 135 : 145
|
|
81
|
+
}
|
|
82
|
+
}, X = (a) => {
|
|
83
|
+
const e = [
|
|
84
|
+
`radial-gradient(circle at 16% 18%, ${w(a, -42, 72, 1.05)} 0%, transparent 34%)`,
|
|
85
|
+
`radial-gradient(circle at 86% 20%, ${k(a)} 0%, transparent 32%)`,
|
|
86
|
+
`radial-gradient(circle at 50% 84%, ${w(a, 56, 64, 1.08)} 0%, transparent 38%)`,
|
|
87
|
+
`linear-gradient(135deg, ${S(a, 94)}, ${S(a, 28)})`
|
|
88
|
+
];
|
|
89
|
+
return {
|
|
90
|
+
layers: e,
|
|
91
|
+
value: e.join(", ")
|
|
92
|
+
};
|
|
93
|
+
}, Y = (a, e, r, t, i) => {
|
|
94
|
+
if (e === "mesh") {
|
|
95
|
+
const n = X(a);
|
|
96
|
+
return {
|
|
97
|
+
cssVar: r,
|
|
98
|
+
layers: n.layers,
|
|
99
|
+
value: n.value
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const c = M(e, i), s = C(a), l = p(s, {
|
|
103
|
+
...c == null ? void 0 : c.gradient,
|
|
104
|
+
...t
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
cssVar: r,
|
|
108
|
+
model: l,
|
|
109
|
+
stops: l.stops,
|
|
110
|
+
svg: K(l, { id: r.replace(/^--/, "") }),
|
|
111
|
+
value: I(l)
|
|
112
|
+
};
|
|
113
|
+
}, ee = (a, e, r, t) => {
|
|
114
|
+
var l, n;
|
|
115
|
+
if (!a) return {};
|
|
116
|
+
const i = `${e.replace(/^--/, "")}-morph`, c = E(
|
|
117
|
+
(l = t == null ? void 0 : t.morph) == null ? void 0 : l.blendMode
|
|
118
|
+
), s = {
|
|
119
|
+
...t == null ? void 0 : t.morph,
|
|
120
|
+
id: ((n = t == null ? void 0 : t.morph) == null ? void 0 : n.id) ?? i
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
boxShadow: {
|
|
124
|
+
cssVar: `${e}-shadow`,
|
|
125
|
+
value: B(a, (t == null ? void 0 : t.shadow) ?? (r == null ? void 0 : r.shadow))
|
|
126
|
+
},
|
|
127
|
+
dropShadow: {
|
|
128
|
+
cssVar: `${e}-drop-shadow`,
|
|
129
|
+
value: P(
|
|
130
|
+
a,
|
|
131
|
+
(t == null ? void 0 : t.dropShadow) ?? (r == null ? void 0 : r.dropShadow)
|
|
132
|
+
)
|
|
133
|
+
},
|
|
134
|
+
morph: {
|
|
135
|
+
blendMode: c,
|
|
136
|
+
blendModeCssVar: `${e}-morph-blend-mode`,
|
|
137
|
+
cssVar: `${e}-morph`,
|
|
138
|
+
svg: L(s),
|
|
139
|
+
value: O(s)
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}, ae = (a, e, r, t) => {
|
|
143
|
+
var c;
|
|
144
|
+
const i = {
|
|
145
|
+
...r == null ? void 0 : r.animation,
|
|
146
|
+
...t,
|
|
147
|
+
name: `g-gradient-${a}-${(t == null ? void 0 : t.preset) ?? ((c = r == null ? void 0 : r.animation) == null ? void 0 : c.preset) ?? "shift"}`,
|
|
148
|
+
selector: `.g-gradient-${a}`
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
css: j(i),
|
|
152
|
+
cssVar: `${e}-animation`,
|
|
153
|
+
keyframes: V(i),
|
|
154
|
+
name: i.name,
|
|
155
|
+
value: T(i)
|
|
156
|
+
};
|
|
157
|
+
}, v = (a, e = "glare", r = {}) => {
|
|
158
|
+
const t = r.registry ?? x, i = D(e), c = F(r.prefix ?? "--g-gradient", i), s = M(e, t), n = C(a)[500], d = Y(
|
|
159
|
+
n,
|
|
160
|
+
e,
|
|
161
|
+
c,
|
|
162
|
+
r,
|
|
163
|
+
t
|
|
164
|
+
), f = {
|
|
165
|
+
[c]: d.value
|
|
166
|
+
}, o = r.effects ? ee(d.model, c, s, {
|
|
167
|
+
dropShadow: r.dropShadow,
|
|
168
|
+
morph: r.morph,
|
|
169
|
+
shadow: r.shadow
|
|
170
|
+
}) : void 0, m = r.animations ? ae(i, c, s, r.animation) : void 0;
|
|
171
|
+
return o != null && o.boxShadow && (f[o.boxShadow.cssVar] = o.boxShadow.value), o != null && o.dropShadow && (f[o.dropShadow.cssVar] = o.dropShadow.value), o != null && o.morph && (f[o.morph.cssVar] = o.morph.value, f[o.morph.blendModeCssVar] = o.morph.blendMode), m && (f[m.cssVar] = m.value), {
|
|
172
|
+
animation: m,
|
|
173
|
+
cssText: y(f),
|
|
174
|
+
cssVars: f,
|
|
175
|
+
description: s == null ? void 0 : s.description,
|
|
176
|
+
effects: o,
|
|
177
|
+
gradient: d,
|
|
178
|
+
keyframes: (m == null ? void 0 : m.keyframes) ?? "",
|
|
179
|
+
label: (s == null ? void 0 : s.label) ?? i,
|
|
180
|
+
name: i
|
|
181
|
+
};
|
|
182
|
+
}, le = (a, e = {}) => {
|
|
183
|
+
const r = e.recipes ?? z, t = {}, i = {}, c = {}, s = {}, l = [];
|
|
184
|
+
for (const n of r) {
|
|
185
|
+
const d = v(a, n, {
|
|
186
|
+
animations: e.animations,
|
|
187
|
+
effects: e.effects,
|
|
188
|
+
morph: e.morph,
|
|
189
|
+
prefix: e.prefix,
|
|
190
|
+
registry: e.registry
|
|
191
|
+
});
|
|
192
|
+
t[d.name] = d.gradient, Object.assign(s, d.cssVars), d.effects && (i[d.name] = d.effects), d.animation && (c[d.name] = d.animation, l.push(d.animation.keyframes));
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
animations: c,
|
|
196
|
+
cssText: y(s),
|
|
197
|
+
cssVars: s,
|
|
198
|
+
effects: i,
|
|
199
|
+
gradients: t,
|
|
200
|
+
keyframes: l.join(`
|
|
201
|
+
`)
|
|
202
|
+
};
|
|
203
|
+
}, me = (a, e = {}) => {
|
|
204
|
+
var b, $;
|
|
205
|
+
const r = U(a, e), t = Z(r);
|
|
206
|
+
if (t) return t;
|
|
207
|
+
const { className: i, id: c, recipe: s = "glare", ...l } = e, n = v(a, s, l), d = n.gradient.model && e.effects && e.morph ? A(n.gradient.model, e.morph) : void 0, f = c ?? `g-gradient-${n.name}-${R(
|
|
208
|
+
u({ options: e, seed: a })
|
|
209
|
+
)}`, o = i ?? f, m = {
|
|
210
|
+
backgroundImage: `var(${n.gradient.cssVar})`
|
|
211
|
+
};
|
|
212
|
+
return (b = n.effects) != null && b.boxShadow && (m.boxShadow = `var(${n.effects.boxShadow.cssVar})`), ($ = n.effects) != null && $.dropShadow && (m.filter = `var(${n.effects.dropShadow.cssVar})`), n.animation && (m.animation = `var(${n.animation.cssVar})`), Q(r, {
|
|
213
|
+
animation: n.animation,
|
|
214
|
+
className: o,
|
|
215
|
+
cssText: q(
|
|
216
|
+
o,
|
|
217
|
+
n.cssVars,
|
|
218
|
+
m,
|
|
219
|
+
n.keyframes
|
|
220
|
+
),
|
|
221
|
+
cssVars: n.cssVars,
|
|
222
|
+
effects: n.effects,
|
|
223
|
+
gradient: n.gradient,
|
|
224
|
+
id: f,
|
|
225
|
+
keyframes: n.keyframes,
|
|
226
|
+
morphBlobs: d,
|
|
227
|
+
preset: n,
|
|
228
|
+
style: m
|
|
229
|
+
});
|
|
230
|
+
};
|
|
2
231
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
232
|
+
ie as clearGradientMaterialCache,
|
|
233
|
+
me as createGradientMaterial,
|
|
234
|
+
v as createGradientPreset,
|
|
235
|
+
le as createGradientTokens,
|
|
236
|
+
de as getGradientMaterialCacheStats,
|
|
237
|
+
ce as setGradientMaterialCacheLimit
|
|
6
238
|
};
|