@thednp/color-picker 0.0.1-alpha2 → 0.0.2-alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/README.md +32 -15
  2. package/dist/css/color-picker.css +38 -15
  3. package/dist/css/color-picker.min.css +2 -2
  4. package/dist/css/color-picker.rtl.css +38 -15
  5. package/dist/css/color-picker.rtl.min.css +2 -2
  6. package/dist/js/color-esm.js +1178 -0
  7. package/dist/js/color-esm.min.js +2 -0
  8. package/dist/js/color-palette-esm.js +1252 -0
  9. package/dist/js/color-palette-esm.min.js +2 -0
  10. package/dist/js/color-palette.js +1260 -0
  11. package/dist/js/color-palette.min.js +2 -0
  12. package/dist/js/color-picker-element-esm.js +433 -424
  13. package/dist/js/color-picker-element-esm.min.js +2 -2
  14. package/dist/js/color-picker-element.js +435 -426
  15. package/dist/js/color-picker-element.min.js +2 -2
  16. package/dist/js/color-picker-esm.js +745 -739
  17. package/dist/js/color-picker-esm.min.js +2 -2
  18. package/dist/js/color-picker.js +747 -741
  19. package/dist/js/color-picker.min.js +2 -2
  20. package/dist/js/color.js +1186 -0
  21. package/dist/js/color.min.js +2 -0
  22. package/package.json +19 -3
  23. package/src/js/color-palette.js +28 -12
  24. package/src/js/color-picker-element.js +8 -4
  25. package/src/js/color-picker.js +84 -172
  26. package/src/js/color.js +125 -131
  27. package/src/js/util/getColorControls.js +3 -3
  28. package/src/js/util/getColorForm.js +0 -1
  29. package/src/js/util/getColorMenu.js +31 -33
  30. package/src/js/util/roundPart.js +9 -0
  31. package/src/js/util/setCSSProperties.js +12 -0
  32. package/src/js/util/setMarkup.js +122 -0
  33. package/src/js/util/tabindex.js +3 -0
  34. package/src/js/util/version.js +6 -0
  35. package/src/scss/color-picker.scss +35 -16
  36. package/types/cp.d.ts +48 -20
  37. package/src/js/util/templates.js +0 -10
@@ -1,14 +1,10 @@
1
1
  import { addListener, removeListener } from 'event-listener.js';
2
2
 
3
3
  import ariaDescription from 'shorter-js/src/strings/ariaDescription';
4
- // import ariaLabel from 'shorter-js/src/strings/ariaLabel';
5
4
  import ariaSelected from 'shorter-js/src/strings/ariaSelected';
6
5
  import ariaExpanded from 'shorter-js/src/strings/ariaExpanded';
7
6
  import ariaValueText from 'shorter-js/src/strings/ariaValueText';
8
7
  import ariaValueNow from 'shorter-js/src/strings/ariaValueNow';
9
- import ariaHasPopup from 'shorter-js/src/strings/ariaHasPopup';
10
- import ariaHidden from 'shorter-js/src/strings/ariaHidden';
11
- import ariaLabelledBy from 'shorter-js/src/strings/ariaLabelledBy';
12
8
  import keyArrowDown from 'shorter-js/src/strings/keyArrowDown';
13
9
  import keyArrowUp from 'shorter-js/src/strings/keyArrowUp';
14
10
  import keyArrowLeft from 'shorter-js/src/strings/keyArrowLeft';
@@ -31,7 +27,7 @@ import keyupEvent from 'shorter-js/src/strings/keyupEvent';
31
27
  import resizeEvent from 'shorter-js/src/strings/resizeEvent';
32
28
  import focusoutEvent from 'shorter-js/src/strings/focusoutEvent';
33
29
 
34
- import isMobile from 'shorter-js/src/boolean/isMobile';
30
+ // import isMobile from 'shorter-js/src/boolean/isMobile';
35
31
  import getDocument from 'shorter-js/src/get/getDocument';
