@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.
Files changed (78) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/es/ColorContrast/ColorContrastLocator.js +3 -3
  3. package/es/ColorContrast/index.js +15 -34
  4. package/es/ColorContrast/props.js +1 -0
  5. package/es/ColorContrast/styles.js +0 -2
  6. package/es/ColorContrast/theme.js +5 -5
  7. package/es/ColorIndicator/ColorIndicatorLocator.js +3 -4
  8. package/es/ColorIndicator/index.js +1 -10
  9. package/es/ColorIndicator/props.js +1 -0
  10. package/es/ColorIndicator/styles.js +2 -5
  11. package/es/ColorIndicator/theme.js +6 -5
  12. package/es/ColorMixer/ColorMixerLocator.js +2 -7
  13. package/es/ColorMixer/ColorPalette/index.js +9 -50
  14. package/es/ColorMixer/ColorPalette/props.js +1 -0
  15. package/es/ColorMixer/ColorPalette/styles.js +2 -3
  16. package/es/ColorMixer/ColorPalette/theme.js +6 -5
  17. package/es/ColorMixer/RGBAInput/index.js +7 -19
  18. package/es/ColorMixer/RGBAInput/props.js +1 -0
  19. package/es/ColorMixer/RGBAInput/styles.js +0 -1
  20. package/es/ColorMixer/RGBAInput/theme.js +3 -3
  21. package/es/ColorMixer/Slider/index.js +7 -37
  22. package/es/ColorMixer/Slider/props.js +1 -0
  23. package/es/ColorMixer/Slider/styles.js +0 -2
  24. package/es/ColorMixer/Slider/theme.js +6 -5
  25. package/es/ColorMixer/index.js +25 -34
  26. package/es/ColorMixer/props.js +1 -0
  27. package/es/ColorMixer/styles.js +0 -1
  28. package/es/ColorMixer/utils/shallowCompare.js +1 -2
  29. package/es/ColorPicker/ColorPickerLocator.js +10 -23
  30. package/es/ColorPicker/index.js +24 -77
  31. package/es/ColorPicker/props.js +1 -0
  32. package/es/ColorPicker/styles.js +4 -5
  33. package/es/ColorPicker/theme.js +7 -6
  34. package/es/ColorPreset/ColorPresetLocator.js +7 -10
  35. package/es/ColorPreset/index.js +4 -28
  36. package/es/ColorPreset/props.js +1 -0
  37. package/es/ColorPreset/styles.js +0 -1
  38. package/es/ColorPreset/theme.js +4 -4
  39. package/lib/ColorContrast/ColorContrastLocator.js +1 -6
  40. package/lib/ColorContrast/index.js +14 -47
  41. package/lib/ColorContrast/props.js +1 -3
  42. package/lib/ColorContrast/styles.js +0 -3
  43. package/lib/ColorContrast/theme.js +5 -6
  44. package/lib/ColorIndicator/ColorIndicatorLocator.js +2 -7
  45. package/lib/ColorIndicator/index.js +0 -18
  46. package/lib/ColorIndicator/props.js +1 -3
  47. package/lib/ColorIndicator/styles.js +2 -6
  48. package/lib/ColorIndicator/theme.js +6 -7
  49. package/lib/ColorMixer/ColorMixerLocator.js +3 -11
  50. package/lib/ColorMixer/ColorPalette/index.js +8 -61
  51. package/lib/ColorMixer/ColorPalette/props.js +1 -3
  52. package/lib/ColorMixer/ColorPalette/styles.js +0 -4
  53. package/lib/ColorMixer/ColorPalette/theme.js +4 -6
  54. package/lib/ColorMixer/RGBAInput/index.js +6 -29
  55. package/lib/ColorMixer/RGBAInput/props.js +1 -3
  56. package/lib/ColorMixer/RGBAInput/styles.js +0 -2
  57. package/lib/ColorMixer/RGBAInput/theme.js +3 -4
  58. package/lib/ColorMixer/Slider/index.js +6 -46
  59. package/lib/ColorMixer/Slider/props.js +1 -3
  60. package/lib/ColorMixer/Slider/styles.js +0 -3
  61. package/lib/ColorMixer/Slider/theme.js +4 -6
  62. package/lib/ColorMixer/index.js +24 -46
  63. package/lib/ColorMixer/props.js +1 -3
  64. package/lib/ColorMixer/styles.js +0 -2
  65. package/lib/ColorMixer/utils/shallowCompare.js +1 -3
  66. package/lib/ColorPicker/ColorPickerLocator.js +10 -29
  67. package/lib/ColorPicker/index.js +24 -102
  68. package/lib/ColorPicker/props.js +1 -3
  69. package/lib/ColorPicker/styles.js +4 -6
  70. package/lib/ColorPicker/theme.js +5 -7
  71. package/lib/ColorPreset/ColorPresetLocator.js +3 -12
  72. package/lib/ColorPreset/index.js +3 -49
  73. package/lib/ColorPreset/props.js +1 -3
  74. package/lib/ColorPreset/styles.js +0 -2
  75. package/lib/ColorPreset/theme.js +4 -5
  76. package/lib/index.js +0 -5
  77. package/package.json +25 -25
  78. package/tsconfig.build.tsbuildinfo +1 -1
