@sanity/color-input 4.0.6 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -20
- package/dist/_chunks-es/ColorInput.js +340 -0
- package/dist/_chunks-es/ColorInput.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -67
- package/lib/_chunks-cjs/ColorInput.js +0 -1041
- package/lib/_chunks-cjs/ColorInput.js.map +0 -1
- package/lib/_chunks-es/ColorInput.mjs +0 -1051
- package/lib/_chunks-es/ColorInput.mjs.map +0 -1
- package/lib/_legacy/ColorInput.esm.js +0 -1051
- package/lib/_legacy/ColorInput.esm.js.map +0 -1
- package/lib/index.d.mts +0 -93
- package/lib/index.d.ts +0 -93
- package/lib/index.esm.js +0 -114
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -114
- package/lib/index.js.map +0 -1
- package/lib/index.mjs +0 -114
- package/lib/index.mjs.map +0 -1
- package/sanity.json +0 -8
- package/src/ColorInput.tsx +0 -97
- package/src/ColorList.tsx +0 -70
- package/src/ColorPicker.tsx +0 -152
- package/src/ColorPickerFields.tsx +0 -144
- package/src/LazyColorInput.tsx +0 -3
- package/src/index.ts +0 -18
- package/src/schemas/color.tsx +0 -98
- package/src/schemas/hslaColor.ts +0 -13
- package/src/schemas/hsvaColor.ts +0 -13
- package/src/schemas/rgbaColor.ts +0 -13
- package/src/types.ts +0 -19
- package/v2-incompatible.js +0 -11
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/LazyColorInput.tsx","../src/schemas/color.tsx","../src/schemas/hslaColor.ts","../src/schemas/hsvaColor.ts","../src/schemas/rgbaColor.ts","../src/index.ts"],"sourcesContent":["import {lazy} from 'react'\n\nexport const ColorInput = lazy(() => import('./ColorInput'))\n","import {defineType, type ObjectDefinition} from 'sanity'\n\nimport {ColorInput} from '../LazyColorInput'\nimport {type ColorOptions} from '../types'\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 {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 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","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 {definePlugin} from 'sanity'\n\nimport {color, type ColorDefinition} from './schemas/color'\nimport {hslaColor} from './schemas/hslaColor'\nimport {hsvaColor} from './schemas/hsvaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\n\nexport const colorInput = definePlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {color, hslaColor, hsvaColor, rgbaColor}\nexport {ColorInput} from './LazyColorInput'\nexport type {ColorDefinition}\nexport type {ColorInputProps, ColorOptions, ColorSchemaType, ColorValue} from './types'\n"],"names":["lazy","defineType","jsx","definePlugin"],"mappings":";;;AAEO,MAAM,aAAaA,MAAAA,KAAK,MAAM,QAAA,QAAA,EAAA,KAAA,WAAA;AAAA,SAAA,QAAO,6BAAc;AAAC,CAAA,CAAA,GCGrD,QAAQ,CAAC,MAAc,MAAM,KAAK,MAAM,MAAM,GAAG,GAEjD,gBAAgB,SAiBT,QAAQC,OAAAA,WAAW;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,WAAU;AAAA,EAC9B,QAAQ;AAAA,IACN;AAAA,MACE,OAAO;AAAA,MAC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,MAAM,KAAK,MAAM,UAAU,OAAO,YAAW;AAAA,IAC9C,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,EAAA;AAE9C,CAAC,GCVY,YAAYA,OAAAA,WAAW;AAAA,EAClC,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,MAAK;AAAA,IACxC,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,aAAY;AAAA,IAC/C,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,IAC1C,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,EAAA;AAE9C,CAAC,GCVY,YAAYA,OAAAA,WAAW;AAAA,EAClC,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,MAAK;AAAA,IACxC,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,IAC1C,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,OAAM;AAAA,IACzC,EAAC,MAAM,KAAK,MAAM,UAAU,OAAO,QAAO;AAAA,EAAA;AAE9C,CAAC,GCLY,aAAaE,OAAAA,aAAa;AAAA,EACrC,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO,CAAC,WAAW,WAAW,WAAW,KAAK;AAAA,EAAA;AAElD,CAAC;;;;;;;"}
|
package/lib/index.mjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { defineType, definePlugin } from "sanity";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { lazy } from "react";
|
|
4
|
-
const ColorInput = lazy(() => import("./_chunks-es/ColorInput.mjs")), round = (val = 1) => Math.round(val * 100), colorTypeName = "color", color = defineType({
|
|
5
|
-
name: colorTypeName,
|
|
6
|
-
type: "object",
|
|
7
|
-
title: "Color",
|
|
8
|
-
components: { input: ColorInput },
|
|
9
|
-
fields: [
|
|
10
|
-
{
|
|
11
|
-
title: "Hex",
|
|
12
|
-
name: "hex",
|
|
13
|
-
type: "string"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
title: "Alpha",
|
|
17
|
-
name: "alpha",
|
|
18
|
-
type: "number"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
title: "Hue Saturation Lightness",
|
|
22
|
-
name: "hsl",
|
|
23
|
-
type: "hslaColor"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
title: "Hue Saturation Value",
|
|
27
|
-
name: "hsv",
|
|
28
|
-
type: "hsvaColor"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
title: "Red Green Blue (rgb)",
|
|
32
|
-
name: "rgb",
|
|
33
|
-
type: "rgbaColor"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
preview: {
|
|
37
|
-
select: {
|
|
38
|
-
title: "hex",
|
|
39
|
-
alpha: "alpha",
|
|
40
|
-
hex: "hex",
|
|
41
|
-
hsl: "hsl"
|
|
42
|
-
},
|
|
43
|
-
prepare({
|
|
44
|
-
title,
|
|
45
|
-
hex,
|
|
46
|
-
hsl,
|
|
47
|
-
alpha
|
|
48
|
-
}) {
|
|
49
|
-
let subtitle = hex || "No color set";
|
|
50
|
-
return hsl && (subtitle = `H:${round(hsl.h)} S:${round(hsl.s)} L:${round(hsl.l)} A:${round(alpha)}`), {
|
|
51
|
-
title,
|
|
52
|
-
subtitle,
|
|
53
|
-
media: () => /* @__PURE__ */ jsx(
|
|
54
|
-
"div",
|
|
55
|
-
{
|
|
56
|
-
style: {
|
|
57
|
-
backgroundColor: hex ?? "#000",
|
|
58
|
-
opacity: alpha ?? 1,
|
|
59
|
-
position: "absolute",
|
|
60
|
-
height: "100%",
|
|
61
|
-
width: "100%",
|
|
62
|
-
top: "0",
|
|
63
|
-
left: "0"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}), hslaColor = defineType({
|
|
71
|
-
title: "Hue Saturation Lightness",
|
|
72
|
-
name: "hslaColor",
|
|
73
|
-
type: "object",
|
|
74
|
-
fields: [
|
|
75
|
-
{ name: "h", type: "number", title: "Hue" },
|
|
76
|
-
{ name: "s", type: "number", title: "Saturation" },
|
|
77
|
-
{ name: "l", type: "number", title: "Lightness" },
|
|
78
|
-
{ name: "a", type: "number", title: "Alpha" }
|
|
79
|
-
]
|
|
80
|
-
}), hsvaColor = defineType({
|
|
81
|
-
title: "Hue Saturation Value",
|
|
82
|
-
name: "hsvaColor",
|
|
83
|
-
type: "object",
|
|
84
|
-
fields: [
|
|
85
|
-
{ name: "h", type: "number", title: "Hue" },
|
|
86
|
-
{ name: "s", type: "number", title: "Saturation" },
|
|
87
|
-
{ name: "v", type: "number", title: "Value" },
|
|
88
|
-
{ name: "a", type: "number", title: "Alpha" }
|
|
89
|
-
]
|
|
90
|
-
}), rgbaColor = defineType({
|
|
91
|
-
title: "Red Green Blue (rgb)",
|
|
92
|
-
name: "rgbaColor",
|
|
93
|
-
type: "object",
|
|
94
|
-
fields: [
|
|
95
|
-
{ name: "r", type: "number", title: "Red" },
|
|
96
|
-
{ name: "g", type: "number", title: "Green" },
|
|
97
|
-
{ name: "b", type: "number", title: "Blue" },
|
|
98
|
-
{ name: "a", type: "number", title: "Alpha" }
|
|
99
|
-
]
|
|
100
|
-
}), colorInput = definePlugin({
|
|
101
|
-
name: "@sanity/color-input",
|
|
102
|
-
schema: {
|
|
103
|
-
types: [hslaColor, hsvaColor, rgbaColor, color]
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
export {
|
|
107
|
-
ColorInput,
|
|
108
|
-
color,
|
|
109
|
-
colorInput,
|
|
110
|
-
hslaColor,
|
|
111
|
-
hsvaColor,
|
|
112
|
-
rgbaColor
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=index.mjs.map
|
package/lib/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/LazyColorInput.tsx","../src/schemas/color.tsx","../src/schemas/hslaColor.ts","../src/schemas/hsvaColor.ts","../src/schemas/rgbaColor.ts","../src/index.ts"],"sourcesContent":["import {lazy} from 'react'\n\nexport const ColorInput = lazy(() => import('./ColorInput'))\n","import {defineType, type ObjectDefinition} from 'sanity'\n\nimport {ColorInput} from '../LazyColorInput'\nimport {type ColorOptions} from '../types'\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 {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 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","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 {definePlugin} from 'sanity'\n\nimport {color, type ColorDefinition} from './schemas/color'\nimport {hslaColor} from './schemas/hslaColor'\nimport {hsvaColor} from './schemas/hsvaColor'\nimport {rgbaColor} from './schemas/rgbaColor'\n\nexport const colorInput = definePlugin({\n name: '@sanity/color-input',\n schema: {\n types: [hslaColor, hsvaColor, rgbaColor, color],\n },\n})\n\nexport {color, hslaColor, hsvaColor, rgbaColor}\nexport {ColorInput} from './LazyColorInput'\nexport type {ColorDefinition}\nexport type {ColorInputProps, ColorOptions, ColorSchemaType, ColorValue} from './types'\n"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,KAAK,MAAM,OAAO,6BAAc,CAAC,GCGrD,QAAQ,CAAC,MAAc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
|
|
3
|
-
import {startTransition, useCallback, useDeferredValue, useEffect, useRef, useState} from 'react'
|
|
4
|
-
import {type ObjectInputProps, set, setIfMissing, unset} from 'sanity'
|
|
5
|
-
import {useEffectEvent} from 'use-effect-event'
|
|
6
|
-
|
|
7
|
-
import {ColorPicker} from './ColorPicker'
|
|
8
|
-
import type {ColorSchemaType, ColorValue} from './types'
|
|
9
|
-
|
|
10
|
-
const DEFAULT_COLOR: ColorValue & {source: string} = {
|
|
11
|
-
hex: '#24a3e3',
|
|
12
|
-
hsl: {h: 200, s: 0.7732, l: 0.5156, a: 1},
|
|
13
|
-
hsv: {h: 200, s: 0.8414, v: 0.8901, a: 1},
|
|
14
|
-
rgb: {r: 46, g: 163, b: 227, a: 1},
|
|
15
|
-
source: 'hex',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default function ColorInput(props: ObjectInputProps) {
|
|
19
|
-
const {onChange, readOnly} = props
|
|
20
|
-
const value = props.value as ColorValue | undefined
|
|
21
|
-
const type = props.schemaType as ColorSchemaType
|
|
22
|
-
const focusRef = useRef<HTMLButtonElement>(null)
|
|
23
|
-
|
|
24
|
-
// use local state so we can have instant ui updates while debouncing patch emits
|
|
25
|
-
const [color, setColor] = useState(value)
|
|
26
|
-
// Marking the `setColor` in a transition allows React to interrupt render should the user start dragging the input before React is finished rendering
|
|
27
|
-
useEffect(() => startTransition(() => setColor(value)), [value])
|
|
28
|
-
|
|
29
|
-
// The color picker emits onChange events continuously while the user is sliding the
|
|
30
|
-
// hue/saturation/alpha selectors. This debounces the event to avoid excessive patches
|
|
31
|
-
// and massively improve render performance and avoid jank
|
|
32
|
-
const [emitColor, setEmitColor] = useState<typeof value>(undefined)
|
|
33
|
-
const debouncedColor = useDeferredValue(emitColor)
|
|
34
|
-
const handleChange = useEffectEvent((nextColor: ColorValue) => {
|
|
35
|
-
const fieldPatches = type.fields
|
|
36
|
-
.filter((field) => field.name in nextColor)
|
|
37
|
-
.map((field) => {
|
|
38
|
-
const nextFieldValue = nextColor[field.name as keyof ColorValue]
|
|
39
|
-
const isObject = field.type.jsonType === 'object'
|
|
40
|
-
return set(
|
|
41
|
-
isObject ? Object.assign({_type: field.type.name}, nextFieldValue) : nextFieldValue,
|
|
42
|
-
[field.name],
|
|
43
|
-
)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
onChange([
|
|
47
|
-
setIfMissing({_type: type.name}),
|
|
48
|
-
set(type.name, ['_type']),
|
|
49
|
-
set(nextColor.rgb?.a, ['alpha']),
|
|
50
|
-
...fieldPatches,
|
|
51
|
-
])
|
|
52
|
-
})
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (!debouncedColor) return undefined
|
|
55
|
-
const raf = requestAnimationFrame(() => handleChange(debouncedColor))
|
|
56
|
-
return () => cancelAnimationFrame(raf)
|
|
57
|
-
}, [debouncedColor])
|
|
58
|
-
|
|
59
|
-
const handleCreateColor = useCallback(() => {
|
|
60
|
-
setColor(DEFAULT_COLOR)
|
|
61
|
-
setEmitColor(DEFAULT_COLOR)
|
|
62
|
-
}, [])
|
|
63
|
-
|
|
64
|
-
const handleColorChange = useCallback((nextColor: ColorValue) => {
|
|
65
|
-
setColor(nextColor)
|
|
66
|
-
setEmitColor(nextColor)
|
|
67
|
-
}, [])
|
|
68
|
-
|
|
69
|
-
const handleUnset = useCallback(() => {
|
|
70
|
-
setColor(undefined)
|
|
71
|
-
onChange(unset())
|
|
72
|
-
}, [onChange])
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<>
|
|
76
|
-
{value && value.hex ? (
|
|
77
|
-
<ColorPicker
|
|
78
|
-
color={color}
|
|
79
|
-
onChange={handleColorChange}
|
|
80
|
-
readOnly={readOnly || (typeof type.readOnly === 'boolean' && type.readOnly)}
|
|
81
|
-
disableAlpha={!!type.options?.disableAlpha}
|
|
82
|
-
colorList={type.options?.colorList}
|
|
83
|
-
onUnset={handleUnset}
|
|
84
|
-
/>
|
|
85
|
-
) : (
|
|
86
|
-
<Button
|
|
87
|
-
icon={AddIcon}
|
|
88
|
-
mode="ghost"
|
|
89
|
-
text="Create color"
|
|
90
|
-
ref={focusRef}
|
|
91
|
-
disabled={Boolean(readOnly)}
|
|
92
|
-
onClick={handleCreateColor}
|
|
93
|
-
/>
|
|
94
|
-
)}
|
|
95
|
-
</>
|
|
96
|
-
)
|
|
97
|
-
}
|
package/src/ColorList.tsx
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {Flex} from '@sanity/ui'
|
|
2
|
-
import {memo} from 'react'
|
|
3
|
-
import type {Color, ColorChangeHandler} from 'react-color'
|
|
4
|
-
import {styled} from 'styled-components'
|
|
5
|
-
import tinycolor from 'tinycolor2'
|
|
6
|
-
|
|
7
|
-
const ColorListWrap = styled(Flex)`
|
|
8
|
-
gap: 0.25em;
|
|
9
|
-
`
|
|
10
|
-
|
|
11
|
-
const ColorBoxContainer = styled.div`
|
|
12
|
-
width: 2.1em;
|
|
13
|
-
height: 2.1em;
|
|
14
|
-
cursor: pointer;
|
|
15
|
-
position: relative;
|
|
16
|
-
overflow: hidden;
|
|
17
|
-
border-radius: 3px;
|
|
18
|
-
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADFJREFUOE9jZGBgEGHAD97gk2YcNYBhmIQBgWSAP52AwoAQwJvQRg1gACckQoC2gQgAIF8IscwEtKYAAAAASUVORK5CYII=')
|
|
19
|
-
left center #fff;
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
const ColorBox = styled.div`
|
|
23
|
-
border-radius: inherit;
|
|
24
|
-
box-shadow: inset 0 0 0 1px var(--card-shadow-outline-color);
|
|
25
|
-
content: '';
|
|
26
|
-
position: absolute;
|
|
27
|
-
inset: 0;
|
|
28
|
-
z-index: 1;
|
|
29
|
-
`
|
|
30
|
-
|
|
31
|
-
interface ValidatedColor {
|
|
32
|
-
color: Color
|
|
33
|
-
backgroundColor: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface ColorListProps {
|
|
37
|
-
colors?: Array<Color>
|
|
38
|
-
onChange: ColorChangeHandler<Color>
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const validateColors = (colors: Array<Color>) =>
|
|
42
|
-
colors.reduce((cls: Array<ValidatedColor>, c) => {
|
|
43
|
-
// @ts-expect-error fix types later
|
|
44
|
-
const color = c.hex ? tinycolor(c.hex) : tinycolor(c)
|
|
45
|
-
if (color.isValid()) {
|
|
46
|
-
cls.push({
|
|
47
|
-
color: c,
|
|
48
|
-
backgroundColor: color.toRgbString(),
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
return cls
|
|
52
|
-
}, [])
|
|
53
|
-
|
|
54
|
-
export const ColorList = memo(function ColorList({colors, onChange}: ColorListProps) {
|
|
55
|
-
if (!colors) return null
|
|
56
|
-
return (
|
|
57
|
-
<ColorListWrap wrap="wrap">
|
|
58
|
-
{validateColors(colors).map(({color, backgroundColor}, idx) => (
|
|
59
|
-
<ColorBoxContainer
|
|
60
|
-
key={`${backgroundColor}-${idx}`}
|
|
61
|
-
onClick={() => {
|
|
62
|
-
onChange(color)
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
<ColorBox style={{background: backgroundColor}} />
|
|
66
|
-
</ColorBoxContainer>
|
|
67
|
-
))}
|
|
68
|
-
</ColorListWrap>
|
|
69
|
-
)
|
|
70
|
-
})
|
package/src/ColorPicker.tsx
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import {TrashIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Button, Card, Flex, Inline, Stack, Text} from '@sanity/ui'
|
|
3
|
-
import {type Color, CustomPicker} from 'react-color'
|
|
4
|
-
import {Alpha, Checkboard, Hue, Saturation} from 'react-color/lib/components/common'
|
|
5
|
-
import type {CustomPickerInjectedProps} from 'react-color/lib/components/common/ColorWrap'
|
|
6
|
-
import {styled} from 'styled-components'
|
|
7
|
-
|
|
8
|
-
import {ColorList} from './ColorList'
|
|
9
|
-
import {ColorPickerFields} from './ColorPickerFields'
|
|
10
|
-
import type {ColorValue} from './types'
|
|
11
|
-
|
|
12
|
-
const ColorBox = styled(Box)`
|
|
13
|
-
position: absolute;
|
|
14
|
-
top: 0;
|
|
15
|
-
left: 0;
|
|
16
|
-
width: 100%;
|
|
17
|
-
height: 100%;
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
const ReadOnlyContainer = styled(Flex)`
|
|
21
|
-
margin-top: 6rem;
|
|
22
|
-
background-color: var(--card-bg-color);
|
|
23
|
-
position: relative;
|
|
24
|
-
width: 100%;
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
export interface ColorPickerProps extends CustomPickerInjectedProps<Color> {
|
|
28
|
-
width?: string
|
|
29
|
-
disableAlpha: boolean
|
|
30
|
-
colorList?: Array<Color>
|
|
31
|
-
readOnly?: boolean
|
|
32
|
-
onUnset: () => void
|
|
33
|
-
color: ColorValue
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const ColorPickerInner = (props: ColorPickerProps) => {
|
|
37
|
-
const {
|
|
38
|
-
width,
|
|
39
|
-
color: {rgb, hex, hsv, hsl},
|
|
40
|
-
onChange,
|
|
41
|
-
onUnset,
|
|
42
|
-
disableAlpha,
|
|
43
|
-
colorList,
|
|
44
|
-
readOnly,
|
|
45
|
-
} = props
|
|
46
|
-
|
|
47
|
-
if (!hsl || !hsv) {
|
|
48
|
-
return null
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div style={{width}}>
|
|
53
|
-
<Card padding={1} border radius={1}>
|
|
54
|
-
<Stack space={2}>
|
|
55
|
-
{!readOnly && (
|
|
56
|
-
<>
|
|
57
|
-
<Card overflow="hidden" style={{position: 'relative', height: '5em'}}>
|
|
58
|
-
<Saturation onChange={onChange} hsl={hsl} hsv={hsv} />
|
|
59
|
-
</Card>
|
|
60
|
-
|
|
61
|
-
<Card
|
|
62
|
-
shadow={1}
|
|
63
|
-
radius={3}
|
|
64
|
-
overflow="hidden"
|
|
65
|
-
style={{position: 'relative', height: '10px'}}
|
|
66
|
-
>
|
|
67
|
-
<Hue hsl={hsl} onChange={!readOnly && onChange} />
|
|
68
|
-
</Card>
|
|
69
|
-
|
|
70
|
-
{!disableAlpha && (
|
|
71
|
-
<Card
|
|
72
|
-
shadow={1}
|
|
73
|
-
radius={3}
|
|
74
|
-
overflow="hidden"
|
|
75
|
-
style={{position: 'relative', height: '10px', background: '#fff'}}
|
|
76
|
-
>
|
|
77
|
-
<Alpha rgb={rgb} hsl={hsl} onChange={onChange} />
|
|
78
|
-
</Card>
|
|
79
|
-
)}
|
|
80
|
-
</>
|
|
81
|
-
)}
|
|
82
|
-
<Flex>
|
|
83
|
-
<Card
|
|
84
|
-
flex={1}
|
|
85
|
-
radius={2}
|
|
86
|
-
overflow="hidden"
|
|
87
|
-
style={{position: 'relative', minWidth: '4em', background: '#fff'}}
|
|
88
|
-
>
|
|
89
|
-
<Checkboard
|
|
90
|
-
size={8}
|
|
91
|
-
white="transparent"
|
|
92
|
-
grey="rgba(0,0,0,.08)"
|
|
93
|
-
renderers={{} as {canvas: unknown}}
|
|
94
|
-
/>
|
|
95
|
-
<ColorBox
|
|
96
|
-
style={{
|
|
97
|
-
backgroundColor: `rgba(${rgb?.r},${rgb?.g},${rgb?.b},${rgb?.a})`,
|
|
98
|
-
}}
|
|
99
|
-
/>
|
|
100
|
-
|
|
101
|
-
{readOnly && (
|
|
102
|
-
<ReadOnlyContainer
|
|
103
|
-
padding={2}
|
|
104
|
-
paddingBottom={1}
|
|
105
|
-
sizing="border"
|
|
106
|
-
justify="space-between"
|
|
107
|
-
>
|
|
108
|
-
<Stack space={3} marginTop={1}>
|
|
109
|
-
<Text size={3} weight="bold">
|
|
110
|
-
{hex}
|
|
111
|
-
</Text>
|
|
112
|
-
|
|
113
|
-
<Inline space={3}>
|
|
114
|
-
<Text size={1}>
|
|
115
|
-
<strong>RGB: </strong>
|
|
116
|
-
{rgb?.r} {rgb?.g} {rgb?.b}
|
|
117
|
-
</Text>
|
|
118
|
-
<Text size={1}>
|
|
119
|
-
<strong>HSL: </strong> {Math.round(hsl?.h ?? 0)}{' '}
|
|
120
|
-
{Math.round((hsl?.s ?? 0) * 100)}% {Math.round((hsl?.l ?? 0) * 100)}%
|
|
121
|
-
</Text>
|
|
122
|
-
</Inline>
|
|
123
|
-
</Stack>
|
|
124
|
-
</ReadOnlyContainer>
|
|
125
|
-
)}
|
|
126
|
-
</Card>
|
|
127
|
-
|
|
128
|
-
{!readOnly && (
|
|
129
|
-
<Flex align="flex-start" marginLeft={2}>
|
|
130
|
-
<Box style={{width: 200}}>
|
|
131
|
-
<ColorPickerFields
|
|
132
|
-
rgb={rgb}
|
|
133
|
-
hsl={hsl}
|
|
134
|
-
hex={hex}
|
|
135
|
-
onChange={onChange}
|
|
136
|
-
disableAlpha={disableAlpha}
|
|
137
|
-
/>
|
|
138
|
-
</Box>
|
|
139
|
-
<Box marginLeft={2}>
|
|
140
|
-
<Button onClick={onUnset} title="Delete color" icon={TrashIcon} tone="critical" />
|
|
141
|
-
</Box>
|
|
142
|
-
</Flex>
|
|
143
|
-
)}
|
|
144
|
-
</Flex>
|
|
145
|
-
{colorList && <ColorList colors={colorList} onChange={onChange} />}
|
|
146
|
-
</Stack>
|
|
147
|
-
</Card>
|
|
148
|
-
</div>
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export const ColorPicker = CustomPicker(ColorPickerInner)
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import {Box, Flex, useTheme} from '@sanity/ui'
|
|
2
|
-
import {useCallback, useMemo} from 'react'
|
|
3
|
-
import type {Color, ColorChangeHandler, HSLColor, RGBColor} from 'react-color'
|
|
4
|
-
import {EditableInput} from 'react-color/lib/components/common'
|
|
5
|
-
import type {EditableInputStyles} from 'react-color/lib/components/common/EditableInput'
|
|
6
|
-
// @ts-expect-error missing export
|
|
7
|
-
import {isValidHex} from 'react-color/lib/helpers/color'
|
|
8
|
-
|
|
9
|
-
interface ColorPickerFieldsProps {
|
|
10
|
-
rgb?: RGBColor
|
|
11
|
-
hsl?: HSLColor
|
|
12
|
-
hex?: string
|
|
13
|
-
disableAlpha: boolean
|
|
14
|
-
onChange: ColorChangeHandler<Color>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const ColorPickerFields = ({
|
|
18
|
-
onChange,
|
|
19
|
-
rgb,
|
|
20
|
-
hsl,
|
|
21
|
-
hex,
|
|
22
|
-
disableAlpha,
|
|
23
|
-
}: ColorPickerFieldsProps) => {
|
|
24
|
-
const {sanity} = useTheme()
|
|
25
|
-
|
|
26
|
-
const inputStyles: EditableInputStyles = useMemo(
|
|
27
|
-
() => ({
|
|
28
|
-
input: {
|
|
29
|
-
width: '80%',
|
|
30
|
-
padding: '4px 10% 3px',
|
|
31
|
-
border: 'none',
|
|
32
|
-
boxShadow: `inset 0 0 0 1px ${sanity.color.input.default.enabled.border}`,
|
|
33
|
-
color: sanity.color.input.default.enabled.fg,
|
|
34
|
-
backgroundColor: sanity.color.input.default.enabled.bg,
|
|
35
|
-
fontSize: sanity.fonts.text.sizes[0].fontSize,
|
|
36
|
-
textAlign: 'center',
|
|
37
|
-
},
|
|
38
|
-
label: {
|
|
39
|
-
display: 'block',
|
|
40
|
-
textAlign: 'center',
|
|
41
|
-
fontSize: sanity.fonts.label.sizes[0].fontSize,
|
|
42
|
-
color: sanity.color.base.fg,
|
|
43
|
-
paddingTop: '3px',
|
|
44
|
-
paddingBottom: '4px',
|
|
45
|
-
textTransform: 'capitalize',
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
[sanity],
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
const handleChange: ColorChangeHandler<Record<string, string>> = useCallback(
|
|
52
|
-
(data) => {
|
|
53
|
-
if ('hex' in data && data['hex'] && isValidHex(data['hex'])) {
|
|
54
|
-
onChange({
|
|
55
|
-
hex: data['hex'],
|
|
56
|
-
source: 'hex',
|
|
57
|
-
})
|
|
58
|
-
} else if (
|
|
59
|
-
rgb &&
|
|
60
|
-
(('r' in data && data['r']) || ('g' in data && data['g']) || ('b' in data && data['b']))
|
|
61
|
-
) {
|
|
62
|
-
onChange({
|
|
63
|
-
r: Number(data['r']) || rgb.r,
|
|
64
|
-
g: Number(data['g']) || rgb.g,
|
|
65
|
-
b: Number(data['b']) || rgb.b,
|
|
66
|
-
a: rgb.a,
|
|
67
|
-
source: 'rgb',
|
|
68
|
-
})
|
|
69
|
-
} else if (hsl && 'a' in data && data['a']) {
|
|
70
|
-
let alpha = Number(data['a'])
|
|
71
|
-
if (alpha < 0) {
|
|
72
|
-
alpha = 0
|
|
73
|
-
} else if (alpha > 100) {
|
|
74
|
-
alpha = 100
|
|
75
|
-
}
|
|
76
|
-
alpha /= 100
|
|
77
|
-
|
|
78
|
-
onChange({
|
|
79
|
-
h: hsl.h,
|
|
80
|
-
s: hsl.s,
|
|
81
|
-
l: hsl.l,
|
|
82
|
-
a: alpha,
|
|
83
|
-
source: 'hsl',
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
[onChange, hsl, rgb],
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Flex>
|
|
92
|
-
<Box flex={2} marginRight={1}>
|
|
93
|
-
<EditableInput
|
|
94
|
-
style={inputStyles}
|
|
95
|
-
label="hex"
|
|
96
|
-
value={hex?.replace('#', '')}
|
|
97
|
-
onChange={handleChange}
|
|
98
|
-
/>
|
|
99
|
-
</Box>
|
|
100
|
-
<Box flex={1} marginRight={1}>
|
|
101
|
-
<EditableInput
|
|
102
|
-
style={inputStyles}
|
|
103
|
-
label="r"
|
|
104
|
-
value={rgb?.r}
|
|
105
|
-
onChange={handleChange}
|
|
106
|
-
dragLabel
|
|
107
|
-
dragMax={255}
|
|
108
|
-
/>
|
|
109
|
-
</Box>
|
|
110
|
-
<Box flex={1} marginRight={1}>
|
|
111
|
-
<EditableInput
|
|
112
|
-
style={inputStyles}
|
|
113
|
-
label="g"
|
|
114
|
-
value={rgb?.g}
|
|
115
|
-
onChange={handleChange}
|
|
116
|
-
dragLabel
|
|
117
|
-
dragMax={255}
|
|
118
|
-
/>
|
|
119
|
-
</Box>
|
|
120
|
-
<Box flex={1} marginRight={1}>
|
|
121
|
-
<EditableInput
|
|
122
|
-
style={inputStyles}
|
|
123
|
-
label="b"
|
|
124
|
-
value={rgb?.b}
|
|
125
|
-
onChange={handleChange}
|
|
126
|
-
dragLabel
|
|
127
|
-
dragMax={255}
|
|
128
|
-
/>
|
|
129
|
-
</Box>
|
|
130
|
-
{!disableAlpha && (
|
|
131
|
-
<Box flex={1}>
|
|
132
|
-
<EditableInput
|
|
133
|
-
style={inputStyles}
|
|
134
|
-
label="a"
|
|
135
|
-
value={Math.round((rgb?.a ?? 1) * 100)}
|
|
136
|
-
onChange={handleChange}
|
|
137
|
-
dragLabel
|
|
138
|
-
dragMax={100}
|
|
139
|
-
/>
|
|
140
|
-
</Box>
|
|
141
|
-
)}
|
|
142
|
-
</Flex>
|
|
143
|
-
)
|
|
144
|
-
}
|
package/src/LazyColorInput.tsx
DELETED
package/src/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {definePlugin} from 'sanity'
|
|
2
|
-
|
|
3
|
-
import {color, type ColorDefinition} from './schemas/color'
|
|
4
|
-
import {hslaColor} from './schemas/hslaColor'
|
|
5
|
-
import {hsvaColor} from './schemas/hsvaColor'
|
|
6
|
-
import {rgbaColor} from './schemas/rgbaColor'
|
|
7
|
-
|
|
8
|
-
export const colorInput = definePlugin({
|
|
9
|
-
name: '@sanity/color-input',
|
|
10
|
-
schema: {
|
|
11
|
-
types: [hslaColor, hsvaColor, rgbaColor, color],
|
|
12
|
-
},
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export {color, hslaColor, hsvaColor, rgbaColor}
|
|
16
|
-
export {ColorInput} from './LazyColorInput'
|
|
17
|
-
export type {ColorDefinition}
|
|
18
|
-
export type {ColorInputProps, ColorOptions, ColorSchemaType, ColorValue} from './types'
|