@gradient-ui/gradient-engine 0.6.0 → 2.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.
- package/README.md +0 -6
- package/dist/animation.cjs +13 -13
- package/dist/animation.mjs +36 -36
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +17 -17
- package/dist/css-B3xGfmW1.js +17 -0
- package/dist/css-CREh0Awz.cjs +1 -0
- package/dist/design-tokens.cjs +1 -1
- package/dist/design-tokens.mjs +5 -5
- package/dist/designTokens-Bw-HZ1f1.js +116 -0
- package/dist/designTokens-DsIk5RSi.cjs +1 -0
- package/dist/effects.cjs +67 -67
- package/dist/effects.mjs +153 -153
- package/dist/formatters.cjs +1 -1
- package/dist/formatters.mjs +33 -33
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +63 -63
- package/dist/material.cjs +8 -8
- package/dist/material.mjs +170 -170
- package/dist/presets-DA-6KYJh.cjs +316 -0
- package/dist/presets-Du6aTLtD.js +4025 -0
- package/dist/svg-B2CaHCLv.js +118 -0
- package/dist/svg-BtMrj3fP.cjs +32 -0
- package/dist/types/animation/css.d.ts +2 -2
- package/dist/types/animation/index.d.ts +1 -1
- package/dist/types/colorSystem.d.ts +3 -3
- package/dist/types/core.d.ts +7 -7
- package/dist/types/designTokens.d.ts +4 -4
- package/dist/types/effects/index.d.ts +2 -2
- package/dist/types/effects/morph.d.ts +1 -1
- package/dist/types/effects/shadow.d.ts +1 -1
- package/dist/types/formatters/canvas.d.ts +1 -1
- package/dist/types/formatters/css.d.ts +1 -1
- package/dist/types/formatters/index.d.ts +3 -3
- package/dist/types/formatters/svg.d.ts +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/material.d.ts +1 -1
- package/dist/types/model.d.ts +3 -3
- package/dist/types/palette.d.ts +1 -1
- package/dist/types/presets.d.ts +1 -1
- package/dist/types/recipes.d.ts +12 -12
- package/dist/types/tokens.d.ts +3 -3
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/{types-BFr1fN-7.js → types-B0eCazk8.js} +4 -4
- package/dist/types-BFkUlDkW.cjs +1 -0
- package/dist/types-cjs/animation/css.d.cts +12 -0
- package/dist/types-cjs/animation/index.d.cts +1 -0
- package/dist/types-cjs/color.d.cts +11 -0
- package/dist/types-cjs/colorMath.d.cts +3 -0
- package/dist/types-cjs/colorSeeds.d.cts +22 -0
- package/dist/types-cjs/colorSystem.d.cts +20 -0
- package/dist/types-cjs/constants.d.cts +3 -0
- package/dist/types-cjs/core.d.cts +9 -0
- package/dist/types-cjs/designTokens.d.cts +24 -0
- package/dist/types-cjs/effects/index.d.cts +2 -0
- package/dist/types-cjs/effects/morph.d.cts +8 -0
- package/dist/types-cjs/effects/shadow.d.cts +3 -0
- package/dist/types-cjs/formatters/canvas.d.cts +2 -0
- package/dist/types-cjs/formatters/css.d.cts +3 -0
- package/dist/types-cjs/formatters/index.d.cts +3 -0
- package/dist/types-cjs/formatters/svg.d.cts +5 -0
- package/dist/types-cjs/index.d.cts +11 -0
- package/dist/types-cjs/material.d.cts +1 -0
- package/dist/types-cjs/model.d.cts +5 -0
- package/dist/types-cjs/package.json +3 -0
- package/dist/types-cjs/palette.d.cts +13 -0
- package/dist/types-cjs/presets.d.cts +239 -0
- package/dist/types-cjs/recipes.d.cts +14 -0
- package/dist/types-cjs/scheme.d.cts +3 -0
- package/dist/types-cjs/tokens.d.cts +107 -0
- package/dist/types-cjs/types.d.cts +127 -0
- package/dist/types-cjs/utils.d.cts +10 -0
- package/dist/utils-Bry9BTmj.cjs +1 -0
- package/dist/utils-VaqPefmS.js +76 -0
- package/package.json +59 -23
- package/dist/css-BVHXLMRl.cjs +0 -1
- package/dist/css-DVaTTIqS.js +0 -17
- package/dist/designTokens-BnzZfRES.js +0 -116
- package/dist/designTokens-C1WdzS3v.cjs +0 -1
- package/dist/presets-BBLdqUE4.cjs +0 -316
- package/dist/presets-DYXLx_nN.js +0 -4025
- package/dist/svg-dGtLYnIJ.cjs +0 -32
- package/dist/svg-hZus3ztj.js +0 -118
- package/dist/types-BMLEvdee.cjs +0 -1
- package/dist/utils-BzSNCfat.js +0 -76
- package/dist/utils-D83DMCMa.cjs +0 -1
package/dist/svg-dGtLYnIJ.cjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";const $=require("./utils-D83DMCMa.cjs"),B=require("./css-BVHXLMRl.cjs"),p="http://www.w3.org/2000/svg",G="http://www.w3.org/1999/xhtml",c=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),x=e=>{const t=e.opacity===void 0?"":` stop-opacity="${$.clamp(e.opacity)}"`;return`<stop offset="${e.position}%" stop-color="${e.color}"${t} />`},P=(e,t)=>{var r,a,i;return{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",background:t.backgroundStroke??((i=e.stops[0])==null?void 0:i.color)??t.activeStroke??"currentColor"}},A=(e,t)=>{var n;const r=(n=e.match(/\bviewBox=(["'])(.*?)\1/i))==null?void 0:n[2];if(r)return r;const a=t.width??240,i=t.height??120;return`0 0 ${a} ${i}`},N=e=>{var t;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},j=e=>{const t=e.trim().split(/(?=M\s*[-+.\d])/).map(r=>r.trim()).filter(Boolean);return t.length>1?t:[e]},O=e=>[...e.matchAll(/<path\b[^>]*\sd=(["'])([\s\S]*?)\1/gi)].flatMap(t=>j(t[2])),v=e=>{var t;return Math.max(1,((t=e.match(/[LlHhVvCcSsQqTtAaZz]/g))==null?void 0:t.length)??0)},T=(e,t)=>{const a=.5+(1-v(e)/t)*.22;return Math.round(a*1e3)/1e3},k=e=>{const[t="0",r="0",a="240",i="120"]=e.trim().split(/[\s,]+/);return{height:Number(i)||120,width:Number(a)||240,x:Number(t)||0,y:Number(r)||0}},V=(e,t,r)=>{if(r.viewBoxPadding===!1)return e;const a=k(e),i=Math.max(t*2,Math.min(a.width,a.height)*.02),n=r.viewBoxPadding??i;return[a.x-n,a.y-n,a.width+n*2,a.height+n*2].join(" ")},W=e=>{const{height:t,width:r}=k(e);return{height:Number(t)||120,width:Number(r)||240}},U=(e,t,r)=>{if(r.normalizeStrokeWidth===!1)return e;const{height:a,width:i}=W(t),n=r.strokeWidthBase??180;return e*(Math.min(i,a)/n)},S=(e,t={})=>{const r=t.id??"g-gradient",a=e.stops.map(x).join("");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(B.toCssGradient(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>`},q=(e,t={})=>{const r=t.id??"g-gradient",a=t.width??240,i=t.height??120,n=t.rx??18;return`<svg xmlns="${p}" viewBox="0 0 ${a} ${i}" role="img">
|
|
2
|
-
<defs>
|
|
3
|
-
${S(e,t)}
|
|
4
|
-
</defs>
|
|
5
|
-
<rect width="${a}" height="${i}" rx="${n}" fill="url(#${r})" />
|
|
6
|
-
</svg>`},z=(e,t,r={})=>{const i=`${r.id??"g-gradient-source"}-stroke`,n=A(e,r),d=N(e),o=O(e),s=U(r.strokeWidth??1.4,n,r),h=V(n,s,r),{width:m,x:g}=k(h),l=r.linecap??"round",u=$.toCssDuration(r.duration??3600),w=r.repeatCount??"indefinite",b=r.sourceOpacity??.22,M=t.stops.map(x).join(""),C=Math.max(...o.map(v));return`<svg xmlns="${p}" viewBox="${c(h)}" role="img">
|
|
7
|
-
<defs>
|
|
8
|
-
<linearGradient id="${i}" gradientUnits="userSpaceOnUse" x1="${g}" y1="0" x2="${g+m}" y2="0">
|
|
9
|
-
${M}
|
|
10
|
-
</linearGradient>
|
|
11
|
-
</defs>
|
|
12
|
-
<g opacity="${$.clamp(b)}">
|
|
13
|
-
${d}
|
|
14
|
-
</g>
|
|
15
|
-
<g fill="none" stroke="url(#${i})" stroke-width="${s}" stroke-linecap="${l}" stroke-linejoin="round">
|
|
16
|
-
${o.map(y=>{const f=T(y,C);return`<path d="${c(y)}" pathLength="100" stroke-dasharray="0 100" stroke-dashoffset="0">
|
|
17
|
-
<animate attributeName="stroke-dasharray" values="0 100;100 100;0 100" keyTimes="0;${f};1" dur="${u}" repeatCount="${w}" calcMode="linear" />
|
|
18
|
-
<animate attributeName="stroke-dashoffset" values="0;0;-100" keyTimes="0;${f};1" dur="${u}" repeatCount="${w}" calcMode="linear" />
|
|
19
|
-
</path>`}).join(`
|
|
20
|
-
`)}
|
|
21
|
-
</g>
|
|
22
|
-
</svg>`},E=(e,t={})=>{const a=`${t.id??"g-gradient-path"}-stroke`,i=t.width??240,n=t.height??120,d=t.path??`M 20 ${n*.64} C ${i*.28} ${n*.18}, ${i*.58} ${n*.18}, ${i-20} ${n*.64}`,o=t.strokeWidth??12,s=t.linecap??"round",h=$.toCssDuration(t.duration??2800),m=t.repeatCount??"indefinite",g=t.backgroundOpacity??.24,l=P(e,t),u=e.stops.map(x).join("");return`<svg xmlns="${p}" viewBox="0 0 ${i} ${n}" role="img">
|
|
23
|
-
<defs>
|
|
24
|
-
<linearGradient id="${a}" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="${i}" y2="0">
|
|
25
|
-
${u}
|
|
26
|
-
</linearGradient>
|
|
27
|
-
</defs>
|
|
28
|
-
<path d="${c(d)}" fill="none" stroke="${l.background}" stroke-width="${o}" stroke-linecap="${s}" opacity="${g}" />
|
|
29
|
-
<path d="${c(d)}" fill="none" stroke="${t.activeStroke?l.active:`url(#${a})`}" stroke-width="${o}" stroke-linecap="${s}" pathLength="100" stroke-dasharray="100 100" stroke-dashoffset="100">
|
|
30
|
-
<animate attributeName="stroke-dashoffset" values="100;0;-100" dur="${h}" repeatCount="${m}" />
|
|
31
|
-
</path>
|
|
32
|
-
</svg>`};exports.toSvgGradient=S;exports.toSvgGradientMarkup=q;exports.toSvgPathAnimationMarkup=E;exports.toSvgSourceAnimationMarkup=z;
|
package/dist/svg-hZus3ztj.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { t as y, b as v } from "./utils-BzSNCfat.js";
|
|
2
|
-
import { t as C } from "./css-DVaTTIqS.js";
|
|
3
|
-
const m = "http://www.w3.org/2000/svg", G = "http://www.w3.org/1999/xhtml", c = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">"), 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
|
-
};
|
package/dist/types-BMLEvdee.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const o=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D="hard-light";exports.DEFAULT_GRADIENT_MORPH_BLEND_MODE=D;exports.GRADIENT_MORPH_BLEND_MODES=o;
|
package/dist/utils-BzSNCfat.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const o = (t, n = 0, r = 1) => Math.min(r, Math.max(n, t)), a = (t) => {
|
|
2
|
-
const n = t / 255;
|
|
3
|
-
return n <= 0.04045 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4;
|
|
4
|
-
}, i = (t) => {
|
|
5
|
-
const n = t.slice(1), r = n.length === 3 || n.length === 4 ? n.slice(0, 3).split("").map((s) => s.repeat(2)).join("") : n.slice(0, 6);
|
|
6
|
-
return r.length !== 6 || !/^[\da-f]{6}$/i.test(r) ? null : {
|
|
7
|
-
r: parseInt(r.slice(0, 2), 16),
|
|
8
|
-
g: parseInt(r.slice(2, 4), 16),
|
|
9
|
-
b: parseInt(r.slice(4, 6), 16)
|
|
10
|
-
};
|
|
11
|
-
}, f = (t) => {
|
|
12
|
-
const n = t.match(
|
|
13
|
-
/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/i
|
|
14
|
-
);
|
|
15
|
-
return n ? {
|
|
16
|
-
r: o(Number(n[1]), 0, 255),
|
|
17
|
-
g: o(Number(n[2]), 0, 255),
|
|
18
|
-
b: o(Number(n[3]), 0, 255)
|
|
19
|
-
} : null;
|
|
20
|
-
}, e = (t) => {
|
|
21
|
-
if (typeof t == "number") {
|
|
22
|
-
const r = t & 16777215;
|
|
23
|
-
return {
|
|
24
|
-
r: r >> 16 & 255,
|
|
25
|
-
g: r >> 8 & 255,
|
|
26
|
-
b: r & 255
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const n = t.trim();
|
|
30
|
-
return n.startsWith("#") ? i(n) : n.toLowerCase().startsWith("rgb") ? f(n) : null;
|
|
31
|
-
}, u = ({ r: t, g: n, b: r }) => `#${[t, n, r].map((s) => Math.round(s).toString(16).padStart(2, "0")).join("")}`, l = ({ r: t, g: n, b: r }) => `${Math.round(t)}, ${Math.round(n)}, ${Math.round(r)}`, g = (t, n) => {
|
|
32
|
-
const r = e(t) ?? e(n);
|
|
33
|
-
if (!r)
|
|
34
|
-
throw new Error(`Invalid fallback color: ${n}`);
|
|
35
|
-
return u(r);
|
|
36
|
-
}, m = (t) => 0.2126 * a(t.r) + 0.7152 * a(t.g) + 0.0722 * a(t.b), d = (t) => {
|
|
37
|
-
const n = e(t);
|
|
38
|
-
if (!n) return "#ffffff";
|
|
39
|
-
const r = m(n), s = 1.05 / (r + 0.05), c = (r + 0.05) / 0.055;
|
|
40
|
-
return s >= c ? "#ffffff" : "#0d0d12";
|
|
41
|
-
}, b = 135, I = "center", $ = "farthest-corner", C = (t = 135) => typeof t == "number" ? `${t}deg` : t, T = (t) => typeof t == "number" ? `${t}px` : t, D = (t) => typeof t == "number" ? `${t}ms` : t, p = (t, n = 0, r = 1) => Math.min(r, Math.max(n, t)), h = (t, n) => {
|
|
42
|
-
if (n === void 0) return t;
|
|
43
|
-
const r = e(t);
|
|
44
|
-
return r ? `rgb(${l(r).replace(/,/g, "")} / ${p(n)})` : t;
|
|
45
|
-
}, E = ({ color: t, opacity: n, position: r }) => `${h(t, n)} ${r}%`, N = (t, n, r) => ({
|
|
46
|
-
color: t,
|
|
47
|
-
position: n
|
|
48
|
-
}), x = (t) => {
|
|
49
|
-
if (t.length <= 1) return t;
|
|
50
|
-
const n = t.map((s) => ({
|
|
51
|
-
...s,
|
|
52
|
-
position: s.position / 2
|
|
53
|
-
})), r = [...t].reverse().map((s) => ({
|
|
54
|
-
...s,
|
|
55
|
-
position: 100 - s.position / 2
|
|
56
|
-
}));
|
|
57
|
-
return [...n, ...r];
|
|
58
|
-
};
|
|
59
|
-
export {
|
|
60
|
-
b as D,
|
|
61
|
-
u as a,
|
|
62
|
-
p as b,
|
|
63
|
-
g as c,
|
|
64
|
-
$ as d,
|
|
65
|
-
I as e,
|
|
66
|
-
E as f,
|
|
67
|
-
d as g,
|
|
68
|
-
x as h,
|
|
69
|
-
N as i,
|
|
70
|
-
h as j,
|
|
71
|
-
T as k,
|
|
72
|
-
C as n,
|
|
73
|
-
e as p,
|
|
74
|
-
l as r,
|
|
75
|
-
D as t
|
|
76
|
-
};
|
package/dist/utils-D83DMCMa.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=(t,n=0,r=1)=>Math.min(r,Math.max(n,t)),a=t=>{const n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},m=t=>{const n=t.slice(1),r=n.length===3||n.length===4?n.slice(0,3).split("").map(o=>o.repeat(2)).join(""):n.slice(0,6);return r.length!==6||!/^[\da-f]{6}$/i.test(r)?null:{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}},p=t=>{const n=t.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/i);return n?{r:s(Number(n[1]),0,255),g:s(Number(n[2]),0,255),b:s(Number(n[3]),0,255)}:null},e=t=>{if(typeof t=="number"){const r=t&16777215;return{r:r>>16&255,g:r>>8&255,b:r&255}}const n=t.trim();return n.startsWith("#")?m(n):n.toLowerCase().startsWith("rgb")?p(n):null},c=({r:t,g:n,b:r})=>`#${[t,n,r].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("")}`,i=({r:t,g:n,b:r})=>`${Math.round(t)}, ${Math.round(n)}, ${Math.round(r)}`,T=(t,n)=>{const r=e(t)??e(n);if(!r)throw new Error(`Invalid fallback color: ${n}`);return c(r)},g=t=>.2126*a(t.r)+.7152*a(t.g)+.0722*a(t.b),I=t=>{const n=e(t);if(!n)return"#ffffff";const r=g(n),o=1.05/(r+.05),u=(r+.05)/.055;return o>=u?"#ffffff":"#0d0d12"};const h="center",C="farthest-corner",D=(t=135)=>typeof t=="number"?`${t}deg`:t,E=t=>typeof t=="number"?`${t}px`:t,b=t=>typeof t=="number"?`${t}ms`:t,l=(t,n=0,r=1)=>Math.min(r,Math.max(n,t)),f=(t,n)=>{if(n===void 0)return t;const r=e(t);return r?`rgb(${i(r).replace(/,/g,"")} / ${l(n)})`:t},d=({color:t,opacity:n,position:r})=>`${f(t,n)} ${r}%`,N=(t,n,r)=>({color:t,position:n}),A=t=>{if(t.length<=1)return t;const n=t.map(o=>({...o,position:o.position/2})),r=[...t].reverse().map(o=>({...o,position:100-o.position/2}));return[...n,...r]};exports.DEFAULT_GRADIENT_DIRECTION=135;exports.DEFAULT_GRADIENT_POSITION=h;exports.DEFAULT_GRADIENT_SIZE=C;exports.clamp=l;exports.colorToHex=T;exports.createStop=N;exports.formatStop=d;exports.getConicStops=A;exports.getContrastingColor=I;exports.normalizeDirection=D;exports.parseColor=e;exports.rgbToChannels=i;exports.rgbToHex=c;exports.toCssColor=f;exports.toCssDuration=b;exports.toCssLength=E;
|