@sanity/color-input 3.0.1 → 3.1.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/LICENSE +1 -1
- package/README.md +38 -9
- package/lib/{src/index.d.ts → index.d.ts} +2 -0
- package/lib/index.esm.js +1714 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1730 -1
- package/lib/index.js.map +1 -1
- package/package.json +31 -26
- package/src/ColorInput.tsx +3 -1
- package/src/ColorList.tsx +67 -0
- package/src/ColorPicker.tsx +8 -5
- package/src/ColorPickerFields.tsx +2 -2
package/src/ColorPicker.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import {Alpha, Checkboard, Hue, Saturation} from 'react-color/lib/components/common'
|
|
3
|
-
import {
|
|
3
|
+
import {Color, CustomPicker} from 'react-color'
|
|
4
4
|
import {Box, Button, Card, Flex, Inline, Stack, Text} from '@sanity/ui'
|
|
5
5
|
import {TrashIcon} from '@sanity/icons'
|
|
6
6
|
import styled from 'styled-components'
|
|
7
7
|
import {ColorPickerFields} from './ColorPickerFields'
|
|
8
8
|
import {CustomPickerInjectedProps} from 'react-color/lib/components/common/ColorWrap'
|
|
9
9
|
import {ColorValue} from './ColorInput'
|
|
10
|
+
import {ColorList} from './ColorList'
|
|
10
11
|
|
|
11
12
|
const ColorBox = styled(Box)`
|
|
12
13
|
position: absolute;
|
|
@@ -23,10 +24,10 @@ const ReadOnlyContainer = styled(Flex)`
|
|
|
23
24
|
width: 100%;
|
|
24
25
|
`
|
|
25
26
|
|
|
26
|
-
export interface ColorPickerProps
|
|
27
|
-
extends CustomPickerInjectedProps<HSLColor | HSVColor | RGBColor | HEXColor> {
|
|
27
|
+
export interface ColorPickerProps extends CustomPickerInjectedProps<Color> {
|
|
28
28
|
width?: string
|
|
29
29
|
disableAlpha: boolean
|
|
30
|
+
colorList?: Array<Color>
|
|
30
31
|
readOnly?: boolean
|
|
31
32
|
onUnset: () => void
|
|
32
33
|
color: ColorValue
|
|
@@ -39,6 +40,7 @@ const ColorPickerInner = (props: ColorPickerProps) => {
|
|
|
39
40
|
onChange,
|
|
40
41
|
onUnset,
|
|
41
42
|
disableAlpha,
|
|
43
|
+
colorList,
|
|
42
44
|
readOnly,
|
|
43
45
|
} = props
|
|
44
46
|
|
|
@@ -70,7 +72,7 @@ const ColorPickerInner = (props: ColorPickerProps) => {
|
|
|
70
72
|
shadow={1}
|
|
71
73
|
radius={3}
|
|
72
74
|
overflow="hidden"
|
|
73
|
-
style={{position: 'relative', height: '10px'}}
|
|
75
|
+
style={{position: 'relative', height: '10px', background: '#fff'}}
|
|
74
76
|
>
|
|
75
77
|
<Alpha rgb={rgb} hsl={hsl} onChange={onChange} />
|
|
76
78
|
</Card>
|
|
@@ -82,7 +84,7 @@ const ColorPickerInner = (props: ColorPickerProps) => {
|
|
|
82
84
|
flex={1}
|
|
83
85
|
radius={2}
|
|
84
86
|
overflow="hidden"
|
|
85
|
-
style={{position: 'relative', minWidth: '4em'}}
|
|
87
|
+
style={{position: 'relative', minWidth: '4em', background: '#fff'}}
|
|
86
88
|
>
|
|
87
89
|
<Checkboard />
|
|
88
90
|
<ColorBox
|
|
@@ -135,6 +137,7 @@ const ColorPickerInner = (props: ColorPickerProps) => {
|
|
|
135
137
|
</Flex>
|
|
136
138
|
)}
|
|
137
139
|
</Flex>
|
|
140
|
+
{colorList && <ColorList colors={colorList} onChange={onChange} />}
|
|
138
141
|
</Stack>
|
|
139
142
|
</Card>
|
|
140
143
|
</div>
|
|
@@ -3,7 +3,7 @@ import React, {useCallback, useMemo} from 'react'
|
|
|
3
3
|
import {isValidHex} from 'react-color/lib/helpers/color'
|
|
4
4
|
import {EditableInput} from 'react-color/lib/components/common'
|
|
5
5
|
import {Box, Flex, useTheme} from '@sanity/ui'
|
|
6
|
-
import {
|
|
6
|
+
import {Color, ColorChangeHandler, HSLColor, RGBColor} from 'react-color'
|
|
7
7
|
import {EditableInputStyles} from 'react-color/lib/components/common/EditableInput'
|
|
8
8
|
|
|
9
9
|
interface ColorPickerFieldsProps {
|
|
@@ -11,7 +11,7 @@ interface ColorPickerFieldsProps {
|
|
|
11
11
|
hsl?: HSLColor
|
|
12
12
|
hex?: string
|
|
13
13
|
disableAlpha: boolean
|
|
14
|
-
onChange: ColorChangeHandler<
|
|
14
|
+
onChange: ColorChangeHandler<Color>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const ColorPickerFields = ({
|