@oscarpalmer/oui 0.38.0 → 0.40.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/badge.css +11 -8
- package/dist/css/button.css +106 -14
- package/dist/css/color-picker.css +555 -73
- package/dist/css/color.css +86 -86
- package/dist/css/combobox.css +98 -4
- package/dist/css/content.css +7 -6
- package/dist/css/floatable.css +1 -3
- package/dist/css/form.css +99 -6
- package/dist/css/icon.css +99 -0
- package/dist/css/listbox.css +3 -0
- package/dist/css/message.css +4 -3
- package/dist/css/mixins/button.mixins.css +1 -0
- package/dist/css/reset.css +1 -1
- package/dist/css/tabs.css +95 -3
- package/dist/css/typography.css +90 -0
- package/dist/js/color-picker/color-picker.constants.d.mts +2 -0
- package/dist/js/color-picker/color-picker.constants.mjs +60 -0
- package/dist/js/color-picker/color-picker.dom.d.mts +8 -0
- package/dist/js/color-picker/color-picker.dom.mjs +191 -0
- package/dist/js/color-picker/color-picker.event.d.mts +9 -0
- package/dist/js/color-picker/color-picker.event.mjs +2 -0
- package/dist/js/color-picker/color-picker.form.d.mts +5 -0
- package/dist/js/color-picker/color-picker.form.mjs +27 -0
- package/dist/js/color-picker/color-picker.misc.d.mts +2 -0
- package/dist/js/color-picker/color-picker.misc.mjs +2 -0
- package/dist/js/color-picker/color-picker.model.d.mts +2 -0
- package/dist/js/color-picker/color-picker.model.mjs +24 -0
- package/dist/js/color-picker/color-picker.output.d.mts +8 -0
- package/dist/js/color-picker/color-picker.output.mjs +235 -0
- package/dist/js/color-picker/color-picker.state.d.mts +8 -0
- package/dist/js/color-picker/color-picker.state.mjs +2 -0
- package/dist/js/{color-picker.d.mts → color-picker/index.d.mts} +10 -43
- package/dist/js/color-picker/index.mjs +305 -0
- package/dist/js/color-picker.constants-D1mxw_Le.d.mts +179 -0
- package/dist/js/color-picker.event-Cksj5TvS.mjs +500 -0
- package/dist/js/color-picker.misc-CtsXGrOe.d.mts +27 -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 +26 -0
- package/dist/js/combobox/{dom.combobox.mjs → combobox.dom.mjs} +44 -37
- package/dist/js/combobox/combobox.event.d.mts +22 -0
- 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/{misc.combobox.mjs → combobox.misc.mjs} +1 -1
- package/dist/js/combobox/combobox.model.d.mts +2 -0
- package/dist/js/combobox/combobox.state.d.mts +10 -0
- package/dist/js/combobox/combobox.state.mjs +2 -0
- package/dist/js/combobox/index.d.mts +163 -2
- package/dist/js/combobox/index.mjs +53 -52
- package/dist/js/combobox.constants-DZVkMP5g.d.mts +19 -0
- package/dist/js/combobox.misc-C1tPZZDi.d.mts +22 -0
- package/dist/js/{combobox/models.combobox.d.mts → combobox.model-oDV06XCN.d.mts} +6 -6
- package/dist/js/{state.combobox-Qm3FWzYW.mjs → combobox.state-BfJ3Hxg8.mjs} +96 -82
- package/dist/js/constants.listbox-C5Ap6Ag_.d.mts +9 -0
- 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-DX2mndMh.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-MeTyXjFn.d.mts +17 -0
- package/dist/js/floatable.model-DXsQgoU7.d.mts +62 -0
- package/dist/js/focus-trap/focus-trap.embedded.d.mts +2 -2
- package/dist/js/focus-trap/focus-trap.embedded.mjs +112 -134
- 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-DIU05m1z.d.mts +13 -0
- package/dist/js/{focus-trap.embedded-DR8NpZfr.d.mts → focus-trap.model-BeX6UYlw.d.mts} +16 -18
- package/dist/js/index.d.mts +26 -14
- package/dist/js/index.mjs +18 -15
- package/dist/js/internal/attributable.d.mts +2 -3
- 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.mjs → draggable/index.mjs} +83 -114
- package/dist/js/internal/listbox/listbox.constants.d.mts +7 -10
- package/dist/js/internal/listbox/listbox.constants.mjs +15 -16
- package/dist/js/internal/listbox/listbox.data.d.mts +9 -10
- package/dist/js/internal/listbox/listbox.data.mjs +1 -1
- package/dist/js/internal/listbox/listbox.dom.d.mts +19 -20
- package/dist/js/internal/listbox/listbox.dom.mjs +1 -1
- package/dist/js/internal/listbox/listbox.event.d.mts +3 -4
- package/dist/js/internal/listbox/listbox.event.mjs +23 -20
- package/dist/js/internal/listbox/listbox.form.d.mts +4 -5
- package/dist/js/internal/listbox/listbox.form.mjs +15 -12
- package/dist/js/internal/listbox/listbox.misc.d.mts +10 -11
- package/dist/js/internal/listbox/listbox.misc.mjs +1 -1
- package/dist/js/internal/listbox/listbox.model.d.mts +2 -2
- package/dist/js/internal/listbox/listbox.state.d.mts +5 -6
- package/dist/js/internal/listbox/listbox.state.mjs +19 -20
- package/dist/js/internal/misc.d.mts +5 -4
- package/dist/js/internal/misc.mjs +7 -1
- 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/l10n/index.d.mts +9 -0
- package/dist/js/{l10n.mjs → l10n/index.mjs} +50 -23
- package/dist/js/l10n/l10n.model.d.mts +2 -0
- package/dist/js/l10n/l10n.model.mjs +9 -0
- package/dist/js/l10n.model-D6a9frgl.d.mts +26 -0
- package/dist/js/listbox/constants.listbox.d.mts +2 -2
- package/dist/js/listbox/constants.listbox.mjs +10 -14
- package/dist/js/listbox/event.listbox.d.mts +6 -7
- package/dist/js/listbox/event.listbox.mjs +47 -1
- package/dist/js/listbox/index.d.mts +8 -6
- package/dist/js/listbox/index.mjs +47 -49
- package/dist/js/listbox/misc.listbox.d.mts +1 -1
- package/dist/js/listbox/misc.listbox.mjs +1 -1
- package/dist/js/listbox/state.listbox.d.mts +8 -10
- package/dist/js/listbox/state.listbox.mjs +2 -2
- package/dist/js/{listbox.data-C7CRa5Ya.mjs → listbox.data-BQyZGKgr.mjs} +83 -66
- package/dist/js/{listbox.model-CRReGOmu.d.mts → listbox.model-CuBOj4qe.d.mts} +15 -11
- package/dist/js/menu/index.mjs +167 -0
- package/dist/js/menu/menu.model.d.mts +33 -0
- package/dist/js/menu/menu.model.mjs +15 -0
- package/dist/js/{misc.listbox-Cyz2CRDy.mjs → misc.listbox-CjfBUbHD.mjs} +27 -69
- package/dist/js/{misc.listbox-gnoJhrTr.d.mts → misc.listbox-CtoGvXQo.d.mts} +2 -2
- package/dist/js/movable/movable.embedded.d.mts +2 -2
- package/dist/js/movable/movable.embedded.mjs +60 -72
- 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-DoyXLegc.d.mts +11 -0
- package/dist/js/movable.model-BHaK_mKw.d.mts +186 -0
- package/dist/js/navigable.model-BPOM8DZk.d.mts +44 -0
- package/dist/js/popover/index.d.mts +12 -0
- package/dist/js/{popover.mjs → popover/index.mjs} +40 -50
- package/dist/js/popover/popover.model.d.mts +2 -0
- package/dist/js/popover/popover.model.mjs +12 -0
- package/dist/js/popover.model-ubKNG612.d.mts +38 -0
- package/dist/js/resizable/resizable.embedded.d.mts +2 -2
- package/dist/js/resizable/resizable.embedded.mjs +44 -59
- 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-Bf1qBUdt.d.mts +11 -0
- package/dist/js/resizable.model-BwzJcTVJ.d.mts +46 -0
- package/dist/js/sortable/sortable.embedded.d.mts +2 -2
- package/dist/js/sortable/sortable.embedded.mjs +69 -82
- 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-DzBKAwSG.d.mts +11 -0
- package/dist/js/{splitter.d.mts → splitter/index.d.mts} +8 -7
- package/dist/js/splitter/index.mjs +284 -0
- package/dist/js/splitter/splitter.model.d.mts +2 -0
- package/dist/js/splitter/splitter.model.mjs +37 -0
- package/dist/js/splitter.model-DOLNjLVS.d.mts +57 -0
- package/dist/js/{tabs.d.mts → tabs/index.d.mts} +7 -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-DRBX_JtI.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} +60 -85
- package/dist/js/tooltip/tooltip.model.d.mts +2 -0
- package/dist/js/tooltip/tooltip.model.mjs +15 -0
- package/dist/js/tooltip.model-DRkY_BsL.d.mts +37 -0
- package/package.json +43 -37
- package/dist/js/color-picker.mjs +0 -924
- package/dist/js/combobox/constants.combobox.d.mts +0 -2
- package/dist/js/combobox/dom.combobox.d.mts +0 -27
- package/dist/js/combobox/event.combobox.d.mts +0 -23
- package/dist/js/combobox/misc.combobox.d.mts +0 -2
- package/dist/js/combobox/state.combobox.d.mts +0 -12
- package/dist/js/combobox/state.combobox.mjs +0 -2
- package/dist/js/constants.combobox-DmRAMC64.d.mts +0 -26
- package/dist/js/constants.listbox-DRsXUxd3.d.mts +0 -14
- package/dist/js/dialog.d.mts +0 -47
- package/dist/js/dialog.mjs +0 -131
- package/dist/js/draggable-a6w0J1OD.d.mts +0 -154
- package/dist/js/floatable.embedded-Bct4U5Dm.d.mts +0 -69
- package/dist/js/index-DJdFlTLm.d.mts +0 -177
- package/dist/js/internal/draggable.d.mts +0 -2
- package/dist/js/internal/navigable.d.mts +0 -37
- 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/menu.mjs +0 -172
- package/dist/js/popover.d.mts +0 -38
- package/dist/js/resizable.embedded-3qoR0Bjm.d.mts +0 -34
- package/dist/js/splitter.mjs +0 -322
- package/dist/js/toolbar.mjs +0 -31
- package/dist/js/tooltip.d.mts +0 -45
- package/src/css/a11y.scss +0 -13
- package/src/css/badge.scss +0 -62
- package/src/css/button.scss +0 -50
- package/src/css/color-picker.scss +0 -344
- package/src/css/color.scss +0 -113
- package/src/css/combobox.scss +0 -255
- package/src/css/content.scss +0 -181
- package/src/css/flex.scss +0 -107
- package/src/css/floatable.scss +0 -155
- package/src/css/form.scss +0 -575
- package/src/css/listbox.scss +0 -121
- package/src/css/message.scss +0 -74
- package/src/css/mixins/badge.mixins.scss +0 -53
- package/src/css/mixins/button.mixins.scss +0 -112
- package/src/css/mixins/input.mixins.scss +0 -114
- package/src/css/mixins/message.mixins.scss +0 -41
- package/src/css/mixins/misc.mixins.scss +0 -48
- package/src/css/mixins/shadow.mixins.scss +0 -57
- package/src/css/reset.scss +0 -392
- package/src/css/splitter.scss +0 -89
- package/src/css/table.scss +0 -107
- package/src/css/tabs.scss +0 -74
- package/src/js/color-picker.ts +0 -1653
- package/src/js/combobox/constants.combobox.ts +0 -83
- package/src/js/combobox/dom.combobox.ts +0 -411
- package/src/js/combobox/event.combobox.ts +0 -365
- package/src/js/combobox/index.ts +0 -382
- package/src/js/combobox/misc.combobox.ts +0 -104
- package/src/js/combobox/models.combobox.ts +0 -54
- package/src/js/combobox/state.combobox.ts +0 -246
- package/src/js/dialog.ts +0 -255
- package/src/js/floatable/floatable.embedded.ts +0 -336
- package/src/js/floatable/floatable.standalone.ts +0 -6
- package/src/js/focus-trap/focus-trap.embedded.ts +0 -411
- package/src/js/focus-trap/focus-trap.standalone.ts +0 -1
- package/src/js/index.ts +0 -16
- package/src/js/internal/attributable.ts +0 -73
- package/src/js/internal/draggable.ts +0 -657
- package/src/js/internal/listbox/listbox.constants.ts +0 -25
- package/src/js/internal/listbox/listbox.data.ts +0 -287
- package/src/js/internal/listbox/listbox.dom.ts +0 -446
- package/src/js/internal/listbox/listbox.event.ts +0 -129
- package/src/js/internal/listbox/listbox.form.ts +0 -125
- package/src/js/internal/listbox/listbox.misc.ts +0 -135
- package/src/js/internal/listbox/listbox.model.ts +0 -169
- package/src/js/internal/listbox/listbox.state.ts +0 -82
- package/src/js/internal/misc.ts +0 -27
- package/src/js/internal/navigable.ts +0 -317
- package/src/js/l10n.ts +0 -192
- package/src/js/listbox/constants.listbox.ts +0 -61
- package/src/js/listbox/event.listbox.ts +0 -106
- package/src/js/listbox/index.ts +0 -364
- package/src/js/listbox/misc.listbox.ts +0 -70
- package/src/js/listbox/state.listbox.ts +0 -194
- package/src/js/menu.ts +0 -348
- package/src/js/movable/movable.embedded.ts +0 -318
- package/src/js/movable/movable.standalone.ts +0 -2
- package/src/js/popover.ts +0 -229
- package/src/js/resizable/resizable.embedded.ts +0 -413
- package/src/js/resizable/resizable.standalone.ts +0 -5
- package/src/js/sortable/sortable.embedded.ts +0 -527
- package/src/js/sortable/sortable.standalone.ts +0 -2
- package/src/js/splitter.ts +0 -583
- package/src/js/tabs.ts +0 -441
- package/src/js/toolbar.ts +0 -63
- package/src/js/tooltip.ts +0 -367
- /package/dist/js/combobox/{models.combobox.mjs → combobox.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
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getLocalization, localize } from "../l10n.mjs";
|
|
2
|
-
import { _ as createListboxValueLabel, f as createListboxInput, l as createListboxFilter, m as createListboxMessage, p as createListboxList } from "../listbox.data-
|
|
3
|
-
import { COMBOBOX_ATTRIBUTE_ANCHOR, COMBOBOX_ATTRIBUTE_SELECTION, COMBOBOX_ATTRIBUTE_SELECTION_ITEM } from "./constants.
|
|
1
|
+
import { getLocalization, localize } from "../l10n/index.mjs";
|
|
2
|
+
import { _ as createListboxValueLabel, f as createListboxInput, l as createListboxFilter, m as createListboxMessage, p as createListboxList } from "../listbox.data-BQyZGKgr.mjs";
|
|
3
|
+
import { COMBOBOX_ATTRIBUTE_ANCHOR, COMBOBOX_ATTRIBUTE_SELECTION, COMBOBOX_ATTRIBUTE_SELECTION_ITEM } from "./combobox.constants.mjs";
|
|
4
4
|
import { setAria } from "@oscarpalmer/toretto/aria";
|
|
5
5
|
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
6
6
|
import { createElement } from "@oscarpalmer/toretto/create";
|
|
7
7
|
import { getData } from "@oscarpalmer/toretto/data";
|
|
8
|
-
//#region src/js/combobox/dom.
|
|
8
|
+
//#region src/js/combobox/combobox.dom.ts
|
|
9
9
|
function createComboboxAnchor(parameters) {
|
|
10
10
|
const { select } = parameters;
|
|
11
11
|
let container;
|
|
@@ -94,7 +94,7 @@ function createComboboxSelectionItem(option, state) {
|
|
|
94
94
|
const optionLabel = option.textContent;
|
|
95
95
|
const optionValue = getData(option, "value", false) ?? "";
|
|
96
96
|
const element = createElement("li");
|
|
97
|
-
const localization = state == null ? option.textContent : getLocalization(state.localizations.global, state.host, "remove", state.localizations.component);
|
|
97
|
+
const localization = state == null ? option.textContent : getLocalization(state.component.localizations.global, state.component.host, "remove", state.component.localizations.component);
|
|
98
98
|
const button = createElement("button", {
|
|
99
99
|
aria: { label: localize(localization, {
|
|
100
100
|
label: optionLabel,
|
|
@@ -109,7 +109,10 @@ function createComboboxSelectionItem(option, state) {
|
|
|
109
109
|
});
|
|
110
110
|
const icon = createElement("span", {
|
|
111
111
|
aria: { hidden: true },
|
|
112
|
-
property: {
|
|
112
|
+
property: {
|
|
113
|
+
className: "oui-icon oui-icon--x",
|
|
114
|
+
innerHTML: ""
|
|
115
|
+
}
|
|
113
116
|
});
|
|
114
117
|
const label = createElement("span", { property: { textContent: option.textContent } });
|
|
115
118
|
button.append(icon, label);
|
|
@@ -130,71 +133,75 @@ function createComboboxSelectionItems(parameters) {
|
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
function updateComboboxTabindices(state, active) {
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
const { selection } = state.component;
|
|
137
|
+
if (active == null || selection == null) return;
|
|
138
|
+
const next = selection.items.find((item) => getData(item.button, "option", false) === active.id);
|
|
135
139
|
if (next == null) return;
|
|
136
|
-
const { length } =
|
|
140
|
+
const { length } = selection.items;
|
|
137
141
|
for (let index = 0; index < length; index += 1) {
|
|
138
|
-
const item =
|
|
142
|
+
const item = selection.items[index];
|
|
139
143
|
item.button.tabIndex = item === next ? 0 : -1;
|
|
140
144
|
}
|
|
141
145
|
next.button.focus();
|
|
142
146
|
}
|
|
143
147
|
function updateComboboxAutocomplete(preview, state, active) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
+
const { anchor, filter, multiple } = state.component;
|
|
149
|
+
if (multiple) return;
|
|
150
|
+
const content = active?.textContent ?? filter.element.value;
|
|
151
|
+
if (preview === "typed" && !content.toLocaleLowerCase().startsWith(filter.element.value.toLocaleLowerCase())) return;
|
|
152
|
+
if (anchor.element instanceof HTMLInputElement) {
|
|
148
153
|
const contentLength = content.length;
|
|
149
|
-
const filterLength =
|
|
154
|
+
const filterLength = filter.element.value.length;
|
|
150
155
|
if (preview === "set" || preview === "typed") {
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
anchor.element.value = content;
|
|
157
|
+
anchor.element.setSelectionRange(preview === "typed" ? filterLength : contentLength, contentLength);
|
|
153
158
|
}
|
|
154
|
-
} else
|
|
159
|
+
} else anchor.element.textContent = content;
|
|
155
160
|
}
|
|
156
161
|
function updateComboboxSelection(state, active, added, selected) {
|
|
157
|
-
|
|
162
|
+
const { anchor, selection } = state.component;
|
|
163
|
+
if (selection == null) return;
|
|
158
164
|
let options = active == null ? [] : [active];
|
|
159
165
|
if (added && selected != null) {
|
|
160
166
|
options = selected;
|
|
161
|
-
const { length } =
|
|
162
|
-
for (let index = 0; index < length; index += 1)
|
|
163
|
-
|
|
167
|
+
const { length } = selection.items;
|
|
168
|
+
for (let index = 0; index < length; index += 1) selection.items[index].element.remove();
|
|
169
|
+
selection.items.splice(0);
|
|
164
170
|
}
|
|
165
171
|
if (added) {
|
|
166
172
|
createComboboxSelectionItems({
|
|
167
173
|
options,
|
|
168
174
|
state,
|
|
169
|
-
container:
|
|
170
|
-
items:
|
|
175
|
+
container: selection.container,
|
|
176
|
+
items: selection.items
|
|
171
177
|
});
|
|
172
178
|
return;
|
|
173
179
|
}
|
|
174
|
-
let current =
|
|
180
|
+
let current = selection.items.findIndex((item) => getData(item.button, "option", false) === active?.id);
|
|
175
181
|
if (current === -1) return;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
182
|
+
selection.items[current].element.remove();
|
|
183
|
+
selection.items.splice(current, 1);
|
|
184
|
+
if (selection.items.length === 0) {
|
|
185
|
+
anchor.element.focus();
|
|
180
186
|
return;
|
|
181
187
|
}
|
|
182
|
-
const { length } =
|
|
188
|
+
const { length } = selection.items;
|
|
183
189
|
if (current < 0) current = 0;
|
|
184
190
|
else if (current >= length) current = length - 1;
|
|
185
191
|
for (let index = 0; index < length; index += 1) {
|
|
186
|
-
const { button } =
|
|
192
|
+
const { button } = selection.items[index];
|
|
187
193
|
button.tabIndex = index === current ? 0 : -1;
|
|
188
194
|
}
|
|
189
|
-
|
|
195
|
+
selection.items[current].button.focus();
|
|
190
196
|
}
|
|
191
197
|
function updateComboboxSelectionItems(state) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
198
|
+
const { host, localizations, options, selection } = state.component;
|
|
199
|
+
if (selection == null) return;
|
|
200
|
+
const localization = getLocalization(localizations.global, host, "remove", localizations.component);
|
|
201
|
+
const { length } = selection.items;
|
|
195
202
|
for (let index = 0; index < length; index += 1) {
|
|
196
|
-
const item =
|
|
197
|
-
const option =
|
|
203
|
+
const item = selection.items[index];
|
|
204
|
+
const option = options.selected.find((option) => option.id === getData(item.button, "option", false));
|
|
198
205
|
if (option == null) continue;
|
|
199
206
|
const optionLabel = option.textContent;
|
|
200
207
|
const optionValue = getData(option, "value", false) ?? "";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { c as OuiListboxPreview } from "../listbox.model-CuBOj4qe.mjs";
|
|
2
|
+
import { c as OuiComboboxState } from "../combobox.model-oDV06XCN.mjs";
|
|
3
|
+
//#region src/js/combobox/combobox.event.d.ts
|
|
4
|
+
export declare function onComboboxActivation(state: OuiComboboxState): void;
|
|
5
|
+
export declare function onComboboxApply(state: OuiComboboxState, option: HTMLElement | undefined, _: string[], added: boolean, selected?: HTMLElement[]): void;
|
|
6
|
+
export declare function onComboboxClickContent(event: PointerEvent, state: OuiComboboxState): void;
|
|
7
|
+
export declare function onComboboxEnter(state: OuiComboboxState): void;
|
|
8
|
+
export declare function onComboboxEscape(state: OuiComboboxState): void;
|
|
9
|
+
export declare function onComboboxFilter(preview: OuiListboxPreview, state: OuiComboboxState, update: boolean, active?: HTMLElement, emit?: boolean): void;
|
|
10
|
+
export declare function onComboboxFocusout(event: FocusEvent): void;
|
|
11
|
+
export declare function onComboboxInput(event: InputEvent): void;
|
|
12
|
+
export declare function onComboboxKeydown(event: KeyboardEvent): void;
|
|
13
|
+
export declare function onComboboxKeydownSelection(event: KeyboardEvent, state: OuiComboboxState, item: HTMLElement): void;
|
|
14
|
+
export declare function onComboboxPreview(preview: OuiListboxPreview, state: OuiComboboxState, active?: HTMLElement): void;
|
|
15
|
+
export declare function onComboboxRemoveSelection(state: OuiComboboxState, item: HTMLElement): void;
|
|
16
|
+
export declare function onComboboxNavigation(preview: OuiListboxPreview, state: OuiComboboxState, active?: HTMLElement): void;
|
|
17
|
+
export declare function onComboboxSelection(state: OuiComboboxState, hasSelection?: boolean): void;
|
|
18
|
+
export declare function onComboboxTab(state: OuiComboboxState): void;
|
|
19
|
+
export declare function onComboboxToggle(state: OuiComboboxState): void;
|
|
20
|
+
export declare function preventComboboxActivation(state: OuiComboboxState): boolean;
|
|
21
|
+
export declare function skipComboboxNavigation(state: OuiComboboxState): boolean;
|
|
22
|
+
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as skipComboboxNavigation, S as preventComboboxActivation, _ as onComboboxPreview, b as onComboboxTab, c as onComboboxClickContent, d as onComboboxFilter, f as onComboboxFocusout, g as onComboboxNavigation, h as onComboboxKeydownSelection, l as onComboboxEnter, m as onComboboxKeydown, o as onComboboxActivation, p as onComboboxInput, s as onComboboxApply, u as onComboboxEscape, v as onComboboxRemoveSelection, x as onComboboxToggle, y as onComboboxSelection } from "../state
|
|
1
|
+
import { C as skipComboboxNavigation, S as preventComboboxActivation, _ as onComboboxPreview, b as onComboboxTab, c as onComboboxClickContent, d as onComboboxFilter, f as onComboboxFocusout, g as onComboboxNavigation, h as onComboboxKeydownSelection, l as onComboboxEnter, m as onComboboxKeydown, o as onComboboxActivation, p as onComboboxInput, s as onComboboxApply, u as onComboboxEscape, v as onComboboxRemoveSelection, x as onComboboxToggle, y as onComboboxSelection } from "../combobox.state-BfJ3Hxg8.mjs";
|
|
2
2
|
export { onComboboxActivation, onComboboxApply, onComboboxClickContent, onComboboxEnter, onComboboxEscape, onComboboxFilter, onComboboxFocusout, onComboboxInput, onComboboxKeydown, onComboboxKeydownSelection, onComboboxNavigation, onComboboxPreview, onComboboxRemoveSelection, onComboboxSelection, onComboboxTab, onComboboxToggle, preventComboboxActivation, skipComboboxNavigation };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as updateComboboxLocalizations, i as setComboboxLocalizations, n as getComboboxId, r as hasTextSelection, t as getComboboxAutoComplete } from "../combobox.misc-C1tPZZDi.mjs";
|
|
2
|
+
export { getComboboxAutoComplete, getComboboxId, hasTextSelection, setComboboxLocalizations, updateComboboxLocalizations };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { D as setComboboxLocalizations, E as hasTextSelection, O as updateComboboxLocalizations, T as getComboboxId, w as getComboboxAutoComplete } from "../state
|
|
1
|
+
import { D as setComboboxLocalizations, E as hasTextSelection, O as updateComboboxLocalizations, T as getComboboxId, w as getComboboxAutoComplete } from "../combobox.state-BfJ3Hxg8.mjs";
|
|
2
2
|
export { getComboboxAutoComplete, getComboboxId, hasTextSelection, setComboboxLocalizations, updateComboboxLocalizations };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as OuiComboboxOptions, c as OuiComboboxState, i as OuiComboboxLabel, l as OuiComboboxValues, n as OuiComboboxFilter, o as OuiComboboxSelection, r as OuiComboboxGroup, s as OuiComboboxSelectionItem, t as OuiComboboxAnchor } from "../combobox.model-oDV06XCN.mjs";
|
|
2
|
+
export { OuiComboboxAnchor, OuiComboboxFilter, OuiComboboxGroup, OuiComboboxLabel, OuiComboboxOptions, OuiComboboxSelection, OuiComboboxSelectionItem, OuiComboboxState, OuiComboboxValues };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { c as OuiLocalizations } from "../l10n.model-D6a9frgl.mjs";
|
|
2
|
+
import { o as OuiListboxLocalizations } from "../listbox.model-CuBOj4qe.mjs";
|
|
3
|
+
import { c as OuiComboboxState } from "../combobox.model-oDV06XCN.mjs";
|
|
4
|
+
//#region src/js/combobox/combobox.state.d.ts
|
|
5
|
+
export declare function initializeCombobox(element: HTMLElement, state: OuiComboboxState): void;
|
|
6
|
+
export declare function onAttachCombobox(state: OuiComboboxState): void;
|
|
7
|
+
export declare function onDetachCombobox(state: OuiComboboxState): void;
|
|
8
|
+
export declare const comboboxLocalizations: OuiLocalizations<OuiListboxLocalizations>;
|
|
9
|
+
export declare const comboboxes: Set<OuiComboboxState>;
|
|
10
|
+
//#endregion
|
|
@@ -1,2 +1,163 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { f as OuiListboxType, o as OuiListboxLocalizations } from "../listbox.model-CuBOj4qe.mjs";
|
|
2
|
+
import { a as COMBOBOX_SYMBOL, o as COMBOBOX_TAGNAME } from "../combobox.constants-DZVkMP5g.mjs";
|
|
3
|
+
import { c as OuiComboboxState } from "../combobox.model-oDV06XCN.mjs";
|
|
4
|
+
import { i as setComboboxLocalizations } from "../combobox.misc-C1tPZZDi.mjs";
|
|
5
|
+
//#region src/js/combobox/index.d.ts
|
|
6
|
+
declare global {
|
|
7
|
+
interface HTMLElementTagNameMap {
|
|
8
|
+
[COMBOBOX_TAGNAME]: OuiComboboxElement & {
|
|
9
|
+
[COMBOBOX_SYMBOL]: OuiComboboxState;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface OuiComboboxElement {
|
|
14
|
+
[COMBOBOX_SYMBOL]: OuiComboboxState;
|
|
15
|
+
}
|
|
16
|
+
export declare class OuiComboboxElement extends HTMLElement {
|
|
17
|
+
static formAssociated: boolean;
|
|
18
|
+
static observedAttributes: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Is the combobox disabled?
|
|
21
|
+
*/
|
|
22
|
+
get disabled(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Should the combobox be disabled?
|
|
25
|
+
*/
|
|
26
|
+
set disabled(value: boolean);
|
|
27
|
+
/**
|
|
28
|
+
* Current filter value
|
|
29
|
+
*/
|
|
30
|
+
get filter(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Set the filter value
|
|
33
|
+
*/
|
|
34
|
+
set filter(value: string);
|
|
35
|
+
/**
|
|
36
|
+
* Form element associated with the combobox
|
|
37
|
+
*/
|
|
38
|
+
get form(): HTMLFormElement | null;
|
|
39
|
+
/**
|
|
40
|
+
* Label elements associated with the combobox
|
|
41
|
+
*/
|
|
42
|
+
get labels(): NodeList;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of selected options
|
|
45
|
+
*/
|
|
46
|
+
get max(): number | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Set the maximum number of selected options
|
|
49
|
+
*/
|
|
50
|
+
set max(value: number);
|
|
51
|
+
/**
|
|
52
|
+
* Minimum number of selected options
|
|
53
|
+
*/
|
|
54
|
+
get min(): number | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Set the minimum number of selected options
|
|
57
|
+
*/
|
|
58
|
+
set min(value: number);
|
|
59
|
+
/**
|
|
60
|
+
* Does the combobox allow multiple values?
|
|
61
|
+
*/
|
|
62
|
+
get multiple(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Name of the combobox
|
|
65
|
+
*/
|
|
66
|
+
get name(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Is the combobox readonly?
|
|
69
|
+
*/
|
|
70
|
+
get readonly(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Should the combobox be readonly?
|
|
73
|
+
*/
|
|
74
|
+
set readonly(value: boolean);
|
|
75
|
+
/**
|
|
76
|
+
* Is the combobox required?
|
|
77
|
+
*/
|
|
78
|
+
get required(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Should the combobox be required?
|
|
81
|
+
*/
|
|
82
|
+
set required(value: boolean);
|
|
83
|
+
/**
|
|
84
|
+
* Selected options
|
|
85
|
+
*/
|
|
86
|
+
get selected(): HTMLElement[];
|
|
87
|
+
/**
|
|
88
|
+
* Type of combobox
|
|
89
|
+
*/
|
|
90
|
+
get type(): OuiListboxType;
|
|
91
|
+
/**
|
|
92
|
+
* Validation message for the combobox
|
|
93
|
+
*/
|
|
94
|
+
get validationMessage(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Validity state for the combobox
|
|
97
|
+
*/
|
|
98
|
+
get validity(): ValidityState;
|
|
99
|
+
/**
|
|
100
|
+
* Current value
|
|
101
|
+
*/
|
|
102
|
+
get value(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Set the value
|
|
105
|
+
*/
|
|
106
|
+
set value(value: unknown);
|
|
107
|
+
/**
|
|
108
|
+
* Current values
|
|
109
|
+
*/
|
|
110
|
+
get values(): string[];
|
|
111
|
+
/**
|
|
112
|
+
* Set the values
|
|
113
|
+
*/
|
|
114
|
+
set values(values: unknown[]);
|
|
115
|
+
/**
|
|
116
|
+
* Can the combobox be validated?
|
|
117
|
+
*/
|
|
118
|
+
get willValidate(): boolean;
|
|
119
|
+
constructor();
|
|
120
|
+
attributeChangedCallback(name: string, _: string | null, value: string | null): void;
|
|
121
|
+
/**
|
|
122
|
+
* Check if the combobox is valid
|
|
123
|
+
*
|
|
124
|
+
* @returns `true` if the combobox is valid, otherwise `false`
|
|
125
|
+
*/
|
|
126
|
+
checkValidity(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Clear all selected options
|
|
129
|
+
*/
|
|
130
|
+
clear(): void;
|
|
131
|
+
connectedCallback(): void;
|
|
132
|
+
disconnectedCallback(): void;
|
|
133
|
+
formDisabledCallback(disabled: boolean): void;
|
|
134
|
+
formResetCallback(): void;
|
|
135
|
+
formStateRestoreCallback(state: unknown, reason: unknown): void;
|
|
136
|
+
/**
|
|
137
|
+
* Check if the combobox is valid and report any validation errors
|
|
138
|
+
*
|
|
139
|
+
* @returns `true` if the combobox is valid, otherwise `false`
|
|
140
|
+
*/
|
|
141
|
+
reportValidity(): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Set a custom validation message for the combobox
|
|
144
|
+
*
|
|
145
|
+
* @param message Validation message
|
|
146
|
+
*/
|
|
147
|
+
setCustomValidity(message: string): void;
|
|
148
|
+
/**
|
|
149
|
+
* Set combobox localizations for a specific language
|
|
150
|
+
*
|
|
151
|
+
* @param language Language code
|
|
152
|
+
* @param localizations Localizations for language
|
|
153
|
+
*/
|
|
154
|
+
setLocalizations(language: string, localizations: Partial<OuiListboxLocalizations>): void;
|
|
155
|
+
/**
|
|
156
|
+
* Set combobox localizations for one or more languages
|
|
157
|
+
*
|
|
158
|
+
* @param localizations Localizations for one or more languages
|
|
159
|
+
*/
|
|
160
|
+
setLocalizations(localizations: Record<string, Partial<OuiListboxLocalizations>>): void;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { setComboboxLocalizations };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { updateLocalizations } from "../l10n.mjs";
|
|
2
|
-
import { C as setListboxDisabled, D as setListboxReadonly, O as setListboxRequired, T as setListboxLimit, a as setListboxValue, o as setListboxValues, w as setListboxFilter } from "../listbox.data-
|
|
1
|
+
import { updateLocalizations } from "../l10n/index.mjs";
|
|
2
|
+
import { C as setListboxDisabled, D as setListboxReadonly, O as setListboxRequired, T as setListboxLimit, a as setListboxValue, o as setListboxValues, w as setListboxFilter } from "../listbox.data-BQyZGKgr.mjs";
|
|
3
3
|
import { attachListbox, detachListbox } from "../internal/listbox/listbox.state.mjs";
|
|
4
|
-
import { COMBOBOX_TAGNAME } from "./constants.
|
|
5
|
-
import { D as setComboboxLocalizations, a as onDetachCombobox, i as onAttachCombobox, n as
|
|
4
|
+
import { COMBOBOX_SYMBOL, COMBOBOX_TAGNAME } from "./combobox.constants.mjs";
|
|
5
|
+
import { D as setComboboxLocalizations, a as onDetachCombobox, i as onAttachCombobox, n as comboboxes, r as initializeCombobox } from "../combobox.state-BfJ3Hxg8.mjs";
|
|
6
6
|
import { getAttribute } from "@oscarpalmer/toretto/attribute";
|
|
7
7
|
import { parse } from "@oscarpalmer/atoms/string";
|
|
8
8
|
//#region src/js/combobox/index.ts
|
|
@@ -14,68 +14,65 @@ var OuiComboboxElement = class extends HTMLElement {
|
|
|
14
14
|
"required",
|
|
15
15
|
"value"
|
|
16
16
|
];
|
|
17
|
-
#internals;
|
|
18
|
-
#restored;
|
|
19
|
-
#state;
|
|
20
17
|
/**
|
|
21
18
|
* Is the combobox disabled?
|
|
22
19
|
*/
|
|
23
20
|
get disabled() {
|
|
24
|
-
return this
|
|
21
|
+
return this[COMBOBOX_SYMBOL].component?.disabled ?? false;
|
|
25
22
|
}
|
|
26
23
|
/**
|
|
27
24
|
* Should the combobox be disabled?
|
|
28
25
|
*/
|
|
29
26
|
set disabled(value) {
|
|
30
|
-
if (typeof value === "boolean" && value !== this.disabled) setListboxDisabled(this
|
|
27
|
+
if (typeof value === "boolean" && value !== this.disabled) setListboxDisabled(this[COMBOBOX_SYMBOL], value);
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
33
30
|
* Current filter value
|
|
34
31
|
*/
|
|
35
32
|
get filter() {
|
|
36
|
-
return this
|
|
33
|
+
return this[COMBOBOX_SYMBOL].component?.filter.element.value ?? "";
|
|
37
34
|
}
|
|
38
35
|
/**
|
|
39
36
|
* Set the filter value
|
|
40
37
|
*/
|
|
41
38
|
set filter(value) {
|
|
42
|
-
setListboxFilter(this
|
|
39
|
+
setListboxFilter(this[COMBOBOX_SYMBOL], value);
|
|
43
40
|
}
|
|
44
41
|
/**
|
|
45
42
|
* Form element associated with the combobox
|
|
46
43
|
*/
|
|
47
44
|
get form() {
|
|
48
|
-
return this
|
|
45
|
+
return this[COMBOBOX_SYMBOL].form.internals.form;
|
|
49
46
|
}
|
|
50
47
|
/**
|
|
51
48
|
* Label elements associated with the combobox
|
|
52
49
|
*/
|
|
53
50
|
get labels() {
|
|
54
|
-
return this
|
|
51
|
+
return this[COMBOBOX_SYMBOL].form.internals.labels;
|
|
55
52
|
}
|
|
56
53
|
/**
|
|
57
54
|
* Maximum number of selected options
|
|
58
55
|
*/
|
|
59
56
|
get max() {
|
|
60
|
-
return this
|
|
57
|
+
return this[COMBOBOX_SYMBOL].component?.max;
|
|
61
58
|
}
|
|
62
59
|
/**
|
|
63
60
|
* Set the maximum number of selected options
|
|
64
61
|
*/
|
|
65
62
|
set max(value) {
|
|
66
|
-
setListboxLimit("max", this
|
|
63
|
+
setListboxLimit("max", this[COMBOBOX_SYMBOL], value);
|
|
67
64
|
}
|
|
68
65
|
/**
|
|
69
66
|
* Minimum number of selected options
|
|
70
67
|
*/
|
|
71
68
|
get min() {
|
|
72
|
-
return this
|
|
69
|
+
return this[COMBOBOX_SYMBOL].component?.min;
|
|
73
70
|
}
|
|
74
71
|
/**
|
|
75
72
|
* Set the minimum number of selected options
|
|
76
73
|
*/
|
|
77
74
|
set min(value) {
|
|
78
|
-
setListboxLimit("min", this
|
|
75
|
+
setListboxLimit("min", this[COMBOBOX_SYMBOL], value);
|
|
79
76
|
}
|
|
80
77
|
/**
|
|
81
78
|
* Does the combobox allow multiple values?
|
|
@@ -93,93 +90,97 @@ var OuiComboboxElement = class extends HTMLElement {
|
|
|
93
90
|
* Is the combobox readonly?
|
|
94
91
|
*/
|
|
95
92
|
get readonly() {
|
|
96
|
-
return this
|
|
93
|
+
return this[COMBOBOX_SYMBOL].component?.readonly ?? false;
|
|
97
94
|
}
|
|
98
95
|
/**
|
|
99
96
|
* Should the combobox be readonly?
|
|
100
97
|
*/
|
|
101
98
|
set readonly(value) {
|
|
102
|
-
if (typeof value === "boolean" && value !== this.readonly) setListboxReadonly(this
|
|
99
|
+
if (typeof value === "boolean" && value !== this.readonly) setListboxReadonly(this[COMBOBOX_SYMBOL], value);
|
|
103
100
|
}
|
|
104
101
|
/**
|
|
105
102
|
* Is the combobox required?
|
|
106
103
|
*/
|
|
107
104
|
get required() {
|
|
108
|
-
return this
|
|
105
|
+
return this[COMBOBOX_SYMBOL].component?.required ?? false;
|
|
109
106
|
}
|
|
110
107
|
/**
|
|
111
108
|
* Should the combobox be required?
|
|
112
109
|
*/
|
|
113
110
|
set required(value) {
|
|
114
|
-
if (typeof value === "boolean" && value !== this.required) setListboxRequired(this
|
|
111
|
+
if (typeof value === "boolean" && value !== this.required) setListboxRequired(this[COMBOBOX_SYMBOL], value);
|
|
115
112
|
}
|
|
116
113
|
/**
|
|
117
114
|
* Selected options
|
|
118
115
|
*/
|
|
119
116
|
get selected() {
|
|
120
|
-
return this
|
|
117
|
+
return this[COMBOBOX_SYMBOL].component?.options.selected.slice() ?? [];
|
|
121
118
|
}
|
|
122
119
|
/**
|
|
123
120
|
* Type of combobox
|
|
124
121
|
*/
|
|
125
122
|
get type() {
|
|
126
|
-
return this
|
|
123
|
+
return this[COMBOBOX_SYMBOL].component?.type;
|
|
127
124
|
}
|
|
128
125
|
/**
|
|
129
126
|
* Validation message for the combobox
|
|
130
127
|
*/
|
|
131
128
|
get validationMessage() {
|
|
132
|
-
return this
|
|
129
|
+
return this[COMBOBOX_SYMBOL].form.internals.validationMessage;
|
|
133
130
|
}
|
|
134
131
|
/**
|
|
135
132
|
* Validity state for the combobox
|
|
136
133
|
*/
|
|
137
134
|
get validity() {
|
|
138
|
-
return this
|
|
135
|
+
return this[COMBOBOX_SYMBOL].form.internals.validity;
|
|
139
136
|
}
|
|
140
137
|
/**
|
|
141
138
|
* Current value
|
|
142
139
|
*/
|
|
143
140
|
get value() {
|
|
144
|
-
return this
|
|
141
|
+
return this[COMBOBOX_SYMBOL].component?.values.current[0] ?? "";
|
|
145
142
|
}
|
|
146
143
|
/**
|
|
147
144
|
* Set the value
|
|
148
145
|
*/
|
|
149
146
|
set value(value) {
|
|
150
|
-
setListboxValue(this
|
|
147
|
+
setListboxValue(this[COMBOBOX_SYMBOL], value);
|
|
151
148
|
}
|
|
152
149
|
/**
|
|
153
150
|
* Current values
|
|
154
151
|
*/
|
|
155
152
|
get values() {
|
|
156
|
-
return this
|
|
153
|
+
return this[COMBOBOX_SYMBOL].component?.values.current.slice() ?? [];
|
|
157
154
|
}
|
|
158
155
|
/**
|
|
159
156
|
* Set the values
|
|
160
157
|
*/
|
|
161
158
|
set values(values) {
|
|
162
|
-
setListboxValues(this
|
|
159
|
+
setListboxValues(this[COMBOBOX_SYMBOL], values);
|
|
163
160
|
}
|
|
164
161
|
/**
|
|
165
162
|
* Can the combobox be validated?
|
|
166
163
|
*/
|
|
167
164
|
get willValidate() {
|
|
168
|
-
return this
|
|
165
|
+
return this[COMBOBOX_SYMBOL].form.internals.willValidate;
|
|
169
166
|
}
|
|
170
167
|
constructor() {
|
|
171
168
|
super();
|
|
172
|
-
this
|
|
169
|
+
this[COMBOBOX_SYMBOL] = {
|
|
170
|
+
component: null,
|
|
171
|
+
form: { internals: this.attachInternals() }
|
|
172
|
+
};
|
|
173
173
|
}
|
|
174
174
|
attributeChangedCallback(name, _, value) {
|
|
175
|
-
|
|
175
|
+
const state = this[COMBOBOX_SYMBOL];
|
|
176
|
+
if (state == null) return;
|
|
176
177
|
switch (name) {
|
|
177
178
|
case "required":
|
|
178
179
|
this[name] = this.hasAttribute(name);
|
|
179
180
|
break;
|
|
180
181
|
case "max":
|
|
181
182
|
case "min":
|
|
182
|
-
setListboxLimit(name,
|
|
183
|
+
setListboxLimit(name, state, value);
|
|
183
184
|
break;
|
|
184
185
|
case "value": this.value = value ?? "";
|
|
185
186
|
}
|
|
@@ -190,33 +191,40 @@ var OuiComboboxElement = class extends HTMLElement {
|
|
|
190
191
|
* @returns `true` if the combobox is valid, otherwise `false`
|
|
191
192
|
*/
|
|
192
193
|
checkValidity() {
|
|
193
|
-
return this
|
|
194
|
+
return this[COMBOBOX_SYMBOL].form.internals.checkValidity();
|
|
194
195
|
}
|
|
195
196
|
/**
|
|
196
197
|
* Clear all selected options
|
|
197
198
|
*/
|
|
198
199
|
clear() {
|
|
199
|
-
setListboxValues(this
|
|
200
|
+
setListboxValues(this[COMBOBOX_SYMBOL], []);
|
|
200
201
|
}
|
|
201
202
|
connectedCallback() {
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
const state = this[COMBOBOX_SYMBOL];
|
|
204
|
+
if (state.component == null) initializeCombobox(this, state);
|
|
205
|
+
else attachListbox(state, comboboxes, onAttachCombobox);
|
|
204
206
|
}
|
|
205
207
|
disconnectedCallback() {
|
|
206
|
-
|
|
208
|
+
const state = this[COMBOBOX_SYMBOL];
|
|
209
|
+
if (state.component != null) detachListbox(state, comboboxes, onDetachCombobox);
|
|
207
210
|
}
|
|
208
211
|
formDisabledCallback(disabled) {
|
|
209
212
|
this.disabled = disabled;
|
|
210
213
|
}
|
|
211
214
|
formResetCallback() {
|
|
212
|
-
|
|
215
|
+
const state = this[COMBOBOX_SYMBOL];
|
|
216
|
+
if (state.component != null) setListboxValues(state, state.component.values.initial);
|
|
213
217
|
}
|
|
214
218
|
formStateRestoreCallback(state, reason) {
|
|
215
219
|
if (reason !== "restore") return;
|
|
216
220
|
const parsed = typeof state === "string" ? parse(state) : void 0;
|
|
217
221
|
if (!Array.isArray(parsed)) return;
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
const { component, form } = this[COMBOBOX_SYMBOL];
|
|
223
|
+
if (component == null) form.restored = parsed;
|
|
224
|
+
else setListboxValues({
|
|
225
|
+
component,
|
|
226
|
+
form
|
|
227
|
+
}, parsed);
|
|
220
228
|
}
|
|
221
229
|
/**
|
|
222
230
|
* Check if the combobox is valid and report any validation errors
|
|
@@ -224,7 +232,7 @@ var OuiComboboxElement = class extends HTMLElement {
|
|
|
224
232
|
* @returns `true` if the combobox is valid, otherwise `false`
|
|
225
233
|
*/
|
|
226
234
|
reportValidity() {
|
|
227
|
-
return this
|
|
235
|
+
return this[COMBOBOX_SYMBOL].form.internals.reportValidity();
|
|
228
236
|
}
|
|
229
237
|
/**
|
|
230
238
|
* Set a custom validation message for the combobox
|
|
@@ -232,18 +240,11 @@ var OuiComboboxElement = class extends HTMLElement {
|
|
|
232
240
|
* @param message Validation message
|
|
233
241
|
*/
|
|
234
242
|
setCustomValidity(message) {
|
|
235
|
-
this
|
|
243
|
+
this[COMBOBOX_SYMBOL].form.internals.setValidity({ customError: message !== "" }, message, this);
|
|
236
244
|
}
|
|
237
245
|
setLocalizations(first, second) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
#initialize() {
|
|
241
|
-
this.tabIndex = -1;
|
|
242
|
-
this.#state = createComboboxState(this, this.#internals);
|
|
243
|
-
if (this.#restored != null) {
|
|
244
|
-
setListboxValues(this.#state, this.#restored);
|
|
245
|
-
this.#restored = void 0;
|
|
246
|
-
}
|
|
246
|
+
const { localizations } = this[COMBOBOX_SYMBOL].component;
|
|
247
|
+
updateLocalizations(localizations.global, typeof first === "string" ? { [first]: second } : first, localizations.component);
|
|
247
248
|
}
|
|
248
249
|
};
|
|
249
250
|
customElements.define(COMBOBOX_TAGNAME, OuiComboboxElement);
|