@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,18 @@
|
|
|
1
|
+
import { _ as OuiLocalizationsValues } from "../../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { a as CreateOptionListList, f as OptionListGroup, g as OptionListState, h as OptionListPreview, i as CreateOptionListGroupParameters, n as CreateOptionListContentParameters, o as CreateOptionListOptionParameters, r as CreateOptionListFilter, s as CreateOptionListOptionsParameters, t as CreateOptionListContent } from "../../option-list.model-CCPUlPeX.mjs";
|
|
3
|
+
import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
4
|
+
//#region src/js/internal/option-list/option-list.dom.d.ts
|
|
5
|
+
export declare function createOptionListContent(parameters: CreateOptionListContentParameters): CreateOptionListContent;
|
|
6
|
+
export declare function createOptionListFilter(parameters: CreateOptionListContentParameters): CreateOptionListFilter | undefined;
|
|
7
|
+
export declare function createOptionListGroup(parameters: CreateOptionListGroupParameters): OptionListGroup;
|
|
8
|
+
export declare function createOptionListHeader(parameters: CreateOptionListGroupParameters, group: HTMLOptGroupElement): HTMLElement;
|
|
9
|
+
export declare function createOptionListInput(parameters: CreateOptionListContentParameters, value: string): HTMLInputElement;
|
|
10
|
+
export declare function createOptionListList(parameters: CreateOptionListContentParameters): CreateOptionListList;
|
|
11
|
+
export declare function createOptionListMessage(attribute: string): HTMLDivElement;
|
|
12
|
+
export declare function createOptionListOption(parameters: CreateOptionListOptionParameters): HTMLElement;
|
|
13
|
+
export declare function createOptionListOptions(parameters: CreateOptionListOptionsParameters): HTMLElement[];
|
|
14
|
+
export declare function createOptionListValueLabel(id: string): HTMLSpanElement;
|
|
15
|
+
export declare function updateOptionListMessage<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>): void;
|
|
16
|
+
export declare function updateOptionListPreview<State extends PlainObject, Localizations extends OuiLocalizationsValues>(preview: OptionListPreview, state: OptionListState<State, Localizations>, active?: HTMLElement, scroll?: boolean): void;
|
|
17
|
+
export declare function updateOptionListValueLabel<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>): void;
|
|
18
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as createOptionListValueLabel, b as updateOptionListValueLabel, c as createOptionListContent, d as createOptionListHeader, f as createOptionListInput, g as createOptionListOptions, h as createOptionListOption, l as createOptionListFilter, m as createOptionListMessage, p as createOptionListList, u as createOptionListGroup, v as updateOptionListMessage, y as updateOptionListPreview } from "../../option-list.data-CgMyUwPc.mjs";
|
|
2
|
+
export { createOptionListContent, createOptionListFilter, createOptionListGroup, createOptionListHeader, createOptionListInput, createOptionListList, createOptionListMessage, createOptionListOption, createOptionListOptions, createOptionListValueLabel, updateOptionListMessage, updateOptionListPreview, updateOptionListValueLabel };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { _ as OuiLocalizationsValues } from "../../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { g as OptionListState } from "../../option-list.model-CCPUlPeX.mjs";
|
|
3
|
+
import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
4
|
+
//#region src/js/internal/option-list/option-list.event.d.ts
|
|
5
|
+
export declare function processOptionListKeydown<State extends PlainObject, Localizations extends OuiLocalizationsValues>(event: KeyboardEvent, state: OptionListState<State, Localizations>): void;
|
|
6
|
+
//#endregion
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LISTBOX_KEYS_NAVIGATION, OPTION_LIST_KEYS_SELECTION } from "./option-list.constants.mjs";
|
|
2
|
+
import { S as getOptionListVisibleOptions } from "../../option-list.data-CgMyUwPc.mjs";
|
|
3
|
+
import { clamp } from "@oscarpalmer/atoms/number";
|
|
4
|
+
//#region src/js/internal/option-list/option-list.event.ts
|
|
5
|
+
function processOptionListKeydown(event, state) {
|
|
6
|
+
const { component, form } = state;
|
|
7
|
+
const { callbacks, disabled, readonly, type } = component;
|
|
8
|
+
const ignore = disabled || readonly;
|
|
9
|
+
const isSelect = type === "select";
|
|
10
|
+
let preventDefault = ignore;
|
|
11
|
+
switch (true) {
|
|
12
|
+
case event.key === " ":
|
|
13
|
+
if (!disabled) callbacks.keydown.onActivation?.(state);
|
|
14
|
+
break;
|
|
15
|
+
case event.key === "Enter":
|
|
16
|
+
preventDefault = callbacks.keydown.preventActivation?.(state) ?? true;
|
|
17
|
+
if (preventDefault) callbacks.keydown.onEnter?.(state);
|
|
18
|
+
else if (!ignore && type === "select") callbacks.keydown.onActivation?.(state);
|
|
19
|
+
else if (!ignore) form.internals.form?.requestSubmit();
|
|
20
|
+
break;
|
|
21
|
+
case event.key === "Escape":
|
|
22
|
+
preventDefault = false;
|
|
23
|
+
callbacks.keydown.onEscape?.(state);
|
|
24
|
+
break;
|
|
25
|
+
case !isSelect && OPTION_LIST_KEYS_SELECTION.has(event.key):
|
|
26
|
+
if (!ignore) callbacks.keydown.onSelection?.(state);
|
|
27
|
+
break;
|
|
28
|
+
case LISTBOX_KEYS_NAVIGATION.has(event.key):
|
|
29
|
+
if (!disabled) onNavigation(event, state);
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
preventDefault = false;
|
|
33
|
+
if (event.key === "Tab") callbacks.keydown.onTab?.(state);
|
|
34
|
+
}
|
|
35
|
+
if (preventDefault) {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
event.stopPropagation();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function onNavigation(event, state) {
|
|
41
|
+
const { active, autocomplete, callbacks, type } = state.component;
|
|
42
|
+
const skip = callbacks.keydown.skipNavigation?.(state) ?? false;
|
|
43
|
+
const visible = getOptionListVisibleOptions(state);
|
|
44
|
+
if (visible.length === 0) return;
|
|
45
|
+
let next;
|
|
46
|
+
if (skip || active == null) next = active ?? visible.at(event.key === "ArrowDown" ? 0 : -1);
|
|
47
|
+
else {
|
|
48
|
+
const current = visible.findIndex((option) => option.id === active?.id);
|
|
49
|
+
let index;
|
|
50
|
+
switch (event.key) {
|
|
51
|
+
case "ArrowDown":
|
|
52
|
+
case "ArrowUp":
|
|
53
|
+
index = clamp(current + (event.key === "ArrowDown" ? 1 : -1), 0, visible.length - 1, true);
|
|
54
|
+
break;
|
|
55
|
+
case "PageDown":
|
|
56
|
+
case "PageUp": index = clamp(current + (event.key === "PageDown" ? 10 : -10), 0, visible.length - 1);
|
|
57
|
+
}
|
|
58
|
+
if (index != null) next = visible[index];
|
|
59
|
+
}
|
|
60
|
+
let preview;
|
|
61
|
+
if (type === "autocomplete" && (autocomplete.both || autocomplete.inline)) preview = "set";
|
|
62
|
+
else preview = "none";
|
|
63
|
+
callbacks.keydown.onNavigation(preview, state, next ?? active ?? visible[0]);
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { processOptionListKeydown };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { _ as OuiLocalizationsValues } from "../../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { g as OptionListState } from "../../option-list.model-CCPUlPeX.mjs";
|
|
3
|
+
import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
4
|
+
//#region src/js/internal/option-list/option-list.form.d.ts
|
|
5
|
+
export declare function updateOptionListForm<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, values: string[], emit?: boolean): void;
|
|
6
|
+
export declare function updateOptionListValidity<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>): void;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { dispatch } from "@oscarpalmer/toretto/event";
|
|
2
|
+
//#region src/js/internal/option-list/option-list.form.ts
|
|
3
|
+
function updateOptionListForm(state, values, emit) {
|
|
4
|
+
const { component, form } = state;
|
|
5
|
+
const { callbacks, host, multiple, name } = component;
|
|
6
|
+
let value;
|
|
7
|
+
if (multiple) {
|
|
8
|
+
const { length } = values;
|
|
9
|
+
value = new FormData();
|
|
10
|
+
for (let index = 0; index < length; index += 1) value.append(name, values[index]);
|
|
11
|
+
} else value = values[0];
|
|
12
|
+
component.values.current = values;
|
|
13
|
+
form.internals.setFormValue(value, JSON.stringify(values));
|
|
14
|
+
callbacks.data.onForm(state);
|
|
15
|
+
updateOptionListValidity(state);
|
|
16
|
+
if (emit ?? true) dispatch(host, "oui:change");
|
|
17
|
+
}
|
|
18
|
+
function updateOptionListValidity(state) {
|
|
19
|
+
const { component, form } = state;
|
|
20
|
+
const { autocomplete, filter, host, listbox, localizations, max, min, multiple, options, required } = component;
|
|
21
|
+
if (autocomplete.none && !listbox) {
|
|
22
|
+
const valueMissing = required && filter.element.value.length === 0;
|
|
23
|
+
form.internals.setValidity({ valueMissing }, localizations.localize("invalid", { element: host }));
|
|
24
|
+
form.internals.checkValidity();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let error;
|
|
28
|
+
let key;
|
|
29
|
+
let parameters = [];
|
|
30
|
+
switch (true) {
|
|
31
|
+
case required && options.selected.length === 0:
|
|
32
|
+
error = "badInput";
|
|
33
|
+
key = "input";
|
|
34
|
+
break;
|
|
35
|
+
case multiple && typeof max === "number" && options.selected.length > max:
|
|
36
|
+
error = "rangeOverflow";
|
|
37
|
+
key = "max";
|
|
38
|
+
parameters = [max];
|
|
39
|
+
break;
|
|
40
|
+
case multiple && typeof min === "number" && options.selected.length < min:
|
|
41
|
+
error = "rangeUnderflow";
|
|
42
|
+
key = "min";
|
|
43
|
+
parameters = [min];
|
|
44
|
+
}
|
|
45
|
+
const message = key == null ? void 0 : localizations.localize(key, {
|
|
46
|
+
arguments: parameters,
|
|
47
|
+
element: host
|
|
48
|
+
});
|
|
49
|
+
form.internals.setValidity(error == null ? {} : { [error]: true }, message);
|
|
50
|
+
form.internals.checkValidity();
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { updateOptionListForm, updateOptionListValidity };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { _ as OuiLocalizationsValues } from "../../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { g as OptionListState } from "../../option-list.model-CCPUlPeX.mjs";
|
|
3
|
+
import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
4
|
+
//#region src/js/internal/option-list/option-list.misc.d.ts
|
|
5
|
+
export declare function generateOptionListIds(prefix: string, select: HTMLSelectElement): void;
|
|
6
|
+
export declare function getOptionListVisibleOptions<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>): Element[];
|
|
7
|
+
export declare function setOptionListDisabled<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, value: boolean): void;
|
|
8
|
+
export declare function setOptionListFilter<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, value: unknown): void;
|
|
9
|
+
export declare function setOptionListLimit<State extends PlainObject, Localizations extends OuiLocalizationsValues>(type: "max" | "min", state: OptionListState<State, Localizations>, value?: unknown): void;
|
|
10
|
+
export declare function setOptionListMultiple(element: Element, value: boolean): void;
|
|
11
|
+
export declare function setOptionListReadonly<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, value: boolean): void;
|
|
12
|
+
export declare function setOptionListRequired<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, value: boolean): void;
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as setOptionListDisabled, D as setOptionListReadonly, E as setOptionListMultiple, O as setOptionListRequired, S as getOptionListVisibleOptions, T as setOptionListLimit, w as setOptionListFilter, x as generateOptionListIds } from "../../option-list.data-CgMyUwPc.mjs";
|
|
2
|
+
export { generateOptionListIds, getOptionListVisibleOptions, setOptionListDisabled, setOptionListFilter, setOptionListLimit, setOptionListMultiple, setOptionListReadonly, setOptionListRequired };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as OptionListType, a as CreateOptionListList, c as OptionListAttributes, d as OptionListCallbacks, f as OptionListGroup, g as OptionListState, h as OptionListPreview, i as CreateOptionListGroupParameters, l as OptionListAutoComplete, m as OptionListOptions, n as CreateOptionListContentParameters, o as CreateOptionListOptionParameters, p as OptionListLocalizationValues, r as CreateOptionListFilter, s as CreateOptionListOptionsParameters, t as CreateOptionListContent, u as OptionListAutoCompleteType } from "../../option-list.model-CCPUlPeX.mjs";
|
|
2
|
+
export { CreateOptionListContent, CreateOptionListContentParameters, CreateOptionListFilter, CreateOptionListGroupParameters, CreateOptionListList, CreateOptionListOptionParameters, CreateOptionListOptionsParameters, OptionListAttributes, OptionListAutoComplete, OptionListAutoCompleteType, OptionListCallbacks, OptionListGroup, OptionListLocalizationValues, OptionListOptions, OptionListPreview, OptionListState, OptionListType };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { _ as OuiLocalizationsValues } from "../../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { g as OptionListState } from "../../option-list.model-CCPUlPeX.mjs";
|
|
3
|
+
import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
4
|
+
//#region src/js/internal/option-list/option-list.state.d.ts
|
|
5
|
+
export declare function attachOptionList<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, set: Set<OptionListState<State, Localizations>>, onAttach: (state: OptionListState<State, Localizations>) => void): void;
|
|
6
|
+
export declare function detachOptionList<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, set: Set<OptionListState<State, Localizations>>, onDetach: (state: OptionListState<State, Localizations>) => void): void;
|
|
7
|
+
export declare function initializeOptionListState<State extends PlainObject, Localizations extends OuiLocalizationsValues>(state: OptionListState<State, Localizations>, set: Set<OptionListState<State, Localizations>>, onAttach: (state: OptionListState<State, Localizations>) => void): OptionListState<State, Localizations>;
|
|
8
|
+
//#endregion
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { updateOptionListForm } from "./option-list.form.mjs";
|
|
2
|
+
import { C as setOptionListDisabled, D as setOptionListReadonly, E as setOptionListMultiple, O as setOptionListRequired, T as setOptionListLimit, b as updateOptionListValueLabel, i as filterOptionListOptions, v as updateOptionListMessage, y as updateOptionListPreview } from "../../option-list.data-CgMyUwPc.mjs";
|
|
3
|
+
import { getAttribute } from "@oscarpalmer/toretto/attribute";
|
|
4
|
+
//#region src/js/internal/option-list/option-list.state.ts
|
|
5
|
+
function attachOptionList(state, set, onAttach) {
|
|
6
|
+
const { filter, id, label } = state.component;
|
|
7
|
+
label.element.htmlFor = filter.element.id;
|
|
8
|
+
label.element.id = `${id}_label`;
|
|
9
|
+
onAttach(state);
|
|
10
|
+
set.add(state);
|
|
11
|
+
}
|
|
12
|
+
function detachOptionList(state, set, onDetach) {
|
|
13
|
+
const { label, select } = state.component;
|
|
14
|
+
const listeners = state.component.listeners.splice(0);
|
|
15
|
+
const { length } = listeners;
|
|
16
|
+
for (let index = 0; index < length; index += 1) listeners[index]();
|
|
17
|
+
label.element.htmlFor = select.id;
|
|
18
|
+
label.element.id = label.id;
|
|
19
|
+
onDetach(state);
|
|
20
|
+
set.delete(state);
|
|
21
|
+
}
|
|
22
|
+
function initializeOptionListState(state, set, onAttach) {
|
|
23
|
+
const { component } = state;
|
|
24
|
+
attachOptionList(state, set, onAttach);
|
|
25
|
+
setOptionListDisabled(state, component.disabled);
|
|
26
|
+
setOptionListLimit("max", state, getAttribute(component.host, "max"));
|
|
27
|
+
setOptionListLimit("min", state, getAttribute(component.host, "min"));
|
|
28
|
+
setOptionListMultiple(component.host, component.multiple);
|
|
29
|
+
setOptionListReadonly(state, component.readonly);
|
|
30
|
+
setOptionListRequired(state, component.required);
|
|
31
|
+
filterOptionListOptions(state);
|
|
32
|
+
updateOptionListForm(state, component.values.current, false);
|
|
33
|
+
updateOptionListMessage(state);
|
|
34
|
+
updateOptionListValueLabel(state);
|
|
35
|
+
if (component.options.selected.length > 0) updateOptionListPreview("none", state, component.options.selected[0], false);
|
|
36
|
+
return state;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { attachOptionList, detachOptionList, initializeOptionListState };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { p as OuiLocalizations, u as OuiDefaultLocalizations } from "../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { createDefaultLocalizations, createLocalizations } from "../internal/l10n/index.mjs";
|
|
3
|
+
export { type OuiDefaultLocalizations, type OuiLocalizations, createDefaultLocalizations, createLocalizations };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { GenericCallback } from "@oscarpalmer/atoms/models";
|
|
2
|
+
//#region src/js/internal/l10n/l10n.model.d.ts
|
|
3
|
+
type OuiDefaultLocalizations<Localizations extends OuiLocalizationsValues> = {
|
|
4
|
+
[L10N_SYMBOL]: OuiDefaultLocalizationsState<Localizations>;
|
|
5
|
+
get keys(): Array<keyof Localizations>;
|
|
6
|
+
get values(): OuiDefaultLocalizationsValues<Localizations>;
|
|
7
|
+
localize<Key extends keyof Localizations>(key: Key, parameters?: OuiLocalizationsParameters<Localizations[Key]>): string;
|
|
8
|
+
setDefaults(values: Partial<Localizations>): Promise<boolean>;
|
|
9
|
+
setLanguages(language: string, localizations: Partial<Localizations>): Promise<boolean>;
|
|
10
|
+
setLanguages(localizations: Record<string, Partial<Localizations>>): Promise<boolean>;
|
|
11
|
+
};
|
|
12
|
+
type OuiDefaultLocalizationsState<Localizations extends OuiLocalizationsValues> = {
|
|
13
|
+
defaults: Localizations;
|
|
14
|
+
keys: Set<keyof Localizations>;
|
|
15
|
+
type: typeof L10N_TYPE_DEFAULT;
|
|
16
|
+
values: Record<string, Partial<Localizations>>;
|
|
17
|
+
};
|
|
18
|
+
type OuiDefaultLocalizationsValues<Localizations extends OuiLocalizationsValues> = {
|
|
19
|
+
defaults: Localizations;
|
|
20
|
+
languages: Record<string, Partial<Localizations>>;
|
|
21
|
+
};
|
|
22
|
+
type OuiLocalizationsCallback<Localization> = Extract<Localization, GenericCallback>;
|
|
23
|
+
type OuiLocalizationsParameters<Localization> = ([OuiLocalizationsCallback<Localization>] extends [never] ? {} : {
|
|
24
|
+
arguments: Parameters<OuiLocalizationsCallback<Localization>>;
|
|
25
|
+
}) & {
|
|
26
|
+
element?: Element;
|
|
27
|
+
language?: string;
|
|
28
|
+
};
|
|
29
|
+
type OuiLocalizations<Localizations extends OuiLocalizationsValues> = {
|
|
30
|
+
[L10N_SYMBOL]: OuiLocalizationsState<Localizations>;
|
|
31
|
+
get defaults(): OuiDefaultLocalizations<Localizations>;
|
|
32
|
+
localize<Key extends keyof Localizations>(key: Key, parameters?: OuiLocalizationsParameters<Localizations[Key]>): string;
|
|
33
|
+
set(language: string, localizations: Partial<Localizations>): Promise<boolean>;
|
|
34
|
+
set(localizations: Record<string, Partial<Localizations>>): Promise<boolean>;
|
|
35
|
+
};
|
|
36
|
+
type OuiLocalizationsState<Localizations extends OuiLocalizationsValues> = {
|
|
37
|
+
defaults: OuiDefaultLocalizations<Localizations>;
|
|
38
|
+
keys: Set<keyof Localizations>;
|
|
39
|
+
type: typeof L10N_TYPE_INSTANCE;
|
|
40
|
+
values: Record<string, Partial<Localizations>>;
|
|
41
|
+
};
|
|
42
|
+
type OuiLocalizationsType = "default" | "instance";
|
|
43
|
+
type OuiLocalizationsValues = Record<string, string | GenericCallback>;
|
|
44
|
+
declare const L10N_MESSAGE_DEFAULT = "Default localizations must be an instance of OuiDefaultLocalizations.";
|
|
45
|
+
declare const L10N_MESSAGE_ITEM_CREATE = "Localization item must be a string or a function.";
|
|
46
|
+
declare const L10N_MESSAGE_ITEM_UPDATE_KEY = "Localization item key must be known.";
|
|
47
|
+
declare const L10N_MESSAGE_ITEM_UPDATE_VALUE = "Localization item value must be a string or a function.";
|
|
48
|
+
declare const L10N_MESSAGE_OBJECT_CREATE = "Default localizations must be a non-empty plain object.";
|
|
49
|
+
declare const L10N_MESSAGE_OBJECT_UPDATE = "Localizations update object must be a plain object.";
|
|
50
|
+
declare const L10N_TYPE_DEFAULT: OuiLocalizationsType;
|
|
51
|
+
declare const L10N_TYPE_INSTANCE: OuiLocalizationsType;
|
|
52
|
+
declare const L10N_SYMBOL: unique symbol;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { OuiLocalizationsValues as _, L10N_MESSAGE_OBJECT_CREATE as a, L10N_TYPE_DEFAULT as c, OuiDefaultLocalizationsState as d, OuiDefaultLocalizationsValues as f, OuiLocalizationsType as g, OuiLocalizationsState as h, L10N_MESSAGE_ITEM_UPDATE_VALUE as i, L10N_TYPE_INSTANCE as l, OuiLocalizationsParameters as m, L10N_MESSAGE_ITEM_CREATE as n, L10N_MESSAGE_OBJECT_UPDATE as o, OuiLocalizations as p, L10N_MESSAGE_ITEM_UPDATE_KEY as r, L10N_SYMBOL as s, L10N_MESSAGE_DEFAULT as t, OuiDefaultLocalizations as u };
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
1
|
+
import { p as OuiLocalizations } from "../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { n as LISTBOX_TAGNAME, t as LISTBOX_SYMBOL } from "../listbox.constants-DOBMwKup.mjs";
|
|
3
|
+
import { n as OuiListboxLocalizations, r as OuiListboxState } from "../listbox.model-C0MYWXZe.mjs";
|
|
4
|
+
import { n as setListboxLocalizations } from "../listbox.misc-DwfB4Mu_.mjs";
|
|
4
5
|
//#region src/js/listbox/index.d.ts
|
|
5
6
|
declare global {
|
|
6
7
|
interface HTMLElementTagNameMap {
|
|
7
8
|
[LISTBOX_TAGNAME]: OuiListboxElement;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
11
|
+
export interface OuiListboxElement {
|
|
12
|
+
[LISTBOX_SYMBOL]: OuiListboxState;
|
|
13
|
+
}
|
|
10
14
|
export declare class OuiListboxElement extends HTMLElement {
|
|
11
|
-
#private;
|
|
12
15
|
static formAssociated: boolean;
|
|
13
16
|
static observedAttributes: string[];
|
|
14
17
|
/**
|
|
@@ -35,6 +38,7 @@ export declare class OuiListboxElement extends HTMLElement {
|
|
|
35
38
|
* Label elements associated with the listbox
|
|
36
39
|
*/
|
|
37
40
|
get labels(): NodeList;
|
|
41
|
+
get localizations(): OuiLocalizations<OuiListboxLocalizations>;
|
|
38
42
|
/**
|
|
39
43
|
* Maximum number of selected options
|
|
40
44
|
*/
|
|
@@ -78,7 +82,7 @@ export declare class OuiListboxElement extends HTMLElement {
|
|
|
78
82
|
/**
|
|
79
83
|
* Selected options
|
|
80
84
|
*/
|
|
81
|
-
get selected():
|
|
85
|
+
get selected(): Element[];
|
|
82
86
|
/**
|
|
83
87
|
* Validation message for the listbox
|
|
84
88
|
*/
|
|
@@ -136,19 +140,6 @@ export declare class OuiListboxElement extends HTMLElement {
|
|
|
136
140
|
* @param message Validation message
|
|
137
141
|
*/
|
|
138
142
|
setCustomValidity(message: string): void;
|
|
139
|
-
/**
|
|
140
|
-
* Set listbox localizations for a specific language
|
|
141
|
-
*
|
|
142
|
-
* @param language Language code
|
|
143
|
-
* @param localizations Localizations for language
|
|
144
|
-
*/
|
|
145
|
-
setLocalizations(language: string, localizations: Partial<OuiListboxLocalizations>): void;
|
|
146
|
-
/**
|
|
147
|
-
* Set listbox localizations for one or more languages
|
|
148
|
-
*
|
|
149
|
-
* @param localizations Localizations for one or more languages
|
|
150
|
-
*/
|
|
151
|
-
setLocalizations(localizations: Record<string, Partial<OuiListboxLocalizations>>): void;
|
|
152
143
|
}
|
|
153
144
|
//#endregion
|
|
154
145
|
export { setListboxLocalizations };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import {
|
|
3
|
-
import { LISTBOX_TAGNAME } from "./constants.
|
|
4
|
-
import {
|
|
1
|
+
import { C as setOptionListDisabled, D as setOptionListReadonly, O as setOptionListRequired, T as setOptionListLimit, a as setOptionListValue, o as setOptionListValues, w as setOptionListFilter } from "../option-list.data-CgMyUwPc.mjs";
|
|
2
|
+
import { attachOptionList, detachOptionList } from "../internal/option-list/option-list.state.mjs";
|
|
3
|
+
import { LISTBOX_SYMBOL, LISTBOX_TAGNAME } from "./listbox.constants.mjs";
|
|
4
|
+
import { a as onDetachListbox, i as onAttachListbox, r as listboxes, s as setListboxLocalizations, t as initializeListbox } from "../listbox.state-BrN296BM.mjs";
|
|
5
5
|
import { getAttribute } from "@oscarpalmer/toretto/attribute";
|
|
6
6
|
import { parse } from "@oscarpalmer/atoms/string";
|
|
7
7
|
//#region src/js/listbox/index.ts
|
|
@@ -13,68 +13,68 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
13
13
|
"required",
|
|
14
14
|
"value"
|
|
15
15
|
];
|
|
16
|
-
#internals;
|
|
17
|
-
#restored;
|
|
18
|
-
#state;
|
|
19
16
|
/**
|
|
20
17
|
* Is the listbox disabled?
|
|
21
18
|
*/
|
|
22
19
|
get disabled() {
|
|
23
|
-
return this
|
|
20
|
+
return this[LISTBOX_SYMBOL].component?.disabled ?? false;
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* Should the listbox be disabled?
|
|
27
24
|
*/
|
|
28
25
|
set disabled(value) {
|
|
29
|
-
if (typeof value === "boolean" && value !== this.disabled)
|
|
26
|
+
if (typeof value === "boolean" && value !== this.disabled) setOptionListDisabled(this[LISTBOX_SYMBOL], value);
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Current filter value
|
|
33
30
|
*/
|
|
34
31
|
get filter() {
|
|
35
|
-
return this
|
|
32
|
+
return this[LISTBOX_SYMBOL].component?.filter.element.value ?? "";
|
|
36
33
|
}
|
|
37
34
|
/**
|
|
38
35
|
* Set the filter value
|
|
39
36
|
*/
|
|
40
37
|
set filter(value) {
|
|
41
|
-
|
|
38
|
+
setOptionListFilter(this[LISTBOX_SYMBOL], value);
|
|
42
39
|
}
|
|
43
40
|
/**
|
|
44
41
|
* Form element associated with the listbox
|
|
45
42
|
*/
|
|
46
43
|
get form() {
|
|
47
|
-
return this
|
|
44
|
+
return this[LISTBOX_SYMBOL].form.internals.form;
|
|
48
45
|
}
|
|
49
46
|
/**
|
|
50
47
|
* Label elements associated with the listbox
|
|
51
48
|
*/
|
|
52
49
|
get labels() {
|
|
53
|
-
return this
|
|
50
|
+
return this[LISTBOX_SYMBOL].form.internals.labels;
|
|
51
|
+
}
|
|
52
|
+
get localizations() {
|
|
53
|
+
return this[LISTBOX_SYMBOL].component?.localizations;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Maximum number of selected options
|
|
57
57
|
*/
|
|
58
58
|
get max() {
|
|
59
|
-
return this
|
|
59
|
+
return this[LISTBOX_SYMBOL].component?.max;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* Set the maximum number of selected options
|
|
63
63
|
*/
|
|
64
64
|
set max(value) {
|
|
65
|
-
|
|
65
|
+
setOptionListLimit("max", this[LISTBOX_SYMBOL], value);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Minimum number of selected options
|
|
69
69
|
*/
|
|
70
70
|
get min() {
|
|
71
|
-
return this
|
|
71
|
+
return this[LISTBOX_SYMBOL].component?.min;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Set the minimum number of selected options
|
|
75
75
|
*/
|
|
76
76
|
set min(value) {
|
|
77
|
-
|
|
77
|
+
setOptionListLimit("min", this[LISTBOX_SYMBOL], value);
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Does the listbox allow multiple values?
|
|
@@ -92,87 +92,91 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
92
92
|
* Is the listbox readonly?
|
|
93
93
|
*/
|
|
94
94
|
get readonly() {
|
|
95
|
-
return this
|
|
95
|
+
return this[LISTBOX_SYMBOL].component?.readonly ?? false;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Should the listbox be readonly?
|
|
99
99
|
*/
|
|
100
100
|
set readonly(value) {
|
|
101
|
-
if (typeof value === "boolean" && value !== this.readonly)
|
|
101
|
+
if (typeof value === "boolean" && value !== this.readonly) setOptionListReadonly(this[LISTBOX_SYMBOL], value);
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Is the listbox required?
|
|
105
105
|
*/
|
|
106
106
|
get required() {
|
|
107
|
-
return this
|
|
107
|
+
return this[LISTBOX_SYMBOL].component?.required ?? false;
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* Should the listbox be required?
|
|
111
111
|
*/
|
|
112
112
|
set required(value) {
|
|
113
|
-
if (typeof value === "boolean" && value !== this.required)
|
|
113
|
+
if (typeof value === "boolean" && value !== this.required) setOptionListRequired(this[LISTBOX_SYMBOL], value);
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Selected options
|
|
117
117
|
*/
|
|
118
118
|
get selected() {
|
|
119
|
-
return this
|
|
119
|
+
return this[LISTBOX_SYMBOL].component?.options.selected.slice() ?? [];
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Validation message for the listbox
|
|
123
123
|
*/
|
|
124
124
|
get validationMessage() {
|
|
125
|
-
return this
|
|
125
|
+
return this[LISTBOX_SYMBOL].form.internals.validationMessage;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Validity state for the listbox
|
|
129
129
|
*/
|
|
130
130
|
get validity() {
|
|
131
|
-
return this
|
|
131
|
+
return this[LISTBOX_SYMBOL].form.internals.validity;
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Current value
|
|
135
135
|
*/
|
|
136
136
|
get value() {
|
|
137
|
-
return this
|
|
137
|
+
return this[LISTBOX_SYMBOL].component?.values.current[0] ?? "";
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Set the value
|
|
141
141
|
*/
|
|
142
142
|
set value(value) {
|
|
143
|
-
|
|
143
|
+
setOptionListValue(this[LISTBOX_SYMBOL], value);
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Current values
|
|
147
147
|
*/
|
|
148
148
|
get values() {
|
|
149
|
-
return this
|
|
149
|
+
return this[LISTBOX_SYMBOL].component?.values.current.slice() ?? [];
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* Set the values
|
|
153
153
|
*/
|
|
154
154
|
set values(values) {
|
|
155
|
-
|
|
155
|
+
setOptionListValues(this[LISTBOX_SYMBOL], values);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Can the listbox be validated?
|
|
159
159
|
*/
|
|
160
160
|
get willValidate() {
|
|
161
|
-
return this
|
|
161
|
+
return this[LISTBOX_SYMBOL].form.internals.willValidate;
|
|
162
162
|
}
|
|
163
163
|
constructor() {
|
|
164
164
|
super();
|
|
165
|
-
this
|
|
165
|
+
this[LISTBOX_SYMBOL] = {
|
|
166
|
+
component: void 0,
|
|
167
|
+
form: { internals: this.attachInternals() }
|
|
168
|
+
};
|
|
166
169
|
}
|
|
167
170
|
attributeChangedCallback(name, _, value) {
|
|
168
|
-
|
|
171
|
+
const state = this[LISTBOX_SYMBOL];
|
|
172
|
+
if (state.component == null) return;
|
|
169
173
|
switch (name) {
|
|
170
174
|
case "required":
|
|
171
175
|
this[name] = this.hasAttribute(name);
|
|
172
176
|
break;
|
|
173
177
|
case "max":
|
|
174
178
|
case "min":
|
|
175
|
-
|
|
179
|
+
setOptionListLimit(name, state, value);
|
|
176
180
|
break;
|
|
177
181
|
case "value": this.value = value ?? "";
|
|
178
182
|
}
|
|
@@ -183,33 +187,36 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
183
187
|
* @returns `true` if the listbox is valid, otherwise `false`
|
|
184
188
|
*/
|
|
185
189
|
checkValidity() {
|
|
186
|
-
return this
|
|
190
|
+
return this[LISTBOX_SYMBOL].form.internals.checkValidity();
|
|
187
191
|
}
|
|
188
192
|
/**
|
|
189
193
|
* Clear all selected options
|
|
190
194
|
*/
|
|
191
195
|
clear() {
|
|
192
|
-
|
|
196
|
+
setOptionListValues(this[LISTBOX_SYMBOL], []);
|
|
193
197
|
}
|
|
194
198
|
connectedCallback() {
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
const state = this[LISTBOX_SYMBOL];
|
|
200
|
+
if (state.component == null) initializeListbox(this, state);
|
|
201
|
+
else attachOptionList(state, listboxes, onAttachListbox);
|
|
197
202
|
}
|
|
198
203
|
disconnectedCallback() {
|
|
199
|
-
|
|
204
|
+
const state = this[LISTBOX_SYMBOL];
|
|
205
|
+
if (state.component != null) detachOptionList(state, listboxes, onDetachListbox);
|
|
200
206
|
}
|
|
201
207
|
formDisabledCallback(disabled) {
|
|
202
208
|
this.disabled = disabled;
|
|
203
209
|
}
|
|
204
210
|
formResetCallback() {
|
|
205
|
-
|
|
211
|
+
const state = this[LISTBOX_SYMBOL];
|
|
212
|
+
setOptionListValues(state, state.component.values.initial);
|
|
206
213
|
}
|
|
207
214
|
formStateRestoreCallback(state, reason) {
|
|
208
215
|
if (reason !== "restore") return;
|
|
209
216
|
const parsed = typeof state === "string" ? parse(state) : void 0;
|
|
210
217
|
if (!Array.isArray(parsed)) return;
|
|
211
|
-
if (this
|
|
212
|
-
else
|
|
218
|
+
if (this[LISTBOX_SYMBOL]?.component == null) this[LISTBOX_SYMBOL].form.restored = parsed;
|
|
219
|
+
else setOptionListValues(this[LISTBOX_SYMBOL], parsed);
|
|
213
220
|
}
|
|
214
221
|
/**
|
|
215
222
|
* Check if the listbox is valid and report any validation errors
|
|
@@ -217,7 +224,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
217
224
|
* @returns `true` if the listbox is valid, otherwise `false`
|
|
218
225
|
*/
|
|
219
226
|
reportValidity() {
|
|
220
|
-
return this
|
|
227
|
+
return this[LISTBOX_SYMBOL].form.internals.reportValidity();
|
|
221
228
|
}
|
|
222
229
|
/**
|
|
223
230
|
* Set a custom validation message for the listbox
|
|
@@ -225,17 +232,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
225
232
|
* @param message Validation message
|
|
226
233
|
*/
|
|
227
234
|
setCustomValidity(message) {
|
|
228
|
-
this
|
|
229
|
-
}
|
|
230
|
-
setLocalizations(first, second) {
|
|
231
|
-
updateListboxLocalizations(this.#state.localizations.global, this.#state.localizations.component, first, second);
|
|
232
|
-
}
|
|
233
|
-
#initialize() {
|
|
234
|
-
this.#state = createListboxState(this, this.#internals);
|
|
235
|
-
if (this.#restored != null) {
|
|
236
|
-
setListboxValues(this.#state, this.#restored);
|
|
237
|
-
this.#restored = void 0;
|
|
238
|
-
}
|
|
235
|
+
this[LISTBOX_SYMBOL].form.internals.setValidity({ customError: message !== "" }, message, this);
|
|
239
236
|
}
|
|
240
237
|
};
|
|
241
238
|
customElements.define(LISTBOX_TAGNAME, OuiListboxElement);
|