@oscarpalmer/oui 0.34.0 → 0.36.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.
Files changed (93) hide show
  1. package/dist/css/combobox.css +1 -1
  2. package/dist/css/listbox.css +152 -0
  3. package/dist/js/combobox/constants.combobox.d.mts +2 -2
  4. package/dist/js/combobox/constants.combobox.mjs +40 -33
  5. package/dist/js/combobox/dom.combobox.d.mts +8 -91
  6. package/dist/js/combobox/dom.combobox.mjs +204 -2
  7. package/dist/js/combobox/event.combobox.d.mts +14 -8
  8. package/dist/js/combobox/event.combobox.mjs +2 -2
  9. package/dist/js/combobox/index.d.mts +1 -1
  10. package/dist/js/combobox/index.mjs +21 -18
  11. package/dist/js/combobox/misc.combobox.d.mts +2 -14
  12. package/dist/js/combobox/misc.combobox.mjs +2 -2
  13. package/dist/js/combobox/models.combobox.d.mts +44 -2
  14. package/dist/js/combobox/state.combobox.d.mts +9 -8
  15. package/dist/js/combobox/state.combobox.mjs +2 -2
  16. package/dist/js/constants.combobox-DmRAMC64.d.mts +26 -0
  17. package/dist/js/constants.listbox-DRsXUxd3.d.mts +14 -0
  18. package/dist/js/index-EfkUSals.d.mts +139 -0
  19. package/dist/js/index.d.mts +4 -2
  20. package/dist/js/index.mjs +4 -2
  21. package/dist/js/internal/attributable.mjs +4 -3
  22. package/dist/js/internal/listbox/listbox.constants.d.mts +11 -0
  23. package/dist/js/internal/listbox/listbox.constants.mjs +23 -0
  24. package/dist/js/internal/listbox/listbox.data.d.mts +20 -0
  25. package/dist/js/internal/listbox/listbox.data.mjs +2 -0
  26. package/dist/js/internal/listbox/listbox.dom.d.mts +66 -0
  27. package/dist/js/internal/listbox/listbox.dom.mjs +2 -0
  28. package/dist/js/internal/listbox/listbox.event.d.mts +5 -0
  29. package/dist/js/internal/listbox/listbox.event.mjs +63 -0
  30. package/dist/js/internal/listbox/listbox.form.d.mts +6 -0
  31. package/dist/js/internal/listbox/listbox.form.mjs +52 -0
  32. package/dist/js/internal/listbox/listbox.misc.d.mts +12 -0
  33. package/dist/js/internal/listbox/listbox.misc.mjs +2 -0
  34. package/dist/js/internal/listbox/listbox.model.d.mts +2 -0
  35. package/dist/js/internal/listbox/listbox.model.mjs +1 -0
  36. package/dist/js/internal/listbox/listbox.state.d.mts +7 -0
  37. package/dist/js/internal/listbox/listbox.state.mjs +40 -0
  38. package/dist/js/internal/misc.d.mts +6 -0
  39. package/dist/js/internal/misc.mjs +13 -0
  40. package/dist/js/l10n-Bn-7RcwR.d.mts +20 -0
  41. package/dist/js/l10n.d.mts +2 -0
  42. package/dist/js/l10n.mjs +80 -0
  43. package/dist/js/listbox/constants.listbox.d.mts +2 -0
  44. package/dist/js/listbox/constants.listbox.mjs +40 -0
  45. package/dist/js/listbox/event.listbox.d.mts +8 -0
  46. package/dist/js/listbox/event.listbox.mjs +2 -0
  47. package/dist/js/listbox/index.d.mts +116 -0
  48. package/dist/js/listbox/index.mjs +189 -0
  49. package/dist/js/listbox/misc.listbox.d.mts +2 -0
  50. package/dist/js/listbox/misc.listbox.mjs +2 -0
  51. package/dist/js/listbox/state.listbox.d.mts +11 -0
  52. package/dist/js/listbox/state.listbox.mjs +2 -0
  53. package/dist/js/listbox.data-BWd0PCy7.mjs +424 -0
  54. package/dist/js/listbox.model-CRReGOmu.d.mts +125 -0
  55. package/dist/js/misc.listbox-BI-XsTOf.mjs +197 -0
  56. package/dist/js/misc.listbox-gnoJhrTr.d.mts +20 -0
  57. package/dist/js/sortable/sortable.embedded.mjs +4 -2
  58. package/dist/js/state.combobox-4xq0FPCF.mjs +365 -0
  59. package/package.json +7 -3
  60. package/src/css/combobox.scss +1 -1
  61. package/src/css/listbox.scss +149 -0
  62. package/src/js/combobox/constants.combobox.ts +46 -25
  63. package/src/js/combobox/dom.combobox.ts +65 -452
  64. package/src/js/combobox/event.combobox.ts +129 -218
  65. package/src/js/combobox/index.ts +43 -30
  66. package/src/js/combobox/misc.combobox.ts +60 -94
  67. package/src/js/combobox/models.combobox.ts +7 -47
  68. package/src/js/combobox/state.combobox.ts +136 -125
  69. package/src/js/index.ts +1 -0
  70. package/src/js/internal/listbox/listbox.constants.ts +25 -0
  71. package/src/js/{combobox/data.combobox.ts → internal/listbox/listbox.data.ts} +94 -43
  72. package/src/js/internal/listbox/listbox.dom.ts +445 -0
  73. package/src/js/internal/listbox/listbox.event.ts +129 -0
  74. package/src/js/{combobox/form.combobox.ts → internal/listbox/listbox.form.ts} +33 -33
  75. package/src/js/internal/listbox/listbox.misc.ts +135 -0
  76. package/src/js/internal/listbox/listbox.model.ts +169 -0
  77. package/src/js/internal/listbox/listbox.state.ts +82 -0
  78. package/src/js/internal/misc.ts +27 -0
  79. package/src/js/l10n.ts +192 -0
  80. package/src/js/listbox/constants.listbox.ts +61 -0
  81. package/src/js/listbox/event.listbox.ts +106 -0
  82. package/src/js/listbox/index.ts +302 -0
  83. package/src/js/listbox/misc.listbox.ts +70 -0
  84. package/src/js/listbox/state.listbox.ts +196 -0
  85. package/dist/js/combobox/data.combobox.d.mts +0 -18
  86. package/dist/js/combobox/data.combobox.mjs +0 -2
  87. package/dist/js/combobox/form.combobox.d.mts +0 -6
  88. package/dist/js/combobox/form.combobox.mjs +0 -2
  89. package/dist/js/combobox/i18n.combobox.d.mts +0 -2
  90. package/dist/js/combobox/i18n.combobox.mjs +0 -2
  91. package/dist/js/constants.combobox-DqNUGBLS.d.mts +0 -243
  92. package/dist/js/data.combobox-8RwBv5ey.mjs +0 -1077
  93. package/src/js/combobox/i18n.combobox.ts +0 -179
