@instructure/ui-color-picker 11.7.8 → 11.7.9-snapshot-1
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/ColorIndicator/v1/styles.js +2 -3
- package/es/ColorIndicator/v2/styles.js +2 -3
- package/es/ColorMixer/v1/index.js +10 -11
- package/es/ColorMixer/v2/index.js +10 -11
- package/es/ColorPicker/v1/index.js +3 -4
- package/es/ColorPicker/v2/index.js +3 -4
- package/es/ColorPreset/v1/index.js +6 -6
- package/es/ColorPreset/v2/index.js +6 -6
- package/lib/ColorContrast/v1/index.js +5 -6
- package/lib/ColorContrast/v2/index.js +5 -6
- package/lib/ColorIndicator/v1/index.js +2 -2
- package/lib/ColorIndicator/v1/styles.js +2 -4
- package/lib/ColorIndicator/v2/index.js +2 -2
- package/lib/ColorIndicator/v2/styles.js +2 -4
- package/lib/ColorMixer/v1/ColorPalette/index.js +7 -7
- package/lib/ColorMixer/v1/ColorPalette/styles.js +3 -3
- package/lib/ColorMixer/v1/RGBAInput/index.js +5 -5
- package/lib/ColorMixer/v1/Slider/index.js +3 -3
- package/lib/ColorMixer/v1/index.js +13 -14
- package/lib/ColorMixer/v2/ColorPalette/index.js +7 -7
- package/lib/ColorMixer/v2/ColorPalette/styles.js +3 -3
- package/lib/ColorMixer/v2/RGBAInput/index.js +5 -5
- package/lib/ColorMixer/v2/Slider/index.js +3 -3
- package/lib/ColorMixer/v2/index.js +13 -14
- package/lib/ColorPicker/v1/index.js +14 -19
- package/lib/ColorPicker/v2/index.js +10 -12
- package/lib/ColorPreset/v1/index.js +11 -12
- package/lib/ColorPreset/v2/index.js +8 -8
- package/package.json +24 -24
- package/src/ColorIndicator/v1/styles.ts +3 -4
- package/src/ColorIndicator/v2/styles.ts +3 -4
- package/src/ColorMixer/v1/index.tsx +15 -13
- package/src/ColorMixer/v2/index.tsx +15 -13
- package/src/ColorPicker/v1/index.tsx +7 -4
- package/src/ColorPicker/v2/index.tsx +7 -4
- package/src/ColorPreset/v1/index.tsx +6 -9
- package/src/ColorPreset/v2/index.tsx +6 -9
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ColorIndicator/v1/styles.d.ts.map +1 -1
- package/types/ColorIndicator/v2/styles.d.ts.map +1 -1
- package/types/ColorMixer/v1/index.d.ts.map +1 -1
- package/types/ColorMixer/v2/index.d.ts.map +1 -1
- package/types/ColorPicker/v1/index.d.ts.map +1 -1
- package/types/ColorPicker/v2/index.d.ts.map +1 -1
- package/types/ColorPreset/v1/index.d.ts.map +1 -1
- package/types/ColorPreset/v2/index.d.ts.map +1 -1
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var
|
|
9
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
10
10
|
var _emotion = require("@instructure/emotion");
|
|
11
11
|
var _v11_ = require("@instructure/ui-view/v11_6");
|
|
12
12
|
var _props = require("./props.js");
|
|
@@ -103,8 +103,8 @@ let Slider = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
103
103
|
e.currentTarget.focus();
|
|
104
104
|
}
|
|
105
105
|
this.handleChange(e);
|
|
106
|
-
this._mouseMoveListener = (0,
|
|
107
|
-
this._mouseUpListener = (0,
|
|
106
|
+
this._mouseMoveListener = (0, _uiDomUtils.addEventListener)(window, 'mousemove', this.handleChange);
|
|
107
|
+
this._mouseUpListener = (0, _uiDomUtils.addEventListener)(window, 'mouseup', this.handleMouseUp);
|
|
108
108
|
}
|
|
109
109
|
handleChange = e => {
|
|
110
110
|
if (this.props.disabled) return;
|
|
@@ -7,9 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.ColorMixer = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
|
|
10
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
11
|
+
var _uiColorUtils = require("@instructure/ui-color-utils");
|
|
13
12
|
var _console = require("@instructure/console");
|
|
14
13
|
var _index = _interopRequireDefault(require("./ColorPalette/index.js"));
|
|
15
14
|
var _index2 = _interopRequireDefault(require("./Slider/index.js"));
|
|
@@ -81,9 +80,9 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
81
80
|
};
|
|
82
81
|
componentDidMount() {
|
|
83
82
|
this.props.makeStyles?.();
|
|
84
|
-
(0, _console.logWarn)((0,
|
|
83
|
+
(0, _console.logWarn)((0, _uiColorUtils.isValid)(this.props.value), `[ColorMixer] The passed color value is not valid.`);
|
|
85
84
|
this.setState({
|
|
86
|
-
..._uiColorUtils.
|
|
85
|
+
...(0, _uiColorUtils.colorToHsva)(this.props.value)
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
88
|
componentDidUpdate(prevProps, prevState) {
|
|
@@ -95,21 +94,21 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
95
94
|
a
|
|
96
95
|
} = this.state;
|
|
97
96
|
if (prevState.h !== h || prevState.s !== s || prevState.v !== v || prevState.a !== a) {
|
|
98
|
-
this.props.onChange(_uiColorUtils.
|
|
97
|
+
this.props.onChange((0, _uiColorUtils.colorToHex8)({
|
|
99
98
|
h,
|
|
100
99
|
s,
|
|
101
100
|
v,
|
|
102
101
|
a
|
|
103
102
|
}));
|
|
104
103
|
}
|
|
105
|
-
if (prevProps.value !== this.props.value && _uiColorUtils.
|
|
104
|
+
if (prevProps.value !== this.props.value && (0, _uiColorUtils.colorToHex8)({
|
|
106
105
|
h,
|
|
107
106
|
s,
|
|
108
107
|
v,
|
|
109
108
|
a
|
|
110
109
|
}) !== this.props.value) {
|
|
111
110
|
this.setState({
|
|
112
|
-
..._uiColorUtils.
|
|
111
|
+
...(0, _uiColorUtils.colorToHsva)(this.props.value)
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
}
|
|
@@ -133,14 +132,14 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
133
132
|
a
|
|
134
133
|
} = this.state;
|
|
135
134
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
136
|
-
...(0,
|
|
135
|
+
...(0, _uiReactUtils.omitProps)(this.props, ColorMixer.allowedProps),
|
|
137
136
|
"aria-disabled": disabled,
|
|
138
137
|
ref: this.handleRef,
|
|
139
138
|
css: styles?.colorMixer,
|
|
140
139
|
"data-cid": "ColorMixer",
|
|
141
140
|
children: [(0, _jsxRuntime.jsxs)("span", {
|
|
142
141
|
css: styles?.sliderAndPaletteContainer,
|
|
143
|
-
"aria-label": `${_uiColorUtils.
|
|
142
|
+
"aria-label": `${(0, _uiColorUtils.colorToHex8)({
|
|
144
143
|
h,
|
|
145
144
|
s,
|
|
146
145
|
v,
|
|
@@ -174,7 +173,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
174
173
|
value: h,
|
|
175
174
|
minValue: 0,
|
|
176
175
|
maxValue: 359,
|
|
177
|
-
color: _uiColorUtils.
|
|
176
|
+
color: (0, _uiColorUtils.colorToHex8)({
|
|
178
177
|
h,
|
|
179
178
|
s,
|
|
180
179
|
v,
|
|
@@ -191,7 +190,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
191
190
|
width: this._width,
|
|
192
191
|
height: this._sliderHeight,
|
|
193
192
|
indicatorRadius: this._sliderIndicatorRadius,
|
|
194
|
-
color: _uiColorUtils.
|
|
193
|
+
color: (0, _uiColorUtils.colorToHex8)({
|
|
195
194
|
h,
|
|
196
195
|
s,
|
|
197
196
|
v
|
|
@@ -208,14 +207,14 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
208
207
|
disabled: disabled,
|
|
209
208
|
label: withAlpha ? 'RGBA' : 'RGB',
|
|
210
209
|
width: this._width,
|
|
211
|
-
value: _uiColorUtils.
|
|
210
|
+
value: (0, _uiColorUtils.colorToRGB)({
|
|
212
211
|
h,
|
|
213
212
|
s,
|
|
214
213
|
v,
|
|
215
214
|
a
|
|
216
215
|
}),
|
|
217
216
|
onChange: color => this.setState({
|
|
218
|
-
..._uiColorUtils.
|
|
217
|
+
...(0, _uiColorUtils.colorToHsva)(color)
|
|
219
218
|
}),
|
|
220
219
|
withAlpha: withAlpha,
|
|
221
220
|
rgbRedInputScreenReaderLabel: rgbRedInputScreenReaderLabel,
|
|
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
|
-
var
|
|
10
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
11
11
|
var _latest = require("@instructure/ui-view/latest");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var _uiUtils = require("@instructure/ui-utils");
|
|
13
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
14
14
|
var _shallowCompare = _interopRequireDefault(require("../utils/shallowCompare.js"));
|
|
15
15
|
var _props = require("./props.js");
|
|
16
16
|
var _styles = _interopRequireDefault(require("./styles.js"));
|
|
@@ -44,7 +44,7 @@ var _dec, _dec2, _class;
|
|
|
44
44
|
private: true
|
|
45
45
|
---
|
|
46
46
|
**/
|
|
47
|
-
let ColorPalette = (_dec = (0,
|
|
47
|
+
let ColorPalette = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyleNew)(_styles.default, 'Palette'), _dec(_class = _dec2(_class = class ColorPalette extends _react.Component {
|
|
48
48
|
static displayName = 'ColorPalette';
|
|
49
49
|
static allowedProps = _props.allowedProps;
|
|
50
50
|
static componentId = 'ColorMixer.Palette';
|
|
@@ -64,7 +64,7 @@ let ColorPalette = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec
|
|
|
64
64
|
_paletteRef = null;
|
|
65
65
|
_mouseMoveListener;
|
|
66
66
|
_mouseUpListener;
|
|
67
|
-
_paletteOffset = (0,
|
|
67
|
+
_paletteOffset = (0, _uiUtils.px)(this.props.styles?.paletteOffset);
|
|
68
68
|
handleRef = el => {
|
|
69
69
|
const {
|
|
70
70
|
elementRef
|
|
@@ -120,8 +120,8 @@ let ColorPalette = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec
|
|
|
120
120
|
e.currentTarget.focus();
|
|
121
121
|
}
|
|
122
122
|
this.handleChange(e);
|
|
123
|
-
this._mouseMoveListener = (0,
|
|
124
|
-
this._mouseUpListener = (0,
|
|
123
|
+
this._mouseMoveListener = (0, _uiDomUtils.addEventListener)(window, 'mousemove', this.handleChange);
|
|
124
|
+
this._mouseUpListener = (0, _uiDomUtils.addEventListener)(window, 'mouseup', this.handleMouseUp);
|
|
125
125
|
}
|
|
126
126
|
handleMouseUp = () => {
|
|
127
127
|
this.removeEventListeners();
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _uiUtils = require("@instructure/ui-utils");
|
|
8
8
|
/*
|
|
9
9
|
* The MIT License (MIT)
|
|
10
10
|
*
|
|
@@ -54,8 +54,8 @@ const generateStyle = (componentTheme, props, _sharedTokens, state) => {
|
|
|
54
54
|
borderStyle: 'solid',
|
|
55
55
|
borderWidth: componentTheme.indicatorBorderWidth,
|
|
56
56
|
borderColor: componentTheme.indicatorBorderColor,
|
|
57
|
-
top: `${state?.colorPosition?.y - (0,
|
|
58
|
-
left: `${state?.colorPosition?.x - (0,
|
|
57
|
+
top: `${state?.colorPosition?.y - (0, _uiUtils.px)(`${props.indicatorRadius / 16}rem`)}px`,
|
|
58
|
+
left: `${state?.colorPosition?.x - (0, _uiUtils.px)(`${props.indicatorRadius / 16}rem`)}px`
|
|
59
59
|
},
|
|
60
60
|
palette: {
|
|
61
61
|
label: 'ColorPalette__palette',
|
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
10
|
var _shallowCompare = _interopRequireDefault(require("../utils/shallowCompare.js"));
|
|
11
|
-
var
|
|
11
|
+
var _uiA11yContent = require("@instructure/ui-a11y-content");
|
|
12
12
|
var _latest = require("@instructure/ui-text-input/latest");
|
|
13
13
|
var _props = require("./props.js");
|
|
14
14
|
var _styles = _interopRequireDefault(require("./styles.js"));
|
|
@@ -113,7 +113,7 @@ let RGBAInput = (_dec = (0, _emotion.withStyleNew)(_styles.default, 'RgbaInput')
|
|
|
113
113
|
disabled: disabled,
|
|
114
114
|
value: `${this.state.value.r}`,
|
|
115
115
|
onChange: e => this.handleChange('r', e),
|
|
116
|
-
renderLabel: (0, _jsxRuntime.jsx)(
|
|
116
|
+
renderLabel: (0, _jsxRuntime.jsx)(_uiA11yContent.ScreenReaderContent, {
|
|
117
117
|
children: this.props.rgbRedInputScreenReaderLabel
|
|
118
118
|
})
|
|
119
119
|
})
|
|
@@ -123,7 +123,7 @@ let RGBAInput = (_dec = (0, _emotion.withStyleNew)(_styles.default, 'RgbaInput')
|
|
|
123
123
|
disabled: disabled,
|
|
124
124
|
value: `${this.state.value.g}`,
|
|
125
125
|
onChange: e => this.handleChange('g', e),
|
|
126
|
-
renderLabel: (0, _jsxRuntime.jsx)(
|
|
126
|
+
renderLabel: (0, _jsxRuntime.jsx)(_uiA11yContent.ScreenReaderContent, {
|
|
127
127
|
children: this.props.rgbGreenInputScreenReaderLabel
|
|
128
128
|
})
|
|
129
129
|
})
|
|
@@ -133,7 +133,7 @@ let RGBAInput = (_dec = (0, _emotion.withStyleNew)(_styles.default, 'RgbaInput')
|
|
|
133
133
|
disabled: disabled,
|
|
134
134
|
value: `${this.state.value.b}`,
|
|
135
135
|
onChange: e => this.handleChange('b', e),
|
|
136
|
-
renderLabel: (0, _jsxRuntime.jsx)(
|
|
136
|
+
renderLabel: (0, _jsxRuntime.jsx)(_uiA11yContent.ScreenReaderContent, {
|
|
137
137
|
children: this.props.rgbBlueInputScreenReaderLabel
|
|
138
138
|
})
|
|
139
139
|
})
|
|
@@ -149,7 +149,7 @@ let RGBAInput = (_dec = (0, _emotion.withStyleNew)(_styles.default, 'RgbaInput')
|
|
|
149
149
|
role: "presentation",
|
|
150
150
|
children: "%"
|
|
151
151
|
}),
|
|
152
|
-
renderLabel: (0, _jsxRuntime.jsx)(
|
|
152
|
+
renderLabel: (0, _jsxRuntime.jsx)(_uiA11yContent.ScreenReaderContent, {
|
|
153
153
|
children: this.props.rgbAlphaInputScreenReaderLabel
|
|
154
154
|
})
|
|
155
155
|
})
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var
|
|
9
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
10
10
|
var _emotion = require("@instructure/emotion");
|
|
11
11
|
var _latest = require("@instructure/ui-view/latest");
|
|
12
12
|
var _props = require("./props.js");
|
|
@@ -103,8 +103,8 @@ let Slider = (_dec = (0, _emotion.withStyleNew)(_styles.default, 'Slider'), _dec
|
|
|
103
103
|
e.currentTarget.focus();
|
|
104
104
|
}
|
|
105
105
|
this.handleChange(e);
|
|
106
|
-
this._mouseMoveListener = (0,
|
|
107
|
-
this._mouseUpListener = (0,
|
|
106
|
+
this._mouseMoveListener = (0, _uiDomUtils.addEventListener)(window, 'mousemove', this.handleChange);
|
|
107
|
+
this._mouseUpListener = (0, _uiDomUtils.addEventListener)(window, 'mouseup', this.handleMouseUp);
|
|
108
108
|
}
|
|
109
109
|
handleChange = e => {
|
|
110
110
|
if (this.props.disabled) return;
|
|
@@ -7,9 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.ColorMixer = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
|
|
10
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
11
|
+
var _uiColorUtils = require("@instructure/ui-color-utils");
|
|
13
12
|
var _console = require("@instructure/console");
|
|
14
13
|
var _index = _interopRequireDefault(require("./ColorPalette/index.js"));
|
|
15
14
|
var _index2 = _interopRequireDefault(require("./Slider/index.js"));
|
|
@@ -81,9 +80,9 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyleNew)(_styles
|
|
|
81
80
|
};
|
|
82
81
|
componentDidMount() {
|
|
83
82
|
this.props.makeStyles?.();
|
|
84
|
-
(0, _console.logWarn)((0,
|
|
83
|
+
(0, _console.logWarn)((0, _uiColorUtils.isValid)(this.props.value), `[ColorMixer] The passed color value is not valid.`);
|
|
85
84
|
this.setState({
|
|
86
|
-
..._uiColorUtils.
|
|
85
|
+
...(0, _uiColorUtils.colorToHsva)(this.props.value)
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
88
|
componentDidUpdate(prevProps, prevState) {
|
|
@@ -95,21 +94,21 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyleNew)(_styles
|
|
|
95
94
|
a
|
|
96
95
|
} = this.state;
|
|
97
96
|
if (prevState.h !== h || prevState.s !== s || prevState.v !== v || prevState.a !== a) {
|
|
98
|
-
this.props.onChange(_uiColorUtils.
|
|
97
|
+
this.props.onChange((0, _uiColorUtils.colorToHex8)({
|
|
99
98
|
h,
|
|
100
99
|
s,
|
|
101
100
|
v,
|
|
102
101
|
a
|
|
103
102
|
}));
|
|
104
103
|
}
|
|
105
|
-
if (prevProps.value !== this.props.value && _uiColorUtils.
|
|
104
|
+
if (prevProps.value !== this.props.value && (0, _uiColorUtils.colorToHex8)({
|
|
106
105
|
h,
|
|
107
106
|
s,
|
|
108
107
|
v,
|
|
109
108
|
a
|
|
110
109
|
}) !== this.props.value) {
|
|
111
110
|
this.setState({
|
|
112
|
-
..._uiColorUtils.
|
|
111
|
+
...(0, _uiColorUtils.colorToHsva)(this.props.value)
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
}
|
|
@@ -133,14 +132,14 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyleNew)(_styles
|
|
|
133
132
|
a
|
|
134
133
|
} = this.state;
|
|
135
134
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
136
|
-
...(0,
|
|
135
|
+
...(0, _uiReactUtils.omitProps)(this.props, ColorMixer.allowedProps),
|
|
137
136
|
"aria-disabled": disabled,
|
|
138
137
|
ref: this.handleRef,
|
|
139
138
|
css: styles?.colorMixer,
|
|
140
139
|
"data-cid": "ColorMixer",
|
|
141
140
|
children: [(0, _jsxRuntime.jsxs)("span", {
|
|
142
141
|
css: styles?.sliderAndPaletteContainer,
|
|
143
|
-
"aria-label": `${_uiColorUtils.
|
|
142
|
+
"aria-label": `${(0, _uiColorUtils.colorToHex8)({
|
|
144
143
|
h,
|
|
145
144
|
s,
|
|
146
145
|
v,
|
|
@@ -174,7 +173,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyleNew)(_styles
|
|
|
174
173
|
value: h,
|
|
175
174
|
minValue: 0,
|
|
176
175
|
maxValue: 359,
|
|
177
|
-
color: _uiColorUtils.
|
|
176
|
+
color: (0, _uiColorUtils.colorToHex8)({
|
|
178
177
|
h,
|
|
179
178
|
s,
|
|
180
179
|
v,
|
|
@@ -191,7 +190,7 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyleNew)(_styles
|
|
|
191
190
|
width: this._width,
|
|
192
191
|
height: this._sliderHeight,
|
|
193
192
|
indicatorRadius: this._sliderIndicatorRadius,
|
|
194
|
-
color: _uiColorUtils.
|
|
193
|
+
color: (0, _uiColorUtils.colorToHex8)({
|
|
195
194
|
h,
|
|
196
195
|
s,
|
|
197
196
|
v
|
|
@@ -208,14 +207,14 @@ let ColorMixer = exports.ColorMixer = (_dec = (0, _emotion.withStyleNew)(_styles
|
|
|
208
207
|
disabled: disabled,
|
|
209
208
|
label: withAlpha ? 'RGBA' : 'RGB',
|
|
210
209
|
width: this._width,
|
|
211
|
-
value: _uiColorUtils.
|
|
210
|
+
value: (0, _uiColorUtils.colorToRGB)({
|
|
212
211
|
h,
|
|
213
212
|
s,
|
|
214
213
|
v,
|
|
215
214
|
a
|
|
216
215
|
}),
|
|
217
216
|
onChange: color => this.setState({
|
|
218
|
-
..._uiColorUtils.
|
|
217
|
+
...(0, _uiColorUtils.colorToHsva)(color)
|
|
219
218
|
}),
|
|
220
219
|
withAlpha: withAlpha,
|
|
221
220
|
rgbRedInputScreenReaderLabel: rgbRedInputScreenReaderLabel,
|
|
@@ -8,18 +8,13 @@ exports.default = exports.ColorPicker = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
10
|
var _console = require("@instructure/console");
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var _contrast = require("@instructure/ui-color-utils/lib/contrast.js");
|
|
14
|
-
var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
|
|
11
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
12
|
+
var _uiColorUtils = require("@instructure/ui-color-utils");
|
|
15
13
|
var _v11_ = require("@instructure/ui-text-input/v11_6");
|
|
16
14
|
var _v11_2 = require("@instructure/ui-tooltip/v11_6");
|
|
17
15
|
var _v11_3 = require("@instructure/ui-buttons/v11_6");
|
|
18
16
|
var _v11_4 = require("@instructure/ui-popover/v11_6");
|
|
19
|
-
var
|
|
20
|
-
var _IconWarningLine = require("@instructure/ui-icons/lib/generated/IconWarningLine.js");
|
|
21
|
-
var _IconTroubleLine = require("@instructure/ui-icons/lib/generated/IconTroubleLine.js");
|
|
22
|
-
var _IconInfoLine = require("@instructure/ui-icons/lib/generated/IconInfoLine.js");
|
|
17
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
23
18
|
var _index = _interopRequireDefault(require("../../ColorIndicator/v1/index.js"));
|
|
24
19
|
var _index2 = _interopRequireDefault(require("../../ColorMixer/v1/index.js"));
|
|
25
20
|
var _index3 = _interopRequireDefault(require("../../ColorContrast/v1/index.js"));
|
|
@@ -230,7 +225,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
230
225
|
hexCode,
|
|
231
226
|
showHelperErrorMessages
|
|
232
227
|
} = this.state;
|
|
233
|
-
const isValidHex = (0,
|
|
228
|
+
const isValidHex = (0, _uiColorUtils.isValid)(hexCode);
|
|
234
229
|
const {
|
|
235
230
|
checkContrast,
|
|
236
231
|
renderMessages,
|
|
@@ -238,7 +233,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
238
233
|
renderIsRequiredMessage,
|
|
239
234
|
isRequired
|
|
240
235
|
} = this.props;
|
|
241
|
-
const contrast = isValidHex ? (0,
|
|
236
|
+
const contrast = isValidHex ? (0, _uiColorUtils.contrast)(this.props.checkContrast?.contrastAgainst || '#fff', hexCode, 2) : undefined;
|
|
242
237
|
const contrastStrength = checkContrast?.contrastStrength ? checkContrast.contrastStrength : 'mid';
|
|
243
238
|
const minContrast = this.getMinContrast(contrastStrength);
|
|
244
239
|
let invalidColorMessages = [];
|
|
@@ -295,18 +290,18 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
295
290
|
const {
|
|
296
291
|
hexCode
|
|
297
292
|
} = this.state;
|
|
298
|
-
if (checkContrast && (0,
|
|
299
|
-
const contrast = (0,
|
|
293
|
+
if (checkContrast && (0, _uiColorUtils.isValid)(hexCode)) {
|
|
294
|
+
const contrast = (0, _uiColorUtils.contrast)(checkContrast.contrastAgainst || '#fff', hexCode, 2);
|
|
300
295
|
const minContrast = this.getMinContrast(checkContrast.contrastStrength ? checkContrast.contrastStrength : 'mid');
|
|
301
296
|
if (minContrast >= contrast) {
|
|
302
297
|
return (0, _jsxRuntime.jsx)("div", {
|
|
303
298
|
css: styles?.errorIcons,
|
|
304
|
-
children: checkContrast.isStrict ? (0, _jsxRuntime.jsx)(
|
|
299
|
+
children: checkContrast.isStrict ? (0, _jsxRuntime.jsx)(_uiIcons.IconTroubleLine, {}) : (0, _jsxRuntime.jsx)(_uiIcons.IconWarningLine, {})
|
|
305
300
|
});
|
|
306
301
|
}
|
|
307
302
|
return (0, _jsxRuntime.jsx)("div", {
|
|
308
303
|
css: styles?.successIcon,
|
|
309
|
-
children: (0, _jsxRuntime.jsx)(
|
|
304
|
+
children: (0, _jsxRuntime.jsx)(_uiIcons.IconCheckDarkLine, {})
|
|
310
305
|
});
|
|
311
306
|
}
|
|
312
307
|
return null;
|
|
@@ -341,7 +336,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
341
336
|
const selectionStart = input.selectionStart ?? currentHex.length;
|
|
342
337
|
const selectionEnd = input.selectionEnd ?? currentHex.length;
|
|
343
338
|
const newHex = currentHex.slice(0, selectionStart) + toPaste + currentHex.slice(selectionEnd);
|
|
344
|
-
if ((0,
|
|
339
|
+
if ((0, _uiColorUtils.isValid)(newHex)) {
|
|
345
340
|
if (typeof this.props.onChange === 'function') {
|
|
346
341
|
this.props.onChange(`#${newHex}`);
|
|
347
342
|
} else {
|
|
@@ -389,7 +384,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
389
384
|
size: "small",
|
|
390
385
|
shape: "circle",
|
|
391
386
|
width: "auto",
|
|
392
|
-
renderIcon:
|
|
387
|
+
renderIcon: _uiIcons.IconInfoLine
|
|
393
388
|
})
|
|
394
389
|
})
|
|
395
390
|
})
|
|
@@ -440,7 +435,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
440
435
|
return (0, _jsxRuntime.jsx)("div", {
|
|
441
436
|
children: typeof children === 'function' && children(`#${this.mixedColorWithStrippedAlpha}`, newColor => {
|
|
442
437
|
this.setState({
|
|
443
|
-
mixedColor: _uiColorUtils.
|
|
438
|
+
mixedColor: (0, _uiColorUtils.colorToHex8)(newColor).slice(1)
|
|
444
439
|
});
|
|
445
440
|
}, () => {
|
|
446
441
|
this.setState({
|
|
@@ -462,7 +457,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
462
457
|
children: [this.props?.colorMixerSettings?.colorMixer && (0, _jsxRuntime.jsx)(_index2.default, {
|
|
463
458
|
value: `#${this.state.mixedColor}`,
|
|
464
459
|
onChange: newColor => this.setState({
|
|
465
|
-
mixedColor: _uiColorUtils.
|
|
460
|
+
mixedColor: (0, _uiColorUtils.colorToHex8)(newColor).slice(1)
|
|
466
461
|
}),
|
|
467
462
|
withAlpha: this.props.colorMixerSettings.colorMixer.withAlpha,
|
|
468
463
|
rgbRedInputScreenReaderLabel: this.props.colorMixerSettings.colorMixer.rgbRedInputScreenReaderLabel,
|
|
@@ -540,7 +535,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
540
535
|
inputRef
|
|
541
536
|
} = this.props;
|
|
542
537
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
543
|
-
...(0,
|
|
538
|
+
...(0, _uiReactUtils.omitProps)(this.props, ColorPicker.allowedProps),
|
|
544
539
|
css: this.props.styles?.colorPicker,
|
|
545
540
|
ref: this.handleRef,
|
|
546
541
|
"data-cid": "ColorPicker",
|
|
@@ -8,10 +8,8 @@ exports.default = exports.ColorPicker = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
10
|
var _console = require("@instructure/console");
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var _contrast = require("@instructure/ui-color-utils/lib/contrast.js");
|
|
14
|
-
var _uiColorUtils = _interopRequireDefault(require("@instructure/ui-color-utils"));
|
|
11
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
12
|
+
var _uiColorUtils = require("@instructure/ui-color-utils");
|
|
15
13
|
var _latest = require("@instructure/ui-text-input/latest");
|
|
16
14
|
var _latest2 = require("@instructure/ui-tooltip/latest");
|
|
17
15
|
var _latest3 = require("@instructure/ui-buttons/latest");
|
|
@@ -226,7 +224,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyleNew)(_styl
|
|
|
226
224
|
hexCode,
|
|
227
225
|
showHelperErrorMessages
|
|
228
226
|
} = this.state;
|
|
229
|
-
const isValidHex = (0,
|
|
227
|
+
const isValidHex = (0, _uiColorUtils.isValid)(hexCode);
|
|
230
228
|
const {
|
|
231
229
|
checkContrast,
|
|
232
230
|
renderMessages,
|
|
@@ -234,7 +232,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyleNew)(_styl
|
|
|
234
232
|
renderIsRequiredMessage,
|
|
235
233
|
isRequired
|
|
236
234
|
} = this.props;
|
|
237
|
-
const contrast = isValidHex ? (0,
|
|
235
|
+
const contrast = isValidHex ? (0, _uiColorUtils.contrast)(this.props.checkContrast?.contrastAgainst || '#fff', hexCode, 2) : undefined;
|
|
238
236
|
const contrastStrength = checkContrast?.contrastStrength ? checkContrast.contrastStrength : 'mid';
|
|
239
237
|
const minContrast = this.getMinContrast(contrastStrength);
|
|
240
238
|
let invalidColorMessages = [];
|
|
@@ -291,8 +289,8 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyleNew)(_styl
|
|
|
291
289
|
const {
|
|
292
290
|
hexCode
|
|
293
291
|
} = this.state;
|
|
294
|
-
if (checkContrast && (0,
|
|
295
|
-
const contrast = (0,
|
|
292
|
+
if (checkContrast && (0, _uiColorUtils.isValid)(hexCode)) {
|
|
293
|
+
const contrast = (0, _uiColorUtils.contrast)(checkContrast.contrastAgainst || '#fff', hexCode, 2);
|
|
296
294
|
const minContrast = this.getMinContrast(checkContrast.contrastStrength ? checkContrast.contrastStrength : 'mid');
|
|
297
295
|
if (minContrast >= contrast) {
|
|
298
296
|
return (0, _jsxRuntime.jsx)("div", {
|
|
@@ -343,7 +341,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyleNew)(_styl
|
|
|
343
341
|
const selectionStart = input.selectionStart ?? currentHex.length;
|
|
344
342
|
const selectionEnd = input.selectionEnd ?? currentHex.length;
|
|
345
343
|
const newHex = currentHex.slice(0, selectionStart) + toPaste + currentHex.slice(selectionEnd);
|
|
346
|
-
if ((0,
|
|
344
|
+
if ((0, _uiColorUtils.isValid)(newHex)) {
|
|
347
345
|
if (typeof this.props.onChange === 'function') {
|
|
348
346
|
this.props.onChange(`#${newHex}`);
|
|
349
347
|
} else {
|
|
@@ -444,7 +442,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyleNew)(_styl
|
|
|
444
442
|
return (0, _jsxRuntime.jsx)("div", {
|
|
445
443
|
children: typeof children === 'function' && children(`#${this.mixedColorWithStrippedAlpha}`, newColor => {
|
|
446
444
|
this.setState({
|
|
447
|
-
mixedColor: _uiColorUtils.
|
|
445
|
+
mixedColor: (0, _uiColorUtils.colorToHex8)(newColor).slice(1)
|
|
448
446
|
});
|
|
449
447
|
}, () => {
|
|
450
448
|
this.setState({
|
|
@@ -466,7 +464,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyleNew)(_styl
|
|
|
466
464
|
children: [this.props?.colorMixerSettings?.colorMixer && (0, _jsxRuntime.jsx)(_index2.default, {
|
|
467
465
|
value: `#${this.state.mixedColor}`,
|
|
468
466
|
onChange: newColor => this.setState({
|
|
469
|
-
mixedColor: _uiColorUtils.
|
|
467
|
+
mixedColor: (0, _uiColorUtils.colorToHex8)(newColor).slice(1)
|
|
470
468
|
}),
|
|
471
469
|
withAlpha: this.props.colorMixerSettings.colorMixer.withAlpha,
|
|
472
470
|
rgbRedInputScreenReaderLabel: this.props.colorMixerSettings.colorMixer.rgbRedInputScreenReaderLabel,
|
|
@@ -544,7 +542,7 @@ let ColorPicker = exports.ColorPicker = (_dec = (0, _emotion.withStyleNew)(_styl
|
|
|
544
542
|
inputRef
|
|
545
543
|
} = this.props;
|
|
546
544
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
547
|
-
...(0,
|
|
545
|
+
...(0, _uiReactUtils.omitProps)(this.props, ColorPicker.allowedProps),
|
|
548
546
|
css: this.props.styles?.colorPicker,
|
|
549
547
|
ref: this.handleRef,
|
|
550
548
|
"data-cid": "ColorPicker",
|
|
@@ -7,16 +7,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.ColorPreset = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
|
-
var
|
|
11
|
-
var _uiColorUtils =
|
|
10
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
11
|
+
var _uiColorUtils = require("@instructure/ui-color-utils");
|
|
12
12
|
var _v11_ = require("@instructure/ui-buttons/v11_6");
|
|
13
13
|
var _v11_2 = require("@instructure/ui-view/v11_6");
|
|
14
14
|
var _v11_3 = require("@instructure/ui-tooltip/v11_6");
|
|
15
15
|
var _v11_4 = require("@instructure/ui-popover/v11_6");
|
|
16
16
|
var _v11_5 = require("@instructure/ui-text/v11_6");
|
|
17
17
|
var _v11_6 = require("@instructure/ui-drilldown/v11_6");
|
|
18
|
-
var
|
|
19
|
-
var _IconCheckDarkSolid = require("@instructure/ui-icons/lib/generated/IconCheckDarkSolid.js");
|
|
18
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
20
19
|
var _index = require("../../ColorIndicator/v1/index.js");
|
|
21
20
|
var _index2 = require("../../ColorMixer/v1/index.js");
|
|
22
21
|
var _index3 = require("../../ColorContrast/v1/index.js");
|
|
@@ -96,7 +95,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
96
95
|
const {
|
|
97
96
|
selected
|
|
98
97
|
} = this.props;
|
|
99
|
-
return !!selected && _uiColorUtils.
|
|
98
|
+
return !!selected && (0, _uiColorUtils.colorToHex8)(selected) === (0, _uiColorUtils.colorToHex8)(color);
|
|
100
99
|
}
|
|
101
100
|
onMenuItemSelected = color => (_e, args) => {
|
|
102
101
|
if (args.value === 'select') {
|
|
@@ -112,7 +111,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
112
111
|
children: (0, _jsxRuntime.jsx)(_v11_.IconButton, {
|
|
113
112
|
disabled: this.props.disabled,
|
|
114
113
|
screenReaderLabel: this.props.colorMixerSettings.addNewPresetButtonScreenReaderLabel,
|
|
115
|
-
children: (0, _jsxRuntime.jsx)(
|
|
114
|
+
children: (0, _jsxRuntime.jsx)(_uiIcons.IconAddLine, {})
|
|
116
115
|
})
|
|
117
116
|
}),
|
|
118
117
|
isShowingContent: this.state.openAddNew,
|
|
@@ -137,9 +136,9 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
137
136
|
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
138
137
|
css: this.props.styles?.popoverContent,
|
|
139
138
|
children: [(0, _jsxRuntime.jsx)(_index2.ColorMixer, {
|
|
140
|
-
value: _uiColorUtils.
|
|
139
|
+
value: (0, _uiColorUtils.colorToHex8)(this.state.newColor),
|
|
141
140
|
onChange: newColor => this.setState({
|
|
142
|
-
newColor: _uiColorUtils.
|
|
141
|
+
newColor: (0, _uiColorUtils.colorToRGB)(newColor)
|
|
143
142
|
}),
|
|
144
143
|
withAlpha: this.props?.colorMixerSettings?.colorMixer?.withAlpha,
|
|
145
144
|
rgbRedInputScreenReaderLabel: this.props.colorMixerSettings.colorMixer.rgbRedInputScreenReaderLabel,
|
|
@@ -153,7 +152,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
153
152
|
css: this.props.styles?.popoverContrastBlock,
|
|
154
153
|
children: (0, _jsxRuntime.jsx)(_index3.ColorContrast, {
|
|
155
154
|
firstColor: this.props.colorMixerSettings.colorContrast.firstColor,
|
|
156
|
-
secondColor: _uiColorUtils.
|
|
155
|
+
secondColor: (0, _uiColorUtils.colorToHex8)(this.state.newColor),
|
|
157
156
|
label: this.props.colorMixerSettings.colorContrast.label,
|
|
158
157
|
successLabel: this.props.colorMixerSettings.colorContrast.successLabel,
|
|
159
158
|
failureLabel: this.props.colorMixerSettings.colorContrast.failureLabel,
|
|
@@ -168,7 +167,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
168
167
|
css: this.props.styles?.popoverFooter,
|
|
169
168
|
children: [(0, _jsxRuntime.jsx)(_v11_.Button, {
|
|
170
169
|
onClick: () => {
|
|
171
|
-
this.props?.colorMixerSettings?.onPresetChange([_uiColorUtils.
|
|
170
|
+
this.props?.colorMixerSettings?.onPresetChange([(0, _uiColorUtils.colorToHex8)(this.state.newColor), ...this.props.colors]);
|
|
172
171
|
this.setState({
|
|
173
172
|
openAddNew: false
|
|
174
173
|
});
|
|
@@ -219,7 +218,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
219
218
|
role: "presentation"
|
|
220
219
|
}), this.isSelectedColor(color) && (0, _jsxRuntime.jsx)("div", {
|
|
221
220
|
css: this.props?.styles?.selectedIndicator,
|
|
222
|
-
children: (0, _jsxRuntime.jsx)(
|
|
221
|
+
children: (0, _jsxRuntime.jsx)(_uiIcons.IconCheckDarkSolid, {
|
|
223
222
|
themeOverride: {
|
|
224
223
|
sizeXSmall: '0.8rem'
|
|
225
224
|
},
|
|
@@ -277,7 +276,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
277
276
|
return null;
|
|
278
277
|
}
|
|
279
278
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
280
|
-
...(0,
|
|
279
|
+
...(0, _uiReactUtils.omitProps)(this.props, ColorPreset.allowedProps),
|
|
281
280
|
ref: this.handleRef,
|
|
282
281
|
css: styles?.colorPreset,
|
|
283
282
|
"data-cid": "ColorPreset",
|