@oscarpalmer/oui 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/css/color-picker.css +80 -69
- package/dist/css/listbox.css +169 -0
- package/dist/js/color-picker/color-picker.constants.d.mts +2 -0
- package/dist/js/color-picker/{constants.color-picker.mjs → color-picker.constants.mjs} +7 -4
- package/dist/js/color-picker/{dom.color-picker.d.mts → color-picker.dom.d.mts} +2 -2
- package/dist/js/color-picker/{dom.color-picker.mjs → color-picker.dom.mjs} +33 -16
- package/dist/js/color-picker/{event.color-picker.d.mts → color-picker.event.d.mts} +3 -3
- package/dist/js/color-picker/color-picker.event.mjs +233 -0
- package/dist/js/color-picker/{form.color-picker.d.mts → color-picker.form.d.mts} +2 -2
- package/dist/js/color-picker/{form.color-picker.mjs → color-picker.form.mjs} +9 -8
- package/dist/js/color-picker/color-picker.misc.d.mts +2 -0
- package/dist/js/color-picker/color-picker.misc.mjs +104 -0
- package/dist/js/color-picker/color-picker.model.d.mts +2 -0
- package/dist/js/color-picker/{models.color-picker.mjs → color-picker.model.mjs} +1 -1
- package/dist/js/color-picker/{output.color-picker.d.mts → color-picker.output.d.mts} +2 -2
- package/dist/js/color-picker/{output.color-picker.mjs → color-picker.output.mjs} +19 -18
- package/dist/js/color-picker/color-picker.state.d.mts +8 -0
- package/dist/js/color-picker/color-picker.state.mjs +168 -0
- package/dist/js/color-picker/index.d.mts +172 -2
- package/dist/js/color-picker/index.mjs +66 -59
- package/dist/js/color-picker.constants-BZgXQr5o.d.mts +177 -0
- package/dist/js/color-picker.misc-BIS3R6jk.d.mts +31 -0
- package/dist/js/combobox/combobox.constants.d.mts +2 -0
- package/dist/js/combobox/{constants.combobox.mjs → combobox.constants.mjs} +21 -21
- package/dist/js/combobox/combobox.dom.d.mts +25 -0
- package/dist/js/combobox/{dom.combobox.mjs → combobox.dom.mjs} +51 -49
- package/dist/js/combobox/{event.combobox.d.mts → combobox.event.d.mts} +9 -9
- package/dist/js/combobox/{event.combobox.mjs → combobox.event.mjs} +1 -1
- package/dist/js/combobox/combobox.misc.d.mts +2 -0
- package/dist/js/combobox/combobox.misc.mjs +2 -0
- package/dist/js/combobox/combobox.model.d.mts +2 -0
- package/dist/js/combobox/combobox.state.d.mts +9 -0
- package/dist/js/combobox/combobox.state.mjs +2 -0
- package/dist/js/combobox/index.d.mts +152 -2
- package/dist/js/combobox/index.mjs +54 -55
- package/dist/js/combobox.constants-Hb3bqqQJ.d.mts +19 -0
- package/dist/js/combobox.misc-DRDFk6X8.d.mts +26 -0
- package/dist/js/combobox.model-gjEI2VqZ.d.mts +46 -0
- package/dist/js/{state.combobox-BWDFHwoi.mjs → combobox.state-AstCICiH.mjs} +109 -106
- package/dist/js/dialog/dialog.model.d.mts +2 -0
- package/dist/js/dialog/dialog.model.mjs +11 -0
- package/dist/js/dialog/index.d.mts +12 -0
- package/dist/js/dialog/index.mjs +123 -0
- package/dist/js/dialog.model-HVzYWoDo.d.mts +45 -0
- package/dist/js/floatable/floatable.embedded.d.mts +2 -2
- package/dist/js/floatable/floatable.embedded.mjs +64 -92
- package/dist/js/floatable/floatable.model.d.mts +2 -0
- package/dist/js/floatable/floatable.model.mjs +23 -0
- package/dist/js/floatable/floatable.standalone.d.mts +2 -1
- package/dist/js/floatable.embedded-ncshL3Sa.d.mts +17 -0
- package/dist/js/{floatable.embedded-DQYkXt8X.d.mts → floatable.model-DXsQgoU7.d.mts} +13 -20
- package/dist/js/focus-trap/focus-trap.embedded.d.mts +2 -2
- package/dist/js/focus-trap/focus-trap.embedded.mjs +117 -138
- package/dist/js/focus-trap/focus-trap.model.d.mts +2 -0
- package/dist/js/focus-trap/focus-trap.model.mjs +15 -0
- package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -1
- package/dist/js/focus-trap.embedded-DpcPkP7c.d.mts +13 -0
- package/dist/js/{focus-trap.embedded-CjyFQYow.d.mts → focus-trap.model-CpltX5B5.d.mts} +16 -18
- package/dist/js/index.d.mts +26 -14
- package/dist/js/index.mjs +18 -17
- package/dist/js/internal/attributable.d.mts +1 -1
- package/dist/js/internal/attributable.mjs +3 -2
- package/dist/js/internal/draggable/draggable.model.d.mts +2 -0
- package/dist/js/internal/draggable/draggable.model.mjs +37 -0
- package/dist/js/internal/draggable/index.d.mts +13 -0
- package/dist/js/internal/draggable/index.mjs +243 -0
- package/dist/js/internal/l10n/index.d.mts +5 -0
- package/dist/js/internal/l10n/index.mjs +147 -0
- package/dist/js/internal/l10n/l10n.model.d.mts +2 -0
- package/dist/js/internal/l10n/l10n.model.mjs +12 -0
- package/dist/js/internal/misc.d.mts +3 -2
- package/dist/js/internal/misc.mjs +4 -6
- package/dist/js/internal/navigable/index.d.mts +6 -0
- package/dist/js/internal/navigable/index.mjs +125 -0
- package/dist/js/internal/navigable/navigable.model.d.mts +2 -0
- package/dist/js/internal/navigable/navigable.model.mjs +18 -0
- package/dist/js/internal/option-list/option-list.constants.d.mts +8 -0
- package/dist/js/internal/option-list/option-list.constants.mjs +22 -0
- package/dist/js/internal/option-list/option-list.data.d.mts +21 -0
- package/dist/js/internal/option-list/option-list.data.mjs +2 -0
- package/dist/js/internal/option-list/option-list.dom.d.mts +18 -0
- package/dist/js/internal/option-list/option-list.dom.mjs +2 -0
- package/dist/js/internal/option-list/option-list.event.d.mts +6 -0
- package/dist/js/internal/option-list/option-list.event.mjs +66 -0
- package/dist/js/internal/option-list/option-list.form.d.mts +7 -0
- package/dist/js/internal/option-list/option-list.form.mjs +53 -0
- package/dist/js/internal/option-list/option-list.misc.d.mts +13 -0
- package/dist/js/internal/option-list/option-list.misc.mjs +2 -0
- package/dist/js/internal/option-list/option-list.model.d.mts +2 -0
- package/dist/js/internal/option-list/option-list.state.d.mts +8 -0
- package/dist/js/internal/option-list/option-list.state.mjs +39 -0
- package/dist/js/l10n/index.d.mts +3 -0
- package/dist/js/l10n/index.mjs +2 -0
- package/dist/js/l10n.model-D1E1u35L.d.mts +54 -0
- package/dist/js/listbox/index.d.mts +9 -18
- package/dist/js/listbox/index.mjs +49 -52
- package/dist/js/listbox/listbox.constants.d.mts +2 -0
- package/dist/js/listbox/{constants.listbox.mjs → listbox.constants.mjs} +11 -15
- package/dist/js/listbox/listbox.dom.d.mts +5 -0
- package/dist/js/listbox/listbox.dom.mjs +2 -0
- package/dist/js/listbox/listbox.event.d.mts +9 -0
- package/dist/js/listbox/listbox.event.mjs +2 -0
- package/dist/js/listbox/listbox.misc.d.mts +2 -0
- package/dist/js/listbox/listbox.misc.mjs +2 -0
- package/dist/js/listbox/listbox.model.d.mts +2 -0
- package/dist/js/listbox/listbox.model.mjs +1 -0
- package/dist/js/listbox/listbox.state.d.mts +9 -0
- package/dist/js/listbox/listbox.state.mjs +2 -0
- package/dist/js/listbox.constants-DOBMwKup.d.mts +9 -0
- package/dist/js/listbox.misc-DwfB4Mu_.d.mts +24 -0
- package/dist/js/listbox.model-C0MYWXZe.d.mts +20 -0
- package/dist/js/listbox.state-BrN296BM.mjs +240 -0
- package/dist/js/menu/index.mjs +171 -0
- package/dist/js/menu/menu.model.d.mts +33 -0
- package/dist/js/menu/menu.model.mjs +15 -0
- package/dist/js/movable/movable.embedded.d.mts +2 -2
- package/dist/js/movable/movable.embedded.mjs +77 -86
- package/dist/js/movable/movable.model.d.mts +2 -0
- package/dist/js/movable/movable.model.mjs +12 -0
- package/dist/js/movable/movable.standalone.d.mts +2 -1
- package/dist/js/movable.embedded-C1bDTLGs.d.mts +11 -0
- package/dist/js/movable.model-D9nnPWKk.d.mts +186 -0
- package/dist/js/navigable.model-BqoR6iBv.d.mts +44 -0
- package/dist/js/option-list.data-CgMyUwPc.mjs +441 -0
- package/dist/js/option-list.model-CCPUlPeX.d.mts +169 -0
- package/dist/js/popover/index.d.mts +12 -0
- package/dist/js/{popover.mjs → popover/index.mjs} +41 -51
- package/dist/js/popover/popover.model.d.mts +2 -0
- package/dist/js/popover/popover.model.mjs +12 -0
- package/dist/js/popover.model-DiLdz0Hc.d.mts +38 -0
- package/dist/js/resizable/resizable.embedded.d.mts +2 -2
- package/dist/js/resizable/resizable.embedded.mjs +43 -58
- package/dist/js/resizable/resizable.model.d.mts +2 -0
- package/dist/js/resizable/resizable.model.mjs +21 -0
- package/dist/js/resizable/resizable.standalone.d.mts +2 -1
- package/dist/js/resizable.embedded-BemH-7Re.d.mts +11 -0
- package/dist/js/resizable.model-YEtcC9li.d.mts +46 -0
- package/dist/js/sortable/sortable.embedded.d.mts +2 -2
- package/dist/js/sortable/sortable.embedded.mjs +111 -116
- package/dist/js/sortable/sortable.model.d.mts +2 -0
- package/dist/js/sortable/sortable.model.mjs +24 -0
- package/dist/js/sortable/sortable.standalone.d.mts +2 -1
- package/dist/js/sortable.embedded-CrEGff9k.d.mts +11 -0
- package/dist/js/{splitter.d.mts → splitter/index.d.mts} +6 -4
- package/dist/js/{splitter.mjs → splitter/index.mjs} +90 -128
- package/dist/js/splitter/splitter.model.d.mts +2 -0
- package/dist/js/splitter/splitter.model.mjs +37 -0
- package/dist/js/splitter.model-C24W6eZ7.d.mts +57 -0
- package/dist/js/{tabs.d.mts → tabs/index.d.mts} +8 -8
- package/dist/js/{tabs.mjs → tabs/index.mjs} +58 -58
- package/dist/js/tabs/tabs.model.d.mts +2 -0
- package/dist/js/tabs/tabs.model.mjs +18 -0
- package/dist/js/tabs.model-BHPy7fPo.d.mts +40 -0
- package/dist/js/toolbar/index.mjs +27 -0
- package/dist/js/toolbar/toolbar.model.d.mts +11 -0
- package/dist/js/toolbar/toolbar.model.mjs +7 -0
- package/dist/js/tooltip/index.d.mts +19 -0
- package/dist/js/{tooltip.mjs → tooltip/index.mjs} +61 -86
- package/dist/js/tooltip/tooltip.model.d.mts +2 -0
- package/dist/js/tooltip/tooltip.model.mjs +15 -0
- package/dist/js/tooltip.model-BpNStw5z.d.mts +37 -0
- package/package.json +30 -24
- package/dist/js/color-picker/constants.color-picker.d.mts +0 -2
- package/dist/js/color-picker/event.color-picker.mjs +0 -2
- package/dist/js/color-picker/misc.color-picker.d.mts +0 -2
- package/dist/js/color-picker/misc.color-picker.mjs +0 -2
- package/dist/js/color-picker/models.color-picker.d.mts +0 -2
- package/dist/js/color-picker/state.color-picker.d.mts +0 -8
- package/dist/js/color-picker/state.color-picker.mjs +0 -2
- package/dist/js/combobox/constants.combobox.d.mts +0 -2
- package/dist/js/combobox/dom.combobox.d.mts +0 -26
- package/dist/js/combobox/misc.combobox.d.mts +0 -2
- package/dist/js/combobox/misc.combobox.mjs +0 -2
- package/dist/js/combobox/models.combobox.d.mts +0 -43
- package/dist/js/combobox/state.combobox.d.mts +0 -11
- package/dist/js/combobox/state.combobox.mjs +0 -2
- package/dist/js/constants.color-picker-B-gFjL8m.d.mts +0 -364
- package/dist/js/constants.combobox-8EMRmv09.d.mts +0 -18
- package/dist/js/constants.listbox-DGnX32kv.d.mts +0 -8
- package/dist/js/dialog.d.mts +0 -47
- package/dist/js/dialog.mjs +0 -131
- package/dist/js/draggable-B5-70SZm.d.mts +0 -155
- package/dist/js/event.color-picker-BEpq0Adu.mjs +0 -485
- package/dist/js/index-C5D3-oiI.d.mts +0 -177
- package/dist/js/internal/draggable.d.mts +0 -2
- package/dist/js/internal/draggable.mjs +0 -265
- package/dist/js/internal/listbox/listbox.constants.d.mts +0 -8
- package/dist/js/internal/listbox/listbox.constants.mjs +0 -22
- package/dist/js/internal/listbox/listbox.data.d.mts +0 -19
- package/dist/js/internal/listbox/listbox.data.mjs +0 -2
- package/dist/js/internal/listbox/listbox.dom.d.mts +0 -65
- package/dist/js/internal/listbox/listbox.dom.mjs +0 -2
- package/dist/js/internal/listbox/listbox.event.d.mts +0 -4
- package/dist/js/internal/listbox/listbox.event.mjs +0 -63
- package/dist/js/internal/listbox/listbox.form.d.mts +0 -5
- package/dist/js/internal/listbox/listbox.form.mjs +0 -53
- package/dist/js/internal/listbox/listbox.misc.d.mts +0 -11
- package/dist/js/internal/listbox/listbox.misc.mjs +0 -2
- package/dist/js/internal/listbox/listbox.model.d.mts +0 -2
- package/dist/js/internal/listbox/listbox.state.d.mts +0 -6
- package/dist/js/internal/listbox/listbox.state.mjs +0 -40
- package/dist/js/internal/navigable.d.mts +0 -36
- package/dist/js/internal/navigable.mjs +0 -135
- package/dist/js/l10n-Bn-7RcwR.d.mts +0 -20
- package/dist/js/l10n.d.mts +0 -2
- package/dist/js/l10n.mjs +0 -80
- package/dist/js/listbox/constants.listbox.d.mts +0 -2
- package/dist/js/listbox/event.listbox.d.mts +0 -7
- package/dist/js/listbox/event.listbox.mjs +0 -2
- package/dist/js/listbox/misc.listbox.d.mts +0 -2
- package/dist/js/listbox/misc.listbox.mjs +0 -2
- package/dist/js/listbox/state.listbox.d.mts +0 -10
- package/dist/js/listbox/state.listbox.mjs +0 -2
- package/dist/js/listbox.data-DQ7-x2uY.mjs +0 -425
- package/dist/js/listbox.model-BHPA7GM4.d.mts +0 -125
- package/dist/js/menu.mjs +0 -172
- package/dist/js/misc.listbox-DKB-j0UK.mjs +0 -196
- package/dist/js/misc.listbox-mZMuYOxg.d.mts +0 -20
- package/dist/js/popover.d.mts +0 -38
- package/dist/js/resizable.embedded-dvhdfQgt.d.mts +0 -34
- package/dist/js/toolbar.mjs +0 -31
- package/dist/js/tooltip.d.mts +0 -45
- /package/dist/js/combobox/{models.combobox.mjs → combobox.model.mjs} +0 -0
- /package/dist/js/internal/{listbox/listbox.model.mjs → option-list/option-list.model.mjs} +0 -0
- /package/dist/js/{menu.d.mts → menu/index.d.mts} +0 -0
- /package/dist/js/{toolbar.d.mts → toolbar/index.d.mts} +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { createEmbeddedFloatable } from "./floatable/floatable.embedded.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { createDefaultLocalizations, createLocalizations } from "./internal/l10n/index.mjs";
|
|
3
3
|
import { getAttributeValue, getBooleanAriaValue } from "./internal/misc.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { createComboboxAnchor, createComboboxContent, updateComboboxAutocomplete, updateComboboxSelection,
|
|
9
|
-
import {
|
|
4
|
+
import { OPTION_LIST_KEYS_ACTIVATION, OPTION_LIST_TYPES } from "./internal/option-list/option-list.constants.mjs";
|
|
5
|
+
import { i as filterOptionListOptions, n as filterOptionList, o as setOptionListValues, r as filterOptionListOption, s as toggleOptionListOption, t as applyOptionListSelection, x as generateOptionListIds, y as updateOptionListPreview } from "./option-list.data-CgMyUwPc.mjs";
|
|
6
|
+
import { initializeOptionListState } from "./internal/option-list/option-list.state.mjs";
|
|
7
|
+
import { COMBOBOX_ATTRIBUTE_SELECTION_ITEM, COMBOBOX_AUTOCOMPLETES, COMBOBOX_SYMBOL, COMBOBOX_TAGNAME, comboboxAttributes, comboboxMessages, comboboxSelectors } from "./combobox/combobox.constants.mjs";
|
|
8
|
+
import { createComboboxAnchor, createComboboxContent, updateComboboxAutocomplete, updateComboboxSelection, updateComboboxTabindices } from "./combobox/combobox.dom.mjs";
|
|
9
|
+
import { processOptionListKeydown } from "./internal/option-list/option-list.event.mjs";
|
|
10
10
|
import { setAria } from "@oscarpalmer/toretto/aria";
|
|
11
|
-
import { on } from "@oscarpalmer/toretto/event";
|
|
12
11
|
import { setAttributes } from "@oscarpalmer/toretto/attribute";
|
|
12
|
+
import { on } from "@oscarpalmer/toretto/event";
|
|
13
|
+
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
13
14
|
import { clamp } from "@oscarpalmer/atoms/number";
|
|
14
15
|
import { noop } from "@oscarpalmer/atoms/function";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
//#region src/js/combobox/misc.combobox.ts
|
|
16
|
+
import { getData } from "@oscarpalmer/toretto/data";
|
|
17
|
+
//#region src/js/combobox/combobox.misc.ts
|
|
18
18
|
function getComboboxAutoComplete(element, select) {
|
|
19
19
|
let value;
|
|
20
20
|
if (select) value = "list";
|
|
@@ -35,86 +35,82 @@ function hasTextSelection(element) {
|
|
|
35
35
|
return element instanceof HTMLInputElement && element.selectionStart !== element.selectionEnd;
|
|
36
36
|
}
|
|
37
37
|
function setComboboxLocalizations(first, second) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function updateComboboxLocalizations(instance, destination, first, second) {
|
|
41
|
-
updateLocalizations(instance, typeof first === "string" ? { [first]: second } : first, destination, () => {
|
|
42
|
-
for (const state of comboboxStates.set) {
|
|
43
|
-
updateListboxMessage(state);
|
|
44
|
-
updateListboxValueLabel(state);
|
|
45
|
-
updateComboboxSelectionItems(state);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
38
|
+
if (second === true) comboboxLocalizations.setDefaults(first);
|
|
39
|
+
else comboboxLocalizations.setLanguages(first, second);
|
|
48
40
|
}
|
|
49
41
|
let index = 0;
|
|
50
42
|
//#endregion
|
|
51
|
-
//#region src/js/combobox/event.
|
|
43
|
+
//#region src/js/combobox/combobox.event.ts
|
|
52
44
|
function onComboboxActivation(state) {
|
|
53
|
-
state.floatable.show();
|
|
45
|
+
state.component.floatable.show();
|
|
54
46
|
}
|
|
55
47
|
function onComboboxApply(state, option, _, added, selected) {
|
|
56
48
|
updateComboboxSelection(state, option, added, selected);
|
|
57
49
|
}
|
|
58
50
|
function onComboboxClickContent(event, state) {
|
|
59
51
|
if (state == null) return;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
else
|
|
52
|
+
const { disabled, filter, readonly } = state.component;
|
|
53
|
+
if (disabled) return;
|
|
54
|
+
const option = findAncestor(event, comboboxSelectors.option);
|
|
55
|
+
if (!(option instanceof HTMLElement)) filter.element.focus();
|
|
56
|
+
else if (readonly) onComboboxPreview("set", state, option);
|
|
57
|
+
else toggleOptionListOption(state, option);
|
|
65
58
|
}
|
|
66
59
|
function onComboboxClickDocument(event) {
|
|
67
60
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
68
|
-
const state =
|
|
61
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
69
62
|
if (combobox == null || state == null) return;
|
|
70
|
-
if (findAncestor(event,
|
|
63
|
+
if (findAncestor(event, comboboxSelectors.content) != null) {
|
|
71
64
|
onComboboxClickContent(event, state);
|
|
72
65
|
return;
|
|
73
66
|
}
|
|
67
|
+
const { disabled, floatable, options, readonly } = state.component;
|
|
74
68
|
const label = findAncestor(event, "label");
|
|
75
69
|
if (label != null) {
|
|
76
|
-
if (label === state.label.element && combobox.type === "select") {
|
|
77
|
-
state.anchor.element.focus();
|
|
78
|
-
if (!
|
|
70
|
+
if (label === state.component.label.element && combobox.type === "select") {
|
|
71
|
+
state.component.anchor.element.focus();
|
|
72
|
+
if (!disabled) floatable.show();
|
|
79
73
|
}
|
|
80
74
|
return;
|
|
81
75
|
}
|
|
82
76
|
const selection = findAncestor(event, `[${COMBOBOX_ATTRIBUTE_SELECTION_ITEM}]`);
|
|
83
77
|
if (selection != null) {
|
|
84
|
-
const option =
|
|
85
|
-
if (
|
|
86
|
-
else if (
|
|
87
|
-
else
|
|
78
|
+
const option = options.selected.find((option) => option.id === getData(selection, "option", false));
|
|
79
|
+
if (disabled) state.component.anchor.element.focus();
|
|
80
|
+
else if (readonly) updateComboboxTabindices(state, option);
|
|
81
|
+
else toggleOptionListOption(state, option);
|
|
88
82
|
return;
|
|
89
83
|
}
|
|
90
|
-
if (findAncestor(event,
|
|
91
|
-
|
|
84
|
+
if (findAncestor(event, comboboxSelectors.anchor) != null && !disabled) {
|
|
85
|
+
floatable.show();
|
|
92
86
|
return;
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
89
|
function onComboboxEnter(state) {
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
90
|
+
const { active, anchor, disabled, readonly } = state.component;
|
|
91
|
+
if (disabled || readonly) return;
|
|
92
|
+
if (hasTextSelection(anchor.element)) onComboboxSelection(state, true);
|
|
93
|
+
else toggleOptionListOption(state, active);
|
|
99
94
|
}
|
|
100
95
|
function onComboboxEscape(state) {
|
|
101
|
-
state.floatable.hide();
|
|
96
|
+
state.component.floatable.hide();
|
|
102
97
|
}
|
|
103
98
|
function onComboboxFilter(preview, state, update, active, emit) {
|
|
104
|
-
if (state.autocomplete.none)
|
|
99
|
+
if (state.component.autocomplete.none) applyOptionListSelection({
|
|
105
100
|
state,
|
|
106
101
|
added: false,
|
|
107
102
|
emit: (emit ?? true) && update
|
|
108
103
|
});
|
|
109
|
-
else
|
|
104
|
+
else updateOptionListPreview(preview, state, active);
|
|
110
105
|
}
|
|
111
106
|
function onComboboxFocusout(event) {
|
|
112
107
|
setTimeout(() => {
|
|
113
108
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
114
|
-
const state =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
110
|
+
const component = state?.component;
|
|
111
|
+
if (combobox == null || state == null || component == null || component.disabled || component.readonly || component.type === "select" || component.host === document.activeElement || component.host.contains(document.activeElement)) return;
|
|
112
|
+
const option = filterOptionListOption(state, component.filter.element.value, true);
|
|
113
|
+
applyOptionListSelection({
|
|
118
114
|
option,
|
|
119
115
|
state,
|
|
120
116
|
added: false,
|
|
@@ -124,31 +120,32 @@ function onComboboxFocusout(event) {
|
|
|
124
120
|
}
|
|
125
121
|
function onComboboxInput(event) {
|
|
126
122
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
127
|
-
const state =
|
|
128
|
-
if (combobox != null && state != null && event.target === state.filter.element)
|
|
123
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
124
|
+
if (combobox != null && state != null && event.target === state.component.filter.element) filterOptionList(event.inputType, state);
|
|
129
125
|
}
|
|
130
126
|
function onComboboxKeydown(event) {
|
|
131
127
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
132
|
-
const state =
|
|
128
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
133
129
|
if (combobox == null || state == null) return;
|
|
134
|
-
const item = findAncestor(event,
|
|
130
|
+
const item = findAncestor(event, comboboxSelectors.selectionItem);
|
|
135
131
|
if (item instanceof HTMLElement) onComboboxKeydownSelection(event, state, item);
|
|
136
|
-
else
|
|
132
|
+
else processOptionListKeydown(event, state);
|
|
137
133
|
}
|
|
138
134
|
function onComboboxKeydownSelection(event, state, item) {
|
|
139
|
-
if (
|
|
135
|
+
if (OPTION_LIST_KEYS_ACTIVATION.has(event.key)) {
|
|
140
136
|
event.preventDefault();
|
|
141
137
|
onComboboxRemoveSelection(state, item);
|
|
142
138
|
return;
|
|
143
139
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
140
|
+
const { anchor, disabled, selection } = state.component;
|
|
141
|
+
if (disabled || selection == null) return;
|
|
142
|
+
const { length } = selection.items;
|
|
143
|
+
const index = selection.items.findIndex((selected) => selected.button === item);
|
|
147
144
|
let next;
|
|
148
145
|
switch (event.key) {
|
|
149
146
|
case "ArrowDown":
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
anchor.element.focus();
|
|
148
|
+
anchor.element.click();
|
|
152
149
|
return;
|
|
153
150
|
case "ArrowRight":
|
|
154
151
|
case "ArrowLeft":
|
|
@@ -162,7 +159,7 @@ function onComboboxKeydownSelection(event, state, item) {
|
|
|
162
159
|
if (next == null) return;
|
|
163
160
|
event.preventDefault();
|
|
164
161
|
for (let index = 0; index < length; index += 1) {
|
|
165
|
-
const { button } =
|
|
162
|
+
const { button } = selection.items[index];
|
|
166
163
|
const selected = index === next;
|
|
167
164
|
button.tabIndex = selected ? 0 : -1;
|
|
168
165
|
if (selected) button.focus();
|
|
@@ -172,33 +169,36 @@ function onComboboxPreview(preview, state, active) {
|
|
|
172
169
|
updateComboboxAutocomplete(preview, state, active);
|
|
173
170
|
}
|
|
174
171
|
function onComboboxRemoveSelection(state, item) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
const { disabled, options, readonly } = state.component;
|
|
173
|
+
if (disabled || readonly) return;
|
|
174
|
+
const option = options.selected.find((option) => option.id === getData(item, "option", false));
|
|
175
|
+
if (option != null) toggleOptionListOption(state, option);
|
|
178
176
|
}
|
|
179
177
|
function onComboboxNavigation(preview, state, active) {
|
|
180
|
-
|
|
178
|
+
updateOptionListPreview(preview, state, active);
|
|
181
179
|
}
|
|
182
180
|
function onComboboxSelection(state, hasSelection) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
const { active, anchor, filter } = state.component;
|
|
182
|
+
if (!(hasSelection ?? hasTextSelection(anchor.element))) return;
|
|
183
|
+
filter.value = anchor.element === filter.element ? filter.element.value : "";
|
|
184
|
+
toggleOptionListOption(state, filterOptionListOptions(state) ?? active);
|
|
186
185
|
}
|
|
187
186
|
function onComboboxTab(state) {
|
|
188
187
|
setTimeout(() => {
|
|
189
|
-
|
|
190
|
-
if (
|
|
188
|
+
const { floatable, host, selection } = state.component;
|
|
189
|
+
if (host === document.activeElement) return;
|
|
190
|
+
if (selection?.container.contains(document.activeElement) || !host.contains(document.activeElement)) floatable.hide();
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
function onComboboxToggle(state) {
|
|
194
|
-
if (!state.multiple) state.floatable.hide();
|
|
194
|
+
if (!state.component.multiple) state.component.floatable.hide();
|
|
195
195
|
}
|
|
196
196
|
function preventComboboxActivation(state) {
|
|
197
|
-
return state.floatable.open;
|
|
197
|
+
return state.component.floatable.open;
|
|
198
198
|
}
|
|
199
199
|
function skipComboboxNavigation(state) {
|
|
200
|
-
if (state.floatable.open) return false;
|
|
201
|
-
state.floatable.show();
|
|
200
|
+
if (state.component.floatable.open) return false;
|
|
201
|
+
state.component.floatable.show();
|
|
202
202
|
return true;
|
|
203
203
|
}
|
|
204
204
|
on(document, "click", onComboboxClickDocument);
|
|
@@ -206,19 +206,19 @@ on(document, "focusout", onComboboxFocusout);
|
|
|
206
206
|
on(document, "input", onComboboxInput, { passive: false });
|
|
207
207
|
on(document, "keydown", onComboboxKeydown, { passive: false });
|
|
208
208
|
//#endregion
|
|
209
|
-
//#region src/js/combobox/state.
|
|
210
|
-
function
|
|
209
|
+
//#region src/js/combobox/combobox.state.ts
|
|
210
|
+
function createComponentState(element, state) {
|
|
211
211
|
const select = element.querySelector("select");
|
|
212
|
-
if (select
|
|
212
|
+
if (!(select instanceof HTMLSelectElement) || select.id === "") throw new Error(comboboxMessages.select);
|
|
213
213
|
const label = element.querySelector(`label[for="${select.id}"]`);
|
|
214
|
-
if (label
|
|
214
|
+
if (!(label instanceof HTMLLabelElement)) throw new Error(comboboxMessages.label);
|
|
215
215
|
element.id = select.id;
|
|
216
216
|
const disabled = getBooleanAriaValue(element, "disabled") || select.disabled;
|
|
217
217
|
const multiple = element.multiple || select.multiple;
|
|
218
218
|
const readonly = getBooleanAriaValue(element, "readonly");
|
|
219
219
|
const required = getBooleanAriaValue(element, "required") || select.required;
|
|
220
220
|
const id = getComboboxId();
|
|
221
|
-
const type = multiple ? "select" : getAttributeValue(element, "type",
|
|
221
|
+
const type = multiple ? "select" : getAttributeValue(element, "type", OPTION_LIST_TYPES, "select");
|
|
222
222
|
const autocomplete = getComboboxAutoComplete(element, type === "select");
|
|
223
223
|
setAttributes(element, {
|
|
224
224
|
autocomplete: autocomplete.value,
|
|
@@ -227,7 +227,7 @@ function createComboboxState(element, internals) {
|
|
|
227
227
|
const labelId = label.id;
|
|
228
228
|
label.htmlFor = id;
|
|
229
229
|
label.id = `${id}_label`;
|
|
230
|
-
|
|
230
|
+
generateOptionListIds(id, select);
|
|
231
231
|
const parameters = {
|
|
232
232
|
autocomplete,
|
|
233
233
|
element,
|
|
@@ -236,18 +236,17 @@ function createComboboxState(element, internals) {
|
|
|
236
236
|
multiple,
|
|
237
237
|
select,
|
|
238
238
|
type,
|
|
239
|
-
attributes:
|
|
239
|
+
attributes: comboboxAttributes,
|
|
240
240
|
listbox: false
|
|
241
241
|
};
|
|
242
242
|
const anchor = createComboboxAnchor(parameters);
|
|
243
243
|
const content = createComboboxContent(parameters);
|
|
244
244
|
const { selected } = content.list.options;
|
|
245
|
-
const values = selected.length === 0 ? [""] : selected.map((option) => getData
|
|
246
|
-
|
|
245
|
+
const values = selected.length === 0 ? [""] : selected.map((option) => getData(option, "value", false) ?? "");
|
|
246
|
+
state.component = {
|
|
247
247
|
autocomplete,
|
|
248
248
|
disabled,
|
|
249
249
|
id,
|
|
250
|
-
internals,
|
|
251
250
|
multiple,
|
|
252
251
|
readonly,
|
|
253
252
|
required,
|
|
@@ -258,7 +257,7 @@ function createComboboxState(element, internals) {
|
|
|
258
257
|
container: anchor.container,
|
|
259
258
|
element: anchor.element
|
|
260
259
|
},
|
|
261
|
-
attributes:
|
|
260
|
+
attributes: comboboxAttributes,
|
|
262
261
|
callbacks: comboboxCallbacks,
|
|
263
262
|
content: content.element,
|
|
264
263
|
elements: [
|
|
@@ -280,10 +279,7 @@ function createComboboxState(element, internals) {
|
|
|
280
279
|
list: content.list.element,
|
|
281
280
|
listbox: false,
|
|
282
281
|
listeners: [],
|
|
283
|
-
localizations:
|
|
284
|
-
component: {},
|
|
285
|
-
global: comboboxLocalizations
|
|
286
|
-
},
|
|
282
|
+
localizations: createLocalizations(comboboxLocalizations),
|
|
287
283
|
message: content.message,
|
|
288
284
|
name: element.name,
|
|
289
285
|
options: {
|
|
@@ -297,34 +293,44 @@ function createComboboxState(element, internals) {
|
|
|
297
293
|
label: content.value
|
|
298
294
|
}
|
|
299
295
|
};
|
|
300
|
-
return
|
|
296
|
+
return initializeOptionListState(state, comboboxes, onAttachCombobox);
|
|
297
|
+
}
|
|
298
|
+
function initializeCombobox(element, state) {
|
|
299
|
+
element.tabIndex = -1;
|
|
300
|
+
createComponentState(element, state);
|
|
301
|
+
if (state.form.restored != null) {
|
|
302
|
+
setOptionListValues(state, state.form.restored);
|
|
303
|
+
state.form.restored = void 0;
|
|
304
|
+
}
|
|
301
305
|
}
|
|
302
306
|
function onAttachCombobox(state) {
|
|
303
|
-
const {
|
|
307
|
+
const { component } = state;
|
|
308
|
+
const { anchor, content, filter, listeners, select } = component;
|
|
304
309
|
select.hidden = true;
|
|
305
310
|
select.insertAdjacentElement("afterend", anchor.container ?? anchor.element);
|
|
306
311
|
(anchor.container ?? anchor.element).insertAdjacentElement("afterend", content);
|
|
307
312
|
select.remove();
|
|
308
|
-
|
|
313
|
+
const floatable = createEmbeddedFloatable(anchor.container ?? anchor.element, content, {
|
|
309
314
|
position: "below-start",
|
|
310
315
|
reusable: false
|
|
311
316
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
setAria(anchor.element, "expanded",
|
|
315
|
-
setAria(filter.element, "activedescendant",
|
|
316
|
-
if (
|
|
317
|
+
floatable.update();
|
|
318
|
+
listeners.push(on(content, "toggle", () => {
|
|
319
|
+
setAria(anchor.element, "expanded", floatable.open);
|
|
320
|
+
setAria(filter.element, "activedescendant", floatable.open ? component.active?.id : void 0);
|
|
321
|
+
if (floatable.open) filter.element.focus();
|
|
317
322
|
}));
|
|
323
|
+
component.floatable = floatable;
|
|
318
324
|
}
|
|
319
325
|
function onDetachCombobox(state) {
|
|
320
|
-
const { content, floatable, label, select } = state;
|
|
326
|
+
const { content, floatable, label, select } = state.component;
|
|
321
327
|
floatable.destroy();
|
|
322
|
-
const anchor = state.anchor.container ?? state.anchor.element;
|
|
328
|
+
const anchor = state.component.anchor.container ?? state.component.anchor.element;
|
|
323
329
|
anchor.insertAdjacentElement("beforebegin", select);
|
|
324
330
|
anchor.remove();
|
|
325
331
|
content.remove();
|
|
326
332
|
label.element.htmlFor = select.id;
|
|
327
|
-
label.element.id = state.label.id;
|
|
333
|
+
label.element.id = state.component.label.id;
|
|
328
334
|
select.hidden = false;
|
|
329
335
|
}
|
|
330
336
|
const comboboxCallbacks = {
|
|
@@ -347,7 +353,7 @@ const comboboxCallbacks = {
|
|
|
347
353
|
skipNavigation: skipComboboxNavigation
|
|
348
354
|
}
|
|
349
355
|
};
|
|
350
|
-
const comboboxLocalizations =
|
|
356
|
+
const comboboxLocalizations = createDefaultLocalizations({
|
|
351
357
|
empty: "No results found",
|
|
352
358
|
input: "Please enter a value",
|
|
353
359
|
invalid: "Please select an option from the list",
|
|
@@ -357,9 +363,6 @@ const comboboxLocalizations = getLocalizations({
|
|
|
357
363
|
results: (amount) => `${amount} results available`,
|
|
358
364
|
selected: (amount) => `${amount} selected`
|
|
359
365
|
});
|
|
360
|
-
const
|
|
361
|
-
map: /* @__PURE__ */ new WeakMap(),
|
|
362
|
-
set: /* @__PURE__ */ new Set()
|
|
363
|
-
};
|
|
366
|
+
const comboboxes = /* @__PURE__ */ new Set();
|
|
364
367
|
//#endregion
|
|
365
|
-
export { skipComboboxNavigation as C, setComboboxLocalizations as D, hasTextSelection as E,
|
|
368
|
+
export { skipComboboxNavigation as C, setComboboxLocalizations as D, hasTextSelection as E, preventComboboxActivation as S, getComboboxId as T, onComboboxPreview as _, onDetachCombobox as a, onComboboxTab as b, onComboboxClickContent as c, onComboboxFilter as d, onComboboxFocusout as f, onComboboxNavigation as g, onComboboxKeydownSelection as h, onAttachCombobox as i, onComboboxEnter as l, onComboboxKeydown as m, comboboxes as n, onComboboxActivation as o, onComboboxInput as p, initializeCombobox as r, onComboboxApply as s, comboboxLocalizations as t, onComboboxEscape as u, onComboboxRemoveSelection as v, getComboboxAutoComplete as w, onComboboxToggle as x, onComboboxSelection as y };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DIALOG_SELECTOR_MOVER, c as OuiDialog, i as DIALOG_MESSAGE, l as OuiDialogState, n as DIALOG_ATTRIBUTE_CONTAINER, o as DIALOG_SELECTOR_RESIZER, r as DIALOG_ATTRIBUTE_OPEN, s as DIALOG_SYMBOL, t as DIALOG_ATTRIBUTE, u as dialogs } from "../dialog.model-HVzYWoDo.mjs";
|
|
2
|
+
export { DIALOG_ATTRIBUTE, DIALOG_ATTRIBUTE_CONTAINER, DIALOG_ATTRIBUTE_OPEN, DIALOG_MESSAGE, DIALOG_SELECTOR_MOVER, DIALOG_SELECTOR_RESIZER, DIALOG_SYMBOL, OuiDialog, OuiDialogState, dialogs };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/js/dialog/dialog.model.ts
|
|
2
|
+
const DIALOG_ATTRIBUTE = "oui-dialog";
|
|
3
|
+
const DIALOG_ATTRIBUTE_CONTAINER = `${DIALOG_ATTRIBUTE}-container`;
|
|
4
|
+
const DIALOG_ATTRIBUTE_OPEN = `${DIALOG_ATTRIBUTE}-open`;
|
|
5
|
+
const DIALOG_MESSAGE = "The element must be an instance of HTMLDialogElement";
|
|
6
|
+
const DIALOG_SELECTOR_MOVER = `[${DIALOG_ATTRIBUTE}-mover]`;
|
|
7
|
+
const DIALOG_SELECTOR_RESIZER = `[${DIALOG_ATTRIBUTE}-resizer]`;
|
|
8
|
+
const DIALOG_SYMBOL = Symbol(DIALOG_ATTRIBUTE);
|
|
9
|
+
const dialogs = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DIALOG_ATTRIBUTE, DIALOG_ATTRIBUTE_CONTAINER, DIALOG_ATTRIBUTE_OPEN, DIALOG_MESSAGE, DIALOG_SELECTOR_MOVER, DIALOG_SELECTOR_RESIZER, DIALOG_SYMBOL, dialogs };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { c as OuiDialog, l as OuiDialogState } from "../dialog.model-HVzYWoDo.mjs";
|
|
2
|
+
//#region src/js/dialog/index.d.ts
|
|
3
|
+
declare function OuiDialog(this: OuiDialog, state: OuiDialogState): void;
|
|
4
|
+
/**
|
|
5
|
+
* Get the _OuiDialog_ for an element
|
|
6
|
+
*
|
|
7
|
+
* @param element Element to get _OuiDialog_ for
|
|
8
|
+
* @returns _OuiDialog_ instance
|
|
9
|
+
*/
|
|
10
|
+
declare function getDialog(element: HTMLDialogElement): OuiDialog | undefined;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { type OuiDialog, getDialog };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { getOnBeforeToggleListener } from "../floatable/floatable.embedded.mjs";
|
|
2
|
+
import { attributable } from "../internal/attributable.mjs";
|
|
3
|
+
import { MOVABLE_ATTRIBUTE_HANDLE } from "../movable/movable.model.mjs";
|
|
4
|
+
import { createMovable } from "../movable/movable.embedded.mjs";
|
|
5
|
+
import "../movable/movable.standalone.mjs";
|
|
6
|
+
import { RESIZABLE_ATTRIBUTE_HANDLE } from "../resizable/resizable.model.mjs";
|
|
7
|
+
import { createResizable } from "../resizable/resizable.embedded.mjs";
|
|
8
|
+
import { DIALOG_ATTRIBUTE, DIALOG_ATTRIBUTE_CONTAINER, DIALOG_ATTRIBUTE_OPEN, DIALOG_MESSAGE, DIALOG_SELECTOR_MOVER, DIALOG_SELECTOR_RESIZER, DIALOG_SYMBOL, dialogs } from "./dialog.model.mjs";
|
|
9
|
+
import { getAria, setAria } from "@oscarpalmer/toretto/aria";
|
|
10
|
+
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
11
|
+
import { on } from "@oscarpalmer/toretto/event";
|
|
12
|
+
import { setStyles } from "@oscarpalmer/toretto/style";
|
|
13
|
+
//#region src/js/dialog/index.ts
|
|
14
|
+
function OuiDialog(state) {
|
|
15
|
+
this[DIALOG_SYMBOL] = state;
|
|
16
|
+
}
|
|
17
|
+
OuiDialog.prototype.hide = hideDialog;
|
|
18
|
+
OuiDialog.prototype.show = showDialog;
|
|
19
|
+
Object.defineProperties(OuiDialog.prototype, { open: {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: getOpen,
|
|
22
|
+
set: setOpen
|
|
23
|
+
} });
|
|
24
|
+
function addDialog(element) {
|
|
25
|
+
if (!(element instanceof HTMLDialogElement)) throw new TypeError(DIALOG_MESSAGE);
|
|
26
|
+
if (!dialogs.has(element)) dialogs.set(element, getState(element));
|
|
27
|
+
}
|
|
28
|
+
function destroyDialog(state) {
|
|
29
|
+
state.element.close();
|
|
30
|
+
setAria(state.element, "modal", state.modal);
|
|
31
|
+
state.element.removeAttribute(DIALOG_ATTRIBUTE_OPEN);
|
|
32
|
+
for (const listener of state.listeners) listener();
|
|
33
|
+
state.movable?.destroy();
|
|
34
|
+
state.resizable?.destroy();
|
|
35
|
+
state.dialog = void 0;
|
|
36
|
+
state.element = void 0;
|
|
37
|
+
state.listeners = void 0;
|
|
38
|
+
state.movable = void 0;
|
|
39
|
+
state.resizable = void 0;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the _OuiDialog_ for an element
|
|
43
|
+
*
|
|
44
|
+
* @param element Element to get _OuiDialog_ for
|
|
45
|
+
* @returns _OuiDialog_ instance
|
|
46
|
+
*/
|
|
47
|
+
function getDialog(element) {
|
|
48
|
+
return dialogs.get(element)?.dialog;
|
|
49
|
+
}
|
|
50
|
+
function getMovable(element) {
|
|
51
|
+
const handles = element.querySelectorAll(DIALOG_SELECTOR_MOVER);
|
|
52
|
+
if (handles.length === 0) return;
|
|
53
|
+
for (const handle of handles) setAttribute(handle, MOVABLE_ATTRIBUTE_HANDLE, "");
|
|
54
|
+
return createMovable(element, { container: getAttribute(element, DIALOG_ATTRIBUTE_CONTAINER) });
|
|
55
|
+
}
|
|
56
|
+
function getOpen() {
|
|
57
|
+
return this[DIALOG_SYMBOL].element.open;
|
|
58
|
+
}
|
|
59
|
+
function getResizable(element) {
|
|
60
|
+
const handle = element.querySelector(DIALOG_SELECTOR_RESIZER);
|
|
61
|
+
if (handle == null) return;
|
|
62
|
+
setAttribute(handle, RESIZABLE_ATTRIBUTE_HANDLE, "");
|
|
63
|
+
return createResizable(element);
|
|
64
|
+
}
|
|
65
|
+
function getState(element) {
|
|
66
|
+
const state = {
|
|
67
|
+
element,
|
|
68
|
+
dialog: void 0,
|
|
69
|
+
listeners: [getOnBeforeToggleListener(element), on(element, "toggle", (event) => {
|
|
70
|
+
const { source } = event;
|
|
71
|
+
if (element.open) {
|
|
72
|
+
const modal = source instanceof HTMLButtonElement && source.command === "show-modal" || element.matches(":modal");
|
|
73
|
+
setAria(element, "modal", modal);
|
|
74
|
+
setAttribute(element, DIALOG_ATTRIBUTE_OPEN, "");
|
|
75
|
+
element.focus();
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
state.resizable?.set();
|
|
78
|
+
}, 500);
|
|
79
|
+
} else {
|
|
80
|
+
setAttribute(element, DIALOG_ATTRIBUTE_OPEN);
|
|
81
|
+
setAria(element, "modal", state.modal);
|
|
82
|
+
setStyles(element, {
|
|
83
|
+
inset: "",
|
|
84
|
+
position: "",
|
|
85
|
+
transform: ""
|
|
86
|
+
});
|
|
87
|
+
state.resizable?.reset();
|
|
88
|
+
}
|
|
89
|
+
})],
|
|
90
|
+
modal: getAria(element, "modal") === true || element.matches(":modal")
|
|
91
|
+
};
|
|
92
|
+
state.dialog = new OuiDialog(state);
|
|
93
|
+
state.movable = getMovable(element);
|
|
94
|
+
state.resizable = getResizable(element);
|
|
95
|
+
return state;
|
|
96
|
+
}
|
|
97
|
+
function hideDialog(first, second) {
|
|
98
|
+
const { element } = this[DIALOG_SYMBOL];
|
|
99
|
+
if (!element.open) return;
|
|
100
|
+
if (first === true) element.requestClose(typeof second === "string" ? second : void 0);
|
|
101
|
+
else element.close(typeof first === "string" ? first : void 0);
|
|
102
|
+
}
|
|
103
|
+
function removeDialog(element) {
|
|
104
|
+
const state = dialogs.get(element);
|
|
105
|
+
if (state == null) return;
|
|
106
|
+
destroyDialog(state);
|
|
107
|
+
dialogs.delete(element);
|
|
108
|
+
}
|
|
109
|
+
function setOpen(value) {
|
|
110
|
+
if (value === true) this.show();
|
|
111
|
+
else if (value === false) this.hide();
|
|
112
|
+
}
|
|
113
|
+
function showDialog(value) {
|
|
114
|
+
const { element } = this[DIALOG_SYMBOL];
|
|
115
|
+
if (element == null || element.open) return;
|
|
116
|
+
const isModal = value !== false;
|
|
117
|
+
setAria(element, "modal", isModal);
|
|
118
|
+
if (isModal) element.showModal();
|
|
119
|
+
else element.show();
|
|
120
|
+
}
|
|
121
|
+
attributable(DIALOG_ATTRIBUTE, addDialog, removeDialog);
|
|
122
|
+
//#endregion
|
|
123
|
+
export { getDialog };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { u as OuiMovable } from "./movable.model-D9nnPWKk.mjs";
|
|
2
|
+
import { n as OuiResizable } from "./resizable.model-YEtcC9li.mjs";
|
|
3
|
+
import { RemovableEventListener } from "@oscarpalmer/toretto/models";
|
|
4
|
+
//#region src/js/dialog/dialog.model.d.ts
|
|
5
|
+
type OuiDialog = {
|
|
6
|
+
[DIALOG_SYMBOL]: OuiDialogState;
|
|
7
|
+
/**
|
|
8
|
+
* Is the dialog open?
|
|
9
|
+
*/
|
|
10
|
+
get open(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Open or close the dialog
|
|
13
|
+
*/
|
|
14
|
+
set open(value: boolean);
|
|
15
|
+
/**
|
|
16
|
+
* Closes the dialog by request
|
|
17
|
+
*/
|
|
18
|
+
hide(request: true, value?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Closes the dialog
|
|
21
|
+
*/
|
|
22
|
+
hide(value?: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Opens the dialog
|
|
25
|
+
*/
|
|
26
|
+
show(modal?: boolean): void;
|
|
27
|
+
};
|
|
28
|
+
type OuiDialogState = {
|
|
29
|
+
dialog: OuiDialog;
|
|
30
|
+
element: HTMLDialogElement;
|
|
31
|
+
listeners: RemovableEventListener[];
|
|
32
|
+
modal: boolean;
|
|
33
|
+
movable?: OuiMovable;
|
|
34
|
+
resizable?: OuiResizable;
|
|
35
|
+
};
|
|
36
|
+
declare const DIALOG_ATTRIBUTE = "oui-dialog";
|
|
37
|
+
declare const DIALOG_ATTRIBUTE_CONTAINER: string;
|
|
38
|
+
declare const DIALOG_ATTRIBUTE_OPEN: string;
|
|
39
|
+
declare const DIALOG_MESSAGE = "The element must be an instance of HTMLDialogElement";
|
|
40
|
+
declare const DIALOG_SELECTOR_MOVER: string;
|
|
41
|
+
declare const DIALOG_SELECTOR_RESIZER: string;
|
|
42
|
+
declare const DIALOG_SYMBOL: unique symbol;
|
|
43
|
+
declare const dialogs: WeakMap<Element, OuiDialogState>;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { DIALOG_SELECTOR_MOVER as a, OuiDialog as c, DIALOG_MESSAGE as i, OuiDialogState as l, DIALOG_ATTRIBUTE_CONTAINER as n, DIALOG_SELECTOR_RESIZER as o, DIALOG_ATTRIBUTE_OPEN as r, DIALOG_SYMBOL as s, DIALOG_ATTRIBUTE as t, dialogs as u };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { i as removeFloatable, n as createFloatable, r as getOnBeforeToggleListener, t as createEmbeddedFloatable } from "../floatable.embedded-ncshL3Sa.mjs";
|
|
2
|
+
export { createEmbeddedFloatable, createFloatable, getOnBeforeToggleListener, removeFloatable };
|