36
32
  import getDocumentElement from 'shorter-js/src/get/getDocumentElement';
37
33
  import getWindow from 'shorter-js/src/get/getWindow';
@@ -42,8 +38,6 @@ import getElementTransitionDuration from 'shorter-js/src/get/getElementTransitio
42
38
  import querySelector from 'shorter-js/src/selectors/querySelector';
43
39
  import closest from 'shorter-js/src/selectors/closest';
44
40
  import getElementsByClassName from 'shorter-js/src/selectors/getElementsByClassName';
45
- import createElement from 'shorter-js/src/misc/createElement';
46
- import createElementNS from 'shorter-js/src/misc/createElementNS';
47
41
  import dispatchEvent from 'shorter-js/src/misc/dispatchEvent';
48
42
  import ObjectAssign from 'shorter-js/src/misc/ObjectAssign';
49
43
  import Data, { getInstance } from 'shorter-js/src/misc/data';
@@ -60,17 +54,16 @@ import removeAttribute from 'shorter-js/src/attr/removeAttribute';
60
54
 
61
55
  // ColorPicker Util
62
56
  // ================
57
+ import Color from './color';
58
+ import ColorPalette from './color-palette';
63
59
  import colorPickerLabels from './util/colorPickerLabels';
64
60
  import colorNames from './util/colorNames';
65
61
  import nonColors from './util/nonColors';
66
- import getColorForm from './util/getColorForm';
67
- import getColorControls from './util/getColorControls';
68
- import getColorMenu from './util/getColorMenu';
69
- import vHidden from './util/vHidden';
62
+ import tabIndex from './util/tabindex';
70
63
  import isValidJSON from './util/isValidJSON';
71
- import Color from './color';
72
- import ColorPalette from './color-palette';
73
- import Version from './version';
64
+ import roundPart from './util/roundPart';
65
+ import setMarkup from './util/setMarkup';
66
+ import Version from './util/version';
74
67
 
75
68
  // ColorPicker GC
76
69
  // ==============
@@ -81,15 +74,15 @@ const colorPickerDefaults = {
81
74
  componentLabels: colorPickerLabels,
82
75
  colorLabels: colorNames,
83
76
  format: 'rgb',
84
- colorPresets: undefined,
85
- colorKeywords: nonColors,
77
+ colorPresets: false,
78
+ colorKeywords: false,
86
79
  };
87
80
 
88
81
  // ColorPicker Static Methods
89
82
  // ==========================
90
83
 
91
84
  /** @type {CP.GetInstance<ColorPicker>} */
92
- const getColorPickerInstance = (element) => getInstance(element, colorPickerString);
85
+ export const getColorPickerInstance = (element) => getInstance(element, colorPickerString);
93
86
 
94
87
  /** @type {CP.InitCallback<ColorPicker>} */
95
88
  const initColorPicker = (element) => new ColorPicker(element);
@@ -97,110 +90,6 @@ const initColorPicker = (element) => new ColorPicker(element);
97
90
  // ColorPicker Private Methods
98
91
  // ===========================
99
92
 
