@zendeskgarden/react-colorpickers 8.57.1 → 8.59.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/dist/index.cjs.js +694 -853
- package/dist/index.esm.js +697 -856
- package/package.json +7 -7
package/dist/index.esm.js
CHANGED
|
@@ -20,192 +20,55 @@ import { composeEventHandlers, useId } from '@zendeskgarden/container-utilities'
|
|
|
20
20
|
import { Tooltip } from '@zendeskgarden/react-tooltips';
|
|
21
21
|
import { useGrid } from '@zendeskgarden/container-grid';
|
|
22
22
|
|
|
23
|
-
function ownKeys(object, enumerableOnly) {
|
|
24
|
-
var keys = Object.keys(object);
|
|
25
|
-
|
|
26
|
-
if (Object.getOwnPropertySymbols) {
|
|
27
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
28
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
29
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
30
|
-
})), keys.push.apply(keys, symbols);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return keys;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _objectSpread2(target) {
|
|
37
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
38
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
39
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
40
|
-
_defineProperty(target, key, source[key]);
|
|
41
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
42
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return target;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function _defineProperty(obj, key, value) {
|
|
50
|
-
if (key in obj) {
|
|
51
|
-
Object.defineProperty(obj, key, {
|
|
52
|
-
value: value,
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
obj[key] = value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return obj;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
23
|
function _extends$2() {
|
|
65
24
|
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
66
25
|
for (var i = 1; i < arguments.length; i++) {
|
|
67
26
|
var source = arguments[i];
|
|
68
|
-
|
|
69
27
|
for (var key in source) {
|
|
70
28
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
71
29
|
target[key] = source[key];
|
|
72
30
|
}
|
|
73
31
|
}
|
|
74
32
|
}
|
|
75
|
-
|
|
76
33
|
return target;
|
|
77
34
|
};
|
|
78
35
|
return _extends$2.apply(this, arguments);
|
|
79
36
|
}
|
|
80
37
|
|
|
81
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
82
|
-
if (source == null) return {};
|
|
83
|
-
var target = {};
|
|
84
|
-
var sourceKeys = Object.keys(source);
|
|
85
|
-
var key, i;
|
|
86
|
-
|
|
87
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
88
|
-
key = sourceKeys[i];
|
|
89
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
90
|
-
target[key] = source[key];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return target;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function _objectWithoutProperties(source, excluded) {
|
|
97
|
-
if (source == null) return {};
|
|
98
|
-
|
|
99
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
100
|
-
|
|
101
|
-
var key, i;
|
|
102
|
-
|
|
103
|
-
if (Object.getOwnPropertySymbols) {
|
|
104
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
105
|
-
|
|
106
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
107
|
-
key = sourceSymbolKeys[i];
|
|
108
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
109
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
110
|
-
target[key] = source[key];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return target;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function _slicedToArray(arr, i) {
|
|
118
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function _arrayWithHoles(arr) {
|
|
122
|
-
if (Array.isArray(arr)) return arr;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function _iterableToArrayLimit(arr, i) {
|
|
126
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
127
|
-
|
|
128
|
-
if (_i == null) return;
|
|
129
|
-
var _arr = [];
|
|
130
|
-
var _n = true;
|
|
131
|
-
var _d = false;
|
|
132
|
-
|
|
133
|
-
var _s, _e;
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
137
|
-
_arr.push(_s.value);
|
|
138
|
-
|
|
139
|
-
if (i && _arr.length === i) break;
|
|
140
|
-
}
|
|
141
|
-
} catch (err) {
|
|
142
|
-
_d = true;
|
|
143
|
-
_e = err;
|
|
144
|
-
} finally {
|
|
145
|
-
try {
|
|
146
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
147
|
-
} finally {
|
|
148
|
-
if (_d) throw _e;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return _arr;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
156
|
-
if (!o) return;
|
|
157
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
158
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
159
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
160
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
161
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function _arrayLikeToArray(arr, len) {
|
|
165
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
166
|
-
|
|
167
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
168
|
-
|
|
169
|
-
return arr2;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function _nonIterableRest() {
|
|
173
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
174
|
-
}
|
|
175
|
-
|
|
176
38
|
function hslToHsv(h, s, l) {
|
|
177
|
-
|
|
39
|
+
let saturation = s;
|
|
178
40
|
saturation *= (l < 50 ? l : 100 - l) / 100;
|
|
179
|
-
|
|
41
|
+
const v = l + saturation;
|
|
180
42
|
return {
|
|
181
|
-
h
|
|
43
|
+
h,
|
|
182
44
|
s: v === 0 ? 0 : 2 * saturation / v * 100,
|
|
183
|
-
v
|
|
45
|
+
v
|
|
184
46
|
};
|
|
185
47
|
}
|
|
186
48
|
function hsvToHsl(h, s, v) {
|
|
187
|
-
|
|
188
|
-
|
|
49
|
+
let saturation = s;
|
|
50
|
+
let value = v;
|
|
189
51
|
saturation /= 100;
|
|
190
52
|
value /= 100;
|
|
191
|
-
|
|
192
|
-
|
|
53
|
+
let l = (2 - saturation) * value;
|
|
54
|
+
let sl = saturation * value;
|
|
193
55
|
sl /= l <= 1 ? l : 2 - l;
|
|
194
56
|
sl = sl || 0;
|
|
195
57
|
l /= 2;
|
|
196
58
|
return {
|
|
197
|
-
h
|
|
59
|
+
h,
|
|
198
60
|
s: sl * 100,
|
|
199
61
|
l: l * 100
|
|
200
62
|
};
|
|
201
63
|
}
|
|
202
64
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
65
|
+
const getSaturationLightness = (element, x, y, rtl) => {
|
|
66
|
+
const {
|
|
67
|
+
width,
|
|
68
|
+
height
|
|
69
|
+
} = element.getBoundingClientRect();
|
|
70
|
+
let left = x - (element.getBoundingClientRect().left + window.pageXOffset);
|
|
71
|
+
let top = y - (element.getBoundingClientRect().top + window.pageYOffset);
|
|
209
72
|
if (left < 0) {
|
|
210
73
|
left = 0;
|
|
211
74
|
} else if (left > width) {
|
|
@@ -219,33 +82,35 @@ var getSaturationLightness = function getSaturationLightness(element, x, y, rtl)
|
|
|
219
82
|
if (rtl) {
|
|
220
83
|
left = width - left;
|
|
221
84
|
}
|
|
222
|
-
|
|
223
|
-
|
|
85
|
+
const saturation = left / width;
|
|
86
|
+
const bright = 1 - top / height;
|
|
224
87
|
return {
|
|
225
|
-
saturation
|
|
226
|
-
bright
|
|
88
|
+
saturation,
|
|
89
|
+
bright
|
|
227
90
|
};
|
|
228
91
|
};
|
|
229
92
|
function getNextHsv(e, hue, container, rtl) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
93
|
+
const {
|
|
94
|
+
saturation,
|
|
95
|
+
bright
|
|
96
|
+
} = getSaturationLightness(container, e.pageX, e.pageY, rtl);
|
|
233
97
|
return {
|
|
234
98
|
h: hue,
|
|
235
99
|
s: saturation,
|
|
236
100
|
v: bright
|
|
237
101
|
};
|
|
238
102
|
}
|
|
239
|
-
|
|
103
|
+
const getThumbPosition = (x, y, rtl, container) => {
|
|
240
104
|
if (container.current) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
105
|
+
const {
|
|
106
|
+
saturation,
|
|
107
|
+
bright
|
|
108
|
+
} = getSaturationLightness(container.current, x, y, rtl);
|
|
109
|
+
const topFromMouse = (1 - bright) * 100;
|
|
110
|
+
const leftFromMouse = rtl ? 100 - saturation * 100 : saturation * 100;
|
|
246
111
|
return {
|
|
247
|
-
topFromMouse
|
|
248
|
-
leftFromMouse
|
|
112
|
+
topFromMouse,
|
|
113
|
+
leftFromMouse
|
|
249
114
|
};
|
|
250
115
|
}
|
|
251
116
|
return {
|
|
@@ -254,137 +119,208 @@ var getThumbPosition = function getThumbPosition(x, y, rtl, container) {
|
|
|
254
119
|
};
|
|
255
120
|
};
|
|
256
121
|
|
|
257
|
-
|
|
258
|
-
|
|
122
|
+
const COMPONENT_ID$l = 'colorpickers.colorpicker';
|
|
123
|
+
const getColorPickerWidth = props => {
|
|
259
124
|
return props.isOpaque ? 268 : 312;
|
|
260
125
|
};
|
|
261
|
-
|
|
126
|
+
const StyledColorPicker = styled.div.attrs({
|
|
262
127
|
'data-garden-id': COMPONENT_ID$l,
|
|
263
|
-
'data-garden-version': '8.
|
|
128
|
+
'data-garden-version': '8.59.0'
|
|
264
129
|
}).withConfig({
|
|
265
130
|
displayName: "StyledColorPicker",
|
|
266
131
|
componentId: "sc-1donyl9-0"
|
|
267
|
-
})(["width:", "px;min-width:", "px;", ";"], getColorPickerWidth, getColorPickerWidth,
|
|
268
|
-
return retrieveComponentStyles(COMPONENT_ID$l, props);
|
|
269
|
-
});
|
|
132
|
+
})(["width:", "px;min-width:", "px;", ";"], getColorPickerWidth, getColorPickerWidth, props => retrieveComponentStyles(COMPONENT_ID$l, props));
|
|
270
133
|
StyledColorPicker.defaultProps = {
|
|
271
134
|
theme: DEFAULT_THEME
|
|
272
135
|
};
|
|
273
136
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
var thumbActiveBackgroundColor = getColor('neutralHue', 200, props.theme);
|
|
291
|
-
var thumbActiveBorderColor = getColor('primaryHue', 600, props.theme);
|
|
292
|
-
var thumbHoverBackgroundColor = thumbActiveBackgroundColor;
|
|
293
|
-
var thumbHoverBorderColor = thumbHoverBackgroundColor;
|
|
294
|
-
return "\n border-color: ".concat(props.isOpaque && props.theme.colors.background, ";\n\n ").concat(trackStyles("\n background-color: transparent;\n "), "\n\n ").concat(thumbStyles("\n border-color: ".concat(thumbBorderColor, ";\n background-color: ").concat(thumbBackgroundColor, ";\n ")), "\n\n ").concat(trackLowerStyles("\n background-color: transparent;\n "), "\n\n ").concat(thumbStyles("\n border-color: ".concat(thumbHoverBorderColor, ";\n background-color: ").concat(thumbHoverBackgroundColor, ";\n "), ':hover'), "\n\n ").concat(thumbStyles("\n background-color: ".concat(thumbBackgroundColor, ";\n border-color: ").concat(thumbActiveBorderColor, ";\n "), '[data-garden-focus-visible="true"]'), "\n\n ").concat(thumbStyles("\n border-color: ".concat(thumbActiveBorderColor, ";\n background-color: ").concat(thumbActiveBackgroundColor, "\n "), ':active'), "\n ");
|
|
137
|
+
const COMPONENT_ID$k = 'colorpickers.colorpicker_range';
|
|
138
|
+
const thumbStyles = function (styles) {
|
|
139
|
+
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
140
|
+
return `
|
|
141
|
+
&${modifier}::-moz-range-thumb {
|
|
142
|
+
${styles}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&${modifier}::-ms-thumb {
|
|
146
|
+
${styles}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&${modifier}::-webkit-slider-thumb {
|
|
150
|
+
${styles}
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
295
153
|
};
|
|
296
|
-
|
|
297
|
-
|
|
154
|
+
const trackStyles = function (styles) {
|
|
155
|
+
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
156
|
+
return `
|
|
157
|
+
&${modifier}::-moz-range-track {
|
|
158
|
+
${styles}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&${modifier}::-ms-track {
|
|
162
|
+
${styles}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&${modifier}::-webkit-slider-runnable-track {
|
|
166
|
+
${styles}
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
298
169
|
};
|
|
299
|
-
|
|
300
|
-
|
|
170
|
+
const trackLowerStyles = function (styles) {
|
|
171
|
+
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
172
|
+
return `
|
|
173
|
+
&${modifier}::-moz-range-progress {
|
|
174
|
+
${styles}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
&${modifier}::-ms-fill-lower {
|
|
178
|
+
${styles}
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
301
181
|
};
|
|
302
|
-
|
|
303
|
-
|
|
182
|
+
const colorStyles$1 = props => {
|
|
183
|
+
const thumbBackgroundColor = getColor('neutralHue', 100, props.theme);
|
|
184
|
+
const thumbBorderColor = thumbBackgroundColor;
|
|
185
|
+
const thumbActiveBackgroundColor = getColor('neutralHue', 200, props.theme);
|
|
186
|
+
const thumbActiveBorderColor = getColor('primaryHue', 600, props.theme);
|
|
187
|
+
const thumbHoverBackgroundColor = thumbActiveBackgroundColor;
|
|
188
|
+
const thumbHoverBorderColor = thumbHoverBackgroundColor;
|
|
189
|
+
return `
|
|
190
|
+
border-color: ${props.isOpaque && props.theme.colors.background};
|
|
191
|
+
|
|
192
|
+
${trackStyles(`
|
|
193
|
+
background-color: transparent;
|
|
194
|
+
`)}
|
|
195
|
+
|
|
196
|
+
${thumbStyles(`
|
|
197
|
+
border-color: ${thumbBorderColor};
|
|
198
|
+
background-color: ${thumbBackgroundColor};
|
|
199
|
+
`)}
|
|
200
|
+
|
|
201
|
+
${trackLowerStyles(`
|
|
202
|
+
background-color: transparent;
|
|
203
|
+
`)}
|
|
204
|
+
|
|
205
|
+
${thumbStyles(`
|
|
206
|
+
border-color: ${thumbHoverBorderColor};
|
|
207
|
+
background-color: ${thumbHoverBackgroundColor};
|
|
208
|
+
`, ':hover')}
|
|
209
|
+
|
|
210
|
+
${thumbStyles(`
|
|
211
|
+
background-color: ${thumbBackgroundColor};
|
|
212
|
+
border-color: ${thumbActiveBorderColor};
|
|
213
|
+
`, '[data-garden-focus-visible="true"]')}
|
|
214
|
+
|
|
215
|
+
${thumbStyles(`
|
|
216
|
+
border-color: ${thumbActiveBorderColor};
|
|
217
|
+
background-color: ${thumbActiveBackgroundColor}
|
|
218
|
+
`, ':active')}
|
|
219
|
+
`;
|
|
304
220
|
};
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
221
|
+
const getThumbSize = props => props.theme.space.base * (props.isOpaque ? 6 : 4);
|
|
222
|
+
const getTrackHeight = props => props.theme.space.base * (props.isOpaque ? 6 : 3);
|
|
223
|
+
const getTrackMargin = props => (getThumbSize(props) - getTrackHeight(props)) / 2 + stripUnit(props.theme.shadowWidths.md);
|
|
224
|
+
const sizeStyles$2 = props => {
|
|
225
|
+
const thumbSize = getThumbSize(props);
|
|
226
|
+
const trackHeight = getTrackHeight(props);
|
|
227
|
+
const trackMargin = getTrackMargin(props);
|
|
228
|
+
const thumbMargin = (trackHeight - thumbSize) / 2;
|
|
229
|
+
const trackOffset = props.theme.space.base * (props.isOpaque ? -2 : -1);
|
|
230
|
+
const height = props.isOpaque ? trackHeight : trackMargin * 2 + trackHeight;
|
|
231
|
+
let marginHorizontal;
|
|
232
|
+
let border;
|
|
233
|
+
let borderRadius;
|
|
315
234
|
if (props.isOpaque) {
|
|
316
|
-
marginHorizontal =
|
|
317
|
-
border =
|
|
318
|
-
borderRadius =
|
|
235
|
+
marginHorizontal = `-${trackMargin}px`;
|
|
236
|
+
border = `${trackMargin}px ${props.theme.borderStyles.solid}`;
|
|
237
|
+
borderRadius = `${trackMargin + stripUnit(props.theme.shadowWidths.md)}px`;
|
|
319
238
|
}
|
|
320
|
-
return
|
|
239
|
+
return `
|
|
240
|
+
/* stylelint-disable-next-line declaration-no-important */
|
|
241
|
+
margin-top: 0 !important;
|
|
242
|
+
margin-${props.theme.rtl ? 'right' : 'left'}: ${marginHorizontal};
|
|
243
|
+
height: ${height}px; /* [1] */
|
|
244
|
+
box-sizing: content-box; /* [2] */
|
|
245
|
+
border: ${border};
|
|
246
|
+
border-radius: ${borderRadius};
|
|
247
|
+
|
|
248
|
+
${trackStyles(`
|
|
249
|
+
margin: ${trackMargin}px ${trackOffset}px;
|
|
250
|
+
height: ${trackHeight}px;
|
|
251
|
+
`)}
|
|
252
|
+
|
|
253
|
+
${thumbStyles(`
|
|
254
|
+
margin: ${thumbMargin}px 0;
|
|
255
|
+
border-width: ${math(`${props.theme.borderWidths.sm} * 2`)};
|
|
256
|
+
height: ${thumbSize}px;
|
|
257
|
+
width: ${thumbSize}px;
|
|
258
|
+
`)};
|
|
259
|
+
`;
|
|
321
260
|
};
|
|
322
|
-
|
|
261
|
+
const StyledRange = styled(Range).attrs({
|
|
323
262
|
'data-garden-id': COMPONENT_ID$k,
|
|
324
|
-
'data-garden-version': '8.
|
|
263
|
+
'data-garden-version': '8.59.0',
|
|
325
264
|
hasLowerTrack: false
|
|
326
265
|
}).withConfig({
|
|
327
266
|
displayName: "StyledRange",
|
|
328
267
|
componentId: "sc-ug3wi9-0"
|
|
329
|
-
})(["", ";", " ", ";", ";"], sizeStyles$2, trackStyles(
|
|
330
|
-
|
|
331
|
-
|
|
268
|
+
})(["", ";", " ", ";", ";"], sizeStyles$2, trackStyles(`
|
|
269
|
+
border-radius: 0;
|
|
270
|
+
`), colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$k, props));
|
|
332
271
|
StyledRange.defaultProps = {
|
|
333
272
|
theme: DEFAULT_THEME
|
|
334
273
|
};
|
|
335
274
|
|
|
336
|
-
|
|
337
|
-
|
|
275
|
+
const COMPONENT_ID$j = 'colorpickers.colorpicker_hue';
|
|
276
|
+
const StyledHueRange = styled(StyledRange).attrs({
|
|
338
277
|
'data-garden-id': COMPONENT_ID$j,
|
|
339
|
-
'data-garden-version': '8.
|
|
278
|
+
'data-garden-version': '8.59.0'
|
|
340
279
|
}).withConfig({
|
|
341
280
|
displayName: "StyledHueRange",
|
|
342
281
|
componentId: "sc-13ly7p-0"
|
|
343
|
-
})(["background:linear-gradient( to ", ",#f00 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,#f00 100% ) no-repeat;background-position:", ";background-size:100% ", "px;"],
|
|
344
|
-
return props.theme.rtl ? 'left' : 'right';
|
|
345
|
-
}, function (props) {
|
|
346
|
-
return !props.isOpaque && "0 ".concat(getTrackMargin(props), "px");
|
|
347
|
-
}, function (props) {
|
|
348
|
-
return getTrackHeight(props);
|
|
349
|
-
});
|
|
282
|
+
})(["background:linear-gradient( to ", ",#f00 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,#f00 100% ) no-repeat;background-position:", ";background-size:100% ", "px;"], props => props.theme.rtl ? 'left' : 'right', props => !props.isOpaque && `0 ${getTrackMargin(props)}px`, props => getTrackHeight(props));
|
|
350
283
|
StyledHueRange.defaultProps = {
|
|
351
284
|
theme: DEFAULT_THEME
|
|
352
285
|
};
|
|
353
286
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
return
|
|
287
|
+
const checkeredBackground = function (theme, size) {
|
|
288
|
+
let positionY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
289
|
+
let repeat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'repeat';
|
|
290
|
+
const color = getColor('neutralHue', 400, theme);
|
|
291
|
+
const dimensions = `${size}px ${size}px`;
|
|
292
|
+
const positionX1 = theme.rtl ? '100%' : '0';
|
|
293
|
+
const positionX2 = theme.rtl ? `calc(100% - ${size / 2}px)` : `${size / 2}px`;
|
|
294
|
+
const position1 = `${positionX1} ${positionY}px`;
|
|
295
|
+
const position2 = `${positionX2} ${size / 2 + positionY}px`;
|
|
296
|
+
const position3 = `${positionX2} ${positionY}px`;
|
|
297
|
+
const position4 = `${positionX1} ${size / -2 + positionY}px`;
|
|
298
|
+
return `
|
|
299
|
+
linear-gradient(45deg, ${color} 25%, transparent 25%) ${position1} / ${dimensions} ${repeat},
|
|
300
|
+
linear-gradient(45deg, transparent 75%, ${color} 75%) ${position2} / ${dimensions} ${repeat},
|
|
301
|
+
linear-gradient(135deg, ${color} 25%, transparent 25%) ${position3} / ${dimensions} ${repeat},
|
|
302
|
+
linear-gradient(135deg, transparent 75%, ${color} 75%) ${position4} / ${dimensions} ${repeat}
|
|
303
|
+
`;
|
|
366
304
|
};
|
|
367
305
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return
|
|
306
|
+
const COMPONENT_ID$i = 'colorpickers.colorpicker_alpha';
|
|
307
|
+
const background$3 = props => {
|
|
308
|
+
const direction = `to ${props.theme.rtl ? 'left' : 'right'}`;
|
|
309
|
+
const fromColor = `rgba(${props.red}, ${props.green}, ${props.blue}, 0)`;
|
|
310
|
+
const toColor = `rgb(${props.red}, ${props.green}, ${props.blue})`;
|
|
311
|
+
const positionY = getTrackMargin(props);
|
|
312
|
+
const height = getTrackHeight(props);
|
|
313
|
+
const gradientBackground = `linear-gradient(${direction}, ${fromColor}, ${toColor}) 0 ${positionY}px / 100% ${height}px no-repeat`;
|
|
314
|
+
return `${gradientBackground}, ${checkeredBackground(props.theme, height, positionY, 'repeat-x')}`;
|
|
377
315
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
};
|
|
387
|
-
}).withConfig({
|
|
316
|
+
const StyledAlphaRange = styled(StyledRange).attrs(props => ({
|
|
317
|
+
style: {
|
|
318
|
+
backgroundSize: 'auto',
|
|
319
|
+
background: background$3(props)
|
|
320
|
+
},
|
|
321
|
+
'data-garden-id': COMPONENT_ID$i,
|
|
322
|
+
'data-garden-version': '8.59.0'
|
|
323
|
+
})).withConfig({
|
|
388
324
|
displayName: "StyledAlphaRange",
|
|
389
325
|
componentId: "sc-kuh2xc-0"
|
|
390
326
|
})([""]);
|
|
@@ -392,476 +328,377 @@ StyledAlphaRange.defaultProps = {
|
|
|
392
328
|
theme: DEFAULT_THEME
|
|
393
329
|
};
|
|
394
330
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
331
|
+
const COMPONENT_ID$h = 'colorpickers.colorpicker_preview_box';
|
|
332
|
+
const background$2 = props => {
|
|
333
|
+
const alpha = props.alpha ? props.alpha / 100 : 0;
|
|
334
|
+
const color = `rgba(${props.red}, ${props.green}, ${props.blue}, ${alpha})`;
|
|
335
|
+
let retVal = `linear-gradient(${color}, ${color})`;
|
|
400
336
|
if (!props.isOpaque) {
|
|
401
|
-
retVal =
|
|
337
|
+
retVal = `${retVal}, ${checkeredBackground(props.theme, 13)}`;
|
|
402
338
|
}
|
|
403
339
|
return retVal;
|
|
404
340
|
};
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
};
|
|
414
|
-
}).withConfig({
|
|
341
|
+
const StyledPreview = styled.div.attrs(props => ({
|
|
342
|
+
style: {
|
|
343
|
+
background: background$2(props)
|
|
344
|
+
},
|
|
345
|
+
'data-garden-id': COMPONENT_ID$h,
|
|
346
|
+
'data-garden-version': '8.59.0',
|
|
347
|
+
'data-test-id': 'preview-box'
|
|
348
|
+
})).withConfig({
|
|
415
349
|
displayName: "StyledPreview",
|
|
416
350
|
componentId: "sc-d70mj1-0"
|
|
417
|
-
})(["flex-shrink:0;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"],
|
|
418
|
-
return props.theme.borderRadii.md;
|
|
419
|
-
}, function (props) {
|
|
420
|
-
return props.theme.borderWidths.sm;
|
|
421
|
-
}, function (props) {
|
|
422
|
-
return rgba(props.theme.palette.black, 0.19);
|
|
423
|
-
}, function (props) {
|
|
424
|
-
return props.theme.space.base * (props.isOpaque ? 6 : 8);
|
|
425
|
-
}, function (props) {
|
|
426
|
-
return props.theme.space.base * (props.isOpaque ? 6 : 8);
|
|
427
|
-
}, function (props) {
|
|
428
|
-
return retrieveComponentStyles(COMPONENT_ID$h, props);
|
|
429
|
-
});
|
|
351
|
+
})(["flex-shrink:0;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.borderRadii.md, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => retrieveComponentStyles(COMPONENT_ID$h, props));
|
|
430
352
|
StyledPreview.defaultProps = {
|
|
431
353
|
theme: DEFAULT_THEME
|
|
432
354
|
};
|
|
433
355
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
return
|
|
356
|
+
const COMPONENT_ID$g = 'colorpickers.colorpicker_colorwell';
|
|
357
|
+
const background$1 = props => {
|
|
358
|
+
const blackAlpha = rgba(props.theme.palette.black, 0.9);
|
|
359
|
+
const black = `linear-gradient(0deg, ${props.theme.palette.black}, ${blackAlpha} 1%, transparent 99%)`;
|
|
360
|
+
const whiteAngle = `${props.theme.rtl ? -90 : 90}deg`;
|
|
361
|
+
const white = `linear-gradient(${whiteAngle}, ${props.theme.palette.white} 1%, transparent)`;
|
|
362
|
+
const colorValue = hsl(props.hue, 1, 0.5);
|
|
363
|
+
const color = `linear-gradient(${colorValue}, ${colorValue})`;
|
|
364
|
+
return `${black}, ${white}, ${color}`;
|
|
443
365
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
};
|
|
453
|
-
}).withConfig({
|
|
366
|
+
const StyledColorWell = styled.div.attrs(props => ({
|
|
367
|
+
'data-garden-id': COMPONENT_ID$g,
|
|
368
|
+
'data-garden-version': '8.59.0',
|
|
369
|
+
'data-test-id': 'colorwell',
|
|
370
|
+
style: {
|
|
371
|
+
background: background$1(props)
|
|
372
|
+
}
|
|
373
|
+
})).withConfig({
|
|
454
374
|
displayName: "StyledColorWell",
|
|
455
375
|
componentId: "sc-54ly7s-0"
|
|
456
|
-
})(["position:relative;margin-bottom:", "px;cursor:pointer;height:208px;overflow:hidden;", ";"],
|
|
457
|
-
return props.theme.space.base * 2;
|
|
458
|
-
}, function (props) {
|
|
459
|
-
return retrieveComponentStyles(COMPONENT_ID$g, props);
|
|
460
|
-
});
|
|
376
|
+
})(["position:relative;margin-bottom:", "px;cursor:pointer;height:208px;overflow:hidden;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$g, props));
|
|
461
377
|
StyledColorWell.defaultProps = {
|
|
462
378
|
theme: DEFAULT_THEME
|
|
463
379
|
};
|
|
464
380
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
return
|
|
381
|
+
const COMPONENT_ID$f = 'colorpickers.colorpicker_colorwell_thumb';
|
|
382
|
+
const sizeStyles$1 = theme => {
|
|
383
|
+
const borderWidth = stripUnit(theme.borderWidths.sm) * 2;
|
|
384
|
+
const size = theme.space.base * 5;
|
|
385
|
+
const translateValue = size / -2;
|
|
386
|
+
return `
|
|
387
|
+
transform: translate(${translateValue}px, ${translateValue}px);
|
|
388
|
+
box-sizing: border-box;
|
|
389
|
+
border-width: ${borderWidth}px;
|
|
390
|
+
width: ${size}px;
|
|
391
|
+
height: ${size}px;
|
|
392
|
+
`;
|
|
471
393
|
};
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
};
|
|
482
|
-
}).withConfig({
|
|
394
|
+
const StyledColorWellThumb = styled.div.attrs(props => ({
|
|
395
|
+
'data-garden-id': COMPONENT_ID$f,
|
|
396
|
+
'data-garden-version': '8.59.0',
|
|
397
|
+
'data-test-id': 'colorwell-thumb',
|
|
398
|
+
style: {
|
|
399
|
+
top: `${props.top}%`,
|
|
400
|
+
left: `${props.left}%`
|
|
401
|
+
}
|
|
402
|
+
})).withConfig({
|
|
483
403
|
displayName: "StyledColorWellThumb",
|
|
484
404
|
componentId: "sc-1pnz3jz-0"
|
|
485
|
-
})(["position:absolute;border:solid ", ";border-radius:50%;box-shadow:", ";", ";", ";"],
|
|
486
|
-
return props.theme.palette.white;
|
|
487
|
-
}, function (props) {
|
|
488
|
-
return props.theme.shadows.lg("".concat(props.theme.space.base, "px"), "".concat(props.theme.space.base * 2, "px"), getColor('neutralHue', 800, props.theme, 0.24));
|
|
489
|
-
}, function (props) {
|
|
490
|
-
return sizeStyles$1(props.theme);
|
|
491
|
-
}, function (props) {
|
|
492
|
-
return retrieveComponentStyles(COMPONENT_ID$f, props);
|
|
493
|
-
});
|
|
405
|
+
})(["position:absolute;border:solid ", ";border-radius:50%;box-shadow:", ";", ";", ";"], props => props.theme.palette.white, props => props.theme.shadows.lg(`${props.theme.space.base}px`, `${props.theme.space.base * 2}px`, getColor('neutralHue', 800, props.theme, 0.24)), props => sizeStyles$1(props.theme), props => retrieveComponentStyles(COMPONENT_ID$f, props));
|
|
494
406
|
StyledColorWellThumb.defaultProps = {
|
|
495
407
|
theme: DEFAULT_THEME
|
|
496
408
|
};
|
|
497
409
|
|
|
498
|
-
|
|
499
|
-
|
|
410
|
+
const COMPONENT_ID$e = 'colorpickers.colorpicker_slider_group';
|
|
411
|
+
const StyledSliderGroup = styled.div.attrs({
|
|
500
412
|
'data-garden-id': COMPONENT_ID$e,
|
|
501
|
-
'data-garden-version': '8.
|
|
413
|
+
'data-garden-version': '8.59.0'
|
|
502
414
|
}).withConfig({
|
|
503
415
|
displayName: "StyledSliderGroup",
|
|
504
416
|
componentId: "sc-rsq0ak-0"
|
|
505
|
-
})(["display:flex;justify-content:space-between;margin-bottom:", "px;", ";"],
|
|
506
|
-
return props.theme.space.base * 2;
|
|
507
|
-
}, function (props) {
|
|
508
|
-
return retrieveComponentStyles(COMPONENT_ID$e, props);
|
|
509
|
-
});
|
|
417
|
+
})(["display:flex;justify-content:space-between;margin-bottom:", "px;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$e, props));
|
|
510
418
|
StyledSliderGroup.defaultProps = {
|
|
511
419
|
theme: DEFAULT_THEME
|
|
512
420
|
};
|
|
513
421
|
|
|
514
|
-
|
|
515
|
-
|
|
422
|
+
const COMPONENT_ID$d = 'colorpickers.colorpicker_hex_field';
|
|
423
|
+
const StyledHexField = styled(Field).attrs({
|
|
516
424
|
'data-garden-id': COMPONENT_ID$d,
|
|
517
|
-
'data-garden-version': '8.
|
|
425
|
+
'data-garden-version': '8.59.0',
|
|
518
426
|
spellcheck: false
|
|
519
427
|
}).withConfig({
|
|
520
428
|
displayName: "StyledHexField",
|
|
521
429
|
componentId: "sc-1lk14t4-0"
|
|
522
|
-
})(["display:flex;flex-basis:0;flex-direction:column;flex-grow:1;width:auto;text-align:center;input{direction:ltr;}", ";"],
|
|
523
|
-
return retrieveComponentStyles(COMPONENT_ID$d, props);
|
|
524
|
-
});
|
|
430
|
+
})(["display:flex;flex-basis:0;flex-direction:column;flex-grow:1;width:auto;text-align:center;input{direction:ltr;}", ";"], props => retrieveComponentStyles(COMPONENT_ID$d, props));
|
|
525
431
|
StyledHexField.defaultProps = {
|
|
526
432
|
theme: DEFAULT_THEME
|
|
527
433
|
};
|
|
528
434
|
|
|
529
|
-
|
|
530
|
-
|
|
435
|
+
const COMPONENT_ID$c = 'colorpickers.colorpicker_label';
|
|
436
|
+
const StyledLabel = styled(Label).attrs({
|
|
531
437
|
'data-garden-id': COMPONENT_ID$c,
|
|
532
|
-
'data-garden-version': '8.
|
|
438
|
+
'data-garden-version': '8.59.0'
|
|
533
439
|
}).withConfig({
|
|
534
440
|
displayName: "StyledLabel",
|
|
535
441
|
componentId: "sc-1klhp6m-0"
|
|
536
|
-
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"],
|
|
537
|
-
return retrieveComponentStyles(COMPONENT_ID$c, props);
|
|
538
|
-
});
|
|
442
|
+
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID$c, props));
|
|
539
443
|
StyledLabel.defaultProps = {
|
|
540
444
|
theme: DEFAULT_THEME
|
|
541
445
|
};
|
|
542
446
|
|
|
543
|
-
|
|
544
|
-
|
|
447
|
+
const COMPONENT_ID$b = 'colorpickers.colorpicker_input';
|
|
448
|
+
const StyledInput = styled(Input).attrs({
|
|
545
449
|
'data-garden-id': COMPONENT_ID$b,
|
|
546
|
-
'data-garden-version': '8.
|
|
450
|
+
'data-garden-version': '8.59.0',
|
|
547
451
|
focusInset: false
|
|
548
452
|
}).withConfig({
|
|
549
453
|
displayName: "StyledInput",
|
|
550
454
|
componentId: "sc-1iap93p-0"
|
|
551
|
-
})(["text-align:center;", ";"],
|
|
552
|
-
return retrieveComponentStyles(COMPONENT_ID$b, props);
|
|
553
|
-
});
|
|
455
|
+
})(["text-align:center;", ";"], props => retrieveComponentStyles(COMPONENT_ID$b, props));
|
|
554
456
|
StyledInput.defaultProps = {
|
|
555
457
|
theme: DEFAULT_THEME
|
|
556
458
|
};
|
|
557
459
|
|
|
558
|
-
|
|
559
|
-
|
|
460
|
+
const COMPONENT_ID$a = 'colorpickers.colorpicker_input_group';
|
|
461
|
+
const StyledInputGroup = styled.div.attrs({
|
|
560
462
|
'data-garden-id': COMPONENT_ID$a,
|
|
561
|
-
'data-garden-version': '8.
|
|
463
|
+
'data-garden-version': '8.59.0'
|
|
562
464
|
}).withConfig({
|
|
563
465
|
displayName: "StyledInputGroup",
|
|
564
466
|
componentId: "sc-mmy93w-0"
|
|
565
|
-
})(["display:flex;justify-content:space-between;", ";"],
|
|
566
|
-
return retrieveComponentStyles(COMPONENT_ID$a, props);
|
|
567
|
-
});
|
|
467
|
+
})(["display:flex;justify-content:space-between;", ";"], props => retrieveComponentStyles(COMPONENT_ID$a, props));
|
|
568
468
|
StyledInputGroup.defaultProps = {
|
|
569
469
|
theme: DEFAULT_THEME
|
|
570
470
|
};
|
|
571
471
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
return
|
|
472
|
+
const COMPONENT_ID$9 = 'colorpickers.colorpicker_rgb_field';
|
|
473
|
+
const sizeStyles = theme => {
|
|
474
|
+
const margin = `${theme.space.base * 1.5}px`;
|
|
475
|
+
const width = `${theme.space.base * 12.75}px`;
|
|
476
|
+
return `
|
|
477
|
+
margin-${theme.rtl ? 'right' : 'left'}: ${margin};
|
|
478
|
+
width: ${width};
|
|
479
|
+
min-width: ${width};
|
|
480
|
+
`;
|
|
577
481
|
};
|
|
578
|
-
|
|
482
|
+
const StyledRGBAField = styled(Field).attrs({
|
|
579
483
|
'data-garden-id': COMPONENT_ID$9,
|
|
580
|
-
'data-garden-version': '8.
|
|
484
|
+
'data-garden-version': '8.59.0'
|
|
581
485
|
}).withConfig({
|
|
582
486
|
displayName: "StyledRGBAField",
|
|
583
487
|
componentId: "sc-ibo1yw-0"
|
|
584
|
-
})(["display:flex;flex-direction:column;text-align:center;", ";", ";"],
|
|
585
|
-
return sizeStyles(props.theme);
|
|
586
|
-
}, function (props) {
|
|
587
|
-
return retrieveComponentStyles(COMPONENT_ID$9, props);
|
|
588
|
-
});
|
|
488
|
+
})(["display:flex;flex-direction:column;text-align:center;", ";", ";"], props => sizeStyles(props.theme), props => retrieveComponentStyles(COMPONENT_ID$9, props));
|
|
589
489
|
StyledRGBAField.defaultProps = {
|
|
590
490
|
theme: DEFAULT_THEME
|
|
591
491
|
};
|
|
592
492
|
|
|
593
|
-
|
|
594
|
-
|
|
493
|
+
const COMPONENT_ID$8 = 'colorpickers.colorpicker_sliders';
|
|
494
|
+
const StyledSliders = styled.div.attrs({
|
|
595
495
|
'data-garden-id': COMPONENT_ID$8,
|
|
596
|
-
'data-garden-version': '8.
|
|
496
|
+
'data-garden-version': '8.59.0'
|
|
597
497
|
}).withConfig({
|
|
598
498
|
displayName: "StyledSliders",
|
|
599
499
|
componentId: "sc-aclca2-0"
|
|
600
|
-
})(["position:relative;margin-", ":", "px;width:100%;& > *{position:absolute;width:100%;height:", "px;}& > :first-child{top:-", "px;}& > :last-child{bottom:-", "px;}", ";"],
|
|
601
|
-
return props.theme.rtl ? 'right' : 'left';
|
|
602
|
-
}, function (props) {
|
|
603
|
-
return props.theme.space.base * 2;
|
|
604
|
-
}, function (props) {
|
|
605
|
-
return getTrackMargin(props) * 2 + getTrackHeight(props);
|
|
606
|
-
}, getTrackMargin, getTrackMargin, function (props) {
|
|
607
|
-
return retrieveComponentStyles(COMPONENT_ID$8, props);
|
|
608
|
-
});
|
|
500
|
+
})(["position:relative;margin-", ":", "px;width:100%;& > *{position:absolute;width:100%;height:", "px;}& > :first-child{top:-", "px;}& > :last-child{bottom:-", "px;}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 2, props => getTrackMargin(props) * 2 + getTrackHeight(props), getTrackMargin, getTrackMargin, props => retrieveComponentStyles(COMPONENT_ID$8, props));
|
|
609
501
|
StyledSliders.defaultProps = {
|
|
610
502
|
theme: DEFAULT_THEME
|
|
611
503
|
};
|
|
612
504
|
|
|
613
|
-
|
|
614
|
-
|
|
505
|
+
const COMPONENT_ID$7 = 'colorpickers.colordialog_button';
|
|
506
|
+
const StyledButton = styled(Button).attrs({
|
|
615
507
|
isNeutral: true,
|
|
616
508
|
'data-garden-id': COMPONENT_ID$7,
|
|
617
|
-
'data-garden-version': '8.
|
|
509
|
+
'data-garden-version': '8.59.0'
|
|
618
510
|
}).withConfig({
|
|
619
511
|
displayName: "StyledButton",
|
|
620
512
|
componentId: "sc-101xjve-0"
|
|
621
|
-
})(["padding:0;width:", "px;max-width:", "px;&:last-of-type:not(:first-child){border-top-", "-radius:", " !important;border-bottom-", "-radius:", " !important;}", ";"],
|
|
622
|
-
return props.theme.space.base * 17;
|
|
623
|
-
}, function (props) {
|
|
624
|
-
return props.theme.space.base * 17;
|
|
625
|
-
}, function (props) {
|
|
626
|
-
return props.theme.rtl ? 'left' : 'right';
|
|
627
|
-
}, function (props) {
|
|
628
|
-
return props.theme.borderRadii.md;
|
|
629
|
-
}, function (props) {
|
|
630
|
-
return props.theme.rtl ? 'left' : 'right';
|
|
631
|
-
}, function (props) {
|
|
632
|
-
return props.theme.borderRadii.md;
|
|
633
|
-
}, function (props) {
|
|
634
|
-
return retrieveComponentStyles(COMPONENT_ID$7, props);
|
|
635
|
-
});
|
|
513
|
+
})(["padding:0;width:", "px;max-width:", "px;&:last-of-type:not(:first-child){border-top-", "-radius:", " !important;border-bottom-", "-radius:", " !important;}", ";"], props => props.theme.space.base * 17, props => props.theme.space.base * 17, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => retrieveComponentStyles(COMPONENT_ID$7, props));
|
|
636
514
|
StyledButton.defaultProps = {
|
|
637
515
|
theme: DEFAULT_THEME
|
|
638
516
|
};
|
|
639
517
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
518
|
+
const COMPONENT_ID$6 = 'colorpickers.colordialog_preview';
|
|
519
|
+
const background = props => {
|
|
520
|
+
const {
|
|
521
|
+
backgroundColor
|
|
522
|
+
} = props;
|
|
523
|
+
let color;
|
|
644
524
|
if (typeof backgroundColor === 'string') {
|
|
645
525
|
color = backgroundColor;
|
|
646
526
|
} else if (backgroundColor === undefined) {
|
|
647
527
|
color = props.theme.palette.white;
|
|
648
528
|
} else {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
529
|
+
const {
|
|
530
|
+
red,
|
|
531
|
+
green,
|
|
532
|
+
blue,
|
|
533
|
+
alpha = 1
|
|
534
|
+
} = backgroundColor;
|
|
535
|
+
color = `rgba(${red}, ${green}, ${blue}, ${alpha ? alpha / 100 : 0})`;
|
|
655
536
|
}
|
|
656
|
-
return
|
|
537
|
+
return `linear-gradient(${color}, ${color})`;
|
|
657
538
|
};
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
};
|
|
667
|
-
}).withConfig({
|
|
539
|
+
const StyledButtonPreview = styled.span.attrs(props => ({
|
|
540
|
+
style: {
|
|
541
|
+
background: `${background(props)}, ${checkeredBackground(props.theme, 8)}`
|
|
542
|
+
},
|
|
543
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
544
|
+
'data-garden-version': '8.59.0',
|
|
545
|
+
'data-test-id': 'dialog-preview'
|
|
546
|
+
})).withConfig({
|
|
668
547
|
displayName: "StyledButtonPreview",
|
|
669
548
|
componentId: "sc-1jzysg3-0"
|
|
670
|
-
})(["display:inline-block;bottom:", "px;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"],
|
|
671
|
-
return props.theme.space.base;
|
|
672
|
-
}, function (props) {
|
|
673
|
-
return props.theme.borderRadii.sm;
|
|
674
|
-
}, function (props) {
|
|
675
|
-
return props.theme.borderWidths.sm;
|
|
676
|
-
}, function (props) {
|
|
677
|
-
return rgba(props.theme.palette.black, 0.19);
|
|
678
|
-
}, function (props) {
|
|
679
|
-
return props.theme.space.base * 5;
|
|
680
|
-
}, function (props) {
|
|
681
|
-
return props.theme.space.base * 5;
|
|
682
|
-
}, function (props) {
|
|
683
|
-
return retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
684
|
-
});
|
|
549
|
+
})(["display:inline-block;bottom:", "px;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.space.base, props => props.theme.borderRadii.sm, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * 5, props => props.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
685
550
|
StyledButtonPreview.defaultProps = {
|
|
686
551
|
theme: DEFAULT_THEME
|
|
687
552
|
};
|
|
688
553
|
|
|
689
|
-
|
|
690
|
-
|
|
554
|
+
const COMPONENT_ID$5 = 'colorpickers.colordialog_tooltipmodal';
|
|
555
|
+
const StyledTooltipModal = styled(TooltipModal).attrs({
|
|
691
556
|
'data-garden-id': COMPONENT_ID$5,
|
|
692
|
-
'data-garden-version': '8.
|
|
557
|
+
'data-garden-version': '8.59.0'
|
|
693
558
|
}).withConfig({
|
|
694
559
|
displayName: "StyledTooltipModal",
|
|
695
560
|
componentId: "sc-o022s8-0"
|
|
696
|
-
})(["width:auto !important;", ";"],
|
|
697
|
-
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
698
|
-
});
|
|
561
|
+
})(["width:auto !important;", ";"], props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
699
562
|
StyledTooltipModal.defaultProps = {
|
|
700
563
|
theme: DEFAULT_THEME
|
|
701
564
|
};
|
|
702
565
|
|
|
703
|
-
|
|
704
|
-
|
|
566
|
+
const COMPONENT_ID$4 = 'colorpickers.colordialog_tooltipmodal_body';
|
|
567
|
+
const StyledTooltipBody = styled(TooltipModal.Body).attrs({
|
|
705
568
|
'data-garden-id': COMPONENT_ID$4,
|
|
706
|
-
'data-garden-version': '8.
|
|
569
|
+
'data-garden-version': '8.59.0'
|
|
707
570
|
}).withConfig({
|
|
708
571
|
displayName: "StyledTooltipBody",
|
|
709
572
|
componentId: "sc-6gsgsy-0"
|
|
710
|
-
})(["padding:0;", ";"],
|
|
711
|
-
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
712
|
-
});
|
|
573
|
+
})(["padding:0;", ";"], props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
713
574
|
StyledTooltipBody.defaultProps = {
|
|
714
575
|
theme: DEFAULT_THEME
|
|
715
576
|
};
|
|
716
577
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
};
|
|
725
|
-
}).withConfig({
|
|
578
|
+
const COMPONENT_ID$3 = 'colorpickers.swatch_button';
|
|
579
|
+
const StyledSwatchButton = styled(StyledButtonPreview).attrs(props => ({
|
|
580
|
+
as: 'button',
|
|
581
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
582
|
+
'data-test-id': props.backgroundColor,
|
|
583
|
+
'data-garden-version': '8.59.0'
|
|
584
|
+
})).withConfig({
|
|
726
585
|
displayName: "StyledSwatchButton",
|
|
727
586
|
componentId: "sc-edpwpp-0"
|
|
728
|
-
})(["outline:none;border:none;border-radius:", ";cursor:pointer;padding:0;&[data-garden-focus-visible]{box-shadow:", ";}", ";"],
|
|
729
|
-
return props.theme.borderRadii.md;
|
|
730
|
-
}, function (props) {
|
|
731
|
-
return props.theme.shadows.md(getColor('primaryHue', 600, props.theme, 0.35));
|
|
732
|
-
}, function (props) {
|
|
733
|
-
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
734
|
-
});
|
|
587
|
+
})(["outline:none;border:none;border-radius:", ";cursor:pointer;padding:0;&[data-garden-focus-visible]{box-shadow:", ";}", ";"], props => props.theme.borderRadii.md, props => props.theme.shadows.md(getColor('primaryHue', 600, props.theme, 0.35)), props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
735
588
|
StyledSwatchButton.defaultProps = {
|
|
736
589
|
theme: DEFAULT_THEME
|
|
737
590
|
};
|
|
738
591
|
|
|
739
|
-
|
|
740
|
-
|
|
592
|
+
const COMPONENT_ID$2 = 'colorpickers.color_swatch';
|
|
593
|
+
const StyledColorSwatch = styled.table.attrs({
|
|
741
594
|
'data-garden-id': COMPONENT_ID$2,
|
|
742
|
-
'data-garden-version': '8.
|
|
595
|
+
'data-garden-version': '8.59.0',
|
|
743
596
|
role: 'grid'
|
|
744
597
|
}).withConfig({
|
|
745
598
|
displayName: "StyledColorSwatch",
|
|
746
599
|
componentId: "sc-ajx440-0"
|
|
747
|
-
})(["border-collapse:collapse;line-height:normal;", ";"],
|
|
748
|
-
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
749
|
-
});
|
|
600
|
+
})(["border-collapse:collapse;line-height:normal;", ";"], props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
750
601
|
StyledColorSwatch.defaultProps = {
|
|
751
602
|
theme: DEFAULT_THEME
|
|
752
603
|
};
|
|
753
604
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
605
|
+
const COMPONENT_ID$1 = 'colorpickers.colorswatch_check';
|
|
606
|
+
const colorStyles = props => {
|
|
607
|
+
const {
|
|
608
|
+
theme,
|
|
609
|
+
color
|
|
610
|
+
} = props;
|
|
611
|
+
const {
|
|
612
|
+
alpha
|
|
613
|
+
} = parseToRgb(color);
|
|
614
|
+
let checkColor = readableColor(color, theme.colors.foreground, theme.colors.background);
|
|
762
615
|
if (alpha !== undefined && alpha < 0.4) {
|
|
763
616
|
checkColor = theme.colors.foreground;
|
|
764
617
|
}
|
|
765
|
-
return
|
|
618
|
+
return `
|
|
619
|
+
color: ${checkColor}
|
|
620
|
+
`;
|
|
766
621
|
};
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
622
|
+
const StyledIcon = styled(_ref => {
|
|
623
|
+
let {
|
|
624
|
+
children,
|
|
625
|
+
color,
|
|
626
|
+
theme,
|
|
627
|
+
...props
|
|
628
|
+
} = _ref;
|
|
772
629
|
return React__default.cloneElement(Children.only(children), props);
|
|
773
630
|
}).attrs({
|
|
774
631
|
'data-garden-id': COMPONENT_ID$1,
|
|
775
|
-
'data-garden-version': '8.
|
|
632
|
+
'data-garden-version': '8.59.0'
|
|
776
633
|
}).withConfig({
|
|
777
634
|
displayName: "StyledIcon",
|
|
778
635
|
componentId: "sc-8oigif-0"
|
|
779
|
-
})(["transition:opacity 0.2s ease-in-out;opacity:", ";width:", "px;height:", "px;", " ", ";"],
|
|
780
|
-
return props.selected ? 1 : 0;
|
|
781
|
-
}, function (props) {
|
|
782
|
-
return props.theme.space.base * 5;
|
|
783
|
-
}, function (props) {
|
|
784
|
-
return props.theme.space.base * 5;
|
|
785
|
-
}, colorStyles, function (props) {
|
|
786
|
-
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
787
|
-
});
|
|
636
|
+
})(["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$1, props));
|
|
788
637
|
StyledIcon.defaultProps = {
|
|
789
638
|
theme: DEFAULT_THEME
|
|
790
639
|
};
|
|
791
640
|
|
|
792
|
-
|
|
793
|
-
|
|
641
|
+
const COMPONENT_ID = 'colorpickers.swatch_cell';
|
|
642
|
+
const StyledCell = styled.td.attrs({
|
|
794
643
|
'data-garden-id': COMPONENT_ID,
|
|
795
|
-
'data-garden-version': '8.
|
|
644
|
+
'data-garden-version': '8.59.0'
|
|
796
645
|
}).withConfig({
|
|
797
646
|
displayName: "StyledCell",
|
|
798
647
|
componentId: "sc-qr3oit-0"
|
|
799
|
-
})(["padding:", "px;font-size:0;", ";"],
|
|
800
|
-
return props.theme.space.base;
|
|
801
|
-
}, function (props) {
|
|
802
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
803
|
-
});
|
|
648
|
+
})(["padding:", "px;font-size:0;", ";"], props => props.theme.space.base, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
804
649
|
StyledCell.defaultProps = {
|
|
805
650
|
theme: DEFAULT_THEME
|
|
806
651
|
};
|
|
807
652
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
831
|
-
topPosition = _useState6[0],
|
|
832
|
-
setTopPosition = _useState6[1];
|
|
833
|
-
var _useState7 = useState(0),
|
|
834
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
835
|
-
leftPosition = _useState8[0],
|
|
836
|
-
setLeftPosition = _useState8[1];
|
|
837
|
-
useEffect(function () {
|
|
653
|
+
const ColorWell = React__default.memo(_ref => {
|
|
654
|
+
let {
|
|
655
|
+
hue,
|
|
656
|
+
saturation,
|
|
657
|
+
lightness,
|
|
658
|
+
onChange
|
|
659
|
+
} = _ref;
|
|
660
|
+
const {
|
|
661
|
+
rtl
|
|
662
|
+
} = useContext(ThemeContext);
|
|
663
|
+
const containerRef = useRef(null);
|
|
664
|
+
const hsv = hslToHsv(hue, saturation, lightness);
|
|
665
|
+
const mouseActiveRef = useRef(false);
|
|
666
|
+
const [x, setX] = useState(0);
|
|
667
|
+
const [y, setY] = useState(0);
|
|
668
|
+
const {
|
|
669
|
+
topFromMouse,
|
|
670
|
+
leftFromMouse
|
|
671
|
+
} = getThumbPosition(x, y, rtl, containerRef);
|
|
672
|
+
const [topPosition, setTopPosition] = useState(0);
|
|
673
|
+
const [leftPosition, setLeftPosition] = useState(0);
|
|
674
|
+
useEffect(() => {
|
|
838
675
|
setTopPosition(100 - hsv.v);
|
|
839
676
|
setLeftPosition(rtl ? 100 - hsv.s : hsv.s);
|
|
840
677
|
}, [hsv.s, hsv.v, rtl]);
|
|
841
|
-
|
|
842
|
-
return throttle(
|
|
678
|
+
const throttledChange = useMemo(() => {
|
|
679
|
+
return throttle(e => {
|
|
843
680
|
if (containerRef.current) {
|
|
844
|
-
|
|
681
|
+
const nextHsv = getNextHsv(e, hue, containerRef.current, rtl);
|
|
845
682
|
onChange && onChange(nextHsv, e);
|
|
846
683
|
}
|
|
847
684
|
}, 50);
|
|
848
685
|
}, [hue, rtl, onChange]);
|
|
849
|
-
|
|
686
|
+
const handleMouseMove = useCallback(e => {
|
|
850
687
|
mouseActiveRef.current = true;
|
|
851
688
|
setX(e.pageX);
|
|
852
689
|
setY(e.pageY);
|
|
853
690
|
throttledChange(e);
|
|
854
691
|
}, [throttledChange]);
|
|
855
|
-
|
|
692
|
+
const handleMouseUp = useCallback(() => {
|
|
856
693
|
mouseActiveRef.current = true;
|
|
857
|
-
setTimeout(
|
|
694
|
+
setTimeout(() => {
|
|
858
695
|
mouseActiveRef.current = false;
|
|
859
696
|
});
|
|
860
697
|
throttledChange.cancel();
|
|
861
698
|
window.removeEventListener('mousemove', handleMouseMove);
|
|
862
699
|
window.removeEventListener('mouseup', handleMouseUp);
|
|
863
700
|
}, [throttledChange, handleMouseMove]);
|
|
864
|
-
|
|
701
|
+
const handleMouseDown = useCallback(e => {
|
|
865
702
|
mouseActiveRef.current = true;
|
|
866
703
|
e.persist();
|
|
867
704
|
handleMouseMove(e);
|
|
@@ -869,8 +706,8 @@ var ColorWell = React__default.memo(function (_ref) {
|
|
|
869
706
|
window.addEventListener('mousemove', handleMouseMove);
|
|
870
707
|
window.addEventListener('mouseup', handleMouseUp);
|
|
871
708
|
}, [throttledChange, handleMouseMove, handleMouseUp]);
|
|
872
|
-
useEffect(
|
|
873
|
-
return
|
|
709
|
+
useEffect(() => {
|
|
710
|
+
return () => {
|
|
874
711
|
throttledChange.cancel();
|
|
875
712
|
};
|
|
876
713
|
}, [throttledChange]);
|
|
@@ -886,8 +723,8 @@ var ColorWell = React__default.memo(function (_ref) {
|
|
|
886
723
|
});
|
|
887
724
|
ColorWell.displayName = 'ColorWell';
|
|
888
725
|
|
|
889
|
-
|
|
890
|
-
|
|
726
|
+
const isValidHex = hexString => {
|
|
727
|
+
const regEx = /^#(?:(?:[0-9A-F]{6}(?:[0-9A-F]{2})?)|(?:[0-9A-F]{3})(?:[0-9A-F]?))$/iu;
|
|
891
728
|
return regEx.test(hexString);
|
|
892
729
|
};
|
|
893
730
|
|
|
@@ -895,45 +732,47 @@ function convertStringToColor(colorString) {
|
|
|
895
732
|
if (colorString.includes('#') && !isValidHex(colorString)) {
|
|
896
733
|
return undefined;
|
|
897
734
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
735
|
+
const {
|
|
736
|
+
hue,
|
|
737
|
+
saturation,
|
|
738
|
+
lightness
|
|
739
|
+
} = parseToHsl(colorString);
|
|
740
|
+
const {
|
|
741
|
+
red,
|
|
742
|
+
green,
|
|
743
|
+
blue,
|
|
744
|
+
alpha
|
|
745
|
+
} = parseToRgb(colorString);
|
|
746
|
+
const computedAlpha = alpha === undefined ? 100 : alpha * 100;
|
|
747
|
+
const computedHex = rgb({
|
|
748
|
+
red,
|
|
749
|
+
green,
|
|
750
|
+
blue
|
|
912
751
|
});
|
|
913
752
|
return {
|
|
914
|
-
hue
|
|
753
|
+
hue,
|
|
915
754
|
saturation: saturation * 100,
|
|
916
755
|
lightness: lightness * 100,
|
|
917
|
-
red
|
|
918
|
-
green
|
|
919
|
-
blue
|
|
756
|
+
red,
|
|
757
|
+
green,
|
|
758
|
+
blue,
|
|
920
759
|
alpha: computedAlpha,
|
|
921
760
|
hex: computedHex
|
|
922
761
|
};
|
|
923
762
|
}
|
|
924
|
-
|
|
763
|
+
const areColorsEqual = (a, b) => {
|
|
925
764
|
if (a === undefined || b === undefined) {
|
|
926
765
|
return false;
|
|
927
766
|
}
|
|
928
|
-
|
|
929
|
-
|
|
767
|
+
const colorA = typeof a === 'string' ? convertStringToColor(a) : a;
|
|
768
|
+
const colorB = typeof b === 'string' ? convertStringToColor(b) : b;
|
|
930
769
|
if (colorA === undefined || colorB === undefined) {
|
|
931
770
|
return false;
|
|
932
771
|
}
|
|
933
772
|
return isEqual(colorA, colorB);
|
|
934
773
|
};
|
|
935
774
|
function getInitialState(color) {
|
|
936
|
-
|
|
775
|
+
const whiteColor = {
|
|
937
776
|
hue: 0,
|
|
938
777
|
saturation: 0,
|
|
939
778
|
lightness: 0,
|
|
@@ -947,11 +786,11 @@ function getInitialState(color) {
|
|
|
947
786
|
return getInitialState(whiteColor);
|
|
948
787
|
}
|
|
949
788
|
if (typeof color === 'string') {
|
|
950
|
-
|
|
789
|
+
const computedColor = convertStringToColor(color);
|
|
951
790
|
return getInitialState(computedColor || whiteColor);
|
|
952
791
|
}
|
|
953
792
|
return {
|
|
954
|
-
color
|
|
793
|
+
color,
|
|
955
794
|
hexInput: color.hex,
|
|
956
795
|
redInput: color.red.toString(),
|
|
957
796
|
blueInput: color.blue.toString(),
|
|
@@ -959,80 +798,88 @@ function getInitialState(color) {
|
|
|
959
798
|
alphaInput: color.alpha.toString()
|
|
960
799
|
};
|
|
961
800
|
}
|
|
962
|
-
|
|
801
|
+
const reducer = (state, action) => {
|
|
963
802
|
switch (action.type) {
|
|
964
803
|
case 'SATURATION_CHANGE':
|
|
965
804
|
{
|
|
966
|
-
|
|
967
|
-
|
|
805
|
+
const hsl$1 = hsvToHsl(action.payload.h, action.payload.s * 100, action.payload.v * 100);
|
|
806
|
+
const hex = hsl({
|
|
968
807
|
hue: action.payload.h,
|
|
969
808
|
saturation: hsl$1.s / 100,
|
|
970
809
|
lightness: hsl$1.l / 100
|
|
971
810
|
});
|
|
972
|
-
|
|
973
|
-
return
|
|
974
|
-
|
|
811
|
+
const rgb = parseToRgb(hex);
|
|
812
|
+
return {
|
|
813
|
+
...state,
|
|
814
|
+
color: {
|
|
815
|
+
...state.color,
|
|
975
816
|
saturation: hsl$1.s,
|
|
976
817
|
lightness: hsl$1.l,
|
|
977
|
-
hex
|
|
978
|
-
red: rgb
|
|
979
|
-
green: rgb
|
|
980
|
-
blue: rgb
|
|
981
|
-
}
|
|
982
|
-
}
|
|
818
|
+
hex,
|
|
819
|
+
red: rgb.red,
|
|
820
|
+
green: rgb.green,
|
|
821
|
+
blue: rgb.blue
|
|
822
|
+
}
|
|
823
|
+
};
|
|
983
824
|
}
|
|
984
825
|
case 'HUE_CHANGE':
|
|
985
826
|
{
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
hue
|
|
827
|
+
const hue = Number(action.payload);
|
|
828
|
+
const hex = hsl({
|
|
829
|
+
hue,
|
|
989
830
|
saturation: state.color.saturation / 100,
|
|
990
831
|
lightness: state.color.lightness / 100
|
|
991
832
|
});
|
|
992
|
-
|
|
993
|
-
return
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
833
|
+
const rgb = parseToRgb(hex);
|
|
834
|
+
return {
|
|
835
|
+
...state,
|
|
836
|
+
color: {
|
|
837
|
+
...state.color,
|
|
838
|
+
hue,
|
|
839
|
+
hex,
|
|
840
|
+
red: rgb.red,
|
|
841
|
+
green: rgb.green,
|
|
842
|
+
blue: rgb.blue
|
|
843
|
+
}
|
|
844
|
+
};
|
|
1002
845
|
}
|
|
1003
846
|
case 'ALPHA_SLIDER_CHANGE':
|
|
1004
847
|
{
|
|
1005
|
-
return
|
|
1006
|
-
|
|
848
|
+
return {
|
|
849
|
+
...state,
|
|
850
|
+
color: {
|
|
851
|
+
...state.color,
|
|
1007
852
|
alpha: Math.round(Number(action.payload) * 100)
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
853
|
+
}
|
|
854
|
+
};
|
|
1010
855
|
}
|
|
1011
856
|
case 'HEX_CHANGE':
|
|
1012
857
|
{
|
|
1013
|
-
|
|
858
|
+
let color = state.color;
|
|
1014
859
|
if (isValidHex(action.payload)) {
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
color =
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
860
|
+
const rgb = parseToRgb(action.payload);
|
|
861
|
+
const hsl = parseToHsl(`rgb(${rgb.red}, ${rgb.green}, ${rgb.blue})`);
|
|
862
|
+
color = {
|
|
863
|
+
...color,
|
|
864
|
+
hue: hsl.hue,
|
|
865
|
+
saturation: hsl.saturation * 100,
|
|
866
|
+
lightness: hsl.lightness * 100,
|
|
1021
867
|
hex: action.payload,
|
|
1022
|
-
red:
|
|
1023
|
-
green:
|
|
1024
|
-
blue:
|
|
1025
|
-
}
|
|
868
|
+
red: rgb.red,
|
|
869
|
+
green: rgb.green,
|
|
870
|
+
blue: rgb.blue
|
|
871
|
+
};
|
|
1026
872
|
}
|
|
1027
|
-
return
|
|
873
|
+
return {
|
|
874
|
+
...state,
|
|
1028
875
|
hexInput: action.payload,
|
|
1029
|
-
color
|
|
1030
|
-
}
|
|
876
|
+
color
|
|
877
|
+
};
|
|
1031
878
|
}
|
|
1032
879
|
case 'RED_CHANGE':
|
|
1033
880
|
{
|
|
1034
|
-
|
|
1035
|
-
|
|
881
|
+
let red = parseInt(action.payload, 10);
|
|
882
|
+
let color = state.color;
|
|
1036
883
|
if (!isNaN(red)) {
|
|
1037
884
|
if (red >= 255) {
|
|
1038
885
|
red = 255;
|
|
@@ -1040,25 +887,27 @@ var reducer = function reducer(state, action) {
|
|
|
1040
887
|
if (red < 0) {
|
|
1041
888
|
red = 0;
|
|
1042
889
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
890
|
+
const hsl = parseToHsl(`rgb(${red}, ${color.green}, ${color.blue})`);
|
|
891
|
+
const hex = rgb(red, color.green, color.blue);
|
|
892
|
+
color = {
|
|
893
|
+
...color,
|
|
894
|
+
hex,
|
|
895
|
+
red: action.payload === '' ? color.red : red,
|
|
896
|
+
hue: hsl.hue,
|
|
897
|
+
saturation: hsl.saturation * 100,
|
|
898
|
+
lightness: hsl.lightness * 100
|
|
899
|
+
};
|
|
1052
900
|
}
|
|
1053
|
-
return
|
|
901
|
+
return {
|
|
902
|
+
...state,
|
|
1054
903
|
redInput: action.payload,
|
|
1055
|
-
color
|
|
1056
|
-
}
|
|
904
|
+
color
|
|
905
|
+
};
|
|
1057
906
|
}
|
|
1058
907
|
case 'GREEN_CHANGE':
|
|
1059
908
|
{
|
|
1060
|
-
|
|
1061
|
-
|
|
909
|
+
let green = parseInt(action.payload, 10);
|
|
910
|
+
let color = state.color;
|
|
1062
911
|
if (!isNaN(green)) {
|
|
1063
912
|
if (green >= 255) {
|
|
1064
913
|
green = 255;
|
|
@@ -1066,25 +915,27 @@ var reducer = function reducer(state, action) {
|
|
|
1066
915
|
if (green < 0) {
|
|
1067
916
|
green = 0;
|
|
1068
917
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
918
|
+
const hsl = parseToHsl(`rgb(${color.red}, ${green}, ${color.blue})`);
|
|
919
|
+
const hex = rgb(color.red, green, color.blue);
|
|
920
|
+
color = {
|
|
921
|
+
...color,
|
|
922
|
+
hex,
|
|
923
|
+
green: action.payload === '' ? color.green : green,
|
|
924
|
+
hue: hsl.hue,
|
|
925
|
+
saturation: hsl.saturation * 100,
|
|
926
|
+
lightness: hsl.lightness * 100
|
|
927
|
+
};
|
|
1078
928
|
}
|
|
1079
|
-
return
|
|
929
|
+
return {
|
|
930
|
+
...state,
|
|
1080
931
|
greenInput: action.payload,
|
|
1081
|
-
color
|
|
1082
|
-
}
|
|
932
|
+
color
|
|
933
|
+
};
|
|
1083
934
|
}
|
|
1084
935
|
case 'BLUE_CHANGE':
|
|
1085
936
|
{
|
|
1086
|
-
|
|
1087
|
-
|
|
937
|
+
let blue = parseInt(action.payload, 10);
|
|
938
|
+
let color = state.color;
|
|
1088
939
|
if (!isNaN(blue)) {
|
|
1089
940
|
if (blue >= 255) {
|
|
1090
941
|
blue = 255;
|
|
@@ -1092,25 +943,27 @@ var reducer = function reducer(state, action) {
|
|
|
1092
943
|
if (blue < 0) {
|
|
1093
944
|
blue = 0;
|
|
1094
945
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
946
|
+
const hsl = parseToHsl(`rgb(${color.red}, ${color.green}, ${blue})`);
|
|
947
|
+
const hex = rgb(color.red, color.green, blue);
|
|
948
|
+
color = {
|
|
949
|
+
...color,
|
|
950
|
+
hex,
|
|
951
|
+
blue: action.payload === '' ? color.blue : blue,
|
|
952
|
+
hue: hsl.hue,
|
|
953
|
+
saturation: hsl.saturation * 100,
|
|
954
|
+
lightness: hsl.lightness * 100
|
|
955
|
+
};
|
|
1104
956
|
}
|
|
1105
|
-
return
|
|
957
|
+
return {
|
|
958
|
+
...state,
|
|
1106
959
|
blueInput: action.payload,
|
|
1107
|
-
color
|
|
1108
|
-
}
|
|
960
|
+
color
|
|
961
|
+
};
|
|
1109
962
|
}
|
|
1110
963
|
case 'ALPHA_CHANGE':
|
|
1111
964
|
{
|
|
1112
|
-
|
|
1113
|
-
|
|
965
|
+
let alpha = parseInt(action.payload, 10);
|
|
966
|
+
let color = state.color;
|
|
1114
967
|
if (!isNaN(alpha)) {
|
|
1115
968
|
if (alpha > 100) {
|
|
1116
969
|
alpha = 100;
|
|
@@ -1118,14 +971,16 @@ var reducer = function reducer(state, action) {
|
|
|
1118
971
|
if (alpha < 0) {
|
|
1119
972
|
alpha = 0;
|
|
1120
973
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
974
|
+
color = {
|
|
975
|
+
...color,
|
|
976
|
+
alpha
|
|
977
|
+
};
|
|
1124
978
|
}
|
|
1125
|
-
return
|
|
979
|
+
return {
|
|
980
|
+
...state,
|
|
1126
981
|
alphaInput: action.payload,
|
|
1127
|
-
color
|
|
1128
|
-
}
|
|
982
|
+
color
|
|
983
|
+
};
|
|
1129
984
|
}
|
|
1130
985
|
case 'RESET_COLOR':
|
|
1131
986
|
{
|
|
@@ -1136,27 +991,24 @@ var reducer = function reducer(state, action) {
|
|
|
1136
991
|
}
|
|
1137
992
|
};
|
|
1138
993
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
var previousStateColorRef = useRef(state.color);
|
|
1155
|
-
var computedColor = useMemo(function () {
|
|
1156
|
-
var retVal = state.color;
|
|
994
|
+
const Colorpicker = forwardRef((_ref, ref) => {
|
|
995
|
+
let {
|
|
996
|
+
color,
|
|
997
|
+
defaultColor,
|
|
998
|
+
isOpaque,
|
|
999
|
+
labels = {},
|
|
1000
|
+
autofocus,
|
|
1001
|
+
onChange,
|
|
1002
|
+
...props
|
|
1003
|
+
} = _ref;
|
|
1004
|
+
const [state, dispatch] = useReducer(reducer, getInitialState(color || defaultColor));
|
|
1005
|
+
const previousComputedColorRef = useRef(state.color);
|
|
1006
|
+
const previousStateColorRef = useRef(state.color);
|
|
1007
|
+
const computedColor = useMemo(() => {
|
|
1008
|
+
let retVal = state.color;
|
|
1157
1009
|
if (color) {
|
|
1158
1010
|
if (typeof color === 'string') {
|
|
1159
|
-
|
|
1011
|
+
const convertedColor = convertStringToColor(color);
|
|
1160
1012
|
if (convertedColor) {
|
|
1161
1013
|
retVal = convertedColor;
|
|
1162
1014
|
}
|
|
@@ -1169,13 +1021,13 @@ var Colorpicker = forwardRef(function (_ref, ref) {
|
|
|
1169
1021
|
}
|
|
1170
1022
|
return retVal;
|
|
1171
1023
|
}, [color, isOpaque, state.color]);
|
|
1172
|
-
useEffect(
|
|
1024
|
+
useEffect(() => {
|
|
1173
1025
|
if (!areColorsEqual(previousStateColorRef.current, state.color) && !areColorsEqual(color, state.color)) {
|
|
1174
1026
|
onChange && onChange(state.color);
|
|
1175
1027
|
}
|
|
1176
1028
|
previousStateColorRef.current = state.color;
|
|
1177
1029
|
}, [color, onChange, state.color]);
|
|
1178
|
-
useEffect(
|
|
1030
|
+
useEffect(() => {
|
|
1179
1031
|
if (!areColorsEqual(computedColor, previousComputedColorRef.current)) {
|
|
1180
1032
|
dispatch({
|
|
1181
1033
|
type: 'RESET_COLOR',
|
|
@@ -1184,55 +1036,55 @@ var Colorpicker = forwardRef(function (_ref, ref) {
|
|
|
1184
1036
|
}
|
|
1185
1037
|
previousComputedColorRef.current = computedColor;
|
|
1186
1038
|
}, [computedColor]);
|
|
1187
|
-
|
|
1039
|
+
const handleColorWellChange = useCallback(hsv => {
|
|
1188
1040
|
dispatch({
|
|
1189
1041
|
type: 'SATURATION_CHANGE',
|
|
1190
1042
|
payload: hsv
|
|
1191
1043
|
});
|
|
1192
1044
|
}, []);
|
|
1193
|
-
|
|
1045
|
+
const handleHueChange = useCallback(e => {
|
|
1194
1046
|
dispatch({
|
|
1195
1047
|
type: 'HUE_CHANGE',
|
|
1196
1048
|
payload: e.target.value
|
|
1197
1049
|
});
|
|
1198
1050
|
}, []);
|
|
1199
|
-
|
|
1051
|
+
const handleAlphaSliderChange = useCallback(e => {
|
|
1200
1052
|
dispatch({
|
|
1201
1053
|
type: 'ALPHA_SLIDER_CHANGE',
|
|
1202
1054
|
payload: e.target.value
|
|
1203
1055
|
});
|
|
1204
1056
|
}, []);
|
|
1205
|
-
|
|
1057
|
+
const handleHexChange = useCallback(e => {
|
|
1206
1058
|
dispatch({
|
|
1207
1059
|
type: 'HEX_CHANGE',
|
|
1208
1060
|
payload: e.target.value
|
|
1209
1061
|
});
|
|
1210
1062
|
}, []);
|
|
1211
|
-
|
|
1063
|
+
const handleRedChange = useCallback(e => {
|
|
1212
1064
|
dispatch({
|
|
1213
1065
|
type: 'RED_CHANGE',
|
|
1214
1066
|
payload: e.target.value
|
|
1215
1067
|
});
|
|
1216
1068
|
}, []);
|
|
1217
|
-
|
|
1069
|
+
const handleGreenChange = useCallback(e => {
|
|
1218
1070
|
dispatch({
|
|
1219
1071
|
type: 'GREEN_CHANGE',
|
|
1220
1072
|
payload: e.target.value
|
|
1221
1073
|
});
|
|
1222
1074
|
}, []);
|
|
1223
|
-
|
|
1075
|
+
const handleBlueChange = useCallback(e => {
|
|
1224
1076
|
dispatch({
|
|
1225
1077
|
type: 'BLUE_CHANGE',
|
|
1226
1078
|
payload: e.target.value
|
|
1227
1079
|
});
|
|
1228
1080
|
}, []);
|
|
1229
|
-
|
|
1081
|
+
const handleAlphaChange = useCallback(e => {
|
|
1230
1082
|
dispatch({
|
|
1231
1083
|
type: 'ALPHA_CHANGE',
|
|
1232
1084
|
payload: e.target.value
|
|
1233
1085
|
});
|
|
1234
1086
|
}, []);
|
|
1235
|
-
|
|
1087
|
+
const handleBlur = useCallback(() => {
|
|
1236
1088
|
dispatch({
|
|
1237
1089
|
type: 'RESET_COLOR',
|
|
1238
1090
|
payload: computedColor
|
|
@@ -1351,65 +1203,61 @@ var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
|
1351
1203
|
height: 16,
|
|
1352
1204
|
focusable: "false",
|
|
1353
1205
|
viewBox: "0 0 16 16",
|
|
1354
|
-
"aria-hidden": "true"
|
|
1206
|
+
"aria-hidden": "true",
|
|
1207
|
+
role: "img"
|
|
1355
1208
|
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
1356
1209
|
fill: "currentColor",
|
|
1357
1210
|
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"
|
|
1358
1211
|
})));
|
|
1359
1212
|
};
|
|
1360
1213
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
var _useState3 = useState(defaultColor),
|
|
1390
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1391
|
-
uncontrolledColor = _useState4[0],
|
|
1392
|
-
setUncontrolledColor = _useState4[1];
|
|
1393
|
-
var openDialog = function openDialog() {
|
|
1214
|
+
const ColorpickerDialog = forwardRef((_ref, ref) => {
|
|
1215
|
+
let {
|
|
1216
|
+
color,
|
|
1217
|
+
defaultColor,
|
|
1218
|
+
placement,
|
|
1219
|
+
onChange,
|
|
1220
|
+
onClose,
|
|
1221
|
+
labels,
|
|
1222
|
+
hasArrow,
|
|
1223
|
+
isAnimated,
|
|
1224
|
+
isOpaque,
|
|
1225
|
+
isOpen,
|
|
1226
|
+
popperModifiers,
|
|
1227
|
+
zIndex,
|
|
1228
|
+
focusInset,
|
|
1229
|
+
disabled,
|
|
1230
|
+
buttonProps,
|
|
1231
|
+
onDialogChange,
|
|
1232
|
+
children,
|
|
1233
|
+
...props
|
|
1234
|
+
} = _ref;
|
|
1235
|
+
const isControlled = color !== null && color !== undefined;
|
|
1236
|
+
const isDialogControlled = isOpen !== undefined && isOpen !== null;
|
|
1237
|
+
const buttonRef = useRef(null);
|
|
1238
|
+
const colorPickerRef = useRef(null);
|
|
1239
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
1240
|
+
const [uncontrolledColor, setUncontrolledColor] = useState(defaultColor);
|
|
1241
|
+
const openDialog = () => {
|
|
1394
1242
|
setReferenceElement(buttonRef.current);
|
|
1395
1243
|
onDialogChange && onDialogChange({
|
|
1396
1244
|
isOpen: true
|
|
1397
1245
|
});
|
|
1398
1246
|
};
|
|
1399
|
-
|
|
1247
|
+
const closeDialog = () => {
|
|
1400
1248
|
setReferenceElement(null);
|
|
1401
1249
|
onDialogChange && onDialogChange({
|
|
1402
1250
|
isOpen: false
|
|
1403
1251
|
});
|
|
1404
1252
|
};
|
|
1405
|
-
|
|
1253
|
+
const onClick = composeEventHandlers(props.onClick, () => {
|
|
1406
1254
|
if (referenceElement) {
|
|
1407
1255
|
closeDialog();
|
|
1408
1256
|
} else {
|
|
1409
1257
|
openDialog();
|
|
1410
1258
|
}
|
|
1411
1259
|
});
|
|
1412
|
-
useEffect(
|
|
1260
|
+
useEffect(() => {
|
|
1413
1261
|
if (isDialogControlled) {
|
|
1414
1262
|
if (isOpen) {
|
|
1415
1263
|
setReferenceElement(buttonRef.current);
|
|
@@ -1419,7 +1267,7 @@ var ColorpickerDialog = forwardRef(function (_ref, ref) {
|
|
|
1419
1267
|
}
|
|
1420
1268
|
}, [isOpen, isDialogControlled]);
|
|
1421
1269
|
return React__default.createElement(React__default.Fragment, null, children ? cloneElement(Children.only(children), {
|
|
1422
|
-
onClick
|
|
1270
|
+
onClick,
|
|
1423
1271
|
ref: buttonRef
|
|
1424
1272
|
}) : React__default.createElement(StyledButton, _extends$2({
|
|
1425
1273
|
disabled: disabled,
|
|
@@ -1440,9 +1288,9 @@ var ColorpickerDialog = forwardRef(function (_ref, ref) {
|
|
|
1440
1288
|
focusOnMount: false,
|
|
1441
1289
|
placement: placement,
|
|
1442
1290
|
referenceElement: referenceElement,
|
|
1443
|
-
onClose:
|
|
1291
|
+
onClose: () => {
|
|
1444
1292
|
closeDialog();
|
|
1445
|
-
|
|
1293
|
+
onClose && onClose(isControlled ? color : uncontrolledColor);
|
|
1446
1294
|
}
|
|
1447
1295
|
}, props), React__default.createElement(StyledTooltipBody, null, React__default.createElement(Colorpicker, {
|
|
1448
1296
|
autofocus: true,
|
|
@@ -1454,7 +1302,8 @@ var ColorpickerDialog = forwardRef(function (_ref, ref) {
|
|
|
1454
1302
|
onChange: isControlled ? onChange : setUncontrolledColor
|
|
1455
1303
|
}))));
|
|
1456
1304
|
});
|
|
1457
|
-
ColorpickerDialog.propTypes =
|
|
1305
|
+
ColorpickerDialog.propTypes = {
|
|
1306
|
+
...Colorpicker.propTypes,
|
|
1458
1307
|
placement: PropTypes.oneOf(PLACEMENT),
|
|
1459
1308
|
onClose: PropTypes.func,
|
|
1460
1309
|
onDialogChange: PropTypes.func,
|
|
@@ -1467,7 +1316,7 @@ ColorpickerDialog.propTypes = _objectSpread2(_objectSpread2({}, Colorpicker.prop
|
|
|
1467
1316
|
isAnimated: PropTypes.bool,
|
|
1468
1317
|
isOpen: PropTypes.bool,
|
|
1469
1318
|
focusInset: PropTypes.bool
|
|
1470
|
-
}
|
|
1319
|
+
};
|
|
1471
1320
|
ColorpickerDialog.defaultProps = {
|
|
1472
1321
|
placement: 'bottom-start',
|
|
1473
1322
|
isAnimated: true,
|
|
@@ -1487,7 +1336,8 @@ var SvgCheckSmFill = function SvgCheckSmFill(props) {
|
|
|
1487
1336
|
height: 12,
|
|
1488
1337
|
focusable: "false",
|
|
1489
1338
|
viewBox: "0 0 12 12",
|
|
1490
|
-
"aria-hidden": "true"
|
|
1339
|
+
"aria-hidden": "true",
|
|
1340
|
+
role: "img"
|
|
1491
1341
|
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
1492
1342
|
fill: "none",
|
|
1493
1343
|
stroke: "currentColor",
|
|
@@ -1498,52 +1348,56 @@ var SvgCheckSmFill = function SvgCheckSmFill(props) {
|
|
|
1498
1348
|
})));
|
|
1499
1349
|
};
|
|
1500
1350
|
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1351
|
+
const ColorSwatch = forwardRef((_ref, ref) => {
|
|
1352
|
+
let {
|
|
1353
|
+
colors,
|
|
1354
|
+
...props
|
|
1355
|
+
} = _ref;
|
|
1356
|
+
const {
|
|
1357
|
+
rtl
|
|
1358
|
+
} = useContext(ThemeContext);
|
|
1359
|
+
const {
|
|
1360
|
+
getGridCellProps
|
|
1361
|
+
} = useGrid({
|
|
1362
|
+
rtl,
|
|
1510
1363
|
matrix: colors,
|
|
1511
1364
|
selection: true,
|
|
1512
1365
|
wrap: true,
|
|
1513
|
-
idPrefix: useId()
|
|
1514
|
-
|
|
1515
|
-
|
|
1366
|
+
idPrefix: useId(),
|
|
1367
|
+
...props
|
|
1368
|
+
});
|
|
1516
1369
|
return React__default.createElement(StyledColorSwatch, {
|
|
1517
1370
|
ref: ref
|
|
1518
|
-
}, React__default.createElement("tbody", null, colors.map(
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1371
|
+
}, React__default.createElement("tbody", null, colors.map((row, rowIdx) => React__default.createElement("tr", {
|
|
1372
|
+
key: row[0].value
|
|
1373
|
+
}, row.map((color, colIdx) => {
|
|
1374
|
+
const {
|
|
1375
|
+
label,
|
|
1376
|
+
value
|
|
1377
|
+
} = color;
|
|
1378
|
+
const {
|
|
1379
|
+
'aria-selected': ariaSelected,
|
|
1380
|
+
...other
|
|
1381
|
+
} = getGridCellProps({
|
|
1382
|
+
colIdx,
|
|
1383
|
+
rowIdx,
|
|
1384
|
+
type: 'button',
|
|
1385
|
+
role: undefined
|
|
1386
|
+
});
|
|
1387
|
+
return React__default.createElement(StyledCell, {
|
|
1388
|
+
key: value,
|
|
1389
|
+
"aria-selected": ariaSelected
|
|
1390
|
+
}, React__default.createElement(Tooltip, {
|
|
1391
|
+
content: label
|
|
1392
|
+
}, React__default.createElement(StyledSwatchButton, _extends$2({
|
|
1393
|
+
backgroundColor: value,
|
|
1394
|
+
"aria-pressed": ariaSelected,
|
|
1395
|
+
"aria-label": label
|
|
1396
|
+
}, other), React__default.createElement(StyledIcon, {
|
|
1397
|
+
color: value,
|
|
1398
|
+
selected: ariaSelected
|
|
1399
|
+
}, React__default.createElement(SvgCheckSmFill, null)))));
|
|
1400
|
+
})))));
|
|
1547
1401
|
});
|
|
1548
1402
|
ColorSwatch.displayName = 'ColorSwatch';
|
|
1549
1403
|
ColorSwatch.propTypes = {
|
|
@@ -1560,59 +1414,45 @@ ColorSwatch.propTypes = {
|
|
|
1560
1414
|
onSelect: PropTypes.func
|
|
1561
1415
|
};
|
|
1562
1416
|
|
|
1563
|
-
|
|
1564
|
-
var ColorSwatchDialog = forwardRef(function (_ref, ref) {
|
|
1417
|
+
const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
1565
1418
|
var _controlledSelectedCo, _uncontrolledSelected;
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
var _useState5 = useState(defaultSelectedColIndex || 0),
|
|
1604
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
1605
|
-
uncontrolledSelectedColIndex = _useState6[0],
|
|
1606
|
-
setUncontrolledSelectedColIndex = _useState6[1];
|
|
1607
|
-
var _useState7 = useState(defaultRowIndex || 0),
|
|
1608
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
1609
|
-
uncontrolledRowIndex = _useState8[0],
|
|
1610
|
-
setUncontrolledRowIndex = _useState8[1];
|
|
1611
|
-
var _useState9 = useState(defaultColIndex || 0),
|
|
1612
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
1613
|
-
uncontrolledColIndex = _useState10[0],
|
|
1614
|
-
setUncontrolledColIndex = _useState10[1];
|
|
1615
|
-
useEffect(function () {
|
|
1419
|
+
let {
|
|
1420
|
+
colors,
|
|
1421
|
+
rowIndex,
|
|
1422
|
+
colIndex,
|
|
1423
|
+
selectedRowIndex,
|
|
1424
|
+
selectedColIndex,
|
|
1425
|
+
defaultRowIndex,
|
|
1426
|
+
defaultColIndex,
|
|
1427
|
+
defaultSelectedRowIndex,
|
|
1428
|
+
defaultSelectedColIndex,
|
|
1429
|
+
placement,
|
|
1430
|
+
onChange,
|
|
1431
|
+
onSelect,
|
|
1432
|
+
hasArrow,
|
|
1433
|
+
isAnimated,
|
|
1434
|
+
popperModifiers,
|
|
1435
|
+
zIndex,
|
|
1436
|
+
isOpen,
|
|
1437
|
+
focusInset,
|
|
1438
|
+
disabled,
|
|
1439
|
+
buttonProps,
|
|
1440
|
+
onDialogChange,
|
|
1441
|
+
children,
|
|
1442
|
+
...props
|
|
1443
|
+
} = _ref;
|
|
1444
|
+
const controlledFocus = rowIndex !== null && colIndex !== null && rowIndex !== undefined && colIndex !== undefined;
|
|
1445
|
+
const controlledSelect = selectedRowIndex !== null && selectedColIndex !== null && selectedRowIndex !== undefined && selectedColIndex !== undefined;
|
|
1446
|
+
const isControlled = controlledFocus || controlledSelect;
|
|
1447
|
+
const isDialogControlled = isOpen !== undefined && isOpen !== null;
|
|
1448
|
+
const buttonRef = useRef(null);
|
|
1449
|
+
const colorSwatchRef = useRef(null);
|
|
1450
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
1451
|
+
const [uncontrolledSelectedRowIndex, setUncontrolledSelectedRowIndex] = useState(defaultSelectedRowIndex || 0);
|
|
1452
|
+
const [uncontrolledSelectedColIndex, setUncontrolledSelectedColIndex] = useState(defaultSelectedColIndex || 0);
|
|
1453
|
+
const [uncontrolledRowIndex, setUncontrolledRowIndex] = useState(defaultRowIndex || 0);
|
|
1454
|
+
const [uncontrolledColIndex, setUncontrolledColIndex] = useState(defaultColIndex || 0);
|
|
1455
|
+
useEffect(() => {
|
|
1616
1456
|
if (isDialogControlled) {
|
|
1617
1457
|
if (isOpen) {
|
|
1618
1458
|
setReferenceElement(buttonRef.current);
|
|
@@ -1621,21 +1461,21 @@ var ColorSwatchDialog = forwardRef(function (_ref, ref) {
|
|
|
1621
1461
|
}
|
|
1622
1462
|
}
|
|
1623
1463
|
}, [isOpen, isDialogControlled]);
|
|
1624
|
-
|
|
1625
|
-
|
|
1464
|
+
let uncontrolledSelectedColor;
|
|
1465
|
+
let controlledSelectedColor;
|
|
1626
1466
|
if (uncontrolledSelectedRowIndex > -1 && uncontrolledSelectedColIndex > -1) {
|
|
1627
1467
|
uncontrolledSelectedColor = colors[uncontrolledSelectedRowIndex][uncontrolledSelectedColIndex];
|
|
1628
1468
|
}
|
|
1629
1469
|
if (selectedRowIndex !== undefined && selectedColIndex !== undefined && selectedRowIndex > -1 && selectedColIndex > -1) {
|
|
1630
1470
|
controlledSelectedColor = colors[selectedRowIndex][selectedColIndex];
|
|
1631
1471
|
}
|
|
1632
|
-
|
|
1472
|
+
const openDialog = () => {
|
|
1633
1473
|
setReferenceElement(buttonRef.current);
|
|
1634
1474
|
onDialogChange && onDialogChange({
|
|
1635
1475
|
isOpen: true
|
|
1636
1476
|
});
|
|
1637
1477
|
};
|
|
1638
|
-
|
|
1478
|
+
const closeDialog = () => {
|
|
1639
1479
|
setUncontrolledRowIndex(uncontrolledSelectedRowIndex);
|
|
1640
1480
|
setUncontrolledColIndex(uncontrolledSelectedColIndex);
|
|
1641
1481
|
setReferenceElement(null);
|
|
@@ -1643,17 +1483,17 @@ var ColorSwatchDialog = forwardRef(function (_ref, ref) {
|
|
|
1643
1483
|
isOpen: false
|
|
1644
1484
|
});
|
|
1645
1485
|
};
|
|
1646
|
-
|
|
1486
|
+
const onClick = composeEventHandlers(props.onClick, () => {
|
|
1647
1487
|
if (referenceElement) {
|
|
1648
1488
|
closeDialog();
|
|
1649
1489
|
} else {
|
|
1650
1490
|
openDialog();
|
|
1651
1491
|
}
|
|
1652
1492
|
});
|
|
1653
|
-
useEffect(
|
|
1493
|
+
useEffect(() => {
|
|
1654
1494
|
if (referenceElement && colorSwatchRef.current) {
|
|
1655
|
-
|
|
1656
|
-
|
|
1495
|
+
const focusableButton = colorSwatchRef.current.querySelector('[tabindex="0"]');
|
|
1496
|
+
const selectedCell = colorSwatchRef.current.querySelector('[aria-selected="true"]');
|
|
1657
1497
|
if (selectedCell) {
|
|
1658
1498
|
selectedCell.children[0].focus();
|
|
1659
1499
|
} else {
|
|
@@ -1662,7 +1502,7 @@ var ColorSwatchDialog = forwardRef(function (_ref, ref) {
|
|
|
1662
1502
|
}
|
|
1663
1503
|
}, [referenceElement]);
|
|
1664
1504
|
return React__default.createElement(React__default.Fragment, null, children ? cloneElement(Children.only(children), {
|
|
1665
|
-
onClick
|
|
1505
|
+
onClick,
|
|
1666
1506
|
ref: buttonRef
|
|
1667
1507
|
}) : React__default.createElement(StyledButton, _extends$2({
|
|
1668
1508
|
disabled: disabled,
|
|
@@ -1694,23 +1534,24 @@ var ColorSwatchDialog = forwardRef(function (_ref, ref) {
|
|
|
1694
1534
|
defaultColIndex: uncontrolledColIndex,
|
|
1695
1535
|
defaultSelectedRowIndex: uncontrolledSelectedRowIndex,
|
|
1696
1536
|
defaultSelectedColIndex: uncontrolledSelectedColIndex,
|
|
1697
|
-
onChange:
|
|
1537
|
+
onChange: (rowIdx, colIdx) => {
|
|
1698
1538
|
if (isControlled === false) {
|
|
1699
1539
|
setUncontrolledRowIndex(rowIdx);
|
|
1700
1540
|
setUncontrolledColIndex(colIdx);
|
|
1701
1541
|
}
|
|
1702
|
-
|
|
1542
|
+
onChange && onChange(rowIdx, colIdx);
|
|
1703
1543
|
},
|
|
1704
|
-
onSelect:
|
|
1544
|
+
onSelect: (rowIdx, colIdx) => {
|
|
1705
1545
|
if (isControlled === false) {
|
|
1706
1546
|
setUncontrolledSelectedRowIndex(rowIdx);
|
|
1707
1547
|
setUncontrolledSelectedColIndex(colIdx);
|
|
1708
1548
|
}
|
|
1709
|
-
|
|
1549
|
+
onSelect && onSelect(rowIdx, colIdx);
|
|
1710
1550
|
}
|
|
1711
1551
|
}))));
|
|
1712
1552
|
});
|
|
1713
|
-
ColorSwatchDialog.propTypes =
|
|
1553
|
+
ColorSwatchDialog.propTypes = {
|
|
1554
|
+
...ColorSwatch.propTypes,
|
|
1714
1555
|
placement: PropTypes.oneOf(PLACEMENT),
|
|
1715
1556
|
onDialogChange: PropTypes.func,
|
|
1716
1557
|
disabled: PropTypes.bool,
|
|
@@ -1721,7 +1562,7 @@ ColorSwatchDialog.propTypes = _objectSpread2(_objectSpread2({}, ColorSwatch.prop
|
|
|
1721
1562
|
isAnimated: PropTypes.bool,
|
|
1722
1563
|
focusInset: PropTypes.bool,
|
|
1723
1564
|
isOpen: PropTypes.bool
|
|
1724
|
-
}
|
|
1565
|
+
};
|
|
1725
1566
|
ColorSwatchDialog.defaultProps = {
|
|
1726
1567
|
placement: 'bottom-start',
|
|
1727
1568
|
isAnimated: true,
|