@@ -21,17 +21,18 @@
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
- borders = theme.borders,
34
- stacking = theme.stacking;
34
+ borders = theme.borders,
35
+ stacking = theme.stacking;
35
36
  const componentVariables = {
36
37
  indicatorBorderColor: colors.licorice,
37
38
  whiteColor: colors.white,
@@ -42,8 +43,8 @@ const generateComponentTheme = theme => {
42
43
  disabledOverlayZIndex: stacking.topmost,
43
44
  paletteOffset: '0.125rem'
44
45
  };
45
- return { ...componentVariables
46
+ return {
47
+ ...componentVariables
46
48
  };
47
49
  };
48
-
49
50
  export default generateComponentTheme;
@@ -1,5 +1,4 @@
1
1
  var _dec, _class, _class2, _span;
2
-
3
2
  /*
4
3
  * The MIT License (MIT)
5
4
  *
@@ -33,57 +32,48 @@ import { TextInput } from '@instructure/ui-text-input';
33
32
  import { propTypes, allowedProps } from './props';
34
33
  import generateStyle from './styles';
35
34
  import generateComponentTheme from './theme';
35
+
36
36
  /**
37
37
  ---
38
38
  private: true
39
39
  ---
40
40
  @tsProps
41
41
  **/
42
-
43
42
  let RGBAInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_class2 = class RGBAInput extends Component {
44
43
  constructor(props) {
45
44
  super(props);
46
45
  this.ref = null;
47
-
48
46
  this.handleRef = el => {
49
47
  const elementRef = this.props.elementRef;
50
48
  this.ref = el;
51
-
52
49
  if (typeof elementRef === 'function') {
53
50
  elementRef(el);
54
51
  }
55
52
  };
56
-
57
53
  this.state = {
58
54
  value: props.value
59
55
  };
60
56
  }
61
-
62
57
  componentDidMount() {
63
58
  var _this$props$makeStyle, _this$props;
64
-
65
59
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
66
60
  }
67
-
68
61
  componentDidUpdate(prevProps) {
69
62
  var _this$props$makeStyle2, _this$props2;
70
-
71
63
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
72
-
73
64
  if (shallowCompare(prevProps.value, this.props.value) || shallowCompare(this.state.value, this.props.value)) {
74
65
  this.setState({
75
66
  value: this.props.value
76
67
  });
77
68
  }
78
69
  }
79
-
80
70
  handleChange(type, e) {
81
71
  const upperLimit = type === 'a' ? 100 : 255;
82
72
  const newValue = type === 'a' ? Number(e.target.value) / 100 : Number(e.target.value);
83
- const newColor = { ...this.props.value,
73
+ const newColor = {
74
+ ...this.props.value,
84
75
  [type]: newValue
85
76
  };
86
-
87
77
  if (!isNaN(Number(newValue)) && newValue >= 0 && newValue <= upperLimit) {
88
78
  this.setState({
89
79
  value: newColor
@@ -92,13 +82,12 @@ let RGBAInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_
92
82
  return;
93
83
  }
94
84
  }
95
-
96
85
  render() {
97
86
  const _this$props3 = this.props,
98
- styles = _this$props3.styles,
99
- disabled = _this$props3.disabled,
100
- label = _this$props3.label,
101
- withAlpha = _this$props3.withAlpha;
87
+ styles = _this$props3.styles,
88
+ disabled = _this$props3.disabled,
89
+ label = _this$props3.label,
90
+ withAlpha = _this$props3.withAlpha;
102
91
  return jsx("div", {
103
92
  ref: this.handleRef,
104
93
  css: styles === null || styles === void 0 ? void 0 : styles.RGBAInput
@@ -141,7 +130,6 @@ let RGBAInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_
141
130
  renderLabel: jsx(ScreenReaderContent, null, this.props.rgbAlphaInputScreenReaderLabel)
142
131
  }))));
143
132
  }
144
-
145
133
  }, _class2.displayName = "RGBAInput", _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.componentId = 'ColorMixer.RGBAInput', _class2.defaultProps = {
146
134
  withAlpha: false
147
135
  }, _class2)) || _class);