100
- /**
101
- * Generate HTML markup and update instance properties.
102
- * @param {ColorPicker} self
103
- */
104
- function initCallback(self) {
105
- const {
106
- input, parent, format, id, componentLabels, colorKeywords, colorPresets,
107
- } = self;
108
- const colorValue = getAttribute(input, 'value') || '#fff';
109
-
110
- const {
111
- toggleLabel, pickerLabel, formatLabel, hexLabel,
112
- } = componentLabels;
113
-
114
- // update color
115
- const color = nonColors.includes(colorValue) ? '#fff' : colorValue;
116
- self.color = new Color(color, format);
117
-
118
- // set initial controls dimensions
119
- // make the controls smaller on mobile
120
- const dropClass = isMobile ? ' mobile' : '';
121
- const formatString = format === 'hex' ? hexLabel : format.toUpperCase();
122
-
123
- const pickerBtn = createElement({
124
- id: `picker-btn-${id}`,
125
- tagName: 'button',
126
- className: 'picker-toggle btn-appearance',
127
- });
128
- setAttribute(pickerBtn, ariaExpanded, 'false');
129
- setAttribute(pickerBtn, ariaHasPopup, 'true');
130
- pickerBtn.append(createElement({
131
- tagName: 'span',
132
- className: vHidden,
133
- innerText: `${pickerLabel}. ${formatLabel}: ${formatString}`,
134
- }));
135
-
136
- const pickerDropdown = createElement({
137
- tagName: 'div',
138
- className: `color-dropdown picker${dropClass}`,
139
- });
140
- setAttribute(pickerDropdown, ariaLabelledBy, `picker-btn-${id}`);
141
- setAttribute(pickerDropdown, 'role', 'group');
142
-
143
- const colorControls = getColorControls(self);
144
- const colorForm = getColorForm(self);
145
-
146
- pickerDropdown.append(colorControls, colorForm);
147
- input.before(pickerBtn);
148
- parent.append(pickerDropdown);
149
-
150
- // set colour key menu template
151
- if (colorKeywords || colorPresets) {
152
- const presetsDropdown = createElement({
153
- tagName: 'div',
154
- className: `color-dropdown scrollable menu${dropClass}`,
155
- });
156
-
157
- // color presets
158
- if ((colorPresets instanceof Array && colorPresets.length)
159
- || (colorPresets instanceof ColorPalette && colorPresets.colors)) {
160
- const presetsMenu = getColorMenu(self, colorPresets, 'color-options');
161
- presetsDropdown.append(presetsMenu);
162
- }
163
-
164
- // explicit defaults [reset, initial, inherit, transparent, currentColor]
165
- if (colorKeywords && colorKeywords.length) {
166
- const keywordsMenu = getColorMenu(self, colorKeywords, 'color-defaults');
167
- presetsDropdown.append(keywordsMenu);
168
- }
169
-
170
- const presetsBtn = createElement({
171
- tagName: 'button',
172
- className: 'menu-toggle btn-appearance',
173
- });
174
- setAttribute(presetsBtn, 'tabindex', '-1');
175
- setAttribute(presetsBtn, ariaExpanded, 'false');
176
- setAttribute(presetsBtn, ariaHasPopup, 'true');
177
-
178
- const xmlns = encodeURI('http://www.w3.org/2000/svg');
179
- const presetsIcon = createElementNS(xmlns, { tagName: 'svg' });
180
- setAttribute(presetsIcon, 'xmlns', xmlns);
181
- setAttribute(presetsIcon, 'viewBox', '0 0 512 512');
182
- setAttribute(presetsIcon, ariaHidden, 'true');
183
-
184
- const path = createElementNS(xmlns, { tagName: 'path' });
185
- setAttribute(path, 'd', 'M98,158l157,156L411,158l27,27L255,368L71,185L98,158z');
186
- setAttribute(path, 'fill', '#fff');
187
- presetsIcon.append(path);
188
- presetsBtn.append(createElement({
189
- tagName: 'span',
190
- className: vHidden,
191
- innerText: `${toggleLabel}`,
192
- }), presetsIcon);
193
-
194
- parent.append(presetsBtn, presetsDropdown);
195
- }
196
-
197
- // solve non-colors after settings save
198
- if (colorKeywords && nonColors.includes(colorValue)) {
199
- self.value = colorValue;
200
- }
201
- setAttribute(input, 'tabindex', '-1');
202
- }
203
-
204
93
  /**
205
94
  * Add / remove `ColorPicker` main event listeners.
206
95
  * @param {ColorPicker} self
@@ -299,8 +188,19 @@ function showDropdown(self, dropdown) {
299
188
  addClass(dropdown, 'bottom');
300
189
  reflow(dropdown);
301
190
  addClass(dropdown, 'show');
191
+
302
192
  if (isPicker) self.update();
303
- self.show();
193
+
194
+ if (!self.isOpen) {
195
+ toggleEventsOnShown(self, true);
196
+ self.updateDropdownPosition();
197
+ self.isOpen = true;
198
+ setAttribute(self.input, tabIndex, '0');
199
+ if (menuToggle) {
200
+ setAttribute(menuToggle, tabIndex, '0');
201
+ }
202
+ }
203
+
304
204
  setAttribute(nextBtn, ariaExpanded, 'true');
305
205
  if (activeBtn) {
306
206
  setAttribute(activeBtn, ariaExpanded, 'false');
@@ -423,7 +323,7 @@ export default class ColorPicker {
423
323
  self.handleKnobs = self.handleKnobs.bind(self);
424
324
 
425
325
  // generate markup
426
- initCallback(self);
326
+ setMarkup(self);
427
327
 
428
328
  const [colorPicker, colorMenu] = getElementsByClassName('color-dropdown', parent);
429
329
  // set main elements
@@ -470,7 +370,7 @@ export default class ColorPicker {
470
370
  set value(v) { this.input.value = v; }
471
371
 
472
372
  /** Check if the colour presets include any non-colour. */
