@sanity/color-input 3.0.0 → 3.0.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/LICENSE +1 -1
- package/lib/{src/index.d.ts → index.d.ts} +5 -5
- package/lib/index.esm.js +489 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +505 -1
- package/lib/index.js.map +1 -1
- package/package.json +28 -24
- package/src/ColorInput.tsx +5 -3
- package/src/schemas/color.tsx +1 -1
package/LICENSE
CHANGED
|
@@ -36,7 +36,7 @@ export declare interface ColorDefinition
|
|
|
36
36
|
options?: ColorOptions
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export declare function ColorInput(props:
|
|
39
|
+
export declare function ColorInput(props: ObjectInputProps): JSX.Element
|
|
40
40
|
|
|
41
41
|
export declare const colorInput: Plugin_2<void>
|
|
42
42
|
|
|
@@ -83,7 +83,7 @@ export declare const rgbaColor: {
|
|
|
83
83
|
export {}
|
|
84
84
|
|
|
85
85
|
declare module '@sanity/types' {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
86
|
+
interface IntrinsicDefinitions {
|
|
87
|
+
color: ColorDefinition
|
|
88
|
+
}
|
|
89
|
+
}
|
package/lib/index.esm.js
CHANGED
|
@@ -1,2 +1,490 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { defineType, set, setIfMissing, unset, definePlugin } from 'sanity';
|
|
4
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import { useMemo, useCallback, useRef, useState, useEffect } from 'react';
|
|
6
|
+
import { debounce } from 'lodash';
|
|
7
|
+
import { useTheme, Flex, Box, Card, Stack, Text, Inline, Button } from '@sanity/ui';
|
|
8
|
+
import { TrashIcon, AddIcon } from '@sanity/icons';
|
|
9
|
+
import { EditableInput, Saturation, Hue, Alpha, Checkboard } from 'react-color/lib/components/common';
|
|
10
|
+
import { CustomPicker } from 'react-color';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
import { isValidHex } from 'react-color/lib/helpers/color';
|
|
13
|
+
const hslaColor = defineType({
|
|
14
|
+
title: "Hue Saturation Lightness",
|
|
15
|
+
name: "hslaColor",
|
|
16
|
+
type: "object",
|
|
17
|
+
fields: [{
|
|
18
|
+
name: "h",
|
|
19
|
+
type: "number",
|
|
20
|
+
title: "Hue"
|
|
21
|
+
}, {
|
|
22
|
+
name: "s",
|
|
23
|
+
type: "number",
|
|
24
|
+
title: "Saturation"
|
|
25
|
+
}, {
|
|
26
|
+
name: "l",
|
|
27
|
+
type: "number",
|
|
28
|
+
title: "Lightness"
|
|
29
|
+
}, {
|
|
30
|
+
name: "a",
|
|
31
|
+
type: "number",
|
|
32
|
+
title: "Alpha"
|
|
33
|
+
}]
|
|
34
|
+
});
|
|
35
|
+
const rgbaColor = defineType({
|
|
36
|
+
title: "Red Green Blue (rgb)",
|
|
37
|
+
name: "rgbaColor",
|
|
38
|
+
type: "object",
|
|
39
|
+
fields: [{
|
|
40
|
+
name: "r",
|
|
41
|
+
type: "number",
|
|
42
|
+
title: "Red"
|
|
43
|
+
}, {
|
|
44
|
+
name: "g",
|
|
45
|
+
type: "number",
|
|
46
|
+
title: "Green"
|
|
47
|
+
}, {
|
|
48
|
+
name: "b",
|
|
49
|
+
type: "number",
|
|
50
|
+
title: "Blue"
|
|
51
|
+
}, {
|
|
52
|
+
name: "a",
|
|
53
|
+
type: "number",
|
|
54
|
+
title: "Alpha"
|
|
55
|
+
}]
|
|
56
|
+
});
|
|
57
|
+
const ColorPickerFields = _ref => {
|
|
58
|
+
let {
|
|
59
|
+
onChange,
|
|
60
|
+
rgb,
|
|
61
|
+
hsl,
|
|
62
|
+
hex,
|
|
63
|
+
disableAlpha
|
|
64
|
+
} = _ref;
|
|
65
|
+
var _a;
|
|
66
|
+
const {
|
|
67
|
+
sanity
|
|
68
|
+
} = useTheme();
|
|
69
|
+
const inputStyles = useMemo(() => ({
|
|
70
|
+
input: {
|
|
71
|
+
width: "80%",
|
|
72
|
+
padding: "4px 10% 3px",
|
|
73
|
+
border: "none",
|
|
74
|
+
boxShadow: "inset 0 0 0 1px ".concat(sanity.color.input.default.enabled.border),
|
|
75
|
+
color: sanity.color.input.default.enabled.fg,
|
|
76
|
+
backgroundColor: sanity.color.input.default.enabled.bg,
|
|
77
|
+
fontSize: sanity.fonts.text.sizes[0].fontSize,
|
|
78
|
+
textAlign: "center"
|
|
79
|
+
},
|
|
80
|
+
label: {
|
|
81
|
+
display: "block",
|
|
82
|
+
textAlign: "center",
|
|
83
|
+
fontSize: sanity.fonts.label.sizes[0].fontSize,
|
|
84
|
+
color: sanity.color.base.fg,
|
|
85
|
+
paddingTop: "3px",
|
|
86
|
+
paddingBottom: "4px",
|
|
87
|
+
textTransform: "capitalize"
|
|
88
|
+
}
|
|
89
|
+
}), [sanity]);
|
|
90
|
+
const handleChange = useCallback(data => {
|
|
91
|
+
if ("hex" in data && data.hex && isValidHex(data.hex)) {
|
|
92
|
+
onChange({
|
|
93
|
+
hex: data.hex,
|
|
94
|
+
source: "hex"
|
|
95
|
+
});
|
|
96
|
+
} else if (rgb && ("r" in data && data.r || "g" in data && data.g || "b" in data && data.b)) {
|
|
97
|
+
onChange({
|
|
98
|
+
r: Number(data.r) || rgb.r,
|
|
99
|
+
g: Number(data.g) || rgb.g,
|
|
100
|
+
b: Number(data.b) || rgb.b,
|
|
101
|
+
a: rgb.a,
|
|
102
|
+
source: "rgb"
|
|
103
|
+
});
|
|
104
|
+
} else if (hsl && "a" in data && data.a) {
|
|
105
|
+
let alpha = Number(data.a);
|
|
106
|
+
if (alpha < 0) {
|
|
107
|
+
alpha = 0;
|
|
108
|
+
} else if (alpha > 100) {
|
|
109
|
+
alpha = 100;
|
|
110
|
+
}
|
|
111
|
+
alpha /= 100;
|
|
112
|
+
onChange({
|
|
113
|
+
h: hsl.h,
|
|
114
|
+
s: hsl.s,
|
|
115
|
+
l: hsl.l,
|
|
116
|
+
a: alpha,
|
|
117
|
+
source: "hsl"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, [onChange, hsl, rgb]);
|
|
121
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
122
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
123
|
+
flex: 2,
|
|
124
|
+
marginRight: 1,
|
|
125
|
+
children: /* @__PURE__ */jsx(EditableInput, {
|
|
126
|
+
style: inputStyles,
|
|
127
|
+
label: "hex",
|
|
128
|
+
value: hex == null ? void 0 : hex.replace("#", ""),
|
|
129
|
+
onChange: handleChange
|
|
130
|
+
})
|
|
131
|
+
}), /* @__PURE__ */jsx(Box, {
|
|
132
|
+
flex: 1,
|
|
133
|
+
marginRight: 1,
|
|
134
|
+
children: /* @__PURE__ */jsx(EditableInput, {
|
|
135
|
+
style: inputStyles,
|
|
136
|
+
label: "r",
|
|
137
|
+
value: rgb == null ? void 0 : rgb.r,
|
|
138
|
+
onChange: handleChange,
|
|
139
|
+
dragLabel: true,
|
|
140
|
+
dragMax: 255
|
|
141
|
+
})
|
|
142
|
+
}), /* @__PURE__ */jsx(Box, {
|
|
143
|
+
flex: 1,
|
|
144
|
+
marginRight: 1,
|
|
145
|
+
children: /* @__PURE__ */jsx(EditableInput, {
|
|
146
|
+
style: inputStyles,
|
|
147
|
+
label: "g",
|
|
148
|
+
value: rgb == null ? void 0 : rgb.g,
|
|
149
|
+
onChange: handleChange,
|
|
150
|
+
dragLabel: true,
|
|
151
|
+
dragMax: 255
|
|
152
|
+
})
|
|
153
|
+
}), /* @__PURE__ */jsx(Box, {
|
|
154
|
+
flex: 1,
|
|
155
|
+
marginRight: 1,
|
|
156
|
+
children: /* @__PURE__ */jsx(EditableInput, {
|
|
157
|
+
style: inputStyles,
|
|
158
|
+
label: "b",
|
|
159
|
+
value: rgb == null ? void 0 : rgb.b,
|
|
160
|
+
onChange: handleChange,
|
|
161
|
+
dragLabel: true,
|
|
162
|
+
dragMax: 255
|
|
163
|
+
})
|
|
164
|
+
}), !disableAlpha && /* @__PURE__ */jsx(Box, {
|
|
165
|
+
flex: 1,
|
|
166
|
+
children: /* @__PURE__ */jsx(EditableInput, {
|
|
167
|
+
style: inputStyles,
|
|
168
|
+
label: "a",
|
|
169
|
+
value: Math.round(((_a = rgb == null ? void 0 : rgb.a) != null ? _a : 1) * 100),
|
|
170
|
+
onChange: handleChange,
|
|
171
|
+
dragLabel: true,
|
|
172
|
+
dragMax: 100
|
|
173
|
+
})
|
|
174
|
+
})]
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
const ColorBox = styled(Box)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"])));
|
|
178
|
+
const ReadOnlyContainer = styled(Flex)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-top: 6rem;\n background-color: var(--card-bg-color);\n position: relative;\n width: 100%;\n"])));
|
|
179
|
+
const ColorPickerInner = props => {
|
|
180
|
+
var _a, _b, _c;
|
|
181
|
+
const {
|
|
182
|
+
width,
|
|
183
|
+
color: {
|
|
184
|
+
rgb,
|
|
185
|
+
hex,
|
|
186
|
+
hsv,
|
|
187
|
+
hsl
|
|
188
|
+
},
|
|
189
|
+
onChange,
|
|
190
|
+
onUnset,
|
|
191
|
+
disableAlpha,
|
|
192
|
+
readOnly
|
|
193
|
+
} = props;
|
|
194
|
+
if (!hsl || !hsv) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return /* @__PURE__ */jsx("div", {
|
|
198
|
+
style: {
|
|
199
|
+
width
|
|
200
|
+
},
|
|
201
|
+
children: /* @__PURE__ */jsx(Card, {
|
|
202
|
+
padding: 1,
|
|
203
|
+
border: true,
|
|
204
|
+
radius: 1,
|
|
205
|
+
children: /* @__PURE__ */jsxs(Stack, {
|
|
206
|
+
space: 2,
|
|
207
|
+
children: [!readOnly && /* @__PURE__ */jsxs(Fragment, {
|
|
208
|
+
children: [/* @__PURE__ */jsx(Card, {
|
|
209
|
+
overflow: "hidden",
|
|
210
|
+
style: {
|
|
211
|
+
position: "relative",
|
|
212
|
+
height: "5em"
|
|
213
|
+
},
|
|
214
|
+
children: /* @__PURE__ */jsx(Saturation, {
|
|
215
|
+
onChange,
|
|
216
|
+
hsl,
|
|
217
|
+
hsv
|
|
218
|
+
})
|
|
219
|
+
}), /* @__PURE__ */jsx(Card, {
|
|
220
|
+
shadow: 1,
|
|
221
|
+
radius: 3,
|
|
222
|
+
overflow: "hidden",
|
|
223
|
+
style: {
|
|
224
|
+
position: "relative",
|
|
225
|
+
height: "10px"
|
|
226
|
+
},
|
|
227
|
+
children: /* @__PURE__ */jsx(Hue, {
|
|
228
|
+
hsl,
|
|
229
|
+
onChange: !readOnly && onChange
|
|
230
|
+
})
|
|
231
|
+
}), !disableAlpha && /* @__PURE__ */jsx(Card, {
|
|
232
|
+
shadow: 1,
|
|
233
|
+
radius: 3,
|
|
234
|
+
overflow: "hidden",
|
|
235
|
+
style: {
|
|
236
|
+
position: "relative",
|
|
237
|
+
height: "10px"
|
|
238
|
+
},
|
|
239
|
+
children: /* @__PURE__ */jsx(Alpha, {
|
|
240
|
+
rgb,
|
|
241
|
+
hsl,
|
|
242
|
+
onChange
|
|
243
|
+
})
|
|
244
|
+
})]
|
|
245
|
+
}), /* @__PURE__ */jsxs(Flex, {
|
|
246
|
+
children: [/* @__PURE__ */jsxs(Card, {
|
|
247
|
+
flex: 1,
|
|
248
|
+
radius: 2,
|
|
249
|
+
overflow: "hidden",
|
|
250
|
+
style: {
|
|
251
|
+
position: "relative",
|
|
252
|
+
minWidth: "4em"
|
|
253
|
+
},
|
|
254
|
+
children: [/* @__PURE__ */jsx(Checkboard, {}), /* @__PURE__ */jsx(ColorBox, {
|
|
255
|
+
style: {
|
|
256
|
+
backgroundColor: "rgba(".concat(rgb == null ? void 0 : rgb.r, ",").concat(rgb == null ? void 0 : rgb.g, ",").concat(rgb == null ? void 0 : rgb.b, ",").concat(rgb == null ? void 0 : rgb.a, ")")
|
|
257
|
+
}
|
|
258
|
+
}), readOnly && /* @__PURE__ */jsx(ReadOnlyContainer, {
|
|
259
|
+
padding: 2,
|
|
260
|
+
paddingBottom: 1,
|
|
261
|
+
sizing: "border",
|
|
262
|
+
justify: "space-between",
|
|
263
|
+
children: /* @__PURE__ */jsxs(Stack, {
|
|
264
|
+
space: 3,
|
|
265
|
+
marginTop: 1,
|
|
266
|
+
children: [/* @__PURE__ */jsx(Text, {
|
|
267
|
+
size: 3,
|
|
268
|
+
weight: "bold",
|
|
269
|
+
children: hex
|
|
270
|
+
}), /* @__PURE__ */jsxs(Inline, {
|
|
271
|
+
space: 3,
|
|
272
|
+
children: [/* @__PURE__ */jsxs(Text, {
|
|
273
|
+
size: 1,
|
|
274
|
+
children: [/* @__PURE__ */jsx("strong", {
|
|
275
|
+
children: "RGB: "
|
|
276
|
+
}), rgb == null ? void 0 : rgb.r, " ", rgb == null ? void 0 : rgb.g, " ", rgb == null ? void 0 : rgb.b]
|
|
277
|
+
}), /* @__PURE__ */jsxs(Text, {
|
|
278
|
+
size: 1,
|
|
279
|
+
children: [/* @__PURE__ */jsx("strong", {
|
|
280
|
+
children: "HSL: "
|
|
281
|
+
}), " ", Math.round((_a = hsl == null ? void 0 : hsl.h) != null ? _a : 0), " ", Math.round((_b = hsl == null ? void 0 : hsl.s) != null ? _b : 0), "%", " ", Math.round((_c = hsl == null ? void 0 : hsl.l) != null ? _c : 0)]
|
|
282
|
+
})]
|
|
283
|
+
})]
|
|
284
|
+
})
|
|
285
|
+
})]
|
|
286
|
+
}), !readOnly && /* @__PURE__ */jsxs(Flex, {
|
|
287
|
+
align: "flex-start",
|
|
288
|
+
marginLeft: 2,
|
|
289
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
290
|
+
style: {
|
|
291
|
+
width: 200
|
|
292
|
+
},
|
|
293
|
+
children: /* @__PURE__ */jsx(ColorPickerFields, {
|
|
294
|
+
rgb,
|
|
295
|
+
hsl,
|
|
296
|
+
hex,
|
|
297
|
+
onChange,
|
|
298
|
+
disableAlpha
|
|
299
|
+
})
|
|
300
|
+
}), /* @__PURE__ */jsx(Box, {
|
|
301
|
+
marginLeft: 2,
|
|
302
|
+
children: /* @__PURE__ */jsx(Button, {
|
|
303
|
+
onClick: onUnset,
|
|
304
|
+
title: "Delete color",
|
|
305
|
+
icon: TrashIcon,
|
|
306
|
+
tone: "critical"
|
|
307
|
+
})
|
|
308
|
+
})]
|
|
309
|
+
})]
|
|
310
|
+
})]
|
|
311
|
+
})
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
const ColorPicker = CustomPicker(ColorPickerInner);
|
|
316
|
+
const DEFAULT_COLOR = {
|
|
317
|
+
hex: "#24a3e3",
|
|
318
|
+
hsl: {
|
|
319
|
+
h: 200,
|
|
320
|
+
s: 0.7732,
|
|
321
|
+
l: 0.5156,
|
|
322
|
+
a: 1
|
|
323
|
+
},
|
|
324
|
+
hsv: {
|
|
325
|
+
h: 200,
|
|
326
|
+
s: 0.8414,
|
|
327
|
+
v: 0.8901,
|
|
328
|
+
a: 1
|
|
329
|
+
},
|
|
330
|
+
rgb: {
|
|
331
|
+
r: 46,
|
|
332
|
+
g: 163,
|
|
333
|
+
b: 227,
|
|
334
|
+
a: 1
|
|
335
|
+
},
|
|
336
|
+
source: "hex"
|
|
337
|
+
};
|
|
338
|
+
function ColorInput(props) {
|
|
339
|
+
var _a;
|
|
340
|
+
const {
|
|
341
|
+
onChange,
|
|
342
|
+
readOnly
|
|
343
|
+
} = props;
|
|
344
|
+
const value = props.value;
|
|
345
|
+
const type = props.schemaType;
|
|
346
|
+
const focusRef = useRef(null);
|
|
347
|
+
const [color, setColor] = useState(value);
|
|
348
|
+
useEffect(() => setColor(value), [value]);
|
|
349
|
+
const emitSetColor = useCallback(nextColor => {
|
|
350
|
+
var _a2;
|
|
351
|
+
const fieldPatches = type.fields.filter(field => field.name in nextColor).map(field => {
|
|
352
|
+
const nextFieldValue = nextColor[field.name];
|
|
353
|
+
const isObject = field.type.jsonType === "object";
|
|
354
|
+
return set(isObject ? Object.assign({
|
|
355
|
+
_type: field.type.name
|
|
356
|
+
}, nextFieldValue) : nextFieldValue, [field.name]);
|
|
357
|
+
});
|
|
358
|
+
onChange([setIfMissing({
|
|
359
|
+
_type: type.name
|
|
360
|
+
}), set(type.name, ["_type"]), set((_a2 = nextColor.rgb) == null ? void 0 : _a2.a, ["alpha"]), ...fieldPatches]);
|
|
361
|
+
}, [onChange, type]);
|
|
362
|
+
const debouncedColorChange = useMemo(() => debounce(emitSetColor, 100), [emitSetColor]);
|
|
363
|
+
const handleColorChange = useCallback(nextColor => {
|
|
364
|
+
setColor(nextColor);
|
|
365
|
+
debouncedColorChange(nextColor);
|
|
366
|
+
}, [debouncedColorChange, setColor]);
|
|
367
|
+
const handleCreateColor = useCallback(() => {
|
|
368
|
+
setColor(DEFAULT_COLOR);
|
|
369
|
+
emitSetColor(DEFAULT_COLOR);
|
|
370
|
+
}, [emitSetColor]);
|
|
371
|
+
const handleUnset = useCallback(() => {
|
|
372
|
+
setColor(void 0);
|
|
373
|
+
onChange(unset());
|
|
374
|
+
}, [onChange]);
|
|
375
|
+
return /* @__PURE__ */jsx(Fragment, {
|
|
376
|
+
children: value && value.hex ? /* @__PURE__ */jsx(ColorPicker, {
|
|
377
|
+
color,
|
|
378
|
+
onChange: handleColorChange,
|
|
379
|
+
readOnly: readOnly || typeof type.readOnly === "boolean" && type.readOnly,
|
|
380
|
+
disableAlpha: !!((_a = type.options) == null ? void 0 : _a.disableAlpha),
|
|
381
|
+
onUnset: handleUnset
|
|
382
|
+
}) : /* @__PURE__ */jsx(Button, {
|
|
383
|
+
icon: AddIcon,
|
|
384
|
+
mode: "ghost",
|
|
385
|
+
text: "Create color",
|
|
386
|
+
ref: focusRef,
|
|
387
|
+
disabled: Boolean(readOnly),
|
|
388
|
+
onClick: handleCreateColor
|
|
389
|
+
})
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
const round = function () {
|
|
393
|
+
let val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
394
|
+
return Math.round(val * 100);
|
|
395
|
+
};
|
|
396
|
+
const colorTypeName = "color";
|
|
397
|
+
const color = defineType({
|
|
398
|
+
name: colorTypeName,
|
|
399
|
+
type: "object",
|
|
400
|
+
title: "Color",
|
|
401
|
+
components: {
|
|
402
|
+
input: ColorInput
|
|
403
|
+
},
|
|
404
|
+
fields: [{
|
|
405
|
+
title: "Hex",
|
|
406
|
+
name: "hex",
|
|
407
|
+
type: "string"
|
|
408
|
+
}, {
|
|
409
|
+
title: "Alpha",
|
|
410
|
+
name: "alpha",
|
|
411
|
+
type: "number"
|
|
412
|
+
}, {
|
|
413
|
+
title: "Hue Saturation Lightness",
|
|
414
|
+
name: "hsl",
|
|
415
|
+
type: "hslaColor"
|
|
416
|
+
}, {
|
|
417
|
+
title: "Hue Saturation Value",
|
|
418
|
+
name: "hsv",
|
|
419
|
+
type: "hsvaColor"
|
|
420
|
+
}, {
|
|
421
|
+
title: "Red Green Blue (rgb)",
|
|
422
|
+
name: "rgb",
|
|
423
|
+
type: "rgbaColor"
|
|
424
|
+
}],
|
|
425
|
+
preview: {
|
|
426
|
+
select: {
|
|
427
|
+
title: "hex",
|
|
428
|
+
alpha: "alpha",
|
|
429
|
+
hex: "hex",
|
|
430
|
+
hsl: "hsl"
|
|
431
|
+
},
|
|
432
|
+
prepare(_ref2) {
|
|
433
|
+
let {
|
|
434
|
+
title,
|
|
435
|
+
hex,
|
|
436
|
+
hsl,
|
|
437
|
+
alpha
|
|
438
|
+
} = _ref2;
|
|
439
|
+
let subtitle = hex || "No color set";
|
|
440
|
+
if (hsl) {
|
|
441
|
+
subtitle = "H:".concat(round(hsl.h), " S:").concat(round(hsl.s), " L:").concat(round(hsl.l), " A:").concat(round(alpha));
|
|
442
|
+
}
|
|
443
|
+
return {
|
|
444
|
+
title,
|
|
445
|
+
subtitle,
|
|
446
|
+
media: () => /* @__PURE__ */jsx("div", {
|
|
447
|
+
style: {
|
|
448
|
+
backgroundColor: hex != null ? hex : "#000",
|
|
449
|
+
opacity: alpha != null ? alpha : 1,
|
|
450
|
+
position: "absolute",
|
|
451
|
+
height: "100%",
|
|
452
|
+
width: "100%",
|
|
453
|
+
top: "0",
|
|
454
|
+
left: "0"
|
|
455
|
+
}
|
|
456
|
+
})
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
const hsvaColor = defineType({
|
|
462
|
+
title: "Hue Saturation Value",
|
|
463
|
+
name: "hsvaColor",
|
|
464
|
+
type: "object",
|
|
465
|
+
fields: [{
|
|
466
|
+
name: "h",
|
|
467
|
+
type: "number",
|
|
468
|
+
title: "Hue"
|
|
469
|
+
}, {
|
|
470
|
+
name: "s",
|
|
471
|
+
type: "number",
|
|
472
|
+
title: "Saturation"
|
|
473
|
+
}, {
|
|
474
|
+
name: "v",
|
|
475
|
+
type: "number",
|
|
476
|
+
title: "Value"
|
|
477
|
+
}, {
|
|
478
|
+
name: "a",
|
|
479
|
+
type: "number",
|
|
480
|
+
title: "Alpha"
|
|
481
|
+
}]
|
|
482
|
+
});
|
|
483
|
+
const colorInput = definePlugin({
|
|
484
|
+
name: "@sanity/color-input",
|
|
485
|
+
schema: {
|
|
486
|
+
types: [hslaColor, hsvaColor, rgbaColor, color]
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
export { ColorInput, color, colorInput, hslaColor, hsvaColor, rgbaColor };
|
|
2
490
|
//# sourceMappingURL=index.esm.js.map
|