@@ -21,6 +21,7 @@
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 PropTypes from 'prop-types';
25
26
  const propTypes = {
26
27
  disabled: PropTypes.bool,
@@ -59,5 +59,4 @@ const generateStyle = (componentTheme, props) => {
59
59
  }
60
60
  };
61
61
  };
62
-
63
62
  export default generateStyle;
@@ -29,15 +29,15 @@
29
29
  */
30
30
  const generateComponentTheme = theme => {
31
31
  const spacing = theme.spacing,
32
- typography = theme.typography;
32
+ typography = theme.typography;
33
33
  const componentVariables = {
34
34
  labelFontWeight: typography.fontWeightBold,
35
35
  inputContainerTopMargin: spacing.xSmall,
36
36
  tgbInputTopMargin: spacing.xSmall,
37
37
  rgbaInputTopMargin: spacing.medium
38
38
  };
39
- return { ...componentVariables
39
+ return {
40
+ ...componentVariables
40
41
  };
41
42
  };
42
-
43
43
  export default generateComponentTheme;
@@ -1,5 +1,4 @@
1
1
  var _dec, _class, _class2;
2
-
3
2
  /*
4
3
  * The MIT License (MIT)
5
4
  *
@@ -32,13 +31,13 @@ import { View } from '@instructure/ui-view';
32
31
  import { propTypes, allowedProps } from './props';
33
32
  import generateStyle from './styles';
34
33
  import generateComponentTheme from './theme';
34
+
35
35
  /**
36
36
  ---
37
37
  private: true
38
38
  ---
39
39
  @tsProps
40
40
  **/
41
-
42
41
  let Slider = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_class2 = class Slider extends Component {
43
42
  constructor() {
44
43
  super(...arguments);
@@ -46,42 +45,34 @@ let Slider = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cla
46
45
  this._sliderRef = null;
47
46
  this._mouseMoveListener = void 0;
48
47
  this._mouseUpListener = void 0;
49
-
50
48
  this.handleRef = el => {
51
49
  const elementRef = this.props.elementRef;
52
50
  this.ref = el;
53
-
54
51
  if (typeof elementRef === 'function') {
55
52
  elementRef(el);
56
53
  }
57
54
  };
58
-
59
55
  this.handleChange = e => {
60
56
  if (this.props.disabled) return;
61
57
  const clientX = e.clientX;
62
58
  const newPosition = this.calcSliderPositionFromCursorPosition(clientX, this._sliderRef);
63
59
  this.props.onChange(this.calcValueFromSliderPosition(newPosition));
64
60
  };
65
-
66
61
  this.handleMouseUp = () => {
67
62
  this.removeEventListeners();
68
63
  };
69
-
70
64
  this.calcSliderPositionFromCursorPosition = (clientX, _sliderRef) => {
71
65
  if (this.props.isColorSlider) {
72
66
  const _sliderRef$getBoundin = _sliderRef.getBoundingClientRect(),
73
- x = _sliderRef$getBoundin.x;
74
-
67
+ x = _sliderRef$getBoundin.x;
75
68
  const newPosition = clientX - x;
76
69
  return newPosition < 0 ? 0 : newPosition > this.props.width ? this.props.width - 1 : newPosition;
77
70
  } else {
78
71
  const _sliderRef$getBoundin2 = _sliderRef.getBoundingClientRect(),
79
- x = _sliderRef$getBoundin2.x;
80
-
72
+ x = _sliderRef$getBoundin2.x;
81
73
  return clientX - x;
82
74
  }
83
75
  };
84
-
85
76
  this.calcSliderPositionFromValue = value => {
86
77
  if (this.props.isColorSlider) {
87
78
  return value / 360 * this.props.width;
@@ -89,7 +80,6 @@ let Slider = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cla
89
80
  return this.props.width - (1 - value) * this.props.width;
90
81
  }
91
82
  };
92
-
93
83
  this.calcValueFromSliderPosition = position => {
94
84
  if (this.props.isColorSlider) {
95
85
  return position / this.props.width * 360;
@@ -99,85 +89,66 @@ let Slider = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cla
99
89
  }
100
90
  };
101
91
  }
102
-
103
92
  componentDidMount() {
104
93
  var _this$props$makeStyle, _this$props;
105
-
106
94
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStylesProps);
107
95
  }
108
-
109
96
  componentDidUpdate() {
110
97
  var _this$props$makeStyle2, _this$props2;
111
-
112
98
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStylesProps);
113
99
  }
