@instructure/ui-color-picker 8.25.1-snapshot-20

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 (201) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +46 -0
  3. package/es/ColorContrast/ColorContrastLocator.js +54 -0
  4. package/es/ColorContrast/index.js +174 -0
  5. package/es/ColorContrast/props.js +40 -0
  6. package/es/ColorContrast/styles.js +99 -0
  7. package/es/ColorContrast/theme.js +55 -0
  8. package/es/ColorIndicator/ColorIndicatorLocator.js +40 -0
  9. package/es/ColorIndicator/index.js +91 -0
  10. package/es/ColorIndicator/props.js +31 -0
  11. package/es/ColorIndicator/styles.js +70 -0
  12. package/es/ColorIndicator/theme.js +53 -0
  13. package/es/ColorMixer/ColorMixerLocator.js +27 -0
  14. package/es/ColorMixer/ColorPalette/index.js +258 -0
  15. package/es/ColorMixer/ColorPalette/props.js +37 -0
  16. package/es/ColorMixer/ColorPalette/styles.js +81 -0
  17. package/es/ColorMixer/ColorPalette/theme.js +48 -0
  18. package/es/ColorMixer/RGBAInput/index.js +148 -0
  19. package/es/ColorMixer/RGBAInput/props.js +39 -0
  20. package/es/ColorMixer/RGBAInput/styles.js +63 -0
  21. package/es/ColorMixer/RGBAInput/theme.js +43 -0
  22. package/es/ColorMixer/Slider/index.js +218 -0
  23. package/es/ColorMixer/Slider/props.js +38 -0
  24. package/es/ColorMixer/Slider/styles.js +95 -0
  25. package/es/ColorMixer/Slider/theme.js +53 -0
  26. package/es/ColorMixer/index.js +232 -0
  27. package/es/ColorMixer/props.js +40 -0
  28. package/es/ColorMixer/styles.js +49 -0
  29. package/es/ColorMixer/utils/shallowCompare.js +32 -0
  30. package/es/ColorPicker/ColorPickerLocator.js +137 -0
  31. package/es/ColorPicker/index.js +487 -0
  32. package/es/ColorPicker/props.js +47 -0
  33. package/es/ColorPicker/styles.js +119 -0
  34. package/es/ColorPicker/theme.js +76 -0
  35. package/es/ColorPreset/ColorPresetLocator.js +27 -0
  36. package/es/ColorPreset/index.js +268 -0
  37. package/es/ColorPreset/props.js +36 -0
  38. package/es/ColorPreset/styles.js +102 -0
  39. package/es/ColorPreset/theme.js +53 -0
  40. package/es/index.js +28 -0
  41. package/lib/ColorContrast/ColorContrastLocator.js +66 -0
  42. package/lib/ColorContrast/index.js +169 -0
  43. package/lib/ColorContrast/props.js +51 -0
  44. package/lib/ColorContrast/styles.js +107 -0
  45. package/lib/ColorContrast/theme.js +63 -0
  46. package/lib/ColorIndicator/ColorIndicatorLocator.js +51 -0
  47. package/lib/ColorIndicator/index.js +82 -0
  48. package/lib/ColorIndicator/props.js +42 -0
  49. package/lib/ColorIndicator/styles.js +78 -0
  50. package/lib/ColorIndicator/theme.js +63 -0
  51. package/lib/ColorMixer/ColorMixerLocator.js +37 -0
  52. package/lib/ColorMixer/ColorPalette/index.js +252 -0
  53. package/lib/ColorMixer/ColorPalette/props.js +48 -0
  54. package/lib/ColorMixer/ColorPalette/styles.js +90 -0
  55. package/lib/ColorMixer/ColorPalette/theme.js +57 -0
  56. package/lib/ColorMixer/RGBAInput/index.js +142 -0
  57. package/lib/ColorMixer/RGBAInput/props.js +50 -0
  58. package/lib/ColorMixer/RGBAInput/styles.js +71 -0
  59. package/lib/ColorMixer/RGBAInput/theme.js +51 -0
  60. package/lib/ColorMixer/Slider/index.js +211 -0
  61. package/lib/ColorMixer/Slider/props.js +49 -0
  62. package/lib/ColorMixer/Slider/styles.js +103 -0
  63. package/lib/ColorMixer/Slider/theme.js +62 -0
  64. package/lib/ColorMixer/index.js +226 -0
  65. package/lib/ColorMixer/props.js +51 -0
  66. package/lib/ColorMixer/styles.js +57 -0
  67. package/lib/ColorMixer/utils/shallowCompare.js +40 -0
  68. package/lib/ColorPicker/ColorPickerLocator.js +151 -0
  69. package/lib/ColorPicker/index.js +500 -0
  70. package/lib/ColorPicker/props.js +58 -0
  71. package/lib/ColorPicker/styles.js +127 -0
  72. package/lib/ColorPicker/theme.js +85 -0
  73. package/lib/ColorPreset/ColorPresetLocator.js +37 -0
  74. package/lib/ColorPreset/index.js +274 -0
  75. package/lib/ColorPreset/props.js +47 -0
  76. package/lib/ColorPreset/styles.js +110 -0
  77. package/lib/ColorPreset/theme.js +61 -0
  78. package/lib/index.js +45 -0
  79. package/lib/package.json +1 -0
  80. package/package.json +62 -0
  81. package/src/ColorContrast/ColorContrastLocator.ts +51 -0
  82. package/src/ColorContrast/README.md +111 -0
  83. package/src/ColorContrast/index.tsx +189 -0
  84. package/src/ColorContrast/props.ts +140 -0
  85. package/src/ColorContrast/styles.ts +102 -0
  86. package/src/ColorContrast/theme.ts +62 -0
  87. package/src/ColorIndicator/ColorIndicatorLocator.ts +41 -0
  88. package/src/ColorIndicator/README.md +76 -0
  89. package/src/ColorIndicator/index.tsx +89 -0
  90. package/src/ColorIndicator/props.ts +68 -0
  91. package/src/ColorIndicator/styles.ts +88 -0
  92. package/src/ColorIndicator/theme.ts +58 -0
  93. package/src/ColorMixer/ColorMixerLocator.ts +29 -0
  94. package/src/ColorMixer/ColorPalette/index.tsx +250 -0
  95. package/src/ColorMixer/ColorPalette/props.ts +87 -0
  96. package/src/ColorMixer/ColorPalette/styles.ts +94 -0
  97. package/src/ColorMixer/ColorPalette/theme.ts +52 -0
  98. package/src/ColorMixer/README.md +98 -0
  99. package/src/ColorMixer/RGBAInput/index.tsx +172 -0
  100. package/src/ColorMixer/RGBAInput/props.ts +93 -0
  101. package/src/ColorMixer/RGBAInput/styles.ts +69 -0
  102. package/src/ColorMixer/RGBAInput/theme.ts +48 -0
  103. package/src/ColorMixer/Slider/index.tsx +242 -0
  104. package/src/ColorMixer/Slider/props.ts +94 -0
  105. package/src/ColorMixer/Slider/styles.ts +114 -0
  106. package/src/ColorMixer/Slider/theme.ts +59 -0
  107. package/src/ColorMixer/index.tsx +221 -0
  108. package/src/ColorMixer/props.ts +169 -0
  109. package/src/ColorMixer/styles.ts +51 -0
  110. package/src/ColorMixer/utils/shallowCompare.ts +35 -0
  111. package/src/ColorPicker/ColorPickerLocator.ts +124 -0
  112. package/src/ColorPicker/README.md +420 -0
  113. package/src/ColorPicker/index.tsx +609 -0
  114. package/src/ColorPicker/props.ts +293 -0
  115. package/src/ColorPicker/styles.ts +131 -0
  116. package/src/ColorPicker/theme.ts +80 -0
  117. package/src/ColorPreset/ColorPresetLocator.ts +29 -0
  118. package/src/ColorPreset/README.md +121 -0
  119. package/src/ColorPreset/index.tsx +328 -0
  120. package/src/ColorPreset/props.ts +162 -0
  121. package/src/ColorPreset/styles.ts +107 -0
  122. package/src/ColorPreset/theme.ts +58 -0
  123. package/src/index.ts +34 -0
  124. package/tsconfig.build.json +36 -0
  125. package/tsconfig.build.tsbuildinfo +1 -0
  126. package/types/ColorContrast/ColorContrastLocator.d.ts +592 -0
  127. package/types/ColorContrast/ColorContrastLocator.d.ts.map +1 -0
  128. package/types/ColorContrast/index.d.ts +61 -0
  129. package/types/ColorContrast/index.d.ts.map +1 -0
  130. package/types/ColorContrast/props.d.ts +62 -0
  131. package/types/ColorContrast/props.d.ts.map +1 -0
  132. package/types/ColorContrast/styles.d.ts +76 -0
  133. package/types/ColorContrast/styles.d.ts.map +1 -0
  134. package/types/ColorContrast/theme.d.ts +10 -0
  135. package/types/ColorContrast/theme.d.ts.map +1 -0
  136. package/types/ColorIndicator/ColorIndicatorLocator.d.ts +577 -0
  137. package/types/ColorIndicator/ColorIndicatorLocator.d.ts.map +1 -0
  138. package/types/ColorIndicator/index.d.ts +35 -0
  139. package/types/ColorIndicator/index.d.ts.map +1 -0
  140. package/types/ColorIndicator/props.d.ts +25 -0
  141. package/types/ColorIndicator/props.d.ts.map +1 -0
  142. package/types/ColorIndicator/styles.d.ts +15 -0
  143. package/types/ColorIndicator/styles.d.ts.map +1 -0
  144. package/types/ColorIndicator/theme.d.ts +11 -0
  145. package/types/ColorIndicator/theme.d.ts.map +1 -0
  146. package/types/ColorMixer/ColorMixerLocator.d.ts +566 -0
  147. package/types/ColorMixer/ColorMixerLocator.d.ts.map +1 -0
  148. package/types/ColorMixer/ColorPalette/index.d.ts +70 -0
  149. package/types/ColorMixer/ColorPalette/index.d.ts.map +1 -0
  150. package/types/ColorMixer/ColorPalette/props.d.ts +29 -0
  151. package/types/ColorMixer/ColorPalette/props.d.ts.map +1 -0
  152. package/types/ColorMixer/ColorPalette/styles.d.ts +15 -0
  153. package/types/ColorMixer/ColorPalette/styles.d.ts.map +1 -0
  154. package/types/ColorMixer/ColorPalette/theme.d.ts +10 -0
  155. package/types/ColorMixer/ColorPalette/theme.d.ts.map +1 -0
  156. package/types/ColorMixer/RGBAInput/index.d.ts +51 -0
  157. package/types/ColorMixer/RGBAInput/index.d.ts.map +1 -0
  158. package/types/ColorMixer/RGBAInput/props.d.ts +28 -0
  159. package/types/ColorMixer/RGBAInput/props.d.ts.map +1 -0
  160. package/types/ColorMixer/RGBAInput/styles.d.ts +15 -0
  161. package/types/ColorMixer/RGBAInput/styles.d.ts.map +1 -0
  162. package/types/ColorMixer/RGBAInput/theme.d.ts +10 -0
  163. package/types/ColorMixer/RGBAInput/theme.d.ts.map +1 -0
  164. package/types/ColorMixer/Slider/index.d.ts +64 -0
  165. package/types/ColorMixer/Slider/index.d.ts.map +1 -0
  166. package/types/ColorMixer/Slider/props.d.ts +26 -0
  167. package/types/ColorMixer/Slider/props.d.ts.map +1 -0
  168. package/types/ColorMixer/Slider/styles.d.ts +15 -0
  169. package/types/ColorMixer/Slider/styles.d.ts.map +1 -0
  170. package/types/ColorMixer/Slider/theme.d.ts +10 -0
  171. package/types/ColorMixer/Slider/theme.d.ts.map +1 -0
  172. package/types/ColorMixer/index.d.ts +59 -0
  173. package/types/ColorMixer/index.d.ts.map +1 -0
  174. package/types/ColorMixer/props.d.ts +91 -0
  175. package/types/ColorMixer/props.d.ts.map +1 -0
  176. package/types/ColorMixer/styles.d.ts +14 -0
  177. package/types/ColorMixer/styles.d.ts.map +1 -0
  178. package/types/ColorMixer/utils/shallowCompare.d.ts +3 -0
  179. package/types/ColorMixer/utils/shallowCompare.d.ts.map +1 -0
  180. package/types/ColorPicker/ColorPickerLocator.d.ts +4113 -0
  181. package/types/ColorPicker/ColorPickerLocator.d.ts.map +1 -0
  182. package/types/ColorPicker/index.d.ts +158 -0
  183. package/types/ColorPicker/index.d.ts.map +1 -0
  184. package/types/ColorPicker/props.d.ts +166 -0
  185. package/types/ColorPicker/props.d.ts.map +1 -0
  186. package/types/ColorPicker/styles.d.ts +17 -0
  187. package/types/ColorPicker/styles.d.ts.map +1 -0
  188. package/types/ColorPicker/theme.d.ts +10 -0
  189. package/types/ColorPicker/theme.d.ts.map +1 -0
  190. package/types/ColorPreset/ColorPresetLocator.d.ts +566 -0
  191. package/types/ColorPreset/ColorPresetLocator.d.ts.map +1 -0
  192. package/types/ColorPreset/index.d.ts +100 -0
  193. package/types/ColorPreset/index.d.ts.map +1 -0
  194. package/types/ColorPreset/props.d.ts +87 -0
  195. package/types/ColorPreset/props.d.ts.map +1 -0
  196. package/types/ColorPreset/styles.d.ts +77 -0
  197. package/types/ColorPreset/styles.d.ts.map +1 -0
  198. package/types/ColorPreset/theme.d.ts +10 -0
  199. package/types/ColorPreset/theme.d.ts.map +1 -0
  200. package/types/index.d.ts +11 -0
  201. package/types/index.d.ts.map +1 -0
