@sanity/color-input 3.0.2 → 3.1.1

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.
@@ -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 {CustomPicker, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'
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 {ColorChangeHandler, HEXColor, HSLColor, HSVColor, RGBColor} from 'react-color'
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<HSLColor | HSVColor | RGBColor | HEXColor>
14
+ onChange: ColorChangeHandler<Color>
15
15
  }
16
16
 
17
17
  export const ColorPickerFields = ({