114
-
115
100
  componentWillUnmount() {
116
101
  this.removeEventListeners();
117
102
  }
118
-
119
103
  removeEventListeners() {
120
104
  var _this$_mouseMoveListe, _this$_mouseUpListene;
121
-
122
105
  (_this$_mouseMoveListe = this._mouseMoveListener) === null || _this$_mouseMoveListe === void 0 ? void 0 : _this$_mouseMoveListe.remove();
123
106
  (_this$_mouseUpListene = this._mouseUpListener) === null || _this$_mouseUpListene === void 0 ? void 0 : _this$_mouseUpListene.remove();
124
107
  }
125
-
126
108
  get sliderPositionFromValue() {
127
109
  return this.calcSliderPositionFromValue(this.props.value);
128
110
  }
129
-
130
111
  get roundedValue() {
131
112
  const _this$props3 = this.props,
132
- value = _this$props3.value,
133
- maxValue = _this$props3.maxValue;
134
-
113
+ value = _this$props3.value,
114
+ maxValue = _this$props3.maxValue;
135
115
  if (maxValue <= 1) {
136
116
  return Math.round(value * 100);
137
117
  } else {
138
118
  return Math.round(value);
139
119
  }
140
120
  }
141
-
142
121
  get makeStylesProps() {
143
122
  return {
144
123
  sliderPositionFromValue: this.sliderPositionFromValue
145
124
  };
146
125
  }
147
-
148
126
  handleMouseDown(e) {
149
127
  this.handleChange(e);
150
128
  this._mouseMoveListener = addEventListener(window, 'mousemove', this.handleChange);
151
129
  this._mouseUpListener = addEventListener(window, 'mouseup', this.handleMouseUp);
152
130
  }
153
-
154
131
  applyBoundaries(x) {
155
132
  if (x > this.props.width) return this.props.width;
156
133
  if (x < 0) return 0;
157
134
  return x;
158
135
  }
159
-
160
136
  handleKeyDown(e) {
161
137
  const key = e.key;
162
138
  if (key === 'Tab') return;
163
139
  e.preventDefault();
164
140
  let deltaX = 0;
165
-
166
141
  if (key === 'ArrowLeft' || key === 'a') {
167
142
  deltaX = -2;
168
143
  }
169
-
170
144
  if (key === 'ArrowRight' || key === 'd') {
171
145
  deltaX = 2;
172
146
  }
173
-
174
147
  const newPosition = this.applyBoundaries(this.sliderPositionFromValue + deltaX);
175
148
  this.props.onChange(this.calcValueFromSliderPosition(newPosition));
176
149
  }
177
-
178
150
  render() {
179
151
  var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
180
-
181
152
  return jsx(View, {
182
153
  elementRef: this.handleRef,
183
154
  disabled: this.props.disabled,
@@ -192,12 +163,12 @@ let Slider = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cla
192
163
  onKeyDown: e => this.handleKeyDown(e),
193
164
  onMouseDown: e => this.handleMouseDown(e),
194
165
  tabIndex: this.props.disabled ? void 0 : 0,
195
- "aria-label": this.props.navigationExplanationScreenReaderLabel // TODO: check RangeInput and ProgressBar to see how the slider role can be handled well
166
+ "aria-label": this.props.navigationExplanationScreenReaderLabel
167
+ // TODO: check RangeInput and ProgressBar to see how the slider role can be handled well
196
168
  // role="slider"
197
169
  // aria-valuemin={this.props.minValue}
198
170
  // aria-valuemax={this.props.maxValue}
199
171
  // aria-valuenow={this.roundedValue}
200
-
201
172
  }, jsx("div", {
202
173
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.indicator
203
174
  }), this.props.disabled && jsx("div", {
@@ -211,7 +182,6 @@ let Slider = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_cla
211
182
  css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.slider
212
183
  })));
