@sanity/color-input 3.0.0-v3-studio.5 → 3.0.0-v3-studio.6
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/lib/cjs/index.js +20 -16
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js +16 -12
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts +36 -59
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/ColorInput.tsx +4 -4
- package/src/index.ts +2 -1
- package/src/schemas/color.tsx +22 -4
- package/src/schemas/hslaColor.ts +4 -2
- package/src/schemas/hsvaColor.ts +4 -2
- package/src/schemas/rgbaColor.ts +4 -2
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var $k7rGe$sanity = require("sanity");
|
|
2
2
|
var $k7rGe$reactjsxruntime = require("react/jsx-runtime");
|
|
3
3
|
var $k7rGe$react = require("react");
|
|
4
|
-
var $k7rGe$sanityform = require("sanity/form");
|
|
5
4
|
var $k7rGe$lodash = require("lodash");
|
|
6
5
|
var $k7rGe$sanityui = require("@sanity/ui");
|
|
7
6
|
var $k7rGe$sanityicons = require("@sanity/icons");
|
|
@@ -24,7 +23,8 @@ $parcel$export(module.exports, "color", () => $1ba04456571fe4ef$export$35e9368ef
|
|
|
24
23
|
$parcel$export(module.exports, "hsvaColor", () => $ebd6b32193e371d0$export$633851ea6f85c81b);
|
|
25
24
|
$parcel$export(module.exports, "ColorInput", () => $50859b401fad6cb5$export$5a1d7ca0a925d9c2);
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
const $f424886802e2a804$export$4e4b8c12b77623c0 = (0, $k7rGe$sanity.defineType)({
|
|
28
28
|
title: "Hue Saturation Lightness",
|
|
29
29
|
name: "hslaColor",
|
|
30
30
|
type: "object",
|
|
@@ -50,10 +50,11 @@ const $f424886802e2a804$export$4e4b8c12b77623c0 = {
|
|
|
50
50
|
title: "Alpha"
|
|
51
51
|
},
|
|
52
52
|
]
|
|
53
|
-
};
|
|
53
|
+
});
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
|
|
57
|
+
const $6707e7c5509edbba$export$cc215b4b2c268dfd = (0, $k7rGe$sanity.defineType)({
|
|
57
58
|
title: "Red Green Blue (rgb)",
|
|
58
59
|
name: "rgbaColor",
|
|
59
60
|
type: "object",
|
|
@@ -79,7 +80,7 @@ const $6707e7c5509edbba$export$cc215b4b2c268dfd = {
|
|
|
79
80
|
title: "Alpha"
|
|
80
81
|
},
|
|
81
82
|
]
|
|
82
|
-
};
|
|
83
|
+
});
|
|
83
84
|
|
|
84
85
|
|
|
85
86
|
|
|
@@ -430,20 +431,20 @@ function $50859b401fad6cb5$export$5a1d7ca0a925d9c2(props) {
|
|
|
430
431
|
const fieldPatches = type.fields.filter((field)=>field.name in nextColor).map((field)=>{
|
|
431
432
|
const nextFieldValue = nextColor[field.name];
|
|
432
433
|
const isObject = field.type.jsonType === "object";
|
|
433
|
-
return (0, $k7rGe$
|
|
434
|
+
return (0, $k7rGe$sanity.set)(isObject ? Object.assign({
|
|
434
435
|
_type: field.type.name
|
|
435
436
|
}, nextFieldValue) : nextFieldValue, [
|
|
436
437
|
field.name
|
|
437
438
|
]);
|
|
438
439
|
});
|
|
439
440
|
onChange([
|
|
440
|
-
(0, $k7rGe$
|
|
441
|
+
(0, $k7rGe$sanity.setIfMissing)({
|
|
441
442
|
_type: type.name
|
|
442
443
|
}),
|
|
443
|
-
(0, $k7rGe$
|
|
444
|
+
(0, $k7rGe$sanity.set)(type.name, [
|
|
444
445
|
"_type"
|
|
445
446
|
]),
|
|
446
|
-
(0, $k7rGe$
|
|
447
|
+
(0, $k7rGe$sanity.set)(nextColor.rgb?.a, [
|
|
447
448
|
"alpha"
|
|
448
449
|
]),
|
|
449
450
|
...fieldPatches,
|
|
@@ -472,7 +473,7 @@ function $50859b401fad6cb5$export$5a1d7ca0a925d9c2(props) {
|
|
|
472
473
|
]);
|
|
473
474
|
const handleUnset = (0, $k7rGe$react.useCallback)(()=>{
|
|
474
475
|
setColor(undefined);
|
|
475
|
-
onChange((0, $k7rGe$
|
|
476
|
+
onChange((0, $k7rGe$sanity.unset)());
|
|
476
477
|
}, [
|
|
477
478
|
onChange
|
|
478
479
|
]);
|
|
@@ -481,7 +482,7 @@ function $50859b401fad6cb5$export$5a1d7ca0a925d9c2(props) {
|
|
|
481
482
|
/* ref={this.focusRef}*/ color: color,
|
|
482
483
|
onChange: handleColorChange,
|
|
483
484
|
readOnly: readOnly || typeof type.readOnly === "boolean" && type.readOnly,
|
|
484
|
-
disableAlpha: type.options?.disableAlpha,
|
|
485
|
+
disableAlpha: !!type.options?.disableAlpha,
|
|
485
486
|
onUnset: handleUnset
|
|
486
487
|
}) : /*#__PURE__*/ (0, $k7rGe$reactjsxruntime.jsx)((0, $k7rGe$sanityui.Button), {
|
|
487
488
|
icon: (0, $k7rGe$sanityicons.AddIcon),
|
|
@@ -495,9 +496,11 @@ function $50859b401fad6cb5$export$5a1d7ca0a925d9c2(props) {
|
|
|
495
496
|
}
|
|
496
497
|
|
|
497
498
|
|
|
499
|
+
|
|
498
500
|
const $1ba04456571fe4ef$var$round = (val = 1)=>Math.round(val * 100);
|
|
499
|
-
const $1ba04456571fe4ef$
|
|
500
|
-
|
|
501
|
+
const $1ba04456571fe4ef$var$colorTypeName = "color";
|
|
502
|
+
const $1ba04456571fe4ef$export$35e9368ef982300f = (0, $k7rGe$sanity.defineType)({
|
|
503
|
+
name: $1ba04456571fe4ef$var$colorTypeName,
|
|
501
504
|
type: "object",
|
|
502
505
|
title: "Color",
|
|
503
506
|
components: {
|
|
@@ -557,10 +560,11 @@ const $1ba04456571fe4ef$export$35e9368ef982300f = {
|
|
|
557
560
|
};
|
|
558
561
|
}
|
|
559
562
|
}
|
|
560
|
-
};
|
|
563
|
+
});
|
|
561
564
|
|
|
562
565
|
|
|
563
|
-
|
|
566
|
+
|
|
567
|
+
const $ebd6b32193e371d0$export$633851ea6f85c81b = (0, $k7rGe$sanity.defineType)({
|
|
564
568
|
title: "Hue Saturation Value",
|
|
565
569
|
name: "hsvaColor",
|
|
566
570
|
type: "object",
|
|
@@ -586,7 +590,7 @@ const $ebd6b32193e371d0$export$633851ea6f85c81b = {
|
|
|
586
590
|
title: "Alpha"
|
|
587
591
|
},
|
|
588
592
|
]
|
|
589
|
-
};
|
|
593
|
+
});
|
|
590
594
|
|
|
591
595
|
|
|
592
596
|
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAO,MAAM,yCAAS,GAAG;IACvB,KAAK,EAAE,0BAA0B;IACjC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,YAAY;SAAC;QAChD;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,WAAW;SAAC;QAC/C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;KAC5C;CACF;;;ACVM,MAAM,yCAAS,GAAG;IACvB,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;QAC3C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,K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,KAAK,EAAE;YAAC,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAK,CAAA;SAAC;KAChD;CACF,CAAC","sources":["src/index.ts","src/schemas/hslaColor.ts","src/schemas/rgbaColor.ts","src/schemas/color.tsx","src/ColorInput.tsx","src/ColorPicker.tsx","src/ColorPickerFields.tsx","src/schemas/hsvaColor.ts"],"sourcesContent":["import {createPlugin} from 'sanity'\nimport {hslaColor} from './schemas/hslaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\nimport {color} from './schemas/color'\nimport {hsvaColor} from './schemas/hsvaColor'\n\nexport const colorInput = createPlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {hslaColor, rgbaColor, color, hsvaColor}\nexport {ColorInput} from './ColorInput'\nexport type {ColorValue, ColorInputProps, ColorOptions, ColorSchemaType} from './ColorInput'\n","export const hslaColor = {\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n}\n","export const rgbaColor = {\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n}\n","import React from 'react'\nimport {ColorInput} from '../ColorInput'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nexport const color = {\n name: 'color',\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n}\n","import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'\nimport {set, setIfMissing, unset} from 'sanity/form'\nimport {debounce} from 'lodash'\nimport {Button} from '@sanity/ui'\nimport {AddIcon} from '@sanity/icons'\nimport {ColorPicker} from './ColorPicker'\nimport {ObjectInputProps} from 'sanity'\nimport {HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {ObjectSchemaType} from 'sanity'\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 interface ColorValue {\n hex: string\n hsl: HSLColor\n hsv: HSVColor\n rgb: RGBColor\n}\n\nexport interface ColorOptions {\n disableAlpha?: boolean\n}\n\nexport type ColorSchemaType = ObjectSchemaType & {\n options?: ColorOptions\n}\nexport type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>\n\nexport function ColorInput(props: ColorInputProps) {\n const {onChange, schemaType: type, readOnly, value} = props\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 useEffect(() => setColor(value), [value])\n\n const emitSetColor = useCallback(\n (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 [onChange, type]\n )\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 const debouncedColorChange = useMemo(() => debounce(emitSetColor, 100), [emitSetColor])\n const handleColorChange = useCallback(\n (nextColor: ColorValue) => {\n setColor(nextColor)\n debouncedColorChange(nextColor)\n },\n [debouncedColorChange, setColor]\n )\n\n const handleCreateColor = useCallback(() => {\n setColor(DEFAULT_COLOR)\n emitSetColor(DEFAULT_COLOR)\n }, [emitSetColor])\n\n const handleUnset = useCallback(() => {\n setColor(undefined)\n onChange(unset())\n }, [onChange])\n\n return (\n <>\n {value ? (\n <ColorPicker\n /* ref={this.focusRef}*/\n color={color}\n onChange={handleColorChange}\n readOnly={readOnly || (typeof type.readOnly === 'boolean' && type.readOnly)}\n disableAlpha={type.options?.disableAlpha}\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","import React from 'react'\nimport {Alpha, Checkboard, Hue, Saturation} from 'react-color/lib/components/common'\nimport {CustomPicker, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {Box, Button, Card, Flex, Inline, Stack, Text} from '@sanity/ui'\nimport {TrashIcon} from '@sanity/icons'\nimport styled from 'styled-components'\nimport {ColorPickerFields} from './ColorPickerFields'\nimport {CustomPickerInjectedProps} from 'react-color/lib/components/common/ColorWrap'\nimport {ColorValue} from './ColorInput'\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\nexport interface ColorPickerProps\n extends CustomPickerInjectedProps<HSLColor | HSVColor | RGBColor | HEXColor> {\n width?: string\n disableAlpha: boolean\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 readOnly,\n } = props\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'}}\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'}}\n >\n <Checkboard />\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)} {Math.round(hsl?.s ?? 0)}%{' '}\n {Math.round(hsl?.l ?? 0)}\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 </Stack>\n </Card>\n </div>\n )\n}\n\nexport const ColorPicker = CustomPicker(ColorPickerInner)\n","import React, {useCallback, useMemo} from 'react'\n// @ts-expect-error missing export\nimport {isValidHex} from 'react-color/lib/helpers/color'\nimport {EditableInput} from 'react-color/lib/components/common'\nimport {Box, Flex, useTheme} from '@sanity/ui'\nimport {ColorChangeHandler, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {EditableInputStyles} from 'react-color/lib/components/common/EditableInput'\n\ninterface ColorPickerFieldsProps {\n rgb?: RGBColor\n hsl?: HSLColor\n hex?: string\n disableAlpha: boolean\n onChange: ColorChangeHandler<HSLColor | HSVColor | RGBColor | HEXColor>\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","export const hsvaColor = {\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AAEO,MAAM,yCAAS,GAAG,CAAA,GAAA,wBAAU,CAAA,CAAC;IAClC,KAAK,EAAE,0BAA0B;IACjC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,YAAY;SAAC;QAChD;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,WAAW;SAAC;QAC/C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;KAC5C;CACF,CAAC;;;ACZF;AAEO,MAAM,yCAAS,GAAG,CAAA,GAAA,wBAAU,CAAA,CAAC;IAClC,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,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OAAO;SAAC;QAC3C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;KAC5C;CACF,CAAC;;;;APNK,MAAM,yCAAU,GAAG,CAAA,GAAA,0BAAY,CAAA,CAAC;IACrC,IAAI,EAAE,qBAAqB;IAC3B,MAAM,EAAE;QACN,KAAK,EAAE;YAAC,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAK,CAAA;SAAC;KAChD;CACF,CAAC","sources":["src/index.ts","src/schemas/hslaColor.ts","src/schemas/rgbaColor.ts","src/schemas/color.tsx","src/ColorInput.tsx","src/ColorPicker.tsx","src/ColorPickerFields.tsx","src/schemas/hsvaColor.ts"],"sourcesContent":["import {createPlugin} from 'sanity'\nimport {hslaColor} from './schemas/hslaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\nimport {color, ColorDefinition} from './schemas/color'\nimport {hsvaColor} from './schemas/hsvaColor'\n\nexport const colorInput = createPlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {hslaColor, rgbaColor, color, hsvaColor}\nexport {ColorInput} from './ColorInput'\nexport type {ColorDefinition}\nexport type {ColorValue, ColorInputProps, ColorOptions, ColorSchemaType} from './ColorInput'\n","import {defineType} from 'sanity'\n\nexport const hslaColor = defineType({\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const rgbaColor = defineType({\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import React from 'react'\nimport {ColorInput, ColorOptions} from '../ColorInput'\nimport {defineType, ObjectDefinition} from 'sanity'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nconst colorTypeName = 'color' as const\n\n/**\n * @public\n */\nexport interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {\n type: typeof colorTypeName\n options?: ColorOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n color: ColorDefinition\n }\n}\n\nexport const color = defineType({\n name: colorTypeName,\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n})\n","import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'\nimport {ObjectOptions, set, setIfMissing, unset} from 'sanity'\nimport {debounce} from 'lodash'\nimport {Button} from '@sanity/ui'\nimport {AddIcon} from '@sanity/icons'\nimport {ColorPicker} from './ColorPicker'\nimport {ObjectInputProps} from 'sanity'\nimport {HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {ObjectSchemaType} from 'sanity'\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 interface ColorValue {\n hex: string\n hsl: HSLColor\n hsv: HSVColor\n rgb: RGBColor\n}\n\nexport interface ColorOptions extends Omit<ObjectOptions, 'columns'> {\n disableAlpha?: boolean\n}\n\nexport type ColorSchemaType = Omit<ObjectSchemaType, 'options'> & {\n options?: ColorOptions\n}\nexport type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>\n\nexport function ColorInput(props: ColorInputProps) {\n const {onChange, schemaType: type, readOnly, value} = props\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 useEffect(() => setColor(value), [value])\n\n const emitSetColor = useCallback(\n (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 [onChange, type]\n )\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 const debouncedColorChange = useMemo(() => debounce(emitSetColor, 100), [emitSetColor])\n const handleColorChange = useCallback(\n (nextColor: ColorValue) => {\n setColor(nextColor)\n debouncedColorChange(nextColor)\n },\n [debouncedColorChange, setColor]\n )\n\n const handleCreateColor = useCallback(() => {\n setColor(DEFAULT_COLOR)\n emitSetColor(DEFAULT_COLOR)\n }, [emitSetColor])\n\n const handleUnset = useCallback(() => {\n setColor(undefined)\n onChange(unset())\n }, [onChange])\n\n return (\n <>\n {value ? (\n <ColorPicker\n /* ref={this.focusRef}*/\n color={color}\n onChange={handleColorChange}\n readOnly={readOnly || (typeof type.readOnly === 'boolean' && type.readOnly)}\n disableAlpha={!!type.options?.disableAlpha}\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","import React from 'react'\nimport {Alpha, Checkboard, Hue, Saturation} from 'react-color/lib/components/common'\nimport {CustomPicker, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {Box, Button, Card, Flex, Inline, Stack, Text} from '@sanity/ui'\nimport {TrashIcon} from '@sanity/icons'\nimport styled from 'styled-components'\nimport {ColorPickerFields} from './ColorPickerFields'\nimport {CustomPickerInjectedProps} from 'react-color/lib/components/common/ColorWrap'\nimport {ColorValue} from './ColorInput'\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\nexport interface ColorPickerProps\n extends CustomPickerInjectedProps<HSLColor | HSVColor | RGBColor | HEXColor> {\n width?: string\n disableAlpha: boolean\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 readOnly,\n } = props\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'}}\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'}}\n >\n <Checkboard />\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)} {Math.round(hsl?.s ?? 0)}%{' '}\n {Math.round(hsl?.l ?? 0)}\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 </Stack>\n </Card>\n </div>\n )\n}\n\nexport const ColorPicker = CustomPicker(ColorPickerInner)\n","import React, {useCallback, useMemo} from 'react'\n// @ts-expect-error missing export\nimport {isValidHex} from 'react-color/lib/helpers/color'\nimport {EditableInput} from 'react-color/lib/components/common'\nimport {Box, Flex, useTheme} from '@sanity/ui'\nimport {ColorChangeHandler, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {EditableInputStyles} from 'react-color/lib/components/common/EditableInput'\n\ninterface ColorPickerFieldsProps {\n rgb?: RGBColor\n hsl?: HSLColor\n hex?: string\n disableAlpha: boolean\n onChange: ColorChangeHandler<HSLColor | HSVColor | RGBColor | HEXColor>\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 {defineType} from 'sanity'\n\nexport const hsvaColor = defineType({\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {createPlugin as $gGrEF$createPlugin} from "sanity";
|
|
1
|
+
import {createPlugin as $gGrEF$createPlugin, defineType as $gGrEF$defineType, set as $gGrEF$set, setIfMissing as $gGrEF$setIfMissing, unset as $gGrEF$unset} from "sanity";
|
|
2
2
|
import {jsx as $gGrEF$jsx, Fragment as $gGrEF$Fragment, jsxs as $gGrEF$jsxs} from "react/jsx-runtime";
|
|
3
3
|
import {useRef as $gGrEF$useRef, useState as $gGrEF$useState, useEffect as $gGrEF$useEffect, useCallback as $gGrEF$useCallback, useMemo as $gGrEF$useMemo} from "react";
|
|
4
|
-
import {set as $gGrEF$set, setIfMissing as $gGrEF$setIfMissing, unset as $gGrEF$unset} from "sanity/form";
|
|
5
4
|
import {debounce as $gGrEF$debounce} from "lodash";
|
|
6
5
|
import {Button as $gGrEF$Button, Box as $gGrEF$Box, Flex as $gGrEF$Flex, Card as $gGrEF$Card, Stack as $gGrEF$Stack, Text as $gGrEF$Text, Inline as $gGrEF$Inline, useTheme as $gGrEF$useTheme} from "@sanity/ui";
|
|
7
6
|
import {AddIcon as $gGrEF$AddIcon, TrashIcon as $gGrEF$TrashIcon} from "@sanity/icons";
|
|
@@ -11,7 +10,8 @@ import $gGrEF$styledcomponents from "styled-components";
|
|
|
11
10
|
import {isValidHex as $gGrEF$isValidHex} from "react-color/lib/helpers/color";
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
const $88b170db27d5e6f3$export$4e4b8c12b77623c0 = (0, $gGrEF$defineType)({
|
|
15
15
|
title: "Hue Saturation Lightness",
|
|
16
16
|
name: "hslaColor",
|
|
17
17
|
type: "object",
|
|
@@ -37,10 +37,11 @@ const $88b170db27d5e6f3$export$4e4b8c12b77623c0 = {
|
|
|
37
37
|
title: "Alpha"
|
|
38
38
|
},
|
|
39
39
|
]
|
|
40
|
-
};
|
|
40
|
+
});
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
const $37ec22070cd01c8b$export$cc215b4b2c268dfd = (0, $gGrEF$defineType)({
|
|
44
45
|
title: "Red Green Blue (rgb)",
|
|
45
46
|
name: "rgbaColor",
|
|
46
47
|
type: "object",
|
|
@@ -66,7 +67,7 @@ const $37ec22070cd01c8b$export$cc215b4b2c268dfd = {
|
|
|
66
67
|
title: "Alpha"
|
|
67
68
|
},
|
|
68
69
|
]
|
|
69
|
-
};
|
|
70
|
+
});
|
|
70
71
|
|
|
71
72
|
|
|
72
73
|
|
|
@@ -468,7 +469,7 @@ function $9a1b799aa4bfa9c5$export$5a1d7ca0a925d9c2(props) {
|
|
|
468
469
|
/* ref={this.focusRef}*/ color: color,
|
|
469
470
|
onChange: handleColorChange,
|
|
470
471
|
readOnly: readOnly || typeof type.readOnly === "boolean" && type.readOnly,
|
|
471
|
-
disableAlpha: type.options?.disableAlpha,
|
|
472
|
+
disableAlpha: !!type.options?.disableAlpha,
|
|
472
473
|
onUnset: handleUnset
|
|
473
474
|
}) : /*#__PURE__*/ (0, $gGrEF$jsx)((0, $gGrEF$Button), {
|
|
474
475
|
icon: (0, $gGrEF$AddIcon),
|
|
@@ -482,9 +483,11 @@ function $9a1b799aa4bfa9c5$export$5a1d7ca0a925d9c2(props) {
|
|
|
482
483
|
}
|
|
483
484
|
|
|
484
485
|
|
|
486
|
+
|
|
485
487
|
const $771ddc1e2be43f68$var$round = (val = 1)=>Math.round(val * 100);
|
|
486
|
-
const $771ddc1e2be43f68$
|
|
487
|
-
|
|
488
|
+
const $771ddc1e2be43f68$var$colorTypeName = "color";
|
|
489
|
+
const $771ddc1e2be43f68$export$35e9368ef982300f = (0, $gGrEF$defineType)({
|
|
490
|
+
name: $771ddc1e2be43f68$var$colorTypeName,
|
|
488
491
|
type: "object",
|
|
489
492
|
title: "Color",
|
|
490
493
|
components: {
|
|
@@ -544,10 +547,11 @@ const $771ddc1e2be43f68$export$35e9368ef982300f = {
|
|
|
544
547
|
};
|
|
545
548
|
}
|
|
546
549
|
}
|
|
547
|
-
};
|
|
550
|
+
});
|
|
548
551
|
|
|
549
552
|
|
|
550
|
-
|
|
553
|
+
|
|
554
|
+
const $b26c91ff9252c28d$export$633851ea6f85c81b = (0, $gGrEF$defineType)({
|
|
551
555
|
title: "Hue Saturation Value",
|
|
552
556
|
name: "hsvaColor",
|
|
553
557
|
type: "object",
|
|
@@ -573,7 +577,7 @@ const $b26c91ff9252c28d$export$633851ea6f85c81b = {
|
|
|
573
577
|
title: "Alpha"
|
|
574
578
|
},
|
|
575
579
|
]
|
|
576
|
-
};
|
|
580
|
+
});
|
|
577
581
|
|
|
578
582
|
|
|
579
583
|
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;ACAO,MAAM,yCAAS,GAAG;IACvB,KAAK,EAAE,0BAA0B;IACjC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,YAAY;SAAC;QAChD;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,WAAW;SAAC;QAC/C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;KAC5C;CACF;;;ACVM,MAAM,yCAAS,GAAG;IACvB,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;QAC3C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,MAAM;SAAC;QAC1C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC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,CAAC","sources":["src/index.ts","src/schemas/hslaColor.ts","src/schemas/rgbaColor.ts","src/schemas/color.tsx","src/ColorInput.tsx","src/ColorPicker.tsx","src/ColorPickerFields.tsx","src/schemas/hsvaColor.ts"],"sourcesContent":["import {createPlugin} from 'sanity'\nimport {hslaColor} from './schemas/hslaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\nimport {color} from './schemas/color'\nimport {hsvaColor} from './schemas/hsvaColor'\n\nexport const colorInput = createPlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {hslaColor, rgbaColor, color, hsvaColor}\nexport {ColorInput} from './ColorInput'\nexport type {ColorValue, ColorInputProps, ColorOptions, ColorSchemaType} from './ColorInput'\n","export const hslaColor = {\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n}\n","export const rgbaColor = {\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n}\n","import React from 'react'\nimport {ColorInput} from '../ColorInput'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nexport const color = {\n name: 'color',\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n}\n","import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'\nimport {set, setIfMissing, unset} from 'sanity/form'\nimport {debounce} from 'lodash'\nimport {Button} from '@sanity/ui'\nimport {AddIcon} from '@sanity/icons'\nimport {ColorPicker} from './ColorPicker'\nimport {ObjectInputProps} from 'sanity'\nimport {HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {ObjectSchemaType} from 'sanity'\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 interface ColorValue {\n hex: string\n hsl: HSLColor\n hsv: HSVColor\n rgb: RGBColor\n}\n\nexport interface ColorOptions {\n disableAlpha?: boolean\n}\n\nexport type ColorSchemaType = ObjectSchemaType & {\n options?: ColorOptions\n}\nexport type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>\n\nexport function ColorInput(props: ColorInputProps) {\n const {onChange, schemaType: type, readOnly, value} = props\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 useEffect(() => setColor(value), [value])\n\n const emitSetColor = useCallback(\n (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 [onChange, type]\n )\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 const debouncedColorChange = useMemo(() => debounce(emitSetColor, 100), [emitSetColor])\n const handleColorChange = useCallback(\n (nextColor: ColorValue) => {\n setColor(nextColor)\n debouncedColorChange(nextColor)\n },\n [debouncedColorChange, setColor]\n )\n\n const handleCreateColor = useCallback(() => {\n setColor(DEFAULT_COLOR)\n emitSetColor(DEFAULT_COLOR)\n }, [emitSetColor])\n\n const handleUnset = useCallback(() => {\n setColor(undefined)\n onChange(unset())\n }, [onChange])\n\n return (\n <>\n {value ? (\n <ColorPicker\n /* ref={this.focusRef}*/\n color={color}\n onChange={handleColorChange}\n readOnly={readOnly || (typeof type.readOnly === 'boolean' && type.readOnly)}\n disableAlpha={type.options?.disableAlpha}\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","import React from 'react'\nimport {Alpha, Checkboard, Hue, Saturation} from 'react-color/lib/components/common'\nimport {CustomPicker, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {Box, Button, Card, Flex, Inline, Stack, Text} from '@sanity/ui'\nimport {TrashIcon} from '@sanity/icons'\nimport styled from 'styled-components'\nimport {ColorPickerFields} from './ColorPickerFields'\nimport {CustomPickerInjectedProps} from 'react-color/lib/components/common/ColorWrap'\nimport {ColorValue} from './ColorInput'\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\nexport interface ColorPickerProps\n extends CustomPickerInjectedProps<HSLColor | HSVColor | RGBColor | HEXColor> {\n width?: string\n disableAlpha: boolean\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 readOnly,\n } = props\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'}}\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'}}\n >\n <Checkboard />\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)} {Math.round(hsl?.s ?? 0)}%{' '}\n {Math.round(hsl?.l ?? 0)}\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 </Stack>\n </Card>\n </div>\n )\n}\n\nexport const ColorPicker = CustomPicker(ColorPickerInner)\n","import React, {useCallback, useMemo} from 'react'\n// @ts-expect-error missing export\nimport {isValidHex} from 'react-color/lib/helpers/color'\nimport {EditableInput} from 'react-color/lib/components/common'\nimport {Box, Flex, useTheme} from '@sanity/ui'\nimport {ColorChangeHandler, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {EditableInputStyles} from 'react-color/lib/components/common/EditableInput'\n\ninterface ColorPickerFieldsProps {\n rgb?: RGBColor\n hsl?: HSLColor\n hex?: string\n disableAlpha: boolean\n onChange: ColorChangeHandler<HSLColor | HSVColor | RGBColor | HEXColor>\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","export const hsvaColor = {\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;ACAA;AAEO,MAAM,yCAAS,GAAG,CAAA,GAAA,iBAAU,CAAA,CAAC;IAClC,KAAK,EAAE,0BAA0B;IACjC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,YAAY;SAAC;QAChD;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,WAAW;SAAC;QAC/C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;KAC5C;CACF,CAAC;;;ACZF;AAEO,MAAM,yCAAS,GAAG,CAAA,GAAA,iBAAU,CAAA,CAAC;IAClC,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE;QACN;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,KAAK;SAAC;QACzC;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,OAAO;SAAC;QAC3C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KAAK,EAAE,MAAM;SAAC;QAC1C;YAAC,IAAI,EAAE,GAAG;YAAE,IAAI,EAAE,QAAQ;YAAE,KA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EAAE;QACN,KAAK,EAAE;YAAC,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAS,CAAA;YAAE,CAAA,GAAA,yCAAK,CAAA;SAAC;KAChD;CACF,CAAC","sources":["src/index.ts","src/schemas/hslaColor.ts","src/schemas/rgbaColor.ts","src/schemas/color.tsx","src/ColorInput.tsx","src/ColorPicker.tsx","src/ColorPickerFields.tsx","src/schemas/hsvaColor.ts"],"sourcesContent":["import {createPlugin} from 'sanity'\nimport {hslaColor} from './schemas/hslaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\nimport {color, ColorDefinition} from './schemas/color'\nimport {hsvaColor} from './schemas/hsvaColor'\n\nexport const colorInput = createPlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {hslaColor, rgbaColor, color, hsvaColor}\nexport {ColorInput} from './ColorInput'\nexport type {ColorDefinition}\nexport type {ColorValue, ColorInputProps, ColorOptions, ColorSchemaType} from './ColorInput'\n","import {defineType} from 'sanity'\n\nexport const hslaColor = defineType({\n title: 'Hue Saturation Lightness',\n name: 'hslaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'l', type: 'number', title: 'Lightness'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import {defineType} from 'sanity'\n\nexport const rgbaColor = defineType({\n title: 'Red Green Blue (rgb)',\n name: 'rgbaColor',\n type: 'object',\n fields: [\n {name: 'r', type: 'number', title: 'Red'},\n {name: 'g', type: 'number', title: 'Green'},\n {name: 'b', type: 'number', title: 'Blue'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n","import React from 'react'\nimport {ColorInput, ColorOptions} from '../ColorInput'\nimport {defineType, ObjectDefinition} from 'sanity'\n\nconst round = (val: number = 1) => Math.round(val * 100)\n\nconst colorTypeName = 'color' as const\n\n/**\n * @public\n */\nexport interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {\n type: typeof colorTypeName\n options?: ColorOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n color: ColorDefinition\n }\n}\n\nexport const color = defineType({\n name: colorTypeName,\n type: 'object',\n title: 'Color',\n components: {input: ColorInput},\n fields: [\n {\n title: 'Hex',\n name: 'hex',\n type: 'string',\n },\n {\n title: 'Alpha',\n name: 'alpha',\n type: 'number',\n },\n {\n title: 'Hue Saturation Lightness',\n name: 'hsl',\n type: 'hslaColor',\n },\n {\n title: 'Hue Saturation Value',\n name: 'hsv',\n type: 'hsvaColor',\n },\n {\n title: 'Red Green Blue (rgb)',\n name: 'rgb',\n type: 'rgbaColor',\n },\n ],\n preview: {\n select: {\n title: 'hex',\n alpha: 'alpha',\n hex: 'hex',\n hsl: 'hsl',\n },\n prepare({\n title,\n hex,\n hsl,\n alpha,\n }: {\n title?: string\n alpha?: number\n hex?: string\n hsl?: {h: number; s: number; l: number}\n }) {\n let subtitle = hex || 'No color set'\n if (hsl) {\n subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`\n }\n return {\n title: title,\n subtitle: subtitle,\n media: () => (\n <div\n style={{\n backgroundColor: hex ?? '#000',\n opacity: alpha ?? 1,\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n }}\n />\n ),\n }\n },\n },\n})\n","import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'\nimport {ObjectOptions, set, setIfMissing, unset} from 'sanity'\nimport {debounce} from 'lodash'\nimport {Button} from '@sanity/ui'\nimport {AddIcon} from '@sanity/icons'\nimport {ColorPicker} from './ColorPicker'\nimport {ObjectInputProps} from 'sanity'\nimport {HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {ObjectSchemaType} from 'sanity'\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 interface ColorValue {\n hex: string\n hsl: HSLColor\n hsv: HSVColor\n rgb: RGBColor\n}\n\nexport interface ColorOptions extends Omit<ObjectOptions, 'columns'> {\n disableAlpha?: boolean\n}\n\nexport type ColorSchemaType = Omit<ObjectSchemaType, 'options'> & {\n options?: ColorOptions\n}\nexport type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>\n\nexport function ColorInput(props: ColorInputProps) {\n const {onChange, schemaType: type, readOnly, value} = props\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 useEffect(() => setColor(value), [value])\n\n const emitSetColor = useCallback(\n (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 [onChange, type]\n )\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 const debouncedColorChange = useMemo(() => debounce(emitSetColor, 100), [emitSetColor])\n const handleColorChange = useCallback(\n (nextColor: ColorValue) => {\n setColor(nextColor)\n debouncedColorChange(nextColor)\n },\n [debouncedColorChange, setColor]\n )\n\n const handleCreateColor = useCallback(() => {\n setColor(DEFAULT_COLOR)\n emitSetColor(DEFAULT_COLOR)\n }, [emitSetColor])\n\n const handleUnset = useCallback(() => {\n setColor(undefined)\n onChange(unset())\n }, [onChange])\n\n return (\n <>\n {value ? (\n <ColorPicker\n /* ref={this.focusRef}*/\n color={color}\n onChange={handleColorChange}\n readOnly={readOnly || (typeof type.readOnly === 'boolean' && type.readOnly)}\n disableAlpha={!!type.options?.disableAlpha}\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","import React from 'react'\nimport {Alpha, Checkboard, Hue, Saturation} from 'react-color/lib/components/common'\nimport {CustomPicker, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {Box, Button, Card, Flex, Inline, Stack, Text} from '@sanity/ui'\nimport {TrashIcon} from '@sanity/icons'\nimport styled from 'styled-components'\nimport {ColorPickerFields} from './ColorPickerFields'\nimport {CustomPickerInjectedProps} from 'react-color/lib/components/common/ColorWrap'\nimport {ColorValue} from './ColorInput'\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\nexport interface ColorPickerProps\n extends CustomPickerInjectedProps<HSLColor | HSVColor | RGBColor | HEXColor> {\n width?: string\n disableAlpha: boolean\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 readOnly,\n } = props\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'}}\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'}}\n >\n <Checkboard />\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)} {Math.round(hsl?.s ?? 0)}%{' '}\n {Math.round(hsl?.l ?? 0)}\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 </Stack>\n </Card>\n </div>\n )\n}\n\nexport const ColorPicker = CustomPicker(ColorPickerInner)\n","import React, {useCallback, useMemo} from 'react'\n// @ts-expect-error missing export\nimport {isValidHex} from 'react-color/lib/helpers/color'\nimport {EditableInput} from 'react-color/lib/components/common'\nimport {Box, Flex, useTheme} from '@sanity/ui'\nimport {ColorChangeHandler, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'\nimport {EditableInputStyles} from 'react-color/lib/components/common/EditableInput'\n\ninterface ColorPickerFieldsProps {\n rgb?: RGBColor\n hsl?: HSLColor\n hex?: string\n disableAlpha: boolean\n onChange: ColorChangeHandler<HSLColor | HSVColor | RGBColor | HEXColor>\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 {defineType} from 'sanity'\n\nexport const hsvaColor = defineType({\n title: 'Hue Saturation Value',\n name: 'hsvaColor',\n type: 'object',\n fields: [\n {name: 'h', type: 'number', title: 'Hue'},\n {name: 's', type: 'number', title: 'Saturation'},\n {name: 'v', type: 'number', title: 'Value'},\n {name: 'a', type: 'number', title: 'Alpha'},\n ],\n})\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import { ObjectInputProps, ObjectSchemaType } from "sanity";
|
|
1
|
+
import { ObjectOptions, ObjectInputProps, ObjectSchemaType, ObjectDefinition } from "sanity";
|
|
2
2
|
import { HSLColor, HSVColor, RGBColor } from "react-color";
|
|
3
3
|
export const hslaColor: {
|
|
4
|
-
|
|
5
|
-
name:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
name: string;
|
|
9
|
-
type: string;
|
|
10
|
-
title: string;
|
|
11
|
-
}[];
|
|
4
|
+
type: "object";
|
|
5
|
+
name: "hslaColor";
|
|
6
|
+
} & Omit<import("sanity").ObjectDefinition, "preview"> & {
|
|
7
|
+
preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
|
|
12
8
|
};
|
|
13
9
|
export const rgbaColor: {
|
|
14
|
-
|
|
15
|
-
name:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
name: string;
|
|
19
|
-
type: string;
|
|
20
|
-
title: string;
|
|
21
|
-
}[];
|
|
10
|
+
type: "object";
|
|
11
|
+
name: "rgbaColor";
|
|
12
|
+
} & Omit<import("sanity").ObjectDefinition, "preview"> & {
|
|
13
|
+
preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
|
|
22
14
|
};
|
|
23
15
|
export interface ColorValue {
|
|
24
16
|
hex: string;
|
|
@@ -26,58 +18,43 @@ export interface ColorValue {
|
|
|
26
18
|
hsv: HSVColor;
|
|
27
19
|
rgb: RGBColor;
|
|
28
20
|
}
|
|
29
|
-
export interface ColorOptions {
|
|
21
|
+
export interface ColorOptions extends Omit<ObjectOptions, 'columns'> {
|
|
30
22
|
disableAlpha?: boolean;
|
|
31
23
|
}
|
|
32
|
-
export type ColorSchemaType = ObjectSchemaType & {
|
|
24
|
+
export type ColorSchemaType = Omit<ObjectSchemaType, 'options'> & {
|
|
33
25
|
options?: ColorOptions;
|
|
34
26
|
};
|
|
35
27
|
export type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>;
|
|
36
28
|
export function ColorInput(props: ColorInputProps): JSX.Element;
|
|
29
|
+
declare const colorTypeName: "color";
|
|
30
|
+
/**
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {
|
|
34
|
+
type: typeof colorTypeName;
|
|
35
|
+
options?: ColorOptions;
|
|
36
|
+
}
|
|
37
|
+
declare module '@sanity/types' {
|
|
38
|
+
interface IntrinsicDefinitions {
|
|
39
|
+
color: ColorDefinition;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
37
42
|
export const color: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
input: typeof ColorInput;
|
|
43
|
-
};
|
|
44
|
-
fields: {
|
|
43
|
+
type: "object";
|
|
44
|
+
name: "color";
|
|
45
|
+
} & Omit<ObjectDefinition, "preview"> & {
|
|
46
|
+
preview?: import("sanity").PreviewConfig<{
|
|
45
47
|
title: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
select: {
|
|
51
|
-
title: string;
|
|
52
|
-
alpha: string;
|
|
53
|
-
hex: string;
|
|
54
|
-
hsl: string;
|
|
55
|
-
};
|
|
56
|
-
prepare({ title, hex, hsl, alpha, }: {
|
|
57
|
-
title?: string | undefined;
|
|
58
|
-
alpha?: number | undefined;
|
|
59
|
-
hex?: string | undefined;
|
|
60
|
-
hsl?: {
|
|
61
|
-
h: number;
|
|
62
|
-
s: number;
|
|
63
|
-
l: number;
|
|
64
|
-
} | undefined;
|
|
65
|
-
}): {
|
|
66
|
-
title: string | undefined;
|
|
67
|
-
subtitle: string;
|
|
68
|
-
media: () => JSX.Element;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
48
|
+
alpha: string;
|
|
49
|
+
hex: string;
|
|
50
|
+
hsl: string;
|
|
51
|
+
}, Record<"title" | "hsl" | "hex" | "alpha", any>> | undefined;
|
|
71
52
|
};
|
|
72
53
|
export const hsvaColor: {
|
|
73
|
-
|
|
74
|
-
name:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
name: string;
|
|
78
|
-
type: string;
|
|
79
|
-
title: string;
|
|
80
|
-
}[];
|
|
54
|
+
type: "object";
|
|
55
|
+
name: "hsvaColor";
|
|
56
|
+
} & Omit<import("sanity").ObjectDefinition, "preview"> & {
|
|
57
|
+
preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
|
|
81
58
|
};
|
|
82
59
|
export const colorInput: import("sanity").Plugin<void>;
|
|
83
60
|
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;
|
|
1
|
+
{"mappings":";;AAEA,OAAO,MAAM;;;;;CAUX,CAAA;ACVF,OAAO,MAAM;;;;;CAUX,CAAA;AGMF;IACE,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,EAAE,QAAQ,CAAA;CACd;AAED,6BAA8B,SAAQ,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC;IAClE,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,8BAA8B,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;IAChE,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,CAAA;AACD,8BAA8B,iBAAiB,UAAU,EAAE,eAAe,CAAC,CAAA;AAE3E,2BAA2B,KAAK,EAAE,eAAe,eA2EhD;ACvGD,QAAA,MAAM,sBAAgC,CAAA;AAEtC;;GAEG;AACH,gCAAiC,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5F,IAAI,EAAE,oBAAoB,CAAA;IAC1B,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB;AAED,eAAe,eAAe,CAAC;IAE7B,UAAiB,oBAAoB;QACnC,KAAK,EAAE,eAAe,CAAA;KACvB;CACF;AAED,OAAO,MAAM;;;;;;;;;;CAyEX,CAAA;AC9FF,OAAO,MAAM;;;;;CAUX,CAAA;ACNF,OAAO,MAAM,yCAKX,CAAA","sources":["src/src/schemas/hslaColor.ts","src/src/schemas/rgbaColor.ts","src/src/ColorPickerFields.tsx","src/src/ColorPicker.tsx","src/src/ColorInput.tsx","src/src/schemas/color.tsx","src/src/schemas/hsvaColor.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"import {createPlugin} from 'sanity'\nimport {hslaColor} from './schemas/hslaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\nimport {color, ColorDefinition} from './schemas/color'\nimport {hsvaColor} from './schemas/hsvaColor'\n\nexport const colorInput = createPlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {hslaColor, rgbaColor, color, hsvaColor}\nexport {ColorInput} from './ColorInput'\nexport type {ColorDefinition}\nexport type {ColorValue, ColorInputProps, ColorOptions, ColorSchemaType} from './ColorInput'\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../../"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/color-input",
|
|
3
|
-
"version": "3.0.0-v3-studio.
|
|
3
|
+
"version": "3.0.0-v3-studio.6",
|
|
4
4
|
"description": "Color input",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf lib",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@sanity/icons": "^1.2.8",
|
|
46
|
-
"@sanity/incompatible-plugin": "^1.0.
|
|
46
|
+
"@sanity/incompatible-plugin": "^1.0.4",
|
|
47
47
|
"@sanity/ui": "^0.38.2",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
49
|
"react-color": "^2.19.3"
|
|
@@ -69,15 +69,15 @@
|
|
|
69
69
|
"lint-staged": "^13.0.3",
|
|
70
70
|
"parcel": "^2.6.0",
|
|
71
71
|
"prettier": "^2.6.2",
|
|
72
|
-
"react": "^
|
|
72
|
+
"react": "^18.0.0",
|
|
73
73
|
"rimraf": "^3.0.2",
|
|
74
|
-
"sanity": "3.0.0-dev-preview.
|
|
74
|
+
"sanity": "3.0.0-dev-preview.21",
|
|
75
75
|
"semantic-release": "^19.0.3",
|
|
76
76
|
"styled-components": "^5.2.0",
|
|
77
77
|
"typescript": "4.7.4"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"react": "^
|
|
80
|
+
"react": "^18.0.0",
|
|
81
81
|
"sanity": "dev-preview",
|
|
82
82
|
"styled-components": "^5.2.0"
|
|
83
83
|
},
|
package/src/ColorInput.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
|
2
|
-
import {set, setIfMissing, unset} from 'sanity
|
|
2
|
+
import {ObjectOptions, set, setIfMissing, unset} from 'sanity'
|
|
3
3
|
import {debounce} from 'lodash'
|
|
4
4
|
import {Button} from '@sanity/ui'
|
|
5
5
|
import {AddIcon} from '@sanity/icons'
|
|
@@ -23,11 +23,11 @@ export interface ColorValue {
|
|
|
23
23
|
rgb: RGBColor
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export interface ColorOptions {
|
|
26
|
+
export interface ColorOptions extends Omit<ObjectOptions, 'columns'> {
|
|
27
27
|
disableAlpha?: boolean
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export type ColorSchemaType = ObjectSchemaType & {
|
|
30
|
+
export type ColorSchemaType = Omit<ObjectSchemaType, 'options'> & {
|
|
31
31
|
options?: ColorOptions
|
|
32
32
|
}
|
|
33
33
|
export type ColorInputProps = ObjectInputProps<ColorValue, ColorSchemaType>
|
|
@@ -92,7 +92,7 @@ export function ColorInput(props: ColorInputProps) {
|
|
|
92
92
|
color={color}
|
|
93
93
|
onChange={handleColorChange}
|
|
94
94
|
readOnly={readOnly || (typeof type.readOnly === 'boolean' && type.readOnly)}
|
|
95
|
-
disableAlpha={type.options?.disableAlpha}
|
|
95
|
+
disableAlpha={!!type.options?.disableAlpha}
|
|
96
96
|
onUnset={handleUnset}
|
|
97
97
|
/>
|
|
98
98
|
) : (
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {createPlugin} from 'sanity'
|
|
2
2
|
import {hslaColor} from './schemas/hslaColor'
|
|
3
3
|
import {rgbaColor} from './schemas/rgbaColor'
|
|
4
|
-
import {color} from './schemas/color'
|
|
4
|
+
import {color, ColorDefinition} from './schemas/color'
|
|
5
5
|
import {hsvaColor} from './schemas/hsvaColor'
|
|
6
6
|
|
|
7
7
|
export const colorInput = createPlugin({
|
|
@@ -13,4 +13,5 @@ export const colorInput = createPlugin({
|
|
|
13
13
|
|
|
14
14
|
export {hslaColor, rgbaColor, color, hsvaColor}
|
|
15
15
|
export {ColorInput} from './ColorInput'
|
|
16
|
+
export type {ColorDefinition}
|
|
16
17
|
export type {ColorValue, ColorInputProps, ColorOptions, ColorSchemaType} from './ColorInput'
|
package/src/schemas/color.tsx
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {ColorInput} from '../ColorInput'
|
|
2
|
+
import {ColorInput, ColorOptions} from '../ColorInput'
|
|
3
|
+
import {defineType, ObjectDefinition} from 'sanity'
|
|
3
4
|
|
|
4
5
|
const round = (val: number = 1) => Math.round(val * 100)
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const colorTypeName = 'color' as const
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface ColorDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {
|
|
13
|
+
type: typeof colorTypeName
|
|
14
|
+
options?: ColorOptions
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare module '@sanity/types' {
|
|
18
|
+
// makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember
|
|
19
|
+
export interface IntrinsicDefinitions {
|
|
20
|
+
color: ColorDefinition
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const color = defineType({
|
|
25
|
+
name: colorTypeName,
|
|
8
26
|
type: 'object',
|
|
9
27
|
title: 'Color',
|
|
10
28
|
components: {input: ColorInput},
|
|
@@ -76,4 +94,4 @@ export const color = {
|
|
|
76
94
|
}
|
|
77
95
|
},
|
|
78
96
|
},
|
|
79
|
-
}
|
|
97
|
+
})
|
package/src/schemas/hslaColor.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import {defineType} from 'sanity'
|
|
2
|
+
|
|
3
|
+
export const hslaColor = defineType({
|
|
2
4
|
title: 'Hue Saturation Lightness',
|
|
3
5
|
name: 'hslaColor',
|
|
4
6
|
type: 'object',
|
|
@@ -8,4 +10,4 @@ export const hslaColor = {
|
|
|
8
10
|
{name: 'l', type: 'number', title: 'Lightness'},
|
|
9
11
|
{name: 'a', type: 'number', title: 'Alpha'},
|
|
10
12
|
],
|
|
11
|
-
}
|
|
13
|
+
})
|
package/src/schemas/hsvaColor.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import {defineType} from 'sanity'
|
|
2
|
+
|
|
3
|
+
export const hsvaColor = defineType({
|
|
2
4
|
title: 'Hue Saturation Value',
|
|
3
5
|
name: 'hsvaColor',
|
|
4
6
|
type: 'object',
|
|
@@ -8,4 +10,4 @@ export const hsvaColor = {
|
|
|
8
10
|
{name: 'v', type: 'number', title: 'Value'},
|
|
9
11
|
{name: 'a', type: 'number', title: 'Alpha'},
|
|
10
12
|
],
|
|
11
|
-
}
|
|
13
|
+
})
|
package/src/schemas/rgbaColor.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import {defineType} from 'sanity'
|
|
2
|
+
|
|
3
|
+
export const rgbaColor = defineType({
|
|
2
4
|
title: 'Red Green Blue (rgb)',
|
|
3
5
|
name: 'rgbaColor',
|
|
4
6
|
type: 'object',
|
|
@@ -8,4 +10,4 @@ export const rgbaColor = {
|
|
|
8
10
|
{name: 'b', type: 'number', title: 'Blue'},
|
|
9
11
|
{name: 'a', type: 'number', title: 'Alpha'},
|
|
10
12
|
],
|
|
11
|
-
}
|
|
13
|
+
})
|