aloha-vue 2.86.0 → 2.87.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 +11 -0
- package/dist/aloha-vue.css +13827 -13806
- package/dist/aloha-vue.css.map +1 -1
- package/dist/aloha-vue.es.js +60256 -60168
- package/dist/aloha-vue.umd.js +319 -319
- package/package.json +1 -1
- package/scss/components/ui/ACheckbox.scss +17 -17
- package/scss/components/ui/AColorPicker.scss +20 -0
- package/scss/components/ui/AInputFile.scss +15 -15
- package/scss/utils/border_radius.scss +61 -61
- package/src/AAlert/compositionAPI/IconAPI.js +28 -28
- package/src/ACloak/ACloak.js +135 -135
- package/src/ALoading/ALoading.js +146 -146
- package/src/AMenu/compositionAPI/ResizeAPI.js +1 -1
- package/src/AMenu/compositionAPI/__tests__/ResizeAPI.test.js +33 -0
- package/src/ASpinner/ASpinner.js +71 -71
- package/src/filters/i18n/ar.json +11 -11
- package/src/filters/i18n/de.json +11 -11
- package/src/filters/i18n/en.json +11 -11
- package/src/filters/i18n/es.json +11 -11
- package/src/filters/i18n/fr.json +11 -11
- package/src/filters/i18n/hr.json +10 -10
- package/src/filters/i18n/it.json +11 -11
- package/src/filters/i18n/nl.json +11 -11
- package/src/filters/i18n/pl.json +11 -11
- package/src/filters/i18n/ru.json +10 -10
- package/src/plugins/ACloakPlugin.js +26 -26
- package/src/plugins/AFormPlugin.js +18 -18
- package/src/plugins/AGroupButtonDropdownPlugin.js +26 -26
- package/src/plugins/AInputNumberPlugin.js +29 -29
- package/src/plugins/ALoadingPlugin.js +26 -26
- package/src/plugins/AModalPlugin.js +41 -41
- package/src/plugins/ARouterLinkConfigPlugin.js +88 -88
- package/src/plugins/ASpinnerPlugin.js +26 -26
- package/src/plugins/ATablePlugin.js +28 -28
- package/src/ui/ACheckbox/i18n/ar.json +5 -5
- package/src/ui/ACheckbox/i18n/de.json +5 -5
- package/src/ui/ACheckbox/i18n/en.json +5 -5
- package/src/ui/ACheckbox/i18n/es.json +5 -5
- package/src/ui/ACheckbox/i18n/fr.json +5 -5
- package/src/ui/ACheckbox/i18n/hr.json +5 -5
- package/src/ui/ACheckbox/i18n/it.json +5 -5
- package/src/ui/ACheckbox/i18n/nl.json +4 -4
- package/src/ui/ACheckbox/i18n/pl.json +4 -4
- package/src/ui/ACheckbox/i18n/ru.json +5 -5
- package/src/ui/AColorPicker/AColorPicker.js +85 -35
- package/src/ui/AColorPicker/__tests__/AColorPicker.test.js +107 -1
- package/src/ui/AColorPicker/__tests__/colorUtils.test.js +12 -0
- package/src/ui/AColorPicker/compositionAPI/ClearAPI.js +23 -0
- package/src/ui/AColorPicker/compositionAPI/ColorStateAPI.js +28 -3
- package/src/ui/AColorPicker/compositionAPI/FormatAPI.js +59 -0
- package/src/ui/AColorPicker/compositionAPI/IdAPI.js +15 -0
- package/src/ui/AColorPicker/compositionAPI/PopoverAPI.js +20 -3
- package/src/ui/AColorPicker/i18n/ar.json +2 -1
- package/src/ui/AColorPicker/i18n/de.json +2 -1
- package/src/ui/AColorPicker/i18n/en.json +2 -1
- package/src/ui/AColorPicker/i18n/es.json +2 -1
- package/src/ui/AColorPicker/i18n/fr.json +2 -1
- package/src/ui/AColorPicker/i18n/hr.json +2 -1
- package/src/ui/AColorPicker/i18n/it.json +2 -1
- package/src/ui/AColorPicker/i18n/nl.json +2 -1
- package/src/ui/AColorPicker/i18n/pl.json +2 -1
- package/src/ui/AColorPicker/i18n/ru.json +2 -1
- package/src/ui/AColorPicker/i18n/uk.json +2 -1
- package/src/ui/AColorPicker/utils/colorUtils.js +15 -0
- package/src/ui/ADatepicker/compositionAPI/PlaceholderAPI.js +32 -32
- package/src/ui/AMultiselectOrdered/compositionAPI/TextsAPI.js +55 -55
- package/src/ui/ASlider/__tests__/ASlider.Form.test.js +38 -0
- package/src/ui/AUiComponents.js +2 -0
- package/src/ui/__tests__/ReadonlyValueParentClass.test.js +217 -217
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "ادخالات غير صالحة",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[لا توجد عناصر متاحة للاختيار]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "بحث"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "ادخالات غير صالحة",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[لا توجد عناصر متاحة للاختيار]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "بحث"
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Invalide Einträge",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Keine Elemente zur Auswahl verfügbar]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Suche"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Invalide Einträge",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Keine Elemente zur Auswahl verfügbar]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Suche"
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Invalid entries",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[No items available for selection]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Search"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Invalid entries",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[No items available for selection]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Search"
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Entradas no válidas",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[No hay elementos disponibles para seleccionar]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Buscar"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Entradas no válidas",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[No hay elementos disponibles para seleccionar]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Buscar"
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Entrées invalides",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Aucun élément disponible pour la sélection]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Recherche"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Entrées invalides",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Aucun élément disponible pour la sélection]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Recherche"
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Neispravni unosi",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Nema dostupnih elemenata za odabir]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Pretraživanje"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Neispravni unosi",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Nema dostupnih elemenata za odabir]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Pretraživanje"
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Voci non valide",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Nessun elemento disponibile per la selezione]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Cerca"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Voci non valide",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Nessun elemento disponibile per la selezione]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Cerca"
|
|
5
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Ongeldige invoer",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Geen items beschikbaar voor selectie]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Zoeken"
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Ongeldige invoer",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Geen items beschikbaar voor selectie]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Zoeken"
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Nieprawidłowe wpisy",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Brak elementów do wyboru]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Szukaj"
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Nieprawidłowe wpisy",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Brak elementów do wyboru]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Szukaj"
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Недопустимые записи",
|
|
3
|
-
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Нет элементов для выбора]",
|
|
4
|
-
"_A_CHECKBOX_SEARCH_": "Поиск"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"_A_CHECKBOX_GROUP_INVALID_ENTRIES_": "Недопустимые записи",
|
|
3
|
+
"_A_CHECKBOX_HAS_NOT_ELEMENTS_WITH_SEARCH_": "[Нет элементов для выбора]",
|
|
4
|
+
"_A_CHECKBOX_SEARCH_": "Поиск"
|
|
5
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
computed,
|
|
3
2
|
h,
|
|
4
3
|
Teleport,
|
|
5
4
|
} from "vue";
|
|
@@ -24,8 +23,11 @@ import {
|
|
|
24
23
|
import AColorPickerSaturation from "./AColorPickerSaturation/AColorPickerSaturation";
|
|
25
24
|
import AColorPickerSlider from "./AColorPickerSlider/AColorPickerSlider";
|
|
26
25
|
|
|
26
|
+
import ClearAPI from "./compositionAPI/ClearAPI";
|
|
27
27
|
import ColorStateAPI from "./compositionAPI/ColorStateAPI";
|
|
28
28
|
import ConfirmAPI from "./compositionAPI/ConfirmAPI";
|
|
29
|
+
import FormatAPI from "./compositionAPI/FormatAPI";
|
|
30
|
+
import IdAPI from "./compositionAPI/IdAPI";
|
|
29
31
|
import InputAPI from "./compositionAPI/InputAPI";
|
|
30
32
|
import PopoverAPI from "./compositionAPI/PopoverAPI";
|
|
31
33
|
import PredefineAPI from "./compositionAPI/PredefineAPI";
|
|
@@ -36,6 +38,7 @@ import {
|
|
|
36
38
|
COLOR_FORMATS,
|
|
37
39
|
} from "./utils/colorUtils";
|
|
38
40
|
import {
|
|
41
|
+
isArray,
|
|
39
42
|
uniqueId,
|
|
40
43
|
} from "lodash-es";
|
|
41
44
|
|
|
@@ -59,11 +62,11 @@ export default {
|
|
|
59
62
|
required: false,
|
|
60
63
|
default: undefined,
|
|
61
64
|
},
|
|
62
|
-
|
|
63
|
-
type: String,
|
|
65
|
+
colorFormats: {
|
|
66
|
+
type: [String, Array],
|
|
64
67
|
required: false,
|
|
65
68
|
default: "hex",
|
|
66
|
-
validator: value => COLOR_FORMATS.indexOf(
|
|
69
|
+
validator: value => (isArray(value) ? value : [value]).every(format => COLOR_FORMATS.indexOf(format) !== -1),
|
|
67
70
|
},
|
|
68
71
|
dependencies: {
|
|
69
72
|
type: [Array, Object],
|
|
@@ -166,7 +169,7 @@ export default {
|
|
|
166
169
|
modelUndefined: {
|
|
167
170
|
type: [String, Number, Object, Array, Boolean],
|
|
168
171
|
required: false,
|
|
169
|
-
default:
|
|
172
|
+
default: undefined,
|
|
170
173
|
},
|
|
171
174
|
modelValue: {
|
|
172
175
|
type: String,
|
|
@@ -238,6 +241,14 @@ export default {
|
|
|
238
241
|
componentStyleHide,
|
|
239
242
|
} = UiStyleHideAPI(props);
|
|
240
243
|
|
|
244
|
+
const {
|
|
245
|
+
currentFormat,
|
|
246
|
+
isFormatSwitch,
|
|
247
|
+
nextFormat,
|
|
248
|
+
setFormatFromModel,
|
|
249
|
+
switchFormat,
|
|
250
|
+
} = FormatAPI(props);
|
|
251
|
+
|
|
241
252
|
const {
|
|
242
253
|
alphaBackground,
|
|
243
254
|
alphaPercent,
|
|
@@ -254,7 +265,9 @@ export default {
|
|
|
254
265
|
setHue,
|
|
255
266
|
setSaturationBrightness,
|
|
256
267
|
valueLocal,
|
|
257
|
-
} = ColorStateAPI(props
|
|
268
|
+
} = ColorStateAPI(props, {
|
|
269
|
+
currentFormat,
|
|
270
|
+
});
|
|
258
271
|
|
|
259
272
|
const {
|
|
260
273
|
ariaDescribedbyLocal,
|
|
@@ -272,6 +285,7 @@ export default {
|
|
|
272
285
|
const {
|
|
273
286
|
closePopover,
|
|
274
287
|
isOpen,
|
|
288
|
+
isPositioned,
|
|
275
289
|
onPopupKeydown,
|
|
276
290
|
onToggleKeydown,
|
|
277
291
|
popupId,
|
|
@@ -280,7 +294,10 @@ export default {
|
|
|
280
294
|
togglePopover,
|
|
281
295
|
} = PopoverAPI(props, context, {
|
|
282
296
|
htmlIdLocal,
|
|
283
|
-
setColorFromModel
|
|
297
|
+
setColorFromModel: () => {
|
|
298
|
+
setFormatFromModel();
|
|
299
|
+
setColorFromModel();
|
|
300
|
+
},
|
|
284
301
|
});
|
|
285
302
|
|
|
286
303
|
const {
|
|
@@ -326,16 +343,19 @@ export default {
|
|
|
326
343
|
isErrors,
|
|
327
344
|
});
|
|
328
345
|
|
|
329
|
-
const
|
|
330
|
-
|
|
346
|
+
const {
|
|
347
|
+
labelId,
|
|
348
|
+
valueId,
|
|
349
|
+
} = IdAPI({
|
|
350
|
+
htmlIdLocal,
|
|
351
|
+
});
|
|
331
352
|
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
};
|
|
353
|
+
const {
|
|
354
|
+
clearModelFromToggle,
|
|
355
|
+
} = ClearAPI(props, {
|
|
356
|
+
changeModel,
|
|
357
|
+
toggleRef,
|
|
358
|
+
});
|
|
339
359
|
|
|
340
360
|
return {
|
|
341
361
|
alphaBackground,
|
|
@@ -349,6 +369,7 @@ export default {
|
|
|
349
369
|
confirmColor,
|
|
350
370
|
cssColorLocal,
|
|
351
371
|
cssColorOpaqueLocal,
|
|
372
|
+
currentFormat,
|
|
352
373
|
disabledAttribut,
|
|
353
374
|
errorsId,
|
|
354
375
|
hasErrorIcon,
|
|
@@ -360,12 +381,15 @@ export default {
|
|
|
360
381
|
inputText,
|
|
361
382
|
isClearButtonLocal,
|
|
362
383
|
isErrors,
|
|
384
|
+
isFormatSwitch,
|
|
363
385
|
isModel,
|
|
364
386
|
isOpen,
|
|
387
|
+
isPositioned,
|
|
365
388
|
labelDescriptionId,
|
|
366
389
|
labelId,
|
|
367
390
|
modelCssColor,
|
|
368
391
|
modelTextColor,
|
|
392
|
+
nextFormat,
|
|
369
393
|
onBlur,
|
|
370
394
|
onFocus,
|
|
371
395
|
onInputChange,
|
|
@@ -379,6 +403,7 @@ export default {
|
|
|
379
403
|
setAlphaPercent,
|
|
380
404
|
setHue,
|
|
381
405
|
setSaturationBrightness,
|
|
406
|
+
switchFormat,
|
|
382
407
|
toggleClassBtns,
|
|
383
408
|
togglePopover,
|
|
384
409
|
toggleRef,
|
|
@@ -553,7 +578,12 @@ export default {
|
|
|
553
578
|
h("div", {
|
|
554
579
|
ref: "popupRef",
|
|
555
580
|
id: this.popupId,
|
|
556
|
-
class:
|
|
581
|
+
class: [
|
|
582
|
+
"a_color_picker__popup",
|
|
583
|
+
{
|
|
584
|
+
a_color_picker__popup_positioning: !this.isPositioned,
|
|
585
|
+
},
|
|
586
|
+
],
|
|
557
587
|
role: "dialog",
|
|
558
588
|
"aria-modal": "true",
|
|
559
589
|
"aria-labelledby": hasLabel ? this.labelId : undefined,
|
|
@@ -618,24 +648,44 @@ export default {
|
|
|
618
648
|
ariaHidden: true,
|
|
619
649
|
}),
|
|
620
650
|
]),
|
|
621
|
-
h(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
651
|
+
h("div", {
|
|
652
|
+
class: "a_color_picker__value",
|
|
653
|
+
}, [
|
|
654
|
+
h(AInput, {
|
|
655
|
+
id: `${ this.htmlIdLocal }_input`,
|
|
656
|
+
alwaysTranslate: this.alwaysTranslate,
|
|
657
|
+
class: "a_color_picker__input",
|
|
658
|
+
errors: this.inputErrors,
|
|
659
|
+
inputAttributes: {
|
|
660
|
+
autocomplete: "off",
|
|
661
|
+
spellcheck: "false",
|
|
662
|
+
onKeydown: this.onInputKeydown,
|
|
663
|
+
},
|
|
664
|
+
extra: {
|
|
665
|
+
format: this.currentFormat.toUpperCase(),
|
|
666
|
+
},
|
|
667
|
+
isClearButton: false,
|
|
668
|
+
label: "_A_COLOR_PICKER_INPUT_{{format}}_",
|
|
669
|
+
modelValue: this.inputText,
|
|
670
|
+
change: this.onInputChange,
|
|
671
|
+
onBlur: this.applyInput,
|
|
672
|
+
}),
|
|
673
|
+
this.isFormatSwitch ?
|
|
674
|
+
h(AButton, {
|
|
675
|
+
alwaysTranslate: this.alwaysTranslate,
|
|
676
|
+
ariaLabel: "_A_COLOR_PICKER_FORMAT_SWITCH_{{format}}_{{next}}_",
|
|
677
|
+
extra: {
|
|
678
|
+
format: this.currentFormat.toUpperCase(),
|
|
679
|
+
next: this.nextFormat.toUpperCase(),
|
|
680
|
+
},
|
|
681
|
+
class: "a_btn a_btn_outline_secondary a_btn_small a_color_picker__format",
|
|
682
|
+
text: this.currentFormat.toUpperCase(),
|
|
683
|
+
title: "_A_COLOR_PICKER_FORMAT_SWITCH_{{format}}_{{next}}_",
|
|
684
|
+
type: "button",
|
|
685
|
+
onClick: this.switchFormat,
|
|
686
|
+
}) :
|
|
687
|
+
"",
|
|
688
|
+
]),
|
|
639
689
|
this.predefineLocal.length ?
|
|
640
690
|
h("div", {
|
|
641
691
|
class: "a_color_picker__predefine",
|
|
@@ -50,6 +50,47 @@ describe("AColorPicker", () => {
|
|
|
50
50
|
wrapper.unmount();
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
it("updates the label and value IDs when htmlId changes", async() => {
|
|
54
|
+
const wrapper = mountPicker({ htmlId: "color", modelValue: "#ff0000" });
|
|
55
|
+
const toggle = wrapper.get("button.a_color_picker__toggle");
|
|
56
|
+
|
|
57
|
+
expect(toggle.attributes("aria-labelledby")).toBe("color_label color_value");
|
|
58
|
+
await wrapper.setProps({ htmlId: "updated_color" });
|
|
59
|
+
expect(toggle.attributes("aria-labelledby")).toBe("updated_color_label updated_color_value");
|
|
60
|
+
expect(wrapper.get(".a_color_picker__toggle__value").attributes("id")).toBe("updated_color_value");
|
|
61
|
+
wrapper.unmount();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it.each(["toggle", "panel"])("clears from the %s to undefined by default and restores focus", async source => {
|
|
65
|
+
const change = vi.fn();
|
|
66
|
+
const wrapper = mountPicker({ modelValue: "#ff0000", change });
|
|
67
|
+
const toggle = wrapper.get("button.a_color_picker__toggle");
|
|
68
|
+
|
|
69
|
+
if (source === "panel") {
|
|
70
|
+
await toggle.trigger("click");
|
|
71
|
+
await flush();
|
|
72
|
+
[...getPopup().querySelectorAll("button")].find(button => button.textContent.includes("_A_COLOR_PICKER_CLEAR_")).click();
|
|
73
|
+
} else {
|
|
74
|
+
await wrapper.get(".a_form_control__actions__btn").trigger("click");
|
|
75
|
+
}
|
|
76
|
+
await flush();
|
|
77
|
+
|
|
78
|
+
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual([undefined]);
|
|
79
|
+
expect(change).toHaveBeenCalledWith(expect.objectContaining({ model: undefined, triggerDetails: "clear" }));
|
|
80
|
+
expect(getPopup()).toBeNull();
|
|
81
|
+
expect(document.activeElement).toBe(toggle.element);
|
|
82
|
+
wrapper.unmount();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("uses the updated modelUndefined when clearing from the toggle", async() => {
|
|
86
|
+
const wrapper = mountPicker({ modelValue: "#ff0000", modelUndefined: "" });
|
|
87
|
+
await wrapper.setProps({ modelUndefined: null });
|
|
88
|
+
await wrapper.get(".a_form_control__actions__btn").trigger("click");
|
|
89
|
+
|
|
90
|
+
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual([null]);
|
|
91
|
+
wrapper.unmount();
|
|
92
|
+
});
|
|
93
|
+
|
|
53
94
|
it("opens a dialog, changes the hue with the keyboard and confirms", async() => {
|
|
54
95
|
const change = vi.fn();
|
|
55
96
|
const wrapper = mountPicker({ modelValue: "#ff0000", change });
|
|
@@ -77,6 +118,21 @@ describe("AColorPicker", () => {
|
|
|
77
118
|
wrapper.unmount();
|
|
78
119
|
});
|
|
79
120
|
|
|
121
|
+
it("focuses the dialog only after it is positioned", async() => {
|
|
122
|
+
const wrapper = mountPicker({ modelValue: "#ff0000" });
|
|
123
|
+
await wrapper.get("button.a_color_picker__toggle").trigger("click");
|
|
124
|
+
await nextTick();
|
|
125
|
+
|
|
126
|
+
expect(getPopup().classList.contains("a_color_picker__popup_positioning")).toBe(true);
|
|
127
|
+
|
|
128
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
129
|
+
await flush();
|
|
130
|
+
|
|
131
|
+
expect(getPopup().classList.contains("a_color_picker__popup_positioning")).toBe(false);
|
|
132
|
+
expect(document.activeElement.classList.contains("a_color_picker_saturation__thumb")).toBe(true);
|
|
133
|
+
wrapper.unmount();
|
|
134
|
+
});
|
|
135
|
+
|
|
80
136
|
it("closes with Escape without changing the model and returns the focus", async() => {
|
|
81
137
|
const wrapper = mountPicker({ modelValue: "#ff0000" });
|
|
82
138
|
const toggle = wrapper.get("button.a_color_picker__toggle");
|
|
@@ -96,7 +152,7 @@ describe("AColorPicker", () => {
|
|
|
96
152
|
});
|
|
97
153
|
|
|
98
154
|
it("applies a typed value and shows an error for an invalid one", async() => {
|
|
99
|
-
const wrapper = mountPicker({ modelValue: "#ff0000",
|
|
155
|
+
const wrapper = mountPicker({ modelValue: "#ff0000", colorFormats: "rgb", showAlpha: true });
|
|
100
156
|
await wrapper.get("button.a_color_picker__toggle").trigger("click");
|
|
101
157
|
await flush();
|
|
102
158
|
|
|
@@ -116,6 +172,56 @@ describe("AColorPicker", () => {
|
|
|
116
172
|
wrapper.unmount();
|
|
117
173
|
});
|
|
118
174
|
|
|
175
|
+
it("opens with the format of the model and switches formats in the given order", async() => {
|
|
176
|
+
const wrapper = mountPicker({ modelValue: "hsl(0, 100%, 50%)", colorFormats: ["hex", "hsl", "rgb"] });
|
|
177
|
+
await wrapper.get("button.a_color_picker__toggle").trigger("click");
|
|
178
|
+
await flush();
|
|
179
|
+
|
|
180
|
+
const input = () => getPopup().querySelector(".a_color_picker__input input");
|
|
181
|
+
const switchButton = () => getPopup().querySelector(".a_color_picker__format");
|
|
182
|
+
expect(input().value).toBe("hsl(0, 100%, 50%)");
|
|
183
|
+
expect(switchButton().textContent).toBe("HSL");
|
|
184
|
+
expect(switchButton().getAttribute("aria-label")).toBe("_A_COLOR_PICKER_FORMAT_SWITCH_{{format}}_{{next}}_");
|
|
185
|
+
|
|
186
|
+
switchButton().click();
|
|
187
|
+
await flush();
|
|
188
|
+
expect(input().value).toBe("rgb(255, 0, 0)");
|
|
189
|
+
switchButton().click();
|
|
190
|
+
await flush();
|
|
191
|
+
expect(input().value).toBe("#ff0000");
|
|
192
|
+
|
|
193
|
+
[...getPopup().querySelectorAll("button")].find(button => button.textContent.includes("_A_COLOR_PICKER_CONFIRM_")).click();
|
|
194
|
+
await flush();
|
|
195
|
+
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual(["#ff0000"]);
|
|
196
|
+
wrapper.unmount();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("keeps the model text when nothing is changed", async() => {
|
|
200
|
+
const wrapper = mountPicker({ modelValue: "hsl(145, 63%, 29%)", colorFormats: ["hex", "hsl"] });
|
|
201
|
+
await wrapper.get("button.a_color_picker__toggle").trigger("click");
|
|
202
|
+
await flush();
|
|
203
|
+
|
|
204
|
+
expect(getPopup().querySelector(".a_color_picker__input input").value).toBe("hsl(145, 63%, 29%)");
|
|
205
|
+
[...getPopup().querySelectorAll("button")].find(button => button.textContent.includes("_A_COLOR_PICKER_CONFIRM_")).click();
|
|
206
|
+
await flush();
|
|
207
|
+
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual(["hsl(145, 63%, 29%)"]);
|
|
208
|
+
wrapper.unmount();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("uses the first format if the model format is not allowed and hides the switch for one format", async() => {
|
|
212
|
+
const wrapper = mountPicker({ modelValue: "#ff0000", colorFormats: ["rgb", "hsv"] });
|
|
213
|
+
await wrapper.get("button.a_color_picker__toggle").trigger("click");
|
|
214
|
+
await flush();
|
|
215
|
+
expect(getPopup().querySelector(".a_color_picker__input input").value).toBe("rgb(255, 0, 0)");
|
|
216
|
+
wrapper.unmount();
|
|
217
|
+
|
|
218
|
+
const single = mountPicker({ modelValue: "#ff0000", colorFormats: "hex" });
|
|
219
|
+
await single.get("button.a_color_picker__toggle").trigger("click");
|
|
220
|
+
await flush();
|
|
221
|
+
expect(getPopup().querySelector(".a_color_picker__format")).toBeNull();
|
|
222
|
+
single.unmount();
|
|
223
|
+
});
|
|
224
|
+
|
|
119
225
|
it("marks the selected predefined color", async() => {
|
|
120
226
|
const wrapper = mountPicker({ modelValue: "#ff0000", predefine: ["#ff0000", "#00ff00", "invalid"] });
|
|
121
227
|
await wrapper.get("button.a_color_picker__toggle").trigger("click");
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
contrastRatio,
|
|
9
|
+
detectColorFormat,
|
|
9
10
|
formatColor,
|
|
10
11
|
getContrastTextColor,
|
|
11
12
|
hslToHsv,
|
|
@@ -42,6 +43,17 @@ describe("colorUtils parseColor", () => {
|
|
|
42
43
|
});
|
|
43
44
|
});
|
|
44
45
|
|
|
46
|
+
describe("colorUtils detectColorFormat", () => {
|
|
47
|
+
it("detects the format of a value", () => {
|
|
48
|
+
expect(detectColorFormat("#0775b0")).toBe("hex");
|
|
49
|
+
expect(detectColorFormat("RGBA(7, 117, 176, .5)")).toBe("rgb");
|
|
50
|
+
expect(detectColorFormat("hsl(0, 100%, 50%)")).toBe("hsl");
|
|
51
|
+
expect(detectColorFormat("hsva(0, 100%, 100%, 1)")).toBe("hsv");
|
|
52
|
+
expect(detectColorFormat("red")).toBeUndefined();
|
|
53
|
+
expect(detectColorFormat(undefined)).toBeUndefined();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
45
57
|
describe("colorUtils formatColor", () => {
|
|
46
58
|
const COLOR = { r: 7, g: 117, b: 176, a: 0.5 };
|
|
47
59
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
toRef,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
export default function ClearAPI(props, {
|
|
7
|
+
changeModel = () => {},
|
|
8
|
+
toggleRef = ref(undefined),
|
|
9
|
+
}) {
|
|
10
|
+
const modelUndefined = toRef(props, "modelUndefined");
|
|
11
|
+
|
|
12
|
+
const clearModelFromToggle = () => {
|
|
13
|
+
changeModel({
|
|
14
|
+
model: modelUndefined.value,
|
|
15
|
+
triggerDetails: "clear",
|
|
16
|
+
});
|
|
17
|
+
toggleRef.value?.focus();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
clearModelFromToggle,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "vue";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
+
detectColorFormat,
|
|
8
9
|
formatColor,
|
|
9
10
|
getContrastTextColor,
|
|
10
11
|
hsvToRgb,
|
|
@@ -12,20 +13,31 @@ import {
|
|
|
12
13
|
rgbToHsv,
|
|
13
14
|
toCssColor,
|
|
14
15
|
} from "../utils/colorUtils";
|
|
16
|
+
import {
|
|
17
|
+
isEqual,
|
|
18
|
+
} from "lodash-es";
|
|
15
19
|
|
|
16
20
|
const COLOR_FALLBACK = { r: 255, g: 0, b: 0, a: 1 };
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* State of the panel (hsva) and the colors derived from it and from the model.
|
|
20
24
|
*/
|
|
21
|
-
export default function ColorStateAPI(props
|
|
22
|
-
|
|
25
|
+
export default function ColorStateAPI(props, {
|
|
26
|
+
currentFormat = ref("hex"),
|
|
27
|
+
} = {}) {
|
|
23
28
|
const modelValue = toRef(props, "modelValue");
|
|
24
29
|
const panelDefaultColor = toRef(props, "panelDefaultColor");
|
|
25
30
|
const showAlpha = toRef(props, "showAlpha");
|
|
26
31
|
|
|
27
32
|
const hsva = ref({ h: 0, s: 100, v: 100, a: 1 });
|
|
28
33
|
|
|
34
|
+
/*
|
|
35
|
+
* The model value as it was when the dialog was opened. As long as the color
|
|
36
|
+
* and the format are not changed, this text is shown and written back,
|
|
37
|
+
* so e.g. "hsl(145, 63%, 29%)" does not become "hsl(145, 64%, 29%)" by rounding.
|
|
38
|
+
*/
|
|
39
|
+
const modelSnapshot = ref(undefined);
|
|
40
|
+
|
|
29
41
|
const modelColor = computed(() => parseColor(modelValue.value));
|
|
30
42
|
|
|
31
43
|
const modelCssColor = computed(() => {
|
|
@@ -44,7 +56,12 @@ export default function ColorStateAPI(props) {
|
|
|
44
56
|
});
|
|
45
57
|
|
|
46
58
|
const valueLocal = computed(() => {
|
|
47
|
-
|
|
59
|
+
if (modelSnapshot.value &&
|
|
60
|
+
modelSnapshot.value.format === currentFormat.value &&
|
|
61
|
+
isEqual(modelSnapshot.value.hsva, hsva.value)) {
|
|
62
|
+
return modelSnapshot.value.text;
|
|
63
|
+
}
|
|
64
|
+
return formatColor(rgbaLocal.value, currentFormat.value, showAlpha.value);
|
|
48
65
|
});
|
|
49
66
|
|
|
50
67
|
const cssColorLocal = computed(() => toCssColor(rgbaLocal.value));
|
|
@@ -73,6 +90,14 @@ export default function ColorStateAPI(props) {
|
|
|
73
90
|
|
|
74
91
|
const setColorFromModel = () => {
|
|
75
92
|
setColor(modelColor.value || parseColor(panelDefaultColor.value) || COLOR_FALLBACK);
|
|
93
|
+
const IS_SNAPSHOT = !!modelColor.value && (showAlpha.value || modelColor.value.a === 1);
|
|
94
|
+
modelSnapshot.value = IS_SNAPSHOT ?
|
|
95
|
+
{
|
|
96
|
+
format: detectColorFormat(modelValue.value),
|
|
97
|
+
hsva: { ...hsva.value },
|
|
98
|
+
text: modelValue.value.trim(),
|
|
99
|
+
} :
|
|
100
|
+
undefined;
|
|
76
101
|
};
|
|
77
102
|
|
|
78
103
|
const setHue = h => {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
ref,
|
|
4
|
+
toRef,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
COLOR_FORMATS,
|
|
9
|
+
detectColorFormat,
|
|
10
|
+
} from "../utils/colorUtils";
|
|
11
|
+
import {
|
|
12
|
+
isArray,
|
|
13
|
+
uniq,
|
|
14
|
+
} from "lodash-es";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Formats from the prop colorFormats (string or array, in the given order)
|
|
18
|
+
* and the format that is currently used in the dialog.
|
|
19
|
+
*/
|
|
20
|
+
export default function FormatAPI(props) {
|
|
21
|
+
const colorFormats = toRef(props, "colorFormats");
|
|
22
|
+
const modelValue = toRef(props, "modelValue");
|
|
23
|
+
|
|
24
|
+
const colorFormatsLocal = computed(() => {
|
|
25
|
+
const FORMATS = isArray(colorFormats.value) ? colorFormats.value : [colorFormats.value];
|
|
26
|
+
const VALID = uniq(FORMATS).filter(format => COLOR_FORMATS.indexOf(format) !== -1);
|
|
27
|
+
return VALID.length ? VALID : ["hex"];
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const currentFormat = ref(colorFormatsLocal.value[0]);
|
|
31
|
+
|
|
32
|
+
const isFormatSwitch = computed(() => colorFormatsLocal.value.length > 1);
|
|
33
|
+
|
|
34
|
+
const nextFormat = computed(() => {
|
|
35
|
+
const INDEX = colorFormatsLocal.value.indexOf(currentFormat.value);
|
|
36
|
+
return colorFormatsLocal.value[(INDEX + 1) % colorFormatsLocal.value.length];
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// The format of the model wins, if it is allowed. Otherwise the first format.
|
|
40
|
+
const setFormatFromModel = () => {
|
|
41
|
+
const FORMAT = detectColorFormat(modelValue.value);
|
|
42
|
+
currentFormat.value = colorFormatsLocal.value.indexOf(FORMAT) !== -1 ?
|
|
43
|
+
FORMAT :
|
|
44
|
+
colorFormatsLocal.value[0];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const switchFormat = () => {
|
|
48
|
+
currentFormat.value = nextFormat.value;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
colorFormatsLocal,
|
|
53
|
+
currentFormat,
|
|
54
|
+
isFormatSwitch,
|
|
55
|
+
nextFormat,
|
|
56
|
+
setFormatFromModel,
|
|
57
|
+
switchFormat,
|
|
58
|
+
};
|
|
59
|
+
}
|