213
184
  }
214
-
215
185
  }, _class2.displayName = "Slider", _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.componentId = 'ColorMixer.Slider', _class2.defaultProps = {
216
186
  isColorSlider: false
217
187
  }, _class2)) || _class);
@@ -21,6 +21,7 @@
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 PropTypes from 'prop-types';
25
26
  const propTypes = {
26
27
  isColorSlider: PropTypes.bool,
@@ -34,7 +34,6 @@
34
34
  */
35
35
  const generateStyle = (componentTheme, props, state) => {
36
36
  var _props$color;
37
-
38
37
  const sliderBackground = props.isColorSlider ? {
39
38
  background: 'linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%)'
40
39
  } : {
@@ -91,5 +90,4 @@ const generateStyle = (componentTheme, props, state) => {
91
90
  }
92
91
  };
93
92
  };
94
-
95
93
  export default generateStyle;
@@ -21,17 +21,18 @@
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
- borders = theme.borders,
34
- stacking = theme.stacking;
34
+ borders = theme.borders,
35
+ stacking = theme.stacking;
35
36
  const componentVariables = {
36
37
  indicatorBorderColor: colors.licorice,
37
38
  checkerboardBackgroundImage: `linear-gradient(45deg, ${colors.tiara} 25%, transparent 25%),
@@ -46,8 +47,8 @@ const generateComponentTheme = theme => {
46
47
  indicatorZIndex: stacking.above,
47
48
  disabledOverlayZIndex: stacking.topmost
48
49
  };
49
- return { ...componentVariables
50
+ return {
51
+ ...componentVariables
50
52
  };
51
53
  };
52
-
53
54
  export default generateComponentTheme;
@@ -1,5 +1,4 @@
1
1
  var _dec, _dec2, _class, _class2;
2
-
3
2
  /*
4
3
  * The MIT License (MIT)
5
4
  *
@@ -36,13 +35,13 @@ import Slider from './Slider';
36
35
  import RGBAInput from './RGBAInput';
37
36
  import { propTypes, allowedProps } from './props';
38
37
  import generateStyle from './styles';
38
+
39
39
  /**
40
40
  ---
41
41
  category: components
42
42
  ---
43
43
  @tsProps
44
44
  **/
45
-
46
45
  let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class ColorMixer extends Component {
47
46
  constructor(props) {
48
47
  super(props);
@@ -52,16 +51,13 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
52
51
  this._sliderHeight = 8;
53
52
  this._sliderIndicatorRadius = 6;
54
53
  this._paletteIndicatorRadius = 6;
55
-
56
54
  this.handleRef = el => {
57
55
  const elementRef = this.props.elementRef;
58
56
  this.ref = el;
59
-
60
57
  if (typeof elementRef === 'function') {
61
58
  elementRef(el);
62
59
  }
63
60
  };
64
-
65
61
  this.state = {
66
62
  h: 0,
67
63
  s: 0,
@@ -69,26 +65,22 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
69
65
  a: 1
70
66
  };
71
67
  }
72
-
73
68
  componentDidMount() {
74
69
  var _this$props$makeStyle, _this$props;
75
-
76
70
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
77
71
  warn(isValid(this.props.value), `[ColorMixer] The passed color value is not valid.`);
78
- this.setState({ ...colorToHsva(this.props.value)
72
+ this.setState({
73
+ ...colorToHsva(this.props.value)
79
74
  });
80
75
  }
81
-
82
76
  componentDidUpdate(prevProps, prevState) {
83
77
  var _this$props$makeStyle2, _this$props2;
84
-
85
78
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
86
79
  const _this$state = this.state,
87
- h = _this$state.h,
88
- s = _this$state.s,
89
- v = _this$state.v,
90
- a = _this$state.a;
91
-
80
+ h = _this$state.h,
81
+ s = _this$state.s,
82
+ v = _this$state.v,
83
+ a = _this$state.a;
92
84
  if (prevState.h !== h || prevState.s !== s || prevState.v !== v || prevState.a !== a) {
93
85
  this.props.onChange(colorToHex8({
94
86
  h,
@@ -97,35 +89,34 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
97
89
  a
98
90
  }));
99
91
  }
100
-
101
92
  if (prevProps.value !== this.props.value && colorToHex8({
102
93
  h,
103
94
  s,
104
95
  v,
105
96
  a
106
97
  }) !== this.props.value) {
107
- this.setState({ ...colorToHsva(this.props.value)
98
+ this.setState({
99
+ ...colorToHsva(this.props.value)
108
100
  });
109
101
  }
110
102
  }
111
-
112
103
  render() {
113
104
  const _this$props3 = this.props,
114
- disabled = _this$props3.disabled,
115
- styles = _this$props3.styles,
116
- withAlpha = _this$props3.withAlpha,
117
- rgbRedInputScreenReaderLabel = _this$props3.rgbRedInputScreenReaderLabel,
118
- rgbGreenInputScreenReaderLabel = _this$props3.rgbGreenInputScreenReaderLabel,
119
- rgbBlueInputScreenReaderLabel = _this$props3.rgbBlueInputScreenReaderLabel,
120
- rgbAlphaInputScreenReaderLabel = _this$props3.rgbAlphaInputScreenReaderLabel,
121
- colorSliderNavigationExplanationScreenReaderLabel = _this$props3.colorSliderNavigationExplanationScreenReaderLabel,
122
- alphaSliderNavigationExplanationScreenReaderLabel = _this$props3.alphaSliderNavigationExplanationScreenReaderLabel,
123
- colorPaletteNavigationExplanationScreenReaderLabel = _this$props3.colorPaletteNavigationExplanationScreenReaderLabel;
105
+ disabled = _this$props3.disabled,
106
+ styles = _this$props3.styles,
107
+ withAlpha = _this$props3.withAlpha,
108
+ rgbRedInputScreenReaderLabel = _this$props3.rgbRedInputScreenReaderLabel,
109
+ rgbGreenInputScreenReaderLabel = _this$props3.rgbGreenInputScreenReaderLabel,
110
+ rgbBlueInputScreenReaderLabel = _this$props3.rgbBlueInputScreenReaderLabel,
111
+ rgbAlphaInputScreenReaderLabel = _this$props3.rgbAlphaInputScreenReaderLabel,
112
+ colorSliderNavigationExplanationScreenReaderLabel = _this$props3.colorSliderNavigationExplanationScreenReaderLabel,
113
+ alphaSliderNavigationExplanationScreenReaderLabel = _this$props3.alphaSliderNavigationExplanationScreenReaderLabel,
114
+ colorPaletteNavigationExplanationScreenReaderLabel = _this$props3.colorPaletteNavigationExplanationScreenReaderLabel;
124
115
  const _this$state2 = this.state,
125
- h = _this$state2.h,
126
- s = _this$state2.s,
127
- v = _this$state2.v,
128
- a = _this$state2.a;
116
+ h = _this$state2.h,
117
+ s = _this$state2.s,
118
+ v = _this$state2.v,
119
+ a = _this$state2.a;
129
120
  return jsx("div", Object.assign({}, omitProps(this.props, ColorMixer.allowedProps), {
130
121
  "aria-disabled": disabled,
131
122
  ref: this.handleRef,
@@ -205,7 +196,8 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
205
196
  v,
206
197
  a
207
198
  }),
208
- onChange: color => this.setState({ ...colorToHsva(color)
199
+ onChange: color => this.setState({
200
+ ...colorToHsva(color)
209
201
  }),
210
202
  withAlpha: withAlpha,
211
203
  rgbRedInputScreenReaderLabel: rgbRedInputScreenReaderLabel,
@@ -214,7 +206,6 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
214
206
  rgbAlphaInputScreenReaderLabel: rgbAlphaInputScreenReaderLabel
215
207
  }));
216
208
  }
217
-
218
209
  }, _class2.displayName = "ColorMixer", _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.componentId = 'ColorMixer', _class2.defaultProps = {
219
210
  value: '#000',
220
211
  withAlpha: false,
@@ -21,6 +21,7 @@
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 PropTypes from 'prop-types';
25
26
  const propTypes = {
26
27
  disabled: PropTypes.bool,
@@ -45,5 +45,4 @@ const generateStyle = () => {
45
45
  }
46
46
  };
47
47
  };
48
-
49
48
  export default generateStyle;
@@ -21,12 +21,11 @@
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
  const shallowCompare = (newObj, prevObj) => {
25
26
  for (const key in newObj) {
26
27
  if (newObj[key] !== prevObj[key]) return true;
27
28
  }
28
-
29
29
  return false;
30
30
  };
31
-
32
31
  export default shallowCompare;
@@ -24,28 +24,25 @@
24
24
  import { locator } from '@instructure/ui-test-locator';
25
25
  import { find, findAll, parseQueryArguments, findWithText, within } from '@instructure/ui-test-utils';
26
26
  import { ColorPicker } from '.';
27
+
27
28
  /* eslint-disable no-restricted-imports */
28
29
  // @ts-expect-error bypass no type definition found error
29
-
30
30
  import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator';
31
31
  /* eslint-enable no-restricted-imports */
32
32
 
33
33
  import { ColorIndicatorLocator } from '../ColorIndicator/ColorIndicatorLocator';
34
34
  import { ColorMixerLocator } from '../ColorMixer/ColorMixerLocator';
35
35
  import { ColorPresetLocator } from '../ColorPreset/ColorPresetLocator';
36
-
37
36
  async function _findColorPreset() {
38
37
  const popoverContent = await PopoverLocator.findContent(...arguments);
39
38
  const colorPreset = await ColorPresetLocator.find(popoverContent.getDOMNode());
40
39
  return ColorIndicatorLocator.findAll(colorPreset.getDOMNode());
41
40
  }
42
-
43
41
  const customMethods = {
44
42
  findTextInput: function () {
45
43
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
46
44
  args[_key] = arguments[_key];
47
45
  }
48
-
49
46
  return find('[id^=TextInput_]', ...args);
50
47
  },
51
48
  findColorIndicator: function () {
@@ -55,14 +52,12 @@ const customMethods = {
55
52
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
56
53
  args[_key2] = arguments[_key2];
57
54
  }
58
-
59
55
  return find('[class$=-textInput__afterElement]', ...args);
60
56
  },
61
57
  findFormMessages: function () {
62
58
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
63
59
  args[_key3] = arguments[_key3];
64
60
  }
65
-
66
61
  return findAll('[class$=-formFieldMessage]', ...args);
67
62
  },
68
63
  findPopoverRoot: function () {
@@ -76,12 +71,13 @@ const customMethods = {
76
71
  },
77
72
  findPopoverContent: function () {
78
73
  const _parseQueryArguments = parseQueryArguments(...arguments),
79
- element = _parseQueryArguments.element,
80
- selector = _parseQueryArguments.selector,
81
- options = _parseQueryArguments.options;
82
-
83
- return PopoverLocator.findContent(element, selector, { ...options,
84
- customMethods: { ...options.customMethods,
74
+ element = _parseQueryArguments.element,
75
+ selector = _parseQueryArguments.selector,
76
+ options = _parseQueryArguments.options;
77
+ return PopoverLocator.findContent(element, selector, {
78
+ ...options,
79
+ customMethods: {
80
+ ...options.customMethods,
85
81
  ...customMethods
86
82
  }
87
83
  });
@@ -90,23 +86,18 @@ const customMethods = {
90
86
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
91
87
  args[_key4] = arguments[_key4];
92
88
  }
93
-
94
89
  const rgbaInputs = await findAll('[class$=-RGBAInput__rgbInput]', ...args);
95
90
  return Promise.all(rgbaInputs.map(span => span.find('input')));
96
91
  },
97
92
  findPopoverButtonWithText: async function () {
98
93
  let el = await findWithText(...arguments);
99
-
100
94
  while (el.getTagName() !== 'button') {
101
95
  const parentNode = el.getParentNode();
102
-
103
96
  if (!parentNode) {
104
97
  break;
105
98
  }
106
-
107
99
  el = within(parentNode);
108
100
  }
109
-
110
101
  return el;
111
102
  },
112
103
  findColorPreset: async function () {
@@ -115,23 +106,19 @@ const customMethods = {
115
106
  findColorPresetButtons: async function () {
116
107
  const colorPresets = await _findColorPreset(...arguments);
117
108
  const colorPresetButtons = [];
118
-
119
109
  for (let el of colorPresets) {
120
110
  while (el.getTagName() !== 'button') {
121
111
  const parentNode = el.getParentNode();
122
-
123
112
  if (!parentNode) {
124
113
  break;
125
114
  }
126
-
127
115
  el = within(parentNode);
128
116
  }
129
-
130
117
  colorPresetButtons.push(el);
131
118
  }
132
-
133
119
  return colorPresetButtons;
134
120
  }
135
- }; //@ts-expect-error no selector on class
121
+ };
136
122
 
123
+ //@ts-expect-error no selector on class
137
124
  export const ColorPickerLocator = locator(ColorPicker.selector, customMethods);