@oscarpalmer/oui 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/css/badge.css +11 -8
- package/dist/css/button.css +106 -14
- package/dist/css/color-picker.css +555 -73
- package/dist/css/color.css +86 -86
- package/dist/css/combobox.css +98 -4
- package/dist/css/content.css +7 -6
- package/dist/css/floatable.css +1 -3
- package/dist/css/form.css +99 -6
- package/dist/css/icon.css +99 -0
- package/dist/css/listbox.css +3 -0
- package/dist/css/message.css +4 -3
- package/dist/css/mixins/button.mixins.css +1 -0
- package/dist/css/reset.css +1 -1
- package/dist/css/tabs.css +95 -3
- package/dist/css/typography.css +90 -0
- package/dist/js/color-picker/color-picker.constants.d.mts +2 -0
- package/dist/js/color-picker/color-picker.constants.mjs +60 -0
- package/dist/js/color-picker/color-picker.dom.d.mts +8 -0
- package/dist/js/color-picker/color-picker.dom.mjs +191 -0
- package/dist/js/color-picker/color-picker.event.d.mts +9 -0
- package/dist/js/color-picker/color-picker.event.mjs +2 -0
- package/dist/js/color-picker/color-picker.form.d.mts +5 -0
- package/dist/js/color-picker/color-picker.form.mjs +27 -0
- package/dist/js/color-picker/color-picker.misc.d.mts +2 -0
- package/dist/js/color-picker/color-picker.misc.mjs +2 -0
- package/dist/js/color-picker/color-picker.model.d.mts +2 -0
- package/dist/js/color-picker/color-picker.model.mjs +24 -0
- package/dist/js/color-picker/color-picker.output.d.mts +8 -0
- package/dist/js/color-picker/color-picker.output.mjs +235 -0
- package/dist/js/color-picker/color-picker.state.d.mts +8 -0
- package/dist/js/color-picker/color-picker.state.mjs +2 -0
- package/dist/js/{color-picker.d.mts → color-picker/index.d.mts} +10 -43
- package/dist/js/color-picker/index.mjs +305 -0
- package/dist/js/color-picker.constants-D1mxw_Le.d.mts +179 -0
- package/dist/js/color-picker.event-Cksj5TvS.mjs +500 -0
- package/dist/js/color-picker.misc-CtsXGrOe.d.mts +27 -0
- package/dist/js/combobox/combobox.constants.d.mts +2 -0
- package/dist/js/combobox/{constants.combobox.mjs → combobox.constants.mjs} +21 -21
- package/dist/js/combobox/combobox.dom.d.mts +26 -0
- package/dist/js/combobox/{dom.combobox.mjs → combobox.dom.mjs} +44 -37
- package/dist/js/combobox/combobox.event.d.mts +22 -0
- package/dist/js/combobox/{event.combobox.mjs → combobox.event.mjs} +1 -1
- package/dist/js/combobox/combobox.misc.d.mts +2 -0
- package/dist/js/combobox/{misc.combobox.mjs → combobox.misc.mjs} +1 -1
- package/dist/js/combobox/combobox.model.d.mts +2 -0
- package/dist/js/combobox/combobox.state.d.mts +10 -0
- package/dist/js/combobox/combobox.state.mjs +2 -0
- package/dist/js/combobox/index.d.mts +163 -2
- package/dist/js/combobox/index.mjs +53 -52
- package/dist/js/combobox.constants-DZVkMP5g.d.mts +19 -0
- package/dist/js/combobox.misc-C1tPZZDi.d.mts +22 -0
- package/dist/js/{combobox/models.combobox.d.mts → combobox.model-oDV06XCN.d.mts} +6 -6
- package/dist/js/{state.combobox-Qm3FWzYW.mjs → combobox.state-BfJ3Hxg8.mjs} +96 -82
- package/dist/js/constants.listbox-C5Ap6Ag_.d.mts +9 -0
- package/dist/js/dialog/dialog.model.d.mts +2 -0
- package/dist/js/dialog/dialog.model.mjs +11 -0
- package/dist/js/dialog/index.d.mts +12 -0
- package/dist/js/dialog/index.mjs +123 -0
- package/dist/js/dialog.model-DX2mndMh.d.mts +45 -0
- package/dist/js/floatable/floatable.embedded.d.mts +2 -2
- package/dist/js/floatable/floatable.embedded.mjs +64 -92
- package/dist/js/floatable/floatable.model.d.mts +2 -0
- package/dist/js/floatable/floatable.model.mjs +23 -0
- package/dist/js/floatable/floatable.standalone.d.mts +2 -1
- package/dist/js/floatable.embedded-MeTyXjFn.d.mts +17 -0
- package/dist/js/floatable.model-DXsQgoU7.d.mts +62 -0
- package/dist/js/focus-trap/focus-trap.embedded.d.mts +2 -2
- package/dist/js/focus-trap/focus-trap.embedded.mjs +112 -134
- package/dist/js/focus-trap/focus-trap.model.d.mts +2 -0
- package/dist/js/focus-trap/focus-trap.model.mjs +15 -0
- package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -1
- package/dist/js/focus-trap.embedded-DIU05m1z.d.mts +13 -0
- package/dist/js/{focus-trap.embedded-DR8NpZfr.d.mts → focus-trap.model-BeX6UYlw.d.mts} +16 -18
- package/dist/js/index.d.mts +26 -14
- package/dist/js/index.mjs +18 -15
- package/dist/js/internal/attributable.d.mts +2 -3
- package/dist/js/internal/attributable.mjs +3 -2
- package/dist/js/internal/draggable/draggable.model.d.mts +2 -0
- package/dist/js/internal/draggable/draggable.model.mjs +37 -0
- package/dist/js/internal/draggable/index.d.mts +13 -0
- package/dist/js/internal/{draggable.mjs → draggable/index.mjs} +83 -114
- package/dist/js/internal/listbox/listbox.constants.d.mts +7 -10
- package/dist/js/internal/listbox/listbox.constants.mjs +15 -16
- package/dist/js/internal/listbox/listbox.data.d.mts +9 -10
- package/dist/js/internal/listbox/listbox.data.mjs +1 -1
- package/dist/js/internal/listbox/listbox.dom.d.mts +19 -20
- package/dist/js/internal/listbox/listbox.dom.mjs +1 -1
- package/dist/js/internal/listbox/listbox.event.d.mts +3 -4
- package/dist/js/internal/listbox/listbox.event.mjs +23 -20
- package/dist/js/internal/listbox/listbox.form.d.mts +4 -5
- package/dist/js/internal/listbox/listbox.form.mjs +15 -12
- package/dist/js/internal/listbox/listbox.misc.d.mts +10 -11
- package/dist/js/internal/listbox/listbox.misc.mjs +1 -1
- package/dist/js/internal/listbox/listbox.model.d.mts +2 -2
- package/dist/js/internal/listbox/listbox.state.d.mts +5 -6
- package/dist/js/internal/listbox/listbox.state.mjs +19 -20
- package/dist/js/internal/misc.d.mts +5 -4
- package/dist/js/internal/misc.mjs +7 -1
- package/dist/js/internal/navigable/index.d.mts +6 -0
- package/dist/js/internal/navigable/index.mjs +125 -0
- package/dist/js/internal/navigable/navigable.model.d.mts +2 -0
- package/dist/js/internal/navigable/navigable.model.mjs +18 -0
- package/dist/js/l10n/index.d.mts +9 -0
- package/dist/js/{l10n.mjs → l10n/index.mjs} +50 -23
- package/dist/js/l10n/l10n.model.d.mts +2 -0
- package/dist/js/l10n/l10n.model.mjs +9 -0
- package/dist/js/l10n.model-D6a9frgl.d.mts +26 -0
- package/dist/js/listbox/constants.listbox.d.mts +2 -2
- package/dist/js/listbox/constants.listbox.mjs +10 -14
- package/dist/js/listbox/event.listbox.d.mts +6 -7
- package/dist/js/listbox/event.listbox.mjs +47 -1
- package/dist/js/listbox/index.d.mts +8 -6
- package/dist/js/listbox/index.mjs +47 -49
- package/dist/js/listbox/misc.listbox.d.mts +1 -1
- package/dist/js/listbox/misc.listbox.mjs +1 -1
- package/dist/js/listbox/state.listbox.d.mts +8 -10
- package/dist/js/listbox/state.listbox.mjs +2 -2
- package/dist/js/{listbox.data-C7CRa5Ya.mjs → listbox.data-BQyZGKgr.mjs} +83 -66
- package/dist/js/{listbox.model-CRReGOmu.d.mts → listbox.model-CuBOj4qe.d.mts} +15 -11
- package/dist/js/menu/index.mjs +167 -0
- package/dist/js/menu/menu.model.d.mts +33 -0
- package/dist/js/menu/menu.model.mjs +15 -0
- package/dist/js/{misc.listbox-Cyz2CRDy.mjs → misc.listbox-CjfBUbHD.mjs} +27 -69
- package/dist/js/{misc.listbox-gnoJhrTr.d.mts → misc.listbox-CtoGvXQo.d.mts} +2 -2
- package/dist/js/movable/movable.embedded.d.mts +2 -2
- package/dist/js/movable/movable.embedded.mjs +60 -72
- package/dist/js/movable/movable.model.d.mts +2 -0
- package/dist/js/movable/movable.model.mjs +12 -0
- package/dist/js/movable/movable.standalone.d.mts +2 -1
- package/dist/js/movable.embedded-DoyXLegc.d.mts +11 -0
- package/dist/js/movable.model-BHaK_mKw.d.mts +186 -0
- package/dist/js/navigable.model-BPOM8DZk.d.mts +44 -0
- package/dist/js/popover/index.d.mts +12 -0
- package/dist/js/{popover.mjs → popover/index.mjs} +40 -50
- package/dist/js/popover/popover.model.d.mts +2 -0
- package/dist/js/popover/popover.model.mjs +12 -0
- package/dist/js/popover.model-ubKNG612.d.mts +38 -0
- package/dist/js/resizable/resizable.embedded.d.mts +2 -2
- package/dist/js/resizable/resizable.embedded.mjs +44 -59
- package/dist/js/resizable/resizable.model.d.mts +2 -0
- package/dist/js/resizable/resizable.model.mjs +21 -0
- package/dist/js/resizable/resizable.standalone.d.mts +2 -1
- package/dist/js/resizable.embedded-Bf1qBUdt.d.mts +11 -0
- package/dist/js/resizable.model-BwzJcTVJ.d.mts +46 -0
- package/dist/js/sortable/sortable.embedded.d.mts +2 -2
- package/dist/js/sortable/sortable.embedded.mjs +69 -82
- package/dist/js/sortable/sortable.model.d.mts +2 -0
- package/dist/js/sortable/sortable.model.mjs +24 -0
- package/dist/js/sortable/sortable.standalone.d.mts +2 -1
- package/dist/js/sortable.embedded-DzBKAwSG.d.mts +11 -0
- package/dist/js/{splitter.d.mts → splitter/index.d.mts} +8 -7
- package/dist/js/splitter/index.mjs +284 -0
- package/dist/js/splitter/splitter.model.d.mts +2 -0
- package/dist/js/splitter/splitter.model.mjs +37 -0
- package/dist/js/splitter.model-DOLNjLVS.d.mts +57 -0
- package/dist/js/{tabs.d.mts → tabs/index.d.mts} +7 -8
- package/dist/js/{tabs.mjs → tabs/index.mjs} +58 -58
- package/dist/js/tabs/tabs.model.d.mts +2 -0
- package/dist/js/tabs/tabs.model.mjs +18 -0
- package/dist/js/tabs.model-DRBX_JtI.d.mts +40 -0
- package/dist/js/toolbar/index.mjs +27 -0
- package/dist/js/toolbar/toolbar.model.d.mts +11 -0
- package/dist/js/toolbar/toolbar.model.mjs +7 -0
- package/dist/js/tooltip/index.d.mts +19 -0
- package/dist/js/{tooltip.mjs → tooltip/index.mjs} +60 -85
- package/dist/js/tooltip/tooltip.model.d.mts +2 -0
- package/dist/js/tooltip/tooltip.model.mjs +15 -0
- package/dist/js/tooltip.model-DRkY_BsL.d.mts +37 -0
- package/package.json +43 -37
- package/dist/js/color-picker.mjs +0 -924
- package/dist/js/combobox/constants.combobox.d.mts +0 -2
- package/dist/js/combobox/dom.combobox.d.mts +0 -27
- package/dist/js/combobox/event.combobox.d.mts +0 -23
- package/dist/js/combobox/misc.combobox.d.mts +0 -2
- package/dist/js/combobox/state.combobox.d.mts +0 -12
- package/dist/js/combobox/state.combobox.mjs +0 -2
- package/dist/js/constants.combobox-DmRAMC64.d.mts +0 -26
- package/dist/js/constants.listbox-DRsXUxd3.d.mts +0 -14
- package/dist/js/dialog.d.mts +0 -47
- package/dist/js/dialog.mjs +0 -131
- package/dist/js/draggable-a6w0J1OD.d.mts +0 -154
- package/dist/js/floatable.embedded-Bct4U5Dm.d.mts +0 -69
- package/dist/js/index-DJdFlTLm.d.mts +0 -177
- package/dist/js/internal/draggable.d.mts +0 -2
- package/dist/js/internal/navigable.d.mts +0 -37
- package/dist/js/internal/navigable.mjs +0 -135
- package/dist/js/l10n-Bn-7RcwR.d.mts +0 -20
- package/dist/js/l10n.d.mts +0 -2
- package/dist/js/menu.mjs +0 -172
- package/dist/js/popover.d.mts +0 -38
- package/dist/js/resizable.embedded-3qoR0Bjm.d.mts +0 -34
- package/dist/js/splitter.mjs +0 -322
- package/dist/js/toolbar.mjs +0 -31
- package/dist/js/tooltip.d.mts +0 -45
- package/src/css/a11y.scss +0 -13
- package/src/css/badge.scss +0 -62
- package/src/css/button.scss +0 -50
- package/src/css/color-picker.scss +0 -344
- package/src/css/color.scss +0 -113
- package/src/css/combobox.scss +0 -255
- package/src/css/content.scss +0 -181
- package/src/css/flex.scss +0 -107
- package/src/css/floatable.scss +0 -155
- package/src/css/form.scss +0 -575
- package/src/css/listbox.scss +0 -121
- package/src/css/message.scss +0 -74
- package/src/css/mixins/badge.mixins.scss +0 -53
- package/src/css/mixins/button.mixins.scss +0 -112
- package/src/css/mixins/input.mixins.scss +0 -114
- package/src/css/mixins/message.mixins.scss +0 -41
- package/src/css/mixins/misc.mixins.scss +0 -48
- package/src/css/mixins/shadow.mixins.scss +0 -57
- package/src/css/reset.scss +0 -392
- package/src/css/splitter.scss +0 -89
- package/src/css/table.scss +0 -107
- package/src/css/tabs.scss +0 -74
- package/src/js/color-picker.ts +0 -1653
- package/src/js/combobox/constants.combobox.ts +0 -83
- package/src/js/combobox/dom.combobox.ts +0 -411
- package/src/js/combobox/event.combobox.ts +0 -365
- package/src/js/combobox/index.ts +0 -382
- package/src/js/combobox/misc.combobox.ts +0 -104
- package/src/js/combobox/models.combobox.ts +0 -54
- package/src/js/combobox/state.combobox.ts +0 -246
- package/src/js/dialog.ts +0 -255
- package/src/js/floatable/floatable.embedded.ts +0 -336
- package/src/js/floatable/floatable.standalone.ts +0 -6
- package/src/js/focus-trap/focus-trap.embedded.ts +0 -411
- package/src/js/focus-trap/focus-trap.standalone.ts +0 -1
- package/src/js/index.ts +0 -16
- package/src/js/internal/attributable.ts +0 -73
- package/src/js/internal/draggable.ts +0 -657
- package/src/js/internal/listbox/listbox.constants.ts +0 -25
- package/src/js/internal/listbox/listbox.data.ts +0 -287
- package/src/js/internal/listbox/listbox.dom.ts +0 -446
- package/src/js/internal/listbox/listbox.event.ts +0 -129
- package/src/js/internal/listbox/listbox.form.ts +0 -125
- package/src/js/internal/listbox/listbox.misc.ts +0 -135
- package/src/js/internal/listbox/listbox.model.ts +0 -169
- package/src/js/internal/listbox/listbox.state.ts +0 -82
- package/src/js/internal/misc.ts +0 -27
- package/src/js/internal/navigable.ts +0 -317
- package/src/js/l10n.ts +0 -192
- package/src/js/listbox/constants.listbox.ts +0 -61
- package/src/js/listbox/event.listbox.ts +0 -106
- package/src/js/listbox/index.ts +0 -364
- package/src/js/listbox/misc.listbox.ts +0 -70
- package/src/js/listbox/state.listbox.ts +0 -194
- package/src/js/menu.ts +0 -348
- package/src/js/movable/movable.embedded.ts +0 -318
- package/src/js/movable/movable.standalone.ts +0 -2
- package/src/js/popover.ts +0 -229
- package/src/js/resizable/resizable.embedded.ts +0 -413
- package/src/js/resizable/resizable.standalone.ts +0 -5
- package/src/js/sortable/sortable.embedded.ts +0 -527
- package/src/js/sortable/sortable.standalone.ts +0 -2
- package/src/js/splitter.ts +0 -583
- package/src/js/tabs.ts +0 -441
- package/src/js/toolbar.ts +0 -63
- package/src/js/tooltip.ts +0 -367
- /package/dist/js/combobox/{models.combobox.mjs → combobox.model.mjs} +0 -0
- /package/dist/js/{menu.d.mts → menu/index.d.mts} +0 -0
- /package/dist/js/{toolbar.d.mts → toolbar/index.d.mts} +0 -0
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
1
|
+
//#region src/js/internal/listbox/listbox.constants.ts
|
|
2
|
+
const LISTBOX_KEYS_ACTIVATION = /* @__PURE__ */ new Set([
|
|
3
|
+
" ",
|
|
4
|
+
"Backspace",
|
|
5
|
+
"Delete",
|
|
6
|
+
"Enter"
|
|
7
|
+
]);
|
|
8
|
+
const LISTBOX_KEYS_NAVIGATION = /* @__PURE__ */ new Set([
|
|
9
|
+
"ArrowDown",
|
|
10
|
+
"ArrowUp",
|
|
11
|
+
"PageDown",
|
|
12
|
+
"PageUp"
|
|
13
|
+
]);
|
|
14
|
+
const LISTBOX_KEYS_SELECTION = /* @__PURE__ */ new Set(["ArrowRight", "End"]);
|
|
16
15
|
const LISTBOX_TYPES = /* @__PURE__ */ new Set(["autocomplete", "select"]);
|
|
17
16
|
const listboxScrollOptions = {
|
|
18
17
|
behavior: "auto",
|
|
@@ -20,4 +19,4 @@ const listboxScrollOptions = {
|
|
|
20
19
|
inline: "nearest"
|
|
21
20
|
};
|
|
22
21
|
//#endregion
|
|
23
|
-
export {
|
|
22
|
+
export { LISTBOX_KEYS_ACTIVATION, LISTBOX_KEYS_NAVIGATION, LISTBOX_KEYS_SELECTION, LISTBOX_TYPES, listboxScrollOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as OuiListboxState } from "../../listbox.model-
|
|
1
|
+
import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
2
|
//#region src/js/internal/listbox/listbox.data.d.ts
|
|
3
3
|
type ApplySelectionParameters<State extends OuiListboxState = OuiListboxState> = {
|
|
4
4
|
added: boolean;
|
|
@@ -9,12 +9,11 @@ type ApplySelectionParameters<State extends OuiListboxState = OuiListboxState> =
|
|
|
9
9
|
state: State;
|
|
10
10
|
values?: string[];
|
|
11
11
|
};
|
|
12
|
-
declare function applyListboxSelection<State extends OuiListboxState>(parameters: ApplySelectionParameters<State>): void;
|
|
13
|
-
declare function filterListbox(type: InputEvent[
|
|
14
|
-
declare function filterListboxOption(state: OuiListboxState, value: unknown, textContent?: boolean): HTMLElement | undefined;
|
|
15
|
-
declare function filterListboxOptions(state: OuiListboxState): HTMLElement | undefined;
|
|
16
|
-
declare function setListboxValue<State extends OuiListboxState>(state: State, value: unknown, emit?: boolean): void;
|
|
17
|
-
declare function setListboxValues<State extends OuiListboxState>(state: State, value: unknown[], emit?: boolean): void;
|
|
18
|
-
declare function toggleListboxOption<State extends OuiListboxState>(state: State, option?: HTMLElement): void;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { applyListboxSelection, filterListbox, filterListboxOption, filterListboxOptions, setListboxValue, setListboxValues, toggleListboxOption };
|
|
12
|
+
export declare function applyListboxSelection<State extends OuiListboxState>(parameters: ApplySelectionParameters<State>): void;
|
|
13
|
+
export declare function filterListbox(type: InputEvent["inputType"], state: OuiListboxState): void;
|
|
14
|
+
export declare function filterListboxOption(state: OuiListboxState, value: unknown, textContent?: boolean): HTMLElement | undefined;
|
|
15
|
+
export declare function filterListboxOptions(state: OuiListboxState): HTMLElement | undefined;
|
|
16
|
+
export declare function setListboxValue<State extends OuiListboxState>(state: State, value: unknown, emit?: boolean): void;
|
|
17
|
+
export declare function setListboxValues<State extends OuiListboxState>(state: State, value: unknown[], emit?: boolean): void;
|
|
18
|
+
export declare function toggleListboxOption<State extends OuiListboxState>(state: State, option?: HTMLElement): void;
|
|
19
|
+
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as setListboxValue, i as filterListboxOptions, n as filterListbox, o as setListboxValues, r as filterListboxOption, s as toggleListboxOption, t as applyListboxSelection } from "../../listbox.data-
|
|
1
|
+
import { a as setListboxValue, i as filterListboxOptions, n as filterListbox, o as setListboxValues, r as filterListboxOption, s as toggleListboxOption, t as applyListboxSelection } from "../../listbox.data-BQyZGKgr.mjs";
|
|
2
2
|
export { applyListboxSelection, filterListbox, filterListboxOption, filterListboxOptions, setListboxValue, setListboxValues, toggleListboxOption };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { a as OuiListboxGroup, c as OuiListboxPreview,
|
|
1
|
+
import { a as OuiListboxGroup, c as OuiListboxPreview, f as OuiListboxType, l as OuiListboxState, n as OuiListboxAutoComplete, s as OuiListboxOptions, t as OuiListboxAttributes } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
2
|
//#region src/js/internal/listbox/listbox.dom.d.ts
|
|
3
|
-
type CreateListboxContent = {
|
|
3
|
+
export type CreateListboxContent = {
|
|
4
4
|
element: HTMLDivElement;
|
|
5
5
|
filter?: CreateListboxFilter;
|
|
6
6
|
list: CreateListboxList;
|
|
7
7
|
message: HTMLDivElement;
|
|
8
8
|
value: HTMLSpanElement;
|
|
9
9
|
};
|
|
10
|
-
type CreateListboxContentParameters = {
|
|
10
|
+
export type CreateListboxContentParameters = {
|
|
11
11
|
attributes: OuiListboxAttributes;
|
|
12
12
|
autocomplete: OuiListboxAutoComplete;
|
|
13
13
|
element: HTMLElement;
|
|
@@ -18,7 +18,7 @@ type CreateListboxContentParameters = {
|
|
|
18
18
|
select: HTMLSelectElement;
|
|
19
19
|
type: OuiListboxType;
|
|
20
20
|
};
|
|
21
|
-
type CreateListboxFilter = {
|
|
21
|
+
export type CreateListboxFilter = {
|
|
22
22
|
container: HTMLElement;
|
|
23
23
|
element: HTMLInputElement;
|
|
24
24
|
};
|
|
@@ -29,7 +29,7 @@ type CreateListboxGroupParameters = {
|
|
|
29
29
|
selected: HTMLElement[];
|
|
30
30
|
type: OuiListboxType;
|
|
31
31
|
};
|
|
32
|
-
type CreateListboxList = {
|
|
32
|
+
export type CreateListboxList = {
|
|
33
33
|
element: HTMLUListElement;
|
|
34
34
|
groups?: OuiListboxGroup[];
|
|
35
35
|
options: OuiListboxOptions;
|
|
@@ -49,18 +49,17 @@ type CreateListboxOptionsParameters = {
|
|
|
49
49
|
selected: HTMLElement[];
|
|
50
50
|
type: OuiListboxType;
|
|
51
51
|
};
|
|
52
|
-
declare function createListboxContent(parameters: CreateListboxContentParameters): CreateListboxContent;
|
|
53
|
-
declare function createListboxFilter(parameters: CreateListboxContentParameters): CreateListboxFilter | undefined;
|
|
54
|
-
declare function createListboxGroup(parameters: CreateListboxGroupParameters): OuiListboxGroup;
|
|
55
|
-
declare function createListboxHeader(parameters: CreateListboxGroupParameters, group: HTMLOptGroupElement): HTMLElement;
|
|
56
|
-
declare function createListboxInput(parameters: CreateListboxContentParameters, value: string): HTMLInputElement;
|
|
57
|
-
declare function createListboxList(parameters: CreateListboxContentParameters): CreateListboxList;
|
|
58
|
-
declare function createListboxMessage(attribute: string): HTMLDivElement;
|
|
59
|
-
declare function createListboxOption(parameters: CreateListboxOptionParameters): HTMLElement;
|
|
60
|
-
declare function createListboxOptions(parameters: CreateListboxOptionsParameters): HTMLElement[];
|
|
61
|
-
declare function createListboxValueLabel(id: string): HTMLSpanElement;
|
|
62
|
-
declare function updateListboxMessage(state: OuiListboxState): void;
|
|
63
|
-
declare function updateListboxPreview<State extends OuiListboxState>(preview: OuiListboxPreview, state: State, active?: HTMLElement, scroll?: boolean): void;
|
|
64
|
-
declare function updateListboxValueLabel<State extends OuiListboxState>(state: State): void;
|
|
65
|
-
//#endregion
|
|
66
|
-
export { CreateListboxContent, CreateListboxContentParameters, CreateListboxFilter, CreateListboxList, createListboxContent, createListboxFilter, createListboxGroup, createListboxHeader, createListboxInput, createListboxList, createListboxMessage, createListboxOption, createListboxOptions, createListboxValueLabel, updateListboxMessage, updateListboxPreview, updateListboxValueLabel };
|
|
52
|
+
export declare function createListboxContent(parameters: CreateListboxContentParameters): CreateListboxContent;
|
|
53
|
+
export declare function createListboxFilter(parameters: CreateListboxContentParameters): CreateListboxFilter | undefined;
|
|
54
|
+
export declare function createListboxGroup(parameters: CreateListboxGroupParameters): OuiListboxGroup;
|
|
55
|
+
export declare function createListboxHeader(parameters: CreateListboxGroupParameters, group: HTMLOptGroupElement): HTMLElement;
|
|
56
|
+
export declare function createListboxInput(parameters: CreateListboxContentParameters, value: string): HTMLInputElement;
|
|
57
|
+
export declare function createListboxList(parameters: CreateListboxContentParameters): CreateListboxList;
|
|
58
|
+
export declare function createListboxMessage(attribute: string): HTMLDivElement;
|
|
59
|
+
export declare function createListboxOption(parameters: CreateListboxOptionParameters): HTMLElement;
|
|
60
|
+
export declare function createListboxOptions(parameters: CreateListboxOptionsParameters): HTMLElement[];
|
|
61
|
+
export declare function createListboxValueLabel(id: string): HTMLSpanElement;
|
|
62
|
+
export declare function updateListboxMessage(state: OuiListboxState): void;
|
|
63
|
+
export declare function updateListboxPreview<State extends OuiListboxState>(preview: OuiListboxPreview, state: State, active?: HTMLElement, scroll?: boolean): void;
|
|
64
|
+
export declare function updateListboxValueLabel<State extends OuiListboxState>(state: State): void;
|
|
65
|
+
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as createListboxValueLabel, b as updateListboxValueLabel, c as createListboxContent, d as createListboxHeader, f as createListboxInput, g as createListboxOptions, h as createListboxOption, l as createListboxFilter, m as createListboxMessage, p as createListboxList, u as createListboxGroup, v as updateListboxMessage, y as updateListboxPreview } from "../../listbox.data-
|
|
1
|
+
import { _ as createListboxValueLabel, b as updateListboxValueLabel, c as createListboxContent, d as createListboxHeader, f as createListboxInput, g as createListboxOptions, h as createListboxOption, l as createListboxFilter, m as createListboxMessage, p as createListboxList, u as createListboxGroup, v as updateListboxMessage, y as updateListboxPreview } from "../../listbox.data-BQyZGKgr.mjs";
|
|
2
2
|
export { createListboxContent, createListboxFilter, createListboxGroup, createListboxHeader, createListboxInput, createListboxList, createListboxMessage, createListboxOption, createListboxOptions, createListboxValueLabel, updateListboxMessage, updateListboxPreview, updateListboxValueLabel };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { l as OuiListboxState } from "../../listbox.model-
|
|
1
|
+
import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
2
|
//#region src/js/internal/listbox/listbox.event.d.ts
|
|
3
|
-
declare function processListboxKeydown<State extends OuiListboxState>(event: KeyboardEvent, state: State): void;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { processListboxKeydown };
|
|
3
|
+
export declare function processListboxKeydown<State extends OuiListboxState>(event: KeyboardEvent, state: State): void;
|
|
4
|
+
//#endregion
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as getListboxVisibleOptions } from "../../listbox.data-
|
|
1
|
+
import { LISTBOX_KEYS_NAVIGATION, LISTBOX_KEYS_SELECTION } from "./listbox.constants.mjs";
|
|
2
|
+
import { S as getListboxVisibleOptions } from "../../listbox.data-BQyZGKgr.mjs";
|
|
3
3
|
import { clamp } from "@oscarpalmer/atoms/number";
|
|
4
4
|
//#region src/js/internal/listbox/listbox.event.ts
|
|
5
5
|
function processListboxKeydown(event, state) {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const { component, form } = state;
|
|
7
|
+
const { callbacks, disabled, readonly, type } = component;
|
|
8
|
+
const ignore = disabled || readonly;
|
|
9
|
+
const isSelect = type === "select";
|
|
8
10
|
let preventDefault = ignore;
|
|
9
11
|
switch (true) {
|
|
10
12
|
case event.key === " ":
|
|
11
|
-
if (!
|
|
13
|
+
if (!disabled) callbacks.keydown.onActivation?.(state);
|
|
12
14
|
break;
|
|
13
15
|
case event.key === "Enter":
|
|
14
|
-
preventDefault =
|
|
15
|
-
if (preventDefault)
|
|
16
|
-
else if (!ignore &&
|
|
17
|
-
else if (!ignore)
|
|
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();
|
|
18
20
|
break;
|
|
19
21
|
case event.key === "Escape":
|
|
20
22
|
preventDefault = false;
|
|
21
|
-
|
|
23
|
+
callbacks.keydown.onEscape?.(state);
|
|
22
24
|
break;
|
|
23
|
-
case !isSelect &&
|
|
24
|
-
if (!ignore)
|
|
25
|
+
case !isSelect && LISTBOX_KEYS_SELECTION.has(event.key):
|
|
26
|
+
if (!ignore) callbacks.keydown.onSelection?.(state);
|
|
25
27
|
break;
|
|
26
|
-
case
|
|
27
|
-
if (!
|
|
28
|
+
case LISTBOX_KEYS_NAVIGATION.has(event.key):
|
|
29
|
+
if (!disabled) onNavigation(event, state);
|
|
28
30
|
break;
|
|
29
31
|
default:
|
|
30
32
|
preventDefault = false;
|
|
31
|
-
if (event.key === "Tab")
|
|
33
|
+
if (event.key === "Tab") callbacks.keydown.onTab?.(state);
|
|
32
34
|
}
|
|
33
35
|
if (preventDefault) {
|
|
34
36
|
event.preventDefault();
|
|
@@ -36,13 +38,14 @@ function processListboxKeydown(event, state) {
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
function onNavigation(event, state) {
|
|
39
|
-
const
|
|
41
|
+
const { active, autocomplete, callbacks, type } = state.component;
|
|
42
|
+
const skip = callbacks.keydown.skipNavigation?.(state) ?? false;
|
|
40
43
|
const visible = getListboxVisibleOptions(state);
|
|
41
44
|
if (visible.length === 0) return;
|
|
42
45
|
let next;
|
|
43
|
-
if (skip ||
|
|
46
|
+
if (skip || active == null) next = active ?? visible.at(event.key === "ArrowDown" ? 0 : -1);
|
|
44
47
|
else {
|
|
45
|
-
const current = visible.findIndex((option) => option.id ===
|
|
48
|
+
const current = visible.findIndex((option) => option.id === active?.id);
|
|
46
49
|
let index;
|
|
47
50
|
switch (event.key) {
|
|
48
51
|
case "ArrowDown":
|
|
@@ -55,9 +58,9 @@ function onNavigation(event, state) {
|
|
|
55
58
|
if (index != null) next = visible[index];
|
|
56
59
|
}
|
|
57
60
|
let preview;
|
|
58
|
-
if (
|
|
61
|
+
if (type === "autocomplete" && (autocomplete.both || autocomplete.inline)) preview = "set";
|
|
59
62
|
else preview = "none";
|
|
60
|
-
|
|
63
|
+
callbacks.keydown.onNavigation(preview, state, next ?? active ?? visible[0]);
|
|
61
64
|
}
|
|
62
65
|
//#endregion
|
|
63
66
|
export { processListboxKeydown };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { l as OuiListboxState } from "../../listbox.model-
|
|
1
|
+
import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
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 };
|
|
3
|
+
export declare function updateListboxForm<State extends OuiListboxState>(state: State, values: string[], emit?: boolean): void;
|
|
4
|
+
export declare function updateListboxValidity(state: OuiListboxState): void;
|
|
5
|
+
//#endregion
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import { getLocalization, localize } from "../../l10n.mjs";
|
|
1
|
+
import { getLocalization, localize } from "../../l10n/index.mjs";
|
|
2
2
|
import { dispatch } from "@oscarpalmer/toretto/event";
|
|
3
3
|
//#region src/js/internal/listbox/listbox.form.ts
|
|
4
4
|
function updateListboxForm(state, values, emit) {
|
|
5
|
+
const { component, form } = state;
|
|
6
|
+
const { callbacks, host, multiple, name } = component;
|
|
5
7
|
let value;
|
|
6
|
-
if (
|
|
8
|
+
if (multiple) {
|
|
7
9
|
const { length } = values;
|
|
8
10
|
value = new FormData();
|
|
9
|
-
for (let index = 0; index < length; index += 1) value.append(
|
|
11
|
+
for (let index = 0; index < length; index += 1) value.append(name, values[index]);
|
|
10
12
|
} else value = values[0];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
component.values.current = values;
|
|
14
|
+
form.internals.setFormValue(value, JSON.stringify(values));
|
|
15
|
+
callbacks.data.onForm(state);
|
|
14
16
|
updateListboxValidity(state);
|
|
15
|
-
if (emit ?? true) dispatch(
|
|
17
|
+
if (emit ?? true) dispatch(host, "oui:change");
|
|
16
18
|
}
|
|
17
19
|
function updateListboxValidity(state) {
|
|
18
|
-
const {
|
|
20
|
+
const { component, form } = state;
|
|
21
|
+
const { autocomplete, filter, host, listbox, localizations, max, min, multiple, options, required } = component;
|
|
19
22
|
if (autocomplete.none && !listbox) {
|
|
20
23
|
const valueMissing = required && filter.element.value.length === 0;
|
|
21
24
|
const localization = getLocalization(localizations.global, host, "invalid", localizations.component);
|
|
22
|
-
internals.setValidity({ valueMissing }, localize(localization, {}, []));
|
|
23
|
-
internals.checkValidity();
|
|
25
|
+
form.internals.setValidity({ valueMissing }, localize(localization, {}, []));
|
|
26
|
+
form.internals.checkValidity();
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
26
29
|
let data = {};
|
|
@@ -46,8 +49,8 @@ function updateListboxValidity(state) {
|
|
|
46
49
|
}
|
|
47
50
|
const localization = key == null ? void 0 : getLocalization(localizations.global, host, key, localizations.component);
|
|
48
51
|
const message = localization == null ? void 0 : localize(localization, data, parameters);
|
|
49
|
-
internals.setValidity(error == null ? {} : { [error]: true }, message);
|
|
50
|
-
internals.checkValidity();
|
|
52
|
+
form.internals.setValidity(error == null ? {} : { [error]: true }, message);
|
|
53
|
+
form.internals.checkValidity();
|
|
51
54
|
}
|
|
52
55
|
//#endregion
|
|
53
56
|
export { updateListboxForm, updateListboxValidity };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { l as OuiListboxState } from "../../listbox.model-
|
|
1
|
+
import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
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:
|
|
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 };
|
|
3
|
+
export declare function generateListboxIds(prefix: string, select: HTMLSelectElement): void;
|
|
4
|
+
export declare function getListboxVisibleOptions(state: OuiListboxState): HTMLElement[];
|
|
5
|
+
export declare function setListboxDisabled<State extends OuiListboxState>(state: State, value: boolean): void;
|
|
6
|
+
export declare function setListboxFilter<State extends OuiListboxState>(state: State, value: unknown): void;
|
|
7
|
+
export declare function setListboxLimit<State extends OuiListboxState>(type: "max" | "min", state: State, value?: unknown): void;
|
|
8
|
+
export declare function setListboxMultiple(element: HTMLElement, value: boolean): void;
|
|
9
|
+
export declare function setListboxReadonly<State extends OuiListboxState>(state: State, value: boolean): void;
|
|
10
|
+
export declare function setListboxRequired<State extends OuiListboxState>(state: State, value: boolean): void;
|
|
11
|
+
//#endregion
|
|
@@ -1,2 +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-
|
|
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-BQyZGKgr.mjs";
|
|
2
2
|
export { generateListboxIds, getListboxVisibleOptions, setListboxDisabled, setListboxFilter, setListboxLimit, setListboxMultiple, setListboxReadonly, setListboxRequired };
|
|
@@ -1,2 +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
|
|
2
|
-
export { OuiListboxAttributes, OuiListboxAutoComplete, OuiListboxAutoCompleteType, OuiListboxCallbacks, OuiListboxGroup, OuiListboxLocalizations, OuiListboxOptions, OuiListboxPreview, OuiListboxState,
|
|
1
|
+
import { a as OuiListboxGroup, c as OuiListboxPreview, d as OuiListboxStateForm, f 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 OuiListboxStateComponent } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
|
+
export { OuiListboxAttributes, OuiListboxAutoComplete, OuiListboxAutoCompleteType, OuiListboxCallbacks, OuiListboxGroup, OuiListboxLocalizations, OuiListboxOptions, OuiListboxPreview, OuiListboxState, OuiListboxStateComponent, OuiListboxStateForm, OuiListboxType };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { l as OuiListboxState
|
|
1
|
+
import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
2
|
//#region src/js/internal/listbox/listbox.state.d.ts
|
|
3
|
-
declare function attachListbox<State extends OuiListboxState>(state: State,
|
|
4
|
-
declare function detachListbox<State extends OuiListboxState>(state: State,
|
|
5
|
-
declare function initializeListboxState<State extends OuiListboxState>(state: State,
|
|
6
|
-
//#endregion
|
|
7
|
-
export { attachListbox, detachListbox, initializeListboxState };
|
|
3
|
+
export declare function attachListbox<State extends OuiListboxState>(state: State, set: Set<State>, onAttach: (state: State) => void): void;
|
|
4
|
+
export declare function detachListbox<State extends OuiListboxState>(state: State, set: Set<State>, onDetach: (state: State) => void): void;
|
|
5
|
+
export declare function initializeListboxState<State extends OuiListboxState>(state: State, set: Set<State>, onAttach: (state: State) => void): State;
|
|
6
|
+
//#endregion
|
|
@@ -1,39 +1,38 @@
|
|
|
1
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-
|
|
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-BQyZGKgr.mjs";
|
|
3
3
|
import { getAttribute } from "@oscarpalmer/toretto/attribute";
|
|
4
4
|
//#region src/js/internal/listbox/listbox.state.ts
|
|
5
|
-
function attachListbox(state,
|
|
6
|
-
const { filter,
|
|
5
|
+
function attachListbox(state, set, onAttach) {
|
|
6
|
+
const { filter, id, label } = state.component;
|
|
7
7
|
label.element.htmlFor = filter.element.id;
|
|
8
8
|
label.element.id = `${id}_label`;
|
|
9
9
|
onAttach(state);
|
|
10
|
-
|
|
11
|
-
states.set.add(state);
|
|
10
|
+
set.add(state);
|
|
12
11
|
}
|
|
13
|
-
function detachListbox(state,
|
|
14
|
-
const {
|
|
15
|
-
const listeners = state.listeners.splice(0);
|
|
12
|
+
function detachListbox(state, set, onDetach) {
|
|
13
|
+
const { label, select } = state.component;
|
|
14
|
+
const listeners = state.component.listeners.splice(0);
|
|
16
15
|
const { length } = listeners;
|
|
17
16
|
for (let index = 0; index < length; index += 1) listeners[index]();
|
|
18
17
|
label.element.htmlFor = select.id;
|
|
19
18
|
label.element.id = label.id;
|
|
20
19
|
onDetach(state);
|
|
21
|
-
|
|
22
|
-
states.set.delete(state);
|
|
20
|
+
set.delete(state);
|
|
23
21
|
}
|
|
24
|
-
function initializeListboxState(state,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
setListboxLimit("
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
function initializeListboxState(state, set, onAttach) {
|
|
23
|
+
const { component } = state;
|
|
24
|
+
attachListbox(state, set, onAttach);
|
|
25
|
+
setListboxDisabled(state, component.disabled);
|
|
26
|
+
setListboxLimit("max", state, getAttribute(component.host, "max"));
|
|
27
|
+
setListboxLimit("min", state, getAttribute(component.host, "min"));
|
|
28
|
+
setListboxMultiple(component.host, component.multiple);
|
|
29
|
+
setListboxReadonly(state, component.readonly);
|
|
30
|
+
setListboxRequired(state, component.required);
|
|
32
31
|
filterListboxOptions(state);
|
|
33
|
-
updateListboxForm(state,
|
|
32
|
+
updateListboxForm(state, component.values.current, false);
|
|
34
33
|
updateListboxMessage(state);
|
|
35
34
|
updateListboxValueLabel(state);
|
|
36
|
-
if (
|
|
35
|
+
if (component.options.selected.length > 0) updateListboxPreview("none", state, component.options.selected[0], false);
|
|
37
36
|
return state;
|
|
38
37
|
}
|
|
39
38
|
//#endregion
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AnyAriaBooleanAttribute } from "@oscarpalmer/toretto/models";
|
|
2
2
|
//#region src/js/internal/misc.d.ts
|
|
3
|
-
declare function
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
export
|
|
3
|
+
export declare function copyValue(value: string, onSuccess?: () => void, onError?: () => void): void;
|
|
4
|
+
export declare function getAttributeValue<Value>(element: HTMLElement, attribute: string, possible: Set<Value>, defaultValue: Value): Value;
|
|
5
|
+
export declare function getBooleanAriaValue(element: HTMLElement, attribute: AnyAriaBooleanAttribute): boolean;
|
|
6
|
+
export declare const EXPRESSION_WHITESPACE: RegExp;
|
|
7
|
+
//#endregion
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getAria } from "@oscarpalmer/toretto/aria";
|
|
2
2
|
import { getAttribute } from "@oscarpalmer/toretto/attribute";
|
|
3
|
+
import { noop } from "@oscarpalmer/atoms/function";
|
|
4
|
+
import { attempt } from "@oscarpalmer/atoms/result";
|
|
3
5
|
//#region src/js/internal/misc.ts
|
|
6
|
+
function copyValue(value, onSuccess, onError) {
|
|
7
|
+
if (!attempt(() => navigator.clipboard.writeText(value).then(onSuccess ?? noop, onError ?? noop)).ok) onError?.();
|
|
8
|
+
}
|
|
4
9
|
function getAttributeValue(element, attribute, possible, defaultValue) {
|
|
5
10
|
const value = getAttribute(element, attribute);
|
|
6
11
|
return possible.has(value) ? value : defaultValue;
|
|
@@ -9,5 +14,6 @@ function getBooleanAriaValue(element, attribute) {
|
|
|
9
14
|
const value = getAria(element, attribute);
|
|
10
15
|
return value === true || value === "true";
|
|
11
16
|
}
|
|
17
|
+
const EXPRESSION_WHITESPACE = /\s+/;
|
|
12
18
|
//#endregion
|
|
13
|
-
export { getAttributeValue, getBooleanAriaValue };
|
|
19
|
+
export { EXPRESSION_WHITESPACE, copyValue, getAttributeValue, getBooleanAriaValue };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { d as OuiNavigable, h as OuiNavigableOrientation, m as OuiNavigableOptions } from "../../navigable.model-BPOM8DZk.mjs";
|
|
2
|
+
//#region src/js/internal/navigable/index.d.ts
|
|
3
|
+
export declare function getNavigable(element: HTMLElement, options: OuiNavigableOptions): OuiNavigable;
|
|
4
|
+
export declare function getNavigableOrientation(element: HTMLElement, vertical: boolean, aria?: boolean): OuiNavigableOrientation;
|
|
5
|
+
export declare function updateNavigableFocus(navigable: OuiNavigable, focus: boolean, items?: HTMLElement[]): void;
|
|
6
|
+
//#endregion
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { NAVIGABLE_KEYS_ABSOLUTE, NAVIGABLE_KEYS_ACTIVATE, NAVIGABLE_KEYS_ALL, NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_NEXT, NAVIGABLE_ORIENTATIONS, NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL, NAVIGABLE_SYMBOL } from "./navigable.model.mjs";
|
|
2
|
+
import { getAria, setAria, setRole } from "@oscarpalmer/toretto/aria";
|
|
3
|
+
import { getAttribute } from "@oscarpalmer/toretto/attribute";
|
|
4
|
+
import { on } from "@oscarpalmer/toretto/event";
|
|
5
|
+
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
6
|
+
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
7
|
+
import { filter } from "@oscarpalmer/atoms/array/filter";
|
|
8
|
+
import { clamp } from "@oscarpalmer/atoms/number";
|
|
9
|
+
//#region src/js/internal/navigable/index.ts
|
|
10
|
+
function OuiNavigable(element, options) {
|
|
11
|
+
this[NAVIGABLE_SYMBOL] = {
|
|
12
|
+
element,
|
|
13
|
+
options,
|
|
14
|
+
active: { index: 0 },
|
|
15
|
+
listeners: [
|
|
16
|
+
on(element, "click", (event) => {
|
|
17
|
+
onClick(this, event);
|
|
18
|
+
}, { passive: false }),
|
|
19
|
+
on(element, "focusin", (event) => {
|
|
20
|
+
onFocusin(this, event);
|
|
21
|
+
}),
|
|
22
|
+
on(element, "keydown", (event) => {
|
|
23
|
+
onKeydown(this, event);
|
|
24
|
+
}, { passive: false })
|
|
25
|
+
],
|
|
26
|
+
orientation: options?.orientation ?? getNavigableOrientation(element, options.vertical)
|
|
27
|
+
};
|
|
28
|
+
setAria(element, "orientation", this[NAVIGABLE_SYMBOL].orientation);
|
|
29
|
+
if (options.role != null) setRole(element, options.role);
|
|
30
|
+
}
|
|
31
|
+
OuiNavigable.prototype.destroy = destroyNavigable;
|
|
32
|
+
OuiNavigable.prototype.navigate = navigateWithNavigable;
|
|
33
|
+
function destroyNavigable() {
|
|
34
|
+
const state = this[NAVIGABLE_SYMBOL];
|
|
35
|
+
const listeners = state.listeners.splice(0);
|
|
36
|
+
for (const listener of listeners) listener();
|
|
37
|
+
state.active.element = void 0;
|
|
38
|
+
state.element = void 0;
|
|
39
|
+
}
|
|
40
|
+
function getItems(container, selector) {
|
|
41
|
+
return filter([...container.querySelectorAll(selector)], isValidItem);
|
|
42
|
+
}
|
|
43
|
+
function getNavigable(element, options) {
|
|
44
|
+
return new OuiNavigable(element, options);
|
|
45
|
+
}
|
|
46
|
+
function getNavigableOrientation(element, vertical, aria) {
|
|
47
|
+
const attribute = aria ?? true ? getAria(element, "orientation") : getAttribute(element, "orientation");
|
|
48
|
+
return NAVIGABLE_ORIENTATIONS.has(attribute) ? attribute : vertical ? NAVIGABLE_ORIENTATION_VERTICAL : NAVIGABLE_ORIENTATION_HORIZONTAL;
|
|
49
|
+
}
|
|
50
|
+
function isValidItem(element) {
|
|
51
|
+
return "disabled" in element ? element.disabled !== true : true;
|
|
52
|
+
}
|
|
53
|
+
function navigateWithNavigable(index, focus) {
|
|
54
|
+
const { element, options } = this[NAVIGABLE_SYMBOL];
|
|
55
|
+
const items = getItems(element, options.selector);
|
|
56
|
+
if (index >= 0 && index < items.length) onNavigate(this, index, items, focus ?? false);
|
|
57
|
+
}
|
|
58
|
+
function onClick(navigable, event) {
|
|
59
|
+
const { active, element, options } = navigable[NAVIGABLE_SYMBOL];
|
|
60
|
+
const item = findAncestor(event, options.selector);
|
|
61
|
+
const items = getItems(element, options.selector);
|
|
62
|
+
const index = items.indexOf(item);
|
|
63
|
+
if (index === -1) return;
|
|
64
|
+
if (index !== active.index) onNavigate(navigable, index, items, false);
|
|
65
|
+
options.onActivate?.(navigable);
|
|
66
|
+
item.focus();
|
|
67
|
+
}
|
|
68
|
+
function onNavigate(navigable, index, items, focus) {
|
|
69
|
+
const { active, options } = navigable[NAVIGABLE_SYMBOL];
|
|
70
|
+
active.element = items[index];
|
|
71
|
+
active.index = index;
|
|
72
|
+
updateNavigableFocus(navigable, focus, items);
|
|
73
|
+
options.onNavigation?.(navigable);
|
|
74
|
+
}
|
|
75
|
+
function onFocusin(navigable, event) {
|
|
76
|
+
const { active, element, options } = navigable[NAVIGABLE_SYMBOL];
|
|
77
|
+
const item = findAncestor(event, options.selector);
|
|
78
|
+
if (!isHTMLOrSVGElement(item) || !isValidItem(item)) return;
|
|
79
|
+
const items = getItems(element, options.selector);
|
|
80
|
+
const index = items.indexOf(item);
|
|
81
|
+
if (index === -1) return;
|
|
82
|
+
active.element = item;
|
|
83
|
+
active.index = index;
|
|
84
|
+
updateNavigableFocus(navigable, false, items);
|
|
85
|
+
}
|
|
86
|
+
function onKeydown(navigable, event) {
|
|
87
|
+
const { active, element, options, orientation } = navigable[NAVIGABLE_SYMBOL];
|
|
88
|
+
const escaped = event.key === "Escape";
|
|
89
|
+
const stopPropagation = options.onShouldDeactivate?.(event, navigable);
|
|
90
|
+
if (escaped || stopPropagation != null) {
|
|
91
|
+
if (escaped || stopPropagation) event.stopPropagation();
|
|
92
|
+
options.onDeactivate?.(event, navigable);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!NAVIGABLE_KEYS_ALL.has(event.key)) return;
|
|
96
|
+
const mustActivate = NAVIGABLE_KEYS_ACTIVATE.has(event.key);
|
|
97
|
+
const shouldActivate = options.onShouldActivate?.(event, navigable) === true;
|
|
98
|
+
if (mustActivate || shouldActivate || options.onPreventNavigation?.(event, navigable) === true) event.stopPropagation();
|
|
99
|
+
if (mustActivate || shouldActivate) {
|
|
100
|
+
options.onActivate?.(navigable);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const items = getItems(element, options.selector);
|
|
104
|
+
const { length } = items;
|
|
105
|
+
if (length === 0) return;
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
let index;
|
|
108
|
+
if (NAVIGABLE_KEYS_ABSOLUTE.has(event.key)) index = event.key === "Home" ? 0 : items.length - 1;
|
|
109
|
+
else if (orientation === (NAVIGABLE_KEYS_HORIZONTAL.has(event.key) ? "horizontal" : "vertical")) {
|
|
110
|
+
if (active.element instanceof HTMLSelectElement) event.preventDefault();
|
|
111
|
+
index = clamp(active.index + (NAVIGABLE_KEYS_NEXT.has(event.key) ? 1 : -1), 0, length - 1, true);
|
|
112
|
+
}
|
|
113
|
+
if (index != null && index !== active.index) onNavigate(navigable, index, items, true);
|
|
114
|
+
}
|
|
115
|
+
function updateNavigableFocus(navigable, focus, items) {
|
|
116
|
+
const { active, element, options } = navigable[NAVIGABLE_SYMBOL];
|
|
117
|
+
const updated = items ?? getItems(element, options.selector);
|
|
118
|
+
const { length } = updated;
|
|
119
|
+
if (length === 0) return;
|
|
120
|
+
for (let index = 0; index < length; index += 1) updated[index].tabIndex = index === active.index ? 0 : -1;
|
|
121
|
+
active.element ??= updated[active.index];
|
|
122
|
+
if (focus) active.element?.focus();
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { getNavigable, getNavigableOrientation, updateNavigableFocus };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as NAVIGABLE_KEYS_NEXT, c as NAVIGABLE_ORIENTATION_HORIZONTAL, d as OuiNavigable, f as OuiNavigableActive, g as OuiNavigableState, h as OuiNavigableOrientation, i as NAVIGABLE_KEYS_HORIZONTAL, l as NAVIGABLE_ORIENTATION_VERTICAL, m as OuiNavigableOptions, n as NAVIGABLE_KEYS_ACTIVATE, o as NAVIGABLE_KEYS_VERTICAL, p as OuiNavigableCallback, r as NAVIGABLE_KEYS_ALL, s as NAVIGABLE_ORIENTATIONS, t as NAVIGABLE_KEYS_ABSOLUTE, u as NAVIGABLE_SYMBOL } from "../../navigable.model-BPOM8DZk.mjs";
|
|
2
|
+
export { NAVIGABLE_KEYS_ABSOLUTE, NAVIGABLE_KEYS_ACTIVATE, NAVIGABLE_KEYS_ALL, NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_NEXT, NAVIGABLE_KEYS_VERTICAL, NAVIGABLE_ORIENTATIONS, NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL, NAVIGABLE_SYMBOL, OuiNavigable, OuiNavigableActive, OuiNavigableCallback, OuiNavigableOptions, OuiNavigableOrientation, OuiNavigableState };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/js/internal/navigable/navigable.model.ts
|
|
2
|
+
const NAVIGABLE_KEYS_ABSOLUTE = /* @__PURE__ */ new Set(["End", "Home"]);
|
|
3
|
+
const NAVIGABLE_KEYS_ACTIVATE = /* @__PURE__ */ new Set(["Enter", " "]);
|
|
4
|
+
const NAVIGABLE_KEYS_HORIZONTAL = /* @__PURE__ */ new Set(["ArrowRight", "ArrowLeft"]);
|
|
5
|
+
const NAVIGABLE_KEYS_VERTICAL = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp"]);
|
|
6
|
+
const NAVIGABLE_KEYS_ALL = /* @__PURE__ */ new Set([
|
|
7
|
+
...NAVIGABLE_KEYS_ABSOLUTE,
|
|
8
|
+
...NAVIGABLE_KEYS_ACTIVATE,
|
|
9
|
+
...NAVIGABLE_KEYS_HORIZONTAL,
|
|
10
|
+
...NAVIGABLE_KEYS_VERTICAL
|
|
11
|
+
]);
|
|
12
|
+
const NAVIGABLE_KEYS_NEXT = /* @__PURE__ */ new Set(["ArrowDown", "ArrowRight"]);
|
|
13
|
+
const NAVIGABLE_ORIENTATION_HORIZONTAL = "horizontal";
|
|
14
|
+
const NAVIGABLE_ORIENTATION_VERTICAL = "vertical";
|
|
15
|
+
const NAVIGABLE_ORIENTATIONS = /* @__PURE__ */ new Set([NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL]);
|
|
16
|
+
const NAVIGABLE_SYMBOL = Symbol("oui-navigable");
|
|
17
|
+
//#endregion
|
|
18
|
+
export { NAVIGABLE_KEYS_ABSOLUTE, NAVIGABLE_KEYS_ACTIVATE, NAVIGABLE_KEYS_ALL, NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_NEXT, NAVIGABLE_KEYS_VERTICAL, NAVIGABLE_ORIENTATIONS, NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL, NAVIGABLE_SYMBOL };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { c as OuiLocalizations, s as OuiLocalizationParameters, u as OuiLocalizationsValues } from "../l10n.model-D6a9frgl.mjs";
|
|
2
|
+
import { GenericCallback } from "@oscarpalmer/atoms/models";
|
|
3
|
+
//#region src/js/l10n/index.d.ts
|
|
4
|
+
export declare function createLocalizations<Localizations extends OuiLocalizationsValues>(defaults: Localizations): OuiLocalizations<Localizations>;
|
|
5
|
+
export declare function getLanguage(element: Element): string;
|
|
6
|
+
export 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;
|
|
7
|
+
export declare function localize<Localizations extends OuiLocalizationsValues, Key extends keyof Localizations, Localization extends Localizations[Key]>(localization: Localization, data: Record<string, unknown>, parameters: OuiLocalizationParameters<Localization>): string;
|
|
8
|
+
export declare function updateLocalizations<Localizations extends OuiLocalizationsValues>(instance: OuiLocalizations<Localizations>, values: Record<string, Partial<Localizations>>, destination: Record<string, Partial<Localizations>>, onAfter?: () => void): void;
|
|
9
|
+
//#endregion
|