storybook 10.2.0-alpha.0 → 10.2.0-alpha.2
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/dist/_browser-chunks/Color-E5XDEOX4.js +484 -0
- package/dist/_browser-chunks/{WithTooltip-IO6J4KBT.js → WithTooltip-65CFNBJE.js} +70 -70
- package/dist/_browser-chunks/{chunk-45UGUKRX.js → chunk-242VQQM5.js} +1 -1
- package/dist/_browser-chunks/chunk-2NDLAB5X.js +363 -0
- package/dist/_browser-chunks/{chunk-JP7NCOJX.js → chunk-3LY4VQVK.js} +1 -1
- package/dist/_browser-chunks/{chunk-XJNX76GA.js → chunk-54PNNATT.js} +3 -20
- package/dist/_browser-chunks/{chunk-VYJQ7RU5.js → chunk-6QKNWBQB.js} +17 -17
- package/dist/_browser-chunks/chunk-CLSHX4VX.js +4140 -0
- package/dist/_browser-chunks/{chunk-2XZMBGTA.js → chunk-DOSERVNW.js} +1 -1
- package/dist/_browser-chunks/chunk-HPYUT3WS.js +199 -0
- package/dist/_browser-chunks/{chunk-BRX2HXH7.js → chunk-IH6QJILI.js} +1 -1
- package/dist/_browser-chunks/{chunk-AS2HQEYC.js → chunk-IWQGIXJS.js} +1 -1
- package/dist/_browser-chunks/{chunk-UD6FQLAF.js → chunk-JK6U3MQW.js} +3 -3
- package/dist/_browser-chunks/{chunk-CHUV5WSW.js → chunk-LE2LTDW3.js} +1 -1
- package/dist/_browser-chunks/{chunk-RP5RXKFU.js → chunk-MOYJJEXA.js} +38 -29
- package/dist/_browser-chunks/chunk-NZMVUW5T.js +7 -0
- package/dist/_browser-chunks/{chunk-AXG2BOBL.js → chunk-S6TK43XQ.js} +10 -10
- package/dist/_browser-chunks/{chunk-H6XK3RSC.js → chunk-UAYGIC3L.js} +6 -6
- package/dist/_browser-chunks/{chunk-YKE5S47A.js → chunk-V2VKKSMQ.js} +18 -18
- package/dist/_browser-chunks/chunk-VIJ7SQRO.js +568 -0
- package/dist/_browser-chunks/chunk-XCZK5QUJ.js +0 -0
- package/dist/_browser-chunks/{chunk-3OXGAGBE.js → chunk-XLJZ7AOP.js} +14 -14
- package/dist/_browser-chunks/{chunk-SS2NHR7W.js → chunk-Y6HZAT53.js} +10 -12
- package/dist/_browser-chunks/{chunk-P4F4UVXX.js → chunk-YKABRMAI.js} +15 -15
- package/dist/_browser-chunks/{chunk-WJYERY3R.js → chunk-ZCFV7BZB.js} +2 -2
- package/dist/_browser-chunks/{formatter-QJ4M4OGQ.js → formatter-EIJCOSYU.js} +2 -2
- package/dist/_browser-chunks/{syntaxhighlighter-IQDEPFLK.js → syntaxhighlighter-ED5Y7EFY.js} +119 -119
- package/dist/_node-chunks/{builder-manager-7Y5SBM27.js → builder-manager-ZK4QXZNX.js} +22 -22
- package/dist/_node-chunks/{camelcase-VIOG5GUK.js → camelcase-QWQG7I72.js} +8 -8
- package/dist/_node-chunks/{chunk-G2SSRQRU.js → chunk-2AFVBCGF.js} +6 -6
- package/dist/_node-chunks/{chunk-YS4ZBVQ2.js → chunk-5VZMCPTH.js} +18 -18
- package/dist/_node-chunks/{chunk-RZYKYZNC.js → chunk-6OZRMRVO.js} +31 -31
- package/dist/_node-chunks/chunk-CLCLRZYL.js +61 -0
- package/dist/_node-chunks/{chunk-6I6BDAIH.js → chunk-CW7HJRCY.js} +9 -9
- package/dist/_node-chunks/chunk-DF3QP62W.js +18 -0
- package/dist/_node-chunks/{chunk-RQYJV7HO.js → chunk-DWVHBQGR.js} +165 -191
- package/dist/_node-chunks/chunk-EVBCPGQO.js +20 -0
- package/dist/_node-chunks/{chunk-NSWP6O57.js → chunk-EXZXVBZO.js} +8 -8
- package/dist/_node-chunks/{chunk-46UKK4ME.js → chunk-FZFZ5TOM.js} +9 -9
- package/dist/_node-chunks/{chunk-IIAWDLTX.js → chunk-GKEAARBQ.js} +10 -10
- package/dist/_node-chunks/{chunk-RFI7ULWH.js → chunk-HMFROKHU.js} +19 -19
- package/dist/_node-chunks/{chunk-KKTHRW4D.js → chunk-I5TOD3AY.js} +66 -72
- package/dist/_node-chunks/{chunk-MTAECA6H.js → chunk-KVNLJSAB.js} +619 -148
- package/dist/_node-chunks/{chunk-DGCZNDMZ.js → chunk-NKOHF7TQ.js} +10 -10
- package/dist/_node-chunks/{chunk-4APIDVTW.js → chunk-OV2CP4VV.js} +7 -7
- package/dist/_node-chunks/chunk-PCMFKXWQ.js +23 -0
- package/dist/_node-chunks/{chunk-T3T35CKM.js → chunk-Q5ZQH2OQ.js} +15 -15
- package/dist/_node-chunks/{chunk-VMPPKUVU.js → chunk-QFSK4B7R.js} +8 -8
- package/dist/_node-chunks/{chunk-WOPURGV3.js → chunk-R2J3OB3H.js} +6 -6
- package/dist/_node-chunks/{chunk-UCXU3VCO.js → chunk-RGQC4G3L.js} +165 -21
- package/dist/_node-chunks/{chunk-KX2RIBIP.js → chunk-TOXVUAH2.js} +6 -6
- package/dist/_node-chunks/{chunk-XE4QTYSE.js → chunk-URBB5EGY.js} +8 -8
- package/dist/_node-chunks/{chunk-XCRYZZCA.js → chunk-UWJ4BOOL.js} +597 -593
- package/dist/_node-chunks/{chunk-RTFXQIIL.js → chunk-VJPI73BB.js} +230 -236
- package/dist/_node-chunks/{chunk-I7HQSEQK.js → chunk-WOS3OQVT.js} +6 -6
- package/dist/_node-chunks/{chunk-UGZX6OPP.js → chunk-WUKWNPSQ.js} +17 -17
- package/dist/_node-chunks/{chunk-2265F7MI.js → chunk-XFU23B4C.js} +9 -9
- package/dist/_node-chunks/{dist-GV3REIPT.js → dist-UBFMIJZC.js} +10 -10
- package/dist/_node-chunks/{globby-QE4LR4PT.js → globby-VD3CGPVI.js} +154 -154
- package/dist/_node-chunks/{lib-NXQ5B2WJ.js → lib-MMJB47J3.js} +16 -16
- package/dist/_node-chunks/{mdx-N42X6CFJ-IGCQXXC5.js → mdx-N42X6CFJ-3J2G7NZZ.js} +11 -11
- package/dist/_node-chunks/{p-limit-S2V3UH5Q.js → p-limit-SOBWTEVH.js} +8 -8
- package/dist/babel/index.js +10 -10
- package/dist/bin/core.js +28 -28
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +14 -11
- package/dist/channels/index.js +3 -3
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +18 -18
- package/dist/common/index.js +19 -19
- package/dist/components/index.d.ts +9 -2
- package/dist/components/index.js +327 -311
- package/dist/core-server/index.js +127 -127
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +43 -38
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +4390 -173
- package/dist/csf/index.js +39 -35
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -5
- package/dist/instrumenter/index.js +1 -1
- package/dist/manager/globals-runtime.js +18956 -12602
- package/dist/manager/runtime.js +148 -132
- package/dist/manager-api/index.js +31 -22
- package/dist/mocking-utils/index.js +14 -14
- package/dist/node-logger/index.d.ts +2 -2
- package/dist/node-logger/index.js +9 -9
- package/dist/preview/runtime.js +30784 -24388
- package/dist/preview-api/index.js +12 -11
- package/dist/preview-errors.js +2 -2
- package/dist/router/index.js +12 -13
- package/dist/server-errors.js +11 -11
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +23 -23
- package/dist/test/index.js +3104 -1604
- package/dist/theming/create.js +3 -3
- package/dist/theming/index.js +38 -38
- package/package.json +2 -8
- package/dist/_browser-chunks/Color-TNPFN3FC.js +0 -1097
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +0 -171
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +0 -252
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +0 -18
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +0 -64
- package/dist/_browser-chunks/chunk-QKODTO7K.js +0 -7
- package/dist/_node-chunks/chunk-5JSWIKE2.js +0 -18
- package/dist/_node-chunks/chunk-BJMYJWGF.js +0 -20
- package/dist/_node-chunks/chunk-BYYI4JA6.js +0 -61
- package/dist/_node-chunks/chunk-RQ4GZHOA.js +0 -23
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getControlId
|
|
3
|
+
} from "./chunk-2FRVAXCZ.js";
|
|
4
|
+
import {
|
|
5
|
+
require_color_convert
|
|
6
|
+
} from "./chunk-VIJ7SQRO.js";
|
|
7
|
+
import {
|
|
8
|
+
debounce
|
|
9
|
+
} from "./chunk-HPYUT3WS.js";
|
|
10
|
+
import "./chunk-NZMVUW5T.js";
|
|
11
|
+
import {
|
|
12
|
+
__toESM
|
|
13
|
+
} from "./chunk-A242L54C.js";
|
|
14
|
+
|
|
15
|
+
// ../addons/docs/src/blocks/controls/Color.tsx
|
|
16
|
+
var import_color_convert = __toESM(require_color_convert(), 1);
|
|
17
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
18
|
+
import { Button, Form, PopoverProvider } from "storybook/internal/components";
|
|
19
|
+
import { MarkupIcon } from "@storybook/icons";
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/react-colorful/dist/index.mjs
|
|
22
|
+
import e, { useRef as r, useMemo as t, useEffect as n, useState as o, useCallback as a, useLayoutEffect as l } from "react";
|
|
23
|
+
function u() {
|
|
24
|
+
return (u = Object.assign || function(e2) {
|
|
25
|
+
for (var r2 = 1; r2 < arguments.length; r2++) {
|
|
26
|
+
var t2 = arguments[r2];
|
|
27
|
+
for (var n2 in t2) Object.prototype.hasOwnProperty.call(t2, n2) && (e2[n2] = t2[n2]);
|
|
28
|
+
}
|
|
29
|
+
return e2;
|
|
30
|
+
}).apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
function c(e2, r2) {
|
|
33
|
+
if (e2 == null) return {};
|
|
34
|
+
var t2, n2, o2 = {}, a2 = Object.keys(e2);
|
|
35
|
+
for (n2 = 0; n2 < a2.length; n2++) r2.indexOf(t2 = a2[n2]) >= 0 || (o2[t2] = e2[t2]);
|
|
36
|
+
return o2;
|
|
37
|
+
}
|
|
38
|
+
function i(e2) {
|
|
39
|
+
var t2 = r(e2), n2 = r(function(e3) {
|
|
40
|
+
t2.current && t2.current(e3);
|
|
41
|
+
});
|
|
42
|
+
return t2.current = e2, n2.current;
|
|
43
|
+
}
|
|
44
|
+
var s = function(e2, r2, t2) {
|
|
45
|
+
return r2 === void 0 && (r2 = 0), t2 === void 0 && (t2 = 1), e2 > t2 ? t2 : e2 < r2 ? r2 : e2;
|
|
46
|
+
}, f = function(e2) {
|
|
47
|
+
return "touches" in e2;
|
|
48
|
+
}, v = function(e2) {
|
|
49
|
+
return e2 && e2.ownerDocument.defaultView || self;
|
|
50
|
+
}, d = function(e2, r2, t2) {
|
|
51
|
+
var n2 = e2.getBoundingClientRect(), o2 = f(r2) ? (function(e3, r3) {
|
|
52
|
+
for (var t3 = 0; t3 < e3.length; t3++) if (e3[t3].identifier === r3) return e3[t3];
|
|
53
|
+
return e3[0];
|
|
54
|
+
})(r2.touches, t2) : r2;
|
|
55
|
+
return { left: s((o2.pageX - (n2.left + v(e2).pageXOffset)) / n2.width), top: s((o2.pageY - (n2.top + v(e2).pageYOffset)) / n2.height) };
|
|
56
|
+
}, h = function(e2) {
|
|
57
|
+
!f(e2) && e2.preventDefault();
|
|
58
|
+
}, m = e.memo(function(o2) {
|
|
59
|
+
var a2 = o2.onMove, l2 = o2.onKey, s2 = c(o2, ["onMove", "onKey"]), m2 = r(null), g2 = i(a2), p2 = i(l2), b2 = r(null), _2 = r(!1), x2 = t(function() {
|
|
60
|
+
var e2 = function(e3) {
|
|
61
|
+
h(e3), (f(e3) ? e3.touches.length > 0 : e3.buttons > 0) && m2.current ? g2(d(m2.current, e3, b2.current)) : t2(!1);
|
|
62
|
+
}, r2 = function() {
|
|
63
|
+
return t2(!1);
|
|
64
|
+
};
|
|
65
|
+
function t2(t3) {
|
|
66
|
+
var n2 = _2.current, o3 = v(m2.current), a3 = t3 ? o3.addEventListener : o3.removeEventListener;
|
|
67
|
+
a3(n2 ? "touchmove" : "mousemove", e2), a3(n2 ? "touchend" : "mouseup", r2);
|
|
68
|
+
}
|
|
69
|
+
return [function(e3) {
|
|
70
|
+
var r3 = e3.nativeEvent, n2 = m2.current;
|
|
71
|
+
if (n2 && (h(r3), !(function(e4, r4) {
|
|
72
|
+
return r4 && !f(e4);
|
|
73
|
+
})(r3, _2.current) && n2)) {
|
|
74
|
+
if (f(r3)) {
|
|
75
|
+
_2.current = !0;
|
|
76
|
+
var o3 = r3.changedTouches || [];
|
|
77
|
+
o3.length && (b2.current = o3[0].identifier);
|
|
78
|
+
}
|
|
79
|
+
n2.focus(), g2(d(n2, r3, b2.current)), t2(!0);
|
|
80
|
+
}
|
|
81
|
+
}, function(e3) {
|
|
82
|
+
var r3 = e3.which || e3.keyCode;
|
|
83
|
+
r3 < 37 || r3 > 40 || (e3.preventDefault(), p2({ left: r3 === 39 ? 0.05 : r3 === 37 ? -0.05 : 0, top: r3 === 40 ? 0.05 : r3 === 38 ? -0.05 : 0 }));
|
|
84
|
+
}, t2];
|
|
85
|
+
}, [p2, g2]), C2 = x2[0], E2 = x2[1], H2 = x2[2];
|
|
86
|
+
return n(function() {
|
|
87
|
+
return H2;
|
|
88
|
+
}, [H2]), e.createElement("div", u({}, s2, { onTouchStart: C2, onMouseDown: C2, className: "react-colorful__interactive", ref: m2, onKeyDown: E2, tabIndex: 0, role: "slider" }));
|
|
89
|
+
}), g = function(e2) {
|
|
90
|
+
return e2.filter(Boolean).join(" ");
|
|
91
|
+
}, p = function(r2) {
|
|
92
|
+
var t2 = r2.color, n2 = r2.left, o2 = r2.top, a2 = o2 === void 0 ? 0.5 : o2, l2 = g(["react-colorful__pointer", r2.className]);
|
|
93
|
+
return e.createElement("div", { className: l2, style: { top: 100 * a2 + "%", left: 100 * n2 + "%" } }, e.createElement("div", { className: "react-colorful__pointer-fill", style: { backgroundColor: t2 } }));
|
|
94
|
+
}, b = function(e2, r2, t2) {
|
|
95
|
+
return r2 === void 0 && (r2 = 0), t2 === void 0 && (t2 = Math.pow(10, r2)), Math.round(t2 * e2) / t2;
|
|
96
|
+
}, _ = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, x = function(e2) {
|
|
97
|
+
return L(C(e2));
|
|
98
|
+
}, C = function(e2) {
|
|
99
|
+
return e2[0] === "#" && (e2 = e2.substring(1)), e2.length < 6 ? { r: parseInt(e2[0] + e2[0], 16), g: parseInt(e2[1] + e2[1], 16), b: parseInt(e2[2] + e2[2], 16), a: e2.length === 4 ? b(parseInt(e2[3] + e2[3], 16) / 255, 2) : 1 } : { r: parseInt(e2.substring(0, 2), 16), g: parseInt(e2.substring(2, 4), 16), b: parseInt(e2.substring(4, 6), 16), a: e2.length === 8 ? b(parseInt(e2.substring(6, 8), 16) / 255, 2) : 1 };
|
|
100
|
+
}, E = function(e2, r2) {
|
|
101
|
+
return r2 === void 0 && (r2 = "deg"), Number(e2) * (_[r2] || 1);
|
|
102
|
+
}, H = function(e2) {
|
|
103
|
+
var r2 = /hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e2);
|
|
104
|
+
return r2 ? N({ h: E(r2[1], r2[2]), s: Number(r2[3]), l: Number(r2[4]), a: r2[5] === void 0 ? 1 : Number(r2[5]) / (r2[6] ? 100 : 1) }) : { h: 0, s: 0, v: 0, a: 1 };
|
|
105
|
+
};
|
|
106
|
+
var N = function(e2) {
|
|
107
|
+
var r2 = e2.s, t2 = e2.l;
|
|
108
|
+
return { h: e2.h, s: (r2 *= (t2 < 50 ? t2 : 100 - t2) / 100) > 0 ? 2 * r2 / (t2 + r2) * 100 : 0, v: t2 + r2, a: e2.a };
|
|
109
|
+
}, w = function(e2) {
|
|
110
|
+
return K(I(e2));
|
|
111
|
+
}, y = function(e2) {
|
|
112
|
+
var r2 = e2.s, t2 = e2.v, n2 = e2.a, o2 = (200 - r2) * t2 / 100;
|
|
113
|
+
return { h: b(e2.h), s: b(o2 > 0 && o2 < 200 ? r2 * t2 / 100 / (o2 <= 100 ? o2 : 200 - o2) * 100 : 0), l: b(o2 / 2), a: b(n2, 2) };
|
|
114
|
+
}, q = function(e2) {
|
|
115
|
+
var r2 = y(e2);
|
|
116
|
+
return "hsl(" + r2.h + ", " + r2.s + "%, " + r2.l + "%)";
|
|
117
|
+
}, k = function(e2) {
|
|
118
|
+
var r2 = y(e2);
|
|
119
|
+
return "hsla(" + r2.h + ", " + r2.s + "%, " + r2.l + "%, " + r2.a + ")";
|
|
120
|
+
}, I = function(e2) {
|
|
121
|
+
var r2 = e2.h, t2 = e2.s, n2 = e2.v, o2 = e2.a;
|
|
122
|
+
r2 = r2 / 360 * 6, t2 /= 100, n2 /= 100;
|
|
123
|
+
var a2 = Math.floor(r2), l2 = n2 * (1 - t2), u2 = n2 * (1 - (r2 - a2) * t2), c2 = n2 * (1 - (1 - r2 + a2) * t2), i2 = a2 % 6;
|
|
124
|
+
return { r: b(255 * [n2, u2, l2, l2, c2, n2][i2]), g: b(255 * [c2, n2, n2, u2, l2, l2][i2]), b: b(255 * [l2, l2, c2, n2, n2, u2][i2]), a: b(o2, 2) };
|
|
125
|
+
};
|
|
126
|
+
var z = function(e2) {
|
|
127
|
+
var r2 = /rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e2);
|
|
128
|
+
return r2 ? L({ r: Number(r2[1]) / (r2[2] ? 100 / 255 : 1), g: Number(r2[3]) / (r2[4] ? 100 / 255 : 1), b: Number(r2[5]) / (r2[6] ? 100 / 255 : 1), a: r2[7] === void 0 ? 1 : Number(r2[7]) / (r2[8] ? 100 : 1) }) : { h: 0, s: 0, v: 0, a: 1 };
|
|
129
|
+
};
|
|
130
|
+
var D = function(e2) {
|
|
131
|
+
var r2 = e2.toString(16);
|
|
132
|
+
return r2.length < 2 ? "0" + r2 : r2;
|
|
133
|
+
}, K = function(e2) {
|
|
134
|
+
var r2 = e2.r, t2 = e2.g, n2 = e2.b, o2 = e2.a, a2 = o2 < 1 ? D(b(255 * o2)) : "";
|
|
135
|
+
return "#" + D(r2) + D(t2) + D(n2) + a2;
|
|
136
|
+
}, L = function(e2) {
|
|
137
|
+
var r2 = e2.r, t2 = e2.g, n2 = e2.b, o2 = e2.a, a2 = Math.max(r2, t2, n2), l2 = a2 - Math.min(r2, t2, n2), u2 = l2 ? a2 === r2 ? (t2 - n2) / l2 : a2 === t2 ? 2 + (n2 - r2) / l2 : 4 + (r2 - t2) / l2 : 0;
|
|
138
|
+
return { h: b(60 * (u2 < 0 ? u2 + 6 : u2)), s: b(a2 ? l2 / a2 * 100 : 0), v: b(a2 / 255 * 100), a: o2 };
|
|
139
|
+
};
|
|
140
|
+
var S = e.memo(function(r2) {
|
|
141
|
+
var t2 = r2.hue, n2 = r2.onChange, o2 = g(["react-colorful__hue", r2.className]);
|
|
142
|
+
return e.createElement("div", { className: o2 }, e.createElement(m, { onMove: function(e2) {
|
|
143
|
+
n2({ h: 360 * e2.left });
|
|
144
|
+
}, onKey: function(e2) {
|
|
145
|
+
n2({ h: s(t2 + 360 * e2.left, 0, 360) });
|
|
146
|
+
}, "aria-label": "Hue", "aria-valuenow": b(t2), "aria-valuemax": "360", "aria-valuemin": "0" }, e.createElement(p, { className: "react-colorful__hue-pointer", left: t2 / 360, color: q({ h: t2, s: 100, v: 100, a: 1 }) })));
|
|
147
|
+
}), T = e.memo(function(r2) {
|
|
148
|
+
var t2 = r2.hsva, n2 = r2.onChange, o2 = { backgroundColor: q({ h: t2.h, s: 100, v: 100, a: 1 }) };
|
|
149
|
+
return e.createElement("div", { className: "react-colorful__saturation", style: o2 }, e.createElement(m, { onMove: function(e2) {
|
|
150
|
+
n2({ s: 100 * e2.left, v: 100 - 100 * e2.top });
|
|
151
|
+
}, onKey: function(e2) {
|
|
152
|
+
n2({ s: s(t2.s + 100 * e2.left, 0, 100), v: s(t2.v - 100 * e2.top, 0, 100) });
|
|
153
|
+
}, "aria-label": "Color", "aria-valuetext": "Saturation " + b(t2.s) + "%, Brightness " + b(t2.v) + "%" }, e.createElement(p, { className: "react-colorful__saturation-pointer", top: 1 - t2.v / 100, left: t2.s / 100, color: q(t2) })));
|
|
154
|
+
}), F = function(e2, r2) {
|
|
155
|
+
if (e2 === r2) return !0;
|
|
156
|
+
for (var t2 in e2) if (e2[t2] !== r2[t2]) return !1;
|
|
157
|
+
return !0;
|
|
158
|
+
}, P = function(e2, r2) {
|
|
159
|
+
return e2.replace(/\s/g, "") === r2.replace(/\s/g, "");
|
|
160
|
+
}, X = function(e2, r2) {
|
|
161
|
+
return e2.toLowerCase() === r2.toLowerCase() || F(C(e2), C(r2));
|
|
162
|
+
};
|
|
163
|
+
function Y(e2, t2, l2) {
|
|
164
|
+
var u2 = i(l2), c2 = o(function() {
|
|
165
|
+
return e2.toHsva(t2);
|
|
166
|
+
}), s2 = c2[0], f2 = c2[1], v2 = r({ color: t2, hsva: s2 });
|
|
167
|
+
n(function() {
|
|
168
|
+
if (!e2.equal(t2, v2.current.color)) {
|
|
169
|
+
var r2 = e2.toHsva(t2);
|
|
170
|
+
v2.current = { hsva: r2, color: t2 }, f2(r2);
|
|
171
|
+
}
|
|
172
|
+
}, [t2, e2]), n(function() {
|
|
173
|
+
var r2;
|
|
174
|
+
F(s2, v2.current.hsva) || e2.equal(r2 = e2.fromHsva(s2), v2.current.color) || (v2.current = { hsva: s2, color: r2 }, u2(r2));
|
|
175
|
+
}, [s2, e2, u2]);
|
|
176
|
+
var d2 = a(function(e3) {
|
|
177
|
+
f2(function(r2) {
|
|
178
|
+
return Object.assign({}, r2, e3);
|
|
179
|
+
});
|
|
180
|
+
}, []);
|
|
181
|
+
return [s2, d2];
|
|
182
|
+
}
|
|
183
|
+
var R, V = typeof window < "u" ? l : n, $ = function() {
|
|
184
|
+
return R || (typeof __webpack_nonce__ < "u" ? __webpack_nonce__ : void 0);
|
|
185
|
+
};
|
|
186
|
+
var J = /* @__PURE__ */ new Map(), Q = function(e2) {
|
|
187
|
+
V(function() {
|
|
188
|
+
var r2 = e2.current ? e2.current.ownerDocument : document;
|
|
189
|
+
if (r2 !== void 0 && !J.has(r2)) {
|
|
190
|
+
var t2 = r2.createElement("style");
|
|
191
|
+
t2.innerHTML = `.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`, J.set(r2, t2);
|
|
192
|
+
var n2 = $();
|
|
193
|
+
n2 && t2.setAttribute("nonce", n2), r2.head.appendChild(t2);
|
|
194
|
+
}
|
|
195
|
+
}, []);
|
|
196
|
+
}, U = function(t2) {
|
|
197
|
+
var n2 = t2.className, o2 = t2.colorModel, a2 = t2.color, l2 = a2 === void 0 ? o2.defaultColor : a2, i2 = t2.onChange, s2 = c(t2, ["className", "colorModel", "color", "onChange"]), f2 = r(null);
|
|
198
|
+
Q(f2);
|
|
199
|
+
var v2 = Y(o2, l2, i2), d2 = v2[0], h2 = v2[1], m2 = g(["react-colorful", n2]);
|
|
200
|
+
return e.createElement("div", u({}, s2, { ref: f2, className: m2 }), e.createElement(T, { hsva: d2, onChange: h2 }), e.createElement(S, { hue: d2.h, onChange: h2, className: "react-colorful__last-control" }));
|
|
201
|
+
}, W = { defaultColor: "000", toHsva: x, fromHsva: function(e2) {
|
|
202
|
+
return w({ h: e2.h, s: e2.s, v: e2.v, a: 1 });
|
|
203
|
+
}, equal: X }, Z = function(r2) {
|
|
204
|
+
return e.createElement(U, u({}, r2, { colorModel: W }));
|
|
205
|
+
}, ee = function(r2) {
|
|
206
|
+
var t2 = r2.className, n2 = r2.hsva, o2 = r2.onChange, a2 = { backgroundImage: "linear-gradient(90deg, " + k(Object.assign({}, n2, { a: 0 })) + ", " + k(Object.assign({}, n2, { a: 1 })) + ")" }, l2 = g(["react-colorful__alpha", t2]), u2 = b(100 * n2.a);
|
|
207
|
+
return e.createElement("div", { className: l2 }, e.createElement("div", { className: "react-colorful__alpha-gradient", style: a2 }), e.createElement(m, { onMove: function(e2) {
|
|
208
|
+
o2({ a: e2.left });
|
|
209
|
+
}, onKey: function(e2) {
|
|
210
|
+
o2({ a: s(n2.a + e2.left) });
|
|
211
|
+
}, "aria-label": "Alpha", "aria-valuetext": u2 + "%", "aria-valuenow": u2, "aria-valuemin": "0", "aria-valuemax": "100" }, e.createElement(p, { className: "react-colorful__alpha-pointer", left: n2.a, color: k(n2) })));
|
|
212
|
+
}, re = function(t2) {
|
|
213
|
+
var n2 = t2.className, o2 = t2.colorModel, a2 = t2.color, l2 = a2 === void 0 ? o2.defaultColor : a2, i2 = t2.onChange, s2 = c(t2, ["className", "colorModel", "color", "onChange"]), f2 = r(null);
|
|
214
|
+
Q(f2);
|
|
215
|
+
var v2 = Y(o2, l2, i2), d2 = v2[0], h2 = v2[1], m2 = g(["react-colorful", n2]);
|
|
216
|
+
return e.createElement("div", u({}, s2, { ref: f2, className: m2 }), e.createElement(T, { hsva: d2, onChange: h2 }), e.createElement(S, { hue: d2.h, onChange: h2 }), e.createElement(ee, { hsva: d2, onChange: h2, className: "react-colorful__last-control" }));
|
|
217
|
+
};
|
|
218
|
+
var le = { defaultColor: "hsla(0, 0%, 0%, 1)", toHsva: H, fromHsva: k, equal: P }, ue = function(r2) {
|
|
219
|
+
return e.createElement(re, u({}, r2, { colorModel: le }));
|
|
220
|
+
};
|
|
221
|
+
var Ee = { defaultColor: "rgba(0, 0, 0, 1)", toHsva: z, fromHsva: function(e2) {
|
|
222
|
+
var r2 = I(e2);
|
|
223
|
+
return "rgba(" + r2.r + ", " + r2.g + ", " + r2.b + ", " + r2.a + ")";
|
|
224
|
+
}, equal: P }, He = function(r2) {
|
|
225
|
+
return e.createElement(re, u({}, r2, { colorModel: Ee }));
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// ../addons/docs/src/blocks/controls/Color.tsx
|
|
229
|
+
import { styled } from "storybook/theming";
|
|
230
|
+
var Wrapper = styled.div({
|
|
231
|
+
position: "relative",
|
|
232
|
+
maxWidth: 250
|
|
233
|
+
}), TooltipContent = styled.div({
|
|
234
|
+
width: 200,
|
|
235
|
+
margin: 5,
|
|
236
|
+
".react-colorful__saturation": {
|
|
237
|
+
borderRadius: "4px 4px 0 0"
|
|
238
|
+
},
|
|
239
|
+
".react-colorful__hue": {
|
|
240
|
+
boxShadow: "inset 0 0 0 1px rgb(0 0 0 / 5%)"
|
|
241
|
+
},
|
|
242
|
+
".react-colorful__last-control": {
|
|
243
|
+
borderRadius: "0 0 4px 4px"
|
|
244
|
+
}
|
|
245
|
+
}), Swatches = styled.div({
|
|
246
|
+
display: "grid",
|
|
247
|
+
gridTemplateColumns: "repeat(9, 16px)",
|
|
248
|
+
gap: 6,
|
|
249
|
+
padding: 3,
|
|
250
|
+
marginTop: 5,
|
|
251
|
+
width: 200
|
|
252
|
+
}), swatchBackground = (isDark) => `url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity="0.05" fill="${isDark ? "white" : "black"}"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')`, SwatchColor = styled(Button)(
|
|
253
|
+
({ value, selected, theme }) => ({
|
|
254
|
+
width: 16,
|
|
255
|
+
height: 16,
|
|
256
|
+
boxShadow: selected ? `${theme.appBorderColor} 0 0 0 1px inset, ${theme.textMutedColor}50 0 0 0 4px` : `${theme.appBorderColor} 0 0 0 1px inset`,
|
|
257
|
+
border: "none",
|
|
258
|
+
borderRadius: theme.appBorderRadius,
|
|
259
|
+
"&, &:hover": {
|
|
260
|
+
background: "unset",
|
|
261
|
+
backgroundColor: "unset",
|
|
262
|
+
backgroundImage: `linear-gradient(${value}, ${value}), ${swatchBackground(theme.base === "dark")}`
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
), Input = styled(Form.Input)(({ theme }) => ({
|
|
266
|
+
width: "100%",
|
|
267
|
+
paddingLeft: 30,
|
|
268
|
+
paddingRight: 30,
|
|
269
|
+
boxSizing: "border-box",
|
|
270
|
+
fontFamily: theme.typography.fonts.base,
|
|
271
|
+
'[aria-readonly="true"] > &': {
|
|
272
|
+
background: theme.base === "light" ? theme.color.lighter : "transparent"
|
|
273
|
+
}
|
|
274
|
+
})), PopoverTrigger = styled(SwatchColor)(({ disabled }) => ({
|
|
275
|
+
position: "absolute",
|
|
276
|
+
top: 4,
|
|
277
|
+
left: 4,
|
|
278
|
+
zIndex: 1,
|
|
279
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
280
|
+
})), CycleColorSpaceButton = styled(Button)(({ theme }) => ({
|
|
281
|
+
position: "absolute",
|
|
282
|
+
zIndex: 1,
|
|
283
|
+
top: 6,
|
|
284
|
+
right: 7,
|
|
285
|
+
width: 20,
|
|
286
|
+
height: 20,
|
|
287
|
+
padding: 4,
|
|
288
|
+
boxSizing: "border-box",
|
|
289
|
+
cursor: "pointer",
|
|
290
|
+
color: theme.input.color
|
|
291
|
+
})), ColorSpace = /* @__PURE__ */ ((ColorSpace2) => (ColorSpace2.RGB = "rgb", ColorSpace2.HSL = "hsl", ColorSpace2.HEX = "hex", ColorSpace2))(ColorSpace || {}), COLOR_SPACES = Object.values(ColorSpace), COLOR_REGEXP = /\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/, RGB_REGEXP = /^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i, HSL_REGEXP = /^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i, HEX_REGEXP = /^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i, SHORTHEX_REGEXP = /^\s*#?([0-9a-f]{3})\s*$/i, ColorPicker = {
|
|
292
|
+
hex: Z,
|
|
293
|
+
rgb: He,
|
|
294
|
+
hsl: ue
|
|
295
|
+
}, fallbackColor = {
|
|
296
|
+
hex: "transparent",
|
|
297
|
+
rgb: "rgba(0, 0, 0, 0)",
|
|
298
|
+
hsl: "hsla(0, 0%, 0%, 0)"
|
|
299
|
+
}, stringToArgs = (value) => {
|
|
300
|
+
let match = value?.match(COLOR_REGEXP);
|
|
301
|
+
if (!match)
|
|
302
|
+
return [0, 0, 0, 1];
|
|
303
|
+
let [, x2, y2, z2, a2 = 1] = match;
|
|
304
|
+
return [x2, y2, z2, a2].map(Number);
|
|
305
|
+
}, parseRgb = (value) => {
|
|
306
|
+
let [r2, g2, b2, a2] = stringToArgs(value), [h2, s2, l2] = import_color_convert.default.rgb.hsl([r2, g2, b2]) || [0, 0, 0];
|
|
307
|
+
return {
|
|
308
|
+
valid: !0,
|
|
309
|
+
value,
|
|
310
|
+
keyword: import_color_convert.default.rgb.keyword([r2, g2, b2]),
|
|
311
|
+
colorSpace: "rgb" /* RGB */,
|
|
312
|
+
rgb: value,
|
|
313
|
+
hsl: `hsla(${h2}, ${s2}%, ${l2}%, ${a2})`,
|
|
314
|
+
hex: `#${import_color_convert.default.rgb.hex([r2, g2, b2]).toLowerCase()}`
|
|
315
|
+
};
|
|
316
|
+
}, parseHsl = (value) => {
|
|
317
|
+
let [h2, s2, l2, a2] = stringToArgs(value), [r2, g2, b2] = import_color_convert.default.hsl.rgb([h2, s2, l2]) || [0, 0, 0];
|
|
318
|
+
return {
|
|
319
|
+
valid: !0,
|
|
320
|
+
value,
|
|
321
|
+
keyword: import_color_convert.default.hsl.keyword([h2, s2, l2]),
|
|
322
|
+
colorSpace: "hsl" /* HSL */,
|
|
323
|
+
rgb: `rgba(${r2}, ${g2}, ${b2}, ${a2})`,
|
|
324
|
+
hsl: value,
|
|
325
|
+
hex: `#${import_color_convert.default.hsl.hex([h2, s2, l2]).toLowerCase()}`
|
|
326
|
+
};
|
|
327
|
+
}, parseHexOrKeyword = (value) => {
|
|
328
|
+
let plain = value.replace("#", ""), rgb = import_color_convert.default.keyword.rgb(plain) || import_color_convert.default.hex.rgb(plain), hsl = import_color_convert.default.rgb.hsl(rgb), mapped = value;
|
|
329
|
+
/[^#a-f0-9]/i.test(value) ? mapped = plain : HEX_REGEXP.test(value) && (mapped = `#${plain}`);
|
|
330
|
+
let valid = !0;
|
|
331
|
+
if (mapped.startsWith("#"))
|
|
332
|
+
valid = HEX_REGEXP.test(mapped);
|
|
333
|
+
else
|
|
334
|
+
try {
|
|
335
|
+
import_color_convert.default.keyword.hex(mapped);
|
|
336
|
+
} catch {
|
|
337
|
+
valid = !1;
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
valid,
|
|
341
|
+
value: mapped,
|
|
342
|
+
keyword: import_color_convert.default.rgb.keyword(rgb),
|
|
343
|
+
colorSpace: "hex" /* HEX */,
|
|
344
|
+
rgb: `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, 1)`,
|
|
345
|
+
hsl: `hsla(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%, 1)`,
|
|
346
|
+
hex: mapped
|
|
347
|
+
};
|
|
348
|
+
}, parseValue = (value) => {
|
|
349
|
+
if (value)
|
|
350
|
+
return RGB_REGEXP.test(value) ? parseRgb(value) : HSL_REGEXP.test(value) ? parseHsl(value) : parseHexOrKeyword(value);
|
|
351
|
+
}, getRealValue = (value, color, colorSpace) => {
|
|
352
|
+
if (!value || !color?.valid)
|
|
353
|
+
return fallbackColor[colorSpace];
|
|
354
|
+
if (colorSpace !== "hex" /* HEX */)
|
|
355
|
+
return color?.[colorSpace] || fallbackColor[colorSpace];
|
|
356
|
+
if (!color.hex.startsWith("#"))
|
|
357
|
+
try {
|
|
358
|
+
return `#${import_color_convert.default.keyword.hex(color.hex)}`;
|
|
359
|
+
} catch {
|
|
360
|
+
return fallbackColor.hex;
|
|
361
|
+
}
|
|
362
|
+
let short = color.hex.match(SHORTHEX_REGEXP);
|
|
363
|
+
if (!short)
|
|
364
|
+
return HEX_REGEXP.test(color.hex) ? color.hex : fallbackColor.hex;
|
|
365
|
+
let [r2, g2, b2] = short[1].split("");
|
|
366
|
+
return `#${r2}${r2}${g2}${g2}${b2}${b2}`;
|
|
367
|
+
}, useColorInput = (initialValue, onChange) => {
|
|
368
|
+
let [value, setValue] = useState(initialValue || ""), [color, setColor] = useState(() => parseValue(value)), [colorSpace, setColorSpace] = useState(color?.colorSpace || "hex" /* HEX */);
|
|
369
|
+
useEffect(() => {
|
|
370
|
+
let nextValue = initialValue || "", nextColor = parseValue(nextValue);
|
|
371
|
+
setValue(nextValue), setColor(nextColor), setColorSpace(nextColor?.colorSpace || "hex" /* HEX */);
|
|
372
|
+
}, [initialValue]);
|
|
373
|
+
let realValue = useMemo(
|
|
374
|
+
() => getRealValue(value, color, colorSpace).toLowerCase(),
|
|
375
|
+
[value, color, colorSpace]
|
|
376
|
+
), updateValue = useCallback(
|
|
377
|
+
(update) => {
|
|
378
|
+
let parsed = parseValue(update), v2 = parsed?.value || update || "";
|
|
379
|
+
setValue(v2), v2 === "" && (setColor(void 0), onChange(void 0)), parsed && (setColor(parsed), setColorSpace(parsed.colorSpace), onChange(parsed.value));
|
|
380
|
+
},
|
|
381
|
+
[onChange]
|
|
382
|
+
), cycleColorSpace = useCallback(() => {
|
|
383
|
+
let nextIndex = (COLOR_SPACES.indexOf(colorSpace) + 1) % COLOR_SPACES.length, nextSpace = COLOR_SPACES[nextIndex];
|
|
384
|
+
setColorSpace(nextSpace);
|
|
385
|
+
let updatedValue = color?.[nextSpace] || "";
|
|
386
|
+
setValue(updatedValue), onChange(updatedValue);
|
|
387
|
+
}, [color, colorSpace, onChange]);
|
|
388
|
+
return { value, realValue, updateValue, color, colorSpace, cycleColorSpace };
|
|
389
|
+
}, id = (value) => value.replace(/\s*/, "").toLowerCase(), usePresets = (presetColors, currentColor, colorSpace) => {
|
|
390
|
+
let [selectedColors, setSelectedColors] = useState(currentColor?.valid ? [currentColor] : []);
|
|
391
|
+
useEffect(() => {
|
|
392
|
+
currentColor === void 0 && setSelectedColors([]);
|
|
393
|
+
}, [currentColor]);
|
|
394
|
+
let presets = useMemo(() => (presetColors || []).map((preset) => typeof preset == "string" ? parseValue(preset) : preset.title ? { ...parseValue(preset.color), keyword: preset.title } : parseValue(preset.color)).concat(selectedColors).filter(Boolean).slice(-27), [presetColors, selectedColors]), addPreset = useCallback(
|
|
395
|
+
(color) => {
|
|
396
|
+
color?.valid && (presets.some(
|
|
397
|
+
(preset) => preset && preset[colorSpace] && id(preset[colorSpace] || "") === id(color[colorSpace] || "")
|
|
398
|
+
) || setSelectedColors((arr) => arr.concat(color)));
|
|
399
|
+
},
|
|
400
|
+
[colorSpace, presets]
|
|
401
|
+
);
|
|
402
|
+
return { presets, addPreset };
|
|
403
|
+
}, ColorControl = ({
|
|
404
|
+
name,
|
|
405
|
+
value: initialValue,
|
|
406
|
+
onChange,
|
|
407
|
+
onFocus,
|
|
408
|
+
onBlur,
|
|
409
|
+
presetColors,
|
|
410
|
+
startOpen = !1,
|
|
411
|
+
argType
|
|
412
|
+
}) => {
|
|
413
|
+
let debouncedOnChange = useCallback(debounce(onChange, 200), [onChange]), { value, realValue, updateValue, color, colorSpace, cycleColorSpace } = useColorInput(
|
|
414
|
+
initialValue,
|
|
415
|
+
debouncedOnChange
|
|
416
|
+
), { presets, addPreset } = usePresets(presetColors ?? [], color, colorSpace), Picker = ColorPicker[colorSpace], readOnly = !!argType?.table?.readonly, controlId = getControlId(name);
|
|
417
|
+
return React.createElement(Wrapper, null, React.createElement("label", { htmlFor: controlId, className: "sb-sr-only" }, name), React.createElement(
|
|
418
|
+
Input,
|
|
419
|
+
{
|
|
420
|
+
id: controlId,
|
|
421
|
+
value,
|
|
422
|
+
onChange: (e2) => updateValue(e2.target.value),
|
|
423
|
+
onFocus: (e2) => e2.target.select(),
|
|
424
|
+
readOnly,
|
|
425
|
+
placeholder: "Choose color..."
|
|
426
|
+
}
|
|
427
|
+
), React.createElement(
|
|
428
|
+
PopoverProvider,
|
|
429
|
+
{
|
|
430
|
+
defaultVisible: startOpen,
|
|
431
|
+
visible: readOnly ? !1 : void 0,
|
|
432
|
+
onVisibleChange: () => color && addPreset(color),
|
|
433
|
+
popover: React.createElement(TooltipContent, null, React.createElement(
|
|
434
|
+
Picker,
|
|
435
|
+
{
|
|
436
|
+
color: realValue === "transparent" ? "#000000" : realValue,
|
|
437
|
+
onChange: updateValue,
|
|
438
|
+
onFocus,
|
|
439
|
+
onBlur
|
|
440
|
+
}
|
|
441
|
+
), presets.length > 0 && React.createElement(Swatches, null, presets.map((preset, index) => React.createElement(
|
|
442
|
+
SwatchColor,
|
|
443
|
+
{
|
|
444
|
+
key: `${preset?.value || index}-${index}`,
|
|
445
|
+
variant: "ghost",
|
|
446
|
+
padding: "small",
|
|
447
|
+
size: "small",
|
|
448
|
+
ariaLabel: "Pick this color",
|
|
449
|
+
tooltip: preset?.keyword || preset?.value || "",
|
|
450
|
+
value: preset?.value || "",
|
|
451
|
+
selected: !!(color && preset && preset[colorSpace] && id(preset[colorSpace] || "") === id(color[colorSpace])),
|
|
452
|
+
onClick: () => preset && updateValue(preset.value || "")
|
|
453
|
+
}
|
|
454
|
+
))))
|
|
455
|
+
},
|
|
456
|
+
React.createElement(
|
|
457
|
+
PopoverTrigger,
|
|
458
|
+
{
|
|
459
|
+
variant: "ghost",
|
|
460
|
+
padding: "small",
|
|
461
|
+
size: "small",
|
|
462
|
+
ariaLabel: "Open color picker",
|
|
463
|
+
value: realValue,
|
|
464
|
+
style: { margin: 4 },
|
|
465
|
+
disabled: readOnly
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
), value ? React.createElement(
|
|
469
|
+
CycleColorSpaceButton,
|
|
470
|
+
{
|
|
471
|
+
variant: "ghost",
|
|
472
|
+
padding: "small",
|
|
473
|
+
size: "small",
|
|
474
|
+
ariaLabel: "Cycle through color spaces",
|
|
475
|
+
disabled: readOnly,
|
|
476
|
+
onClick: readOnly ? void 0 : cycleColorSpace
|
|
477
|
+
},
|
|
478
|
+
React.createElement(MarkupIcon, null)
|
|
479
|
+
) : null);
|
|
480
|
+
}, Color_default = ColorControl;
|
|
481
|
+
export {
|
|
482
|
+
ColorControl,
|
|
483
|
+
Color_default as default
|
|
484
|
+
};
|