@oscarpalmer/oui 0.40.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/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 -2
- package/dist/js/color-picker/color-picker.constants.mjs +5 -3
- package/dist/js/color-picker/color-picker.dom.d.mts +1 -1
- package/dist/js/color-picker/color-picker.dom.mjs +31 -14
- package/dist/js/color-picker/color-picker.event.d.mts +2 -2
- package/dist/js/color-picker/color-picker.event.mjs +232 -1
- package/dist/js/color-picker/color-picker.form.d.mts +1 -1
- package/dist/js/color-picker/color-picker.form.mjs +1 -3
- package/dist/js/color-picker/color-picker.misc.d.mts +2 -2
- package/dist/js/color-picker/color-picker.misc.mjs +104 -2
- package/dist/js/color-picker/color-picker.model.d.mts +2 -2
- package/dist/js/color-picker/color-picker.output.d.mts +1 -1
- package/dist/js/color-picker/color-picker.output.mjs +7 -8
- package/dist/js/color-picker/color-picker.state.d.mts +1 -1
- package/dist/js/color-picker/color-picker.state.mjs +167 -1
- package/dist/js/color-picker/index.d.mts +7 -15
- package/dist/js/color-picker/index.mjs +11 -6
- package/dist/js/{color-picker.constants-D1mxw_Le.d.mts → color-picker.constants-BZgXQr5o.d.mts} +6 -8
- package/dist/js/{color-picker.misc-CtsXGrOe.d.mts → color-picker.misc-BIS3R6jk.d.mts} +8 -4
- package/dist/js/combobox/combobox.constants.d.mts +1 -1
- package/dist/js/combobox/combobox.dom.d.mts +12 -13
- package/dist/js/combobox/combobox.dom.mjs +15 -17
- package/dist/js/combobox/combobox.event.d.mts +8 -8
- package/dist/js/combobox/combobox.event.mjs +1 -1
- package/dist/js/combobox/combobox.misc.d.mts +2 -2
- package/dist/js/combobox/combobox.misc.mjs +2 -2
- package/dist/js/combobox/combobox.model.d.mts +2 -2
- package/dist/js/combobox/combobox.state.d.mts +3 -4
- package/dist/js/combobox/combobox.state.mjs +1 -1
- package/dist/js/combobox/index.d.mts +8 -19
- package/dist/js/combobox/index.mjs +21 -23
- package/dist/js/{combobox.constants-DZVkMP5g.d.mts → combobox.constants-Hb3bqqQJ.d.mts} +3 -3
- package/dist/js/combobox.misc-DRDFk6X8.d.mts +26 -0
- package/dist/js/combobox.model-gjEI2VqZ.d.mts +46 -0
- package/dist/js/{combobox.state-BfJ3Hxg8.mjs → combobox.state-AstCICiH.mjs} +30 -41
- package/dist/js/dialog/dialog.model.d.mts +1 -1
- package/dist/js/dialog/index.d.mts +1 -1
- package/dist/js/{dialog.model-DX2mndMh.d.mts → dialog.model-HVzYWoDo.d.mts} +3 -3
- package/dist/js/floatable/floatable.embedded.d.mts +1 -1
- package/dist/js/floatable/floatable.embedded.mjs +2 -2
- package/dist/js/floatable/floatable.standalone.d.mts +1 -1
- package/dist/js/{floatable.embedded-MeTyXjFn.d.mts → floatable.embedded-ncshL3Sa.d.mts} +3 -3
- package/dist/js/focus-trap/focus-trap.embedded.d.mts +1 -1
- package/dist/js/focus-trap/focus-trap.embedded.mjs +10 -9
- package/dist/js/focus-trap/focus-trap.model.d.mts +1 -1
- package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -2
- package/dist/js/{focus-trap.embedded-DIU05m1z.d.mts → focus-trap.embedded-DpcPkP7c.d.mts} +3 -3
- package/dist/js/{focus-trap.model-BeX6UYlw.d.mts → focus-trap.model-CpltX5B5.d.mts} +1 -1
- package/dist/js/index.d.mts +16 -16
- package/dist/js/index.mjs +3 -3
- package/dist/js/internal/attributable.d.mts +1 -1
- package/dist/js/internal/draggable/draggable.model.d.mts +1 -1
- package/dist/js/internal/draggable/index.d.mts +8 -8
- package/dist/js/internal/draggable/index.mjs +27 -18
- 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/{l10n → internal/l10n}/l10n.model.mjs +5 -2
- package/dist/js/internal/misc.d.mts +2 -2
- package/dist/js/internal/navigable/index.d.mts +3 -3
- package/dist/js/internal/navigable/index.mjs +1 -1
- package/dist/js/internal/navigable/navigable.model.d.mts +1 -1
- 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/{listbox/listbox.event.mjs → option-list/option-list.event.mjs} +7 -7
- package/dist/js/internal/option-list/option-list.form.d.mts +7 -0
- package/dist/js/internal/{listbox/listbox.form.mjs → option-list/option-list.form.mjs} +10 -13
- 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 -9
- package/dist/js/l10n/index.mjs +2 -107
- package/dist/js/l10n.model-D1E1u35L.d.mts +54 -0
- package/dist/js/listbox/index.d.mts +6 -17
- package/dist/js/listbox/index.mjs +22 -23
- package/dist/js/listbox/{constants.listbox.d.mts → listbox.constants.d.mts} +1 -1
- package/dist/js/listbox/{constants.listbox.mjs → listbox.constants.mjs} +1 -1
- 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/{constants.listbox-C5Ap6Ag_.d.mts → listbox.constants-DOBMwKup.d.mts} +3 -3
- 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 +7 -3
- package/dist/js/menu/menu.model.d.mts +7 -7
- package/dist/js/movable/movable.embedded.d.mts +1 -1
- package/dist/js/movable/movable.embedded.mjs +21 -18
- package/dist/js/movable/movable.model.d.mts +1 -1
- package/dist/js/movable/movable.standalone.d.mts +2 -2
- package/dist/js/{movable.embedded-DoyXLegc.d.mts → movable.embedded-C1bDTLGs.d.mts} +2 -2
- package/dist/js/{movable.model-BHaK_mKw.d.mts → movable.model-D9nnPWKk.d.mts} +41 -41
- package/dist/js/{navigable.model-BPOM8DZk.d.mts → navigable.model-BqoR6iBv.d.mts} +1 -1
- package/dist/js/{listbox.data-BQyZGKgr.mjs → option-list.data-CgMyUwPc.mjs} +70 -71
- package/dist/js/option-list.model-CCPUlPeX.d.mts +169 -0
- package/dist/js/popover/index.d.mts +2 -2
- package/dist/js/popover/index.mjs +1 -1
- package/dist/js/popover/popover.model.d.mts +1 -1
- package/dist/js/{popover.model-ubKNG612.d.mts → popover.model-DiLdz0Hc.d.mts} +4 -4
- package/dist/js/resizable/resizable.embedded.d.mts +1 -1
- package/dist/js/resizable/resizable.model.d.mts +1 -1
- package/dist/js/resizable/resizable.standalone.d.mts +2 -2
- package/dist/js/{resizable.embedded-Bf1qBUdt.d.mts → resizable.embedded-BemH-7Re.d.mts} +2 -2
- package/dist/js/{resizable.model-BwzJcTVJ.d.mts → resizable.model-YEtcC9li.d.mts} +3 -3
- package/dist/js/sortable/sortable.embedded.d.mts +1 -1
- package/dist/js/sortable/sortable.embedded.mjs +46 -38
- package/dist/js/sortable/sortable.model.d.mts +1 -1
- package/dist/js/sortable/sortable.standalone.d.mts +2 -2
- package/dist/js/{sortable.embedded-DzBKAwSG.d.mts → sortable.embedded-CrEGff9k.d.mts} +2 -2
- package/dist/js/splitter/index.d.mts +1 -1
- package/dist/js/splitter/splitter.model.d.mts +1 -1
- package/dist/js/{splitter.model-DOLNjLVS.d.mts → splitter.model-C24W6eZ7.d.mts} +2 -2
- package/dist/js/tabs/index.d.mts +2 -2
- package/dist/js/tabs/index.mjs +1 -1
- package/dist/js/tabs/tabs.model.d.mts +1 -1
- package/dist/js/{tabs.model-DRBX_JtI.d.mts → tabs.model-BHPy7fPo.d.mts} +1 -1
- package/dist/js/toolbar/toolbar.model.d.mts +2 -2
- package/dist/js/tooltip/index.d.mts +2 -2
- package/dist/js/tooltip/tooltip.model.d.mts +1 -1
- package/dist/js/{tooltip.model-DRkY_BsL.d.mts → tooltip.model-BpNStw5z.d.mts} +3 -3
- package/package.json +1 -1
- package/dist/js/color-picker.event-Cksj5TvS.mjs +0 -500
- package/dist/js/combobox.misc-C1tPZZDi.d.mts +0 -22
- package/dist/js/combobox.model-oDV06XCN.d.mts +0 -44
- 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.form.d.mts +0 -5
- 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 -39
- package/dist/js/l10n/l10n.model.d.mts +0 -2
- package/dist/js/l10n.model-D6a9frgl.d.mts +0 -26
- package/dist/js/listbox/event.listbox.d.mts +0 -7
- package/dist/js/listbox/event.listbox.mjs +0 -48
- 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 -9
- package/dist/js/listbox/state.listbox.mjs +0 -2
- package/dist/js/listbox.model-CuBOj4qe.d.mts +0 -129
- package/dist/js/misc.listbox-CjfBUbHD.mjs +0 -154
- package/dist/js/misc.listbox-CtoGvXQo.d.mts +0 -20
- /package/dist/js/internal/{listbox/listbox.model.mjs → option-list/option-list.model.mjs} +0 -0
|
@@ -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,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as LISTBOX_TAGNAME, t as LISTBOX_SYMBOL } from "../constants
|
|
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 {
|
|
@@ -37,6 +38,7 @@ export declare class OuiListboxElement extends HTMLElement {
|
|
|
37
38
|
* Label elements associated with the listbox
|
|
38
39
|
*/
|
|
39
40
|
get labels(): NodeList;
|
|
41
|
+
get localizations(): OuiLocalizations<OuiListboxLocalizations>;
|
|
40
42
|
/**
|
|
41
43
|
* Maximum number of selected options
|
|
42
44
|
*/
|
|
@@ -80,7 +82,7 @@ export declare class OuiListboxElement extends HTMLElement {
|
|
|
80
82
|
/**
|
|
81
83
|
* Selected options
|
|
82
84
|
*/
|
|
83
|
-
get selected():
|
|
85
|
+
get selected(): Element[];
|
|
84
86
|
/**
|
|
85
87
|
* Validation message for the listbox
|
|
86
88
|
*/
|
|
@@ -138,19 +140,6 @@ export declare class OuiListboxElement extends HTMLElement {
|
|
|
138
140
|
* @param message Validation message
|
|
139
141
|
*/
|
|
140
142
|
setCustomValidity(message: string): void;
|
|
141
|
-
/**
|
|
142
|
-
* Set listbox localizations for a specific language
|
|
143
|
-
*
|
|
144
|
-
* @param language Language code
|
|
145
|
-
* @param localizations Localizations for language
|
|
146
|
-
*/
|
|
147
|
-
setLocalizations(language: string, localizations: Partial<OuiListboxLocalizations>): void;
|
|
148
|
-
/**
|
|
149
|
-
* Set listbox localizations for one or more languages
|
|
150
|
-
*
|
|
151
|
-
* @param localizations Localizations for one or more languages
|
|
152
|
-
*/
|
|
153
|
-
setLocalizations(localizations: Record<string, Partial<OuiListboxLocalizations>>): void;
|
|
154
143
|
}
|
|
155
144
|
//#endregion
|
|
156
145
|
export { setListboxLocalizations };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import {
|
|
3
|
-
import { LISTBOX_SYMBOL, 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
|
|
@@ -23,7 +23,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
23
23
|
* Should the listbox be disabled?
|
|
24
24
|
*/
|
|
25
25
|
set disabled(value) {
|
|
26
|
-
if (typeof value === "boolean" && value !== this.disabled)
|
|
26
|
+
if (typeof value === "boolean" && value !== this.disabled) setOptionListDisabled(this[LISTBOX_SYMBOL], value);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Current filter value
|
|
@@ -35,7 +35,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
35
35
|
* Set the filter value
|
|
36
36
|
*/
|
|
37
37
|
set filter(value) {
|
|
38
|
-
|
|
38
|
+
setOptionListFilter(this[LISTBOX_SYMBOL], value);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Form element associated with the listbox
|
|
@@ -49,6 +49,9 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
49
49
|
get labels() {
|
|
50
50
|
return this[LISTBOX_SYMBOL].form.internals.labels;
|
|
51
51
|
}
|
|
52
|
+
get localizations() {
|
|
53
|
+
return this[LISTBOX_SYMBOL].component?.localizations;
|
|
54
|
+
}
|
|
52
55
|
/**
|
|
53
56
|
* Maximum number of selected options
|
|
54
57
|
*/
|
|
@@ -59,7 +62,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
59
62
|
* Set the maximum number of selected options
|
|
60
63
|
*/
|
|
61
64
|
set max(value) {
|
|
62
|
-
|
|
65
|
+
setOptionListLimit("max", this[LISTBOX_SYMBOL], value);
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
68
|
* Minimum number of selected options
|
|
@@ -71,7 +74,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
71
74
|
* Set the minimum number of selected options
|
|
72
75
|
*/
|
|
73
76
|
set min(value) {
|
|
74
|
-
|
|
77
|
+
setOptionListLimit("min", this[LISTBOX_SYMBOL], value);
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
77
80
|
* Does the listbox allow multiple values?
|
|
@@ -95,7 +98,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
95
98
|
* Should the listbox be readonly?
|
|
96
99
|
*/
|
|
97
100
|
set readonly(value) {
|
|
98
|
-
if (typeof value === "boolean" && value !== this.readonly)
|
|
101
|
+
if (typeof value === "boolean" && value !== this.readonly) setOptionListReadonly(this[LISTBOX_SYMBOL], value);
|
|
99
102
|
}
|
|
100
103
|
/**
|
|
101
104
|
* Is the listbox required?
|
|
@@ -107,7 +110,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
107
110
|
* Should the listbox be required?
|
|
108
111
|
*/
|
|
109
112
|
set required(value) {
|
|
110
|
-
if (typeof value === "boolean" && value !== this.required)
|
|
113
|
+
if (typeof value === "boolean" && value !== this.required) setOptionListRequired(this[LISTBOX_SYMBOL], value);
|
|
111
114
|
}
|
|
112
115
|
/**
|
|
113
116
|
* Selected options
|
|
@@ -137,7 +140,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
137
140
|
* Set the value
|
|
138
141
|
*/
|
|
139
142
|
set value(value) {
|
|
140
|
-
|
|
143
|
+
setOptionListValue(this[LISTBOX_SYMBOL], value);
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
143
146
|
* Current values
|
|
@@ -149,7 +152,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
149
152
|
* Set the values
|
|
150
153
|
*/
|
|
151
154
|
set values(values) {
|
|
152
|
-
|
|
155
|
+
setOptionListValues(this[LISTBOX_SYMBOL], values);
|
|
153
156
|
}
|
|
154
157
|
/**
|
|
155
158
|
* Can the listbox be validated?
|
|
@@ -160,7 +163,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
160
163
|
constructor() {
|
|
161
164
|
super();
|
|
162
165
|
this[LISTBOX_SYMBOL] = {
|
|
163
|
-
component:
|
|
166
|
+
component: void 0,
|
|
164
167
|
form: { internals: this.attachInternals() }
|
|
165
168
|
};
|
|
166
169
|
}
|
|
@@ -173,7 +176,7 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
173
176
|
break;
|
|
174
177
|
case "max":
|
|
175
178
|
case "min":
|
|
176
|
-
|
|
179
|
+
setOptionListLimit(name, state, value);
|
|
177
180
|
break;
|
|
178
181
|
case "value": this.value = value ?? "";
|
|
179
182
|
}
|
|
@@ -190,30 +193,30 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
190
193
|
* Clear all selected options
|
|
191
194
|
*/
|
|
192
195
|
clear() {
|
|
193
|
-
|
|
196
|
+
setOptionListValues(this[LISTBOX_SYMBOL], []);
|
|
194
197
|
}
|
|
195
198
|
connectedCallback() {
|
|
196
199
|
const state = this[LISTBOX_SYMBOL];
|
|
197
200
|
if (state.component == null) initializeListbox(this, state);
|
|
198
|
-
else
|
|
201
|
+
else attachOptionList(state, listboxes, onAttachListbox);
|
|
199
202
|
}
|
|
200
203
|
disconnectedCallback() {
|
|
201
204
|
const state = this[LISTBOX_SYMBOL];
|
|
202
|
-
if (state.component != null)
|
|
205
|
+
if (state.component != null) detachOptionList(state, listboxes, onDetachListbox);
|
|
203
206
|
}
|
|
204
207
|
formDisabledCallback(disabled) {
|
|
205
208
|
this.disabled = disabled;
|
|
206
209
|
}
|
|
207
210
|
formResetCallback() {
|
|
208
211
|
const state = this[LISTBOX_SYMBOL];
|
|
209
|
-
|
|
212
|
+
setOptionListValues(state, state.component.values.initial);
|
|
210
213
|
}
|
|
211
214
|
formStateRestoreCallback(state, reason) {
|
|
212
215
|
if (reason !== "restore") return;
|
|
213
216
|
const parsed = typeof state === "string" ? parse(state) : void 0;
|
|
214
217
|
if (!Array.isArray(parsed)) return;
|
|
215
218
|
if (this[LISTBOX_SYMBOL]?.component == null) this[LISTBOX_SYMBOL].form.restored = parsed;
|
|
216
|
-
else
|
|
219
|
+
else setOptionListValues(this[LISTBOX_SYMBOL], parsed);
|
|
217
220
|
}
|
|
218
221
|
/**
|
|
219
222
|
* Check if the listbox is valid and report any validation errors
|
|
@@ -231,10 +234,6 @@ var OuiListboxElement = class extends HTMLElement {
|
|
|
231
234
|
setCustomValidity(message) {
|
|
232
235
|
this[LISTBOX_SYMBOL].form.internals.setValidity({ customError: message !== "" }, message, this);
|
|
233
236
|
}
|
|
234
|
-
setLocalizations(first, second) {
|
|
235
|
-
const { localizations } = this[LISTBOX_SYMBOL].component;
|
|
236
|
-
updateListboxLocalizations(localizations.global, localizations.component, first, second);
|
|
237
|
-
}
|
|
238
237
|
};
|
|
239
238
|
customElements.define(LISTBOX_TAGNAME, OuiListboxElement);
|
|
240
239
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as listboxSelectors, i as listboxMessages, n as LISTBOX_TAGNAME, r as listboxAttributes, t as LISTBOX_SYMBOL } from "../constants
|
|
1
|
+
import { a as listboxSelectors, i as listboxMessages, n as LISTBOX_TAGNAME, r as listboxAttributes, t as LISTBOX_SYMBOL } from "../listbox.constants-DOBMwKup.mjs";
|
|
2
2
|
export { LISTBOX_SYMBOL, LISTBOX_TAGNAME, listboxAttributes, listboxMessages, listboxSelectors };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { r as OuiListboxState, t as OuiListboxFooter } from "../listbox.model-C0MYWXZe.mjs";
|
|
2
|
+
//#region src/js/listbox/listbox.dom.d.ts
|
|
3
|
+
export declare function createListboxFooter(): OuiListboxFooter;
|
|
4
|
+
export declare function updateListboxFooter(state: OuiListboxState): void;
|
|
5
|
+
//#endregion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { h as OptionListPreview } from "../option-list.model-CCPUlPeX.mjs";
|
|
2
|
+
import { r as OuiListboxState } from "../listbox.model-C0MYWXZe.mjs";
|
|
3
|
+
//#region src/js/listbox/listbox.event.d.ts
|
|
4
|
+
export declare function onListboxApply(state: OuiListboxState): void;
|
|
5
|
+
export declare function onListboxEnter(state: OuiListboxState): void;
|
|
6
|
+
export declare function onListboxFilter(preview: OptionListPreview, state: OuiListboxState, _: boolean, active?: Element): void;
|
|
7
|
+
export declare function onListboxNavigation(preview: OptionListPreview, state: OuiListboxState, active?: HTMLElement): void;
|
|
8
|
+
export declare function onListboxToggle(state: OuiListboxState): void;
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { u as OuiDefaultLocalizations } from "../l10n.model-D1E1u35L.mjs";
|
|
2
|
+
import { n as OuiListboxLocalizations, r as OuiListboxState } from "../listbox.model-C0MYWXZe.mjs";
|
|
3
|
+
//#region src/js/listbox/listbox.state.d.ts
|
|
4
|
+
export declare function initializeListbox(element: Element, state: OuiListboxState): void;
|
|
5
|
+
export declare function onAttachListbox(state: OuiListboxState): void;
|
|
6
|
+
export declare function onDetachListbox(state: OuiListboxState): void;
|
|
7
|
+
export declare const listboxLocalizations: OuiDefaultLocalizations<OuiListboxLocalizations>;
|
|
8
|
+
export declare const listboxes: Set<OuiListboxState>;
|
|
9
|
+
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/js/listbox/constants.
|
|
1
|
+
import { c as OptionListAttributes } from "./option-list.model-CCPUlPeX.mjs";
|
|
2
|
+
//#region src/js/listbox/listbox.constants.d.ts
|
|
3
3
|
declare const LISTBOX_TAGNAME = "oui-listbox";
|
|
4
4
|
declare const LISTBOX_SYMBOL: unique symbol;
|
|
5
|
-
declare const listboxAttributes:
|
|
5
|
+
declare const listboxAttributes: OptionListAttributes;
|
|
6
6
|
declare const listboxMessages: Record<string, string>;
|
|
7
7
|
declare const listboxSelectors: Record<string, string>;
|
|
8
8
|
//#endregion
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { p as OptionListLocalizationValues } from "./option-list.model-CCPUlPeX.mjs";
|
|
2
|
+
//#region src/js/listbox/listbox.misc.d.ts
|
|
3
|
+
declare function getListboxId(): string;
|
|
4
|
+
/**
|
|
5
|
+
* Set listbox localizations for a specific language
|
|
6
|
+
*
|
|
7
|
+
* @param language Language code
|
|
8
|
+
* @param localizations Localizations for language
|
|
9
|
+
*/
|
|
10
|
+
declare function setListboxLocalizations(language: string, localizations: Partial<OptionListLocalizationValues>): void;
|
|
11
|
+
/**
|
|
12
|
+
* Set default listbox localizations
|
|
13
|
+
*
|
|
14
|
+
* @param localizations Default localizations
|
|
15
|
+
*/
|
|
16
|
+
declare function setListboxLocalizations(localizations: Partial<OptionListLocalizationValues>, defaults: true): void;
|
|
17
|
+
/**
|
|
18
|
+
* Set listbox localizations for one or more languages
|
|
19
|
+
*
|
|
20
|
+
* @param localizations Localizations for one or more languages
|
|
21
|
+
*/
|
|
22
|
+
declare function setListboxLocalizations(localizations: Record<string, Partial<OptionListLocalizationValues>>): void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { setListboxLocalizations as n, getListboxId as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { g as OptionListState, p as OptionListLocalizationValues } from "./option-list.model-CCPUlPeX.mjs";
|
|
2
|
+
//#region src/js/listbox/listbox.model.d.ts
|
|
3
|
+
type OuiListboxFooter = {
|
|
4
|
+
button: OuiListboxFooterButton;
|
|
5
|
+
container: Element;
|
|
6
|
+
};
|
|
7
|
+
type OuiListboxFooterButton = {
|
|
8
|
+
clear: HTMLButtonElement;
|
|
9
|
+
select: HTMLButtonElement;
|
|
10
|
+
};
|
|
11
|
+
type OuiListboxLocalizations = {
|
|
12
|
+
clearSelection: string | (() => string);
|
|
13
|
+
selectAll: string | (() => string);
|
|
14
|
+
} & OptionListLocalizationValues;
|
|
15
|
+
type OuiListboxState = OptionListState<OuiListboxStateExtras, OuiListboxLocalizations>;
|
|
16
|
+
type OuiListboxStateExtras = {
|
|
17
|
+
footer: OuiListboxFooter;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { OuiListboxStateExtras as i, OuiListboxLocalizations as n, OuiListboxState as r, OuiListboxFooter as t };
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { createDefaultLocalizations, createLocalizations } from "./internal/l10n/index.mjs";
|
|
2
|
+
import { getBooleanAriaValue } from "./internal/misc.mjs";
|
|
3
|
+
import { c as createOptionListContent, n as filterOptionList, o as setOptionListValues, s as toggleOptionListOption, t as applyOptionListSelection, x as generateOptionListIds, y as updateOptionListPreview } from "./option-list.data-CgMyUwPc.mjs";
|
|
4
|
+
import { initializeOptionListState } from "./internal/option-list/option-list.state.mjs";
|
|
5
|
+
import { processOptionListKeydown } from "./internal/option-list/option-list.event.mjs";
|
|
6
|
+
import { LISTBOX_SYMBOL, LISTBOX_TAGNAME, listboxAttributes, listboxMessages, listboxSelectors } from "./listbox/listbox.constants.mjs";
|
|
7
|
+
import { getAria, setAria } from "@oscarpalmer/toretto/aria";
|
|
8
|
+
import { setAttributes } from "@oscarpalmer/toretto/attribute";
|
|
9
|
+
import { on } from "@oscarpalmer/toretto/event";
|
|
10
|
+
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
11
|
+
import { noop } from "@oscarpalmer/atoms/function";
|
|
12
|
+
import { createElement } from "@oscarpalmer/toretto/create";
|
|
13
|
+
import { getData } from "@oscarpalmer/toretto/data";
|
|
14
|
+
//#region src/js/listbox/listbox.dom.ts
|
|
15
|
+
function createListboxFooter() {
|
|
16
|
+
const container = createElement("div", { attribute: { [`${LISTBOX_TAGNAME}-footer`]: "" } });
|
|
17
|
+
const clear = createElement("button", {
|
|
18
|
+
attribute: { [`${LISTBOX_TAGNAME}-footer-button`]: "" },
|
|
19
|
+
property: { textContent: listboxLocalizations.localize("clearSelection") }
|
|
20
|
+
});
|
|
21
|
+
const select = createElement("button", {
|
|
22
|
+
attribute: { [`${LISTBOX_TAGNAME}-footer-button`]: "" },
|
|
23
|
+
property: { textContent: listboxLocalizations.localize("selectAll") }
|
|
24
|
+
});
|
|
25
|
+
container.append(select, clear);
|
|
26
|
+
return {
|
|
27
|
+
container,
|
|
28
|
+
button: {
|
|
29
|
+
clear,
|
|
30
|
+
select
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function updateListboxFooter(state) {
|
|
35
|
+
const { disabled, footer, options, readonly } = state.component;
|
|
36
|
+
setAria(footer.button.clear, "disabled", disabled || readonly || options.selected.length === 0);
|
|
37
|
+
setAria(footer.button.select, "disabled", disabled || readonly || options.selected.length === options.all.length);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/js/listbox/listbox.event.ts
|
|
41
|
+
function onListboxApply(state) {
|
|
42
|
+
updateListboxFooter(state);
|
|
43
|
+
}
|
|
44
|
+
function onListboxClick(event) {
|
|
45
|
+
const listbox = findAncestor(event, LISTBOX_TAGNAME);
|
|
46
|
+
const state = listbox?.[LISTBOX_SYMBOL];
|
|
47
|
+
if (listbox == null || state == null) return;
|
|
48
|
+
const button = findAncestor(event, `[${LISTBOX_TAGNAME}-footer-button]`);
|
|
49
|
+
if (button instanceof HTMLElement) {
|
|
50
|
+
onListboxSelection(state, button);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const option = findAncestor(event, listboxSelectors.option);
|
|
54
|
+
if (!(option instanceof HTMLElement)) return;
|
|
55
|
+
const { disabled, filter, readonly } = state.component;
|
|
56
|
+
if (disabled) filter.element.focus();
|
|
57
|
+
else if (readonly) updateOptionListPreview("none", state, option, false);
|
|
58
|
+
else toggleOptionListOption(state, option);
|
|
59
|
+
}
|
|
60
|
+
function onListboxEnter(state) {
|
|
61
|
+
if (!state.component.disabled && !state.component.readonly) toggleOptionListOption(state, state.component.active);
|
|
62
|
+
}
|
|
63
|
+
function onListboxFilter(preview, state, _, active) {
|
|
64
|
+
updateOptionListPreview(preview, state, active);
|
|
65
|
+
}
|
|
66
|
+
function onListboxInput(event) {
|
|
67
|
+
const state = findAncestor(event, LISTBOX_TAGNAME)?.[LISTBOX_SYMBOL];
|
|
68
|
+
if (state?.component.filter.element === event.target) filterOptionList(event.inputType, state);
|
|
69
|
+
}
|
|
70
|
+
function onListboxKeydown(event) {
|
|
71
|
+
const state = findAncestor(event, LISTBOX_TAGNAME)?.[LISTBOX_SYMBOL];
|
|
72
|
+
if (state?.component.filter.element === event.target) processOptionListKeydown(event, state);
|
|
73
|
+
}
|
|
74
|
+
function onListboxNavigation(preview, state, active) {
|
|
75
|
+
if (state.component.multiple || state.component.readonly) updateOptionListPreview(preview, state, active);
|
|
76
|
+
else applyOptionListSelection({
|
|
77
|
+
state,
|
|
78
|
+
option: active,
|
|
79
|
+
added: true,
|
|
80
|
+
selected: active == null ? [] : [active]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function onListboxSelection(state, button) {
|
|
84
|
+
if (getAria(button, "disabled") || state.component.options.all.length === 0) return;
|
|
85
|
+
const clear = button === state.component.footer.button.clear;
|
|
86
|
+
const select = button === state.component.footer.button.select;
|
|
87
|
+
if (clear || select) applyOptionListSelection({
|
|
88
|
+
state,
|
|
89
|
+
option: state.component.options.all[0],
|
|
90
|
+
added: false,
|
|
91
|
+
selected: clear ? [] : state.component.options.all
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function onListboxToggle(state) {
|
|
95
|
+
state.component.filter.element.focus();
|
|
96
|
+
}
|
|
97
|
+
on(document, "click", onListboxClick);
|
|
98
|
+
on(document, "input", onListboxInput);
|
|
99
|
+
on(document, "keydown", onListboxKeydown, { passive: false });
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/js/listbox/listbox.misc.ts
|
|
102
|
+
function getListboxId() {
|
|
103
|
+
index += 1;
|
|
104
|
+
return `oui_listbox_${index}`;
|
|
105
|
+
}
|
|
106
|
+
function setListboxLocalizations(first, second) {
|
|
107
|
+
if (second === true) listboxLocalizations.setDefaults(first);
|
|
108
|
+
else listboxLocalizations.setLanguages(first, second);
|
|
109
|
+
}
|
|
110
|
+
let index = 0;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/js/listbox/listbox.state.ts
|
|
113
|
+
function createComponentState(element, state) {
|
|
114
|
+
const select = element.querySelector("select");
|
|
115
|
+
if (!(select instanceof HTMLSelectElement)) throw new Error(listboxMessages.select);
|
|
116
|
+
const label = element.querySelector(`label[for="${select.id}"]`);
|
|
117
|
+
if (!(label instanceof HTMLLabelElement)) throw new Error(listboxMessages.label);
|
|
118
|
+
element.id = select.id;
|
|
119
|
+
const disabled = getBooleanAriaValue(element, "disabled") || select.disabled;
|
|
120
|
+
const multiple = element.multiple || select.multiple;
|
|
121
|
+
const readonly = getBooleanAriaValue(element, "readonly");
|
|
122
|
+
const required = getBooleanAriaValue(element, "required") || select.required;
|
|
123
|
+
setAttributes(element, {
|
|
124
|
+
autocomplete: "none",
|
|
125
|
+
name: select.name === "" ? select.id : select.name
|
|
126
|
+
});
|
|
127
|
+
const id = getListboxId();
|
|
128
|
+
const labelId = label.id;
|
|
129
|
+
label.htmlFor = id;
|
|
130
|
+
label.id = `${id}_label`;
|
|
131
|
+
generateOptionListIds(id, select);
|
|
132
|
+
const type = "select";
|
|
133
|
+
const content = createOptionListContent({
|
|
134
|
+
element,
|
|
135
|
+
id,
|
|
136
|
+
label,
|
|
137
|
+
multiple,
|
|
138
|
+
select,
|
|
139
|
+
type,
|
|
140
|
+
attributes: listboxAttributes,
|
|
141
|
+
autocomplete: listboxAutoComplete,
|
|
142
|
+
listbox: true
|
|
143
|
+
});
|
|
144
|
+
const footer = createListboxFooter();
|
|
145
|
+
content.element.append(footer.container);
|
|
146
|
+
const { selected } = content.list.options;
|
|
147
|
+
const values = selected.length === 0 ? [""] : selected.map((option) => getData(option, "value", false) ?? "");
|
|
148
|
+
state.component = {
|
|
149
|
+
disabled,
|
|
150
|
+
footer,
|
|
151
|
+
id,
|
|
152
|
+
multiple,
|
|
153
|
+
readonly,
|
|
154
|
+
required,
|
|
155
|
+
select,
|
|
156
|
+
type,
|
|
157
|
+
active: selected[0],
|
|
158
|
+
attributes: listboxAttributes,
|
|
159
|
+
autocomplete: listboxAutoComplete,
|
|
160
|
+
callbacks: listboxCallbacks,
|
|
161
|
+
content: content.element,
|
|
162
|
+
elements: [element, content.filter.element],
|
|
163
|
+
filter: {
|
|
164
|
+
element: content.filter.element,
|
|
165
|
+
value: ""
|
|
166
|
+
},
|
|
167
|
+
host: element,
|
|
168
|
+
label: {
|
|
169
|
+
id: labelId,
|
|
170
|
+
element: label
|
|
171
|
+
},
|
|
172
|
+
list: content.list.element,
|
|
173
|
+
listeners: [],
|
|
174
|
+
listbox: true,
|
|
175
|
+
localizations: createLocalizations(listboxLocalizations),
|
|
176
|
+
message: content.message,
|
|
177
|
+
name: element.name,
|
|
178
|
+
options: content.list.options,
|
|
179
|
+
values: {
|
|
180
|
+
current: values.slice(),
|
|
181
|
+
initial: values.slice(),
|
|
182
|
+
label: content.value
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
return initializeOptionListState(state, listboxes, onAttachListbox);
|
|
186
|
+
}
|
|
187
|
+
function initializeListbox(element, state) {
|
|
188
|
+
createComponentState(element, state);
|
|
189
|
+
if (state.form.restored != null) {
|
|
190
|
+
setOptionListValues(state, state.form.restored);
|
|
191
|
+
state.form.restored = void 0;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function onAttachListbox(state) {
|
|
195
|
+
const { content, select } = state.component;
|
|
196
|
+
select.hidden = true;
|
|
197
|
+
select.insertAdjacentElement("afterend", content);
|
|
198
|
+
select.remove();
|
|
199
|
+
}
|
|
200
|
+
function onDetachListbox(state) {
|
|
201
|
+
const { content, select } = state.component;
|
|
202
|
+
content.insertAdjacentElement("beforebegin", select);
|
|
203
|
+
content.remove();
|
|
204
|
+
select.hidden = false;
|
|
205
|
+
}
|
|
206
|
+
const listboxAutoComplete = {
|
|
207
|
+
both: false,
|
|
208
|
+
inline: false,
|
|
209
|
+
list: false,
|
|
210
|
+
none: true
|
|
211
|
+
};
|
|
212
|
+
const listboxCallbacks = {
|
|
213
|
+
data: {
|
|
214
|
+
onApply: onListboxApply,
|
|
215
|
+
onFilter: onListboxFilter,
|
|
216
|
+
onForm: noop,
|
|
217
|
+
onPreview: noop,
|
|
218
|
+
onToggle: onListboxToggle
|
|
219
|
+
},
|
|
220
|
+
keydown: {
|
|
221
|
+
onEnter: onListboxEnter,
|
|
222
|
+
onNavigation: onListboxNavigation,
|
|
223
|
+
onToggle: onListboxToggle
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const listboxLocalizations = createDefaultLocalizations({
|
|
227
|
+
clearSelection: "Clear",
|
|
228
|
+
empty: "No results found",
|
|
229
|
+
input: "",
|
|
230
|
+
invalid: "Please select an option from the list",
|
|
231
|
+
max: (max) => `Please select fewer options (maximum is ${max})`,
|
|
232
|
+
min: (min) => `Please select more options (minimum is ${min})`,
|
|
233
|
+
remove: "",
|
|
234
|
+
results: (amount) => `${amount} results available`,
|
|
235
|
+
selectAll: "Select all",
|
|
236
|
+
selected: (amount) => `${amount} selected`
|
|
237
|
+
});
|
|
238
|
+
const listboxes = /* @__PURE__ */ new Set();
|
|
239
|
+
//#endregion
|
|
240
|
+
export { onDetachListbox as a, onListboxApply as c, onListboxNavigation as d, onListboxToggle as f, onAttachListbox as i, onListboxEnter as l, updateListboxFooter as m, listboxLocalizations as n, getListboxId as o, createListboxFooter as p, listboxes as r, setListboxLocalizations as s, initializeListbox as t, onListboxFilter as u };
|
package/dist/js/menu/index.mjs
CHANGED
|
@@ -23,8 +23,12 @@ function OuiMenu(element, navigable) {
|
|
|
23
23
|
event.stopPropagation();
|
|
24
24
|
if (findAncestor(event, MENU_SELECTOR_TOGGLE) != null) return;
|
|
25
25
|
const elements = document.querySelectorAll(MENU_SELECTOR_CONTENT);
|
|
26
|
-
|
|
27
|
-
const
|
|
26
|
+
let firstElement;
|
|
27
|
+
for (const element of elements) {
|
|
28
|
+
firstElement ??= element;
|
|
29
|
+
menus.get(element)?.floatable.hide();
|
|
30
|
+
}
|
|
31
|
+
const menu = firstElement == null ? void 0 : menus.get(firstElement);
|
|
28
32
|
if (menu != null && event.pointerId === -1) updateNavigableFocus(menu.navigable, true);
|
|
29
33
|
}), on(this.content, "toggle", (event) => {
|
|
30
34
|
const expanded = event.newState === "open";
|
|
@@ -116,7 +120,7 @@ function onDeactivate(_, navigable) {
|
|
|
116
120
|
const menu = menus.get(navigable[NAVIGABLE_SYMBOL].element);
|
|
117
121
|
if (menu == null) return;
|
|
118
122
|
menu.floatable.hide();
|
|
119
|
-
const element = findAncestor(menu.element.parentElement, MENU_MENUBAR_SELECTORS);
|
|
123
|
+
const element = menu.element.parentElement == null ? void 0 : findAncestor(menu.element.parentElement, MENU_MENUBAR_SELECTORS);
|
|
120
124
|
if (element == null) return;
|
|
121
125
|
const instance = menubars.get(element) ?? menus.get(element);
|
|
122
126
|
if (instance != null) updateNavigableFocus(instance.navigable, true);
|