@instructure/ui-color-picker 8.33.1 → 8.33.2-snapshot-5
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/CHANGELOG.md +8 -0
- package/es/ColorContrast/ColorContrastLocator.js +3 -3
- package/es/ColorContrast/index.js +15 -34
- package/es/ColorContrast/props.js +1 -0
- package/es/ColorContrast/styles.js +0 -2
- package/es/ColorContrast/theme.js +5 -5
- package/es/ColorIndicator/ColorIndicatorLocator.js +3 -4
- package/es/ColorIndicator/index.js +1 -10
- package/es/ColorIndicator/props.js +1 -0
- package/es/ColorIndicator/styles.js +2 -5
- package/es/ColorIndicator/theme.js +6 -5
- package/es/ColorMixer/ColorMixerLocator.js +2 -7
- package/es/ColorMixer/ColorPalette/index.js +9 -50
- package/es/ColorMixer/ColorPalette/props.js +1 -0
- package/es/ColorMixer/ColorPalette/styles.js +2 -3
- package/es/ColorMixer/ColorPalette/theme.js +6 -5
- package/es/ColorMixer/RGBAInput/index.js +7 -19
- package/es/ColorMixer/RGBAInput/props.js +1 -0
- package/es/ColorMixer/RGBAInput/styles.js +0 -1
- package/es/ColorMixer/RGBAInput/theme.js +3 -3
- package/es/ColorMixer/Slider/index.js +7 -37
- package/es/ColorMixer/Slider/props.js +1 -0
- package/es/ColorMixer/Slider/styles.js +0 -2
- package/es/ColorMixer/Slider/theme.js +6 -5
- package/es/ColorMixer/index.js +25 -34
- package/es/ColorMixer/props.js +1 -0
- package/es/ColorMixer/styles.js +0 -1
- package/es/ColorMixer/utils/shallowCompare.js +1 -2
- package/es/ColorPicker/ColorPickerLocator.js +10 -23
- package/es/ColorPicker/index.js +24 -77
- package/es/ColorPicker/props.js +1 -0
- package/es/ColorPicker/styles.js +4 -5
- package/es/ColorPicker/theme.js +7 -6
- package/es/ColorPreset/ColorPresetLocator.js +7 -10
- package/es/ColorPreset/index.js +4 -28
- package/es/ColorPreset/props.js +1 -0
- package/es/ColorPreset/styles.js +0 -1
- package/es/ColorPreset/theme.js +4 -4
- package/lib/ColorContrast/ColorContrastLocator.js +1 -6
- package/lib/ColorContrast/index.js +14 -47
- package/lib/ColorContrast/props.js +1 -3
- package/lib/ColorContrast/styles.js +0 -3
- package/lib/ColorContrast/theme.js +5 -6
- package/lib/ColorIndicator/ColorIndicatorLocator.js +2 -7
- package/lib/ColorIndicator/index.js +0 -18
- package/lib/ColorIndicator/props.js +1 -3
- package/lib/ColorIndicator/styles.js +2 -6
- package/lib/ColorIndicator/theme.js +6 -7
- package/lib/ColorMixer/ColorMixerLocator.js +3 -11
- package/lib/ColorMixer/ColorPalette/index.js +8 -61
- package/lib/ColorMixer/ColorPalette/props.js +1 -3
- package/lib/ColorMixer/ColorPalette/styles.js +0 -4
- package/lib/ColorMixer/ColorPalette/theme.js +4 -6
- package/lib/ColorMixer/RGBAInput/index.js +6 -29
- package/lib/ColorMixer/RGBAInput/props.js +1 -3
- package/lib/ColorMixer/RGBAInput/styles.js +0 -2
- package/lib/ColorMixer/RGBAInput/theme.js +3 -4
- package/lib/ColorMixer/Slider/index.js +6 -46
- package/lib/ColorMixer/Slider/props.js +1 -3
- package/lib/ColorMixer/Slider/styles.js +0 -3
- package/lib/ColorMixer/Slider/theme.js +4 -6
- package/lib/ColorMixer/index.js +24 -46
- package/lib/ColorMixer/props.js +1 -3
- package/lib/ColorMixer/styles.js +0 -2
- package/lib/ColorMixer/utils/shallowCompare.js +1 -3
- package/lib/ColorPicker/ColorPickerLocator.js +10 -29
- package/lib/ColorPicker/index.js +24 -102
- package/lib/ColorPicker/props.js +1 -3
- package/lib/ColorPicker/styles.js +4 -6
- package/lib/ColorPicker/theme.js +5 -7
- package/lib/ColorPreset/ColorPresetLocator.js +3 -12
- package/lib/ColorPreset/index.js +3 -49
- package/lib/ColorPreset/props.js +1 -3
- package/lib/ColorPreset/styles.js +0 -2
- package/lib/ColorPreset/theme.js +4 -5
- package/lib/index.js +0 -5
- package/package.json +25 -25
- package/tsconfig.build.tsbuildinfo +1 -1
package/es/ColorPicker/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2, _IconTroubleLine, _IconWarningLine, _IconCheckDarkLine, _IconInfoLine;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -25,7 +24,6 @@ var _dec, _dec2, _class, _class2, _IconTroubleLine, _IconWarningLine, _IconCheck
|
|
|
25
24
|
*/
|
|
26
25
|
|
|
27
26
|
/** @jsx jsx */
|
|
28
|
-
|
|
29
27
|
/** @jsxFrag React.Fragment */
|
|
30
28
|
import React, { Component } from 'react';
|
|
31
29
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
@@ -46,40 +44,34 @@ import generateStyle from './styles';
|
|
|
46
44
|
import generateComponentTheme from './theme';
|
|
47
45
|
import { propTypes, allowedProps } from './props';
|
|
48
46
|
const acceptedCharactersForHEX = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', null];
|
|
47
|
+
|
|
49
48
|
/**
|
|
50
49
|
---
|
|
51
50
|
category: components
|
|
52
51
|
---
|
|
53
52
|
@tsProps
|
|
54
53
|
**/
|
|
55
|
-
|
|
56
54
|
let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class ColorPicker extends Component {
|
|
57
55
|
constructor(props) {
|
|
58
56
|
super(props);
|
|
59
57
|
this.ref = null;
|
|
60
|
-
|
|
61
58
|
this.handleRef = el => {
|
|
62
59
|
const elementRef = this.props.elementRef;
|
|
63
60
|
this.ref = el;
|
|
64
|
-
|
|
65
61
|
if (typeof elementRef === 'function') {
|
|
66
62
|
elementRef(el);
|
|
67
63
|
}
|
|
68
64
|
};
|
|
69
|
-
|
|
70
65
|
this.checkSettings = () => {
|
|
71
66
|
if (this.props.children && this.props.colorMixerSettings) {
|
|
72
67
|
warn(false, 'You should either use children, colorMixerSettings or neither, not both. In this case, the colorMixerSettings will be ignored.', '');
|
|
73
68
|
}
|
|
74
|
-
|
|
75
69
|
if (this.props.value && typeof this.props.onChange !== 'function') {
|
|
76
70
|
error(false, 'You provided a `value` prop on ColorPicker, which will render a controlled component. Please provide an `onChange` handler.');
|
|
77
71
|
}
|
|
78
72
|
};
|
|
79
|
-
|
|
80
73
|
this.renderPopover = () => {
|
|
81
74
|
var _this$props$styles;
|
|
82
|
-
|
|
83
75
|
return jsx(Popover, {
|
|
84
76
|
renderTrigger: jsx(IconButton, {
|
|
85
77
|
disabled: this.props.disabled,
|
|
@@ -109,11 +101,10 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
109
101
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.popoverContentContainer
|
|
110
102
|
}, this.isDefaultPopover ? this.renderDefaultPopoverContent() : this.renderCustomPopoverContent()));
|
|
111
103
|
};
|
|
112
|
-
|
|
113
104
|
this.renderCustomPopoverContent = () => {
|
|
114
105
|
const _this$props = this.props,
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
children = _this$props.children,
|
|
107
|
+
onChange = _this$props.onChange;
|
|
117
108
|
return jsx("div", null, typeof children === 'function' && children(`#${this.mixedColorWithStrippedAlpha}`, newColor => {
|
|
118
109
|
this.setState({
|
|
119
110
|
mixedColor: colorToHex8(newColor).slice(1)
|
|
@@ -129,10 +120,8 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
129
120
|
mixedColor: this.state.hexCode
|
|
130
121
|
})));
|
|
131
122
|
};
|
|
132
|
-
|
|
133
123
|
this.renderDefaultPopoverContent = () => {
|
|
134
124
|
var _this$props$styles2, _this$props2, _this$props2$colorMix, _this$props3, _this$props3$colorMix, _this$props$styles3, _this$props4, _this$props4$colorMix, _this$props$styles4, _this$props$styles5, _this$props$colorMixe, _this$props$colorMixe2;
|
|
135
|
-
|
|
136
125
|
return jsx(React.Fragment, null, jsx("div", {
|
|
137
126
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.popoverContent
|
|
138
127
|
}, ((_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$colorMix = _this$props2.colorMixerSettings) === null || _this$props2$colorMix === void 0 ? void 0 : _this$props2$colorMix.colorMixer) && jsx(ColorMixer, {
|
|
@@ -197,7 +186,6 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
197
186
|
margin: "xx-small"
|
|
198
187
|
}, (_this$props$colorMixe2 = this.props.colorMixerSettings) === null || _this$props$colorMixe2 === void 0 ? void 0 : _this$props$colorMixe2.popoverAddButtonLabel)));
|
|
199
188
|
};
|
|
200
|
-
|
|
201
189
|
this.state = {
|
|
202
190
|
hexCode: '',
|
|
203
191
|
showHelperErrorMessages: false,
|
|
@@ -205,11 +193,10 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
205
193
|
mixedColor: ''
|
|
206
194
|
};
|
|
207
195
|
}
|
|
208
|
-
|
|
209
196
|
componentDidMount() {
|
|
210
197
|
var _this$props$makeStyle, _this$props5, _this$props$value;
|
|
211
|
-
|
|
212
|
-
|
|
198
|
+
(_this$props$makeStyle = (_this$props5 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props5, {
|
|
199
|
+
...this.state,
|
|
213
200
|
isSimple: this.isSimple
|
|
214
201
|
});
|
|
215
202
|
this.checkSettings();
|
|
@@ -217,55 +204,43 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
217
204
|
hexCode: (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.slice(1)
|
|
218
205
|
});
|
|
219
206
|
}
|
|
220
|
-
|
|
221
207
|
componentDidUpdate(prevProps) {
|
|
222
208
|
var _this$props$makeStyle2, _this$props6;
|
|
223
|
-
|
|
224
|
-
|
|
209
|
+
(_this$props$makeStyle2 = (_this$props6 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props6, {
|
|
210
|
+
...this.state,
|
|
225
211
|
isSimple: this.isSimple
|
|
226
212
|
});
|
|
227
|
-
|
|
228
213
|
if (prevProps.value !== this.props.value) {
|
|
229
214
|
var _this$props$value2;
|
|
230
|
-
|
|
231
215
|
this.setState({
|
|
232
216
|
showHelperErrorMessages: false,
|
|
233
217
|
hexCode: ((_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.slice(1)) || ''
|
|
234
218
|
});
|
|
235
219
|
}
|
|
236
|
-
|
|
237
220
|
this.checkSettings();
|
|
238
221
|
}
|
|
239
|
-
|
|
240
222
|
get renderMode() {
|
|
241
223
|
if (this.props.children) {
|
|
242
224
|
return 'customPopover';
|
|
243
225
|
}
|
|
244
|
-
|
|
245
226
|
if (this.props.colorMixerSettings) {
|
|
246
227
|
return 'defaultPopover';
|
|
247
228
|
}
|
|
248
|
-
|
|
249
229
|
return 'simple';
|
|
250
230
|
}
|
|
251
|
-
|
|
252
231
|
get isSimple() {
|
|
253
232
|
return this.renderMode === 'simple';
|
|
254
233
|
}
|
|
255
|
-
|
|
256
234
|
get isDefaultPopover() {
|
|
257
235
|
return this.renderMode === 'defaultPopover';
|
|
258
236
|
}
|
|
259
|
-
|
|
260
237
|
get isCustomPopover() {
|
|
261
238
|
return this.renderMode === 'customPopover';
|
|
262
239
|
}
|
|
263
|
-
|
|
264
240
|
get mixedColorWithStrippedAlpha() {
|
|
265
241
|
const mixedColor = this.state.mixedColor;
|
|
266
242
|
return mixedColor.length === 8 && mixedColor.slice(-2) === 'FF' ? mixedColor.slice(0, -2) : mixedColor;
|
|
267
243
|
}
|
|
268
|
-
|
|
269
244
|
getMinContrast(strength) {
|
|
270
245
|
return {
|
|
271
246
|
min: 3,
|
|
@@ -273,20 +248,18 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
273
248
|
max: 7
|
|
274
249
|
}[strength];
|
|
275
250
|
}
|
|
276
|
-
|
|
277
251
|
renderMessages() {
|
|
278
252
|
var _this$props$checkCont;
|
|
279
|
-
|
|
280
253
|
const _this$state = this.state,
|
|
281
|
-
|
|
282
|
-
|
|
254
|
+
hexCode = _this$state.hexCode,
|
|
255
|
+
showHelperErrorMessages = _this$state.showHelperErrorMessages;
|
|
283
256
|
const isValidHex = isValid(hexCode);
|
|
284
257
|
const _this$props7 = this.props,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
258
|
+
checkContrast = _this$props7.checkContrast,
|
|
259
|
+
renderMessages = _this$props7.renderMessages,
|
|
260
|
+
renderInvalidColorMessage = _this$props7.renderInvalidColorMessage,
|
|
261
|
+
renderIsRequiredMessage = _this$props7.renderIsRequiredMessage,
|
|
262
|
+
isRequired = _this$props7.isRequired;
|
|
290
263
|
const contrast = isValidHex ? getContrast(((_this$props$checkCont = this.props.checkContrast) === null || _this$props$checkCont === void 0 ? void 0 : _this$props$checkCont.contrastAgainst) || '#fff', hexCode, 2) : void 0;
|
|
291
264
|
const contrastStrength = checkContrast !== null && checkContrast !== void 0 && checkContrast.contrastStrength ? checkContrast.contrastStrength : 'mid';
|
|
292
265
|
const minContrast = this.getMinContrast(contrastStrength);
|
|
@@ -294,11 +267,9 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
294
267
|
let isRequiredMessages = [];
|
|
295
268
|
let generalMessages = [];
|
|
296
269
|
let contrastMessages = [];
|
|
297
|
-
|
|
298
270
|
if (checkContrast && contrast) {
|
|
299
271
|
const renderContrastSuccessMessage = checkContrast.renderContrastSuccessMessage,
|
|
300
|
-
|
|
301
|
-
|
|
272
|
+
renderContrastErrorMessage = checkContrast.renderContrastErrorMessage;
|
|
302
273
|
if (contrast < minContrast) {
|
|
303
274
|
contrastMessages = typeof renderContrastErrorMessage === 'function' ? renderContrastErrorMessage(contrast, minContrast) : checkContrast.isStrict ? [{
|
|
304
275
|
type: 'error',
|
|
@@ -308,25 +279,20 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
308
279
|
contrastMessages = renderContrastSuccessMessage(contrast, minContrast);
|
|
309
280
|
}
|
|
310
281
|
}
|
|
311
|
-
|
|
312
282
|
if (showHelperErrorMessages && hexCode !== '' && !isValidHex && typeof renderInvalidColorMessage === 'function') {
|
|
313
283
|
invalidColorMessages = renderInvalidColorMessage(hexCode);
|
|
314
284
|
}
|
|
315
|
-
|
|
316
285
|
if (isRequired && showHelperErrorMessages && hexCode === '') {
|
|
317
286
|
isRequiredMessages = typeof renderIsRequiredMessage === 'function' ? renderIsRequiredMessage() : [{
|
|
318
287
|
type: 'error',
|
|
319
288
|
text: '*'
|
|
320
289
|
}];
|
|
321
290
|
}
|
|
322
|
-
|
|
323
291
|
if (typeof renderMessages === 'function') {
|
|
324
292
|
generalMessages = renderMessages(hexCode, isValidHex, minContrast, contrast);
|
|
325
293
|
}
|
|
326
|
-
|
|
327
294
|
return [...invalidColorMessages, ...isRequiredMessages, ...generalMessages, ...contrastMessages];
|
|
328
295
|
}
|
|
329
|
-
|
|
330
296
|
renderBeforeInput() {
|
|
331
297
|
const styles = this.props.styles;
|
|
332
298
|
return jsx("div", {
|
|
@@ -337,38 +303,30 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
337
303
|
css: styles === null || styles === void 0 ? void 0 : styles.hashMarkContainer
|
|
338
304
|
}, "#"));
|
|
339
305
|
}
|
|
340
|
-
|
|
341
306
|
renderAfterInput() {
|
|
342
307
|
const _this$props8 = this.props,
|
|
343
|
-
|
|
344
|
-
|
|
308
|
+
checkContrast = _this$props8.checkContrast,
|
|
309
|
+
styles = _this$props8.styles;
|
|
345
310
|
const hexCode = this.state.hexCode;
|
|
346
|
-
|
|
347
311
|
if (checkContrast && isValid(hexCode)) {
|
|
348
312
|
const contrast = getContrast(checkContrast.contrastAgainst || '#fff', hexCode, 2);
|
|
349
313
|
const minContrast = this.getMinContrast(checkContrast.contrastStrength ? checkContrast.contrastStrength : 'mid');
|
|
350
|
-
|
|
351
314
|
if (minContrast >= contrast) {
|
|
352
315
|
return jsx("div", {
|
|
353
316
|
css: styles === null || styles === void 0 ? void 0 : styles.errorIcons
|
|
354
317
|
}, checkContrast.isStrict ? _IconTroubleLine || (_IconTroubleLine = jsx(IconTroubleLine, null)) : _IconWarningLine || (_IconWarningLine = jsx(IconWarningLine, null)));
|
|
355
318
|
}
|
|
356
|
-
|
|
357
319
|
return jsx("div", {
|
|
358
320
|
css: styles === null || styles === void 0 ? void 0 : styles.successIcon
|
|
359
321
|
}, _IconCheckDarkLine || (_IconCheckDarkLine = jsx(IconCheckDarkLine, null)));
|
|
360
322
|
}
|
|
361
|
-
|
|
362
323
|
return null;
|
|
363
324
|
}
|
|
364
|
-
|
|
365
325
|
handleOnChange(_event, value) {
|
|
366
326
|
const onChange = this.props.onChange;
|
|
367
|
-
|
|
368
327
|
if (value.length > (this.props.withAlpha ? 8 : 6) || value.split('').find(char => !acceptedCharactersForHEX.includes(char)) !== void 0) {
|
|
369
328
|
return;
|
|
370
329
|
}
|
|
371
|
-
|
|
372
330
|
if (typeof onChange === 'function') {
|
|
373
331
|
onChange(`#${value}`);
|
|
374
332
|
} else {
|
|
@@ -378,21 +336,16 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
378
336
|
});
|
|
379
337
|
}
|
|
380
338
|
}
|
|
381
|
-
|
|
382
339
|
handleOnPaste(event) {
|
|
383
340
|
const pasted = event.clipboardData.getData('Text');
|
|
384
341
|
let toPaste = pasted;
|
|
385
|
-
|
|
386
342
|
if (pasted[0] && pasted[0] === '#') {
|
|
387
343
|
toPaste = pasted.slice(1);
|
|
388
344
|
}
|
|
389
|
-
|
|
390
345
|
if (this.props.withAlpha && toPaste.length > 8 || !this.props.withAlpha && toPaste.length > 6) {
|
|
391
346
|
return event.preventDefault();
|
|
392
347
|
}
|
|
393
|
-
|
|
394
348
|
const newHex = `${this.state.hexCode}${toPaste}`;
|
|
395
|
-
|
|
396
349
|
if (isValid(newHex)) {
|
|
397
350
|
if (typeof this.props.onChange === 'function') {
|
|
398
351
|
this.props.onChange(`#${newHex}`);
|
|
@@ -403,21 +356,18 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
403
356
|
});
|
|
404
357
|
}
|
|
405
358
|
}
|
|
406
|
-
|
|
407
359
|
event.preventDefault();
|
|
408
360
|
}
|
|
409
|
-
|
|
410
361
|
handleOnBlur() {
|
|
411
362
|
this.setState({
|
|
412
363
|
showHelperErrorMessages: true
|
|
413
364
|
});
|
|
414
365
|
}
|
|
415
|
-
|
|
416
366
|
renderLabel() {
|
|
417
367
|
const _this$props9 = this.props,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
368
|
+
label = _this$props9.label,
|
|
369
|
+
tooltip = _this$props9.tooltip,
|
|
370
|
+
styles = _this$props9.styles;
|
|
421
371
|
return tooltip ? jsx("div", null, jsx("span", {
|
|
422
372
|
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
423
373
|
}, label), jsx("span", null, jsx(Tooltip, {
|
|
@@ -426,15 +376,13 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
426
376
|
tabIndex: -1
|
|
427
377
|
}))))) : label;
|
|
428
378
|
}
|
|
429
|
-
|
|
430
379
|
render() {
|
|
431
380
|
var _this$props$styles6, _this$props$styles7, _this$props$styles8;
|
|
432
|
-
|
|
433
381
|
const _this$props10 = this.props,
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
382
|
+
disabled = _this$props10.disabled,
|
|
383
|
+
isRequired = _this$props10.isRequired,
|
|
384
|
+
placeholderText = _this$props10.placeholderText,
|
|
385
|
+
width = _this$props10.width;
|
|
438
386
|
return jsx("div", Object.assign({}, omitProps(this.props, ColorPicker.allowedProps), {
|
|
439
387
|
css: (_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.colorPicker,
|
|
440
388
|
ref: this.handleRef
|
|
@@ -461,7 +409,6 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
461
409
|
css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.colorMixerButtonWrapper
|
|
462
410
|
}, this.renderPopover())));
|
|
463
411
|
}
|
|
464
|
-
|
|
465
412
|
}, _class2.displayName = "ColorPicker", _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.componentId = 'ColorPicker', _class2.defaultProps = {
|
|
466
413
|
disabled: false,
|
|
467
414
|
withAlpha: false,
|
package/es/ColorPicker/props.js
CHANGED
package/es/ColorPicker/styles.js
CHANGED
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props, state) => {
|
|
36
36
|
const hashMarkColor = componentTheme.hashMarkColor,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
errorIconColor = componentTheme.errorIconColor,
|
|
38
|
+
warningIconColor = componentTheme.warningIconColor,
|
|
39
|
+
successIconColor = componentTheme.successIconColor;
|
|
40
40
|
const checkContrast = props.checkContrast,
|
|
41
|
-
|
|
41
|
+
popoverMaxHeight = props.popoverMaxHeight;
|
|
42
42
|
const isSimple = state.isSimple;
|
|
43
43
|
return {
|
|
44
44
|
colorPicker: {
|
|
@@ -116,5 +116,4 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
};
|
|
119
|
-
|
|
120
119
|
export default generateStyle;
|
package/es/ColorPicker/theme.js
CHANGED
|
@@ -21,18 +21,19 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { colorIndicatorBorderColor } from '../ColorIndicator/theme';
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* Generates the theme object for the component from the theme and provided additional information
|
|
27
29
|
* @param {Object} theme The actual theme object.
|
|
28
30
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
32
|
const generateComponentTheme = theme => {
|
|
32
33
|
const colors = theme.colors,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
borders = theme.borders,
|
|
35
|
+
spacing = theme.spacing,
|
|
36
|
+
typography = theme.typography;
|
|
36
37
|
const componentVariables = {
|
|
37
38
|
hashMarkColor: colors === null || colors === void 0 ? void 0 : colors.ash,
|
|
38
39
|
warningIconColor: colors === null || colors === void 0 ? void 0 : colors.textWarning,
|
|
@@ -70,8 +71,8 @@ const generateComponentTheme = theme => {
|
|
|
70
71
|
popoverFooterTopBorderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
71
72
|
colorMixerButtonContainerLeftMargin: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall
|
|
72
73
|
};
|
|
73
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
...componentVariables
|
|
74
76
|
};
|
|
75
77
|
};
|
|
76
|
-
|
|
77
78
|
export default generateComponentTheme;
|
|
@@ -23,19 +23,20 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
25
|
import { find } from '@instructure/ui-test-queries';
|
|
26
|
+
|
|
26
27
|
/* eslint-disable no-restricted-imports */
|
|
27
28
|
// @ts-expect-error bypass no type definition found error
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
import { DrilldownLocator } from '@instructure/ui-drilldown/es/Drilldown/DrilldownLocator';
|
|
30
|
+
// @ts-expect-error bypass no type definition found error
|
|
31
|
+
import { TooltipLocator } from '@instructure/ui-tooltip/es/Tooltip/TooltipLocator';
|
|
32
|
+
// @ts-expect-error bypass no type definition found error
|
|
33
33
|
import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator';
|
|
34
34
|
/* eslint-enable no-restricted-imports */
|
|
35
35
|
|
|
36
36
|
import { ColorIndicatorLocator } from '../ColorIndicator/ColorIndicatorLocator';
|
|
37
|
-
import { ColorPreset } from './index';
|
|
37
|
+
import { ColorPreset } from './index';
|
|
38
38
|
|
|
39
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
39
40
|
export const ColorPresetLocator = locator(ColorPreset.selector, {
|
|
40
41
|
findAllColorIndicators: function () {
|
|
41
42
|
return ColorIndicatorLocator.findAll(...arguments);
|
|
@@ -50,20 +51,16 @@ export const ColorPresetLocator = locator(ColorPreset.selector, {
|
|
|
50
51
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
52
|
args[_key] = arguments[_key];
|
|
52
53
|
}
|
|
53
|
-
|
|
54
54
|
const selected = await find('[aria-label="selected"]', ...args);
|
|
55
|
-
|
|
56
55
|
if (!selected) {
|
|
57
56
|
return selected;
|
|
58
57
|
}
|
|
59
|
-
|
|
60
58
|
return await ColorIndicatorLocator.find(selected.getDOMNode());
|
|
61
59
|
},
|
|
62
60
|
findSelectedIcon: function () {
|
|
63
61
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
64
62
|
args[_key2] = arguments[_key2];
|
|
65
63
|
}
|
|
66
|
-
|
|
67
64
|
return find('[class$=-colorPreset__selectedIndicator]', ...args);
|
|
68
65
|
},
|
|
69
66
|
findAddColorPopoverContent: function () {
|
package/es/ColorPreset/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2, _IconAddLine;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -43,42 +42,35 @@ import { ColorContrast } from '../ColorContrast';
|
|
|
43
42
|
import generateStyle from './styles';
|
|
44
43
|
import generateComponentTheme from './theme';
|
|
45
44
|
import { propTypes, allowedProps } from './props';
|
|
45
|
+
|
|
46
46
|
/**
|
|
47
47
|
---
|
|
48
48
|
category: components
|
|
49
49
|
---
|
|
50
50
|
@tsProps
|
|
51
51
|
**/
|
|
52
|
-
|
|
53
52
|
let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class ColorPreset extends Component {
|
|
54
53
|
constructor(props) {
|
|
55
54
|
super(props);
|
|
56
55
|
this.ref = null;
|
|
57
|
-
|
|
58
56
|
this.handleRef = el => {
|
|
59
57
|
const elementRef = this.props.elementRef;
|
|
60
58
|
this.ref = el;
|
|
61
|
-
|
|
62
59
|
if (typeof elementRef === 'function') {
|
|
63
60
|
elementRef(el);
|
|
64
61
|
}
|
|
65
62
|
};
|
|
66
|
-
|
|
67
63
|
this.onMenuItemSelected = color => (_e, args) => {
|
|
68
64
|
if (args.value === 'select') {
|
|
69
65
|
this.props.onSelect(color);
|
|
70
66
|
}
|
|
71
|
-
|
|
72
67
|
if (args.value === 'remove') {
|
|
73
68
|
var _this$props, _this$props$colorMixe;
|
|
74
|
-
|
|
75
69
|
(_this$props = this.props) === null || _this$props === void 0 ? void 0 : (_this$props$colorMixe = _this$props.colorMixerSettings) === null || _this$props$colorMixe === void 0 ? void 0 : _this$props$colorMixe.onPresetChange(this.props.colors.filter(clr => clr !== color));
|
|
76
70
|
}
|
|
77
71
|
};
|
|
78
|
-
|
|
79
72
|
this.renderAddNewPresetButton = () => {
|
|
80
73
|
var _this$props2, _this$props2$styles, _this$props$styles, _this$props3, _this$props3$colorMix, _this$props3$colorMix2, _this$props4, _this$props4$colorMix, _this$props$styles2, _this$props$styles3, _this$props$colorMixe2, _this$props$colorMixe3;
|
|
81
|
-
|
|
82
74
|
return jsx(Popover, {
|
|
83
75
|
renderTrigger: jsx("div", {
|
|
84
76
|
css: (_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$styles = _this$props2.styles) === null || _this$props2$styles === void 0 ? void 0 : _this$props2$styles.addNewPresetButton
|
|
@@ -138,7 +130,6 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
138
130
|
}, jsx(Button, {
|
|
139
131
|
onClick: () => {
|
|
140
132
|
var _this$props5, _this$props5$colorMix;
|
|
141
|
-
|
|
142
133
|
(_this$props5 = this.props) === null || _this$props5 === void 0 ? void 0 : (_this$props5$colorMix = _this$props5.colorMixerSettings) === null || _this$props5$colorMix === void 0 ? void 0 : _this$props5$colorMix.onPresetChange([colorToHex8(this.state.newColor), ...this.props.colors]);
|
|
143
134
|
this.setState({
|
|
144
135
|
openAddNew: false
|
|
@@ -154,10 +145,8 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
154
145
|
margin: "0 xx-small 0 xx-small"
|
|
155
146
|
}, (_this$props$colorMixe3 = this.props.colorMixerSettings) === null || _this$props$colorMixe3 === void 0 ? void 0 : _this$props$colorMixe3.popoverCloseButtonLabel)));
|
|
156
147
|
};
|
|
157
|
-
|
|
158
148
|
this.renderColorIndicator = (color, selectOnClick) => {
|
|
159
149
|
var _this$props6, _this$props6$styles;
|
|
160
|
-
|
|
161
150
|
return jsx(Tooltip, {
|
|
162
151
|
renderTip: jsx("div", null, color)
|
|
163
152
|
}, jsx(View, Object.assign({
|
|
@@ -190,7 +179,6 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
190
179
|
size: "x-small"
|
|
191
180
|
})))));
|
|
192
181
|
};
|
|
193
|
-
|
|
194
182
|
this.renderSettingsMenu = (color, index) => jsx(Drilldown, {
|
|
195
183
|
onSelect: this.onMenuItemSelected(color),
|
|
196
184
|
trigger: this.renderColorIndicator(color),
|
|
@@ -209,7 +197,6 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
209
197
|
value: "remove",
|
|
210
198
|
id: "remove"
|
|
211
199
|
}, this.props.colorMixerSettings.removeColorLabel)));
|
|
212
|
-
|
|
213
200
|
this.state = {
|
|
214
201
|
openEditor: false,
|
|
215
202
|
openAddNew: false,
|
|
@@ -221,42 +208,32 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
221
208
|
}
|
|
222
209
|
};
|
|
223
210
|
}
|
|
224
|
-
|
|
225
211
|
componentDidMount() {
|
|
226
212
|
var _this$props$makeStyle, _this$props7;
|
|
227
|
-
|
|
228
213
|
(_this$props$makeStyle = (_this$props7 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props7);
|
|
229
214
|
}
|
|
230
|
-
|
|
231
215
|
componentDidUpdate() {
|
|
232
216
|
var _this$props$makeStyle2, _this$props8;
|
|
233
|
-
|
|
234
217
|
(_this$props$makeStyle2 = (_this$props8 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props8);
|
|
235
218
|
}
|
|
236
|
-
|
|
237
219
|
get isModifiable() {
|
|
238
220
|
var _this$props$colorMixe4;
|
|
239
|
-
|
|
240
221
|
return typeof ((_this$props$colorMixe4 = this.props.colorMixerSettings) === null || _this$props$colorMixe4 === void 0 ? void 0 : _this$props$colorMixe4.onPresetChange) === 'function';
|
|
241
222
|
}
|
|
242
|
-
|
|
243
223
|
isSelectedColor(color) {
|
|
244
224
|
const selected = this.props.selected;
|
|
245
225
|
return !!selected && colorToHex8(selected) === colorToHex8(color);
|
|
246
226
|
}
|
|
247
|
-
|
|
248
227
|
render() {
|
|
249
228
|
const _this$props9 = this.props,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
229
|
+
styles = _this$props9.styles,
|
|
230
|
+
label = _this$props9.label,
|
|
231
|
+
colors = _this$props9.colors;
|
|
254
232
|
if (!this.isModifiable && colors.length === 0) {
|
|
255
233
|
// if there is no preset and no ability to add new,
|
|
256
234
|
// there is no point of rendering the component
|
|
257
235
|
return null;
|
|
258
236
|
}
|
|
259
|
-
|
|
260
237
|
return jsx("div", Object.assign({}, omitProps(this.props, ColorPreset.allowedProps), {
|
|
261
238
|
ref: this.handleRef,
|
|
262
239
|
css: styles === null || styles === void 0 ? void 0 : styles.colorPreset
|
|
@@ -270,7 +247,6 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
270
247
|
}, this.renderColorIndicator(color, true));
|
|
271
248
|
}));
|
|
272
249
|
}
|
|
273
|
-
|
|
274
250
|
}, _class2.displayName = "ColorPreset", _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.componentId = 'ColorPreset', _class2.defaultProps = {
|
|
275
251
|
disabled: false
|
|
276
252
|
}, _class2)) || _class) || _class);
|
package/es/ColorPreset/props.js
CHANGED
package/es/ColorPreset/styles.js
CHANGED
package/es/ColorPreset/theme.js
CHANGED
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
borders = theme.borders,
|
|
33
|
+
spacing = theme.spacing;
|
|
34
34
|
const componentVariables = {
|
|
35
35
|
xxSmallSpacing: spacing === null || spacing === void 0 ? void 0 : spacing.xxSmall,
|
|
36
36
|
smallSpacing: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
@@ -49,8 +49,8 @@ const generateComponentTheme = theme => {
|
|
|
49
49
|
popoverContentBlockBottomMargin: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
50
50
|
popoverContentBlockTopPadding: spacing === null || spacing === void 0 ? void 0 : spacing.medium
|
|
51
51
|
};
|
|
52
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
...componentVariables
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
|
-
|
|
56
56
|
export default generateComponentTheme;
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ColorContrastLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _uiTestQueries = require("@instructure/ui-test-queries");
|
|
11
|
-
|
|
12
9
|
var _PillLocator = require("@instructure/ui-pill/lib/Pill/PillLocator");
|
|
13
|
-
|
|
14
10
|
var _index = require("./index");
|
|
15
|
-
|
|
16
11
|
/*
|
|
17
12
|
* The MIT License (MIT)
|
|
18
13
|
*
|
|
@@ -41,13 +36,13 @@ var _index = require("./index");
|
|
|
41
36
|
// @ts-expect-error bypass no type definition found error
|
|
42
37
|
|
|
43
38
|
/* eslint-enable no-restricted-imports */
|
|
39
|
+
|
|
44
40
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
45
41
|
const ColorContrastLocator = (0, _locator.locator)(_index.ColorContrast.selector, {
|
|
46
42
|
findPreview: function () {
|
|
47
43
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
44
|
args[_key] = arguments[_key];
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
return (0, _uiTestQueries.find)('[class$=-colorContrast__colorPreview]', ...args);
|
|
52
47
|
},
|
|
53
48
|
findNormalTextCheckPill: async () => {
|