@@ -0,0 +1,53 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { colorIndicatorBorderColor } from '../../ColorIndicator/theme';
25
+ /**
26
+ * Generates the theme object for the component from the theme and provided additional information
27
+ * @param {Object} theme The actual theme object.
28
+ * @return {Object} The final theme object with the overrides and component variables
29
+ */
30
+
31
+ const generateComponentTheme = theme => {
32
+ const colors = theme.colors,
33
+ borders = theme.borders,
34
+ stacking = theme.stacking;
35
+ const componentVariables = {
36
+ indicatorBorderColor: colors.licorice,
37
+ checkerboardBackgroundImage: `linear-gradient(45deg, ${colors.tiara} 25%, transparent 25%),
38
+ linear-gradient(-45deg, ${colors.tiara} 25%, transparent 25%),
39
+ linear-gradient(45deg, transparent 75%, ${colors.tiara} 75%),
40
+ linear-gradient(-45deg, transparent 75%, ${colors.tiara} 75%)`,
41
+ checkerboardBackgroundSize: '.5rem .5rem',
42
+ checkerboardBackgroundPosition: '0 0, 0 .25rem, .25rem -0.25rem, -0.25rem 0px',
43
+ colorIndicatorBorderColor,
44
+ indicatorBorderWidth: borders.widthSmall,
45
+ sliderBorderWidth: borders.widthSmall,
46
+ indicatorZIndex: stacking.above,
47
+ disabledOverlayZIndex: stacking.topmost
48
+ };
49
+ return { ...componentVariables
50
+ };
51
+ };
52
+
53
+ export default generateComponentTheme;
@@ -0,0 +1,232 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ const _excluded = ["disabled", "onChange", "value", "elementRef", "styles", "withAlpha", "rgbRedInputScreenReaderLabel", "rgbGreenInputScreenReaderLabel", "rgbBlueInputScreenReaderLabel", "rgbAlphaInputScreenReaderLabel", "colorSliderNavigationExplanationScreenReaderLabel", "alphaSliderNavigationExplanationScreenReaderLabel", "colorPaletteNavigationExplanationScreenReaderLabel"];
3
+
4
+ var _dec, _dec2, _class, _class2;
5
+
6
+ /*
7
+ * The MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2015 - present Instructure, Inc.
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all
19
+ * copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ * SOFTWARE.
28
+ */
29
+
30
+ /** @jsx jsx */
31
+ import { Component } from 'react';
32
+ import { withStyle, jsx } from '@instructure/emotion';
33
+ import { passthroughProps } from '@instructure/ui-react-utils';
34
+ import { testable } from '@instructure/ui-testable';
35
+ import { colorToHex8, colorToHsva, colorToRGB } from '@instructure/ui-color-utils';
36
+ import ColorPalette from './ColorPalette';
37
+ import Slider from './Slider';
38
+ import RGBAInput from './RGBAInput';
39
+ import { propTypes, allowedProps } from './props';
40
+ import generateStyle from './styles';
41
+ /**
42
+ ---
43
+ category: components
44
+ ---
45
+ @tsProps
46
+ **/
47
+
48
+ let ColorMixer = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class ColorMixer extends Component {
49
+ constructor(props) {
50
+ super(props);
51
+ this.ref = null;
52
+ this._width = 272;
53
+ this._paletteHeight = 160;
54
+ this._sliderHeight = 8;
55
+ this._sliderIndicatorRadius = 6;
56
+ this._paletteIndicatorRadius = 6;
57
+
58
+ this.handleRef = el => {
59
+ const elementRef = this.props.elementRef;
60
+ this.ref = el;
61
+
62
+ if (typeof elementRef === 'function') {
63
+ elementRef(el);
64
+ }
65
+ };
66
+
67
+ this.state = {
68
+ h: 0,
69
+ s: 0,
70
+ v: 0,
71
+ a: 1
72
+ };
73
+ }
74
+
75
+ componentDidMount() {
76
+ var _this$props$makeStyle, _this$props;
77
+
78
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
79
+
80
+ if (this.props.value) {
81
+ this.setState({ ...colorToHsva(this.props.value)
82
+ });
83
+ }
84
+ }
85
+
86
+ componentDidUpdate(prevProps, prevState) {
87
+ var _this$props$makeStyle2, _this$props2;
88
+
89
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
90
+ const _this$state = this.state,
91
+ h = _this$state.h,
92
+ s = _this$state.s,
93
+ v = _this$state.v,
94
+ a = _this$state.a;
95
+
96
+ if (prevState.h !== h || prevState.s !== s || prevState.v !== v || prevState.a !== a) {
97
+ this.props.onChange(colorToHex8({
98
+ h,
99
+ s,
100
+ v,
101
+ a
102
+ }));
103
+ }
104
+
105
+ if (prevProps.value !== this.props.value && colorToHex8({
106
+ h,
107
+ s,
108
+ v,
109
+ a
110
+ }) !== this.props.value) {
111
+ this.setState({ ...colorToHsva(this.props.value)
112
+ });
113
+ }
114
+ }
115
+
116
+ render() {
117
+ const _this$props3 = this.props,
118
+ disabled = _this$props3.disabled,
119
+ onChange = _this$props3.onChange,
120
+ value = _this$props3.value,
121
+ elementRef = _this$props3.elementRef,
122
+ styles = _this$props3.styles,
123
+ withAlpha = _this$props3.withAlpha,
124
+ rgbRedInputScreenReaderLabel = _this$props3.rgbRedInputScreenReaderLabel,
125
+ rgbGreenInputScreenReaderLabel = _this$props3.rgbGreenInputScreenReaderLabel,
126
+ rgbBlueInputScreenReaderLabel = _this$props3.rgbBlueInputScreenReaderLabel,
127
+ rgbAlphaInputScreenReaderLabel = _this$props3.rgbAlphaInputScreenReaderLabel,
128
+ colorSliderNavigationExplanationScreenReaderLabel = _this$props3.colorSliderNavigationExplanationScreenReaderLabel,
129
+ alphaSliderNavigationExplanationScreenReaderLabel = _this$props3.alphaSliderNavigationExplanationScreenReaderLabel,
130
+ colorPaletteNavigationExplanationScreenReaderLabel = _this$props3.colorPaletteNavigationExplanationScreenReaderLabel,
131
+ props = _objectWithoutProperties(_this$props3, _excluded);
132
+
133
+ const _this$state2 = this.state,
134
+ h = _this$state2.h,
135
+ s = _this$state2.s,
136
+ v = _this$state2.v,
137
+ a = _this$state2.a;
138
+ return jsx("div", Object.assign({}, passthroughProps(props), {
139
+ "aria-disabled": disabled,
140
+ ref: this.handleRef,
141
+ css: styles === null || styles === void 0 ? void 0 : styles.colorMixer
142
+ }), jsx("span", {
143
+ css: styles === null || styles === void 0 ? void 0 : styles.sliderAndPaletteContainer,
144
+ "aria-label": `${colorToHex8({
145
+ h,
146
+ s,
147
+ v,
148
+ a
149
+ })}`,
150
+ "aria-live": "polite"
151
+ }, jsx(ColorPalette, {
152
+ disabled: disabled,
153
+ width: this._width,
154
+ height: this._paletteHeight,
155
+ indicatorRadius: this._paletteIndicatorRadius,
156
+ hue: h,
157
+ color: {
158
+ h,
159
+ s,
160
+ v
161
+ },
162
+ onChange: color => {
163
+ this.setState({
164
+ s: color.s,
165
+ v: color.v
166
+ });
167
+ },
168
+ navigationExplanationScreenReaderLabel: colorPaletteNavigationExplanationScreenReaderLabel
169
+ }), jsx(Slider, {
170
+ disabled: disabled,
171
+ isColorSlider: true,
172
+ width: this._width,
173
+ height: this._sliderHeight,
174
+ indicatorRadius: this._sliderIndicatorRadius,
175
+ value: h,
176
+ minValue: 0,
177
+ maxValue: 359,
178
+ color: colorToHex8({
179
+ h,
180
+ s,
181
+ v,
182
+ a
183
+ }),
184
+ onChange: hue => {
185
+ this.setState({
186
+ h: hue
187
+ });
188
+ },
189
+ navigationExplanationScreenReaderLabel: colorSliderNavigationExplanationScreenReaderLabel
190
+ }), withAlpha && jsx(Slider, {
191
+ disabled: disabled,
192
+ width: this._width,
193
+ height: this._sliderHeight,
194
+ indicatorRadius: this._sliderIndicatorRadius,
195
+ color: colorToHex8({
196
+ h,
197
+ s,
198
+ v
199
+ }),
200
+ value: a,
201
+ minValue: 0,
202
+ maxValue: 1,
203
+ onChange: opacity => this.setState({
204
+ a: opacity / 100
205
+ }),
206
+ navigationExplanationScreenReaderLabel: alphaSliderNavigationExplanationScreenReaderLabel
207
+ })), jsx(RGBAInput, {
208
+ disabled: disabled,
209
+ label: withAlpha ? 'RGBA' : 'RGB',
210
+ width: this._width,
211
+ value: colorToRGB({
212
+ h,
213
+ s,
214
+ v,
215
+ a
216
+ }),
217
+ onChange: color => this.setState({ ...colorToHsva(color)
218
+ }),
219
+ withAlpha: withAlpha,
220
+ rgbRedInputScreenReaderLabel: rgbRedInputScreenReaderLabel,
221
+ rgbGreenInputScreenReaderLabel: rgbGreenInputScreenReaderLabel,
222
+ rgbBlueInputScreenReaderLabel: rgbBlueInputScreenReaderLabel,
223
+ rgbAlphaInputScreenReaderLabel: rgbAlphaInputScreenReaderLabel
224
+ }));
225
+ }
226
+
227
+ }, _class2.displayName = "ColorMixer", _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.componentId = 'ColorMixer', _class2.defaultProps = {
228
+ withAlpha: false,
229
+ disabled: false
230
+ }, _class2)) || _class) || _class);
231
+ export { ColorMixer };
232
+ export default ColorMixer;
@@ -0,0 +1,40 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import PropTypes from 'prop-types';
25
+ const propTypes = {
26
+ disabled: PropTypes.bool,
27
+ elementRef: PropTypes.func,
28
+ value: PropTypes.string,
29
+ onChange: PropTypes.func,
30
+ withAlpha: PropTypes.bool,
31
+ rgbRedInputScreenReaderLabel: PropTypes.string.isRequired,
32
+ rgbGreenInputScreenReaderLabel: PropTypes.string.isRequired,
33
+ rgbBlueInputScreenReaderLabel: PropTypes.string.isRequired,
34
+ rgbAlphaInputScreenReaderLabel: PropTypes.string.isRequired,
35
+ colorSliderNavigationExplanationScreenReaderLabel: PropTypes.string.isRequired,
36
+ alphaSliderNavigationExplanationScreenReaderLabel: PropTypes.string.isRequired,
37
+ colorPaletteNavigationExplanationScreenReaderLabel: PropTypes.string.isRequired
38
+ };
39
+ const allowedProps = ['disabled', 'elementRef', 'value', 'onChange', 'withAlpha', 'rgbRedInputScreenReaderLabel', 'rgbGreenInputScreenReaderLabel', 'rgbBlueInputScreenReaderLabel', 'rgbAlphaInputScreenReaderLabel', 'colorSliderNavigationExplanationScreenReaderLabel', 'alphaSliderNavigationExplanationScreenReaderLabel', 'colorPaletteNavigationExplanationScreenReaderLabel'];
40
+ export { propTypes, allowedProps };
@@ -0,0 +1,49 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = () => {
36
+ return {
37
+ colorMixer: {
38
+ label: 'colorMixer',
39
+ width: '17rem'
40
+ },
41
+ sliderAndPaletteContainer: {
42
+ label: 'colorMixer__sliderAndPaletteContainer',
43
+ display: 'flex',
44
+ flexDirection: 'column'
45
+ }
46
+ };
47
+ };
48
+
49
+ export default generateStyle;
@@ -0,0 +1,32 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ const shallowCompare = (newObj, prevObj) => {
25
+ for (const key in newObj) {
26
+ if (newObj[key] !== prevObj[key]) return true;
27
+ }
28
+
29
+ return false;
30
+ };
31
+
32
+ export default shallowCompare;
@@ -0,0 +1,137 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { locator } from '@instructure/ui-test-locator';
25
+ import { find, findAll, parseQueryArguments, findWithText, within } from '@instructure/ui-test-utils';
26
+ import { ColorPicker } from '.';
27
+ /* eslint-disable no-restricted-imports */
28
+ // @ts-expect-error bypass no type definition found error
29
+
30
+ import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator';
31
+ /* eslint-enable no-restricted-imports */
32
+
33
+ import { ColorIndicatorLocator } from '../ColorIndicator/ColorIndicatorLocator';
34
+ import { ColorMixerLocator } from '../ColorMixer/ColorMixerLocator';
35
+ import { ColorPresetLocator } from '../ColorPreset/ColorPresetLocator';
36
+
37
+ async function _findColorPreset() {
38
+ const popoverContent = await PopoverLocator.findContent(...arguments);
39
+ const colorPreset = await ColorPresetLocator.find(popoverContent.getDOMNode());
40
+ return ColorIndicatorLocator.findAll(colorPreset.getDOMNode());
41
+ }
42
+
43
+ const customMethods = {
44
+ findTextInput: function () {
45
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
46
+ args[_key] = arguments[_key];
47
+ }
48
+
49
+ return find('[id^=TextInput_]', ...args);
50
+ },
51
+ findColorIndicator: function () {
52
+ return ColorIndicatorLocator.find(...arguments);
53
+ },
54
+ findInputAfterIcon: function () {
55
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
56
+ args[_key2] = arguments[_key2];
57
+ }
58
+
59
+ return find('[class$=-textInput__afterElement]', ...args);
60
+ },
61
+ findFormMessages: function () {
62
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
63
+ args[_key3] = arguments[_key3];
64
+ }
65
+
66
+ return findAll('[class$=-formFieldMessage]', ...args);
67
+ },
68
+ findPopoverRoot: function () {
69
+ return PopoverLocator.find(...arguments);
70
+ },
71
+ findPopoverTrigger: function () {
72
+ return PopoverLocator.findTrigger(...arguments);
73
+ },
74
+ findColorMixer: function () {
75
+ return ColorMixerLocator.find(...arguments);
76
+ },
77
+ findPopoverContent: function () {
78
+ 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,
85
+ ...customMethods
86
+ }
87
+ });
88
+ },
89
+ findRGBAInputs: async function () {
90
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
91
+ args[_key4] = arguments[_key4];
92
+ }
93
+
94
+ const rgbaInputs = await findAll('[class$=-RGBAInput__rgbInput]', ...args);
95
+ return Promise.all(rgbaInputs.map(span => span.find('input')));
96
+ },
97
+ findPopoverButtonWithText: async function () {
98
+ let el = await findWithText(...arguments);
99
+
100
+ while (el.getTagName() !== 'button') {
101
+ const parentNode = el.getParentNode();
102
+
103
+ if (!parentNode) {
104
+ break;
105
+ }
106
+
107
+ el = within(parentNode);
108
+ }
109
+
110
+ return el;
111
+ },
112
+ findColorPreset: async function () {
113
+ return _findColorPreset(...arguments);
114
+ },
115
+ findColorPresetButtons: async function () {
116
+ const colorPresets = await _findColorPreset(...arguments);
117
+ const colorPresetButtons = [];
118
+
119
+ for (let el of colorPresets) {
120
+ while (el.getTagName() !== 'button') {
121
+ const parentNode = el.getParentNode();
122
+
123
+ if (!parentNode) {
124
+ break;
125
+ }
126
+
127
+ el = within(parentNode);
128
+ }
129
+
130
+ colorPresetButtons.push(el);
131
+ }
132
+
133
+ return colorPresetButtons;
134
+ }
135
+ }; //@ts-expect-error no selector on class
136
+
137
+ export const ColorPickerLocator = locator(ColorPicker.selector, customMethods);