@@ -0,0 +1,63 @@
1
+ import { LISTBOX_KEYS } from "./listbox.constants.mjs";
2
+ import { S as getListboxVisibleOptions } from "../../listbox.data-BWd0PCy7.mjs";
3
+ import { clamp } from "@oscarpalmer/atoms/number";
4
+ //#region src/js/internal/listbox/listbox.event.ts
5
+ function processListboxKeydown(event, state) {
6
+ const ignore = state.disabled || state.readonly;
7
+ const isSelect = state.type === "select";
8
+ let preventDefault = ignore;
9
+ switch (true) {
10
+ case event.key === " ":
11
+ if (!state.disabled) state.callbacks.keydown.onActivation?.(state);
12
+ break;
13
+ case event.key === "Enter":
14
+ preventDefault = state.callbacks.keydown.preventActivation?.(state) ?? true;
15
+ if (preventDefault) state.callbacks.keydown.onEnter?.(state);
16
+ else if (!ignore && state.type === "select") state.callbacks.keydown.onActivation?.(state);
17
+ else if (!ignore) state.internals.form?.requestSubmit();
18
+ break;
19
+ case event.key === "Escape":
20
+ preventDefault = false;
21
+ state.callbacks.keydown.onEscape?.(state);
22
+ break;
23
+ case !isSelect && LISTBOX_KEYS.selection.has(event.key):
24
+ if (!ignore) state.callbacks.keydown.onSelection?.(state);
25
+ break;
26
+ case LISTBOX_KEYS.navigation.has(event.key):
27
+ if (!state.disabled) onNavigation(event, state);
28
+ break;
29
+ default:
30
+ preventDefault = false;
31
+ if (event.key === "Tab") state.callbacks.keydown.onTab?.(state);
32
+ }
33
+ if (preventDefault) {
34
+ event.preventDefault();
35
+ event.stopPropagation();
36
+ }
37
+ }
38
+ function onNavigation(event, state) {
39
+ const skip = state.callbacks.keydown.skipNavigation?.(state) ?? false;
40
+ const visible = getListboxVisibleOptions(state);
41
+ if (visible.length === 0) return;
42
+ let next;
43
+ if (skip || state.active == null) next = state.active ?? visible.at(event.key === "ArrowDown" ? 0 : -1);
44
+ else {
45
+ const current = visible.findIndex((option) => option.id === state.active?.id);
46
+ let index;
47
+ switch (event.key) {
48
+ case "ArrowDown":
49
+ case "ArrowUp":
50
+ index = clamp(current + (event.key === "ArrowDown" ? 1 : -1), 0, visible.length - 1, true);
51
+ break;
52
+ case "PageDown":
53
+ case "PageUp": index = clamp(current + (event.key === "PageDown" ? 10 : -10), 0, visible.length - 1);
54
+ }
55
+ if (index != null) next = visible[index];
56
+ }
57
+ let preview;
58
+ if (state.type === "autocomplete" && (state.autocomplete.both || state.autocomplete.inline)) preview = "set";
59
+ else preview = "none";
60
+ state.callbacks.keydown.onNavigation(preview, state, next ?? state.active ?? visible[0]);
61
+ }
62
+ //#endregion
63
+ export { processListboxKeydown };
@@ -0,0 +1,6 @@
1
+ import { l as OuiListboxState } from "../../listbox.model-CRReGOmu.mjs";
2
+ //#region src/js/internal/listbox/listbox.form.d.ts
3
+ declare function updateListboxForm<State extends OuiListboxState>(state: State, values: string[], emit?: boolean): void;
4
+ declare function updateListboxValidity(state: OuiListboxState): void;
5
+ //#endregion
6
+ export { updateListboxForm, updateListboxValidity };
@@ -0,0 +1,52 @@
1
+ import { getLocalization, localize } from "../../l10n.mjs";
2
+ import { dispatch } from "@oscarpalmer/toretto/event";
3
+ //#region src/js/internal/listbox/listbox.form.ts
4
+ function updateListboxForm(state, values, emit) {
5
+ let value;
6
+ if (state.multiple) {
7
+ const { length } = values;
8
+ value = new FormData();
9
+ for (let index = 0; index < length; index += 1) value.append(state.name, values[index]);
10
+ } else value = values[0];
11
+ state.values.current = values;
12
+ state.internals.setFormValue(value, JSON.stringify(values));
13
+ state.callbacks.data.onForm(state);
14
+ updateListboxValidity(state);
15
+ if (emit ?? true) dispatch(state.host, "change");
16
+ }
17
+ function updateListboxValidity(state) {
18
+ if (state.autocomplete.none && !state.listbox) {
19
+ const valueMissing = state.required && state.filter.element.value.length === 0;
20
+ const localization = getLocalization(state.localizations.global, state.host, "invalid", state.localizations.component);
21
+ state.internals.setValidity({ valueMissing }, localize(localization, {}, []));
22
+ state.internals.checkValidity();
23
+ return;
24
+ }
25
+ let data = {};
26
+ let error;
27
+ let key;
28
+ let parameters = [];
29
+ switch (true) {
30
+ case state.required && state.options.selected.length === 0:
31
+ error = "badInput";
32
+ key = "input";
33
+ break;
34
+ case state.multiple && typeof state.max === "number" && state.options.selected.length > state.max:
35
+ data = { amount: state.max };
36
+ error = "rangeOverflow";
37
+ key = "max";
38
+ parameters = [state.max];
39
+ break;
40
+ case state.multiple && typeof state.min === "number" && state.options.selected.length < state.min:
41
+ data = { amount: state.min };
42
+ error = "rangeUnderflow";
43
+ key = "min";
44
+ parameters = [state.min];
45
+ }
46
+ const localization = key == null ? void 0 : getLocalization(state.localizations.global, state.host, key, state.localizations.component);
47
+ const message = localization == null ? void 0 : localize(localization, data, parameters);
48
+ state.internals.setValidity(error == null ? {} : { [error]: true }, message);
49
+ state.internals.checkValidity();
50
+ }
51
+ //#endregion
52
+ export { updateListboxForm, updateListboxValidity };
@@ -0,0 +1,12 @@
1
+ import { l as OuiListboxState } from "../../listbox.model-CRReGOmu.mjs";
2
+ //#region src/js/internal/listbox/listbox.misc.d.ts
3
+ declare function generateListboxIds(prefix: string, select: HTMLSelectElement): void;
4
+ declare function getListboxVisibleOptions(state: OuiListboxState): HTMLElement[];
5
+ declare function setListboxDisabled<State extends OuiListboxState>(state: State, value: boolean): void;
6
+ declare function setListboxFilter<State extends OuiListboxState>(state: State, value: unknown): void;
7
+ declare function setListboxLimit<State extends OuiListboxState>(type: 'max' | 'min', state: State, value?: unknown): void;
8
+ declare function setListboxMultiple(element: HTMLElement, value: boolean): void;
9
+ declare function setListboxReadonly<State extends OuiListboxState>(state: State, value: boolean): void;
10
+ declare function setListboxRequired<State extends OuiListboxState>(state: State, value: boolean): void;
11
+ //#endregion
12
+ export { generateListboxIds, getListboxVisibleOptions, setListboxDisabled, setListboxFilter, setListboxLimit, setListboxMultiple, setListboxReadonly, setListboxRequired };
@@ -0,0 +1,2 @@
1
+ import { C as setListboxDisabled, D as setListboxReadonly, E as setListboxMultiple, O as setListboxRequired, S as getListboxVisibleOptions, T as setListboxLimit, w as setListboxFilter, x as generateListboxIds } from "../../listbox.data-BWd0PCy7.mjs";
2
+ export { generateListboxIds, getListboxVisibleOptions, setListboxDisabled, setListboxFilter, setListboxLimit, setListboxMultiple, setListboxReadonly, setListboxRequired };
@@ -0,0 +1,2 @@
1
+ import { a as OuiListboxGroup, c as OuiListboxPreview, d as OuiListboxType, i as OuiListboxCallbacks, l as OuiListboxState, n as OuiListboxAutoComplete, o as OuiListboxLocalizations, r as OuiListboxAutoCompleteType, s as OuiListboxOptions, t as OuiListboxAttributes, u as OuiListboxStates } from "../../listbox.model-CRReGOmu.mjs";
2
+ export { OuiListboxAttributes, OuiListboxAutoComplete, OuiListboxAutoCompleteType, OuiListboxCallbacks, OuiListboxGroup, OuiListboxLocalizations, OuiListboxOptions, OuiListboxPreview, OuiListboxState, OuiListboxStates, OuiListboxType };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { l as OuiListboxState, u as OuiListboxStates } from "../../listbox.model-CRReGOmu.mjs";
2
+ //#region src/js/internal/listbox/listbox.state.d.ts
3
+ declare function attachListbox<State extends OuiListboxState>(state: State, states: OuiListboxStates<State>, onAttach: (state: State) => void): void;
4
+ declare function detachListbox<State extends OuiListboxState>(state: State, states: OuiListboxStates<State>, onDetach: (state: State) => void): void;
5
+ declare function initializeListboxState<State extends OuiListboxState>(state: State, states: OuiListboxStates<State>, onAttach: (state: State) => void): State;
6
+ //#endregion
7
+ export { attachListbox, detachListbox, initializeListboxState };
@@ -0,0 +1,40 @@
1
+ import { updateListboxForm } from "./listbox.form.mjs";
2
+ import { C as setListboxDisabled, D as setListboxReadonly, E as setListboxMultiple, O as setListboxRequired, T as setListboxLimit, b as updateListboxValueLabel, i as filterListboxOptions, v as updateListboxMessage, y as updateListboxPreview } from "../../listbox.data-BWd0PCy7.mjs";
3
+ import { getAttribute } from "@oscarpalmer/toretto/attribute";
4
+ //#region src/js/internal/listbox/listbox.state.ts
5
+ function attachListbox(state, states, onAttach) {
6
+ const { filter, host, label } = state;
7
+ label.element.htmlFor = filter.element.id;
8
+ label.element.id = `${state.id}_label`;
9
+ onAttach(state);
10
+ states.map.set(host, state);
11
+ states.set.add(state);
12
+ }
13
+ function detachListbox(state, states, onDetach) {
14
+ const { host, label, select } = state;
15
+ const listeners = state.listeners.splice(0);
16
+ const { length } = listeners;
17
+ for (let index = 0; index < length; index += 1) listeners[index]();
18
+ label.element.htmlFor = select.id;
19
+ label.element.id = label.id;
20
+ onDetach(state);
21
+ states.map.delete(host);
22
+ states.set.delete(state);
23
+ }
24
+ function initializeListboxState(state, states, onAttach) {
25
+ attachListbox(state, states, onAttach);
26
+ setListboxDisabled(state, state.disabled);
27
+ setListboxLimit("max", state, getAttribute(state.host, "max"));
28
+ setListboxLimit("min", state, getAttribute(state.host, "min"));
29
+ setListboxMultiple(state.host, state.multiple);
30
+ setListboxReadonly(state, state.readonly);
31
+ setListboxRequired(state, state.required);
32
+ filterListboxOptions(state);
33
+ updateListboxForm(state, state.values.current, false);
34
+ updateListboxMessage(state);
35
+ updateListboxValueLabel(state);
36
+ if (state.options.selected.length > 0) updateListboxPreview("none", state, state.options.selected[0]);
37
+ return state;
38
+ }
39
+ //#endregion
40
+ export { attachListbox, detachListbox, initializeListboxState };
@@ -0,0 +1,6 @@
1
+ import { AnyAriaBooleanAttribute } from "@oscarpalmer/toretto/models";
2
+ //#region src/js/internal/misc.d.ts
3
+ declare function getAttributeValue<Value>(element: HTMLElement, attribute: string, possible: Set<Value>, defaultValue: Value): Value;
4
+ declare function getBooleanAriaValue(element: HTMLElement, attribute: AnyAriaBooleanAttribute): boolean;
5
+ //#endregion
6
+ export { getAttributeValue, getBooleanAriaValue };
@@ -0,0 +1,13 @@
1
+ import { getAria } from "@oscarpalmer/toretto/aria";
2
+ import { getAttribute } from "@oscarpalmer/toretto/attribute";
3
+ //#region src/js/internal/misc.ts
4
+ function getAttributeValue(element, attribute, possible, defaultValue) {
5
+ const value = getAttribute(element, attribute);
6
+ return possible.has(value) ? value : defaultValue;
7
+ }
8
+ function getBooleanAriaValue(element, attribute) {
9
+ const value = getAria(element, attribute);
10
+ return value === true || value === "true";
11
+ }
12
+ //#endregion
13
+ export { getAttributeValue, getBooleanAriaValue };
@@ -0,0 +1,20 @@
1
+ import { GenericCallback } from "@oscarpalmer/atoms/models";
2
+ //#region src/js/l10n.d.ts
3
+ type LocalizationParameters<Localization> = Localization extends GenericCallback ? Parameters<Localization> : never;
4
+ declare class OuiLocalizations<Localizations extends OuiLocalizationsValues> {
5
+ readonly defaults: Localizations;
6
+ readonly keys: Set<keyof Localizations>;
7
+ readonly values: Record<string, Partial<Localizations>>;
8
+ constructor(defaults: Localizations);
9
+ get<Key extends keyof Localizations>(element: Element, key: Key, localizations: Record<string, Partial<Localizations>>): string | GenericCallback;
10
+ set(language: string, localizations: Partial<Localizations>): void;
11
+ set(localizations: Record<string, Partial<Localizations>>): void;
12
+ }
13
+ type OuiLocalizationsValues = Record<string, string | GenericCallback>;
14
+ declare function getLanguage(element: Element): string;
15
+ declare function getLocalization<Localizations extends OuiLocalizationsValues, Key extends keyof Localizations>(localizations: OuiLocalizations<Localizations>, element: Element, key: Key, value: Record<string, Partial<Localizations>>): Localizations[Key] | GenericCallback;
16
+ declare function getLocalizations<Localizations extends OuiLocalizationsValues>(defaults: Localizations): OuiLocalizations<Localizations>;
17
+ declare function localize<Localizations extends OuiLocalizationsValues, Key extends keyof Localizations, Localization extends Localizations[Key]>(localization: Localization, data: Record<string, unknown>, parameters: LocalizationParameters<Localization>): string;
18
+ declare function updateLocalizations<Localizations extends OuiLocalizationsValues>(instance: OuiLocalizations<Localizations>, values: Record<string, Partial<Localizations>>, destination: Record<string, Partial<Localizations>>, onAfter?: () => void): void;
19
+ //#endregion
20
+ export { getLocalizations as a, getLocalization as i, OuiLocalizationsValues as n, localize as o, getLanguage as r, updateLocalizations as s, OuiLocalizations as t };
@@ -0,0 +1,2 @@
1
+ import { a as getLocalizations, i as getLocalization, n as OuiLocalizationsValues, o as localize, r as getLanguage, s as updateLocalizations, t as OuiLocalizations } from "./l10n-Bn-7RcwR.mjs";
2
+ export { OuiLocalizations, OuiLocalizationsValues, getLanguage, getLocalization, getLocalizations, localize, updateLocalizations };
@@ -0,0 +1,80 @@
1
+ import { getString } from "@oscarpalmer/atoms/string";
2
+ //#region src/js/l10n.ts
3
+ var OuiLocalizations = class {
4
+ defaults;
5
+ keys;
6
+ values = {};
7
+ constructor(defaults) {
8
+ this.defaults = defaults;
9
+ this.keys = new Set(Object.keys(defaults));
10
+ }
11
+ get(element, key, localizations) {
12
+ return getLocalization(this, element, key, localizations);
13
+ }
14
+ set(first, second) {
15
+ updateLocalizations(this, typeof first === "string" ? { [first]: second } : first, this.values);
16
+ }
17
+ };
18
+ function getLanguage(element) {
19
+ return (element.closest("[lang]")?.getAttribute("lang") ?? document.documentElement.lang).toLowerCase();
20
+ }
21
+ function getLocalization(localizations, element, key, value) {
22
+ const language = getLanguage(element);
23
+ const values = [value, localizations.values];
24
+ const { length } = values;
25
+ let localization;
26
+ let shortLanguage;
27
+ for (let index = 0; index < length; index += 1) {
28
+ const value = values[index];
29
+ localization = value?.[language]?.[key];
30
+ if (localization != null) break;
31
+ shortLanguage ??= language.split("-")[0];
32
+ if (shortLanguage === language) continue;
33
+ localization = value?.[shortLanguage]?.[key];
34
+ if (localization != null) break;
35
+ }
36
+ return localization ?? localizations.defaults[key];
37
+ }
38
+ function getLocalizations(defaults) {
39
+ return new OuiLocalizations(defaults);
40
+ }
41
+ function localize(localization, data, parameters) {
42
+ if (typeof localization === "function") return localization(...parameters);
43
+ const keys = Object.keys(data);
44
+ const { length } = keys;
45
+ let localized = localization;
46
+ for (let index = 0; index < length; index += 1) {
47
+ const key = keys[index];
48
+ const value = data[key];
49
+ localized = localized.replaceAll(`{${key}}`, getString(value));
50
+ }
51
+ return localized;
52
+ }
53
+ function updateLocalizations(instance, values, destination, onAfter) {
54
+ if (typeof values !== "object" || values == null) return;
55
+ const localizations = destination ?? instance.values;
56
+ const languages = Object.keys(values);
57
+ const languagesLength = languages.length;
58
+ let updated = false;
59
+ for (let languagesIndex = 0; languagesIndex < languagesLength; languagesIndex += 1) {
60
+ const language = languages[languagesIndex];
61
+ const languageValue = values[language];
62
+ if (typeof languageValue !== "object" || languageValue == null) continue;
63
+ const normalizedLanguage = language.toLowerCase();
64
+ localizations[normalizedLanguage] ??= {};
65
+ const keys = Object.keys(languageValue);
66
+ const keysLength = keys.length;
67
+ for (let keysIndex = 0; keysIndex < keysLength; keysIndex += 1) {
68
+ const key = keys[keysIndex];
69
+ const keyValue = languageValue[key];
70
+ const normalizedKey = key.toLowerCase();
71
+ if (instance.keys.has(normalizedKey) && (typeof keyValue === "string" || typeof keyValue === "function")) {
72
+ updated = true;
73
+ localizations[normalizedLanguage][normalizedKey] = keyValue;
74
+ }
75
+ }
76
+ }
77
+ if (updated && typeof onAfter === "function") onAfter();
78
+ }
79
+ //#endregion
80
+ export { OuiLocalizations, getLanguage, getLocalization, getLocalizations, localize, updateLocalizations };
@@ -0,0 +1,2 @@
1
+ import { i as LISTBOX_TAGNAME, n as LISTBOX_MESSAGES, r as LISTBOX_SELECTORS, t as LISTBOX_ATTRIBUTES } from "../constants.listbox-DRsXUxd3.mjs";
2
+ export { LISTBOX_ATTRIBUTES, LISTBOX_MESSAGES, LISTBOX_SELECTORS, LISTBOX_TAGNAME };
@@ -0,0 +1,40 @@
1
+ //#region src/js/listbox/constants.listbox.ts
2
+ const LISTBOX_TAGNAME = "oui-listbox";
3
+ const attributeContent = `${LISTBOX_TAGNAME}-content`;
4
+ const attributeFilter = `${LISTBOX_TAGNAME}-filter`;
5
+ const attributeFilterInput = `${attributeFilter}-input`;
6
+ const attributeGroup = `${LISTBOX_TAGNAME}-group`;
7
+ const attributeHeader = `${LISTBOX_TAGNAME}-header`;
8
+ const attributeHidden = `${LISTBOX_TAGNAME}-hidden`;
9
+ const attributeList = `${LISTBOX_TAGNAME}-list`;
10
+ const attributeListEmpty = `${attributeList}-empty`;
11
+ const attributeMessage = `${LISTBOX_TAGNAME}-message`;
12
+ const attributeOption = `${LISTBOX_TAGNAME}-option`;
13
+ const attributeOptionActive = `${LISTBOX_TAGNAME}-option-active`;
14
+ const messageLabel = `<${LISTBOX_TAGNAME}> must contain a <label> element for the <select> element`;
15
+ const messageSelect = `<${LISTBOX_TAGNAME}> must contain a valid <select> element`;
16
+ const selectorFilter = `[${attributeFilterInput}]`;
17
+ const selectorOption = `[${attributeOption}]`;
18
+ const LISTBOX_ATTRIBUTES = {
19
+ active: attributeOptionActive,
20
+ content: attributeContent,
21
+ empty: attributeListEmpty,
22
+ filter: attributeFilter,
23
+ group: attributeGroup,
24
+ header: attributeHeader,
25
+ hidden: attributeHidden,
26
+ input: attributeFilterInput,
27
+ list: attributeList,
28
+ message: attributeMessage,
29
+ option: attributeOption
30
+ };
31
+ const LISTBOX_MESSAGES = {
32
+ label: messageLabel,
33
+ select: messageSelect
34
+ };
35
+ const LISTBOX_SELECTORS = {
36
+ filter: selectorFilter,
37
+ option: selectorOption
38
+ };
39
+ //#endregion
40
+ export { LISTBOX_ATTRIBUTES, LISTBOX_MESSAGES, LISTBOX_SELECTORS, LISTBOX_TAGNAME };
@@ -0,0 +1,8 @@
1
+ import { c as OuiListboxPreview, l as OuiListboxState } from "../listbox.model-CRReGOmu.mjs";
2
+ //#region src/js/listbox/event.listbox.d.ts
3
+ declare function onListboxEnter(state: OuiListboxState): void;
4
+ declare function onListboxFilter(preview: OuiListboxPreview, state: OuiListboxState, _: boolean, active?: HTMLElement): void;
5
+ declare function onListboxNavigation(preview: OuiListboxPreview, state: OuiListboxState, active?: HTMLElement): void;
6
+ declare function onListboxToggle(state: OuiListboxState): void;
7
+ //#endregion
8
+ export { onListboxEnter, onListboxFilter, onListboxNavigation, onListboxToggle };
@@ -0,0 +1,2 @@
1
+ import { d as onListboxNavigation, f as onListboxToggle, l as onListboxEnter, u as onListboxFilter } from "../misc.listbox-BI-XsTOf.mjs";
2
+ export { onListboxEnter, onListboxFilter, onListboxNavigation, onListboxToggle };
@@ -0,0 +1,116 @@
1
+ import { o as OuiListboxLocalizations } from "../listbox.model-CRReGOmu.mjs";
2
+ import { i as LISTBOX_TAGNAME } from "../constants.listbox-DRsXUxd3.mjs";
3
+ import { n as setListboxLocalizations } from "../misc.listbox-gnoJhrTr.mjs";
4
+ //#region src/js/listbox/index.d.ts
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ [LISTBOX_TAGNAME]: OuiListboxElement;
8
+ }
9
+ }
10
+ declare class OuiListboxElement extends HTMLElement {
11
+ #private;
12
+ static formAssociated: boolean;
13
+ static observedAttributes: string[];
14
+ /**
15
+ * Is the listbox disabled?
16
+ */
17
+ get disabled(): boolean;
18
+ /**
19
+ * Should the listbox be disabled?
20
+ */
21
+ set disabled(value: boolean);
22
+ /**
23
+ * Current filter value
24
+ */
25
+ get filter(): string;
26
+ /**
27
+ * Set the filter value
28
+ */
29
+ set filter(value: string);
30
+ /**
31
+ * Maximum number of selected options
32
+ */
33
+ get max(): number | undefined;
34
+ /**
35
+ * Set the maximum number of selected options
36
+ */
37
+ set max(value: number);
38
+ /**
39
+ * Minimum number of selected options
40
+ */
41
+ get min(): number | undefined;
42
+ /**
43
+ * Set the minimum number of selected options
44
+ */
45
+ set min(value: number);
46
+ /**
47
+ * Does the listbox allow multiple values?
48
+ */
49
+ get multiple(): boolean;
50
+ /**
51
+ * Name of the listbox
52
+ */
53
+ get name(): string;
54
+ /**
55
+ * Is the listbox readonly?
56
+ */
57
+ get readonly(): boolean;
58
+ /**
59
+ * Should the listbox be readonly?
60
+ */
61
+ set readonly(value: boolean);
62
+ /**
63
+ * Is the listbox required?
64
+ */
65
+ get required(): boolean;
66
+ /**
67
+ * Should the listbox be required?
68
+ */
69
+ set required(value: boolean);
70
+ /**
71
+ * Selected options
72
+ */
73
+ get selected(): HTMLElement[];
74
+ /**
75
+ * Current value
76
+ */
77
+ get value(): string;
78
+ /**
79
+ * Set the value
80
+ */
81
+ set value(value: unknown);
82
+ /**
83
+ * Current values
84
+ */
85
+ get values(): string[];
86
+ /**
87
+ * Set the values
88
+ */
89
+ set values(values: unknown[]);
90
+ constructor();
91
+ attributeChangedCallback(name: string, _: string | null, value: string | null): void;
92
+ /**
93
+ * Clear all selected options
94
+ */
95
+ clear(): void;
96
+ connectedCallback(): void;
97
+ disconnectedCallback(): void;
98
+ formDisabledCallback(disabled: boolean): void;
99
+ formResetCallback(): void;
100
+ formStateRestoreCallback(state: string | File | FormData, reason: unknown): void;
101
+ /**
102
+ * Set listbox localizations for a specific language
103
+ *
104
+ * @param language Language code
105
+ * @param localizations Localizations for language
106
+ */
107
+ setLocalizations(language: string, localizations: Partial<OuiListboxLocalizations>): void;
108
+ /**
109
+ * Set listbox localizations for one or more languages
110
+ *
111
+ * @param localizations Localizations for one or more languages
112
+ */
113
+ setLocalizations(localizations: Record<string, Partial<OuiListboxLocalizations>>): void;
114
+ }
115
+ //#endregion
116
+ export { OuiListboxElement, setListboxLocalizations };