@gradient-ui/gradient-engine 0.5.0 → 1.0.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.
Files changed (89) hide show
  1. package/README.md +19 -5
  2. package/dist/animation.cjs +13 -13
  3. package/dist/animation.mjs +36 -36
  4. package/dist/core.cjs +1 -1
  5. package/dist/core.mjs +17 -14
  6. package/dist/css-B3xGfmW1.js +17 -0
  7. package/dist/css-CREh0Awz.cjs +1 -0
  8. package/dist/design-tokens.cjs +1 -0
  9. package/dist/design-tokens.mjs +8 -0
  10. package/dist/designTokens-Bw-HZ1f1.js +116 -0
  11. package/dist/designTokens-DsIk5RSi.cjs +1 -0
  12. package/dist/effects.cjs +137 -32
  13. package/dist/effects.mjs +225 -108
  14. package/dist/formatters.cjs +1 -1
  15. package/dist/formatters.mjs +33 -33
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.mjs +63 -43
  18. package/dist/material.cjs +9 -1
  19. package/dist/material.mjs +236 -4
  20. package/dist/presets-DA-6KYJh.cjs +316 -0
  21. package/dist/presets-Du6aTLtD.js +4025 -0
  22. package/dist/svg-B2CaHCLv.js +118 -0
  23. package/dist/svg-BtMrj3fP.cjs +32 -0
  24. package/dist/types/animation/css.d.ts +2 -2
  25. package/dist/types/animation/index.d.ts +1 -1
  26. package/dist/types/color.d.ts +1 -0
  27. package/dist/types/colorSeeds.d.ts +22 -0
  28. package/dist/types/colorSystem.d.ts +20 -0
  29. package/dist/types/core.d.ts +7 -7
  30. package/dist/types/designTokens.d.ts +24 -0
  31. package/dist/types/effects/index.d.ts +2 -2
  32. package/dist/types/effects/morph.d.ts +4 -1
  33. package/dist/types/effects/shadow.d.ts +1 -1
  34. package/dist/types/formatters/canvas.d.ts +1 -1
  35. package/dist/types/formatters/css.d.ts +1 -1
  36. package/dist/types/formatters/index.d.ts +3 -3
  37. package/dist/types/formatters/svg.d.ts +1 -1
  38. package/dist/types/index.d.ts +11 -7
  39. package/dist/types/material.d.ts +1 -1
  40. package/dist/types/model.d.ts +3 -3
  41. package/dist/types/palette.d.ts +8 -1
  42. package/dist/types/presets.d.ts +1 -1
  43. package/dist/types/recipes.d.ts +12 -12
  44. package/dist/types/scheme.d.ts +3 -0
  45. package/dist/types/tokens.d.ts +11 -3
  46. package/dist/types/types.d.ts +11 -1
  47. package/dist/types/utils.d.ts +1 -1
  48. package/dist/types-B0eCazk8.js +22 -0
  49. package/dist/types-BFkUlDkW.cjs +1 -0
  50. package/dist/types-cjs/animation/css.d.cts +12 -0
  51. package/dist/types-cjs/animation/index.d.cts +1 -0
  52. package/dist/types-cjs/color.d.cts +11 -0
  53. package/dist/types-cjs/colorMath.d.cts +3 -0
  54. package/dist/types-cjs/colorSeeds.d.cts +22 -0
  55. package/dist/types-cjs/colorSystem.d.cts +20 -0
  56. package/dist/types-cjs/constants.d.cts +3 -0
  57. package/dist/types-cjs/core.d.cts +9 -0
  58. package/dist/types-cjs/designTokens.d.cts +24 -0
  59. package/dist/types-cjs/effects/index.d.cts +2 -0
  60. package/dist/types-cjs/effects/morph.d.cts +8 -0
  61. package/dist/types-cjs/effects/shadow.d.cts +3 -0
  62. package/dist/types-cjs/formatters/canvas.d.cts +2 -0
  63. package/dist/types-cjs/formatters/css.d.cts +3 -0
  64. package/dist/types-cjs/formatters/index.d.cts +3 -0
  65. package/dist/types-cjs/formatters/svg.d.cts +5 -0
  66. package/dist/types-cjs/index.d.cts +11 -0
  67. package/dist/types-cjs/material.d.cts +1 -0
  68. package/dist/types-cjs/model.d.cts +5 -0
  69. package/dist/types-cjs/package.json +3 -0
  70. package/dist/types-cjs/palette.d.cts +13 -0
  71. package/dist/types-cjs/presets.d.cts +239 -0
  72. package/dist/types-cjs/recipes.d.cts +14 -0
  73. package/dist/types-cjs/scheme.d.cts +3 -0
  74. package/dist/types-cjs/tokens.d.cts +107 -0
  75. package/dist/types-cjs/types.d.cts +127 -0
  76. package/dist/types-cjs/utils.d.cts +10 -0
  77. package/dist/utils-Bry9BTmj.cjs +1 -0
  78. package/dist/utils-VaqPefmS.js +76 -0
  79. package/package.json +64 -20
  80. package/dist/css-CaOuUhfh.js +0 -17
  81. package/dist/css-YuAJQW13.cjs +0 -1
  82. package/dist/presets-55krt4L_.js +0 -354
  83. package/dist/presets-UIJJyagu.cjs +0 -1
  84. package/dist/svg-BVcl24Cf.cjs +0 -32
  85. package/dist/svg-CZThYPKf.js +0 -118
  86. package/dist/tokens-DMGI7_df.cjs +0 -9
  87. package/dist/tokens-OfSofVKl.js +0 -204
  88. package/dist/utils-6iJ6IpZZ.cjs +0 -1
  89. package/dist/utils-B_VQDGMy.js +0 -67
