@oscarpalmer/oui 0.39.0 → 0.41.0
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/README.md +1 -1
- package/dist/css/color-picker.css +80 -69
- package/dist/css/listbox.css +169 -0
- package/dist/js/color-picker/color-picker.constants.d.mts +2 -0
- package/dist/js/color-picker/{constants.color-picker.mjs → color-picker.constants.mjs} +7 -4
- package/dist/js/color-picker/{dom.color-picker.d.mts → color-picker.dom.d.mts} +2 -2
- package/dist/js/color-picker/{dom.color-picker.mjs → color-picker.dom.mjs} +33 -16
- package/dist/js/color-picker/{event.color-picker.d.mts → color-picker.event.d.mts} +3 -3
- package/dist/js/color-picker/color-picker.event.mjs +233 -0
- package/dist/js/color-picker/{form.color-picker.d.mts → color-picker.form.d.mts} +2 -2
- package/dist/js/color-picker/{form.color-picker.mjs → color-picker.form.mjs} +9 -8
- package/dist/js/color-picker/color-picker.misc.d.mts +2 -0
- package/dist/js/color-picker/color-picker.misc.mjs +104 -0
- package/dist/js/color-picker/color-picker.model.d.mts +2 -0
- package/dist/js/color-picker/{models.color-picker.mjs → color-picker.model.mjs} +1 -1
- package/dist/js/color-picker/{output.color-picker.d.mts → color-picker.output.d.mts} +2 -2
- package/dist/js/color-picker/{output.color-picker.mjs → color-picker.output.mjs} +19 -18
- package/dist/js/color-picker/color-picker.state.d.mts +8 -0
- package/dist/js/color-picker/color-picker.state.mjs +168 -0
- package/dist/js/color-picker/index.d.mts +172 -2
- package/dist/js/color-picker/index.mjs +66 -59
- package/dist/js/color-picker.constants-BZgXQr5o.d.mts +177 -0
- package/dist/js/color-picker.misc-BIS3R6jk.d.mts +31 -0
- package/dist/js/combobox/combobox.constants.d.mts +2 -0
- package/dist/js/combobox/{constants.combobox.mjs → combobox.constants.mjs} +21 -21
- package/dist/js/combobox/combobox.dom.d.mts +25 -0
- package/dist/js/combobox/{dom.combobox.mjs → combobox.dom.mjs} +51 -49
- package/dist/js/combobox/{event.combobox.d.mts → combobox.event.d.mts} +9 -9
- package/dist/js/combobox/{event.combobox.mjs → combobox.event.mjs} +1 -1
- package/dist/js/combobox/combobox.misc.d.mts +2 -0
- package/dist/js/combobox/combobox.misc.mjs +2 -0
- package/dist/js/combobox/combobox.model.d.mts +2 -0
- package/dist/js/combobox/combobox.state.d.mts +9 -0
- package/dist/js/combobox/combobox.state.mjs +2 -0
- package/dist/js/combobox/index.d.mts +152 -2
- package/dist/js/combobox/index.mjs +54 -55
- package/dist/js/combobox.constants-Hb3bqqQJ.d.mts +19 -0
- package/dist/js/combobox.misc-DRDFk6X8.d.mts +26 -0
- package/dist/js/combobox.model-gjEI2VqZ.d.mts +46 -0
- package/dist/js/{state.combobox-BWDFHwoi.mjs → combobox.state-AstCICiH.mjs} +109 -106
- package/dist/js/dialog/dialog.model.d.mts +2 -0
- package/dist/js/dialog/dialog.model.mjs +11 -0
- package/dist/js/dialog/index.d.mts +12 -0
- package/dist/js/dialog/index.mjs +123 -0
- package/dist/js/dialog.model-HVzYWoDo.d.mts +45 -0
- package/dist/js/floatable/floatable.embedded.d.mts +2 -2
- package/dist/js/floatable/floatable.embedded.mjs +64 -92
- package/dist/js/floatable/floatable.model.d.mts +2 -0
- package/dist/js/floatable/floatable.model.mjs +23 -0
- package/dist/js/floatable/floatable.standalone.d.mts +2 -1
- package/dist/js/floatable.embedded-ncshL3Sa.d.mts +17 -0
- package/dist/js/{floatable.embedded-DQYkXt8X.d.mts → floatable.model-DXsQgoU7.d.mts} +13 -20
- package/dist/js/focus-trap/focus-trap.embedded.d.mts +2 -2
- package/dist/js/focus-trap/focus-trap.embedded.mjs +117 -138
- package/dist/js/focus-trap/focus-trap.model.d.mts +2 -0
- package/dist/js/focus-trap/focus-trap.model.mjs +15 -0
- package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -1
- package/dist/js/focus-trap.embedded-DpcPkP7c.d.mts +13 -0
- package/dist/js/{focus-trap.embedded-CjyFQYow.d.mts → focus-trap.model-CpltX5B5.d.mts} +16 -18
- package/dist/js/index.d.mts +26 -14
- package/dist/js/index.mjs +18 -17
- package/dist/js/internal/attributable.d.mts +1 -1
- package/dist/js/internal/attributable.mjs +3 -2
- package/dist/js/internal/draggable/draggable.model.d.mts +2 -0
- package/dist/js/internal/draggable/draggable.model.mjs +37 -0
- package/dist/js/internal/draggable/index.d.mts +13 -0
- package/dist/js/internal/draggable/index.mjs +243 -0
- package/dist/js/internal/l10n/index.d.mts +5 -0
- package/dist/js/internal/l10n/index.mjs +147 -0
- package/dist/js/internal/l10n/l10n.model.d.mts +2 -0
- package/dist/js/internal/l10n/l10n.model.mjs +12 -0
- package/dist/js/internal/misc.d.mts +3 -2
- package/dist/js/internal/misc.mjs +4 -6
- package/dist/js/internal/navigable/index.d.mts +6 -0
- package/dist/js/internal/navigable/index.mjs +125 -0
- package/dist/js/internal/navigable/navigable.model.d.mts +2 -0
- package/dist/js/internal/navigable/navigable.model.mjs +18 -0
- package/dist/js/internal/option-list/option-list.constants.d.mts +8 -0
- package/dist/js/internal/option-list/option-list.constants.mjs +22 -0
- package/dist/js/internal/option-list/option-list.data.d.mts +21 -0
- package/dist/js/internal/option-list/option-list.data.mjs +2 -0
- package/dist/js/internal/option-list/option-list.dom.d.mts +18 -0
- package/dist/js/internal/option-list/option-list.dom.mjs +2 -0
- package/dist/js/internal/option-list/option-list.event.d.mts +6 -0
- package/dist/js/internal/option-list/option-list.event.mjs +66 -0
- package/dist/js/internal/option-list/option-list.form.d.mts +7 -0
- package/dist/js/internal/option-list/option-list.form.mjs +53 -0
- package/dist/js/internal/option-list/option-list.misc.d.mts +13 -0
- package/dist/js/internal/option-list/option-list.misc.mjs +2 -0
- package/dist/js/internal/option-list/option-list.model.d.mts +2 -0
- package/dist/js/internal/option-list/option-list.state.d.mts +8 -0
- package/dist/js/internal/option-list/option-list.state.mjs +39 -0
- package/dist/js/l10n/index.d.mts +3 -0
- package/dist/js/l10n/index.mjs +2 -0
- package/dist/js/l10n.model-D1E1u35L.d.mts +54 -0
- package/dist/js/listbox/index.d.mts +9 -18
- package/dist/js/listbox/index.mjs +49 -52
- package/dist/js/listbox/listbox.constants.d.mts +2 -0
- package/dist/js/listbox/{constants.listbox.mjs → listbox.constants.mjs} +11 -15
- package/dist/js/listbox/listbox.dom.d.mts +5 -0
- package/dist/js/listbox/listbox.dom.mjs +2 -0
- package/dist/js/listbox/listbox.event.d.mts +9 -0
- package/dist/js/listbox/listbox.event.mjs +2 -0
- package/dist/js/listbox/listbox.misc.d.mts +2 -0
- package/dist/js/listbox/listbox.misc.mjs +2 -0
- package/dist/js/listbox/listbox.model.d.mts +2 -0
- package/dist/js/listbox/listbox.model.mjs +1 -0
- package/dist/js/listbox/listbox.state.d.mts +9 -0
- package/dist/js/listbox/listbox.state.mjs +2 -0
- package/dist/js/listbox.constants-DOBMwKup.d.mts +9 -0
- package/dist/js/listbox.misc-DwfB4Mu_.d.mts +24 -0
- package/dist/js/listbox.model-C0MYWXZe.d.mts +20 -0
- package/dist/js/listbox.state-BrN296BM.mjs +240 -0
- package/dist/js/menu/index.mjs +171 -0
- package/dist/js/menu/menu.model.d.mts +33 -0
- package/dist/js/menu/menu.model.mjs +15 -0
- package/dist/js/movable/movable.embedded.d.mts +2 -2
- package/dist/js/movable/movable.embedded.mjs +77 -86
- package/dist/js/movable/movable.model.d.mts +2 -0
- package/dist/js/movable/movable.model.mjs +12 -0
- package/dist/js/movable/movable.standalone.d.mts +2 -1
- package/dist/js/movable.embedded-C1bDTLGs.d.mts +11 -0
- package/dist/js/movable.model-D9nnPWKk.d.mts +186 -0
- package/dist/js/navigable.model-BqoR6iBv.d.mts +44 -0
- package/dist/js/option-list.data-CgMyUwPc.mjs +441 -0
- package/dist/js/option-list.model-CCPUlPeX.d.mts +169 -0
- package/dist/js/popover/index.d.mts +12 -0
- package/dist/js/{popover.mjs → popover/index.mjs} +41 -51
- package/dist/js/popover/popover.model.d.mts +2 -0
- package/dist/js/popover/popover.model.mjs +12 -0
- package/dist/js/popover.model-DiLdz0Hc.d.mts +38 -0
- package/dist/js/resizable/resizable.embedded.d.mts +2 -2
- package/dist/js/resizable/resizable.embedded.mjs +43 -58
- package/dist/js/resizable/resizable.model.d.mts +2 -0
- package/dist/js/resizable/resizable.model.mjs +21 -0
- package/dist/js/resizable/resizable.standalone.d.mts +2 -1
- package/dist/js/resizable.embedded-BemH-7Re.d.mts +11 -0
- package/dist/js/resizable.model-YEtcC9li.d.mts +46 -0
- package/dist/js/sortable/sortable.embedded.d.mts +2 -2
- package/dist/js/sortable/sortable.embedded.mjs +111 -116
- package/dist/js/sortable/sortable.model.d.mts +2 -0
- package/dist/js/sortable/sortable.model.mjs +24 -0
- package/dist/js/sortable/sortable.standalone.d.mts +2 -1
- package/dist/js/sortable.embedded-CrEGff9k.d.mts +11 -0
- package/dist/js/{splitter.d.mts → splitter/index.d.mts} +6 -4
- package/dist/js/{splitter.mjs → splitter/index.mjs} +90 -128
- package/dist/js/splitter/splitter.model.d.mts +2 -0
- package/dist/js/splitter/splitter.model.mjs +37 -0
- package/dist/js/splitter.model-C24W6eZ7.d.mts +57 -0
- package/dist/js/{tabs.d.mts → tabs/index.d.mts} +8 -8
- package/dist/js/{tabs.mjs → tabs/index.mjs} +58 -58
- package/dist/js/tabs/tabs.model.d.mts +2 -0
- package/dist/js/tabs/tabs.model.mjs +18 -0
- package/dist/js/tabs.model-BHPy7fPo.d.mts +40 -0
- package/dist/js/toolbar/index.mjs +27 -0
- package/dist/js/toolbar/toolbar.model.d.mts +11 -0
- package/dist/js/toolbar/toolbar.model.mjs +7 -0
- package/dist/js/tooltip/index.d.mts +19 -0
- package/dist/js/{tooltip.mjs → tooltip/index.mjs} +61 -86
- package/dist/js/tooltip/tooltip.model.d.mts +2 -0
- package/dist/js/tooltip/tooltip.model.mjs +15 -0
- package/dist/js/tooltip.model-BpNStw5z.d.mts +37 -0
- package/package.json +30 -24
- package/dist/js/color-picker/constants.color-picker.d.mts +0 -2
- package/dist/js/color-picker/event.color-picker.mjs +0 -2
- package/dist/js/color-picker/misc.color-picker.d.mts +0 -2
- package/dist/js/color-picker/misc.color-picker.mjs +0 -2
- package/dist/js/color-picker/models.color-picker.d.mts +0 -2
- package/dist/js/color-picker/state.color-picker.d.mts +0 -8
- package/dist/js/color-picker/state.color-picker.mjs +0 -2
- package/dist/js/combobox/constants.combobox.d.mts +0 -2
- package/dist/js/combobox/dom.combobox.d.mts +0 -26
- package/dist/js/combobox/misc.combobox.d.mts +0 -2
- package/dist/js/combobox/misc.combobox.mjs +0 -2
- package/dist/js/combobox/models.combobox.d.mts +0 -43
- package/dist/js/combobox/state.combobox.d.mts +0 -11
- package/dist/js/combobox/state.combobox.mjs +0 -2
- package/dist/js/constants.color-picker-B-gFjL8m.d.mts +0 -364
- package/dist/js/constants.combobox-8EMRmv09.d.mts +0 -18
- package/dist/js/constants.listbox-DGnX32kv.d.mts +0 -8
- package/dist/js/dialog.d.mts +0 -47
- package/dist/js/dialog.mjs +0 -131
- package/dist/js/draggable-B5-70SZm.d.mts +0 -155
- package/dist/js/event.color-picker-BEpq0Adu.mjs +0 -485
- package/dist/js/index-C5D3-oiI.d.mts +0 -177
- package/dist/js/internal/draggable.d.mts +0 -2
- package/dist/js/internal/draggable.mjs +0 -265
- package/dist/js/internal/listbox/listbox.constants.d.mts +0 -8
- package/dist/js/internal/listbox/listbox.constants.mjs +0 -22
- package/dist/js/internal/listbox/listbox.data.d.mts +0 -19
- package/dist/js/internal/listbox/listbox.data.mjs +0 -2
- package/dist/js/internal/listbox/listbox.dom.d.mts +0 -65
- package/dist/js/internal/listbox/listbox.dom.mjs +0 -2
- package/dist/js/internal/listbox/listbox.event.d.mts +0 -4
- package/dist/js/internal/listbox/listbox.event.mjs +0 -63
- package/dist/js/internal/listbox/listbox.form.d.mts +0 -5
- package/dist/js/internal/listbox/listbox.form.mjs +0 -53
- package/dist/js/internal/listbox/listbox.misc.d.mts +0 -11
- package/dist/js/internal/listbox/listbox.misc.mjs +0 -2
- package/dist/js/internal/listbox/listbox.model.d.mts +0 -2
- package/dist/js/internal/listbox/listbox.state.d.mts +0 -6
- package/dist/js/internal/listbox/listbox.state.mjs +0 -40
- package/dist/js/internal/navigable.d.mts +0 -36
- package/dist/js/internal/navigable.mjs +0 -135
- package/dist/js/l10n-Bn-7RcwR.d.mts +0 -20
- package/dist/js/l10n.d.mts +0 -2
- package/dist/js/l10n.mjs +0 -80
- package/dist/js/listbox/constants.listbox.d.mts +0 -2
- package/dist/js/listbox/event.listbox.d.mts +0 -7
- package/dist/js/listbox/event.listbox.mjs +0 -2
- package/dist/js/listbox/misc.listbox.d.mts +0 -2
- package/dist/js/listbox/misc.listbox.mjs +0 -2
- package/dist/js/listbox/state.listbox.d.mts +0 -10
- package/dist/js/listbox/state.listbox.mjs +0 -2
- package/dist/js/listbox.data-DQ7-x2uY.mjs +0 -425
- package/dist/js/listbox.model-BHPA7GM4.d.mts +0 -125
- package/dist/js/menu.mjs +0 -172
- package/dist/js/misc.listbox-DKB-j0UK.mjs +0 -196
- package/dist/js/misc.listbox-mZMuYOxg.d.mts +0 -20
- package/dist/js/popover.d.mts +0 -38
- package/dist/js/resizable.embedded-dvhdfQgt.d.mts +0 -34
- package/dist/js/toolbar.mjs +0 -31
- package/dist/js/tooltip.d.mts +0 -45
- /package/dist/js/combobox/{models.combobox.mjs → combobox.model.mjs} +0 -0
- /package/dist/js/internal/{listbox/listbox.model.mjs → option-list/option-list.model.mjs} +0 -0
- /package/dist/js/{menu.d.mts → menu/index.d.mts} +0 -0
- /package/dist/js/{toolbar.d.mts → toolbar/index.d.mts} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { createEmbeddedFloatable } from "../floatable/floatable.embedded.mjs";
|
|
2
|
+
import { createLocalizations } from "../internal/l10n/index.mjs";
|
|
3
|
+
import { COLOR_PICKER_INPUT_TYPES, COLOR_PICKER_MESSAGE_INPUT, COLOR_PICKER_MESSAGE_LABEL, COLOR_PICKER_SYMBOL, colorPickerLocalizations } from "./color-picker.constants.mjs";
|
|
4
|
+
import { updateColorPickerValidity } from "./color-picker.form.mjs";
|
|
5
|
+
import { getColorPickerId, getColorPickerOutput, setColorPickerDisabled, setColorPickerRequired, setColorPickerValues, updateColorPickerLabels } from "./color-picker.misc.mjs";
|
|
6
|
+
import { colorPickerMovement, onColorPickerHue, onColorPickerInput, onColorPickerOpacity, onColorPickerOutputFormat, onColorPickerOutputValue } from "./color-picker.event.mjs";
|
|
7
|
+
import { createColorPickerAnchor, createColorPickerContent } from "./color-picker.dom.mjs";
|
|
8
|
+
import { getAria, setAria } from "@oscarpalmer/toretto/aria";
|
|
9
|
+
import { setAttributes } from "@oscarpalmer/toretto/attribute";
|
|
10
|
+
import { on } from "@oscarpalmer/toretto/event";
|
|
11
|
+
import { createElement } from "@oscarpalmer/toretto/create";
|
|
12
|
+
import { getColor, isHexColor } from "@oscarpalmer/atoms/color";
|
|
13
|
+
//#region src/js/color-picker/color-picker.state.ts
|
|
14
|
+
function attachColorPicker(state) {
|
|
15
|
+
const { component } = state;
|
|
16
|
+
const { anchor, content, host, id, inline, input, label, listeners, style } = state.component;
|
|
17
|
+
if (!inline) {
|
|
18
|
+
component.floatable = createEmbeddedFloatable(anchor.container ?? anchor.container, content.element, {
|
|
19
|
+
position: "below-start",
|
|
20
|
+
reusable: false
|
|
21
|
+
});
|
|
22
|
+
component.floatable.update();
|
|
23
|
+
}
|
|
24
|
+
const labelId = `${id}_label`;
|
|
25
|
+
setAria(host, {
|
|
26
|
+
describedby: getAria(input, "describedby"),
|
|
27
|
+
labelledby: labelId
|
|
28
|
+
});
|
|
29
|
+
setAttributes(host, { name: input.name === "" ? input.id : input.name });
|
|
30
|
+
label.element.htmlFor = anchor.input.id;
|
|
31
|
+
label.element.id = labelId;
|
|
32
|
+
if (anchor.toggle != null) setAria(anchor.toggle, "expanded", false);
|
|
33
|
+
input.before(style, anchor.container, content.element);
|
|
34
|
+
input.remove();
|
|
35
|
+
listeners.push(on(host, "focusout", () => {
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
if (colorPickerMovement.parameters == null && !host.contains(document.activeElement)) component.floatable?.hide();
|
|
38
|
+
});
|
|
39
|
+
}), on(anchor.input, "change", () => {
|
|
40
|
+
onColorPickerInput(state);
|
|
41
|
+
}), on(anchor.input, "input", () => {
|
|
42
|
+
onColorPickerInput(state);
|
|
43
|
+
}), on(content.element, "beforetoggle", (event) => {
|
|
44
|
+
if (component.disabled) event.preventDefault();
|
|
45
|
+
}, { passive: false }), on(content.element, "toggle", (event) => {
|
|
46
|
+
const open = event.newState === "open";
|
|
47
|
+
if (anchor.toggle != null) setAria(anchor.toggle, "expanded", open);
|
|
48
|
+
if (open) content.well.knob.focus();
|
|
49
|
+
}), on(content.hue.input, "input", () => {
|
|
50
|
+
onColorPickerHue(state);
|
|
51
|
+
}));
|
|
52
|
+
if (content.opacity != null) listeners.push(on(content.opacity.input, "input", () => {
|
|
53
|
+
onColorPickerOpacity(state, content.opacity.input);
|
|
54
|
+
}), on(content.opacity.range, "input", () => {
|
|
55
|
+
onColorPickerOpacity(state, content.opacity.range);
|
|
56
|
+
}));
|
|
57
|
+
if (content.output?.toggle != null) listeners.push(on(content.element, "change", (event) => {
|
|
58
|
+
onColorPickerOutputValue(event, state);
|
|
59
|
+
}), on(content.element, "input", (event) => {
|
|
60
|
+
onColorPickerOutputValue(event, state);
|
|
61
|
+
}), on(content.output.toggle, "change", () => {
|
|
62
|
+
onColorPickerOutputFormat(state);
|
|
63
|
+
}));
|
|
64
|
+
colorPickers.add(state);
|
|
65
|
+
}
|
|
66
|
+
function detachColorPicker(state) {
|
|
67
|
+
const { component } = state;
|
|
68
|
+
const { anchor, content, floatable, host, input, label, style } = component;
|
|
69
|
+
floatable?.destroy();
|
|
70
|
+
setAria(host, {
|
|
71
|
+
describedby: void 0,
|
|
72
|
+
labelledby: void 0
|
|
73
|
+
});
|
|
74
|
+
setAttributes(host, { name: void 0 });
|
|
75
|
+
label.element.htmlFor = input.id;
|
|
76
|
+
label.element.id = label.id;
|
|
77
|
+
anchor.container.before(input);
|
|
78
|
+
anchor.container.remove();
|
|
79
|
+
content.element.remove();
|
|
80
|
+
style.remove();
|
|
81
|
+
const listeners = component.listeners.splice(0);
|
|
82
|
+
const { length } = listeners;
|
|
83
|
+
for (let index = 0; index < length; index += 1) listeners[index]();
|
|
84
|
+
colorPickers.delete(state);
|
|
85
|
+
}
|
|
86
|
+
function initializeColorPicker(colorPicker) {
|
|
87
|
+
const state = colorPicker[COLOR_PICKER_SYMBOL];
|
|
88
|
+
colorPicker[COLOR_PICKER_SYMBOL].component = initializeColorPickerComponent(colorPicker, state);
|
|
89
|
+
if (state.form.restored != null) {
|
|
90
|
+
colorPicker.value = state.form.restored;
|
|
91
|
+
state.form.restored = void 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function initializeColorPickerComponent(element, state) {
|
|
95
|
+
const input = element.querySelector("input");
|
|
96
|
+
if (input == null || !COLOR_PICKER_INPUT_TYPES.has(input.type)) throw new Error(COLOR_PICKER_MESSAGE_INPUT);
|
|
97
|
+
const label = element.querySelector(`label[for="${input.id}"]`);
|
|
98
|
+
if (!(label instanceof HTMLLabelElement)) throw new Error(COLOR_PICKER_MESSAGE_LABEL);
|
|
99
|
+
element.id = input.id;
|
|
100
|
+
const id = getColorPickerId();
|
|
101
|
+
const labelId = label.id;
|
|
102
|
+
const alpha = element.hasAttribute("alpha");
|
|
103
|
+
const color = getColor(input.value);
|
|
104
|
+
const copy = element.hasAttribute("copy");
|
|
105
|
+
const disabled = element.hasAttribute("disabled") || input.disabled;
|
|
106
|
+
const inline = element.hasAttribute("inline");
|
|
107
|
+
const output = getColorPickerOutput(element);
|
|
108
|
+
const readonly = element.hasAttribute("readonly") || input.readOnly;
|
|
109
|
+
const required = element.hasAttribute("required") || input.required;
|
|
110
|
+
const parameters = {
|
|
111
|
+
alpha,
|
|
112
|
+
color,
|
|
113
|
+
copy,
|
|
114
|
+
id,
|
|
115
|
+
inline,
|
|
116
|
+
input,
|
|
117
|
+
output
|
|
118
|
+
};
|
|
119
|
+
const anchor = createColorPickerAnchor(parameters);
|
|
120
|
+
const content = createColorPickerContent(parameters);
|
|
121
|
+
const formatted = color.toHexString(alpha);
|
|
122
|
+
state.component = {
|
|
123
|
+
alpha,
|
|
124
|
+
anchor,
|
|
125
|
+
content,
|
|
126
|
+
copy,
|
|
127
|
+
disabled,
|
|
128
|
+
id,
|
|
129
|
+
inline,
|
|
130
|
+
input,
|
|
131
|
+
output,
|
|
132
|
+
readonly,
|
|
133
|
+
required,
|
|
134
|
+
color: {
|
|
135
|
+
foreground: "",
|
|
136
|
+
value: color
|
|
137
|
+
},
|
|
138
|
+
host: element,
|
|
139
|
+
label: {
|
|
140
|
+
element: label,
|
|
141
|
+
id: labelId
|
|
142
|
+
},
|
|
143
|
+
listeners: [],
|
|
144
|
+
localizations: createLocalizations(colorPickerLocalizations),
|
|
145
|
+
style: createElement("style"),
|
|
146
|
+
value: {
|
|
147
|
+
current: formatted,
|
|
148
|
+
initial: formatted
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
attachColorPicker(state);
|
|
152
|
+
setAttributes(element, {
|
|
153
|
+
output,
|
|
154
|
+
alpha: alpha ? "" : void 0,
|
|
155
|
+
copy: copy ? "" : void 0,
|
|
156
|
+
inline: inline ? "" : void 0
|
|
157
|
+
});
|
|
158
|
+
setColorPickerDisabled(state, "disabled", disabled);
|
|
159
|
+
setColorPickerDisabled(state, "readonly", readonly);
|
|
160
|
+
setColorPickerRequired(state, required);
|
|
161
|
+
setColorPickerValues(state, false);
|
|
162
|
+
updateColorPickerLabels(state);
|
|
163
|
+
updateColorPickerValidity(state, isHexColor(state.component.value.current, alpha));
|
|
164
|
+
return state.component;
|
|
165
|
+
}
|
|
166
|
+
const colorPickers = /* @__PURE__ */ new Set();
|
|
167
|
+
//#endregion
|
|
168
|
+
export { attachColorPicker, colorPickers, detachColorPicker, initializeColorPicker, initializeColorPickerComponent };
|
|
@@ -1,2 +1,172 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { p as OuiLocalizations } from "../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { B as OuiColorPickerState, N as OuiColorPickerEvent, P as OuiColorPickerLocalizations, b as COLOR_PICKER_SYMBOL, x as COLOR_PICKER_TAGNAME } from "../color-picker.constants-BZgXQr5o.mjs";
|
|
3
|
+
import { a as setColorPickerLocalizations } from "../color-picker.misc-BIS3R6jk.mjs";
|
|
4
|
+
import { HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "@oscarpalmer/atoms/color";
|
|
5
|
+
//#region src/js/color-picker/index.d.ts
|
|
6
|
+
declare global {
|
|
7
|
+
interface HTMLElementTagNameMap {
|
|
8
|
+
[COLOR_PICKER_TAGNAME]: OuiColorPickerElement;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export interface OuiColorPickerElement {
|
|
12
|
+
[COLOR_PICKER_SYMBOL]: OuiColorPickerState;
|
|
13
|
+
}
|
|
14
|
+
export declare class OuiColorPickerElement extends HTMLElement {
|
|
15
|
+
static formAssociated: boolean;
|
|
16
|
+
static observedAttributes: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Is the color picker disabled?
|
|
19
|
+
*/
|
|
20
|
+
get disabled(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Should the color picker be disabled?
|
|
23
|
+
*/
|
|
24
|
+
set disabled(value: boolean);
|
|
25
|
+
/**
|
|
26
|
+
* Form element associated with the color picker
|
|
27
|
+
*/
|
|
28
|
+
get form(): HTMLFormElement | null;
|
|
29
|
+
/**
|
|
30
|
+
* Color value as hexadecimal string
|
|
31
|
+
*/
|
|
32
|
+
get hex(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Set color value from a hexadecimal string
|
|
35
|
+
*/
|
|
36
|
+
set hex(value: string);
|
|
37
|
+
/**
|
|
38
|
+
* Color value as hexadecimal string with alpha channel
|
|
39
|
+
*/
|
|
40
|
+
get hexa(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Set color value from a hexadecimal string with alpha channel
|
|
43
|
+
*/
|
|
44
|
+
set hexa(value: string);
|
|
45
|
+
/**
|
|
46
|
+
* Color value as an _HSL_ color object
|
|
47
|
+
*/
|
|
48
|
+
get hsl(): HSLColor;
|
|
49
|
+
/**
|
|
50
|
+
* Set color value from an _HSL_ color object
|
|
51
|
+
*/
|
|
52
|
+
set hsl(value: HSLColor);
|
|
53
|
+
/**
|
|
54
|
+
* Color value as an _HSLA_ color object _(HSL with alpha channel)_
|
|
55
|
+
*/
|
|
56
|
+
get hsla(): HSLAColor;
|
|
57
|
+
/**
|
|
58
|
+
* Set color value from an _HSLA_ color object _(HSL with alpha channel)_
|
|
59
|
+
*/
|
|
60
|
+
set hsla(value: HSLAColor);
|
|
61
|
+
/**
|
|
62
|
+
* Color value as an _HWB_ color object
|
|
63
|
+
*/
|
|
64
|
+
get hwb(): HWBColor;
|
|
65
|
+
/**
|
|
66
|
+
* Set color value from an _HWB_ color object
|
|
67
|
+
*/
|
|
68
|
+
set hwb(value: HWBColor);
|
|
69
|
+
/**
|
|
70
|
+
* Color value as an _HWBA_ color object _(HWB with alpha channel)_
|
|
71
|
+
*/
|
|
72
|
+
get hwba(): HWBAColor;
|
|
73
|
+
/**
|
|
74
|
+
* Set color value from an _HWBA_ color object _(HWB with alpha channel)_
|
|
75
|
+
*/
|
|
76
|
+
set hwba(value: HWBAColor);
|
|
77
|
+
/**
|
|
78
|
+
* Text input value
|
|
79
|
+
*/
|
|
80
|
+
get input(): string;
|
|
81
|
+
/**
|
|
82
|
+
* Label elements associated with the color picker
|
|
83
|
+
*/
|
|
84
|
+
get labels(): NodeList;
|
|
85
|
+
/**
|
|
86
|
+
* Localization information for the color picker
|
|
87
|
+
*/
|
|
88
|
+
get localizations(): OuiLocalizations<OuiColorPickerLocalizations>;
|
|
89
|
+
/**
|
|
90
|
+
* Is the color picker readonly?
|
|
91
|
+
*/
|
|
92
|
+
get readonly(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Should the color picker be readonly?
|
|
95
|
+
*/
|
|
96
|
+
set readonly(value: boolean);
|
|
97
|
+
/**
|
|
98
|
+
* Is the color picker required?
|
|
99
|
+
*/
|
|
100
|
+
get required(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Should the color picker be required?
|
|
103
|
+
*/
|
|
104
|
+
set required(value: boolean);
|
|
105
|
+
/**
|
|
106
|
+
* Color value as an _RGB_ color object
|
|
107
|
+
*/
|
|
108
|
+
get rgb(): RGBColor;
|
|
109
|
+
/**
|
|
110
|
+
* Set color value from an _RGB_ color object
|
|
111
|
+
*/
|
|
112
|
+
set rgb(value: RGBColor);
|
|
113
|
+
/**
|
|
114
|
+
* Color value as an _RGBA_ color object _(RGB with alpha channel)_
|
|
115
|
+
*/
|
|
116
|
+
get rgba(): RGBAColor;
|
|
117
|
+
/**
|
|
118
|
+
* Set color value from an _RGBA_ color object _(RGB with alpha channel)_
|
|
119
|
+
*/
|
|
120
|
+
set rgba(value: RGBAColor);
|
|
121
|
+
/**
|
|
122
|
+
* Validation message for the color picker
|
|
123
|
+
*/
|
|
124
|
+
get validationMessage(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Validity state for the color picker
|
|
127
|
+
*/
|
|
128
|
+
get validity(): ValidityState;
|
|
129
|
+
/**
|
|
130
|
+
* Current color value
|
|
131
|
+
*/
|
|
132
|
+
get value(): string;
|
|
133
|
+
/**
|
|
134
|
+
* Set color value from a string, _HSL(A)_, _HWB(A)_, or _RGB(A)_ color object
|
|
135
|
+
*/
|
|
136
|
+
set value(value: string | HSLColor | HSLAColor | HWBColor | HWBAColor | RGBColor | RGBAColor);
|
|
137
|
+
/**
|
|
138
|
+
* Can the color picker be validated?
|
|
139
|
+
*/
|
|
140
|
+
get willValidate(): boolean;
|
|
141
|
+
constructor();
|
|
142
|
+
attributeChangedCallback(name: string, _: string | null, value: string | null): void;
|
|
143
|
+
/**
|
|
144
|
+
* Check if the color picker is valid
|
|
145
|
+
*
|
|
146
|
+
* @returns `true` if the color picker is valid, otherwise `false`
|
|
147
|
+
*/
|
|
148
|
+
checkValidity(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Clear the color picker's value
|
|
151
|
+
*/
|
|
152
|
+
clear(): void;
|
|
153
|
+
connectedCallback(): void;
|
|
154
|
+
disconnectedCallback(): void;
|
|
155
|
+
formDisabledCallback(disabled: boolean): void;
|
|
156
|
+
formResetCallback(): void;
|
|
157
|
+
formStateRestoreCallback(state: unknown, reason: unknown): void;
|
|
158
|
+
/**
|
|
159
|
+
* Check if the color picker is valid and report any validation errors
|
|
160
|
+
*
|
|
161
|
+
* @returns `true` if the color picker is valid, otherwise `false`
|
|
162
|
+
*/
|
|
163
|
+
reportValidity(): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Set a custom validation message for the color picker
|
|
166
|
+
*
|
|
167
|
+
* @param message Validation message
|
|
168
|
+
*/
|
|
169
|
+
setCustomValidity(message: string): void;
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { OuiColorPickerEvent, setColorPickerLocalizations };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OuiColorPickerEvent } from "./
|
|
3
|
-
import {
|
|
1
|
+
import { COLOR_PICKER_SYMBOL, COLOR_PICKER_TAGNAME } from "./color-picker.constants.mjs";
|
|
2
|
+
import { OuiColorPickerEvent } from "./color-picker.model.mjs";
|
|
3
|
+
import { setColorPickerDisabled, setColorPickerLocalizations, setColorPickerRequired, setColorPickerValue } from "./color-picker.misc.mjs";
|
|
4
|
+
import { onColorPickerInput } from "./color-picker.event.mjs";
|
|
5
|
+
import { attachColorPicker, detachColorPicker, initializeColorPickerComponent } from "./color-picker.state.mjs";
|
|
4
6
|
import "@oscarpalmer/atoms/color";
|
|
5
7
|
//#region src/js/color-picker/index.ts
|
|
6
8
|
var OuiColorPickerElement = class extends HTMLElement {
|
|
@@ -10,56 +12,54 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
10
12
|
"required",
|
|
11
13
|
"value"
|
|
12
14
|
];
|
|
13
|
-
#internals;
|
|
14
|
-
#restored;
|
|
15
|
-
#state;
|
|
16
15
|
/**
|
|
17
16
|
* Is the color picker disabled?
|
|
18
17
|
*/
|
|
19
18
|
get disabled() {
|
|
20
|
-
return this
|
|
19
|
+
return this[COLOR_PICKER_SYMBOL]?.component.disabled ?? false;
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* Should the color picker be disabled?
|
|
24
23
|
*/
|
|
25
24
|
set disabled(value) {
|
|
26
|
-
|
|
25
|
+
const state = this[COLOR_PICKER_SYMBOL];
|
|
26
|
+
if (state.component != null && typeof value === "boolean" && value !== state.component.disabled) setColorPickerDisabled(state, "disabled", value);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Form element associated with the color picker
|
|
30
30
|
*/
|
|
31
31
|
get form() {
|
|
32
|
-
return this
|
|
32
|
+
return this[COLOR_PICKER_SYMBOL].form.internals.form;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Color value as hexadecimal string
|
|
36
36
|
*/
|
|
37
37
|
get hex() {
|
|
38
|
-
return this
|
|
38
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.hex ?? "";
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Set color value from a hexadecimal string
|
|
42
42
|
*/
|
|
43
43
|
set hex(value) {
|
|
44
|
-
setColorPickerValue(this
|
|
44
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "hex");
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Color value as hexadecimal string with alpha channel
|
|
48
48
|
*/
|
|
49
49
|
get hexa() {
|
|
50
|
-
return this
|
|
50
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.hexa ?? "";
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Set color value from a hexadecimal string with alpha channel
|
|
54
54
|
*/
|
|
55
55
|
set hexa(value) {
|
|
56
|
-
setColorPickerValue(this
|
|
56
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "hexa");
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Color value as an _HSL_ color object
|
|
60
60
|
*/
|
|
61
61
|
get hsl() {
|
|
62
|
-
return this
|
|
62
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.hsl ?? {
|
|
63
63
|
hue: 0,
|
|
64
64
|
lightness: 0,
|
|
65
65
|
saturation: 0
|
|
@@ -69,13 +69,13 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
69
69
|
* Set color value from an _HSL_ color object
|
|
70
70
|
*/
|
|
71
71
|
set hsl(value) {
|
|
72
|
-
setColorPickerValue(this
|
|
72
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "hsl");
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Color value as an _HSLA_ color object _(HSL with alpha channel)_
|
|
76
76
|
*/
|
|
77
77
|
get hsla() {
|
|
78
|
-
return this
|
|
78
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.hsla ?? {
|
|
79
79
|
hue: 0,
|
|
80
80
|
lightness: 0,
|
|
81
81
|
saturation: 0,
|
|
@@ -86,13 +86,13 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
86
86
|
* Set color value from an _HSLA_ color object _(HSL with alpha channel)_
|
|
87
87
|
*/
|
|
88
88
|
set hsla(value) {
|
|
89
|
-
setColorPickerValue(this
|
|
89
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "hsla");
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Color value as an _HWB_ color object
|
|
93
93
|
*/
|
|
94
94
|
get hwb() {
|
|
95
|
-
return this
|
|
95
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.hwb ?? {
|
|
96
96
|
hue: 0,
|
|
97
97
|
whiteness: 0,
|
|
98
98
|
blackness: 0
|
|
@@ -102,13 +102,13 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
102
102
|
* Set color value from an _HWB_ color object
|
|
103
103
|
*/
|
|
104
104
|
set hwb(value) {
|
|
105
|
-
setColorPickerValue(this
|
|
105
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "hwb");
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Color value as an _HWBA_ color object _(HWB with alpha channel)_
|
|
109
109
|
*/
|
|
110
110
|
get hwba() {
|
|
111
|
-
return this
|
|
111
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.hwba ?? {
|
|
112
112
|
hue: 0,
|
|
113
113
|
whiteness: 0,
|
|
114
114
|
blackness: 0,
|
|
@@ -119,49 +119,57 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
119
119
|
* Set color value from an _HWBA_ color object _(HWB with alpha channel)_
|
|
120
120
|
*/
|
|
121
121
|
set hwba(value) {
|
|
122
|
-
setColorPickerValue(this
|
|
122
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "hwba");
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Text input value
|
|
126
126
|
*/
|
|
127
127
|
get input() {
|
|
128
|
-
return this
|
|
128
|
+
return this[COLOR_PICKER_SYMBOL]?.component.anchor.input.value ?? "";
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Label elements associated with the color picker
|
|
132
132
|
*/
|
|
133
133
|
get labels() {
|
|
134
|
-
return this
|
|
134
|
+
return this[COLOR_PICKER_SYMBOL].form.internals.labels;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Localization information for the color picker
|
|
138
|
+
*/
|
|
139
|
+
get localizations() {
|
|
140
|
+
return this[COLOR_PICKER_SYMBOL]?.component.localizations;
|
|
135
141
|
}
|
|
136
142
|
/**
|
|
137
143
|
* Is the color picker readonly?
|
|
138
144
|
*/
|
|
139
145
|
get readonly() {
|
|
140
|
-
return this
|
|
146
|
+
return this[COLOR_PICKER_SYMBOL]?.component.readonly ?? false;
|
|
141
147
|
}
|
|
142
148
|
/**
|
|
143
149
|
* Should the color picker be readonly?
|
|
144
150
|
*/
|
|
145
151
|
set readonly(value) {
|
|
146
|
-
|
|
152
|
+
const state = this[COLOR_PICKER_SYMBOL];
|
|
153
|
+
if (state.component != null && typeof value === "boolean" && value !== state.component.readonly) setColorPickerDisabled(state, "readonly", value);
|
|
147
154
|
}
|
|
148
155
|
/**
|
|
149
156
|
* Is the color picker required?
|
|
150
157
|
*/
|
|
151
158
|
get required() {
|
|
152
|
-
return this
|
|
159
|
+
return this[COLOR_PICKER_SYMBOL]?.component.required ?? false;
|
|
153
160
|
}
|
|
154
161
|
/**
|
|
155
162
|
* Should the color picker be required?
|
|
156
163
|
*/
|
|
157
164
|
set required(value) {
|
|
158
|
-
|
|
165
|
+
const state = this[COLOR_PICKER_SYMBOL];
|
|
166
|
+
if (state.component != null && typeof value === "boolean" && value !== state.component.required) setColorPickerRequired(state, value);
|
|
159
167
|
}
|
|
160
168
|
/**
|
|
161
169
|
* Color value as an _RGB_ color object
|
|
162
170
|
*/
|
|
163
171
|
get rgb() {
|
|
164
|
-
return this
|
|
172
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.rgb ?? {
|
|
165
173
|
red: 0,
|
|
166
174
|
green: 0,
|
|
167
175
|
blue: 0
|
|
@@ -171,13 +179,13 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
171
179
|
* Set color value from an _RGB_ color object
|
|
172
180
|
*/
|
|
173
181
|
set rgb(value) {
|
|
174
|
-
setColorPickerValue(this
|
|
182
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "rgb");
|
|
175
183
|
}
|
|
176
184
|
/**
|
|
177
185
|
* Color value as an _RGBA_ color object _(RGB with alpha channel)_
|
|
178
186
|
*/
|
|
179
187
|
get rgba() {
|
|
180
|
-
return this
|
|
188
|
+
return this[COLOR_PICKER_SYMBOL]?.component.color.value.rgba ?? {
|
|
181
189
|
red: 0,
|
|
182
190
|
green: 0,
|
|
183
191
|
blue: 0,
|
|
@@ -188,47 +196,52 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
188
196
|
* Set color value from an _RGBA_ color object _(RGB with alpha channel)_
|
|
189
197
|
*/
|
|
190
198
|
set rgba(value) {
|
|
191
|
-
setColorPickerValue(this
|
|
199
|
+
setColorPickerValue(this[COLOR_PICKER_SYMBOL], value, "rgba");
|
|
192
200
|
}
|
|
193
201
|
/**
|
|
194
202
|
* Validation message for the color picker
|
|
195
203
|
*/
|
|
196
204
|
get validationMessage() {
|
|
197
|
-
return this
|
|
205
|
+
return this[COLOR_PICKER_SYMBOL].form.internals.validationMessage;
|
|
198
206
|
}
|
|
199
207
|
/**
|
|
200
208
|
* Validity state for the color picker
|
|
201
209
|
*/
|
|
202
210
|
get validity() {
|
|
203
|
-
return this
|
|
211
|
+
return this[COLOR_PICKER_SYMBOL].form.internals.validity;
|
|
204
212
|
}
|
|
205
213
|
/**
|
|
206
214
|
* Current color value
|
|
207
215
|
*/
|
|
208
216
|
get value() {
|
|
209
|
-
return this
|
|
217
|
+
return this[COLOR_PICKER_SYMBOL]?.component.value.current ?? "";
|
|
210
218
|
}
|
|
211
219
|
/**
|
|
212
220
|
* Set color value from a string, _HSL(A)_, _HWB(A)_, or _RGB(A)_ color object
|
|
213
221
|
*/
|
|
214
222
|
set value(value) {
|
|
223
|
+
const state = this[COLOR_PICKER_SYMBOL];
|
|
224
|
+
if (state.component == null) return;
|
|
215
225
|
if (typeof value === "string") {
|
|
216
|
-
|
|
217
|
-
onColorPickerInput(
|
|
218
|
-
} else setColorPickerValue(
|
|
226
|
+
state.component.anchor.input.value = value;
|
|
227
|
+
onColorPickerInput(state);
|
|
228
|
+
} else setColorPickerValue(state, value);
|
|
219
229
|
}
|
|
220
230
|
/**
|
|
221
231
|
* Can the color picker be validated?
|
|
222
232
|
*/
|
|
223
233
|
get willValidate() {
|
|
224
|
-
return this
|
|
234
|
+
return this[COLOR_PICKER_SYMBOL].form.internals.willValidate;
|
|
225
235
|
}
|
|
226
236
|
constructor() {
|
|
227
237
|
super();
|
|
228
|
-
this
|
|
238
|
+
this[COLOR_PICKER_SYMBOL] = {
|
|
239
|
+
component: void 0,
|
|
240
|
+
form: { internals: this.attachInternals() }
|
|
241
|
+
};
|
|
229
242
|
}
|
|
230
243
|
attributeChangedCallback(name, _, value) {
|
|
231
|
-
if (this
|
|
244
|
+
if (this[COLOR_PICKER_SYMBOL].component == null) return;
|
|
232
245
|
switch (name) {
|
|
233
246
|
case "disabled":
|
|
234
247
|
this.disabled = value != null;
|
|
@@ -245,7 +258,7 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
245
258
|
* @returns `true` if the color picker is valid, otherwise `false`
|
|
246
259
|
*/
|
|
247
260
|
checkValidity() {
|
|
248
|
-
return this
|
|
261
|
+
return this[COLOR_PICKER_SYMBOL].form.internals.checkValidity();
|
|
249
262
|
}
|
|
250
263
|
/**
|
|
251
264
|
* Clear the color picker's value
|
|
@@ -254,21 +267,25 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
254
267
|
this.value = "";
|
|
255
268
|
}
|
|
256
269
|
connectedCallback() {
|
|
257
|
-
|
|
258
|
-
|
|
270
|
+
const state = this[COLOR_PICKER_SYMBOL];
|
|
271
|
+
const { component } = state;
|
|
272
|
+
if (component == null) initializeColorPickerComponent(this, state);
|
|
273
|
+
else attachColorPicker(state);
|
|
259
274
|
}
|
|
260
275
|
disconnectedCallback() {
|
|
261
|
-
|
|
276
|
+
const state = this[COLOR_PICKER_SYMBOL];
|
|
277
|
+
if (state.component != null) detachColorPicker(state);
|
|
262
278
|
}
|
|
263
279
|
formDisabledCallback(disabled) {
|
|
264
280
|
this.disabled = disabled;
|
|
265
281
|
}
|
|
266
282
|
formResetCallback() {
|
|
267
|
-
this.value = this
|
|
283
|
+
this.value = this[COLOR_PICKER_SYMBOL]?.component.value.initial ?? "";
|
|
268
284
|
}
|
|
269
285
|
formStateRestoreCallback(state, reason) {
|
|
270
|
-
|
|
271
|
-
if (
|
|
286
|
+
const { component, form } = this[COLOR_PICKER_SYMBOL];
|
|
287
|
+
if (reason !== "restore" || typeof state !== "string" || component == null) return;
|
|
288
|
+
if (component == null) form.restored = state;
|
|
272
289
|
else this.value = state;
|
|
273
290
|
}
|
|
274
291
|
/**
|
|
@@ -277,7 +294,7 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
277
294
|
* @returns `true` if the color picker is valid, otherwise `false`
|
|
278
295
|
*/
|
|
279
296
|
reportValidity() {
|
|
280
|
-
return this
|
|
297
|
+
return this[COLOR_PICKER_SYMBOL].form.internals.reportValidity();
|
|
281
298
|
}
|
|
282
299
|
/**
|
|
283
300
|
* Set a custom validation message for the color picker
|
|
@@ -285,17 +302,7 @@ var OuiColorPickerElement = class extends HTMLElement {
|
|
|
285
302
|
* @param message Validation message
|
|
286
303
|
*/
|
|
287
304
|
setCustomValidity(message) {
|
|
288
|
-
this
|
|
289
|
-
}
|
|
290
|
-
setLocalizations(first, second) {
|
|
291
|
-
updateColorPickerLocalizations(colorPickerLocalizations, this.#state.localizations.component, first, second);
|
|
292
|
-
}
|
|
293
|
-
#initialize() {
|
|
294
|
-
this.#state = initializeColorPicker(this, this.#internals);
|
|
295
|
-
if (this.#restored != null) {
|
|
296
|
-
this.value = this.#restored;
|
|
297
|
-
this.#restored = void 0;
|
|
298
|
-
}
|
|
305
|
+
this[COLOR_PICKER_SYMBOL].form.internals.setValidity({ customError: message !== "" }, message, this);
|
|
299
306
|
}
|
|
300
307
|
};
|
|
301
308
|
customElements.define(COLOR_PICKER_TAGNAME, OuiColorPickerElement);
|