@sanity/color-input 4.0.6 → 5.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 +3 -20
- package/dist/_chunks-es/ColorInput.js +340 -0
- package/dist/_chunks-es/ColorInput.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -67
- package/lib/_chunks-cjs/ColorInput.js +0 -1041
- package/lib/_chunks-cjs/ColorInput.js.map +0 -1
- package/lib/_chunks-es/ColorInput.mjs +0 -1051
- package/lib/_chunks-es/ColorInput.mjs.map +0 -1
- package/lib/_legacy/ColorInput.esm.js +0 -1051
- package/lib/_legacy/ColorInput.esm.js.map +0 -1
- package/lib/index.d.mts +0 -93
- package/lib/index.d.ts +0 -93
- package/lib/index.esm.js +0 -114
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -114
- package/lib/index.js.map +0 -1
- package/lib/index.mjs +0 -114
- package/lib/index.mjs.map +0 -1
- package/sanity.json +0 -8
- package/src/ColorInput.tsx +0 -97
- package/src/ColorList.tsx +0 -70
- package/src/ColorPicker.tsx +0 -152
- package/src/ColorPickerFields.tsx +0 -144
- package/src/LazyColorInput.tsx +0 -3
- package/src/index.ts +0 -18
- package/src/schemas/color.tsx +0 -98
- package/src/schemas/hslaColor.ts +0 -13
- package/src/schemas/hsvaColor.ts +0 -13
- package/src/schemas/rgbaColor.ts +0 -13
- package/src/types.ts +0 -19
- package/v2-incompatible.js +0 -11
package/README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# @sanity/color-input
|
|
2
2
|
|
|
3
|
-
> For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity/tree/next/packages/%40sanity/color-input).
|
|
4
|
-
|
|
5
3
|
## What is it?
|
|
6
4
|
|
|
7
5
|
Color input plugin for [Sanity](https://sanity.io/) that stores selected colors in hex, hsl, hsv and rgb format.
|
|
8
6
|
|
|
9
|
-

|
|
10
8
|
|
|
11
9
|
## Installation
|
|
12
10
|
|
|
@@ -69,7 +67,7 @@ To disable the alpha option, set `disableAlpha` to `true`:
|
|
|
69
67
|
|
|
70
68
|
Which will render accordingly:
|
|
71
69
|
|
|
72
|
-

|
|
73
71
|
|
|
74
72
|
### Color list
|
|
75
73
|
|
|
@@ -99,7 +97,7 @@ This uses the `react-color` under the hood https://casesandberg.github.io/react-
|
|
|
99
97
|
|
|
100
98
|
Which will render accordingly:
|
|
101
99
|
|
|
102
|
-

|
|
103
101
|
|
|
104
102
|
## Data model
|
|
105
103
|
|
|
@@ -135,18 +133,3 @@ Which will render accordingly:
|
|
|
135
133
|
## License
|
|
136
134
|
|
|
137
135
|
MIT-licensed. See LICENSE.
|
|
138
|
-
|
|
139
|
-
## Develop & test
|
|
140
|
-
|
|
141
|
-
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
142
|
-
with default configuration for build & watch scripts.
|
|
143
|
-
|
|
144
|
-
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
145
|
-
on how to run this plugin with hotreload in the studio.
|
|
146
|
-
|
|
147
|
-
### Release new version
|
|
148
|
-
|
|
149
|
-
Run ["CI & Release" workflow](https://github.com/sanity-io/color-input/actions/workflows/main.yml).
|
|
150
|
-
Make sure to select the main branch and check "Release new version".
|
|
151
|
-
|
|
152
|
-
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { useRef, useState, useEffect, useDeferredValue, startTransition } from "react";
|
|
4
|
+
import { CustomPicker } from "react-color";
|
|
5
|
+
import { EditableInput, Saturation, Hue, Alpha, Checkboard } from "react-color/lib/components/common";
|
|
6
|
+
import { set, setIfMissing, unset } from "sanity";
|
|
7
|
+
import { styled } from "styled-components";
|
|
8
|
+
import { useEffectEvent } from "use-effect-event";
|
|
9
|
+
import { AddIcon, TrashIcon } from "@sanity/icons";
|
|
10
|
+
import { Flex, useTheme, Box, Button, Card, Stack, Text, Inline } from "@sanity/ui";
|
|
11
|
+
import tinycolor from "tinycolor2";
|
|
12
|
+
import { isValidHex } from "react-color/lib/helpers/color";
|
|
13
|
+
const ColorListWrap = styled(Flex)`
|
|
14
|
+
gap: 0.25em;
|
|
15
|
+
`, ColorBoxContainer = styled.div`
|
|
16
|
+
width: 2.1em;
|
|
17
|
+
height: 2.1em;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
position: relative;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
border-radius: 3px;
|
|
22
|
+
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADFJREFUOE9jZGBgEGHAD97gk2YcNYBhmIQBgWSAP52AwoAQwJvQRg1gACckQoC2gQgAIF8IscwEtKYAAAAASUVORK5CYII=')
|
|
23
|
+
left center #fff;
|
|
24
|
+
`, ColorBox$1 = styled.div`
|
|
25
|
+
border-radius: inherit;
|
|
26
|
+
box-shadow: inset 0 0 0 1px var(--card-shadow-outline-color);
|
|
27
|
+
content: '';
|
|
28
|
+
position: absolute;
|
|
29
|
+
inset: 0;
|
|
30
|
+
z-index: 1;
|
|
31
|
+
`, validateColors = (colors) => colors.reduce((cls, c2) => {
|
|
32
|
+
const color = c2.hex ? tinycolor(c2.hex) : tinycolor(c2);
|
|
33
|
+
return color.isValid() && cls.push({
|
|
34
|
+
color: c2,
|
|
35
|
+
backgroundColor: color.toRgbString()
|
|
36
|
+
}), cls;
|
|
37
|
+
}, []);
|
|
38
|
+
function ColorList(t0) {
|
|
39
|
+
const $ = c(7), {
|
|
40
|
+
colors,
|
|
41
|
+
onChange
|
|
42
|
+
} = t0;
|
|
43
|
+
if (!colors)
|
|
44
|
+
return null;
|
|
45
|
+
let t1;
|
|
46
|
+
if ($[0] !== colors || $[1] !== onChange) {
|
|
47
|
+
let t22;
|
|
48
|
+
$[3] !== onChange ? (t22 = (t3, idx) => {
|
|
49
|
+
const {
|
|
50
|
+
color,
|
|
51
|
+
backgroundColor
|
|
52
|
+
} = t3;
|
|
53
|
+
return /* @__PURE__ */ jsx(ColorBoxContainer, { onClick: () => {
|
|
54
|
+
onChange(color);
|
|
55
|
+
}, children: /* @__PURE__ */ jsx(ColorBox$1, { style: {
|
|
56
|
+
background: backgroundColor
|
|
57
|
+
} }) }, `${backgroundColor}-${idx}`);
|
|
58
|
+
}, $[3] = onChange, $[4] = t22) : t22 = $[4], t1 = validateColors(colors).map(t22), $[0] = colors, $[1] = onChange, $[2] = t1;
|
|
59
|
+
} else
|
|
60
|
+
t1 = $[2];
|
|
61
|
+
let t2;
|
|
62
|
+
return $[5] !== t1 ? (t2 = /* @__PURE__ */ jsx(ColorListWrap, { wrap: "wrap", children: t1 }), $[5] = t1, $[6] = t2) : t2 = $[6], t2;
|
|
63
|
+
}
|
|
64
|
+
const ColorPickerFields = (t0) => {
|
|
65
|
+
const $ = c(44), {
|
|
66
|
+
onChange,
|
|
67
|
+
rgb,
|
|
68
|
+
hsl,
|
|
69
|
+
hex,
|
|
70
|
+
disableAlpha
|
|
71
|
+
} = t0, {
|
|
72
|
+
sanity
|
|
73
|
+
} = useTheme(), t1 = `inset 0 0 0 1px ${sanity.color.input.default.enabled.border}`, t2 = sanity.fonts.text.sizes[0]?.fontSize;
|
|
74
|
+
let t3;
|
|
75
|
+
$[0] !== sanity.color.input.default.enabled.bg || $[1] !== sanity.color.input.default.enabled.fg || $[2] !== t1 || $[3] !== t2 ? (t3 = {
|
|
76
|
+
width: "80%",
|
|
77
|
+
padding: "4px 10% 3px",
|
|
78
|
+
border: "none",
|
|
79
|
+
boxShadow: t1,
|
|
80
|
+
color: sanity.color.input.default.enabled.fg,
|
|
81
|
+
backgroundColor: sanity.color.input.default.enabled.bg,
|
|
82
|
+
fontSize: t2,
|
|
83
|
+
textAlign: "center"
|
|
84
|
+
}, $[0] = sanity.color.input.default.enabled.bg, $[1] = sanity.color.input.default.enabled.fg, $[2] = t1, $[3] = t2, $[4] = t3) : t3 = $[4];
|
|
85
|
+
const t4 = sanity.fonts.label.sizes[0]?.fontSize;
|
|
86
|
+
let t5;
|
|
87
|
+
$[5] !== sanity.color.base.fg || $[6] !== t4 ? (t5 = {
|
|
88
|
+
display: "block",
|
|
89
|
+
textAlign: "center",
|
|
90
|
+
fontSize: t4,
|
|
91
|
+
color: sanity.color.base.fg,
|
|
92
|
+
paddingTop: "3px",
|
|
93
|
+
paddingBottom: "4px",
|
|
94
|
+
textTransform: "capitalize"
|
|
95
|
+
}, $[5] = sanity.color.base.fg, $[6] = t4, $[7] = t5) : t5 = $[7];
|
|
96
|
+
let t6;
|
|
97
|
+
$[8] !== t3 || $[9] !== t5 ? (t6 = {
|
|
98
|
+
input: t3,
|
|
99
|
+
label: t5
|
|
100
|
+
}, $[8] = t3, $[9] = t5, $[10] = t6) : t6 = $[10];
|
|
101
|
+
const inputStyles = t6;
|
|
102
|
+
let t7;
|
|
103
|
+
$[11] !== hsl || $[12] !== onChange || $[13] !== rgb ? (t7 = (data) => {
|
|
104
|
+
if ("hex" in data && data.hex && isValidHex(data.hex))
|
|
105
|
+
onChange({
|
|
106
|
+
hex: data.hex,
|
|
107
|
+
source: "hex"
|
|
108
|
+
});
|
|
109
|
+
else if (rgb && ("r" in data && data.r || "g" in data && data.g || "b" in data && data.b))
|
|
110
|
+
onChange({
|
|
111
|
+
r: Number(data.r) || rgb.r,
|
|
112
|
+
g: Number(data.g) || rgb.g,
|
|
113
|
+
b: Number(data.b) || rgb.b,
|
|
114
|
+
a: rgb.a,
|
|
115
|
+
source: "rgb"
|
|
116
|
+
});
|
|
117
|
+
else if (hsl && "a" in data && data.a) {
|
|
118
|
+
let alpha = Number(data.a);
|
|
119
|
+
alpha < 0 ? alpha = 0 : alpha > 100 && (alpha = 100), alpha = alpha / 100, onChange({
|
|
120
|
+
h: hsl.h,
|
|
121
|
+
s: hsl.s,
|
|
122
|
+
l: hsl.l,
|
|
123
|
+
a: alpha,
|
|
124
|
+
source: "hsl"
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}, $[11] = hsl, $[12] = onChange, $[13] = rgb, $[14] = t7) : t7 = $[14];
|
|
128
|
+
const handleChange = t7;
|
|
129
|
+
let t8;
|
|
130
|
+
$[15] !== hex ? (t8 = hex?.replace("#", ""), $[15] = hex, $[16] = t8) : t8 = $[16];
|
|
131
|
+
let t9;
|
|
132
|
+
$[17] !== handleChange || $[18] !== inputStyles || $[19] !== t8 ? (t9 = /* @__PURE__ */ jsx(Box, { flex: 2, marginRight: 1, children: /* @__PURE__ */ jsx(EditableInput, { style: inputStyles, label: "hex", value: t8, onChange: handleChange }) }), $[17] = handleChange, $[18] = inputStyles, $[19] = t8, $[20] = t9) : t9 = $[20];
|
|
133
|
+
const t10 = rgb?.r;
|
|
134
|
+
let t11;
|
|
135
|
+
$[21] !== handleChange || $[22] !== inputStyles || $[23] !== t10 ? (t11 = /* @__PURE__ */ jsx(Box, { flex: 1, marginRight: 1, children: /* @__PURE__ */ jsx(EditableInput, { style: inputStyles, label: "r", value: t10, onChange: handleChange, dragLabel: !0, dragMax: 255 }) }), $[21] = handleChange, $[22] = inputStyles, $[23] = t10, $[24] = t11) : t11 = $[24];
|
|
136
|
+
const t12 = rgb?.g;
|
|
137
|
+
let t13;
|
|
138
|
+
$[25] !== handleChange || $[26] !== inputStyles || $[27] !== t12 ? (t13 = /* @__PURE__ */ jsx(Box, { flex: 1, marginRight: 1, children: /* @__PURE__ */ jsx(EditableInput, { style: inputStyles, label: "g", value: t12, onChange: handleChange, dragLabel: !0, dragMax: 255 }) }), $[25] = handleChange, $[26] = inputStyles, $[27] = t12, $[28] = t13) : t13 = $[28];
|
|
139
|
+
const t14 = rgb?.b;
|
|
140
|
+
let t15;
|
|
141
|
+
$[29] !== handleChange || $[30] !== inputStyles || $[31] !== t14 ? (t15 = /* @__PURE__ */ jsx(Box, { flex: 1, marginRight: 1, children: /* @__PURE__ */ jsx(EditableInput, { style: inputStyles, label: "b", value: t14, onChange: handleChange, dragLabel: !0, dragMax: 255 }) }), $[29] = handleChange, $[30] = inputStyles, $[31] = t14, $[32] = t15) : t15 = $[32];
|
|
142
|
+
let t16;
|
|
143
|
+
$[33] !== disableAlpha || $[34] !== handleChange || $[35] !== inputStyles || $[36] !== rgb?.a ? (t16 = !disableAlpha && /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(EditableInput, { style: inputStyles, label: "a", value: Math.round((rgb?.a ?? 1) * 100), onChange: handleChange, dragLabel: !0, dragMax: 100 }) }), $[33] = disableAlpha, $[34] = handleChange, $[35] = inputStyles, $[36] = rgb?.a, $[37] = t16) : t16 = $[37];
|
|
144
|
+
let t17;
|
|
145
|
+
return $[38] !== t11 || $[39] !== t13 || $[40] !== t15 || $[41] !== t16 || $[42] !== t9 ? (t17 = /* @__PURE__ */ jsxs(Flex, { children: [
|
|
146
|
+
t9,
|
|
147
|
+
t11,
|
|
148
|
+
t13,
|
|
149
|
+
t15,
|
|
150
|
+
t16
|
|
151
|
+
] }), $[38] = t11, $[39] = t13, $[40] = t15, $[41] = t16, $[42] = t9, $[43] = t17) : t17 = $[43], t17;
|
|
152
|
+
}, ColorBox = styled(Box)`
|
|
153
|
+
position: absolute;
|
|
154
|
+
top: 0;
|
|
155
|
+
left: 0;
|
|
156
|
+
width: 100%;
|
|
157
|
+
height: 100%;
|
|
158
|
+
`, ReadOnlyContainer = styled(Flex)`
|
|
159
|
+
margin-top: 6rem;
|
|
160
|
+
background-color: var(--card-bg-color);
|
|
161
|
+
position: relative;
|
|
162
|
+
width: 100%;
|
|
163
|
+
`, ColorPickerInner = (props) => {
|
|
164
|
+
const $ = c(47), {
|
|
165
|
+
width,
|
|
166
|
+
color: t0,
|
|
167
|
+
onChange,
|
|
168
|
+
onUnset,
|
|
169
|
+
disableAlpha,
|
|
170
|
+
colorList,
|
|
171
|
+
readOnly
|
|
172
|
+
} = props, {
|
|
173
|
+
rgb,
|
|
174
|
+
hex,
|
|
175
|
+
hsv,
|
|
176
|
+
hsl
|
|
177
|
+
} = t0;
|
|
178
|
+
if (!hsl || !hsv)
|
|
179
|
+
return null;
|
|
180
|
+
let t1;
|
|
181
|
+
$[0] !== width ? (t1 = {
|
|
182
|
+
width
|
|
183
|
+
}, $[0] = width, $[1] = t1) : t1 = $[1];
|
|
184
|
+
let t2;
|
|
185
|
+
$[2] !== disableAlpha || $[3] !== hsl || $[4] !== hsv || $[5] !== onChange || $[6] !== readOnly || $[7] !== rgb ? (t2 = !readOnly && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
186
|
+
/* @__PURE__ */ jsx(Card, { overflow: "hidden", style: {
|
|
187
|
+
position: "relative",
|
|
188
|
+
height: "5em"
|
|
189
|
+
}, children: /* @__PURE__ */ jsx(Saturation, { onChange, hsl, hsv }) }),
|
|
190
|
+
/* @__PURE__ */ jsx(Card, { shadow: 1, radius: 3, overflow: "hidden", style: {
|
|
191
|
+
position: "relative",
|
|
192
|
+
height: "10px"
|
|
193
|
+
}, children: /* @__PURE__ */ jsx(Hue, { hsl, onChange: !readOnly && onChange }) }),
|
|
194
|
+
!disableAlpha && /* @__PURE__ */ jsx(Card, { shadow: 1, radius: 3, overflow: "hidden", style: {
|
|
195
|
+
position: "relative",
|
|
196
|
+
height: "10px",
|
|
197
|
+
background: "#fff"
|
|
198
|
+
}, children: /* @__PURE__ */ jsx(Alpha, { rgb, hsl, onChange }) })
|
|
199
|
+
] }), $[2] = disableAlpha, $[3] = hsl, $[4] = hsv, $[5] = onChange, $[6] = readOnly, $[7] = rgb, $[8] = t2) : t2 = $[8];
|
|
200
|
+
let t3;
|
|
201
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
|
|
202
|
+
position: "relative",
|
|
203
|
+
minWidth: "4em",
|
|
204
|
+
background: "#fff"
|
|
205
|
+
}, $[9] = t3) : t3 = $[9];
|
|
206
|
+
let t4;
|
|
207
|
+
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {}, $[10] = t4) : t4 = $[10];
|
|
208
|
+
let t5;
|
|
209
|
+
$[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsx(Checkboard, { size: 8, white: "transparent", grey: "rgba(0,0,0,.08)", renderers: t4 }), $[11] = t5) : t5 = $[11];
|
|
210
|
+
const t6 = `rgba(${rgb?.r},${rgb?.g},${rgb?.b},${rgb?.a})`;
|
|
211
|
+
let t7;
|
|
212
|
+
$[12] !== t6 ? (t7 = /* @__PURE__ */ jsx(ColorBox, { style: {
|
|
213
|
+
backgroundColor: t6
|
|
214
|
+
} }), $[12] = t6, $[13] = t7) : t7 = $[13];
|
|
215
|
+
let t8;
|
|
216
|
+
$[14] !== hex || $[15] !== hsl?.h || $[16] !== hsl?.l || $[17] !== hsl?.s || $[18] !== readOnly || $[19] !== rgb?.b || $[20] !== rgb?.g || $[21] !== rgb?.r ? (t8 = readOnly && /* @__PURE__ */ jsx(ReadOnlyContainer, { padding: 2, paddingBottom: 1, sizing: "border", justify: "space-between", children: /* @__PURE__ */ jsxs(Stack, { space: 3, marginTop: 1, children: [
|
|
217
|
+
/* @__PURE__ */ jsx(Text, { size: 3, weight: "bold", children: hex }),
|
|
218
|
+
/* @__PURE__ */ jsxs(Inline, { space: 3, children: [
|
|
219
|
+
/* @__PURE__ */ jsxs(Text, { size: 1, children: [
|
|
220
|
+
/* @__PURE__ */ jsx("strong", { children: "RGB: " }),
|
|
221
|
+
rgb?.r,
|
|
222
|
+
" ",
|
|
223
|
+
rgb?.g,
|
|
224
|
+
" ",
|
|
225
|
+
rgb?.b
|
|
226
|
+
] }),
|
|
227
|
+
/* @__PURE__ */ jsxs(Text, { size: 1, children: [
|
|
228
|
+
/* @__PURE__ */ jsx("strong", { children: "HSL: " }),
|
|
229
|
+
" ",
|
|
230
|
+
Math.round(hsl?.h ?? 0),
|
|
231
|
+
" ",
|
|
232
|
+
Math.round((hsl?.s ?? 0) * 100),
|
|
233
|
+
"% ",
|
|
234
|
+
Math.round((hsl?.l ?? 0) * 100),
|
|
235
|
+
"%"
|
|
236
|
+
] })
|
|
237
|
+
] })
|
|
238
|
+
] }) }), $[14] = hex, $[15] = hsl?.h, $[16] = hsl?.l, $[17] = hsl?.s, $[18] = readOnly, $[19] = rgb?.b, $[20] = rgb?.g, $[21] = rgb?.r, $[22] = t8) : t8 = $[22];
|
|
239
|
+
let t9;
|
|
240
|
+
$[23] !== t7 || $[24] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Card, { flex: 1, radius: 2, overflow: "hidden", style: t3, children: [
|
|
241
|
+
t5,
|
|
242
|
+
t7,
|
|
243
|
+
t8
|
|
244
|
+
] }), $[23] = t7, $[24] = t8, $[25] = t9) : t9 = $[25];
|
|
245
|
+
let t10;
|
|
246
|
+
$[26] !== disableAlpha || $[27] !== hex || $[28] !== hsl || $[29] !== onChange || $[30] !== onUnset || $[31] !== readOnly || $[32] !== rgb ? (t10 = !readOnly && /* @__PURE__ */ jsxs(Flex, { align: "flex-start", marginLeft: 2, children: [
|
|
247
|
+
/* @__PURE__ */ jsx(Box, { style: {
|
|
248
|
+
width: 200
|
|
249
|
+
}, children: /* @__PURE__ */ jsx(ColorPickerFields, { rgb, hsl, hex, onChange, disableAlpha }) }),
|
|
250
|
+
/* @__PURE__ */ jsx(Box, { marginLeft: 2, children: /* @__PURE__ */ jsx(Button, { onClick: onUnset, title: "Delete color", icon: TrashIcon, tone: "critical" }) })
|
|
251
|
+
] }), $[26] = disableAlpha, $[27] = hex, $[28] = hsl, $[29] = onChange, $[30] = onUnset, $[31] = readOnly, $[32] = rgb, $[33] = t10) : t10 = $[33];
|
|
252
|
+
let t11;
|
|
253
|
+
$[34] !== t10 || $[35] !== t9 ? (t11 = /* @__PURE__ */ jsxs(Flex, { children: [
|
|
254
|
+
t9,
|
|
255
|
+
t10
|
|
256
|
+
] }), $[34] = t10, $[35] = t9, $[36] = t11) : t11 = $[36];
|
|
257
|
+
let t12;
|
|
258
|
+
$[37] !== colorList || $[38] !== onChange ? (t12 = colorList && /* @__PURE__ */ jsx(ColorList, { colors: colorList, onChange }), $[37] = colorList, $[38] = onChange, $[39] = t12) : t12 = $[39];
|
|
259
|
+
let t13;
|
|
260
|
+
$[40] !== t11 || $[41] !== t12 || $[42] !== t2 ? (t13 = /* @__PURE__ */ jsx(Card, { padding: 1, border: !0, radius: 1, children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
261
|
+
t2,
|
|
262
|
+
t11,
|
|
263
|
+
t12
|
|
264
|
+
] }) }), $[40] = t11, $[41] = t12, $[42] = t2, $[43] = t13) : t13 = $[43];
|
|
265
|
+
let t14;
|
|
266
|
+
return $[44] !== t1 || $[45] !== t13 ? (t14 = /* @__PURE__ */ jsx("div", { style: t1, children: t13 }), $[44] = t1, $[45] = t13, $[46] = t14) : t14 = $[46], t14;
|
|
267
|
+
}, ColorPicker = CustomPicker(ColorPickerInner), DEFAULT_COLOR = {
|
|
268
|
+
hex: "#24a3e3",
|
|
269
|
+
hsl: {
|
|
270
|
+
h: 200,
|
|
271
|
+
s: 0.7732,
|
|
272
|
+
l: 0.5156,
|
|
273
|
+
a: 1
|
|
274
|
+
},
|
|
275
|
+
hsv: {
|
|
276
|
+
h: 200,
|
|
277
|
+
s: 0.8414,
|
|
278
|
+
v: 0.8901,
|
|
279
|
+
a: 1
|
|
280
|
+
},
|
|
281
|
+
rgb: {
|
|
282
|
+
r: 46,
|
|
283
|
+
g: 163,
|
|
284
|
+
b: 227,
|
|
285
|
+
a: 1
|
|
286
|
+
},
|
|
287
|
+
source: "hex"
|
|
288
|
+
};
|
|
289
|
+
function ColorInput(props) {
|
|
290
|
+
const $ = c(24), {
|
|
291
|
+
onChange,
|
|
292
|
+
readOnly
|
|
293
|
+
} = props, value = props.value, type = props.schemaType, focusRef = useRef(null), [color, setColor] = useState(value);
|
|
294
|
+
let t0, t1;
|
|
295
|
+
$[0] !== value ? (t0 = () => startTransition(() => setColor(value)), t1 = [value], $[0] = value, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1);
|
|
296
|
+
const [emitColor, setEmitColor] = useState(void 0), debouncedColor = useDeferredValue(emitColor);
|
|
297
|
+
let t2;
|
|
298
|
+
$[3] !== onChange || $[4] !== type.fields || $[5] !== type.name ? (t2 = (nextColor) => {
|
|
299
|
+
const fieldPatches = type.fields.filter((field) => field.name in nextColor).map((field_0) => {
|
|
300
|
+
const nextFieldValue = nextColor[field_0.name], isObject = field_0.type.jsonType === "object";
|
|
301
|
+
return set(isObject ? Object.assign({
|
|
302
|
+
_type: field_0.type.name
|
|
303
|
+
}, nextFieldValue) : nextFieldValue, [field_0.name]);
|
|
304
|
+
});
|
|
305
|
+
onChange([setIfMissing({
|
|
306
|
+
_type: type.name
|
|
307
|
+
}), set(type.name, ["_type"]), set(nextColor.rgb?.a, ["alpha"]), ...fieldPatches]);
|
|
308
|
+
}, $[3] = onChange, $[4] = type.fields, $[5] = type.name, $[6] = t2) : t2 = $[6];
|
|
309
|
+
const handleChange = useEffectEvent(t2);
|
|
310
|
+
let t3;
|
|
311
|
+
$[7] !== debouncedColor || $[8] !== handleChange ? (t3 = () => {
|
|
312
|
+
if (!debouncedColor)
|
|
313
|
+
return;
|
|
314
|
+
const raf = requestAnimationFrame(() => handleChange(debouncedColor));
|
|
315
|
+
return () => cancelAnimationFrame(raf);
|
|
316
|
+
}, $[7] = debouncedColor, $[8] = handleChange, $[9] = t3) : t3 = $[9];
|
|
317
|
+
let t4;
|
|
318
|
+
$[10] !== debouncedColor ? (t4 = [debouncedColor], $[10] = debouncedColor, $[11] = t4) : t4 = $[11], useEffect(t3, t4);
|
|
319
|
+
let t5;
|
|
320
|
+
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
321
|
+
setColor(DEFAULT_COLOR), setEmitColor(DEFAULT_COLOR);
|
|
322
|
+
}, $[12] = t5) : t5 = $[12];
|
|
323
|
+
const handleCreateColor = t5;
|
|
324
|
+
let t6;
|
|
325
|
+
$[13] === Symbol.for("react.memo_cache_sentinel") ? (t6 = (nextColor_0) => {
|
|
326
|
+
setColor(nextColor_0), setEmitColor(nextColor_0);
|
|
327
|
+
}, $[13] = t6) : t6 = $[13];
|
|
328
|
+
const handleColorChange = t6;
|
|
329
|
+
let t7;
|
|
330
|
+
$[14] !== onChange ? (t7 = () => {
|
|
331
|
+
setColor(void 0), onChange(unset());
|
|
332
|
+
}, $[14] = onChange, $[15] = t7) : t7 = $[15];
|
|
333
|
+
const handleUnset = t7;
|
|
334
|
+
let t8;
|
|
335
|
+
return $[16] !== color || $[17] !== handleUnset || $[18] !== readOnly || $[19] !== type.options?.colorList || $[20] !== type.options?.disableAlpha || $[21] !== type.readOnly || $[22] !== value ? (t8 = /* @__PURE__ */ jsx(Fragment, { children: value && value.hex ? /* @__PURE__ */ jsx(ColorPicker, { color, onChange: handleColorChange, readOnly: readOnly || typeof type.readOnly == "boolean" && type.readOnly, disableAlpha: !!type.options?.disableAlpha, colorList: type.options?.colorList, onUnset: handleUnset }) : /* @__PURE__ */ jsx(Button, { icon: AddIcon, mode: "ghost", text: "Create color", ref: focusRef, disabled: !!readOnly, onClick: handleCreateColor }) }), $[16] = color, $[17] = handleUnset, $[18] = readOnly, $[19] = type.options?.colorList, $[20] = type.options?.disableAlpha, $[21] = type.readOnly, $[22] = value, $[23] = t8) : t8 = $[23], t8;
|
|
336
|
+
}
|
|
337
|
+
export {
|
|
338
|
+
ColorInput as default
|
|
339
|
+
};
|
|
340
|
+
//# sourceMappingURL=ColorInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorInput.js","sources":["../../src/ColorList.tsx","../../src/ColorPickerFields.tsx","../../src/ColorInput.tsx"],"sourcesContent":["import type {Color, ColorChangeHandler} from 'react-color'\n\nimport {styled} from 'styled-components'\nimport tinycolor from 'tinycolor2'\n\nimport {Flex} from '@sanity/ui'\n\nconst ColorListWrap = styled(Flex)`\n gap: 0.25em;\n`\n\nconst ColorBoxContainer = styled.div`\n width: 2.1em;\n height: 2.1em;\n cursor: pointer;\n position: relative;\n overflow: hidden;\n border-radius: 3px;\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADFJREFUOE9jZGBgEGHAD97gk2YcNYBhmIQBgWSAP52AwoAQwJvQRg1gACckQoC2gQgAIF8IscwEtKYAAAAASUVORK5CYII=')\n left center #fff;\n`\n\nconst ColorBox = styled.div`\n border-radius: inherit;\n box-shadow: inset 0 0 0 1px var(--card-shadow-outline-color);\n content: '';\n position: absolute;\n inset: 0;\n z-index: 1;\n`\n\ninterface ValidatedColor {\n color: Color\n backgroundColor: string\n}\n\ninterface ColorListProps {\n colors?: Array<Color>\n onChange: ColorChangeHandler<Color>\n}\n\nconst validateColors = (colors: Array<Color>) =>\n colors.reduce((cls: Array<ValidatedColor>, c) => {\n // @ts-expect-error fix types later\n const color = c.hex ? tinycolor(c.hex) : tinycolor(c)\n if (color.isValid()) {\n cls.push({\n color: c,\n backgroundColor: color.toRgbString(),\n })\n }\n return cls\n }, [])\n\nexport function ColorList({colors, onChange}: ColorListProps): React.JSX.Element | null {\n if (!colors) return null\n return (\n <ColorListWrap wrap=\"wrap\">\n {validateColors(colors).map(({color, backgroundColor}, idx) => (\n <ColorBoxContainer\n key={`${backgroundColor}-${idx}`}\n onClick={() => {\n onChange(color)\n }}\n >\n <ColorBox style={{background: backgroundColor}} />\n </ColorBoxContainer>\n ))}\n </ColorListWrap>\n )\n}\n","import type {Color, ColorChangeHandler, HSLColor, RGBColor} from 'react-color'\nimport type {EditableInputStyles} from 'react-color/lib/components/common/EditableInput'\n\nimport {useCallback, useMemo} from 'react'\nimport {EditableInput} from 'react-color/lib/components/common'\n// @ts-expect-error missing export\nimport {isValidHex} from 'react-color/lib/helpers/color'\n\nimport {Box, Flex, useTheme} from '@sanity/ui'\n\ninterface ColorPickerFieldsProps {\n rgb?: RGBColor\n hsl?: HSLColor\n hex?: string\n disableAlpha: boolean\n onChange: ColorChangeHandler<Color>\n}\n\nexport const ColorPickerFields = ({\n onChange,\n rgb,\n hsl,\n hex,\n disableAlpha,\n}: ColorPickerFieldsProps) => {\n const {sanity} = useTheme()\n\n const inputStyles: EditableInputStyles = useMemo(\n () => ({\n input: {\n width: '80%',\n padding: '4px 10% 3px',\n border: 'none',\n boxShadow: `inset 0 0 0 1px ${sanity.color.input.default.enabled.border}`,\n color: sanity.color.input.default.enabled.fg,\n backgroundColor: sanity.color.input.default.enabled.bg,\n fontSize: sanity.fonts.text.sizes[0]?.fontSize,\n textAlign: 'center',\n },\n label: {\n display: 'block',\n textAlign: 'center',\n fontSize: sanity.fonts.label.sizes[0]?.fontSize,\n color: sanity.color.base.fg,\n paddingTop: '3px',\n paddingBottom: '4px',\n textTransform: 'capitalize',\n },\n }),\n [sanity],\n )\n\n const handleChange: ColorChangeHandler<Record<string, string>> = useCallback(\n (data) => {\n if ('hex' in data && data['hex'] && isValidHex(data['hex'])) {\n onChange({\n hex: data['hex'],\n source: 'hex',\n })\n } else if (\n rgb &&\n (('r' in data && data['r']) || ('g' in data && data['g']) || ('b' in data && data['b']))\n ) {\n onChange({\n r: Number(data['r']) || rgb.r,\n g: Number(data['g']) || rgb.g,\n b: Number(data['b']) || rgb.b,\n a: rgb.a,\n source: 'rgb',\n })\n } else if (hsl && 'a' in data && data['a']) {\n let alpha = Number(data['a'])\n if (alpha < 0) {\n alpha = 0\n } else if (alpha > 100) {\n alpha = 100\n }\n alpha /= 100\n\n onChange({\n h: hsl.h,\n s: hsl.s,\n l: hsl.l,\n a: alpha,\n source: 'hsl',\n })\n }\n },\n [onChange, hsl, rgb],\n )\n\n return (\n <Flex>\n <Box flex={2} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"hex\"\n value={hex?.replace('#', '')}\n onChange={handleChange}\n />\n </Box>\n <Box flex={1} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"r\"\n value={rgb?.r}\n onChange={handleChange}\n dragLabel\n dragMax={255}\n />\n </Box>\n <Box flex={1} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"g\"\n value={rgb?.g}\n onChange={handleChange}\n dragLabel\n dragMax={255}\n />\n </Box>\n <Box flex={1} marginRight={1}>\n <EditableInput\n style={inputStyles}\n label=\"b\"\n value={rgb?.b}\n onChange={handleChange}\n dragLabel\n dragMax={255}\n />\n </Box>\n {!disableAlpha && (\n <Box flex={1}>\n <EditableInput\n style={inputStyles}\n label=\"a\"\n value={Math.round((rgb?.a ?? 1) * 100)}\n onChange={handleChange}\n dragLabel\n dragMax={100}\n />\n </Box>\n )}\n </Flex>\n )\n}\n","import type {CustomPickerInjectedProps} from 'react-color/lib/components/common/ColorWrap'\n\nimport {startTransition, useCallback, useDeferredValue, useEffect, useRef, useState} from 'react'\nimport {type Color, CustomPicker} from 'react-color'\nimport {Alpha, Checkboard, Hue, Saturation} from 'react-color/lib/components/common'\nimport {type ObjectInputProps, set, setIfMissing, unset} from 'sanity'\nimport {styled} from 'styled-components'\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {AddIcon} from '@sanity/icons'\nimport {TrashIcon} from '@sanity/icons'\nimport {Box, Button, Card, Flex, Inline, Stack, Text} from '@sanity/ui'\n\nimport type {ColorSchemaType, ColorValue} from './types'\n\nimport {ColorList} from './ColorList'\nimport {ColorPickerFields} from './ColorPickerFields'\n\nconst ColorBox = styled(Box)`\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n`\n\nconst ReadOnlyContainer = styled(Flex)`\n margin-top: 6rem;\n background-color: var(--card-bg-color);\n position: relative;\n width: 100%;\n`\n\ninterface ColorPickerProps extends CustomPickerInjectedProps<Color> {\n width?: string\n disableAlpha: boolean\n colorList?: Array<Color> | undefined\n readOnly?: boolean\n onUnset: () => void\n color: ColorValue\n}\n\nconst ColorPickerInner = (props: ColorPickerProps) => {\n const {\n width,\n color: {rgb, hex, hsv, hsl},\n onChange,\n onUnset,\n disableAlpha,\n colorList,\n readOnly,\n } = props\n\n if (!hsl || !hsv) {\n return null\n }\n\n return (\n <div style={{width}}>\n <Card padding={1} border radius={1}>\n <Stack space={2}>\n {!readOnly && (\n <>\n <Card overflow=\"hidden\" style={{position: 'relative', height: '5em'}}>\n <Saturation onChange={onChange} hsl={hsl} hsv={hsv} />\n </Card>\n\n <Card\n shadow={1}\n radius={3}\n overflow=\"hidden\"\n style={{position: 'relative', height: '10px'}}\n >\n <Hue hsl={hsl} onChange={!readOnly && onChange} />\n </Card>\n\n {!disableAlpha && (\n <Card\n shadow={1}\n radius={3}\n overflow=\"hidden\"\n style={{position: 'relative', height: '10px', background: '#fff'}}\n >\n <Alpha rgb={rgb} hsl={hsl} onChange={onChange} />\n </Card>\n )}\n </>\n )}\n <Flex>\n <Card\n flex={1}\n radius={2}\n overflow=\"hidden\"\n style={{position: 'relative', minWidth: '4em', background: '#fff'}}\n >\n <Checkboard\n size={8}\n white=\"transparent\"\n grey=\"rgba(0,0,0,.08)\"\n renderers={{} as {canvas: unknown}}\n />\n <ColorBox\n style={{\n backgroundColor: `rgba(${rgb?.r},${rgb?.g},${rgb?.b},${rgb?.a})`,\n }}\n />\n\n {readOnly && (\n <ReadOnlyContainer\n padding={2}\n paddingBottom={1}\n sizing=\"border\"\n justify=\"space-between\"\n >\n <Stack space={3} marginTop={1}>\n <Text size={3} weight=\"bold\">\n {hex}\n </Text>\n\n <Inline space={3}>\n <Text size={1}>\n <strong>RGB: </strong>\n {rgb?.r} {rgb?.g} {rgb?.b}\n </Text>\n <Text size={1}>\n <strong>HSL: </strong> {Math.round(hsl?.h ?? 0)}{' '}\n {Math.round((hsl?.s ?? 0) * 100)}% {Math.round((hsl?.l ?? 0) * 100)}%\n </Text>\n </Inline>\n </Stack>\n </ReadOnlyContainer>\n )}\n </Card>\n\n {!readOnly && (\n <Flex align=\"flex-start\" marginLeft={2}>\n <Box style={{width: 200}}>\n <ColorPickerFields\n rgb={rgb}\n hsl={hsl}\n hex={hex}\n onChange={onChange}\n disableAlpha={disableAlpha}\n />\n </Box>\n <Box marginLeft={2}>\n <Button onClick={onUnset} title=\"Delete color\" icon={TrashIcon} tone=\"critical\" />\n </Box>\n </Flex>\n )}\n </Flex>\n {colorList && <ColorList colors={colorList} onChange={onChange} />}\n </Stack>\n </Card>\n </div>\n )\n}\n\nconst ColorPicker = CustomPicker(ColorPickerInner)\n\nconst DEFAULT_COLOR: ColorValue & {source: string} = {\n hex: '#24a3e3',\n hsl: {h: 200, s: 0.7732, l: 0.5156, a: 1},\n hsv: {h: 200, s: 0.8414, v: 0.8901, a: 1},\n rgb: {r: 46, g: 163, b: 227, a: 1},\n source: 'hex',\n}\n\nexport default function ColorInput(props: ObjectInputProps) {\n const {onChange, readOnly} = props\n const value = props.value as ColorValue | undefined\n const type = props.schemaType as ColorSchemaType\n const focusRef = useRef<HTMLButtonElement>(null)\n\n // use local state so we can have instant ui updates while debouncing patch emits\n const [color, setColor] = useState(value)\n // Marking the `setColor` in a transition allows React to interrupt render should the user start dragging the input before React is finished rendering\n useEffect(() => startTransition(() => setColor(value)), [value])\n\n // The color picker emits onChange events continuously while the user is sliding the\n // hue/saturation/alpha selectors. This debounces the event to avoid excessive patches\n // and massively improve render performance and avoid jank\n const [emitColor, setEmitColor] = useState<typeof value>(undefined)\n const debouncedColor = useDeferredValue(emitColor)\n const handleChange = useEffectEvent((nextColor: ColorValue) => {\n const fieldPatches = type.fields\n .filter((field) => field.name in nextColor)\n .map((field) => {\n const nextFieldValue = nextColor[field.name as keyof ColorValue]\n const isObject = field.type.jsonType === 'object'\n return set(\n isObject ? Object.assign({_type: field.type.name}, nextFieldValue) : nextFieldValue,\n [field.name],\n )\n })\n\n onChange([\n setIfMissing({_type: type.name}),\n set(type.name, ['_type']),\n set(nextColor.rgb?.a, ['alpha']),\n ...fieldPatches,\n ])\n })\n useEffect(() => {\n if (!debouncedColor) return undefined\n const raf = requestAnimationFrame(() => handleChange(debouncedColor))\n return () => cancelAnimationFrame(raf)\n }, [debouncedColor])\n\n const handleCreateColor = useCallback(() => {\n setColor(DEFAULT_COLOR)\n setEmitColor(DEFAULT_COLOR)\n }, [])\n\n const handleColorChange = useCallback((nextColor: ColorValue) => {\n setColor(nextColor)\n setEmitColor(nextColor)\n }, [])\n\n const handleUnset = useCallback(() => {\n setColor(undefined)\n onChange(unset())\n }, [onChange])\n\n return (\n <>\n {value && value.hex ? (\n <ColorPicker\n color={color!}\n onChange={handleColorChange}\n readOnly={readOnly || (typeof type.readOnly === 'boolean' && type.readOnly)}\n disableAlpha={!!type.options?.disableAlpha}\n colorList={type.options?.colorList}\n onUnset={handleUnset}\n />\n ) : (\n <Button\n icon={AddIcon}\n mode=\"ghost\"\n text=\"Create color\"\n ref={focusRef}\n disabled={Boolean(readOnly)}\n onClick={handleCreateColor}\n />\n )}\n </>\n )\n}\n"],"names":["ColorListWrap","styled","Flex","ColorBoxContainer","div","ColorBox","validateColors","colors","reduce","cls","c","color","hex","tinycolor","isValid","push","backgroundColor","toRgbString","ColorList","t0","$","_c","onChange","t1","t2","t3","idx","background","map","ColorPickerFields","rgb","hsl","disableAlpha","sanity","useTheme","input","default","enabled","border","fonts","text","sizes","fontSize","bg","fg","width","padding","boxShadow","textAlign","t4","label","t5","base","display","paddingTop","paddingBottom","textTransform","t6","inputStyles","t7","data","isValidHex","source","r","g","b","Number","a","alpha","h","s","l","handleChange","t8","replace","t9","t10","t11","t12","t13","t14","t15","t16","Math","round","t17","Box","ReadOnlyContainer","ColorPickerInner","props","onUnset","colorList","readOnly","hsv","position","height","Symbol","for","minWidth","TrashIcon","ColorPicker","CustomPicker","DEFAULT_COLOR","v","ColorInput","value","type","schemaType","focusRef","useRef","setColor","useState","startTransition","useEffect","emitColor","setEmitColor","undefined","debouncedColor","useDeferredValue","fields","name","nextColor","fieldPatches","filter","field","field_0","nextFieldValue","isObject","jsonType","set","Object","assign","_type","setIfMissing","useEffectEvent","raf","requestAnimationFrame","cancelAnimationFrame","handleCreateColor","nextColor_0","handleColorChange","unset","handleUnset","options","AddIcon","Boolean"],"mappings":";;;;;;;;;;;;AAOA,MAAMA,gBAAgBC,OAAOC,IAAI;AAAA;AAAA,GAI3BC,oBAAoBF,OAAOG;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,GAW3BC,aAAWJ,OAAOG;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,GAmBlBE,iBAAkBC,CAAAA,WACtBA,OAAOC,OAAO,CAACC,KAA4BC,OAAM;AAE/C,QAAMC,QAAQD,GAAEE,MAAMC,UAAUH,GAAEE,GAAG,IAAIC,UAAUH,EAAC;AACpD,SAAIC,MAAMG,aACRL,IAAIM,KAAK;AAAA,IACPJ,OAAOD;AAAAA,IACPM,iBAAiBL,MAAMM,YAAAA;AAAAA,EAAY,CACpC,GAEIR;AACT,GAAG,EAAE;AAEA,SAAAS,UAAAC,IAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAmB;AAAA,IAAAd;AAAAA,IAAAe;AAAAA,EAAAA,IAAAH;AACxB,MAAI,CAACZ;AAAM,WAAS;AAAI,MAAAgB;AAAA,MAAAH,EAAA,CAAA,MAAAb,UAAAa,SAAAE,UAAA;AAAA,QAAAE;AAAAJ,aAAAE,YAGQE,MAAAA,CAAAC,IAAAC,QAAA;AAAC,YAAA;AAAA,QAAAf;AAAAA,QAAAK;AAAAA,MAAAA,IAAAS;AAAwB,aACnD,oBAAC,mBAAA,EAEU,SAAA,MAAA;AACPH,iBAASX,KAAK;AAAA,MAAC,GAGjB,UAAA,oBAACN,YAAA,EAAgB,OAAA;AAAA,QAAAsB,YAAaX;AAAAA,MAAAA,GAAgB,EAAA,GALzC,GAAGA,eAAe,IAAIU,GAAG,EAMhC;AAAA,IAAoB,GACrBN,O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C,KAAAA,UACK,UAAAqC,CAAAA,CAAQrD,UACT8C,SAAAA,kBAAAA,CAAiB,EAAA,CAE7B,GACAtH,QAAAT,OAAAS,QAAA0H,aAAA1H,QAAAwE,UAAAxE,EAAA,EAAA,IAAAsF,KAAAqC,SAAApD,WAAAvE,EAAA,EAAA,IAAAsF,KAAAqC,SAAA/G,cAAAZ,EAAA,EAAA,IAAAsF,KAAAd,UAAAxE,QAAAqF,OAAArF,QAAAqD,MAAAA,KAAArD,EAAA,EAAA,GApBHqD;AAoBG;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as sanity14 from "sanity";
|
|
2
|
+
import { ObjectDefinition, ObjectInputProps, ObjectOptions, ObjectSchemaType } from "sanity";
|
|
3
|
+
import { Color, HSLColor, HSVColor, RGBColor } from "react-color";
|
|
4
|
+
import * as react2 from "react";
|
|
5
|
+
interface ColorValue {
|
|
6
|
+
hex: string;
|
|
7
|
+
hsl: HSLColor;
|
|
8
|
+
hsv: HSVColor;
|
|
9
|
+
rgb: RGBColor;
|
|
10
|
+
}
|
|
11
|
+
interface ColorOptions extends Omit<ObjectOptions, 'columns'> {
|
|
12
|
+
disableAlpha?: boolean;
|
|
13
|
+
colorList?: Array<Color>;
|
|
14
|
+
}
|
|
15
|
+
type ColorSchemaType = Omit<ObjectSchemaType, 'options'> & {
|
|
16
|
+
options?: ColorOptions;
|
|
17
|
+
};
|
|
18
|
+
type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>;
|
|
19
|
+
declare const colorTypeName: "color";
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {
|
|
24
|
+
type: typeof colorTypeName;
|
|
25
|
+
options?: ColorOptions;
|
|
26
|
+
}
|
|
27
|
+
declare module 'sanity' {
|
|
28
|
+
interface IntrinsicDefinitions {
|
|
29
|
+
color: ColorDefinition;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
declare const color: {
|
|
33
|
+
type: "object";
|
|
34
|
+
name: "color";
|
|
35
|
+
} & Omit<ObjectDefinition, "preview"> & {
|
|
36
|
+
preview?: sanity14.PreviewConfig<{
|
|
37
|
+
title: string;
|
|
38
|
+
alpha: string;
|
|
39
|
+
hex: string;
|
|
40
|
+
hsl: string;
|
|
41
|
+
}, Record<"alpha" | "hex" | "hsl" | "title", any>>;
|
|
42
|
+
};
|
|
43
|
+
declare const hslaColor: {
|
|
44
|
+
type: "object";
|
|
45
|
+
name: "hslaColor";
|
|
46
|
+
} & Omit<sanity14.ObjectDefinition, "preview"> & {
|
|
47
|
+
preview?: sanity14.PreviewConfig<Record<string, string>, Record<never, any>>;
|
|
48
|
+
};
|
|
49
|
+
declare const hsvaColor: {
|
|
50
|
+
type: "object";
|
|
51
|
+
name: "hsvaColor";
|
|
52
|
+
} & Omit<sanity14.ObjectDefinition, "preview"> & {
|
|
53
|
+
preview?: sanity14.PreviewConfig<Record<string, string>, Record<never, any>>;
|
|
54
|
+
};
|
|
55
|
+
declare const rgbaColor: {
|
|
56
|
+
type: "object";
|
|
57
|
+
name: "rgbaColor";
|
|
58
|
+
} & Omit<sanity14.ObjectDefinition, "preview"> & {
|
|
59
|
+
preview?: sanity14.PreviewConfig<Record<string, string>, Record<never, any>>;
|
|
60
|
+
};
|
|
61
|
+
declare function ColorInput$1(props: ObjectInputProps): react2.JSX.Element;
|
|
62
|
+
declare const ColorInput: react2.LazyExoticComponent<typeof ColorInput$1>;
|
|
63
|
+
declare const colorInput: sanity14.Plugin<void>;
|
|
64
|
+
export { type ColorDefinition, ColorInput, type ColorInputProps, type ColorOptions, type ColorSchemaType, type ColorValue, color, colorInput, hslaColor, hsvaColor, rgbaColor };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { defineType, definePlugin } from "sanity";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { lazy } from "react";
|
|
4
|
+
const ColorInput = lazy(() => import("./_chunks-es/ColorInput.js")), round = (val = 1) => Math.round(val * 100), colorTypeName = "color", color = defineType({
|
|
5
|
+
name: colorTypeName,
|
|
6
|
+
type: "object",
|
|
7
|
+
title: "Color",
|
|
8
|
+
components: {
|
|
9
|
+
input: ColorInput
|
|
10
|
+
},
|
|
11
|
+
fields: [{
|
|
12
|
+
title: "Hex",
|
|
13
|
+
name: "hex",
|
|
14
|
+
type: "string"
|
|
15
|
+
}, {
|
|
16
|
+
title: "Alpha",
|
|
17
|
+
name: "alpha",
|
|
18
|
+
type: "number"
|
|
19
|
+
}, {
|
|
20
|
+
title: "Hue Saturation Lightness",
|
|
21
|
+
name: "hsl",
|
|
22
|
+
type: "hslaColor"
|
|
23
|
+
}, {
|
|
24
|
+
title: "Hue Saturation Value",
|
|
25
|
+
name: "hsv",
|
|
26
|
+
type: "hsvaColor"
|
|
27
|
+
}, {
|
|
28
|
+
title: "Red Green Blue (rgb)",
|
|
29
|
+
name: "rgb",
|
|
30
|
+
type: "rgbaColor"
|
|
31
|
+
}],
|
|
32
|
+
preview: {
|
|
33
|
+
select: {
|
|
34
|
+
title: "hex",
|
|
35
|
+
alpha: "alpha",
|
|
36
|
+
hex: "hex",
|
|
37
|
+
hsl: "hsl"
|
|
38
|
+
},
|
|
39
|
+
prepare({
|
|
40
|
+
title,
|
|
41
|
+
hex,
|
|
42
|
+
hsl,
|
|
43
|
+
alpha
|
|
44
|
+
}) {
|
|
45
|
+
let subtitle = hex || "No color set";
|
|
46
|
+
return hsl && (subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`), {
|
|
47
|
+
title,
|
|
48
|
+
subtitle,
|
|
49
|
+
media: () => /* @__PURE__ */ jsx("div", { style: {
|
|
50
|
+
backgroundColor: hex ?? "#000",
|
|
51
|
+
opacity: alpha ?? 1,
|
|
52
|
+
position: "absolute",
|
|
53
|
+
height: "100%",
|
|
54
|
+
width: "100%",
|
|
55
|
+
top: "0",
|
|
56
|
+
left: "0"
|
|
57
|
+
} })
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}), hslaColor = defineType({
|
|
62
|
+
title: "Hue Saturation Lightness",
|
|
63
|
+
name: "hslaColor",
|
|
64
|
+
type: "object",
|
|
65
|
+
fields: [{
|
|
66
|
+
name: "h",
|
|
67
|
+
type: "number",
|
|
68
|
+
title: "Hue"
|
|
69
|
+
}, {
|
|
70
|
+
name: "s",
|
|
71
|
+
type: "number",
|
|
72
|
+
title: "Saturation"
|
|
73
|
+
}, {
|
|
74
|
+
name: "l",
|
|
75
|
+
type: "number",
|
|
76
|
+
title: "Lightness"
|
|
77
|
+
}, {
|
|
78
|
+
name: "a",
|
|
79
|
+
type: "number",
|
|
80
|
+
title: "Alpha"
|
|
81
|
+
}]
|
|
82
|
+
}), hsvaColor = defineType({
|
|
83
|
+
title: "Hue Saturation Value",
|
|
84
|
+
name: "hsvaColor",
|
|
85
|
+
type: "object",
|
|
86
|
+
fields: [{
|
|
87
|
+
name: "h",
|
|
88
|
+
type: "number",
|
|
89
|
+
title: "Hue"
|
|
90
|
+
}, {
|
|
91
|
+
name: "s",
|
|
92
|
+
type: "number",
|
|
93
|
+
title: "Saturation"
|
|
94
|
+
}, {
|
|
95
|
+
name: "v",
|
|
96
|
+
type: "number",
|
|
97
|
+
title: "Value"
|
|
98
|
+
}, {
|
|
99
|
+
name: "a",
|
|
100
|
+
type: "number",
|
|
101
|
+
title: "Alpha"
|
|
102
|
+
}]
|
|
103
|
+
}), rgbaColor = defineType({
|
|
104
|
+
title: "Red Green Blue (rgb)",
|
|
105
|
+
name: "rgbaColor",
|
|
106
|
+
type: "object",
|
|
107
|
+
fields: [{
|
|
108
|
+
name: "r",
|
|
109
|
+
type: "number",
|
|
110
|
+
title: "Red"
|
|
111
|
+
}, {
|
|
112
|
+
name: "g",
|
|
113
|
+
type: "number",
|
|
114
|
+
title: "Green"
|
|
115
|
+
}, {
|
|
116
|
+
name: "b",
|
|
117
|
+
type: "number",
|
|
118
|
+
title: "Blue"
|
|
119
|
+
}, {
|
|
120
|
+
name: "a",
|
|
121
|
+
type: "number",
|
|
122
|
+
title: "Alpha"
|
|
123
|
+
}]
|
|
124
|
+
}), colorInput = definePlugin({
|
|
125
|
+
name: "@sanity/color-input",
|
|
126
|
+
schema: {
|
|
127
|
+
types: [hslaColor, hsvaColor, rgbaColor, color]
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
export {
|
|
131
|
+
ColorInput,
|
|
132
|
+
color,
|
|
133
|
+
colorInput,
|
|
134
|
+
hslaColor,
|
|
135
|
+
hsvaColor,
|
|
136
|
+
rgbaColor
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=index.js.map
|