@@ -1,118 +0,0 @@
1
- import { t as y, b as v } from "./utils-B_VQDGMy.js";
2
- import { t as C } from "./css-CaOuUhfh.js";
3
- const m = "http://www.w3.org/2000/svg", G = "http://www.w3.org/1999/xhtml", c = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), p = (e) => {
4
- const t = e.opacity === void 0 ? "" : ` stop-opacity="${v(e.opacity)}"`;
5
- return `<stop offset="${e.position}%" stop-color="${e.color}"${t} />`;
6
- }, N = (e, t) => {
7
- var r, a, i;
8
- return {
9
- active: t.activeStroke ?? ((r = e.stops[Math.max(0, Math.floor(e.stops.length / 2))]) == null ? void 0 : r.color) ?? ((a = e.stops[0]) == null ? void 0 : a.color) ?? "currentColor",
10
- background: t.backgroundStroke ?? ((i = e.stops[0]) == null ? void 0 : i.color) ?? t.activeStroke ?? "currentColor"
11
- };
12
- }, P = (e, t) => {
13
- var n;
14
- const r = (n = e.match(/\bviewBox=(["'])(.*?)\1/i)) == null ? void 0 : n[2];
15
- if (r) return r;
16
- const a = t.width ?? 240, i = t.height ?? 120;
17
- return `0 0 ${a} ${i}`;
18
- }, A = (e) => {
19
- var t;
20
- return ((t = e.replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<!doctype[\s\S]*?>/gi, "").match(/<svg\b[^>]*>([\s\S]*?)<\/svg>/i)) == null ? void 0 : t[1].trim()) ?? e;
21
- }, j = (e) => {
22
- const t = e.trim().split(/(?=M\s*[-+.\d])/).map((r) => r.trim()).filter(Boolean);
23
- return t.length > 1 ? t : [e];
24
- }, O = (e) => [...e.matchAll(/<path\b[^>]*\sd=(["'])([\s\S]*?)\1/gi)].flatMap(
25
- (t) => j(t[2])
26
- ), b = (e) => {
27
- var t;
28
- return Math.max(1, ((t = e.match(/[LlHhVvCcSsQqTtAaZz]/g)) == null ? void 0 : t.length) ?? 0);
29
- }, T = (e, t) => {
30
- const a = 0.5 + (1 - b(e) / t) * 0.22;
31
- return Math.round(a * 1e3) / 1e3;
32
- }, x = (e) => {
33
- const [t = "0", r = "0", a = "240", i = "120"] = e.trim().split(/[\s,]+/);
34
- return {
35
- height: Number(i) || 120,
36
- width: Number(a) || 240,
37
- x: Number(t) || 0,
38
- y: Number(r) || 0
39
- };
40
- }, V = (e, t, r) => {
41
- if (r.viewBoxPadding === !1) return e;
42
- const a = x(e), i = Math.max(
43
- t * 2,
44
- Math.min(a.width, a.height) * 0.02
45
- ), n = r.viewBoxPadding ?? i;
46
- return [
47
- a.x - n,
48
- a.y - n,
49
- a.width + n * 2,
50
- a.height + n * 2
51
- ].join(" ");
52
- }, W = (e) => {
53
- const { height: t, width: r } = x(e);
54
- return {
55
- height: Number(t) || 120,
56
- width: Number(r) || 240
57
- };
58
- }, U = (e, t, r) => {
59
- if (r.normalizeStrokeWidth === !1) return e;
60
- const { height: a, width: i } = W(t), n = r.strokeWidthBase ?? 180;
61
- return e * (Math.min(i, a) / n);
62
- }, z = (e, t = {}) => {
63
- const r = t.id ?? "g-gradient", a = e.stops.map(p).join("");
64
- return e.type === "radial" ? `<radialGradient id="${r}" cx="${t.cx ?? "50%"}" cy="${t.cy ?? "50%"}" r="${t.r ?? "75%"}">${a}</radialGradient>` : e.type === "conic" ? `<pattern id="${r}" patternUnits="objectBoundingBox" width="1" height="1"><foreignObject x="0" y="0" width="100%" height="100%"><div xmlns="${G}" style="width:100%;height:100%;background:${c(C(e))};"></div></foreignObject></pattern>` : `<linearGradient id="${r}" x1="${t.x1 ?? "0%"}" y1="${t.y1 ?? "0%"}" x2="${t.x2 ?? "100%"}" y2="${t.y2 ?? "100%"}">${a}</linearGradient>`;
65
- }, q = (e, t = {}) => {
66
- const r = t.id ?? "g-gradient", a = t.width ?? 240, i = t.height ?? 120, n = t.rx ?? 18;
67
- return `<svg xmlns="${m}" viewBox="0 0 ${a} ${i}" role="img">
68
- <defs>
69
- ${z(e, t)}
70
- </defs>
71
- <rect width="${a}" height="${i}" rx="${n}" fill="url(#${r})" />
72
- </svg>`;
73
- }, D = (e, t, r = {}) => {
74
- const i = `${r.id ?? "g-gradient-source"}-stroke`, n = P(e, r), d = A(e), s = O(e), o = U(
75
- r.strokeWidth ?? 1.4,
76
- n,
77
- r
78
- ), h = V(n, o, r), { width: $, x: g } = x(h), l = r.linecap ?? "round", u = y(r.duration ?? 3600), k = r.repeatCount ?? "indefinite", S = r.sourceOpacity ?? 0.22, M = t.stops.map(p).join(""), B = Math.max(...s.map(b));
79
- return `<svg xmlns="${m}" viewBox="${c(h)}" role="img">
80
- <defs>
81
- <linearGradient id="${i}" gradientUnits="userSpaceOnUse" x1="${g}" y1="0" x2="${g + $}" y2="0">
82
- ${M}
83
- </linearGradient>
84
- </defs>
85
- <g opacity="${v(S)}">
86
- ${d}
87
- </g>
88
- <g fill="none" stroke="url(#${i})" stroke-width="${o}" stroke-linecap="${l}" stroke-linejoin="round">
89
- ${s.map((w) => {
90
- const f = T(w, B);
91
- return `<path d="${c(w)}" pathLength="100" stroke-dasharray="0 100" stroke-dashoffset="0">
92
- <animate attributeName="stroke-dasharray" values="0 100;100 100;0 100" keyTimes="0;${f};1" dur="${u}" repeatCount="${k}" calcMode="linear" />
93
- <animate attributeName="stroke-dashoffset" values="0;0;-100" keyTimes="0;${f};1" dur="${u}" repeatCount="${k}" calcMode="linear" />
94
- </path>`;
95
- }).join(`
96
- `)}
97
- </g>
98
- </svg>`;
99
- }, H = (e, t = {}) => {
100
- const a = `${t.id ?? "g-gradient-path"}-stroke`, i = t.width ?? 240, n = t.height ?? 120, d = t.path ?? `M 20 ${n * 0.64} C ${i * 0.28} ${n * 0.18}, ${i * 0.58} ${n * 0.18}, ${i - 20} ${n * 0.64}`, s = t.strokeWidth ?? 12, o = t.linecap ?? "round", h = y(t.duration ?? 2800), $ = t.repeatCount ?? "indefinite", g = t.backgroundOpacity ?? 0.24, l = N(e, t), u = e.stops.map(p).join("");
101
- return `<svg xmlns="${m}" viewBox="0 0 ${i} ${n}" role="img">
102
- <defs>
103
- <linearGradient id="${a}" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="${i}" y2="0">
104
- ${u}
105
- </linearGradient>
106
- </defs>
107
- <path d="${c(d)}" fill="none" stroke="${l.background}" stroke-width="${s}" stroke-linecap="${o}" opacity="${g}" />
108
- <path d="${c(d)}" fill="none" stroke="${t.activeStroke ? l.active : `url(#${a})`}" stroke-width="${s}" stroke-linecap="${o}" pathLength="100" stroke-dasharray="100 100" stroke-dashoffset="100">
109
- <animate attributeName="stroke-dashoffset" values="100;0;-100" dur="${h}" repeatCount="${$}" />
110
- </path>
111
- </svg>`;
112
- };
113
- export {
114
- q as a,
115
- H as b,
116
- D as c,
117
- z as t
118
- };
@@ -1,9 +0,0 @@
1
- "use strict";const f=require("./presets-UIJJyagu.cjs"),u=require("./animation.cjs"),g=require("./effects.cjs"),b=require("./css-YuAJQW13.cjs"),v=require("./svg-BVcl24Cf.cjs"),G=["glare","soft","mesh"],k=e=>e.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),x=e=>k(e),C=(e,a,r)=>`${e}-${a}`,$=e=>Object.entries(e).map(([a,r])=>`${a}: ${r};`).join(`
2
- `),T=e=>e.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),V=e=>Object.entries(e).map(([a,r])=>`${T(a)}: ${r};`).join(`
3
- `),y=e=>e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(y).join(",")}]`:`{${Object.entries(e).filter(([,a])=>a!==void 0).sort(([a],[r])=>a.localeCompare(r)).map(([a,r])=>`${JSON.stringify(a)}:${y(r)}`).join(",")}}`,p=e=>{let a=5381;for(let r=0;r<e.length;r+=1)a=a*33^e.charCodeAt(r);return(a>>>0).toString(36)},j=(e,a,r,n)=>{const o=$(a),s=V(r),t=[o,s].filter(Boolean).join(`
4
- `);return[`.${e} {
5
- ${t}
6
- }`,n].filter(Boolean).join(`
7
-
8
- `)},A=(e,a)=>e in a,w=(e,a)=>A(e,a)?f.getGradientPreset(e,a):e==="soft"?{label:"Soft",description:"Quiet monochrome radial gradient.",gradient:{recipe:"monochrome",type:"radial",position:"center",shape:"ellipse"},shadow:{layers:2,opacity:.18,blur:18,y:7,spread:-4},dropShadow:{layers:2,opacity:.26,blur:16,y:6},animation:{preset:"pulse",duration:7200,easing:"ease-in-out"}}:e==="mesh"?null:{label:e,gradient:{recipe:e,type:"linear",direction:e==="glare"?135:145}},O=e=>{const a=[`radial-gradient(circle at 16% 18%, ${f.shiftHue(e,-42,72,1.05)} 0%, transparent 34%)`,`radial-gradient(circle at 86% 20%, ${f.getComplementaryColor(e)} 0%, transparent 32%)`,`radial-gradient(circle at 50% 84%, ${f.shiftHue(e,56,64,1.08)} 0%, transparent 38%)`,`linear-gradient(135deg, ${f.changeTone(e,94)}, ${f.changeTone(e,28)})`];return{layers:a,value:a.join(", ")}},P=(e,a,r,n,o)=>{if(a==="mesh"){const h=O(e);return{cssVar:r,layers:h.layers,value:h.value}}const s=w(a,o),t=f.createPalette(e),l=f.createGradientModel(t,{...s==null?void 0:s.gradient,...n});return{cssVar:r,model:l,stops:l.stops,svg:v.toSvgGradient(l,{id:r.replace(/^--/,"")}),value:b.toCssGradient(l)}},E=(e,a,r,n)=>{var t;if(!e)return{};const o=`${a.replace(/^--/,"")}-morph`,s={...n==null?void 0:n.morph,id:((t=n==null?void 0:n.morph)==null?void 0:t.id)??o};return{boxShadow:{cssVar:`${a}-shadow`,value:g.toGradientBoxShadow(e,(n==null?void 0:n.shadow)??(r==null?void 0:r.shadow))},dropShadow:{cssVar:`${a}-drop-shadow`,value:g.toGradientDropShadow(e,(n==null?void 0:n.dropShadow)??(r==null?void 0:r.dropShadow))},morph:{cssVar:`${a}-morph`,svg:g.toGradientMorphFilterMarkup(s),value:g.toGradientMorphFilter(s)}}},M=(e,a,r,n)=>{var s;const o={...r==null?void 0:r.animation,...n,name:`g-gradient-${e}-${(n==null?void 0:n.preset)??((s=r==null?void 0:r.animation)==null?void 0:s.preset)??"shift"}`,selector:`.g-gradient-${e}`};return{css:u.toGradientAnimationCSS(o),cssVar:`${a}-animation`,keyframes:u.toGradientAnimationKeyframes(o),name:o.name,value:u.toGradientAnimationValue(o)}},S=(e,a="glare",r={})=>{const n=r.registry??f.gradientPresets,o=x(a),s=C(r.prefix??"--g-gradient",o),t=w(a,n),h=f.createPalette(e)[500],c=P(h,a,s,r,n),d={[s]:c.value},i=r.effects?E(c.model,s,t,{dropShadow:r.dropShadow,morph:r.morph,shadow:r.shadow}):void 0,m=r.animations?M(o,s,t,r.animation):void 0;return i!=null&&i.boxShadow&&(d[i.boxShadow.cssVar]=i.boxShadow.value),i!=null&&i.dropShadow&&(d[i.dropShadow.cssVar]=i.dropShadow.value),i!=null&&i.morph&&(d[i.morph.cssVar]=i.morph.value),m&&(d[m.cssVar]=m.value),{animation:m,cssText:$(d),cssVars:d,description:t==null?void 0:t.description,effects:i,gradient:c,keyframes:(m==null?void 0:m.keyframes)??"",label:(t==null?void 0:t.label)??o,name:o}},N=(e,a={})=>{const r=a.recipes??G,n={},o={},s={},t={},l=[];for(const h of r){const c=S(e,h,{animations:a.animations,effects:a.effects,morph:a.morph,prefix:a.prefix,registry:a.registry});n[c.name]=c.gradient,Object.assign(t,c.cssVars),c.effects&&(o[c.name]=c.effects),c.animation&&(s[c.name]=c.animation,l.push(c.animation.keyframes))}return{animations:s,cssText:$(t),cssVars:t,effects:o,gradients:n,keyframes:l.join(`
9
- `)}},q=(e,a={})=>{var i,m;const{className:r,id:n,recipe:o="glare",...s}=a,t=S(e,o,s),l=t.gradient.model&&a.effects&&a.morph?g.createGradientMorphBlobs(t.gradient.model,a.morph):void 0,h=n??`g-gradient-${t.name}-${p(y({options:a,seed:e}))}`,c=r??h,d={backgroundImage:`var(${t.gradient.cssVar})`};return(i=t.effects)!=null&&i.boxShadow&&(d.boxShadow=`var(${t.effects.boxShadow.cssVar})`),(m=t.effects)!=null&&m.dropShadow&&(d.filter=`var(${t.effects.dropShadow.cssVar})`),t.animation&&(d.animation=`var(${t.animation.cssVar})`),{animation:t.animation,className:c,cssText:j(c,t.cssVars,d,t.keyframes),cssVars:t.cssVars,effects:t.effects,gradient:t.gradient,id:h,keyframes:t.keyframes,morphBlobs:l,preset:t,style:d}};exports.createGradientMaterial=q;exports.createGradientPreset=S;exports.createGradientTokens=N;
@@ -1,204 +0,0 @@
1
- import { h as w, b as $, g as v, c as p, s as u, j as x, k as y } from "./presets-55krt4L_.js";
2
- import { toGradientAnimationValue as k, toGradientAnimationKeyframes as G, toGradientAnimationCSS as C } from "./animation.mjs";
3
- import { createGradientMorphBlobs as V, toGradientMorphFilter as j, toGradientMorphFilterMarkup as T, toGradientDropShadow as A, toGradientBoxShadow as O } from "./effects.mjs";
4
- import { t as E } from "./css-CaOuUhfh.js";
5
- import { t as P } from "./svg-CZThYPKf.js";
6
- const M = ["glare", "soft", "mesh"], N = (a) => a.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`), B = (a) => N(a), I = (a, r, e) => `${a}-${r}`, g = (a) => Object.entries(a).map(([r, e]) => `${r}: ${e};`).join(`
7
- `), D = (a) => a.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`), F = (a) => Object.entries(a).map(([r, e]) => `${D(r)}: ${e};`).join(`
8
- `), h = (a) => a === null || typeof a != "object" ? JSON.stringify(a) : Array.isArray(a) ? `[${a.map(h).join(",")}]` : `{${Object.entries(a).filter(([, r]) => r !== void 0).sort(([r], [e]) => r.localeCompare(e)).map(
9
- ([r, e]) => `${JSON.stringify(r)}:${h(e)}`
10
- ).join(",")}}`, K = (a) => {
11
- let r = 5381;
12
- for (let e = 0; e < a.length; e += 1)
13
- r = r * 33 ^ a.charCodeAt(e);
14
- return (r >>> 0).toString(36);
15
- }, L = (a, r, e, n) => {
16
- const o = g(r), s = F(e), t = [o, s].filter(Boolean).join(`
17
- `);
18
- return [`.${a} {
19
- ${t}
20
- }`, n].filter(Boolean).join(`
21
-
22
- `);
23
- }, J = (a, r) => a in r, S = (a, r) => J(a, r) ? v(a, r) : a === "soft" ? {
24
- label: "Soft",
25
- description: "Quiet monochrome radial gradient.",
26
- gradient: {
27
- recipe: "monochrome",
28
- type: "radial",
29
- position: "center",
30
- shape: "ellipse"
31
- },
32
- shadow: {
33
- layers: 2,
34
- opacity: 0.18,
35
- blur: 18,
36
- y: 7,
37
- spread: -4
38
- },
39
- dropShadow: {
40
- layers: 2,
41
- opacity: 0.26,
42
- blur: 16,
43
- y: 6
44
- },
45
- animation: {
46
- preset: "pulse",
47
- duration: 7200,
48
- easing: "ease-in-out"
49
- }
50
- } : a === "mesh" ? null : {
51
- label: a,
52
- gradient: {
53
- recipe: a,
54
- type: "linear",
55
- direction: a === "glare" ? 135 : 145
56
- }
57
- }, Z = (a) => {
58
- const r = [
59
- `radial-gradient(circle at 16% 18%, ${u(a, -42, 72, 1.05)} 0%, transparent 34%)`,
60
- `radial-gradient(circle at 86% 20%, ${x(a)} 0%, transparent 32%)`,
61
- `radial-gradient(circle at 50% 84%, ${u(a, 56, 64, 1.08)} 0%, transparent 38%)`,
62
- `linear-gradient(135deg, ${y(a, 94)}, ${y(a, 28)})`
63
- ];
64
- return {
65
- layers: r,
66
- value: r.join(", ")
67
- };
68
- }, _ = (a, r, e, n, o) => {
69
- if (r === "mesh") {
70
- const f = Z(a);
71
- return {
72
- cssVar: e,
73
- layers: f.layers,
74
- value: f.value
75
- };
76
- }
77
- const s = S(r, o), t = $(a), l = p(t, {
78
- ...s == null ? void 0 : s.gradient,
79
- ...n
80
- });
81
- return {
82
- cssVar: e,
83
- model: l,
84
- stops: l.stops,
85
- svg: P(l, { id: e.replace(/^--/, "") }),
86
- value: E(l)
87
- };
88
- }, z = (a, r, e, n) => {
89
- var t;
90
- if (!a) return {};
91
- const o = `${r.replace(/^--/, "")}-morph`, s = {
92
- ...n == null ? void 0 : n.morph,
93
- id: ((t = n == null ? void 0 : n.morph) == null ? void 0 : t.id) ?? o
94
- };
95
- return {
96
- boxShadow: {
97
- cssVar: `${r}-shadow`,
98
- value: O(a, (n == null ? void 0 : n.shadow) ?? (e == null ? void 0 : e.shadow))
99
- },
100
- dropShadow: {
101
- cssVar: `${r}-drop-shadow`,
102
- value: A(
103
- a,
104
- (n == null ? void 0 : n.dropShadow) ?? (e == null ? void 0 : e.dropShadow)
105
- )
106
- },
107
- morph: {
108
- cssVar: `${r}-morph`,
109
- svg: T(s),
110
- value: j(s)
111
- }
112
- };
113
- }, H = (a, r, e, n) => {
114
- var s;
115
- const o = {
116
- ...e == null ? void 0 : e.animation,
117
- ...n,
118
- name: `g-gradient-${a}-${(n == null ? void 0 : n.preset) ?? ((s = e == null ? void 0 : e.animation) == null ? void 0 : s.preset) ?? "shift"}`,
119
- selector: `.g-gradient-${a}`
120
- };
121
- return {
122
- css: C(o),
123
- cssVar: `${r}-animation`,
124
- keyframes: G(o),
125
- name: o.name,
126
- value: k(o)
127
- };
128
- }, b = (a, r = "glare", e = {}) => {
129
- const n = e.registry ?? w, o = B(r), s = I(e.prefix ?? "--g-gradient", o), t = S(r, n), f = $(a)[500], c = _(
130
- f,
131
- r,
132
- s,
133
- e,
134
- n
135
- ), d = {
136
- [s]: c.value
137
- }, i = e.effects ? z(c.model, s, t, {
138
- dropShadow: e.dropShadow,
139
- morph: e.morph,
140
- shadow: e.shadow
141
- }) : void 0, m = e.animations ? H(o, s, t, e.animation) : void 0;
142
- return i != null && i.boxShadow && (d[i.boxShadow.cssVar] = i.boxShadow.value), i != null && i.dropShadow && (d[i.dropShadow.cssVar] = i.dropShadow.value), i != null && i.morph && (d[i.morph.cssVar] = i.morph.value), m && (d[m.cssVar] = m.value), {
143
- animation: m,
144
- cssText: g(d),
145
- cssVars: d,
146
- description: t == null ? void 0 : t.description,
147
- effects: i,
148
- gradient: c,
149
- keyframes: (m == null ? void 0 : m.keyframes) ?? "",
150
- label: (t == null ? void 0 : t.label) ?? o,
151
- name: o
152
- };
153
- }, X = (a, r = {}) => {
154
- const e = r.recipes ?? M, n = {}, o = {}, s = {}, t = {}, l = [];
155
- for (const f of e) {
156
- const c = b(a, f, {
157
- animations: r.animations,
158
- effects: r.effects,
159
- morph: r.morph,
160
- prefix: r.prefix,
161
- registry: r.registry
162
- });
163
- n[c.name] = c.gradient, Object.assign(t, c.cssVars), c.effects && (o[c.name] = c.effects), c.animation && (s[c.name] = c.animation, l.push(c.animation.keyframes));
164
- }
165
- return {
166
- animations: s,
167
- cssText: g(t),
168
- cssVars: t,
169
- effects: o,
170
- gradients: n,
171
- keyframes: l.join(`
172
- `)
173
- };
174
- }, Y = (a, r = {}) => {
175
- var i, m;
176
- const { className: e, id: n, recipe: o = "glare", ...s } = r, t = b(a, o, s), l = t.gradient.model && r.effects && r.morph ? V(t.gradient.model, r.morph) : void 0, f = n ?? `g-gradient-${t.name}-${K(
177
- h({ options: r, seed: a })
178
- )}`, c = e ?? f, d = {
179
- backgroundImage: `var(${t.gradient.cssVar})`
180
- };
181
- return (i = t.effects) != null && i.boxShadow && (d.boxShadow = `var(${t.effects.boxShadow.cssVar})`), (m = t.effects) != null && m.dropShadow && (d.filter = `var(${t.effects.dropShadow.cssVar})`), t.animation && (d.animation = `var(${t.animation.cssVar})`), {
182
- animation: t.animation,
183
- className: c,
184
- cssText: L(
185
- c,
186
- t.cssVars,
187
- d,
188
- t.keyframes
189
- ),
190
- cssVars: t.cssVars,
191
- effects: t.effects,
192
- gradient: t.gradient,
193
- id: f,
194
- keyframes: t.keyframes,
195
- morphBlobs: l,
196
- preset: t,
197
- style: d
198
- };
199
- };
200
- export {
201
- b as a,
202
- X as b,
203
- Y as c
204
- };
@@ -1 +0,0 @@
1
- "use strict";const s=(t,r=0,o=1)=>Math.min(o,Math.max(r,t)),T=t=>{const r=t.slice(1),o=r.length===3||r.length===4?r.slice(0,3).split("").map(n=>n.repeat(2)).join(""):r.slice(0,6);return o.length!==6||!/^[\da-f]{6}$/i.test(o)?null:{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}},m=t=>{const r=t.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/i);return r?{r:s(Number(r[1]),0,255),g:s(Number(r[2]),0,255),b:s(Number(r[3]),0,255)}:null},e=t=>{if(typeof t=="number"){const o=t&16777215;return{r:o>>16&255,g:o>>8&255,b:o&255}}const r=t.trim();return r.startsWith("#")?T(r):r.toLowerCase().startsWith("rgb")?m(r):null},a=({r:t,g:r,b:o})=>`#${[t,r,o].map(n=>Math.round(n).toString(16).padStart(2,"0")).join("")}`,c=({r:t,g:r,b:o})=>`${Math.round(t)}, ${Math.round(r)}, ${Math.round(o)}`,p=(t,r)=>{const o=e(t)??e(r);if(!o)throw new Error(`Invalid fallback color: ${r}`);return a(o)};const u="center",I="farthest-corner",D=(t=135)=>typeof t=="number"?`${t}deg`:t,h=t=>typeof t=="number"?`${t}px`:t,E=t=>typeof t=="number"?`${t}ms`:t,i=(t,r=0,o=1)=>Math.min(o,Math.max(r,t)),l=(t,r)=>{if(r===void 0)return t;const o=e(t);return o?`rgb(${c(o).replace(/,/g,"")} / ${i(r)})`:t},g=({color:t,opacity:r,position:o})=>`${l(t,r)} ${o}%`,f=(t,r,o)=>({color:t,position:r}),C=t=>{if(t.length<=1)return t;const r=t.map(n=>({...n,position:n.position/2})),o=[...t].reverse().map(n=>({...n,position:100-n.position/2}));return[...r,...o]};exports.DEFAULT_GRADIENT_DIRECTION=135;exports.DEFAULT_GRADIENT_POSITION=u;exports.DEFAULT_GRADIENT_SIZE=I;exports.clamp=i;exports.colorToHex=p;exports.createStop=f;exports.formatStop=g;exports.getConicStops=C;exports.normalizeDirection=D;exports.parseColor=e;exports.rgbToChannels=c;exports.rgbToHex=a;exports.toCssColor=l;exports.toCssDuration=E;exports.toCssLength=h;
@@ -1,67 +0,0 @@
1
- const e = (t, r = 0, n = 1) => Math.min(n, Math.max(r, t)), a = (t) => {
2
- const r = t.slice(1), n = r.length === 3 || r.length === 4 ? r.slice(0, 3).split("").map((s) => s.repeat(2)).join("") : r.slice(0, 6);
3
- return n.length !== 6 || !/^[\da-f]{6}$/i.test(n) ? null : {
4
- r: parseInt(n.slice(0, 2), 16),
5
- g: parseInt(n.slice(2, 4), 16),
6
- b: parseInt(n.slice(4, 6), 16)
7
- };
8
- }, c = (t) => {
9
- const r = t.match(
10
- /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/i
11
- );
12
- return r ? {
13
- r: e(Number(r[1]), 0, 255),
14
- g: e(Number(r[2]), 0, 255),
15
- b: e(Number(r[3]), 0, 255)
16
- } : null;
17
- }, o = (t) => {
18
- if (typeof t == "number") {
19
- const n = t & 16777215;
20
- return {
21
- r: n >> 16 & 255,
22
- g: n >> 8 & 255,
23
- b: n & 255
24
- };
25
- }
26
- const r = t.trim();
27
- return r.startsWith("#") ? a(r) : r.toLowerCase().startsWith("rgb") ? c(r) : null;
28
- }, i = ({ r: t, g: r, b: n }) => `#${[t, r, n].map((s) => Math.round(s).toString(16).padStart(2, "0")).join("")}`, l = ({ r: t, g: r, b: n }) => `${Math.round(t)}, ${Math.round(r)}, ${Math.round(n)}`, p = (t, r) => {
29
- const n = o(t) ?? o(r);
30
- if (!n)
31
- throw new Error(`Invalid fallback color: ${r}`);
32
- return i(n);
33
- }, h = 135, f = "center", g = "farthest-corner", b = (t = 135) => typeof t == "number" ? `${t}deg` : t, d = (t) => typeof t == "number" ? `${t}px` : t, I = (t) => typeof t == "number" ? `${t}ms` : t, u = (t, r = 0, n = 1) => Math.min(n, Math.max(r, t)), m = (t, r) => {
34
- if (r === void 0) return t;
35
- const n = o(t);
36
- return n ? `rgb(${l(n).replace(/,/g, "")} / ${u(r)})` : t;
37
- }, $ = ({ color: t, opacity: r, position: n }) => `${m(t, r)} ${n}%`, T = (t, r, n) => ({
38
- color: t,
39
- position: r
40
- }), D = (t) => {
41
- if (t.length <= 1) return t;
42
- const r = t.map((s) => ({
43
- ...s,
44
- position: s.position / 2
45
- })), n = [...t].reverse().map((s) => ({
46
- ...s,
47
- position: 100 - s.position / 2
48
- }));
49
- return [...r, ...n];
50
- };
51
- export {
52
- h as D,
53
- i as a,
54
- u as b,
55
- p as c,
56
- g as d,
57
- f as e,
58
- $ as f,
59
- D as g,
60
- T as h,
61
- m as i,
62
- d as j,
63
- b as n,
64
- o as p,
65
- l as r,
66
- I as t
67
- };