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