@zendeskgarden/react-colorpickers 8.75.1 → 8.76.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.
- package/dist/esm/elements/ColorSwatch/index.js +102 -0
- package/dist/esm/elements/ColorSwatchDialog/index.js +198 -0
- package/dist/esm/elements/Colorpicker/ColorWell.js +109 -0
- package/dist/esm/elements/Colorpicker/index.js +236 -0
- package/dist/esm/elements/Colorpicker/reducer.js +275 -0
- package/dist/esm/elements/ColorpickerDialog/index.js +156 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/check-sm-fill.svg.js +29 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +25 -0
- package/dist/esm/styled/ColorSwatch/StyledCell.js +22 -0
- package/dist/esm/styled/ColorSwatch/StyledColorSwatch.js +23 -0
- package/dist/esm/styled/ColorSwatch/StyledIcon.js +48 -0
- package/dist/esm/styled/ColorSwatch/StyledSwatchButton.js +27 -0
- package/dist/esm/styled/Colorpicker/StyledAlphaRange.js +37 -0
- package/dist/esm/styled/Colorpicker/StyledColorPicker.js +25 -0
- package/dist/esm/styled/Colorpicker/StyledColorWell.js +36 -0
- package/dist/esm/styled/Colorpicker/StyledColorWellThumb.js +40 -0
- package/dist/esm/styled/Colorpicker/StyledHexField.js +24 -0
- package/dist/esm/styled/Colorpicker/StyledHueRange.js +23 -0
- package/dist/esm/styled/Colorpicker/StyledInput.js +24 -0
- package/dist/esm/styled/Colorpicker/StyledInputGroup.js +22 -0
- package/dist/esm/styled/Colorpicker/StyledLabel.js +23 -0
- package/dist/esm/styled/Colorpicker/StyledPreview.js +37 -0
- package/dist/esm/styled/Colorpicker/StyledRGBAField.js +32 -0
- package/dist/esm/styled/Colorpicker/StyledSliderGroup.js +22 -0
- package/dist/esm/styled/Colorpicker/StyledSliders.js +23 -0
- package/dist/esm/styled/ColorpickerDialog/StyledButton.js +24 -0
- package/dist/esm/styled/ColorpickerDialog/StyledButtonPreview.js +48 -0
- package/dist/esm/styled/ColorpickerDialog/StyledTooltipBody.js +23 -0
- package/dist/esm/styled/ColorpickerDialog/StyledTooltipModal.js +23 -0
- package/dist/esm/styled/common/StyledRange.js +151 -0
- package/dist/esm/styled/common/checkeredBackground.js +28 -0
- package/dist/esm/utils/conversion.js +34 -0
- package/dist/esm/utils/saturation.js +64 -0
- package/dist/esm/utils/validation.js +12 -0
- package/dist/index.cjs.js +33 -49
- package/package.json +9 -9
- package/dist/index.esm.js +0 -1583
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import isEqual from 'lodash.isequal';
|
|
8
|
+
import { parseToHsl, parseToRgb, rgb, hsl } from 'polished';
|
|
9
|
+
import { hsvToHsl } from '../../utils/conversion.js';
|
|
10
|
+
import { isValidHex } from '../../utils/validation.js';
|
|
11
|
+
|
|
12
|
+
function convertStringToColor(colorString) {
|
|
13
|
+
if (colorString.includes('#') && !isValidHex(colorString)) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
hue,
|
|
18
|
+
saturation,
|
|
19
|
+
lightness
|
|
20
|
+
} = parseToHsl(colorString);
|
|
21
|
+
const {
|
|
22
|
+
red,
|
|
23
|
+
green,
|
|
24
|
+
blue,
|
|
25
|
+
alpha
|
|
26
|
+
} = parseToRgb(colorString);
|
|
27
|
+
const computedAlpha = alpha === undefined ? 100 : alpha * 100;
|
|
28
|
+
const computedHex = rgb({
|
|
29
|
+
red,
|
|
30
|
+
green,
|
|
31
|
+
blue
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
hue,
|
|
35
|
+
saturation: saturation * 100,
|
|
36
|
+
lightness: lightness * 100,
|
|
37
|
+
red,
|
|
38
|
+
green,
|
|
39
|
+
blue,
|
|
40
|
+
alpha: computedAlpha,
|
|
41
|
+
hex: computedHex
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const areColorsEqual = (a, b) => {
|
|
45
|
+
if (a === undefined || b === undefined) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const colorA = typeof a === 'string' ? convertStringToColor(a) : a;
|
|
49
|
+
const colorB = typeof b === 'string' ? convertStringToColor(b) : b;
|
|
50
|
+
if (colorA === undefined || colorB === undefined) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return isEqual(colorA, colorB);
|
|
54
|
+
};
|
|
55
|
+
function getInitialState(color) {
|
|
56
|
+
const whiteColor = {
|
|
57
|
+
hue: 0,
|
|
58
|
+
saturation: 0,
|
|
59
|
+
lightness: 0,
|
|
60
|
+
red: 255,
|
|
61
|
+
green: 255,
|
|
62
|
+
blue: 255,
|
|
63
|
+
alpha: 100,
|
|
64
|
+
hex: '#ffffff'
|
|
65
|
+
};
|
|
66
|
+
if (color === undefined) {
|
|
67
|
+
return getInitialState(whiteColor);
|
|
68
|
+
}
|
|
69
|
+
if (typeof color === 'string') {
|
|
70
|
+
const computedColor = convertStringToColor(color);
|
|
71
|
+
return getInitialState(computedColor || whiteColor);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
color,
|
|
75
|
+
hexInput: color.hex,
|
|
76
|
+
redInput: color.red.toString(),
|
|
77
|
+
blueInput: color.blue.toString(),
|
|
78
|
+
greenInput: color.green.toString(),
|
|
79
|
+
alphaInput: color.alpha.toString()
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const reducer = (state, action) => {
|
|
83
|
+
switch (action.type) {
|
|
84
|
+
case 'SATURATION_CHANGE':
|
|
85
|
+
{
|
|
86
|
+
const hsl$1 = hsvToHsl(action.payload.h, action.payload.s * 100, action.payload.v * 100);
|
|
87
|
+
const hex = hsl({
|
|
88
|
+
hue: action.payload.h,
|
|
89
|
+
saturation: hsl$1.s / 100,
|
|
90
|
+
lightness: hsl$1.l / 100
|
|
91
|
+
});
|
|
92
|
+
const rgb = parseToRgb(hex);
|
|
93
|
+
return {
|
|
94
|
+
...state,
|
|
95
|
+
color: {
|
|
96
|
+
...state.color,
|
|
97
|
+
saturation: hsl$1.s,
|
|
98
|
+
lightness: hsl$1.l,
|
|
99
|
+
hex,
|
|
100
|
+
red: rgb.red,
|
|
101
|
+
green: rgb.green,
|
|
102
|
+
blue: rgb.blue
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
case 'HUE_CHANGE':
|
|
107
|
+
{
|
|
108
|
+
const hue = Number(action.payload);
|
|
109
|
+
const hex = hsl({
|
|
110
|
+
hue,
|
|
111
|
+
saturation: state.color.saturation / 100,
|
|
112
|
+
lightness: state.color.lightness / 100
|
|
113
|
+
});
|
|
114
|
+
const rgb = parseToRgb(hex);
|
|
115
|
+
return {
|
|
116
|
+
...state,
|
|
117
|
+
color: {
|
|
118
|
+
...state.color,
|
|
119
|
+
hue,
|
|
120
|
+
hex,
|
|
121
|
+
red: rgb.red,
|
|
122
|
+
green: rgb.green,
|
|
123
|
+
blue: rgb.blue
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
case 'ALPHA_SLIDER_CHANGE':
|
|
128
|
+
{
|
|
129
|
+
return {
|
|
130
|
+
...state,
|
|
131
|
+
color: {
|
|
132
|
+
...state.color,
|
|
133
|
+
alpha: Math.round(Number(action.payload) * 100)
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
case 'HEX_CHANGE':
|
|
138
|
+
{
|
|
139
|
+
let color = state.color;
|
|
140
|
+
if (isValidHex(action.payload)) {
|
|
141
|
+
const rgb = parseToRgb(action.payload);
|
|
142
|
+
const hsl = parseToHsl(`rgb(${rgb.red}, ${rgb.green}, ${rgb.blue})`);
|
|
143
|
+
color = {
|
|
144
|
+
...color,
|
|
145
|
+
hue: hsl.hue,
|
|
146
|
+
saturation: hsl.saturation * 100,
|
|
147
|
+
lightness: hsl.lightness * 100,
|
|
148
|
+
hex: action.payload,
|
|
149
|
+
red: rgb.red,
|
|
150
|
+
green: rgb.green,
|
|
151
|
+
blue: rgb.blue
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
...state,
|
|
156
|
+
hexInput: action.payload,
|
|
157
|
+
color
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
case 'RED_CHANGE':
|
|
161
|
+
{
|
|
162
|
+
let red = parseInt(action.payload, 10);
|
|
163
|
+
let color = state.color;
|
|
164
|
+
if (!isNaN(red)) {
|
|
165
|
+
if (red >= 255) {
|
|
166
|
+
red = 255;
|
|
167
|
+
}
|
|
168
|
+
if (red < 0) {
|
|
169
|
+
red = 0;
|
|
170
|
+
}
|
|
171
|
+
const hsl = parseToHsl(`rgb(${red}, ${color.green}, ${color.blue})`);
|
|
172
|
+
const hex = rgb(red, color.green, color.blue);
|
|
173
|
+
color = {
|
|
174
|
+
...color,
|
|
175
|
+
hex,
|
|
176
|
+
red: action.payload === '' ? color.red : red,
|
|
177
|
+
hue: hsl.hue,
|
|
178
|
+
saturation: hsl.saturation * 100,
|
|
179
|
+
lightness: hsl.lightness * 100
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
...state,
|
|
184
|
+
redInput: action.payload,
|
|
185
|
+
color
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
case 'GREEN_CHANGE':
|
|
189
|
+
{
|
|
190
|
+
let green = parseInt(action.payload, 10);
|
|
191
|
+
let color = state.color;
|
|
192
|
+
if (!isNaN(green)) {
|
|
193
|
+
if (green >= 255) {
|
|
194
|
+
green = 255;
|
|
195
|
+
}
|
|
196
|
+
if (green < 0) {
|
|
197
|
+
green = 0;
|
|
198
|
+
}
|
|
199
|
+
const hsl = parseToHsl(`rgb(${color.red}, ${green}, ${color.blue})`);
|
|
200
|
+
const hex = rgb(color.red, green, color.blue);
|
|
201
|
+
color = {
|
|
202
|
+
...color,
|
|
203
|
+
hex,
|
|
204
|
+
green: action.payload === '' ? color.green : green,
|
|
205
|
+
hue: hsl.hue,
|
|
206
|
+
saturation: hsl.saturation * 100,
|
|
207
|
+
lightness: hsl.lightness * 100
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
...state,
|
|
212
|
+
greenInput: action.payload,
|
|
213
|
+
color
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
case 'BLUE_CHANGE':
|
|
217
|
+
{
|
|
218
|
+
let blue = parseInt(action.payload, 10);
|
|
219
|
+
let color = state.color;
|
|
220
|
+
if (!isNaN(blue)) {
|
|
221
|
+
if (blue >= 255) {
|
|
222
|
+
blue = 255;
|
|
223
|
+
}
|
|
224
|
+
if (blue < 0) {
|
|
225
|
+
blue = 0;
|
|
226
|
+
}
|
|
227
|
+
const hsl = parseToHsl(`rgb(${color.red}, ${color.green}, ${blue})`);
|
|
228
|
+
const hex = rgb(color.red, color.green, blue);
|
|
229
|
+
color = {
|
|
230
|
+
...color,
|
|
231
|
+
hex,
|
|
232
|
+
blue: action.payload === '' ? color.blue : blue,
|
|
233
|
+
hue: hsl.hue,
|
|
234
|
+
saturation: hsl.saturation * 100,
|
|
235
|
+
lightness: hsl.lightness * 100
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
...state,
|
|
240
|
+
blueInput: action.payload,
|
|
241
|
+
color
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
case 'ALPHA_CHANGE':
|
|
245
|
+
{
|
|
246
|
+
let alpha = parseInt(action.payload, 10);
|
|
247
|
+
let color = state.color;
|
|
248
|
+
if (!isNaN(alpha)) {
|
|
249
|
+
if (alpha > 100) {
|
|
250
|
+
alpha = 100;
|
|
251
|
+
}
|
|
252
|
+
if (alpha < 0) {
|
|
253
|
+
alpha = 0;
|
|
254
|
+
}
|
|
255
|
+
color = {
|
|
256
|
+
...color,
|
|
257
|
+
alpha
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
...state,
|
|
262
|
+
alphaInput: action.payload,
|
|
263
|
+
color
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
case 'RESET_COLOR':
|
|
267
|
+
{
|
|
268
|
+
return getInitialState(action.payload);
|
|
269
|
+
}
|
|
270
|
+
default:
|
|
271
|
+
throw new Error('Unknown reducer case.');
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export { areColorsEqual, convertStringToColor, getInitialState, reducer };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import React__default, { forwardRef, useRef, useState, useEffect, cloneElement, Children } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { Button } from '@zendeskgarden/react-buttons';
|
|
10
|
+
import { PLACEMENT } from '@zendeskgarden/react-modals';
|
|
11
|
+
import { composeEventHandlers } from '@zendeskgarden/container-utilities';
|
|
12
|
+
import SvgChevronDownStroke from '../../node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js';
|
|
13
|
+
import { Colorpicker } from '../Colorpicker/index.js';
|
|
14
|
+
import '../../styled/Colorpicker/StyledColorPicker.js';
|
|
15
|
+
import '../../styled/Colorpicker/StyledHueRange.js';
|
|
16
|
+
import '../../styled/Colorpicker/StyledAlphaRange.js';
|
|
17
|
+
import '../../styled/Colorpicker/StyledPreview.js';
|
|
18
|
+
import '../../styled/Colorpicker/StyledColorWell.js';
|
|
19
|
+
import '../../styled/Colorpicker/StyledColorWellThumb.js';
|
|
20
|
+
import '../../styled/Colorpicker/StyledSliderGroup.js';
|
|
21
|
+
import '../../styled/Colorpicker/StyledHexField.js';
|
|
22
|
+
import '../../styled/Colorpicker/StyledLabel.js';
|
|
23
|
+
import '../../styled/Colorpicker/StyledInput.js';
|
|
24
|
+
import '../../styled/Colorpicker/StyledInputGroup.js';
|
|
25
|
+
import '../../styled/Colorpicker/StyledRGBAField.js';
|
|
26
|
+
import '../../styled/Colorpicker/StyledSliders.js';
|
|
27
|
+
import { StyledButton } from '../../styled/ColorpickerDialog/StyledButton.js';
|
|
28
|
+
import { StyledButtonPreview } from '../../styled/ColorpickerDialog/StyledButtonPreview.js';
|
|
29
|
+
import { StyledTooltipModal } from '../../styled/ColorpickerDialog/StyledTooltipModal.js';
|
|
30
|
+
import { StyledTooltipBody } from '../../styled/ColorpickerDialog/StyledTooltipBody.js';
|
|
31
|
+
import '../../styled/ColorSwatch/StyledSwatchButton.js';
|
|
32
|
+
import '../../styled/ColorSwatch/StyledColorSwatch.js';
|
|
33
|
+
import '../../styled/ColorSwatch/StyledIcon.js';
|
|
34
|
+
import '../../styled/ColorSwatch/StyledCell.js';
|
|
35
|
+
import { useText } from '@zendeskgarden/react-theming';
|
|
36
|
+
|
|
37
|
+
const ColorpickerDialog = forwardRef((_ref, ref) => {
|
|
38
|
+
let {
|
|
39
|
+
color,
|
|
40
|
+
defaultColor,
|
|
41
|
+
placement,
|
|
42
|
+
onChange,
|
|
43
|
+
onClose,
|
|
44
|
+
labels,
|
|
45
|
+
hasArrow,
|
|
46
|
+
isAnimated,
|
|
47
|
+
isOpaque,
|
|
48
|
+
isOpen,
|
|
49
|
+
popperModifiers,
|
|
50
|
+
zIndex,
|
|
51
|
+
focusInset,
|
|
52
|
+
disabled,
|
|
53
|
+
buttonProps,
|
|
54
|
+
onDialogChange,
|
|
55
|
+
'aria-label': ariaLabel,
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
} = _ref;
|
|
59
|
+
const isControlled = color !== null && color !== undefined;
|
|
60
|
+
const isDialogControlled = isOpen !== undefined && isOpen !== null;
|
|
61
|
+
const buttonRef = useRef(null);
|
|
62
|
+
const colorPickerRef = useRef(null);
|
|
63
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
64
|
+
const [uncontrolledColor, setUncontrolledColor] = useState(defaultColor);
|
|
65
|
+
const ariaLabelText = useText(ColorpickerDialog, {
|
|
66
|
+
'aria-label': ariaLabel
|
|
67
|
+
}, 'aria-label', 'Color picker');
|
|
68
|
+
const openDialog = () => {
|
|
69
|
+
setReferenceElement(buttonRef.current);
|
|
70
|
+
onDialogChange && onDialogChange({
|
|
71
|
+
isOpen: true
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const closeDialog = () => {
|
|
75
|
+
setReferenceElement(null);
|
|
76
|
+
onDialogChange && onDialogChange({
|
|
77
|
+
isOpen: false
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const onClick = composeEventHandlers(props.onClick, () => {
|
|
81
|
+
if (referenceElement) {
|
|
82
|
+
closeDialog();
|
|
83
|
+
} else {
|
|
84
|
+
openDialog();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (isDialogControlled) {
|
|
89
|
+
if (isOpen) {
|
|
90
|
+
setReferenceElement(buttonRef.current);
|
|
91
|
+
} else {
|
|
92
|
+
setReferenceElement(null);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, [isOpen, isDialogControlled]);
|
|
96
|
+
return React__default.createElement(React__default.Fragment, null, children ? ( cloneElement(Children.only(children), {
|
|
97
|
+
onClick,
|
|
98
|
+
ref: buttonRef
|
|
99
|
+
})) : React__default.createElement(StyledButton, Object.assign({
|
|
100
|
+
disabled: disabled,
|
|
101
|
+
focusInset: focusInset,
|
|
102
|
+
ref: buttonRef,
|
|
103
|
+
onClick: onClick
|
|
104
|
+
}, buttonProps), React__default.createElement(StyledButtonPreview, {
|
|
105
|
+
backgroundColor: isControlled ? color : uncontrolledColor
|
|
106
|
+
}), React__default.createElement(Button.EndIcon, {
|
|
107
|
+
isRotated: referenceElement != null
|
|
108
|
+
}, React__default.createElement(SvgChevronDownStroke, null))), React__default.createElement(StyledTooltipModal, Object.assign({
|
|
109
|
+
ref: ref,
|
|
110
|
+
hasArrow: hasArrow,
|
|
111
|
+
popperModifiers: popperModifiers,
|
|
112
|
+
zIndex: zIndex,
|
|
113
|
+
isAnimated: isAnimated,
|
|
114
|
+
isOpaque: isOpaque,
|
|
115
|
+
focusOnMount: false,
|
|
116
|
+
placement: placement,
|
|
117
|
+
referenceElement: referenceElement,
|
|
118
|
+
onClose: () => {
|
|
119
|
+
closeDialog();
|
|
120
|
+
onClose && onClose(isControlled ? color : uncontrolledColor);
|
|
121
|
+
},
|
|
122
|
+
"aria-label": ariaLabelText
|
|
123
|
+
}, props), React__default.createElement(StyledTooltipBody, null, React__default.createElement(Colorpicker, {
|
|
124
|
+
autofocus: true,
|
|
125
|
+
color: color,
|
|
126
|
+
isOpaque: isOpaque,
|
|
127
|
+
labels: labels,
|
|
128
|
+
ref: colorPickerRef,
|
|
129
|
+
defaultColor: uncontrolledColor,
|
|
130
|
+
onChange: isControlled ? onChange : setUncontrolledColor
|
|
131
|
+
}))));
|
|
132
|
+
});
|
|
133
|
+
ColorpickerDialog.propTypes = {
|
|
134
|
+
...Colorpicker.propTypes,
|
|
135
|
+
placement: PropTypes.oneOf(PLACEMENT),
|
|
136
|
+
onClose: PropTypes.func,
|
|
137
|
+
onDialogChange: PropTypes.func,
|
|
138
|
+
disabled: PropTypes.bool,
|
|
139
|
+
labels: PropTypes.object,
|
|
140
|
+
buttonProps: PropTypes.object,
|
|
141
|
+
popperModifiers: PropTypes.any,
|
|
142
|
+
zIndex: PropTypes.number,
|
|
143
|
+
hasArrow: PropTypes.bool,
|
|
144
|
+
isAnimated: PropTypes.bool,
|
|
145
|
+
isOpen: PropTypes.bool,
|
|
146
|
+
focusInset: PropTypes.bool
|
|
147
|
+
};
|
|
148
|
+
ColorpickerDialog.defaultProps = {
|
|
149
|
+
placement: 'bottom-start',
|
|
150
|
+
isAnimated: true,
|
|
151
|
+
zIndex: 1000,
|
|
152
|
+
hasArrow: false
|
|
153
|
+
};
|
|
154
|
+
ColorpickerDialog.displayName = 'ColorpickerDialog';
|
|
155
|
+
|
|
156
|
+
export { ColorpickerDialog };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
export { Colorpicker } from './elements/Colorpicker/index.js';
|
|
8
|
+
export { ColorpickerDialog } from './elements/ColorpickerDialog/index.js';
|
|
9
|
+
export { ColorSwatch } from './elements/ColorSwatch/index.js';
|
|
10
|
+
export { ColorSwatchDialog } from './elements/ColorSwatchDialog/index.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _path;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgCheckSmFill = function SvgCheckSmFill(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 12,
|
|
15
|
+
height: 12,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 12 12",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
fill: "none",
|
|
21
|
+
stroke: "currentColor",
|
|
22
|
+
strokeLinecap: "round",
|
|
23
|
+
strokeLinejoin: "round",
|
|
24
|
+
strokeWidth: 2,
|
|
25
|
+
d: "M3 6l2 2 4-4"
|
|
26
|
+
})));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { SvgCheckSmFill as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _path;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 16,
|
|
15
|
+
height: 16,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
fill: "currentColor",
|
|
21
|
+
d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
|
|
22
|
+
})));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { SvgChevronDownStroke as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'colorpickers.swatch_cell';
|
|
11
|
+
const StyledCell = styled.td.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '8.76.1'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledCell",
|
|
16
|
+
componentId: "sc-qr3oit-0"
|
|
17
|
+
})(["padding:", "px;font-size:0;", ";"], props => props.theme.space.base, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledCell.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledCell };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'colorpickers.color_swatch';
|
|
11
|
+
const StyledColorSwatch = styled.table.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '8.76.1',
|
|
14
|
+
role: 'grid'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledColorSwatch",
|
|
17
|
+
componentId: "sc-ajx440-0"
|
|
18
|
+
})(["border-collapse:collapse;line-height:normal;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledColorSwatch.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledColorSwatch };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { parseToRgb, readableColor } from 'polished';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
10
|
+
import React__default, { Children } from 'react';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'colorpickers.colorswatch_check';
|
|
13
|
+
const colorStyles = props => {
|
|
14
|
+
const {
|
|
15
|
+
theme,
|
|
16
|
+
color
|
|
17
|
+
} = props;
|
|
18
|
+
const {
|
|
19
|
+
alpha
|
|
20
|
+
} = parseToRgb(color);
|
|
21
|
+
let checkColor = readableColor(color, getColorV8('foreground', 600 , theme), getColorV8('background', 600 , theme));
|
|
22
|
+
if (alpha !== undefined && alpha < 0.4) {
|
|
23
|
+
checkColor = getColorV8('foreground', 600 , theme);
|
|
24
|
+
}
|
|
25
|
+
return `
|
|
26
|
+
color: ${checkColor}
|
|
27
|
+
`;
|
|
28
|
+
};
|
|
29
|
+
const StyledIcon = styled(_ref => {
|
|
30
|
+
let {
|
|
31
|
+
children,
|
|
32
|
+
color,
|
|
33
|
+
theme,
|
|
34
|
+
...props
|
|
35
|
+
} = _ref;
|
|
36
|
+
return React__default.cloneElement(Children.only(children), props);
|
|
37
|
+
}).attrs({
|
|
38
|
+
'data-garden-id': COMPONENT_ID,
|
|
39
|
+
'data-garden-version': '8.76.1'
|
|
40
|
+
}).withConfig({
|
|
41
|
+
displayName: "StyledIcon",
|
|
42
|
+
componentId: "sc-8oigif-0"
|
|
43
|
+
})(["transition:opacity 0.2s ease-in-out;opacity:", ";width:", "px;height:", "px;", " ", ";"], props => props.selected ? 1 : 0, props => props.theme.space.base * 5, props => props.theme.space.base * 5, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
44
|
+
StyledIcon.defaultProps = {
|
|
45
|
+
theme: DEFAULT_THEME
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { StyledIcon };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { focusStyles, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledButtonPreview } from '../ColorpickerDialog/StyledButtonPreview.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.swatch_button';
|
|
12
|
+
const StyledSwatchButton = styled(StyledButtonPreview).attrs(props => ({
|
|
13
|
+
as: 'button',
|
|
14
|
+
'data-garden-id': COMPONENT_ID,
|
|
15
|
+
'data-test-id': props.backgroundColor,
|
|
16
|
+
'data-garden-version': '8.76.1'
|
|
17
|
+
})).withConfig({
|
|
18
|
+
displayName: "StyledSwatchButton",
|
|
19
|
+
componentId: "sc-edpwpp-0"
|
|
20
|
+
})(["transition:box-shadow 0.1s ease-in-out;outline:none;border:none;border-radius:", ";cursor:pointer;padding:0;", " ", ";"], props => props.theme.borderRadii.md, props => focusStyles({
|
|
21
|
+
theme: props.theme
|
|
22
|
+
}), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
23
|
+
StyledSwatchButton.defaultProps = {
|
|
24
|
+
theme: DEFAULT_THEME
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { StyledSwatchButton };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledRange, getTrackMargin, getTrackHeight } from '../common/StyledRange.js';
|
|
10
|
+
import { checkeredBackground } from '../common/checkeredBackground.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_alpha';
|
|
13
|
+
const background = props => {
|
|
14
|
+
const direction = `to ${props.theme.rtl ? 'left' : 'right'}`;
|
|
15
|
+
const fromColor = `rgba(${props.red}, ${props.green}, ${props.blue}, 0)`;
|
|
16
|
+
const toColor = `rgb(${props.red}, ${props.green}, ${props.blue})`;
|
|
17
|
+
const positionY = getTrackMargin(props);
|
|
18
|
+
const height = getTrackHeight(props);
|
|
19
|
+
const gradientBackground = `linear-gradient(${direction}, ${fromColor}, ${toColor}) 0 ${positionY}px / 100% ${height}px no-repeat`;
|
|
20
|
+
return `${gradientBackground}, ${checkeredBackground(props.theme, height, positionY, 'repeat-x')}`;
|
|
21
|
+
};
|
|
22
|
+
const StyledAlphaRange = styled(StyledRange).attrs(props => ({
|
|
23
|
+
style: {
|
|
24
|
+
backgroundSize: 'auto',
|
|
25
|
+
background: background(props)
|
|
26
|
+
},
|
|
27
|
+
'data-garden-id': COMPONENT_ID,
|
|
28
|
+
'data-garden-version': '8.76.1'
|
|
29
|
+
})).withConfig({
|
|
30
|
+
displayName: "StyledAlphaRange",
|
|
31
|
+
componentId: "sc-kuh2xc-0"
|
|
32
|
+
})([""]);
|
|
33
|
+
StyledAlphaRange.defaultProps = {
|
|
34
|
+
theme: DEFAULT_THEME
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { StyledAlphaRange };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'colorpickers.colorpicker';
|
|
11
|
+
const getColorV8PickerWidth = props => {
|
|
12
|
+
return props.isOpaque ? 268 : 312;
|
|
13
|
+
};
|
|
14
|
+
const StyledColorPicker = styled.div.attrs({
|
|
15
|
+
'data-garden-id': COMPONENT_ID,
|
|
16
|
+
'data-garden-version': '8.76.1'
|
|
17
|
+
}).withConfig({
|
|
18
|
+
displayName: "StyledColorPicker",
|
|
19
|
+
componentId: "sc-1donyl9-0"
|
|
20
|
+
})(["width:", "px;min-width:", "px;", ";"], getColorV8PickerWidth, getColorV8PickerWidth, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
21
|
+
StyledColorPicker.defaultProps = {
|
|
22
|
+
theme: DEFAULT_THEME
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { StyledColorPicker, getColorV8PickerWidth };
|