@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,15 @@
|
|
|
1
|
+
//#region src/js/focus-trap/focus-trap.model.ts
|
|
2
|
+
const FOCUSTRAP_ATTRIBUTE = "oui-focus-trap";
|
|
3
|
+
const FOCUSTRAP_ATTRIBUTE_CONTAIN = `${FOCUSTRAP_ATTRIBUTE}-contain`;
|
|
4
|
+
const FOCUSTRAP_ATTRIBUTE_NOESCAPE = `${FOCUSTRAP_ATTRIBUTE}-noescape`;
|
|
5
|
+
const FOCUSTRAP_EVENT_OPTIONS = {
|
|
6
|
+
capture: true,
|
|
7
|
+
passive: false
|
|
8
|
+
};
|
|
9
|
+
const FOCUSTRAP_MESSAGE = "Element must be an HTMLElement or SVGElement";
|
|
10
|
+
const FOCUSTRAP_SELECTOR = `[${FOCUSTRAP_ATTRIBUTE}]`;
|
|
11
|
+
const FOCUSTRAP_SYMBOL = Symbol(FOCUSTRAP_ATTRIBUTE);
|
|
12
|
+
const disabledFocusTraps = /* @__PURE__ */ new Set();
|
|
13
|
+
const focusTraps = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
//#endregion
|
|
15
|
+
export { FOCUSTRAP_ATTRIBUTE, FOCUSTRAP_ATTRIBUTE_CONTAIN, FOCUSTRAP_ATTRIBUTE_NOESCAPE, FOCUSTRAP_EVENT_OPTIONS, FOCUSTRAP_MESSAGE, FOCUSTRAP_SELECTOR, FOCUSTRAP_SYMBOL, disabledFocusTraps, focusTraps };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as OuiFocusTrap, l as OuiFocusTrapOptions } from "../focus-trap.model-BeX6UYlw.mjs";
|
|
2
|
+
import { t as createFocusTrap } from "../focus-trap.embedded-DIU05m1z.mjs";
|
|
2
3
|
export { type OuiFocusTrap, type OuiFocusTrapOptions, createFocusTrap };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { c as OuiFocusTrap, l as OuiFocusTrapOptions } from "./focus-trap.model-BeX6UYlw.mjs";
|
|
2
|
+
//#region src/js/focus-trap/focus-trap.embedded.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates _(or retrieves)_ a _focus trap_ for an element
|
|
5
|
+
*
|
|
6
|
+
* @param element Element to trap focus within
|
|
7
|
+
* @param options _Focus trap_ options
|
|
8
|
+
* @returns _Focus trap_ instance
|
|
9
|
+
*/
|
|
10
|
+
declare function createFocusTrap(element: HTMLElement, options?: OuiFocusTrapOptions): OuiFocusTrap;
|
|
11
|
+
declare function removeFocusTrap(element: HTMLElement): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { removeFocusTrap as n, createFocusTrap as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//#region src/js/focus-trap/focus-trap.
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/js/focus-trap/focus-trap.model.d.ts
|
|
2
|
+
type OuiFocusTrap = {
|
|
3
|
+
[FOCUSTRAP_SYMBOL]: OuiFocusTrapState;
|
|
4
4
|
/**
|
|
5
5
|
* Is focused maintained within the _focus trap_ when clicking outside of it?
|
|
6
6
|
*/
|
|
@@ -25,7 +25,6 @@ declare class OuiFocusTrap {
|
|
|
25
25
|
* Should the _focus trap_ allow focus to escape when pressing _Escape_?
|
|
26
26
|
*/
|
|
27
27
|
set noescape(value: boolean);
|
|
28
|
-
constructor(state: OuiFocusTrapState);
|
|
29
28
|
/**
|
|
30
29
|
* Destroys the _focus trap_
|
|
31
30
|
*/
|
|
@@ -44,7 +43,7 @@ declare class OuiFocusTrap {
|
|
|
44
43
|
* @param last When `true`, focuses the last focusable element within the _focus trap_ instead of the first
|
|
45
44
|
*/
|
|
46
45
|
focus(last: boolean): void;
|
|
47
|
-
}
|
|
46
|
+
};
|
|
48
47
|
type OuiFocusTrapOptions = {
|
|
49
48
|
/**
|
|
50
49
|
* Should focus be maintained within the _focus trap_ when clicking outside of it?
|
|
@@ -56,21 +55,20 @@ type OuiFocusTrapOptions = {
|
|
|
56
55
|
noescape?: boolean;
|
|
57
56
|
};
|
|
58
57
|
type OuiFocusTrapState = {
|
|
58
|
+
destroyed: boolean;
|
|
59
59
|
disabled: boolean;
|
|
60
60
|
element: HTMLElement;
|
|
61
61
|
options: Required<OuiFocusTrapOptions>;
|
|
62
|
+
tabIndex: number;
|
|
62
63
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
declare
|
|
71
|
-
declare
|
|
72
|
-
declare const ATTRIBUTE_FOCUSTRAP = "oui-focus-trap";
|
|
73
|
-
declare const ATTRIBUTE_FOCUSTRAP_CONTAIN = "oui-focus-trap-contain";
|
|
74
|
-
declare const ATTRIBUTE_FOCUSTRAP_NOESCAPE = "oui-focus-trap-noescape";
|
|
64
|
+
declare const FOCUSTRAP_ATTRIBUTE = "oui-focus-trap";
|
|
65
|
+
declare const FOCUSTRAP_ATTRIBUTE_CONTAIN: string;
|
|
66
|
+
declare const FOCUSTRAP_ATTRIBUTE_NOESCAPE: string;
|
|
67
|
+
declare const FOCUSTRAP_EVENT_OPTIONS: AddEventListenerOptions;
|
|
68
|
+
declare const FOCUSTRAP_MESSAGE = "Element must be an HTMLElement or SVGElement";
|
|
69
|
+
declare const FOCUSTRAP_SELECTOR: string;
|
|
70
|
+
declare const FOCUSTRAP_SYMBOL: unique symbol;
|
|
71
|
+
declare const disabledFocusTraps: Set<OuiFocusTrap>;
|
|
72
|
+
declare const focusTraps: WeakMap<HTMLElement, OuiFocusTrap>;
|
|
75
73
|
//#endregion
|
|
76
|
-
export {
|
|
74
|
+
export { FOCUSTRAP_MESSAGE as a, OuiFocusTrap as c, disabledFocusTraps as d, focusTraps as f, FOCUSTRAP_EVENT_OPTIONS as i, OuiFocusTrapOptions as l, FOCUSTRAP_ATTRIBUTE_CONTAIN as n, FOCUSTRAP_SELECTOR as o, FOCUSTRAP_ATTRIBUTE_NOESCAPE as r, FOCUSTRAP_SYMBOL as s, FOCUSTRAP_ATTRIBUTE as t, OuiFocusTrapState as u };
|
package/dist/js/index.d.mts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
1
|
+
import { c as OuiFloatable, t as CreateOuiFloatableOptions, u as OuiFloatablePosition } from "./floatable.model-DXsQgoU7.mjs";
|
|
2
|
+
import { M as OuiColorPickerEvent } from "./color-picker.constants-D1mxw_Le.mjs";
|
|
3
|
+
import { a as setColorPickerLocalizations } from "./color-picker.misc-CtsXGrOe.mjs";
|
|
4
|
+
import { OuiColorPickerElement } from "./color-picker/index.mjs";
|
|
5
|
+
import { i as setComboboxLocalizations } from "./combobox.misc-C1tPZZDi.mjs";
|
|
6
|
+
import { OuiComboboxElement } from "./combobox/index.mjs";
|
|
7
|
+
import { $ as OuiSortable, p as CreateOuiDraggableOptions, u as OuiMovable } from "./movable.model-BHaK_mKw.mjs";
|
|
8
|
+
import { n as OuiResizable, t as CreateOuiResizableOptions } from "./resizable.model-BwzJcTVJ.mjs";
|
|
9
|
+
import { c as OuiDialog } from "./dialog.model-DX2mndMh.mjs";
|
|
10
|
+
import { getDialog } from "./dialog/index.mjs";
|
|
11
|
+
import { n as createFloatable } from "./floatable.embedded-MeTyXjFn.mjs";
|
|
12
|
+
import "./floatable/floatable.standalone.mjs";
|
|
13
|
+
import { c as OuiFocusTrap, l as OuiFocusTrapOptions } from "./focus-trap.model-BeX6UYlw.mjs";
|
|
14
|
+
import { t as createFocusTrap } from "./focus-trap.embedded-DIU05m1z.mjs";
|
|
15
|
+
import { t as createMovable } from "./movable.embedded-DoyXLegc.mjs";
|
|
5
16
|
import "./movable/movable.standalone.mjs";
|
|
6
|
-
import {
|
|
17
|
+
import { t as createResizable } from "./resizable.embedded-Bf1qBUdt.mjs";
|
|
7
18
|
import "./resizable/resizable.standalone.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import "./floatable/floatable.standalone.mjs";
|
|
10
|
-
import { a as OuiFocusTrapOptions, i as OuiFocusTrap, o as createFocusTrap } from "./focus-trap.embedded-DR8NpZfr.mjs";
|
|
11
|
-
import { n as setListboxLocalizations } from "./misc.listbox-gnoJhrTr.mjs";
|
|
12
|
-
import { OuiListboxElement } from "./listbox/index.mjs";
|
|
13
|
-
import { OuiPopover, getPopover } from "./popover.mjs";
|
|
19
|
+
import { t as createSortable } from "./sortable.embedded-DzBKAwSG.mjs";
|
|
14
20
|
import "./sortable/sortable.standalone.mjs";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
21
|
+
import { n as setListboxLocalizations } from "./misc.listbox-CtoGvXQo.mjs";
|
|
22
|
+
import { OuiListboxElement } from "./listbox/index.mjs";
|
|
23
|
+
import { t as OuiPopover } from "./popover.model-ubKNG612.mjs";
|
|
24
|
+
import { getPopover } from "./popover/index.mjs";
|
|
25
|
+
import { OuiSplitterElement } from "./splitter/index.mjs";
|
|
26
|
+
import { r as OuiTabsEvent } from "./tabs.model-DRBX_JtI.mjs";
|
|
27
|
+
import { OuiTabsElement } from "./tabs/index.mjs";
|
|
28
|
+
import { t as OuiTooltip } from "./tooltip.model-DRkY_BsL.mjs";
|
|
29
|
+
import { getTooltip, setTooltipDelay } from "./tooltip/index.mjs";
|
|
18
30
|
export { type CreateOuiFloatableOptions, type CreateOuiDraggableOptions as CreateOuiMovableOptions, type CreateOuiDraggableOptions as CreateOuiSortableOptions, type CreateOuiResizableOptions, OuiColorPickerElement, OuiColorPickerEvent, OuiComboboxElement, type OuiDialog, type OuiFloatable, type OuiFloatablePosition, type OuiFocusTrap, type OuiFocusTrapOptions, OuiListboxElement, type OuiMovable, type OuiPopover, type OuiResizable, type OuiSortable, OuiSplitterElement, OuiTabsElement, OuiTabsEvent, type OuiTooltip, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setColorPickerLocalizations, setComboboxLocalizations, setListboxLocalizations, setTooltipDelay };
|
package/dist/js/index.mjs
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { createFloatable } from "./floatable/floatable.embedded.mjs";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "./movable/movable.standalone.mjs";
|
|
5
|
-
import { createResizable } from "./resizable/resizable.embedded.mjs";
|
|
6
|
-
import { getDialog } from "./dialog.mjs";
|
|
7
|
-
import "./menu.mjs";
|
|
8
|
-
import "./toolbar.mjs";
|
|
9
|
-
import { D as setComboboxLocalizations } from "./state.combobox-Qm3FWzYW.mjs";
|
|
10
|
-
import { OuiComboboxElement } from "./combobox/index.mjs";
|
|
2
|
+
import "./menu/index.mjs";
|
|
3
|
+
import "./toolbar/index.mjs";
|
|
11
4
|
import "./floatable/floatable.standalone.mjs";
|
|
12
5
|
import { createFocusTrap } from "./focus-trap/focus-trap.embedded.mjs";
|
|
13
6
|
import "./focus-trap/focus-trap.standalone.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
7
|
+
import { createMovable } from "./movable/movable.embedded.mjs";
|
|
8
|
+
import "./movable/movable.standalone.mjs";
|
|
9
|
+
import { createResizable } from "./resizable/resizable.embedded.mjs";
|
|
17
10
|
import "./resizable/resizable.standalone.mjs";
|
|
18
11
|
import { createSortable } from "./sortable/sortable.embedded.mjs";
|
|
19
12
|
import "./sortable/sortable.standalone.mjs";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
13
|
+
import { OuiColorPickerEvent } from "./color-picker/color-picker.model.mjs";
|
|
14
|
+
import { d as setColorPickerLocalizations } from "./color-picker.event-Cksj5TvS.mjs";
|
|
15
|
+
import { OuiColorPickerElement } from "./color-picker/index.mjs";
|
|
16
|
+
import { D as setComboboxLocalizations } from "./combobox.state-BfJ3Hxg8.mjs";
|
|
17
|
+
import { OuiComboboxElement } from "./combobox/index.mjs";
|
|
18
|
+
import { getDialog } from "./dialog/index.mjs";
|
|
19
|
+
import { n as setListboxLocalizations } from "./misc.listbox-CjfBUbHD.mjs";
|
|
20
|
+
import { OuiListboxElement } from "./listbox/index.mjs";
|
|
21
|
+
import { getPopover } from "./popover/index.mjs";
|
|
22
|
+
import { OuiSplitterElement } from "./splitter/index.mjs";
|
|
23
|
+
import { OuiTabsEvent } from "./tabs/tabs.model.mjs";
|
|
24
|
+
import { OuiTabsElement } from "./tabs/index.mjs";
|
|
25
|
+
import { getTooltip, setTooltipDelay } from "./tooltip/index.mjs";
|
|
23
26
|
export { OuiColorPickerElement, OuiColorPickerEvent, OuiComboboxElement, OuiListboxElement, OuiSplitterElement, OuiTabsElement, OuiTabsEvent, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setColorPickerLocalizations, setComboboxLocalizations, setListboxLocalizations, setTooltipDelay };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
//#region src/js/internal/attributable.d.ts
|
|
2
|
-
declare function attributable(attribute: string, add: (element: HTMLElement) => void, remove: (element: HTMLElement) => void): void;
|
|
3
|
-
//#endregion
|
|
4
|
-
export { attributable };
|
|
2
|
+
export declare function attributable(attribute: string, add: (element: HTMLElement) => void, remove: (element: HTMLElement) => void): void;
|
|
3
|
+
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { filter } from "@oscarpalmer/atoms/array/filter";
|
|
1
2
|
//#region src/js/internal/attributable.ts
|
|
2
3
|
function attributable(attribute, add, remove) {
|
|
3
4
|
new MutationObserver((entries) => {
|
|
@@ -23,7 +24,7 @@ function attributable(attribute, add, remove) {
|
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
function handleAdded(attribute, nodes, add) {
|
|
26
|
-
const elements = [...nodes]
|
|
27
|
+
const elements = filter([...nodes], (node) => node instanceof Element);
|
|
27
28
|
const { length } = elements;
|
|
28
29
|
for (let index = 0; index < length; index += 1) {
|
|
29
30
|
const element = elements[index];
|
|
@@ -32,7 +33,7 @@ function handleAdded(attribute, nodes, add) {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
function handleRemoved(nodes, remove) {
|
|
35
|
-
const elements = [...nodes]
|
|
36
|
+
const elements = filter([...nodes], (node) => node instanceof Element);
|
|
36
37
|
const { length } = elements;
|
|
37
38
|
for (let index = 0; index < length; index += 1) {
|
|
38
39
|
const element = elements[index];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as OuiDraggableGlobals, B as OuiDraggableOptionsDrag, C as OuiDragCancel, D as OuiDraggable, E as OuiDragMovePosition, F as OuiDraggableOptionsContainer, G as OuiDraggableStates, H as OuiDraggableOptionsPositionGetOffset, I as OuiDraggableOptionsContainerOnDestroy, J as draggableHorizontals, K as draggableContainers, L as OuiDraggableOptionsContainerOnInitialize, M as OuiDraggableInstances, N as OuiDraggableItem, O as OuiDraggableBound, P as OuiDraggableOptions, Q as draggableVerticals, R as OuiDraggableOptionsDirection, S as OuiDragBegin, T as OuiDragMove, U as OuiDraggableOptionsPositionGetOriginal, V as OuiDraggableOptionsPosition, W as OuiDraggableState, X as draggableStyleToggler, Y as draggableProperties, Z as draggableStyles, _ as DRAGGABLE_SELECTOR, b as DRAGGABLE_SELECTOR_SORTABLE_ITEM, g as DRAGGABLE_KEY_ESCAPE, h as DRAGGABLE_ATTRIBUTE_SORTABLE, j as OuiDraggableGlobalsElement, k as OuiDraggableDirection, m as DRAGGABLE_ATTRIBUTE_MOVABLE, p as CreateOuiDraggableOptions, q as draggableGlobals, v as DRAGGABLE_SELECTOR_MOVABLE_HANDLE, w as OuiDragEnd, x as DRAGGABLE_SYMBOL, y as DRAGGABLE_SELECTOR_SORTABLE_HANDLE, z as OuiDraggableOptionsDirectionOnAfter } from "../../movable.model-BHaK_mKw.mjs";
|
|
2
|
+
export { CreateOuiDraggableOptions, DRAGGABLE_ATTRIBUTE_MOVABLE, DRAGGABLE_ATTRIBUTE_SORTABLE, DRAGGABLE_KEY_ESCAPE, DRAGGABLE_SELECTOR, DRAGGABLE_SELECTOR_MOVABLE_HANDLE, DRAGGABLE_SELECTOR_SORTABLE_HANDLE, DRAGGABLE_SELECTOR_SORTABLE_ITEM, DRAGGABLE_SYMBOL, OuiDragBegin, OuiDragCancel, OuiDragEnd, OuiDragMove, OuiDragMovePosition, OuiDraggable, OuiDraggableBound, OuiDraggableDirection, OuiDraggableGlobals, OuiDraggableGlobalsElement, OuiDraggableInstances, OuiDraggableItem, OuiDraggableOptions, OuiDraggableOptionsContainer, OuiDraggableOptionsContainerOnDestroy, OuiDraggableOptionsContainerOnInitialize, OuiDraggableOptionsDirection, OuiDraggableOptionsDirectionOnAfter, OuiDraggableOptionsDrag, OuiDraggableOptionsPosition, OuiDraggableOptionsPositionGetOffset, OuiDraggableOptionsPositionGetOriginal, OuiDraggableState, OuiDraggableStates, draggableContainers, draggableGlobals, draggableHorizontals, draggableProperties, draggableStyleToggler, draggableStyles, draggableVerticals };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { toggleStyles } from "@oscarpalmer/toretto/style";
|
|
2
|
+
//#region src/js/internal/draggable/draggable.model.ts
|
|
3
|
+
const DRAGGABLE_ATTRIBUTE_MOVABLE = "oui-movable";
|
|
4
|
+
const DRAGGABLE_ATTRIBUTE_SORTABLE = "oui-sortable";
|
|
5
|
+
const DRAGGABLE_KEY_ESCAPE = "Escape";
|
|
6
|
+
const DRAGGABLE_SELECTOR = `[${DRAGGABLE_ATTRIBUTE_MOVABLE}], [${DRAGGABLE_ATTRIBUTE_SORTABLE}]`;
|
|
7
|
+
const DRAGGABLE_SELECTOR_MOVABLE_HANDLE = `[${DRAGGABLE_ATTRIBUTE_MOVABLE}-handle]`;
|
|
8
|
+
const DRAGGABLE_SELECTOR_SORTABLE_HANDLE = `[${DRAGGABLE_ATTRIBUTE_SORTABLE}-handle]`;
|
|
9
|
+
const DRAGGABLE_SELECTOR_SORTABLE_ITEM = `[${DRAGGABLE_ATTRIBUTE_SORTABLE}] > *`;
|
|
10
|
+
const DRAGGABLE_SYMBOL = Symbol(DRAGGABLE_ATTRIBUTE_MOVABLE);
|
|
11
|
+
const draggableContainers = /* @__PURE__ */ new Set([
|
|
12
|
+
"body",
|
|
13
|
+
"document",
|
|
14
|
+
"window"
|
|
15
|
+
]);
|
|
16
|
+
const draggableHorizontals = /* @__PURE__ */ new Set(["horizontal", "x"]);
|
|
17
|
+
const draggableProperties = {
|
|
18
|
+
movable: "sortable",
|
|
19
|
+
sortable: "movable"
|
|
20
|
+
};
|
|
21
|
+
const draggableGlobals = {
|
|
22
|
+
container: void 0,
|
|
23
|
+
element: void 0,
|
|
24
|
+
instances: /* @__PURE__ */ new WeakMap(),
|
|
25
|
+
offset: void 0,
|
|
26
|
+
original: void 0,
|
|
27
|
+
states: /* @__PURE__ */ new WeakMap()
|
|
28
|
+
};
|
|
29
|
+
const draggableStyles = {
|
|
30
|
+
touchAction: "none",
|
|
31
|
+
userSelect: "none",
|
|
32
|
+
webkitUserSelect: "none"
|
|
33
|
+
};
|
|
34
|
+
const draggableStyleToggler = toggleStyles(document.body, draggableStyles);
|
|
35
|
+
const draggableVerticals = /* @__PURE__ */ new Set(["vertical", "y"]);
|
|
36
|
+
//#endregion
|
|
37
|
+
export { DRAGGABLE_ATTRIBUTE_MOVABLE, DRAGGABLE_ATTRIBUTE_SORTABLE, DRAGGABLE_KEY_ESCAPE, DRAGGABLE_SELECTOR, DRAGGABLE_SELECTOR_MOVABLE_HANDLE, DRAGGABLE_SELECTOR_SORTABLE_HANDLE, DRAGGABLE_SELECTOR_SORTABLE_ITEM, DRAGGABLE_SYMBOL, draggableContainers, draggableGlobals, draggableHorizontals, draggableProperties, draggableStyleToggler, draggableStyles, draggableVerticals };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { D as OuiDraggable, G as OuiDraggableStates, M as OuiDraggableInstances, O as OuiDraggableBound, P as OuiDraggableOptions, W as OuiDraggableState, p as CreateOuiDraggableOptions } from "../../movable.model-BHaK_mKw.mjs";
|
|
2
|
+
import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
3
|
+
//#region src/js/internal/draggable/index.d.ts
|
|
4
|
+
export declare function addDraggable<Property extends keyof OuiDraggableInstances, Instance extends OuiDraggableInstances[Property]>(this: OuiDraggableBound<Property, Instance>, element: HTMLElement, options?: CreateOuiDraggableOptions): Instance;
|
|
5
|
+
export declare function destroyDraggable(draggable: OuiDraggable): void;
|
|
6
|
+
export declare function getDraggableStates(element: HTMLElement): OuiDraggableStates | undefined;
|
|
7
|
+
export declare function getDraggableElement(this: OuiDraggable): HTMLElement;
|
|
8
|
+
export declare function initializeDraggable<ExtraState extends PlainObject = PlainObject>(draggable: OuiDraggable, name: keyof OuiDraggableStates, event: string, attribute: string, element: HTMLElement, options: OuiDraggableOptions<ExtraState>, extras: ExtraState): OuiDraggableState & ExtraState;
|
|
9
|
+
export declare function removeDraggable<Property extends keyof OuiDraggableInstances, Instance extends OuiDraggableInstances[Property]>(this: {
|
|
10
|
+
constructor: new (element: HTMLElement) => Instance;
|
|
11
|
+
property: Property;
|
|
12
|
+
}, element: HTMLElement): void;
|
|
13
|
+
//#endregion
|
|
@@ -1,62 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DRAGGABLE_SELECTOR, DRAGGABLE_SELECTOR_MOVABLE_HANDLE, DRAGGABLE_SELECTOR_SORTABLE_HANDLE, DRAGGABLE_SELECTOR_SORTABLE_ITEM, DRAGGABLE_SYMBOL, draggableContainers, draggableGlobals, draggableHorizontals, draggableProperties, draggableStyleToggler, draggableStyles, draggableVerticals } from "./draggable.model.mjs";
|
|
2
|
+
import { MOVABLE_ATTRIBUTE } from "../../movable/movable.model.mjs";
|
|
2
3
|
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
3
4
|
import { dispatch, getEventPosition, on } from "@oscarpalmer/toretto/event";
|
|
4
5
|
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
5
|
-
import { setStyle, setStyles, toggleStyles } from "@oscarpalmer/toretto/style";
|
|
6
|
-
import supportsTouch from "@oscarpalmer/toretto/touch";
|
|
7
6
|
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get element() {
|
|
13
|
-
return this.#state.element;
|
|
14
|
-
}
|
|
15
|
-
constructor(name, event, attribute, element, options, extras) {
|
|
16
|
-
this.#state = {
|
|
17
|
-
...extras,
|
|
18
|
-
attribute,
|
|
19
|
-
element,
|
|
20
|
-
event,
|
|
21
|
-
name,
|
|
22
|
-
options,
|
|
23
|
-
horizontal: true,
|
|
24
|
-
vertical: true,
|
|
25
|
-
styling: toggleStyles(element, styles)
|
|
26
|
-
};
|
|
27
|
-
const item = {
|
|
28
|
-
instance: this,
|
|
29
|
-
state: this.#state
|
|
30
|
-
};
|
|
31
|
-
setContainer(item);
|
|
32
|
-
setDirection(item);
|
|
33
|
-
setAttribute(element, attribute, "");
|
|
34
|
-
let states = globals.states.get(element);
|
|
35
|
-
states ??= {};
|
|
36
|
-
states[this.#state.name] = this.#state;
|
|
37
|
-
globals.states.set(element, states);
|
|
38
|
-
}
|
|
39
|
-
destroy() {
|
|
40
|
-
if (this.#destroyed) return;
|
|
41
|
-
this.#destroyed = true;
|
|
42
|
-
destroyInstance(this, this.#state);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
7
|
+
import { setStyle, setStyles, toggleStyles } from "@oscarpalmer/toretto/style";
|
|
8
|
+
import { clamp } from "@oscarpalmer/atoms/number";
|
|
9
|
+
import { supportsTouch } from "@oscarpalmer/toretto/touch";
|
|
10
|
+
//#region src/js/internal/draggable/index.ts
|
|
45
11
|
function addDraggable(element, options) {
|
|
46
|
-
let instances =
|
|
12
|
+
let instances = draggableGlobals.instances.get(element);
|
|
47
13
|
if (instances == null) {
|
|
48
14
|
instances = {};
|
|
49
|
-
|
|
15
|
+
draggableGlobals.instances.set(element, instances);
|
|
50
16
|
}
|
|
51
17
|
instances[this.property] ??= new this.constructor(element, options);
|
|
52
18
|
return instances[this.property];
|
|
53
19
|
}
|
|
54
20
|
function cancelDrag(item) {
|
|
55
21
|
if (item == null) return;
|
|
56
|
-
item.state.options.drag.onCancel?.(
|
|
22
|
+
item.state.options.drag.onCancel?.(draggableGlobals, item);
|
|
57
23
|
dispatch(item.state.element, `oui:${item.state.name}:cancel`, { detail: { element: item.state.options.getOrigin() } });
|
|
58
24
|
reset();
|
|
59
25
|
}
|
|
26
|
+
function destroyDraggable(draggable) {
|
|
27
|
+
const state = draggable[DRAGGABLE_SYMBOL];
|
|
28
|
+
if (state.destroyed) return;
|
|
29
|
+
state.destroyed = true;
|
|
30
|
+
destroyInstance(draggable, state);
|
|
31
|
+
}
|
|
60
32
|
function destroyInstance(instance, state) {
|
|
61
33
|
unsetContainer({
|
|
62
34
|
instance,
|
|
@@ -70,37 +42,66 @@ function destroyInstance(instance, state) {
|
|
|
70
42
|
state.styling = void 0;
|
|
71
43
|
}
|
|
72
44
|
function getDraggableStates(element) {
|
|
73
|
-
return
|
|
45
|
+
return draggableGlobals.states.get(element);
|
|
46
|
+
}
|
|
47
|
+
function getDraggableElement() {
|
|
48
|
+
return this[DRAGGABLE_SYMBOL].element;
|
|
74
49
|
}
|
|
75
50
|
function getHandle(event, isMovable) {
|
|
76
|
-
return findAncestor(event, isMovable ?
|
|
51
|
+
return findAncestor(event, isMovable ? DRAGGABLE_SELECTOR_MOVABLE_HANDLE : DRAGGABLE_SELECTOR_SORTABLE_HANDLE);
|
|
77
52
|
}
|
|
78
53
|
function getNextPosition(item, position) {
|
|
79
|
-
let x =
|
|
80
|
-
let y =
|
|
54
|
+
let x = draggableGlobals.original?.x ?? 0;
|
|
55
|
+
let y = draggableGlobals.original?.y ?? 0;
|
|
81
56
|
if (item.state.horizontal) {
|
|
82
|
-
x = position.x - (
|
|
83
|
-
if (
|
|
57
|
+
x = position.x - (draggableGlobals.offset?.x ?? 0);
|
|
58
|
+
if (draggableGlobals.container != null && draggableGlobals.element != null) x = clamp(x, draggableGlobals.container.left, draggableGlobals.container.right - draggableGlobals.element.rectangle.width);
|
|
84
59
|
}
|
|
85
60
|
if (item.state.vertical) {
|
|
86
|
-
y = position.y - (
|
|
87
|
-
if (
|
|
61
|
+
y = position.y - (draggableGlobals.offset?.y ?? 0);
|
|
62
|
+
if (draggableGlobals.container != null && draggableGlobals.element != null) y = clamp(y, draggableGlobals.container.top, draggableGlobals.container.bottom - draggableGlobals.element.rectangle.height);
|
|
88
63
|
}
|
|
89
64
|
return {
|
|
90
65
|
x,
|
|
91
66
|
y
|
|
92
67
|
};
|
|
93
68
|
}
|
|
69
|
+
function initializeDraggable(draggable, name, event, attribute, element, options, extras) {
|
|
70
|
+
const state = {
|
|
71
|
+
...extras,
|
|
72
|
+
attribute,
|
|
73
|
+
element,
|
|
74
|
+
event,
|
|
75
|
+
name,
|
|
76
|
+
options,
|
|
77
|
+
horizontal: true,
|
|
78
|
+
vertical: true,
|
|
79
|
+
destroyed: false,
|
|
80
|
+
styling: toggleStyles(element, draggableStyles)
|
|
81
|
+
};
|
|
82
|
+
const item = {
|
|
83
|
+
state,
|
|
84
|
+
instance: draggable
|
|
85
|
+
};
|
|
86
|
+
setContainer(item);
|
|
87
|
+
setDirection(item);
|
|
88
|
+
setAttribute(element, attribute, "");
|
|
89
|
+
let states = draggableGlobals.states.get(element);
|
|
90
|
+
states ??= {};
|
|
91
|
+
states[state.name] = state;
|
|
92
|
+
draggableGlobals.states.set(element, states);
|
|
93
|
+
return state;
|
|
94
|
+
}
|
|
94
95
|
function onKeydown(event) {
|
|
95
|
-
if (current != null && event.key ===
|
|
96
|
+
if (current != null && event.key === "Escape") cancelDrag(current);
|
|
96
97
|
}
|
|
97
98
|
function onPointerdown(event) {
|
|
98
99
|
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || (supportsTouch.value ? event.type === "mousedown" : event.type === "touchstart" || event.button !== 0)) return;
|
|
99
|
-
const container = findAncestor(event,
|
|
100
|
-
const instances =
|
|
101
|
-
const states =
|
|
100
|
+
const container = findAncestor(event, DRAGGABLE_SELECTOR);
|
|
101
|
+
const instances = draggableGlobals.instances.get(container);
|
|
102
|
+
const states = draggableGlobals.states.get(container);
|
|
102
103
|
if (instances == null || states == null) return;
|
|
103
|
-
const isMovable = container.hasAttribute(
|
|
104
|
+
const isMovable = container.hasAttribute(MOVABLE_ATTRIBUTE);
|
|
104
105
|
const item = {
|
|
105
106
|
instance: isMovable ? instances.movable : instances.sortable,
|
|
106
107
|
state: isMovable ? states.movable : states.sortable
|
|
@@ -109,11 +110,11 @@ function onPointerdown(event) {
|
|
|
109
110
|
if (supportsTouch.value) event.preventDefault();
|
|
110
111
|
let element = container;
|
|
111
112
|
if (!isMovable) {
|
|
112
|
-
element = findAncestor(event,
|
|
113
|
+
element = findAncestor(event, DRAGGABLE_SELECTOR_SORTABLE_ITEM);
|
|
113
114
|
if (element == null || element.parentElement !== container) return;
|
|
114
115
|
}
|
|
115
116
|
let handle = element;
|
|
116
|
-
item.state.hasHandles ??= element.querySelector(
|
|
117
|
+
item.state.hasHandles ??= element.querySelector(DRAGGABLE_SELECTOR_SORTABLE_HANDLE) != null;
|
|
117
118
|
if (item.state.hasHandles) handle = getHandle(event, isMovable);
|
|
118
119
|
if (handle == null) return;
|
|
119
120
|
const dragged = item.state.options.getDragged();
|
|
@@ -123,18 +124,18 @@ function onPointerdown(event) {
|
|
|
123
124
|
y: 0
|
|
124
125
|
};
|
|
125
126
|
current = item;
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
draggableGlobals.container = item.state.container?.getBoundingClientRect();
|
|
128
|
+
draggableGlobals.element = {
|
|
128
129
|
rectangle,
|
|
129
130
|
node: dragged
|
|
130
131
|
};
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
draggableGlobals.offset = item.state.options.position.getOffset(draggableGlobals, item, element, position);
|
|
133
|
+
draggableGlobals.original = item.state.options.position.getOriginal(draggableGlobals, item, position);
|
|
133
134
|
if (dispatch(item.state.element, `oui:${item.state.name}:begin`, { detail: {
|
|
134
135
|
element,
|
|
135
|
-
position: { ...
|
|
136
|
+
position: { ...draggableGlobals.original }
|
|
136
137
|
} }).defaultPrevented) {
|
|
137
|
-
item.state.options.drag.onCancel?.(
|
|
138
|
+
item.state.options.drag.onCancel?.(draggableGlobals, item);
|
|
138
139
|
reset();
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
@@ -144,45 +145,45 @@ function onPointerdown(event) {
|
|
|
144
145
|
inset: `${next.y}px auto auto ${next.x}px`,
|
|
145
146
|
transform: "translate3d(0, 0, 0)"
|
|
146
147
|
});
|
|
147
|
-
item.state.options.drag.onBegin?.(event,
|
|
148
|
+
item.state.options.drag.onBegin?.(event, draggableGlobals, item, element, handle, next);
|
|
148
149
|
item.state.styling.set();
|
|
149
|
-
|
|
150
|
+
draggableStyleToggler.set();
|
|
150
151
|
}
|
|
151
152
|
function onPointermove(event) {
|
|
152
153
|
if (current == null) return;
|
|
153
154
|
const position = getEventPosition(event);
|
|
154
155
|
if (position == null) return;
|
|
155
156
|
const next = getNextPosition(current, position);
|
|
156
|
-
if (
|
|
157
|
-
const detail = current.state.options.drag.onMove(event,
|
|
157
|
+
if (draggableGlobals.element != null) setStyle(draggableGlobals.element.node, "inset", `${next.y}px auto auto ${next.x}px`);
|
|
158
|
+
const detail = current.state.options.drag.onMove(event, draggableGlobals, current, {
|
|
158
159
|
calculated: next,
|
|
159
160
|
original: position
|
|
160
161
|
});
|
|
161
162
|
if (dispatch(current.state.element, `oui:${current.state.name}:move`, { detail }).defaultPrevented) cancelDrag(current);
|
|
162
163
|
}
|
|
163
164
|
function onPointerup(event) {
|
|
164
|
-
current?.state.options.drag.onEnd?.(event,
|
|
165
|
+
current?.state.options.drag.onEnd?.(event, draggableGlobals, current, reset);
|
|
165
166
|
}
|
|
166
167
|
function removeDraggable(element) {
|
|
167
168
|
const { property } = this;
|
|
168
|
-
removeInstance(
|
|
169
|
-
removeInstance(
|
|
169
|
+
removeInstance(draggableGlobals.instances, property, element);
|
|
170
|
+
removeInstance(draggableGlobals.states, property, element);
|
|
170
171
|
}
|
|
171
172
|
function removeInstance(map, name, element) {
|
|
172
173
|
const instances = map.get(element);
|
|
173
174
|
if (instances == null || instances[name] == null) return;
|
|
174
175
|
if (typeof instances[name].destroy === "function") instances[name].destroy();
|
|
175
176
|
instances[name] = void 0;
|
|
176
|
-
if (instances[
|
|
177
|
+
if (instances[draggableProperties[name]] == null) map.delete(element);
|
|
177
178
|
}
|
|
178
179
|
function reset() {
|
|
179
180
|
current?.state.styling.remove();
|
|
180
|
-
|
|
181
|
+
draggableStyleToggler.remove();
|
|
181
182
|
current = void 0;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
draggableGlobals.container = void 0;
|
|
184
|
+
draggableGlobals.element = void 0;
|
|
185
|
+
draggableGlobals.offset = void 0;
|
|
186
|
+
draggableGlobals.original = void 0;
|
|
186
187
|
}
|
|
187
188
|
function setContainer(item) {
|
|
188
189
|
const { container } = item.state.options.input ?? {};
|
|
@@ -190,9 +191,9 @@ function setContainer(item) {
|
|
|
190
191
|
setContainerElement(item, container);
|
|
191
192
|
return;
|
|
192
193
|
}
|
|
193
|
-
const selector = container ?? getAttribute(item.
|
|
194
|
+
const selector = container ?? getAttribute(item.state.element, item.state.options.container.attribute);
|
|
194
195
|
if (typeof selector !== "string") return;
|
|
195
|
-
const element =
|
|
196
|
+
const element = draggableContainers.has(selector) ? item.state.element.ownerDocument.body : document.querySelector(selector) ?? void 0;
|
|
196
197
|
if (isHTMLOrSVGElement(element)) setContainerElement(item, element);
|
|
197
198
|
}
|
|
198
199
|
function setContainerElement(item, element) {
|
|
@@ -204,8 +205,8 @@ function setContainerElement(item, element) {
|
|
|
204
205
|
}
|
|
205
206
|
function setDirection(item) {
|
|
206
207
|
const direction = getAttribute(item.state.element, item.state.options.direction.attribute);
|
|
207
|
-
if (
|
|
208
|
-
else if (
|
|
208
|
+
if (draggableHorizontals.has(direction)) item.state.vertical = false;
|
|
209
|
+
else if (draggableVerticals.has(direction)) item.state.horizontal = false;
|
|
209
210
|
item.state.options.direction.onAfter?.(item);
|
|
210
211
|
}
|
|
211
212
|
function unsetContainer(item) {
|
|
@@ -222,38 +223,6 @@ function unsetContainer(item) {
|
|
|
222
223
|
}
|
|
223
224
|
item.state.options.container.onDestroy?.(item, container, empty);
|
|
224
225
|
}
|
|
225
|
-
const ATTRIBUTE_MOVABLE = "oui-movable";
|
|
226
|
-
const ATTRIBUTE_SORTABLE = "oui-sortable";
|
|
227
|
-
const KEY_ESCAPE = "Escape";
|
|
228
|
-
const SELECTOR = `[${ATTRIBUTE_MOVABLE}], [${ATTRIBUTE_SORTABLE}]`;
|
|
229
|
-
const SELECTOR_MOVABLE_HANDLE = `[${ATTRIBUTE_MOVABLE}-handle]`;
|
|
230
|
-
const SELECTOR_SORTABLE_HANDLE = `[${ATTRIBUTE_SORTABLE}-handle]`;
|
|
231
|
-
const SELECTOR_SORTABLE_ITEM = `[${ATTRIBUTE_SORTABLE}] > *`;
|
|
232
|
-
const containers = /* @__PURE__ */ new Set([
|
|
233
|
-
"body",
|
|
234
|
-
"document",
|
|
235
|
-
"window"
|
|
236
|
-
]);
|
|
237
|
-
const horizontals = /* @__PURE__ */ new Set(["horizontal", "x"]);
|
|
238
|
-
const properties = {
|
|
239
|
-
movable: "sortable",
|
|
240
|
-
sortable: "movable"
|
|
241
|
-
};
|
|
242
|
-
const globals = {
|
|
243
|
-
container: void 0,
|
|
244
|
-
element: void 0,
|
|
245
|
-
instances: /* @__PURE__ */ new WeakMap(),
|
|
246
|
-
offset: void 0,
|
|
247
|
-
original: void 0,
|
|
248
|
-
states: /* @__PURE__ */ new WeakMap()
|
|
249
|
-
};
|
|
250
|
-
const styles = {
|
|
251
|
-
touchAction: "none",
|
|
252
|
-
userSelect: "none",
|
|
253
|
-
webkitUserSelect: "none"
|
|
254
|
-
};
|
|
255
|
-
const styleToggler = toggleStyles(document.body, styles);
|
|
256
|
-
const verticals = /* @__PURE__ */ new Set(["vertical", "y"]);
|
|
257
226
|
let current;
|
|
258
227
|
on(document, "keydown", onKeydown);
|
|
259
228
|
on(document, "mousedown", onPointerdown);
|
|
@@ -262,4 +231,4 @@ on(document, "pointerup", onPointerup);
|
|
|
262
231
|
on(document, "touchcancel", onPointerup);
|
|
263
232
|
on(document, "touchstart", onPointerdown, { passive: false });
|
|
264
233
|
//#endregion
|
|
265
|
-
export {
|
|
234
|
+
export { addDraggable, destroyDraggable, getDraggableElement, getDraggableStates, initializeDraggable, removeDraggable };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as OuiListboxType } from "../../listbox.model-CuBOj4qe.mjs";
|
|
2
2
|
//#region src/js/internal/listbox/listbox.constants.d.ts
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare const listboxScrollOptions: ScrollIntoViewOptions;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { LISTBOX_KEYS, LISTBOX_TYPES, listboxScrollOptions };
|
|
3
|
+
export declare const LISTBOX_KEYS_ACTIVATION: Set<string>;
|
|
4
|
+
export declare const LISTBOX_KEYS_NAVIGATION: Set<string>;
|
|
5
|
+
export declare const LISTBOX_KEYS_SELECTION: Set<string>;
|
|
6
|
+
export declare const LISTBOX_TYPES: Set<OuiListboxType>;
|
|
7
|
+
export declare const listboxScrollOptions: ScrollIntoViewOptions;
|
|
8
|
+
//#endregion
|