@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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { r as OuiListboxAutoCompleteType, t as OuiListboxAttributes } from "./listbox.model-CuBOj4qe.mjs";
|
|
2
|
+
//#region src/js/combobox/combobox.constants.d.ts
|
|
3
|
+
declare const COMBOBOX_TAGNAME = "oui-combobox";
|
|
4
|
+
declare const COMBOBOX_ATTRIBUTE_ANCHOR: string;
|
|
5
|
+
declare const COMBOBOX_ATTRIBUTE_SELECTION: string;
|
|
6
|
+
declare const COMBOBOX_ATTRIBUTE_SELECTION_ITEM: string;
|
|
7
|
+
declare const COMBOBOX_AUTOCOMPLETES: Set<OuiListboxAutoCompleteType>;
|
|
8
|
+
declare const COMBOBOX_SYMBOL: unique symbol;
|
|
9
|
+
declare const comboboxAttributes: OuiListboxAttributes;
|
|
10
|
+
declare const messageLabel: string;
|
|
11
|
+
declare const messageSelect: string;
|
|
12
|
+
declare const comboboxMessages: Record<string, string>;
|
|
13
|
+
declare const selectorAnchor: string;
|
|
14
|
+
declare const selectorContent: string;
|
|
15
|
+
declare const selectorOption: string;
|
|
16
|
+
declare const selectorSelectionItem: string;
|
|
17
|
+
declare const comboboxSelectors: Record<string, string>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { COMBOBOX_SYMBOL as a, comboboxMessages as c, messageSelect as d, selectorAnchor as f, selectorSelectionItem as h, COMBOBOX_AUTOCOMPLETES as i, comboboxSelectors as l, selectorOption as m, COMBOBOX_ATTRIBUTE_SELECTION as n, COMBOBOX_TAGNAME as o, selectorContent as p, COMBOBOX_ATTRIBUTE_SELECTION_ITEM as r, comboboxAttributes as s, COMBOBOX_ATTRIBUTE_ANCHOR as t, messageLabel as u };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { c as OuiLocalizations } from "./l10n.model-D6a9frgl.mjs";
|
|
2
|
+
import { n as OuiListboxAutoComplete, o as OuiListboxLocalizations } from "./listbox.model-CuBOj4qe.mjs";
|
|
3
|
+
//#region src/js/combobox/combobox.misc.d.ts
|
|
4
|
+
declare function getComboboxAutoComplete(element: HTMLElement, select: boolean): OuiListboxAutoComplete;
|
|
5
|
+
declare function getComboboxId(): string;
|
|
6
|
+
declare function hasTextSelection(element: HTMLElement): element is HTMLInputElement;
|
|
7
|
+
/**
|
|
8
|
+
* Set combobox localizations for a specific language
|
|
9
|
+
*
|
|
10
|
+
* @param language Language code
|
|
11
|
+
* @param localizations Localizations for language
|
|
12
|
+
*/
|
|
13
|
+
declare function setComboboxLocalizations(language: string, localizations: Partial<OuiListboxLocalizations>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Set combobox localizations for one or more languages
|
|
16
|
+
*
|
|
17
|
+
* @param localizations Localizations for one or more languages
|
|
18
|
+
*/
|
|
19
|
+
declare function setComboboxLocalizations(localizations: Record<string, Partial<OuiListboxLocalizations>>): void;
|
|
20
|
+
declare function updateComboboxLocalizations(instance: OuiLocalizations<OuiListboxLocalizations>, destination: Record<string, Partial<OuiListboxLocalizations>>, first: string | Record<string, Partial<OuiListboxLocalizations>>, second?: Partial<OuiListboxLocalizations>): void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { updateComboboxLocalizations as a, setComboboxLocalizations as i, getComboboxId as n, hasTextSelection as r, getComboboxAutoComplete as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//#region src/js/combobox/
|
|
1
|
+
import { c as OuiFloatable } from "./floatable.model-DXsQgoU7.mjs";
|
|
2
|
+
import { f as OuiListboxType, l as OuiListboxState } from "./listbox.model-CuBOj4qe.mjs";
|
|
3
|
+
//#region src/js/combobox/combobox.model.d.ts
|
|
4
4
|
type OuiComboboxAnchor = {
|
|
5
5
|
container?: HTMLElement;
|
|
6
6
|
element: HTMLElement;
|
|
@@ -30,15 +30,15 @@ type OuiComboboxSelectionItem = {
|
|
|
30
30
|
button: HTMLButtonElement;
|
|
31
31
|
element: HTMLElement;
|
|
32
32
|
};
|
|
33
|
-
type OuiComboboxState = {
|
|
33
|
+
type OuiComboboxState = OuiListboxState<{
|
|
34
34
|
anchor: OuiComboboxAnchor;
|
|
35
35
|
floatable: OuiFloatable;
|
|
36
36
|
selection?: OuiComboboxSelection;
|
|
37
37
|
type: OuiListboxType;
|
|
38
|
-
}
|
|
38
|
+
}>;
|
|
39
39
|
type OuiComboboxValues = {
|
|
40
40
|
current: string[];
|
|
41
41
|
initial: string[];
|
|
42
42
|
};
|
|
43
43
|
//#endregion
|
|
44
|
-
export {
|
|
44
|
+
export { OuiComboboxOptions as a, OuiComboboxState as c, OuiComboboxLabel as i, OuiComboboxValues as l, OuiComboboxFilter as n, OuiComboboxSelection as o, OuiComboboxGroup as r, OuiComboboxSelectionItem as s, OuiComboboxAnchor as t };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { createEmbeddedFloatable } from "./floatable/floatable.embedded.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { LISTBOX_KEYS, LISTBOX_TYPES } from "./internal/listbox/listbox.constants.mjs";
|
|
4
|
-
import { b as updateListboxValueLabel, i as filterListboxOptions, n as filterListbox, r as filterListboxOption, s as toggleListboxOption, t as applyListboxSelection, v as updateListboxMessage, x as generateListboxIds, y as updateListboxPreview } from "./listbox.data-C7CRa5Ya.mjs";
|
|
5
|
-
import { initializeListboxState } from "./internal/listbox/listbox.state.mjs";
|
|
6
|
-
import { COMBOBOX_ATTRIBUTES, COMBOBOX_ATTRIBUTE_SELECTION_ITEM, COMBOBOX_AUTOCOMPLETES, COMBOBOX_MESSAGES, COMBOBOX_SELECTORS, COMBOBOX_TAGNAME } from "./combobox/constants.combobox.mjs";
|
|
2
|
+
import { createLocalizations, updateLocalizations } from "./l10n/index.mjs";
|
|
7
3
|
import { getAttributeValue, getBooleanAriaValue } from "./internal/misc.mjs";
|
|
8
|
-
import {
|
|
4
|
+
import { LISTBOX_KEYS_ACTIVATION, LISTBOX_TYPES } from "./internal/listbox/listbox.constants.mjs";
|
|
5
|
+
import { b as updateListboxValueLabel, i as filterListboxOptions, n as filterListbox, o as setListboxValues, r as filterListboxOption, s as toggleListboxOption, t as applyListboxSelection, v as updateListboxMessage, x as generateListboxIds, y as updateListboxPreview } from "./listbox.data-BQyZGKgr.mjs";
|
|
6
|
+
import { initializeListboxState } from "./internal/listbox/listbox.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, updateComboboxSelectionItems, updateComboboxTabindices } from "./combobox/combobox.dom.mjs";
|
|
9
9
|
import { processListboxKeydown } from "./internal/listbox/listbox.event.mjs";
|
|
10
|
-
import { clamp } from "@oscarpalmer/atoms/number";
|
|
11
10
|
import { setAria } from "@oscarpalmer/toretto/aria";
|
|
12
11
|
import { setAttributes } from "@oscarpalmer/toretto/attribute";
|
|
13
12
|
import { on } from "@oscarpalmer/toretto/event";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
14
|
+
import { clamp } from "@oscarpalmer/atoms/number";
|
|
16
15
|
import { noop } from "@oscarpalmer/atoms/function";
|
|
17
|
-
|
|
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";
|
|
@@ -39,7 +39,7 @@ function setComboboxLocalizations(first, second) {
|
|
|
39
39
|
}
|
|
40
40
|
function updateComboboxLocalizations(instance, destination, first, second) {
|
|
41
41
|
updateLocalizations(instance, typeof first === "string" ? { [first]: second } : first, destination, () => {
|
|
42
|
-
for (const state of
|
|
42
|
+
for (const state of comboboxes) {
|
|
43
43
|
updateListboxMessage(state);
|
|
44
44
|
updateListboxValueLabel(state);
|
|
45
45
|
updateComboboxSelectionItems(state);
|
|
@@ -48,60 +48,63 @@ function updateComboboxLocalizations(instance, destination, first, second) {
|
|
|
48
48
|
}
|
|
49
49
|
let index = 0;
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region src/js/combobox/event.
|
|
51
|
+
//#region src/js/combobox/combobox.event.ts
|
|
52
52
|
function onComboboxActivation(state) {
|
|
53
|
-
state.floatable.show();
|
|
53
|
+
state.component.floatable.show();
|
|
54
54
|
}
|
|
55
55
|
function onComboboxApply(state, option, _, added, selected) {
|
|
56
56
|
updateComboboxSelection(state, option, added, selected);
|
|
57
57
|
}
|
|
58
58
|
function onComboboxClickContent(event, state) {
|
|
59
59
|
if (state == null) return;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const { disabled, filter, readonly } = state.component;
|
|
61
|
+
if (disabled) return;
|
|
62
|
+
const option = findAncestor(event, comboboxSelectors.option);
|
|
63
|
+
if (!(option instanceof HTMLElement)) filter.element.focus();
|
|
64
|
+
else if (readonly) onComboboxPreview("set", state, option);
|
|
64
65
|
else toggleListboxOption(state, option);
|
|
65
66
|
}
|
|
66
67
|
function onComboboxClickDocument(event) {
|
|
67
68
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
68
|
-
const state =
|
|
69
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
69
70
|
if (combobox == null || state == null) return;
|
|
70
|
-
if (findAncestor(event,
|
|
71
|
+
if (findAncestor(event, comboboxSelectors.content) != null) {
|
|
71
72
|
onComboboxClickContent(event, state);
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
75
|
+
const { disabled, floatable, options, readonly } = state.component;
|
|
74
76
|
const label = findAncestor(event, "label");
|
|
75
77
|
if (label != null) {
|
|
76
|
-
if (label === state.label.element && combobox.type === "select") {
|
|
77
|
-
state.anchor.element.focus();
|
|
78
|
-
if (!
|
|
78
|
+
if (label === state.component.label.element && combobox.type === "select") {
|
|
79
|
+
state.component.anchor.element.focus();
|
|
80
|
+
if (!disabled) floatable.show();
|
|
79
81
|
}
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
82
84
|
const selection = findAncestor(event, `[${COMBOBOX_ATTRIBUTE_SELECTION_ITEM}]`);
|
|
83
85
|
if (selection != null) {
|
|
84
|
-
const option =
|
|
85
|
-
if (
|
|
86
|
-
else if (
|
|
86
|
+
const option = options.selected.find((option) => option.id === getData(selection, "option", false));
|
|
87
|
+
if (disabled) state.component.anchor.element.focus();
|
|
88
|
+
else if (readonly) updateComboboxTabindices(state, option);
|
|
87
89
|
else toggleListboxOption(state, option);
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
|
-
if (findAncestor(event,
|
|
91
|
-
|
|
92
|
+
if (findAncestor(event, comboboxSelectors.anchor) != null && !disabled) {
|
|
93
|
+
floatable.show();
|
|
92
94
|
return;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
function onComboboxEnter(state) {
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
98
|
+
const { active, anchor, disabled, readonly } = state.component;
|
|
99
|
+
if (disabled || readonly) return;
|
|
100
|
+
if (hasTextSelection(anchor.element)) onComboboxSelection(state, true);
|
|
101
|
+
else toggleListboxOption(state, active);
|
|
99
102
|
}
|
|
100
103
|
function onComboboxEscape(state) {
|
|
101
|
-
state.floatable.hide();
|
|
104
|
+
state.component.floatable.hide();
|
|
102
105
|
}
|
|
103
106
|
function onComboboxFilter(preview, state, update, active, emit) {
|
|
104
|
-
if (state.autocomplete.none) applyListboxSelection({
|
|
107
|
+
if (state.component.autocomplete.none) applyListboxSelection({
|
|
105
108
|
state,
|
|
106
109
|
added: false,
|
|
107
110
|
emit: (emit ?? true) && update
|
|
@@ -111,9 +114,10 @@ function onComboboxFilter(preview, state, update, active, emit) {
|
|
|
111
114
|
function onComboboxFocusout(event) {
|
|
112
115
|
setTimeout(() => {
|
|
113
116
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
114
|
-
const state =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
118
|
+
const component = state?.component;
|
|
119
|
+
if (combobox == null || state == null || component == null || component.disabled || component.readonly || component.type === "select" || component.host === document.activeElement || component.host.contains(document.activeElement)) return;
|
|
120
|
+
const option = filterListboxOption(state, component.filter.element.value, true);
|
|
117
121
|
applyListboxSelection({
|
|
118
122
|
option,
|
|
119
123
|
state,
|
|
@@ -124,31 +128,32 @@ function onComboboxFocusout(event) {
|
|
|
124
128
|
}
|
|
125
129
|
function onComboboxInput(event) {
|
|
126
130
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
127
|
-
const state =
|
|
128
|
-
if (combobox != null && state != null && event.target === state.filter.element) filterListbox(event.inputType, state);
|
|
131
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
132
|
+
if (combobox != null && state != null && event.target === state.component.filter.element) filterListbox(event.inputType, state);
|
|
129
133
|
}
|
|
130
134
|
function onComboboxKeydown(event) {
|
|
131
135
|
const combobox = findAncestor(event, COMBOBOX_TAGNAME);
|
|
132
|
-
const state =
|
|
136
|
+
const state = combobox?.[COMBOBOX_SYMBOL];
|
|
133
137
|
if (combobox == null || state == null) return;
|
|
134
|
-
const item = findAncestor(event,
|
|
138
|
+
const item = findAncestor(event, comboboxSelectors.selectionItem);
|
|
135
139
|
if (item instanceof HTMLElement) onComboboxKeydownSelection(event, state, item);
|
|
136
140
|
else processListboxKeydown(event, state);
|
|
137
141
|
}
|
|
138
142
|
function onComboboxKeydownSelection(event, state, item) {
|
|
139
|
-
if (
|
|
143
|
+
if (LISTBOX_KEYS_ACTIVATION.has(event.key)) {
|
|
140
144
|
event.preventDefault();
|
|
141
145
|
onComboboxRemoveSelection(state, item);
|
|
142
146
|
return;
|
|
143
147
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
148
|
+
const { anchor, disabled, selection } = state.component;
|
|
149
|
+
if (disabled || selection == null) return;
|
|
150
|
+
const { length } = selection.items;
|
|
151
|
+
const index = selection.items.findIndex((selected) => selected.button === item);
|
|
147
152
|
let next;
|
|
148
153
|
switch (event.key) {
|
|
149
154
|
case "ArrowDown":
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
anchor.element.focus();
|
|
156
|
+
anchor.element.click();
|
|
152
157
|
return;
|
|
153
158
|
case "ArrowRight":
|
|
154
159
|
case "ArrowLeft":
|
|
@@ -162,7 +167,7 @@ function onComboboxKeydownSelection(event, state, item) {
|
|
|
162
167
|
if (next == null) return;
|
|
163
168
|
event.preventDefault();
|
|
164
169
|
for (let index = 0; index < length; index += 1) {
|
|
165
|
-
const { button } =
|
|
170
|
+
const { button } = selection.items[index];
|
|
166
171
|
const selected = index === next;
|
|
167
172
|
button.tabIndex = selected ? 0 : -1;
|
|
168
173
|
if (selected) button.focus();
|
|
@@ -172,33 +177,36 @@ function onComboboxPreview(preview, state, active) {
|
|
|
172
177
|
updateComboboxAutocomplete(preview, state, active);
|
|
173
178
|
}
|
|
174
179
|
function onComboboxRemoveSelection(state, item) {
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
const { disabled, options, readonly } = state.component;
|
|
181
|
+
if (disabled || readonly) return;
|
|
182
|
+
const option = options.selected.find((option) => option.id === getData(item, "option", false));
|
|
177
183
|
if (option != null) toggleListboxOption(state, option);
|
|
178
184
|
}
|
|
179
185
|
function onComboboxNavigation(preview, state, active) {
|
|
180
186
|
updateListboxPreview(preview, state, active);
|
|
181
187
|
}
|
|
182
188
|
function onComboboxSelection(state, hasSelection) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
const { active, anchor, filter } = state.component;
|
|
190
|
+
if (!(hasSelection ?? hasTextSelection(anchor.element))) return;
|
|
191
|
+
filter.value = anchor.element === filter.element ? filter.element.value : "";
|
|
192
|
+
toggleListboxOption(state, filterListboxOptions(state) ?? active);
|
|
186
193
|
}
|
|
187
194
|
function onComboboxTab(state) {
|
|
188
195
|
setTimeout(() => {
|
|
189
|
-
|
|
190
|
-
if (
|
|
196
|
+
const { floatable, host, selection } = state.component;
|
|
197
|
+
if (host === document.activeElement) return;
|
|
198
|
+
if (selection?.container.contains(document.activeElement) || !host.contains(document.activeElement)) floatable.hide();
|
|
191
199
|
});
|
|
192
200
|
}
|
|
193
201
|
function onComboboxToggle(state) {
|
|
194
|
-
if (!state.multiple) state.floatable.hide();
|
|
202
|
+
if (!state.component.multiple) state.component.floatable.hide();
|
|
195
203
|
}
|
|
196
204
|
function preventComboboxActivation(state) {
|
|
197
|
-
return state.floatable.open;
|
|
205
|
+
return state.component.floatable.open;
|
|
198
206
|
}
|
|
199
207
|
function skipComboboxNavigation(state) {
|
|
200
|
-
if (state.floatable.open) return false;
|
|
201
|
-
state.floatable.show();
|
|
208
|
+
if (state.component.floatable.open) return false;
|
|
209
|
+
state.component.floatable.show();
|
|
202
210
|
return true;
|
|
203
211
|
}
|
|
204
212
|
on(document, "click", onComboboxClickDocument);
|
|
@@ -206,12 +214,12 @@ on(document, "focusout", onComboboxFocusout);
|
|
|
206
214
|
on(document, "input", onComboboxInput, { passive: false });
|
|
207
215
|
on(document, "keydown", onComboboxKeydown, { passive: false });
|
|
208
216
|
//#endregion
|
|
209
|
-
//#region src/js/combobox/state.
|
|
210
|
-
function
|
|
217
|
+
//#region src/js/combobox/combobox.state.ts
|
|
218
|
+
function createComponentState(element, state) {
|
|
211
219
|
const select = element.querySelector("select");
|
|
212
|
-
if (select == null || select.id === "") throw new Error(
|
|
220
|
+
if (select == null || select.id === "") throw new Error(comboboxMessages.select);
|
|
213
221
|
const label = element.querySelector(`label[for="${select.id}"]`);
|
|
214
|
-
if (label == null) throw new Error(
|
|
222
|
+
if (label == null) throw new Error(comboboxMessages.label);
|
|
215
223
|
element.id = select.id;
|
|
216
224
|
const disabled = getBooleanAriaValue(element, "disabled") || select.disabled;
|
|
217
225
|
const multiple = element.multiple || select.multiple;
|
|
@@ -236,18 +244,17 @@ function createComboboxState(element, internals) {
|
|
|
236
244
|
multiple,
|
|
237
245
|
select,
|
|
238
246
|
type,
|
|
239
|
-
attributes:
|
|
247
|
+
attributes: comboboxAttributes,
|
|
240
248
|
listbox: false
|
|
241
249
|
};
|
|
242
250
|
const anchor = createComboboxAnchor(parameters);
|
|
243
251
|
const content = createComboboxContent(parameters);
|
|
244
252
|
const { selected } = content.list.options;
|
|
245
253
|
const values = selected.length === 0 ? [""] : selected.map((option) => getData(option, "value", false) ?? "");
|
|
246
|
-
|
|
254
|
+
state.component = {
|
|
247
255
|
autocomplete,
|
|
248
256
|
disabled,
|
|
249
257
|
id,
|
|
250
|
-
internals,
|
|
251
258
|
multiple,
|
|
252
259
|
readonly,
|
|
253
260
|
required,
|
|
@@ -258,7 +265,7 @@ function createComboboxState(element, internals) {
|
|
|
258
265
|
container: anchor.container,
|
|
259
266
|
element: anchor.element
|
|
260
267
|
},
|
|
261
|
-
attributes:
|
|
268
|
+
attributes: comboboxAttributes,
|
|
262
269
|
callbacks: comboboxCallbacks,
|
|
263
270
|
content: content.element,
|
|
264
271
|
elements: [
|
|
@@ -297,34 +304,44 @@ function createComboboxState(element, internals) {
|
|
|
297
304
|
label: content.value
|
|
298
305
|
}
|
|
299
306
|
};
|
|
300
|
-
return initializeListboxState(state,
|
|
307
|
+
return initializeListboxState(state, comboboxes, onAttachCombobox);
|
|
308
|
+
}
|
|
309
|
+
function initializeCombobox(element, state) {
|
|
310
|
+
element.tabIndex = -1;
|
|
311
|
+
createComponentState(element, state);
|
|
312
|
+
if (state.form.restored != null) {
|
|
313
|
+
setListboxValues(state, state.form.restored);
|
|
314
|
+
state.form.restored = void 0;
|
|
315
|
+
}
|
|
301
316
|
}
|
|
302
317
|
function onAttachCombobox(state) {
|
|
303
|
-
const {
|
|
318
|
+
const { component } = state;
|
|
319
|
+
const { anchor, content, filter, listeners, select } = component;
|
|
304
320
|
select.hidden = true;
|
|
305
321
|
select.insertAdjacentElement("afterend", anchor.container ?? anchor.element);
|
|
306
322
|
(anchor.container ?? anchor.element).insertAdjacentElement("afterend", content);
|
|
307
323
|
select.remove();
|
|
308
|
-
|
|
324
|
+
const floatable = createEmbeddedFloatable(anchor.container ?? anchor.element, content, {
|
|
309
325
|
position: "below-start",
|
|
310
326
|
reusable: false
|
|
311
327
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
setAria(anchor.element, "expanded",
|
|
315
|
-
setAria(filter.element, "activedescendant",
|
|
316
|
-
if (
|
|
328
|
+
floatable.update();
|
|
329
|
+
listeners.push(on(content, "toggle", () => {
|
|
330
|
+
setAria(anchor.element, "expanded", floatable.open);
|
|
331
|
+
setAria(filter.element, "activedescendant", floatable.open ? component.active?.id : void 0);
|
|
332
|
+
if (floatable.open) filter.element.focus();
|
|
317
333
|
}));
|
|
334
|
+
component.floatable = floatable;
|
|
318
335
|
}
|
|
319
336
|
function onDetachCombobox(state) {
|
|
320
|
-
const { content, floatable, label, select } = state;
|
|
337
|
+
const { content, floatable, label, select } = state.component;
|
|
321
338
|
floatable.destroy();
|
|
322
|
-
const anchor = state.anchor.container ?? state.anchor.element;
|
|
339
|
+
const anchor = state.component.anchor.container ?? state.component.anchor.element;
|
|
323
340
|
anchor.insertAdjacentElement("beforebegin", select);
|
|
324
341
|
anchor.remove();
|
|
325
342
|
content.remove();
|
|
326
343
|
label.element.htmlFor = select.id;
|
|
327
|
-
label.element.id = state.label.id;
|
|
344
|
+
label.element.id = state.component.label.id;
|
|
328
345
|
select.hidden = false;
|
|
329
346
|
}
|
|
330
347
|
const comboboxCallbacks = {
|
|
@@ -347,7 +364,7 @@ const comboboxCallbacks = {
|
|
|
347
364
|
skipNavigation: skipComboboxNavigation
|
|
348
365
|
}
|
|
349
366
|
};
|
|
350
|
-
const comboboxLocalizations =
|
|
367
|
+
const comboboxLocalizations = createLocalizations({
|
|
351
368
|
empty: "No results found",
|
|
352
369
|
input: "Please enter a value",
|
|
353
370
|
invalid: "Please select an option from the list",
|
|
@@ -357,9 +374,6 @@ const comboboxLocalizations = getLocalizations({
|
|
|
357
374
|
results: (amount) => `${amount} results available`,
|
|
358
375
|
selected: (amount) => `${amount} selected`
|
|
359
376
|
});
|
|
360
|
-
const
|
|
361
|
-
map: /* @__PURE__ */ new WeakMap(),
|
|
362
|
-
set: /* @__PURE__ */ new Set()
|
|
363
|
-
};
|
|
377
|
+
const comboboxes = /* @__PURE__ */ new Set();
|
|
364
378
|
//#endregion
|
|
365
|
-
export { skipComboboxNavigation as C, setComboboxLocalizations as D, hasTextSelection as E, updateComboboxLocalizations as O, 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,
|
|
379
|
+
export { skipComboboxNavigation as C, setComboboxLocalizations as D, hasTextSelection as E, updateComboboxLocalizations as O, 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,9 @@
|
|
|
1
|
+
import { t as OuiListboxAttributes } from "./listbox.model-CuBOj4qe.mjs";
|
|
2
|
+
//#region src/js/listbox/constants.listbox.d.ts
|
|
3
|
+
declare const LISTBOX_TAGNAME = "oui-listbox";
|
|
4
|
+
declare const LISTBOX_SYMBOL: unique symbol;
|
|
5
|
+
declare const listboxAttributes: OuiListboxAttributes;
|
|
6
|
+
declare const listboxMessages: Record<string, string>;
|
|
7
|
+
declare const listboxSelectors: Record<string, string>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { listboxSelectors as a, listboxMessages as i, LISTBOX_TAGNAME as n, listboxAttributes as r, LISTBOX_SYMBOL as t };
|
|
@@ -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-DX2mndMh.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-DX2mndMh.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-BHaK_mKw.mjs";
|
|
2
|
+
import { n as OuiResizable } from "./resizable.model-BwzJcTVJ.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<HTMLElement, 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-MeTyXjFn.mjs";
|
|
2
|
+
export { createEmbeddedFloatable, createFloatable, getOnBeforeToggleListener, removeFloatable };
|