@instructure/ui-color-picker 8.56.1 → 8.56.2-snapshot-2

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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.56.2-snapshot-2](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2-snapshot-2) (2024-08-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-color-picker,ui-color-utils:** fix corrupted CJS build ([ba5965f](https://github.com/instructure/instructure-ui/commit/ba5965f1b4b21067b1122a490183252868916f1a))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [8.56.1](https://github.com/instructure/instructure-ui/compare/v8.56.0...v8.56.1) (2024-06-13)
7
18
 
8
19
 
@@ -29,7 +29,8 @@ import React, { Component } from 'react';
29
29
  import { omitProps } from '@instructure/ui-react-utils';
30
30
  import { testable } from '@instructure/ui-testable';
31
31
  import { error } from '@instructure/console';
32
- import { contrast as getContrast, colorToRGB, colorToHex8 } from '@instructure/ui-color-utils';
32
+ import { contrast as getContrast } from '@instructure/ui-color-utils';
33
+ import conversions from '@instructure/ui-color-utils';
33
34
  import { withStyle, jsx } from '@instructure/emotion';
34
35
  import { Text } from '@instructure/ui-text';
35
36
  import { Pill } from '@instructure/ui-pill';
@@ -124,8 +125,8 @@ let ColorContrast = (_dec = withStyle(generateStyle, generateComponentTheme), _d
124
125
  //We project the firstColor onto an opaque white background, then we project the secondColor onto
125
126
  //the projected first color. We calculate the contrast of these two, projected colors.
126
127
  get calcContrast() {
127
- const c1RGBA = colorToRGB(this.props.firstColor);
128
- const c2RGBA = colorToRGB(this.props.secondColor);
128
+ const c1RGBA = conversions.colorToRGB(this.props.firstColor);
129
+ const c2RGBA = conversions.colorToRGB(this.props.secondColor);
129
130
  const c1OnWhite = this.calcBlendedColor({
130
131
  r: 255,
131
132
  g: 255,
@@ -133,7 +134,7 @@ let ColorContrast = (_dec = withStyle(generateStyle, generateComponentTheme), _d
133
134
  a: 1
134
135
  }, c1RGBA);
135
136
  const c2OnC1OnWhite = this.calcBlendedColor(c1OnWhite, c2RGBA);
136
- return getContrast(colorToHex8(c1OnWhite), colorToHex8(c2OnC1OnWhite), 2);
137
+ return getContrast(conversions.colorToHex8(c1OnWhite), conversions.colorToHex8(c2OnC1OnWhite), 2);
137
138
  }
138
139
  render() {
139
140
  const _this$props5 = this.props,
@@ -22,8 +22,8 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
+ import conversions from '@instructure/ui-color-utils';
25
26
  import { isValid } from '@instructure/ui-color-utils';
26
- import { colorToRGB } from '@instructure/ui-color-utils';
27
27
  const calcBlendedColor = (c1, c2) => {
28
28
  // 0.4 as decided by design
29
29
  const c2Alpha = c2.a * 0.4;
@@ -61,7 +61,7 @@ const generateStyle = (componentTheme, props) => {
61
61
  backgroundImage: componentTheme.backgroundImage,
62
62
  backgroundSize: componentTheme.backgroundSize,
63
63
  backgroundPosition: componentTheme.backgroundPosition,
64
- borderColor: calcBlendedColor(colorToRGB(componentTheme.colorIndicatorBorderColor), colorToRGB(isValid(color) ? color : '#fff'))
64
+ borderColor: calcBlendedColor(conversions.colorToRGB(componentTheme.colorIndicatorBorderColor), conversions.colorToRGB(isValid(color) ? color : '#fff'))
65
65
  }
66
66
  };
67
67
  };
@@ -28,7 +28,8 @@ import { Component } from 'react';
28
28
  import { withStyle, jsx } from '@instructure/emotion';
29
29
  import { omitProps } from '@instructure/ui-react-utils';
30
30
  import { testable } from '@instructure/ui-testable';
31
- import { colorToHex8, colorToHsva, colorToRGB, isValid } from '@instructure/ui-color-utils';
31
+ import { isValid } from '@instructure/ui-color-utils';
32
+ import conversions from '@instructure/ui-color-utils';
32
33
  import { logWarn as warn } from '@instructure/console';
33
34
  import ColorPalette from './ColorPalette';
34
35
  import Slider from './Slider';
@@ -69,7 +70,7 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
69
70
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
70
71
  warn(isValid(this.props.value), `[ColorMixer] The passed color value is not valid.`);
71
72
  this.setState({
72
- ...colorToHsva(this.props.value)
73
+ ...conversions.colorToHsva(this.props.value)
73
74
  });
74
75
  }
75
76
  componentDidUpdate(prevProps, prevState) {
@@ -81,21 +82,21 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
81
82
  v = _this$state.v,
82
83
  a = _this$state.a;
83
84
  if (prevState.h !== h || prevState.s !== s || prevState.v !== v || prevState.a !== a) {
84
- this.props.onChange(colorToHex8({
85
+ this.props.onChange(conversions.colorToHex8({
85
86
  h,
86
87
  s,
87
88
  v,
88
89
  a
89
90
  }));
90
91
  }
91
- if (prevProps.value !== this.props.value && colorToHex8({
92
+ if (prevProps.value !== this.props.value && conversions.colorToHex8({
92
93
  h,
93
94
  s,
94
95
  v,
95
96
  a
96
97
  }) !== this.props.value) {
97
98
  this.setState({
98
- ...colorToHsva(this.props.value)
99
+ ...conversions.colorToHsva(this.props.value)
99
100
  });
100
101
  }
101
102
  }
@@ -122,7 +123,7 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
122
123
  css: styles === null || styles === void 0 ? void 0 : styles.colorMixer
123
124
  }), jsx("span", {
124
125
  css: styles === null || styles === void 0 ? void 0 : styles.sliderAndPaletteContainer,
125
- "aria-label": `${colorToHex8({
126
+ "aria-label": `${conversions.colorToHex8({
126
127
  h,
127
128
  s,
128
129
  v,
@@ -156,7 +157,7 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
156
157
  value: h,
157
158
  minValue: 0,
158
159
  maxValue: 359,
159
- color: colorToHex8({
160
+ color: conversions.colorToHex8({
160
161
  h,
161
162
  s,
162
163
  v,
@@ -173,7 +174,7 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
173
174
  width: this._width,
174
175
  height: this._sliderHeight,
175
176
  indicatorRadius: this._sliderIndicatorRadius,
176
- color: colorToHex8({
177
+ color: conversions.colorToHex8({
177
178
  h,
178
179
  s,
179
180
  v
@@ -189,14 +190,14 @@ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
189
190
  disabled: disabled,
190
191
  label: withAlpha ? 'RGBA' : 'RGB',
191
192
  width: this._width,
192
- value: colorToRGB({
193
+ value: conversions.colorToRGB({
193
194
  h,
194
195
  s,
195
196
  v,
196
197
  a
197
198
  }),
198
199
  onChange: color => this.setState({
199
- ...colorToHsva(color)
200
+ ...conversions.colorToHsva(color)
200
201
  }),
201
202
  withAlpha: withAlpha,
202
203
  rgbRedInputScreenReaderLabel: rgbRedInputScreenReaderLabel,
@@ -30,7 +30,8 @@ import { withStyle, jsx } from '@instructure/emotion';
30
30
  import { warn, error } from '@instructure/console';
31
31
  import { omitProps } from '@instructure/ui-react-utils';
32
32
  import { testable } from '@instructure/ui-testable';
33
- import { colorToHex8, isValid, contrast as getContrast } from '@instructure/ui-color-utils';
33
+ import { isValid, contrast as getContrast } from '@instructure/ui-color-utils';
34
+ import conversions from '@instructure/ui-color-utils';
34
35
  import { TextInput } from '@instructure/ui-text-input';
35
36
  import { Tooltip } from '@instructure/ui-tooltip';
36
37
  import { Button, IconButton } from '@instructure/ui-buttons';
@@ -119,7 +120,7 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
119
120
  onChange = _this$props.onChange;
120
121
  return jsx("div", null, typeof children === 'function' && children(`#${this.mixedColorWithStrippedAlpha}`, newColor => {
121
122
  this.setState({
122
- mixedColor: colorToHex8(newColor).slice(1)
123
+ mixedColor: conversions.colorToHex8(newColor).slice(1)
123
124
  });
124
125
  }, () => {
125
126
  this.setState({
@@ -139,7 +140,7 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
139
140
  }, ((_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, {
140
141
  value: `#${this.state.mixedColor}`,
141
142
  onChange: newColor => this.setState({
142
- mixedColor: colorToHex8(newColor).slice(1)
143
+ mixedColor: conversions.colorToHex8(newColor).slice(1)
143
144
  }),
144
145
  withAlpha: this.props.colorMixerSettings.colorMixer.withAlpha,
145
146
  rgbRedInputScreenReaderLabel: this.props.colorMixerSettings.colorMixer.rgbRedInputScreenReaderLabel,
@@ -28,7 +28,7 @@ import { Component } from 'react';
28
28
  import { withStyle, jsx } from '@instructure/emotion';
29
29
  import { omitProps } from '@instructure/ui-react-utils';
30
30
  import { testable } from '@instructure/ui-testable';
31
- import { colorToHex8, colorToRGB } from '@instructure/ui-color-utils';
31
+ import conversions from '@instructure/ui-color-utils';
32
32
  import { IconButton, Button } from '@instructure/ui-buttons';
33
33
  import { View } from '@instructure/ui-view';
34
34
  import { Tooltip } from '@instructure/ui-tooltip';
@@ -99,9 +99,9 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
99
99
  }, jsx("div", {
100
100
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.popoverContent
101
101
  }, jsx(ColorMixer, {
102
- value: colorToHex8(this.state.newColor),
102
+ value: conversions.colorToHex8(this.state.newColor),
103
103
  onChange: newColor => this.setState({
104
- newColor: colorToRGB(newColor)
104
+ newColor: conversions.colorToRGB(newColor)
105
105
  }),
106
106
  withAlpha: (_this$props3 = this.props) === null || _this$props3 === void 0 ? void 0 : (_this$props3$colorMix = _this$props3.colorMixerSettings) === null || _this$props3$colorMix === void 0 ? void 0 : (_this$props3$colorMix2 = _this$props3$colorMix.colorMixer) === null || _this$props3$colorMix2 === void 0 ? void 0 : _this$props3$colorMix2.withAlpha,
107
107
  rgbRedInputScreenReaderLabel: this.props.colorMixerSettings.colorMixer.rgbRedInputScreenReaderLabel,
@@ -115,7 +115,7 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
115
115
  css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.popoverContrastBlock
116
116
  }, jsx(ColorContrast, {
117
117
  firstColor: this.props.colorMixerSettings.colorContrast.firstColor,
118
- secondColor: colorToHex8(this.state.newColor),
118
+ secondColor: conversions.colorToHex8(this.state.newColor),
119
119
  label: this.props.colorMixerSettings.colorContrast.label,
120
120
  successLabel: this.props.colorMixerSettings.colorContrast.successLabel,
121
121
  failureLabel: this.props.colorMixerSettings.colorContrast.failureLabel,
@@ -129,7 +129,7 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
129
129
  }, jsx(Button, {
130
130
  onClick: () => {
131
131
  var _this$props5, _this$props5$colorMix;
132
- (_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]);
132
+ (_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([conversions.colorToHex8(this.state.newColor), ...this.props.colors]);
133
133
  this.setState({
134
134
  openAddNew: false
135
135
  });
@@ -226,7 +226,7 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
226
226
  }
227
227
  isSelectedColor(color) {
228
228
  const selected = this.props.selected;
229
- return !!selected && colorToHex8(selected) === colorToHex8(color);
229
+ return !!selected && conversions.colorToHex8(selected) === conversions.colorToHex8(color);
230
230
  }
231
231
  render() {
232
232
  const _this$props9 = this.props,
@@ -11,6 +11,7 @@ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
11
11
  var _testable = require("@instructure/ui-testable/lib/testable.js");
12
12
  var _console = require("@instructure/console");
13
13
  var _contrast = require("@instructure/ui-color-utils/lib/contrast.js");
14
+ var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
14
15
  var _emotion = require("@instructure/emotion");
15
16
  var _Text = require("@instructure/ui-text/lib/Text");
16
17
  var _Pill = require("@instructure/ui-pill/lib/Pill");
@@ -130,8 +131,8 @@ let ColorContrast = exports.ColorContrast = (_dec = (0, _emotion.withStyle)(_sty
130
131
  //We project the firstColor onto an opaque white background, then we project the secondColor onto
131
132
  //the projected first color. We calculate the contrast of these two, projected colors.
132
133
  get calcContrast() {
133
- const c1RGBA = colorToRGB(this.props.firstColor);
134
- const c2RGBA = colorToRGB(this.props.secondColor);
134
+ const c1RGBA = _uiColorUtils.default.colorToRGB(this.props.firstColor);
135
+ const c2RGBA = _uiColorUtils.default.colorToRGB(this.props.secondColor);
135
136
  const c1OnWhite = this.calcBlendedColor({
136
137
  r: 255,
137
138
  g: 255,
@@ -139,7 +140,7 @@ let ColorContrast = exports.ColorContrast = (_dec = (0, _emotion.withStyle)(_sty
139
140
  a: 1
140
141
  }, c1RGBA);
141
142
  const c2OnC1OnWhite = this.calcBlendedColor(c1OnWhite, c2RGBA);
142
- return (0, _contrast.contrast)(colorToHex8(c1OnWhite), colorToHex8(c2OnC1OnWhite), 2);
143
+ return (0, _contrast.contrast)(_uiColorUtils.default.colorToHex8(c1OnWhite), _uiColorUtils.default.colorToHex8(c2OnC1OnWhite), 2);
143
144
  }
144
145
  render() {
145
146
  const _this$props5 = this.props,
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
8
+ var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
7
9
  var _isValid = require("@instructure/ui-color-utils/lib/isValid.js");
8
- var _uiColorUtils = require("@instructure/ui-color-utils");
9
10
  /*
10
11
  * The MIT License (MIT)
11
12
  *
@@ -67,7 +68,7 @@ const generateStyle = (componentTheme, props) => {
67
68
  backgroundImage: componentTheme.backgroundImage,
68
69
  backgroundSize: componentTheme.backgroundSize,
69
70
  backgroundPosition: componentTheme.backgroundPosition,
70
- borderColor: calcBlendedColor((0, _uiColorUtils.colorToRGB)(componentTheme.colorIndicatorBorderColor), (0, _uiColorUtils.colorToRGB)((0, _isValid.isValid)(color) ? color : '#fff'))
71
+ borderColor: calcBlendedColor(_uiColorUtils.default.colorToRGB(componentTheme.colorIndicatorBorderColor), _uiColorUtils.default.colorToRGB((0, _isValid.isValid)(color) ? color : '#fff'))
71
72
  }
72
73
  };
73
74
  };
@@ -10,6 +10,7 @@ var _emotion = require("@instructure/emotion");
10
10
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
11
11
  var _testable = require("@instructure/ui-testable/lib/testable.js");
12
12
  var _isValid = require("@instructure/ui-color-utils/lib/isValid.js");
13
+ var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
13
14
  var _console = require("@instructure/console");
14
15
  var _ColorPalette = _interopRequireDefault(require("./ColorPalette"));
15
16
  var _Slider = _interopRequireDefault(require("./Slider"));
@@ -74,7 +75,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
74
75
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
75
76
  (0, _console.logWarn)((0, _isValid.isValid)(this.props.value), `[ColorMixer] The passed color value is not valid.`);
76
77
  this.setState({
77
- ...colorToHsva(this.props.value)
78
+ ..._uiColorUtils.default.colorToHsva(this.props.value)
78
79
  });
79
80
  }
80
81
  componentDidUpdate(prevProps, prevState) {
@@ -86,21 +87,21 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
86
87
  v = _this$state.v,
87
88
  a = _this$state.a;
88
89
  if (prevState.h !== h || prevState.s !== s || prevState.v !== v || prevState.a !== a) {
89
- this.props.onChange(colorToHex8({
90
+ this.props.onChange(_uiColorUtils.default.colorToHex8({
90
91
  h,
91
92
  s,
92
93
  v,
93
94
  a
94
95
  }));
95
96
  }
96
- if (prevProps.value !== this.props.value && colorToHex8({
97
+ if (prevProps.value !== this.props.value && _uiColorUtils.default.colorToHex8({
97
98
  h,
98
99
  s,
99
100
  v,
100
101
  a
101
102
  }) !== this.props.value) {
102
103
  this.setState({
103
- ...colorToHsva(this.props.value)
104
+ ..._uiColorUtils.default.colorToHsva(this.props.value)
104
105
  });
105
106
  }
106
107
  }
@@ -127,7 +128,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
127
128
  css: styles === null || styles === void 0 ? void 0 : styles.colorMixer
128
129
  }), (0, _emotion.jsx)("span", {
129
130
  css: styles === null || styles === void 0 ? void 0 : styles.sliderAndPaletteContainer,
130
- "aria-label": `${colorToHex8({
131
+ "aria-label": `${_uiColorUtils.default.colorToHex8({
131
132
  h,
132
133
  s,
133
134
  v,
@@ -161,7 +162,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
161
162
  value: h,
162
163
  minValue: 0,
163
164
  maxValue: 359,
164
- color: colorToHex8({
165
+ color: _uiColorUtils.default.colorToHex8({
165
166
  h,
166
167
  s,
167
168
  v,
@@ -178,7 +179,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
178
179
  width: this._width,
179
180
  height: this._sliderHeight,
180
181
  indicatorRadius: this._sliderIndicatorRadius,
181
- color: colorToHex8({
182
+ color: _uiColorUtils.default.colorToHex8({
182
183
  h,
183
184
  s,
184
185
  v
@@ -194,14 +195,14 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
194
195
  disabled: disabled,
195
196
  label: withAlpha ? 'RGBA' : 'RGB',
196
197
  width: this._width,
197
- value: colorToRGB({
198
+ value: _uiColorUtils.default.colorToRGB({
198
199
  h,
199
200
  s,
200
201
  v,
201
202
  a
202
203
  }),
203
204
  onChange: color => this.setState({
204
- ...colorToHsva(color)
205
+ ..._uiColorUtils.default.colorToHsva(color)
205
206
  }),
206
207
  withAlpha: withAlpha,
207
208
  rgbRedInputScreenReaderLabel: rgbRedInputScreenReaderLabel,
@@ -13,6 +13,7 @@ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
13
13
  var _testable = require("@instructure/ui-testable/lib/testable.js");
14
14
  var _isValid = require("@instructure/ui-color-utils/lib/isValid.js");
15
15
  var _contrast = require("@instructure/ui-color-utils/lib/contrast.js");
16
+ var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
16
17
  var _TextInput = require("@instructure/ui-text-input/lib/TextInput");
17
18
  var _Tooltip = require("@instructure/ui-tooltip/lib/Tooltip");
18
19
  var _Button = require("@instructure/ui-buttons/lib/Button");
@@ -131,7 +132,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
131
132
  onChange = _this$props.onChange;
132
133
  return (0, _emotion.jsx)("div", null, typeof children === 'function' && children(`#${this.mixedColorWithStrippedAlpha}`, newColor => {
133
134
  this.setState({
134
- mixedColor: colorToHex8(newColor).slice(1)
135
+ mixedColor: _uiColorUtils.default.colorToHex8(newColor).slice(1)
135
136
  });
136
137
  }, () => {
137
138
  this.setState({
@@ -151,7 +152,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
151
152
  }, ((_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) && (0, _emotion.jsx)(_ColorMixer.default, {
152
153
  value: `#${this.state.mixedColor}`,
153
154
  onChange: newColor => this.setState({
154
- mixedColor: colorToHex8(newColor).slice(1)
155
+ mixedColor: _uiColorUtils.default.colorToHex8(newColor).slice(1)
155
156
  }),
156
157
  withAlpha: this.props.colorMixerSettings.colorMixer.withAlpha,
157
158
  rgbRedInputScreenReaderLabel: this.props.colorMixerSettings.colorMixer.rgbRedInputScreenReaderLabel,
@@ -9,7 +9,7 @@ var _react = require("react");
9
9
  var _emotion = require("@instructure/emotion");
10
10
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
11
11
  var _testable = require("@instructure/ui-testable/lib/testable.js");
12
- var _uiColorUtils = require("@instructure/ui-color-utils");
12
+ var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
13
13
  var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
14
14
  var _Button = require("@instructure/ui-buttons/lib/Button");
15
15
  var _View = require("@instructure/ui-view/lib/View");
@@ -106,9 +106,9 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
106
106
  }, (0, _emotion.jsx)("div", {
107
107
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.popoverContent
108
108
  }, (0, _emotion.jsx)(_ColorMixer.ColorMixer, {
109
- value: (0, _uiColorUtils.colorToHex8)(this.state.newColor),
109
+ value: _uiColorUtils.default.colorToHex8(this.state.newColor),
110
110
  onChange: newColor => this.setState({
111
- newColor: (0, _uiColorUtils.colorToRGB)(newColor)
111
+ newColor: _uiColorUtils.default.colorToRGB(newColor)
112
112
  }),
113
113
  withAlpha: (_this$props3 = this.props) === null || _this$props3 === void 0 ? void 0 : (_this$props3$colorMix = _this$props3.colorMixerSettings) === null || _this$props3$colorMix === void 0 ? void 0 : (_this$props3$colorMix2 = _this$props3$colorMix.colorMixer) === null || _this$props3$colorMix2 === void 0 ? void 0 : _this$props3$colorMix2.withAlpha,
114
114
  rgbRedInputScreenReaderLabel: this.props.colorMixerSettings.colorMixer.rgbRedInputScreenReaderLabel,
@@ -122,7 +122,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
122
122
  css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.popoverContrastBlock
123
123
  }, (0, _emotion.jsx)(_ColorContrast.ColorContrast, {
124
124
  firstColor: this.props.colorMixerSettings.colorContrast.firstColor,
125
- secondColor: (0, _uiColorUtils.colorToHex8)(this.state.newColor),
125
+ secondColor: _uiColorUtils.default.colorToHex8(this.state.newColor),
126
126
  label: this.props.colorMixerSettings.colorContrast.label,
127
127
  successLabel: this.props.colorMixerSettings.colorContrast.successLabel,
128
128
  failureLabel: this.props.colorMixerSettings.colorContrast.failureLabel,
@@ -136,7 +136,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
136
136
  }, (0, _emotion.jsx)(_Button.Button, {
137
137
  onClick: () => {
138
138
  var _this$props5, _this$props5$colorMix;
139
- (_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([(0, _uiColorUtils.colorToHex8)(this.state.newColor), ...this.props.colors]);
139
+ (_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([_uiColorUtils.default.colorToHex8(this.state.newColor), ...this.props.colors]);
140
140
  this.setState({
141
141
  openAddNew: false
142
142
  });
@@ -233,7 +233,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
233
233
  }
234
234
  isSelectedColor(color) {
235
235
  const selected = this.props.selected;
236
- return !!selected && (0, _uiColorUtils.colorToHex8)(selected) === (0, _uiColorUtils.colorToHex8)(color);
236
+ return !!selected && _uiColorUtils.default.colorToHex8(selected) === _uiColorUtils.default.colorToHex8(color);
237
237
  }
238
238
  render() {
239
239
  const _this$props9 = this.props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-color-picker",
3
- "version": "8.56.1",
3
+ "version": "8.56.2-snapshot-2",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,33 +24,33 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.23.2",
27
- "@instructure/console": "8.56.1",
28
- "@instructure/emotion": "8.56.1",
29
- "@instructure/shared-types": "8.56.1",
30
- "@instructure/ui-a11y-content": "8.56.1",
31
- "@instructure/ui-buttons": "8.56.1",
32
- "@instructure/ui-color-utils": "8.56.1",
33
- "@instructure/ui-dom-utils": "8.56.1",
34
- "@instructure/ui-drilldown": "8.56.1",
35
- "@instructure/ui-form-field": "8.56.1",
36
- "@instructure/ui-icons": "8.56.1",
37
- "@instructure/ui-pill": "8.56.1",
38
- "@instructure/ui-popover": "8.56.1",
39
- "@instructure/ui-react-utils": "8.56.1",
40
- "@instructure/ui-testable": "8.56.1",
41
- "@instructure/ui-text": "8.56.1",
42
- "@instructure/ui-text-input": "8.56.1",
43
- "@instructure/ui-themes": "8.56.1",
44
- "@instructure/ui-tooltip": "8.56.1",
45
- "@instructure/ui-utils": "8.56.1",
46
- "@instructure/ui-view": "8.56.1",
27
+ "@instructure/console": "8.56.2-snapshot-2",
28
+ "@instructure/emotion": "8.56.2-snapshot-2",
29
+ "@instructure/shared-types": "8.56.2-snapshot-2",
30
+ "@instructure/ui-a11y-content": "8.56.2-snapshot-2",
31
+ "@instructure/ui-buttons": "8.56.2-snapshot-2",
32
+ "@instructure/ui-color-utils": "8.56.2-snapshot-2",
33
+ "@instructure/ui-dom-utils": "8.56.2-snapshot-2",
34
+ "@instructure/ui-drilldown": "8.56.2-snapshot-2",
35
+ "@instructure/ui-form-field": "8.56.2-snapshot-2",
36
+ "@instructure/ui-icons": "8.56.2-snapshot-2",
37
+ "@instructure/ui-pill": "8.56.2-snapshot-2",
38
+ "@instructure/ui-popover": "8.56.2-snapshot-2",
39
+ "@instructure/ui-react-utils": "8.56.2-snapshot-2",
40
+ "@instructure/ui-testable": "8.56.2-snapshot-2",
41
+ "@instructure/ui-text": "8.56.2-snapshot-2",
42
+ "@instructure/ui-text-input": "8.56.2-snapshot-2",
43
+ "@instructure/ui-themes": "8.56.2-snapshot-2",
44
+ "@instructure/ui-tooltip": "8.56.2-snapshot-2",
45
+ "@instructure/ui-utils": "8.56.2-snapshot-2",
46
+ "@instructure/ui-view": "8.56.2-snapshot-2",
47
47
  "prop-types": "^15.8.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@instructure/ui-babel-preset": "8.56.1",
51
- "@instructure/ui-test-locator": "8.56.1",
52
- "@instructure/ui-test-queries": "8.56.1",
53
- "@instructure/ui-test-utils": "8.56.1"
50
+ "@instructure/ui-babel-preset": "8.56.2-snapshot-2",
51
+ "@instructure/ui-test-locator": "8.56.2-snapshot-2",
52
+ "@instructure/ui-test-queries": "8.56.2-snapshot-2",
53
+ "@instructure/ui-test-utils": "8.56.2-snapshot-2"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": ">=16.8 <=18"
@@ -29,11 +29,8 @@ import React, { Component } from 'react'
29
29
  import { omitProps } from '@instructure/ui-react-utils'
30
30
  import { testable } from '@instructure/ui-testable'
31
31
  import { error } from '@instructure/console'
32
- import {
33
- contrast as getContrast,
34
- colorToRGB,
35
- colorToHex8
36
- } from '@instructure/ui-color-utils'
32
+ import { contrast as getContrast } from '@instructure/ui-color-utils'
33
+ import conversions from '@instructure/ui-color-utils'
37
34
  import type { RGBAType } from '@instructure/ui-color-utils'
38
35
  import { withStyle, jsx } from '@instructure/emotion'
39
36
 
@@ -169,15 +166,19 @@ class ColorContrast extends Component<ColorContrastProps> {
169
166
  //We project the firstColor onto an opaque white background, then we project the secondColor onto
170
167
  //the projected first color. We calculate the contrast of these two, projected colors.
171
168
  get calcContrast() {
172
- const c1RGBA = colorToRGB(this.props.firstColor)
173
- const c2RGBA = colorToRGB(this.props.secondColor)
169
+ const c1RGBA = conversions.colorToRGB(this.props.firstColor)
170
+ const c2RGBA = conversions.colorToRGB(this.props.secondColor)
174
171
  const c1OnWhite = this.calcBlendedColor(
175
172
  { r: 255, g: 255, b: 255, a: 1 },
176
173
  c1RGBA
177
174
  )
178
175
  const c2OnC1OnWhite = this.calcBlendedColor(c1OnWhite, c2RGBA)
179
176
 
180
- return getContrast(colorToHex8(c1OnWhite), colorToHex8(c2OnC1OnWhite), 2)
177
+ return getContrast(
178
+ conversions.colorToHex8(c1OnWhite),
179
+ conversions.colorToHex8(c2OnC1OnWhite),
180
+ 2
181
+ )
181
182
  }
182
183
 
183
184
  render() {
@@ -25,8 +25,8 @@
25
25
  import type { ColorIndicatorProps, ColorIndicatorStyle } from './props'
26
26
  import type { ColorIndicatorTheme } from '@instructure/shared-types'
27
27
  import type { RGBAType } from '@instructure/ui-color-utils'
28
+ import conversions from '@instructure/ui-color-utils'
28
29
  import { isValid } from '@instructure/ui-color-utils'
29
- import { colorToRGB } from '@instructure/ui-color-utils'
30
30
 
31
31
  const calcBlendedColor = (c1: RGBAType, c2: RGBAType) => {
32
32
  // 0.4 as decided by design
@@ -79,8 +79,8 @@ const generateStyle = (
79
79
  backgroundSize: componentTheme.backgroundSize,
80
80
  backgroundPosition: componentTheme.backgroundPosition,
81
81
  borderColor: calcBlendedColor(
82
- colorToRGB(componentTheme.colorIndicatorBorderColor),
83
- colorToRGB(isValid(color!) ? color! : '#fff')
82
+ conversions.colorToRGB(componentTheme.colorIndicatorBorderColor),
83
+ conversions.colorToRGB(isValid(color!) ? color! : '#fff')
84
84
  )
85
85
  }
86
86
  }
@@ -28,12 +28,8 @@ import { Component } from 'react'
28
28
  import { withStyle, jsx } from '@instructure/emotion'
29
29
  import { omitProps } from '@instructure/ui-react-utils'
30
30
  import { testable } from '@instructure/ui-testable'
31
- import {
32
- colorToHex8,
33
- colorToHsva,
34
- colorToRGB,
35
- isValid
36
- } from '@instructure/ui-color-utils'
31
+ import { isValid } from '@instructure/ui-color-utils'
32
+ import conversions from '@instructure/ui-color-utils'
37
33
  import { logWarn as warn } from '@instructure/console'
38
34
  import type { HSVType } from '@instructure/ui-color-utils'
39
35
  import ColorPalette from './ColorPalette'
@@ -97,7 +93,7 @@ class ColorMixer extends Component<ColorMixerProps, ColorMixerState> {
97
93
  `[ColorMixer] The passed color value is not valid.`
98
94
  )
99
95
  this.setState({
100
- ...colorToHsva(this.props.value!)
96
+ ...conversions.colorToHsva(this.props.value!)
101
97
  })
102
98
  }
103
99
 
@@ -110,14 +106,14 @@ class ColorMixer extends Component<ColorMixerProps, ColorMixerState> {
110
106
  prevState.v !== v ||
111
107
  prevState.a !== a
112
108
  ) {
113
- this.props.onChange(colorToHex8({ h, s, v, a }))
109
+ this.props.onChange(conversions.colorToHex8({ h, s, v, a }))
114
110
  }
115
111
  if (
116
112
  prevProps.value !== this.props.value &&
117
- colorToHex8({ h, s, v, a }) !== this.props.value
113
+ conversions.colorToHex8({ h, s, v, a }) !== this.props.value
118
114
  ) {
119
115
  this.setState({
120
- ...colorToHsva(this.props.value!)
116
+ ...conversions.colorToHsva(this.props.value!)
121
117
  })
122
118
  }
123
119
  }
@@ -147,7 +143,7 @@ class ColorMixer extends Component<ColorMixerProps, ColorMixerState> {
147
143
  >
148
144
  <span
149
145
  css={styles?.sliderAndPaletteContainer}
150
- aria-label={`${colorToHex8({ h, s, v, a })}`}
146
+ aria-label={`${conversions.colorToHex8({ h, s, v, a })}`}
151
147
  aria-live="polite"
152
148
  >
153
149
  <ColorPalette
@@ -177,7 +173,7 @@ class ColorMixer extends Component<ColorMixerProps, ColorMixerState> {
177
173
  value={h}
178
174
  minValue={0}
179
175
  maxValue={359}
180
- color={colorToHex8({ h, s, v, a })}
176
+ color={conversions.colorToHex8({ h, s, v, a })}
181
177
  onChange={(hue: number) => {
182
178
  this.setState({ h: hue })
183
179
  }}
@@ -191,7 +187,7 @@ class ColorMixer extends Component<ColorMixerProps, ColorMixerState> {
191
187
  width={this._width}
192
188
  height={this._sliderHeight}
193
189
  indicatorRadius={this._sliderIndicatorRadius}
194
- color={colorToHex8({ h, s, v })}
190
+ color={conversions.colorToHex8({ h, s, v })}
195
191
  value={a}
196
192
  minValue={0}
197
193
  maxValue={1}
@@ -206,8 +202,10 @@ class ColorMixer extends Component<ColorMixerProps, ColorMixerState> {
206
202
  disabled={disabled}
207
203
  label={withAlpha ? 'RGBA' : 'RGB'}
208
204
  width={this._width}
209
- value={colorToRGB({ h, s, v, a })}
210
- onChange={(color) => this.setState({ ...colorToHsva(color) })}
205
+ value={conversions.colorToRGB({ h, s, v, a })}
206
+ onChange={(color) =>
207
+ this.setState({ ...conversions.colorToHsva(color) })
208
+ }
211
209
  withAlpha={withAlpha}
212
210
  rgbRedInputScreenReaderLabel={rgbRedInputScreenReaderLabel}
213
211
  rgbGreenInputScreenReaderLabel={rgbGreenInputScreenReaderLabel}