473
- get includeNonColor() {
373
+ get hasNonColor() {
474
374
  return this.colorKeywords instanceof Array
475
375
  && this.colorKeywords.some((x) => nonColors.includes(x));
476
376
  }
@@ -526,7 +426,7 @@ export default class ColorPicker {
526
426
  const { r, g, b } = Color.hslToRgb(hue, 1, 0.5);
527
427
  const whiteGrad = 'linear-gradient(rgb(255,255,255) 0%, rgb(255,255,255) 100%)';
528
428
  const alpha = 1 - controlPositions.c3y / offsetHeight;
529
- const roundA = Math.round((alpha * 100)) / 100;
429
+ const roundA = roundPart((alpha * 100)) / 100;
530
430
 
531
431
  if (format !== 'hsl') {
532
432
  const fill = new Color({
@@ -544,7 +444,7 @@ export default class ColorPicker {
544
444
  });
545
445
  setElementStyle(v2, { background: hueGradient });
546
446
  } else {
547
- const saturation = Math.round((controlPositions.c2y / offsetHeight) * 100);
447
+ const saturation = roundPart((controlPositions.c2y / offsetHeight) * 100);
548
448
  const fill0 = new Color({
549
449
  r: 255, g: 0, b: 0, a: alpha,
550
450
  }).saturate(-saturation).toRgbString();
@@ -619,7 +519,7 @@ export default class ColorPicker {
619
519
  const self = this;
620
520
  const { activeElement } = getDocument(self.input);
621
521
 
622
- if ((isMobile && self.dragElement)
522
+ if ((e.type === touchmoveEvent && self.dragElement)
623
523
  || (activeElement && self.controlKnobs.includes(activeElement))) {
624
524
  e.stopPropagation();
625
525
  e.preventDefault();
@@ -699,12 +599,12 @@ export default class ColorPicker {
699
599
 
700
600
  self.update();
701
601
 
702
- if (currentActive) {
703
- removeClass(currentActive, 'active');
704
- removeAttribute(currentActive, ariaSelected);
705
- }
706
-
707
602
  if (currentActive !== target) {
603
+ if (currentActive) {
604
+ removeClass(currentActive, 'active');
605
+ removeAttribute(currentActive, ariaSelected);
606
+ }
607
+
708
608
  addClass(target, 'active');
709
609
  setAttribute(target, ariaSelected, 'true');
710
610
 
@@ -826,30 +726,41 @@ export default class ColorPicker {
826
726
  if (![keyArrowUp, keyArrowDown, keyArrowLeft, keyArrowRight].includes(code)) return;
827
727
  e.preventDefault();
828
728
 
829
- const { controlKnobs } = self;
729
+ const { format, controlKnobs, visuals } = self;
730
+ const { offsetWidth, offsetHeight } = visuals[0];
830
731
  const [c1, c2, c3] = controlKnobs;
831
732
  const { activeElement } = getDocument(c1);
832
733
  const currentKnob = controlKnobs.find((x) => x === activeElement);
734
+ const yRatio = offsetHeight / (format === 'hsl' ? 100 : 360);
833
735
 
834
736
  if (currentKnob) {
835
737
  let offsetX = 0;
836
738
  let offsetY = 0;
739
+
837
740
  if (target === c1) {
741
+ const xRatio = offsetWidth / (format === 'hsl' ? 360 : 100);
742
+
838
743
  if ([keyArrowLeft, keyArrowRight].includes(code)) {
839
- self.controlPositions.c1x += code === keyArrowRight ? +1 : -1;
744
+ self.controlPositions.c1x += code === keyArrowRight ? xRatio : -xRatio;
840
745
  } else if ([keyArrowUp, keyArrowDown].includes(code)) {
841
- self.controlPositions.c1y += code === keyArrowDown ? +1 : -1;
746
+ self.controlPositions.c1y += code === keyArrowDown ? yRatio : -yRatio;
842
747
  }
843
748
 
844
749
  offsetX = self.controlPositions.c1x;
845
750
  offsetY = self.controlPositions.c1y;
846
751
  self.changeControl1(offsetX, offsetY);
847
752
  } else if (target === c2) {
848
- self.controlPositions.c2y += [keyArrowDown, keyArrowRight].includes(code) ? +1 : -1;
753
+ self.controlPositions.c2y += [keyArrowDown, keyArrowRight].includes(code)
754
+ ? yRatio
755
+ : -yRatio;
756
+
849
757
  offsetY = self.controlPositions.c2y;
850
758
  self.changeControl2(offsetY);
851
759
  } else if (target === c3) {
852
- self.controlPositions.c3y += [keyArrowDown, keyArrowRight].includes(code) ? +1 : -1;
760
+ self.controlPositions.c3y += [keyArrowDown, keyArrowRight].includes(code)
761
+ ? yRatio
762
+ : -yRatio;
763
+
853
764
  offsetY = self.controlPositions.c3y;
854
765
  self.changeAlpha(offsetY);
855
766
  }
@@ -871,7 +782,7 @@ export default class ColorPicker {
871
782
  const [v1, v2, v3, v4] = format === 'rgb'
872
783
  ? inputs.map((i) => parseFloat(i.value) / (i === i4 ? 100 : 1))
873
784
  : inputs.map((i) => parseFloat(i.value) / (i !== i1 ? 100 : 360));
874
- const isNonColorValue = self.includeNonColor && nonColors.includes(currentValue);
785
+ const isNonColorValue = self.hasNonColor && nonColors.includes(currentValue);
875
786
  const alpha = i4 ? v4 : (1 - controlPositions.c3y / offsetHeight);
876
787
 
877
788
  if (activeElement === input || (activeElement && inputs.includes(activeElement))) {
@@ -1130,11 +1041,11 @@ export default class ColorPicker {
1130
1041
  } = componentLabels;
1131
1042
  const { r, g, b } = color.toRgb();
1132
1043
  const [knob1, knob2, knob3] = controlKnobs;
1133
- const hue = Math.round(hsl.h * 360);
1044
+ const hue = roundPart(hsl.h * 360);
1134
1045
  const alpha = color.a;
1135
1046
  const saturationSource = format === 'hsl' ? hsl.s : hsv.s;
1136
- const saturation = Math.round(saturationSource * 100);
1137
- const lightness = Math.round(hsl.l * 100);
1047
+ const saturation = roundPart(saturationSource * 100);
1048
+ const lightness = roundPart(hsl.l * 100);
1138
1049
  const hsvl = hsv.v * 100;
1139
1050
  let colorName;
1140
1051
 
@@ -1181,8 +1092,8 @@ export default class ColorPicker {
1181
1092
  setAttribute(knob2, ariaValueNow, `${saturation}`);
1182
1093
  } else if (format === 'hwb') {
1183
1094
  const { hwb } = self;
1184
- const whiteness = Math.round(hwb.w * 100);
1185
- const blackness = Math.round(hwb.b * 100);
1095
+ const whiteness = roundPart(hwb.w * 100);
1096
+ const blackness = roundPart(hwb.b * 100);
1186
1097
  colorLabel = `HWB: ${hue}°, ${whiteness}%, ${blackness}%`;
1187
1098
  setAttribute(knob1, ariaDescription, `${valueLabel}: ${colorLabel}. ${appearanceLabel}: ${colorName}.`);
1188
1099
  setAttribute(knob1, ariaValueText, `${whiteness}% & ${blackness}%`);
@@ -1198,7 +1109,7 @@ export default class ColorPicker {
1198
1109
  setAttribute(knob2, ariaValueNow, `${hue}`);
1199
1110
  }
1200
1111
 
1201
- const alphaValue = Math.round(alpha * 100);
1112
+ const alphaValue = roundPart(alpha * 100);
1202
1113
  setAttribute(knob3, ariaValueText, `${alphaValue}%`);
1203
1114
  setAttribute(knob3, ariaValueNow, `${alphaValue}`);
1204
1115
 
@@ -1221,10 +1132,16 @@ export default class ColorPicker {
1221
1132
  /** Updates the control knobs actual positions. */
1222
1133
  updateControls() {
1223
1134
  const { controlKnobs, controlPositions } = this;
1135
+ let {
1136
+ c1x, c1y, c2y, c3y,
1137
+ } = controlPositions;
1224
1138
  const [control1, control2, control3] = controlKnobs;
1225
- setElementStyle(control1, { transform: `translate3d(${controlPositions.c1x - 4}px,${controlPositions.c1y - 4}px,0)` });
1226
- setElementStyle(control2, { transform: `translate3d(0,${controlPositions.c2y - 4}px,0)` });
1227
- setElementStyle(control3, { transform: `translate3d(0,${controlPositions.c3y - 4}px,0)` });
1139
+ // round control positions
1140
+ [c1x, c1y, c2y, c3y] = [c1x, c1y, c2y, c3y].map(roundPart);
1141
+
1142
+ setElementStyle(control1, { transform: `translate3d(${c1x - 4}px,${c1y - 4}px,0)` });
1143
+ setElementStyle(control2, { transform: `translate3d(0,${c2y - 4}px,0)` });
1144
+ setElementStyle(control3, { transform: `translate3d(0,${c3y - 4}px,0)` });
1228
1145
  }
1229
1146
 
1230
1147
  /**
@@ -1237,16 +1154,16 @@ export default class ColorPicker {
1237
1154
  value: oldColor, format, inputs, color, hsl,
1238
1155
  } = self;
1239
1156
  const [i1, i2, i3, i4] = inputs;
1240
- const alpha = Math.round(color.a * 100);
1241
- const hue = Math.round(hsl.h * 360);
1157
+ const alpha = roundPart(color.a * 100);
1158
+ const hue = roundPart(hsl.h * 360);
1242
1159
  let newColor;
1243
1160
 
1244
1161
  if (format === 'hex') {
1245
1162
  newColor = self.color.toHexString(true);
1246
1163
  i1.value = self.hex;
1247
1164
  } else if (format === 'hsl') {
1248
- const lightness = Math.round(hsl.l * 100);
1249
- const saturation = Math.round(hsl.s * 100);
1165
+ const lightness = roundPart(hsl.l * 100);
1166
+ const saturation = roundPart(hsl.s * 100);
1250
1167
  newColor = self.color.toHslString();
1251
1168
  i1.value = `${hue}`;
1252
1169
  i2.value = `${saturation}`;
@@ -1254,8 +1171,8 @@ export default class ColorPicker {
1254
1171
  i4.value = `${alpha}`;
1255
1172
  } else if (format === 'hwb') {
1256
1173
  const { w, b } = self.hwb;
1257
- const whiteness = Math.round(w * 100);
1258
- const blackness = Math.round(b * 100);
1174
+ const whiteness = roundPart(w * 100);
1175
+ const blackness = roundPart(b * 100);
1259
1176
 
1260
1177
  newColor = self.color.toHwbString();
1261
1178
  i1.value = `${hue}`;
@@ -1263,7 +1180,8 @@ export default class ColorPicker {
1263
1180
  i3.value = `${blackness}`;
1264
1181
  i4.value = `${alpha}`;
1265
1182
  } else if (format === 'rgb') {
1266
- const { r, g, b } = self.rgb;
1183
+ let { r, g, b } = self.rgb;
1184
+ [r, g, b] = [r, g, b].map(roundPart);
1267
1185
 
1268
1186
  newColor = self.color.toRgbString();
1269
1187
  i1.value = `${r}`;
@@ -1327,7 +1245,7 @@ export default class ColorPicker {
1327
1245
  const self = this;
1328
1246
  const { colorPicker } = self;
1329
1247
 
1330
- if (!hasClass(colorPicker, 'show')) {
1248
+ if (!['top', 'bottom'].some((c) => hasClass(colorPicker, c))) {
1331
1249
  showDropdown(self, colorPicker);
1332
1250
  }
1333
1251
  }
@@ -1344,21 +1262,6 @@ export default class ColorPicker {
1344
1262
  }
1345
1263
  }
1346
1264
 
1347
- /** Shows the `ColorPicker` dropdown or the presets menu. */
1348
- show() {
1349
- const self = this;
1350
- const { menuToggle } = self;
1351
- if (!self.isOpen) {
1352
- toggleEventsOnShown(self, true);
1353
- self.updateDropdownPosition();
1354
- self.isOpen = true;
1355
- setAttribute(self.input, 'tabindex', '0');
1356
- if (menuToggle) {
1357
- setAttribute(menuToggle, 'tabindex', '0');
1358
- }
1359
- }
1360
- }
1361
-
1362
1265
  /**
1363
1266
  * Hides the currently open `ColorPicker` dropdown.
1364
1267
  * @param {boolean=} focusPrevented
@@ -1393,9 +1296,9 @@ export default class ColorPicker {
1393
1296
  if (!focusPrevented) {
1394
1297
  focus(pickerToggle);
1395
1298
  }
1396
- setAttribute(input, 'tabindex', '-1');
1299
+ setAttribute(input, tabIndex, '-1');
1397
1300
  if (menuToggle) {
1398
- setAttribute(menuToggle, 'tabindex', '-1');
1301
+ setAttribute(menuToggle, tabIndex, '-1');
1399
1302
  }
1400
1303
  }
1401
1304
  }
@@ -1409,7 +1312,10 @@ export default class ColorPicker {
1409
1312
  [...parent.children].forEach((el) => {
1410
1313
  if (el !== input) el.remove();
1411
1314
  });
1315
+
1316
+ removeAttribute(input, tabIndex);
1412
1317
  setElementStyle(input, { backgroundColor: '' });
1318
+
1413
1319
  ['txt-light', 'txt-dark'].forEach((c) => removeClass(parent, c));
1414
1320
  Data.remove(input, colorPickerString);
1415
1321
  }
@@ -1417,8 +1323,14 @@ export default class ColorPicker {
1417
1323
 
1418
1324
  ObjectAssign(ColorPicker, {
1419
1325
  Color,
1326
+ ColorPalette,
1420
1327
  Version,
1421
1328
  getInstance: getColorPickerInstance,
1422
1329
  init: initColorPicker,
1423
1330
  selector: colorPickerSelector,
1331
+ // utils important for render
1332
+ roundPart,
1333
+ setElementStyle,
1334
+ setAttribute,
1335
+ getBoundingClientRect,
1424
1336
  });