@oscarpalmer/oui 0.29.1 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/badge.css +4 -4
- package/dist/css/combobox.css +165 -0
- package/dist/css/form.css +18 -14
- package/dist/js/combobox.d.mts +91 -0
- package/dist/js/combobox.mjs +797 -0
- package/dist/js/dialog.d.mts +4 -3
- package/dist/js/dialog.mjs +1 -1
- package/dist/js/{draggable-fIYXd8eO.d.mts → draggable-a6w0J1OD.d.mts} +1 -2
- package/dist/js/floatable/floatable.embedded.d.mts +1 -1
- package/dist/js/floatable/floatable.embedded.mjs +2 -2
- package/dist/js/floatable/floatable.standalone.d.mts +1 -1
- package/dist/js/{floatable.embedded-DUR8bQBK.d.mts → floatable.embedded-Bct4U5Dm.d.mts} +0 -1
- package/dist/js/focus-trap/focus-trap.embedded.mjs +13 -9
- package/dist/js/index.d.mts +9 -4
- package/dist/js/index.mjs +2 -1
- package/dist/js/internal/draggable.d.mts +1 -1
- package/dist/js/internal/draggable.mjs +22 -21
- package/dist/js/internal/navigable.d.mts +0 -1
- package/dist/js/internal/navigable.mjs +4 -3
- package/dist/js/menu.mjs +5 -2
- package/dist/js/movable/movable.embedded.d.mts +1 -1
- package/dist/js/movable/movable.embedded.mjs +7 -12
- package/dist/js/movable/movable.standalone.d.mts +1 -1
- package/dist/js/popover.d.mts +1 -2
- package/dist/js/popover.mjs +1 -1
- package/dist/js/resizable/resizable.embedded.d.mts +1 -1
- package/dist/js/resizable/resizable.embedded.mjs +41 -20
- package/dist/js/resizable/resizable.standalone.d.mts +1 -1
- package/dist/js/{resizable.embedded-CXrUVPzR.d.mts → resizable.embedded-3qoR0Bjm.d.mts} +0 -1
- package/dist/js/sortable/sortable.embedded.d.mts +1 -1
- package/dist/js/sortable/sortable.embedded.mjs +28 -37
- package/dist/js/sortable/sortable.standalone.d.mts +1 -1
- package/dist/js/splitter.d.mts +2 -2
- package/dist/js/splitter.mjs +11 -11
- package/dist/js/tooltip.d.mts +1 -2
- package/dist/js/tooltip.mjs +3 -3
- package/package.json +7 -3
- package/src/css/badge.scss +1 -18
- package/src/css/combobox.scss +137 -0
- package/src/css/form.scss +18 -80
- package/src/css/mixins.scss +86 -0
- package/src/js/combobox.ts +1479 -0
- package/src/js/focus-trap/focus-trap.embedded.ts +19 -11
- package/src/js/index.ts +1 -0
- package/src/js/internal/draggable.ts +33 -31
- package/src/js/internal/navigable.ts +5 -1
- package/src/js/menu.ts +5 -2
- package/src/js/movable/movable.embedded.ts +3 -8
- package/src/js/resizable/resizable.embedded.ts +57 -20
- package/src/js/sortable/sortable.embedded.ts +21 -26
- package/src/js/splitter.ts +37 -23
package/dist/js/dialog.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { h as OuiMovable } from "./draggable-
|
|
2
|
-
import
|
|
1
|
+
import { h as OuiMovable } from "./draggable-a6w0J1OD.mjs";
|
|
2
|
+
import "./movable/movable.standalone.mjs";
|
|
3
|
+
import { n as OuiResizable } from "./resizable.embedded-3qoR0Bjm.mjs";
|
|
4
|
+
import "./resizable/resizable.standalone.mjs";
|
|
3
5
|
import { RemovableEventListener } from "@oscarpalmer/toretto/models";
|
|
4
|
-
|
|
5
6
|
//#region src/js/dialog.d.ts
|
|
6
7
|
declare class OuiDialog {
|
|
7
8
|
#private;
|
package/dist/js/dialog.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import { ATTRIBUTE_MOVABLE_HANDLE, createMovable } from "./movable/movable.embed
|
|
|
4
4
|
import "./movable/movable.standalone.mjs";
|
|
5
5
|
import { RESIZABLE_ATTRIBUTE_HANDLE, createResizable } from "./resizable/resizable.embedded.mjs";
|
|
6
6
|
import { getAria, setAria } from "@oscarpalmer/toretto/aria";
|
|
7
|
-
import { on } from "@oscarpalmer/toretto/event";
|
|
8
7
|
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
8
|
+
import { on } from "@oscarpalmer/toretto/event";
|
|
9
9
|
import { setStyles } from "@oscarpalmer/toretto/style";
|
|
10
10
|
//#region src/js/dialog.ts
|
|
11
11
|
var OuiDialog = class {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StyleToggler } from "@oscarpalmer/toretto/style";
|
|
2
2
|
import { EventPosition, PlainObject } from "@oscarpalmer/atoms/models";
|
|
3
|
-
|
|
4
3
|
//#region src/js/movable/movable.embedded.d.ts
|
|
5
4
|
declare class OuiMovable extends OuiDraggable<OuiMovableState> {
|
|
6
5
|
#private;
|
|
@@ -134,9 +133,9 @@ type OuiDraggableState = {
|
|
|
134
133
|
attribute: string;
|
|
135
134
|
container?: HTMLElement;
|
|
136
135
|
element: HTMLElement;
|
|
137
|
-
event: string;
|
|
138
136
|
hasHandles?: boolean;
|
|
139
137
|
horizontal: boolean;
|
|
138
|
+
name: keyof OuiDraggableStates;
|
|
140
139
|
options: OuiDraggableOptions;
|
|
141
140
|
styling: StyleToggler;
|
|
142
141
|
vertical: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OuiFloatablePosition, c as getOnBeforeToggleListener, i as OuiFloatableOptions, l as removeFloatable, n as CreateOuiFloatableOptions, o as createEmbeddedFloatable, r as OuiFloatable, s as createFloatable, t as ATTRIBUTE_FLOATABLE } from "../floatable.embedded-
|
|
1
|
+
import { a as OuiFloatablePosition, c as getOnBeforeToggleListener, i as OuiFloatableOptions, l as removeFloatable, n as CreateOuiFloatableOptions, o as createEmbeddedFloatable, r as OuiFloatable, s as createFloatable, t as ATTRIBUTE_FLOATABLE } from "../floatable.embedded-Bct4U5Dm.mjs";
|
|
2
2
|
export { ATTRIBUTE_FLOATABLE, CreateOuiFloatableOptions, OuiFloatable, OuiFloatableOptions, OuiFloatablePosition, createEmbeddedFloatable, createFloatable, getOnBeforeToggleListener, removeFloatable };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getAria } from "@oscarpalmer/toretto/aria";
|
|
2
|
+
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
2
3
|
import { on } from "@oscarpalmer/toretto/event";
|
|
4
|
+
import { setStyle, setStyles } from "@oscarpalmer/toretto/style";
|
|
3
5
|
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
4
|
-
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
5
6
|
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
6
|
-
import { setStyle, setStyles } from "@oscarpalmer/toretto/style";
|
|
7
7
|
//#region src/js/floatable/floatable.embedded.ts
|
|
8
8
|
var OuiFloatable = class {
|
|
9
9
|
#destroyed = false;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OuiFloatablePosition, n as CreateOuiFloatableOptions, r as OuiFloatable, s as createFloatable } from "../floatable.embedded-
|
|
1
|
+
import { a as OuiFloatablePosition, n as CreateOuiFloatableOptions, r as OuiFloatable, s as createFloatable } from "../floatable.embedded-Bct4U5Dm.mjs";
|
|
2
2
|
export { type CreateOuiFloatableOptions, type OuiFloatable, type OuiFloatablePosition, createFloatable };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { attributable } from "../internal/attributable.mjs";
|
|
2
|
-
import { on } from "@oscarpalmer/toretto/event";
|
|
3
|
-
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
4
|
-
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
5
|
-
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
6
2
|
import { clamp } from "@oscarpalmer/atoms/number";
|
|
3
|
+
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
4
|
+
import { dispatch, on } from "@oscarpalmer/toretto/event";
|
|
7
5
|
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
6
|
+
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
7
|
+
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
8
8
|
import { getFocusable } from "@oscarpalmer/toretto/focusable";
|
|
9
9
|
//#region src/js/focus-trap/focus-trap.embedded.ts
|
|
10
10
|
var OuiFocusTrap = class {
|
|
@@ -172,11 +172,15 @@ function onTab(event) {
|
|
|
172
172
|
const element = findAncestor(event, SELECTOR);
|
|
173
173
|
const instance = instances.get(element);
|
|
174
174
|
if (instance == null) return;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
const dispatched = dispatch(element, "focus-trap");
|
|
176
|
+
setTimeout(() => {
|
|
177
|
+
if (dispatched.defaultPrevented) return;
|
|
178
|
+
if (!instance.disabled) event.preventDefault();
|
|
179
|
+
const elements = getFocusable(element);
|
|
180
|
+
const index = elements.indexOf(event.target);
|
|
181
|
+
if (index === -1 || elements.length === 0) tabToTrap(instance, elements, element);
|
|
182
|
+
else tabToElement(instance, elements, index, event.shiftKey ? -1 : 1);
|
|
183
|
+
});
|
|
180
184
|
}
|
|
181
185
|
function removeFocusTrap(element) {
|
|
182
186
|
instances.get(element)?.destroy();
|
package/dist/js/index.d.mts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { OuiComboboxElement } from "./combobox.mjs";
|
|
2
|
+
import { d as OuiSortable, f as createSortable, g as createMovable, h as OuiMovable, t as CreateOuiDraggableOptions } from "./draggable-a6w0J1OD.mjs";
|
|
3
|
+
import "./movable/movable.standalone.mjs";
|
|
4
|
+
import { a as createResizable, n as OuiResizable, t as CreateOuiResizableOptions } from "./resizable.embedded-3qoR0Bjm.mjs";
|
|
5
|
+
import "./resizable/resizable.standalone.mjs";
|
|
3
6
|
import { OuiDialog, getDialog } from "./dialog.mjs";
|
|
4
|
-
import { a as OuiFloatablePosition, n as CreateOuiFloatableOptions, r as OuiFloatable, s as createFloatable } from "./floatable.embedded-
|
|
7
|
+
import { a as OuiFloatablePosition, n as CreateOuiFloatableOptions, r as OuiFloatable, s as createFloatable } from "./floatable.embedded-Bct4U5Dm.mjs";
|
|
8
|
+
import "./floatable/floatable.standalone.mjs";
|
|
5
9
|
import { a as OuiFocusTrapOptions, i as OuiFocusTrap, o as createFocusTrap } from "./focus-trap.embedded-DR8NpZfr.mjs";
|
|
6
10
|
import { OuiPopover, getPopover } from "./popover.mjs";
|
|
11
|
+
import "./sortable/sortable.standalone.mjs";
|
|
7
12
|
import { OuiSplitterElement } from "./splitter.mjs";
|
|
8
13
|
import { OuiTooltip, getTooltip, setTooltipDelay } from "./tooltip.mjs";
|
|
9
|
-
export { type CreateOuiFloatableOptions, type CreateOuiDraggableOptions as CreateOuiMovableOptions, type CreateOuiDraggableOptions as CreateOuiSortableOptions, type CreateOuiResizableOptions, type OuiDialog, type OuiFloatable, type OuiFloatablePosition, type OuiFocusTrap, type OuiFocusTrapOptions, type OuiMovable, type OuiPopover, type OuiResizable, type OuiSortable, OuiSplitterElement, type OuiTooltip, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setTooltipDelay };
|
|
14
|
+
export { type CreateOuiFloatableOptions, type CreateOuiDraggableOptions as CreateOuiMovableOptions, type CreateOuiDraggableOptions as CreateOuiSortableOptions, type CreateOuiResizableOptions, OuiComboboxElement, type OuiDialog, type OuiFloatable, type OuiFloatablePosition, type OuiFocusTrap, type OuiFocusTrapOptions, type OuiMovable, type OuiPopover, type OuiResizable, type OuiSortable, OuiSplitterElement, type OuiTooltip, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setTooltipDelay };
|
package/dist/js/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createFloatable } from "./floatable/floatable.embedded.mjs";
|
|
2
|
+
import { OuiComboboxElement } from "./combobox.mjs";
|
|
2
3
|
import { createMovable } from "./movable/movable.embedded.mjs";
|
|
3
4
|
import "./movable/movable.standalone.mjs";
|
|
4
5
|
import { createResizable } from "./resizable/resizable.embedded.mjs";
|
|
@@ -14,4 +15,4 @@ import { createSortable } from "./sortable/sortable.embedded.mjs";
|
|
|
14
15
|
import "./sortable/sortable.standalone.mjs";
|
|
15
16
|
import { OuiSplitterElement } from "./splitter.mjs";
|
|
16
17
|
import { getTooltip, setTooltipDelay } from "./tooltip.mjs";
|
|
17
|
-
export { OuiSplitterElement, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setTooltipDelay };
|
|
18
|
+
export { OuiComboboxElement, OuiSplitterElement, createFloatable, createFocusTrap, createMovable, createResizable as createOuiResizable, createSortable, getDialog, getPopover, getTooltip, setTooltipDelay };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OuiDraggableGlobals, c as addDraggable, i as OuiDraggableBound, l as getDraggableStates, n as OuiDragMovePosition, o as OuiDraggableItem, r as OuiDraggable, s as OuiDraggableState, t as CreateOuiDraggableOptions, u as removeDraggable } from "../draggable-
|
|
1
|
+
import { a as OuiDraggableGlobals, c as addDraggable, i as OuiDraggableBound, l as getDraggableStates, n as OuiDragMovePosition, o as OuiDraggableItem, r as OuiDraggable, s as OuiDraggableState, t as CreateOuiDraggableOptions, u as removeDraggable } from "../draggable-a6w0J1OD.mjs";
|
|
2
2
|
export { CreateOuiDraggableOptions, OuiDragMovePosition, OuiDraggable, OuiDraggableBound, OuiDraggableGlobals, OuiDraggableItem, OuiDraggableState, addDraggable, getDraggableStates, removeDraggable };
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { getPosition, on } from "@oscarpalmer/toretto/event";
|
|
2
|
-
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
3
|
-
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
4
|
-
import { setStyle, setStyles, toggleStyles } from "@oscarpalmer/toretto/style";
|
|
5
1
|
import { clamp } from "@oscarpalmer/atoms/number";
|
|
2
|
+
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
3
|
+
import { dispatch, getPosition, on } from "@oscarpalmer/toretto/event";
|
|
6
4
|
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
5
|
+
import { setStyle, setStyles, toggleStyles } from "@oscarpalmer/toretto/style";
|
|
6
|
+
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
7
7
|
import supportsTouch from "@oscarpalmer/toretto/touch";
|
|
8
8
|
//#region src/js/internal/draggable.ts
|
|
9
9
|
var OuiDraggable = class {
|
|
10
10
|
#destroyed = false;
|
|
11
|
-
#name;
|
|
12
11
|
#state;
|
|
13
12
|
get element() {
|
|
14
13
|
return this.#state.element;
|
|
15
14
|
}
|
|
16
15
|
constructor(name, event, attribute, element, options, extras) {
|
|
17
|
-
this.#name = name;
|
|
18
16
|
this.#state = {
|
|
19
17
|
...extras,
|
|
20
18
|
attribute,
|
|
21
19
|
element,
|
|
22
20
|
event,
|
|
21
|
+
name,
|
|
23
22
|
options,
|
|
24
23
|
horizontal: true,
|
|
25
24
|
vertical: true,
|
|
@@ -34,7 +33,7 @@ var OuiDraggable = class {
|
|
|
34
33
|
setAttribute(element, attribute, "");
|
|
35
34
|
let states = globals.states.get(element);
|
|
36
35
|
states ??= {};
|
|
37
|
-
states[this.#name] = this.#state;
|
|
36
|
+
states[this.#state.name] = this.#state;
|
|
38
37
|
globals.states.set(element, states);
|
|
39
38
|
}
|
|
40
39
|
destroy() {
|
|
@@ -52,6 +51,12 @@ function addDraggable(element, options) {
|
|
|
52
51
|
instances[this.property] ??= new this.constructor(element, options);
|
|
53
52
|
return instances[this.property];
|
|
54
53
|
}
|
|
54
|
+
function cancelDrag(item) {
|
|
55
|
+
if (item == null) return;
|
|
56
|
+
item.state.options.drag.onCancel?.(globals, item);
|
|
57
|
+
dispatch(item.state.element, `${item.state.name}:cancel`, { detail: { element: item.state.options.getOrigin() } });
|
|
58
|
+
reset();
|
|
59
|
+
}
|
|
55
60
|
function destroyInstance(instance, state) {
|
|
56
61
|
unsetContainer({
|
|
57
62
|
instance,
|
|
@@ -87,10 +92,7 @@ function getNextPosition(item, position) {
|
|
|
87
92
|
};
|
|
88
93
|
}
|
|
89
94
|
function onKeydown(event) {
|
|
90
|
-
if (current
|
|
91
|
-
current.state.options.drag.onCancel?.(globals, current);
|
|
92
|
-
current.state.element.dispatchEvent(new CustomEvent(`${current.state.event}:cancel`, { detail: { element: current.state.options.getOrigin() } }));
|
|
93
|
-
reset();
|
|
95
|
+
if (current != null && event.key === KEY_ESCAPE) cancelDrag(current);
|
|
94
96
|
}
|
|
95
97
|
function onPointerdown(event) {
|
|
96
98
|
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || (supportsTouch.value ? event.type === "mousedown" : event.type === "touchstart" || event.button !== 0)) return;
|
|
@@ -128,16 +130,12 @@ function onPointerdown(event) {
|
|
|
128
130
|
};
|
|
129
131
|
globals.offset = item.state.options.position.getOffset(globals, item, element, position);
|
|
130
132
|
globals.original = item.state.options.position.getOriginal(globals, item, position);
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
cancelable: true
|
|
137
|
-
});
|
|
138
|
-
item.state.element.dispatchEvent(begin);
|
|
133
|
+
const dispatched = dispatch(item.state.element, `${item.state.name}:begin`, { detail: {
|
|
134
|
+
element,
|
|
135
|
+
position: { ...globals.original }
|
|
136
|
+
} });
|
|
139
137
|
setTimeout(() => {
|
|
140
|
-
if (
|
|
138
|
+
if (dispatched.defaultPrevented) {
|
|
141
139
|
item.state.options.drag.onCancel?.(globals, item);
|
|
142
140
|
reset();
|
|
143
141
|
return;
|
|
@@ -163,7 +161,10 @@ function onPointermove(event) {
|
|
|
163
161
|
calculated: next,
|
|
164
162
|
original: position
|
|
165
163
|
});
|
|
166
|
-
current.state.element
|
|
164
|
+
const dispatched = dispatch(current.state.element, `${current.state.name}:move`, { detail });
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
if (dispatched.defaultPrevented) cancelDrag(current);
|
|
167
|
+
});
|
|
167
168
|
}
|
|
168
169
|
function onPointerup(event) {
|
|
169
170
|
current?.state.options.drag.onEnd?.(event, globals, current, reset);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getAria, setRole } from "@oscarpalmer/toretto/aria";
|
|
2
|
-
import { on } from "@oscarpalmer/toretto/event";
|
|
3
|
-
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
4
1
|
import { clamp } from "@oscarpalmer/atoms/number";
|
|
2
|
+
import { getAria, setRole } from "@oscarpalmer/toretto/aria";
|
|
3
|
+
import { dispatch, on } from "@oscarpalmer/toretto/event";
|
|
5
4
|
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
5
|
+
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
6
6
|
//#region src/js/internal/navigable.ts
|
|
7
7
|
var OuiNavigable = class {
|
|
8
8
|
active = { index: 0 };
|
|
@@ -88,6 +88,7 @@ function updateNavigableFocus(navigable, focus, items) {
|
|
|
88
88
|
for (let index = 0; index < length; index += 1) updated[index].tabIndex = index === navigable.active.index ? 0 : -1;
|
|
89
89
|
navigable.active.element ??= updated[navigable.active.index];
|
|
90
90
|
if (focus) navigable.active.element?.focus();
|
|
91
|
+
dispatch(navigable.active.element, "navigable:change", { detail: { ...navigable.active } });
|
|
91
92
|
}
|
|
92
93
|
const KEYS_ABSOLUTE = /* @__PURE__ */ new Set(["End", "Home"]);
|
|
93
94
|
const KEYS_ACTIVATE = /* @__PURE__ */ new Set(["Enter", " "]);
|
package/dist/js/menu.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { createEmbeddedFloatable, getOnBeforeToggleListener } from "./floatable/
|
|
|
2
2
|
import { attributable } from "./internal/attributable.mjs";
|
|
3
3
|
import { NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_VERTICAL, getNavigable, updateNavigableFocus } from "./internal/navigable.mjs";
|
|
4
4
|
import { setAria, setRole } from "@oscarpalmer/toretto/aria";
|
|
5
|
+
import { setAttribute, setAttributes } from "@oscarpalmer/toretto/attribute";
|
|
5
6
|
import { on } from "@oscarpalmer/toretto/event";
|
|
6
|
-
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
7
7
|
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
8
8
|
//#region src/js/menu.ts
|
|
9
9
|
var OuiMenu = class {
|
|
@@ -104,7 +104,10 @@ function initializeMenu(menu) {
|
|
|
104
104
|
expanded: "false",
|
|
105
105
|
haspopup: "menu"
|
|
106
106
|
});
|
|
107
|
-
|
|
107
|
+
setAttributes(menu.content, {
|
|
108
|
+
popover: "",
|
|
109
|
+
tabindex: "-1"
|
|
110
|
+
});
|
|
108
111
|
setRole(menu.content, "menu");
|
|
109
112
|
}
|
|
110
113
|
function onDeactivate(_, navigable) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { g as createMovable, h as OuiMovable, m as ATTRIBUTE_MOVABLE_HANDLE, p as ATTRIBUTE_MOVABLE } from "../draggable-
|
|
1
|
+
import { g as createMovable, h as OuiMovable, m as ATTRIBUTE_MOVABLE_HANDLE, p as ATTRIBUTE_MOVABLE } from "../draggable-a6w0J1OD.mjs";
|
|
2
2
|
export { ATTRIBUTE_MOVABLE, ATTRIBUTE_MOVABLE_HANDLE, OuiMovable, createMovable };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { attributable } from "../internal/attributable.mjs";
|
|
2
2
|
import { OuiDraggable, addDraggable, getDraggableStates, removeDraggable } from "../internal/draggable.mjs";
|
|
3
|
-
import { getPosition, on } from "@oscarpalmer/toretto/event";
|
|
4
3
|
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
5
|
-
import {
|
|
4
|
+
import { dispatch, getPosition, on } from "@oscarpalmer/toretto/event";
|
|
6
5
|
import { getStyles, setStyle, setStyles } from "@oscarpalmer/toretto/style";
|
|
6
|
+
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
7
7
|
//#region src/js/movable/movable.embedded.ts
|
|
8
8
|
var OuiMovable = class extends OuiDraggable {
|
|
9
9
|
#element;
|
|
@@ -110,16 +110,12 @@ function onEnd(event, globals, item, reset) {
|
|
|
110
110
|
}
|
|
111
111
|
const container = state.container?.getBoundingClientRect();
|
|
112
112
|
if (container != null) setOffset(state, container);
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
cancelable: true
|
|
119
|
-
});
|
|
120
|
-
state.element.dispatchEvent(end);
|
|
113
|
+
const dispatched = dispatch(state.element, "movable:end", { detail: {
|
|
114
|
+
from: { ...globals.original },
|
|
115
|
+
to: getPosition(event)
|
|
116
|
+
} });
|
|
121
117
|
setTimeout(() => {
|
|
122
|
-
if (
|
|
118
|
+
if (dispatched.defaultPrevented) onCancel(globals, item);
|
|
123
119
|
reset();
|
|
124
120
|
});
|
|
125
121
|
}
|
|
@@ -162,7 +158,6 @@ const ATTRIBUTE_DIRECTION = `${ATTRIBUTE_MOVABLE}-direction`;
|
|
|
162
158
|
const ATTRIBUTE_MOVABLE_HANDLE = `${ATTRIBUTE_MOVABLE}-handle`;
|
|
163
159
|
const ATTRIBUTE_MOVING = `${ATTRIBUTE_MOVABLE}-moving`;
|
|
164
160
|
const CONTAINERS = /* @__PURE__ */ new Map();
|
|
165
|
-
const EVENT_END = "move:end";
|
|
166
161
|
const MESSAGE = "The element must be an instance of HTMLElement or SVGElement";
|
|
167
162
|
const MOVED = /* @__PURE__ */ new Set();
|
|
168
163
|
const SELECTOR_HANDLE = `[${ATTRIBUTE_MOVABLE_HANDLE}]`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { g as createMovable, h as OuiMovable, t as CreateOuiDraggableOptions } from "../draggable-
|
|
1
|
+
import { g as createMovable, h as OuiMovable, t as CreateOuiDraggableOptions } from "../draggable-a6w0J1OD.mjs";
|
|
2
2
|
export { type CreateOuiDraggableOptions as CreateOuiMovableOptions, type OuiMovable, createMovable };
|
package/dist/js/popover.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { r as OuiFloatable } from "./floatable.embedded-
|
|
1
|
+
import { r as OuiFloatable } from "./floatable.embedded-Bct4U5Dm.mjs";
|
|
2
2
|
import { i as OuiFocusTrap } from "./focus-trap.embedded-DR8NpZfr.mjs";
|
|
3
3
|
import { RemovableEventListener } from "@oscarpalmer/toretto/models";
|
|
4
|
-
|
|
5
4
|
//#region src/js/popover.d.ts
|
|
6
5
|
declare class OuiPopover {
|
|
7
6
|
#private;
|
package/dist/js/popover.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { createEmbeddedFloatable, getOnBeforeToggleListener } from "./floatable/
|
|
|
2
2
|
import { attributable } from "./internal/attributable.mjs";
|
|
3
3
|
import { createFocusTrap } from "./focus-trap/focus-trap.embedded.mjs";
|
|
4
4
|
import { getAria, setAria } from "@oscarpalmer/toretto/aria";
|
|
5
|
-
import { on } from "@oscarpalmer/toretto/event";
|
|
6
5
|
import { setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
6
|
+
import { on } from "@oscarpalmer/toretto/event";
|
|
7
7
|
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
8
8
|
//#region src/js/popover.ts
|
|
9
9
|
var OuiPopover = class {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createResizable, i as RESIZABLE_ATTRIBUTE_HANDLE, n as OuiResizable, r as RESIZABLE_ATTRIBUTE, t as CreateOuiResizableOptions } from "../resizable.embedded-
|
|
1
|
+
import { a as createResizable, i as RESIZABLE_ATTRIBUTE_HANDLE, n as OuiResizable, r as RESIZABLE_ATTRIBUTE, t as CreateOuiResizableOptions } from "../resizable.embedded-3qoR0Bjm.mjs";
|
|
2
2
|
export { CreateOuiResizableOptions, OuiResizable, RESIZABLE_ATTRIBUTE, RESIZABLE_ATTRIBUTE_HANDLE, createResizable };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { attributable } from "../internal/attributable.mjs";
|
|
2
|
-
import { getPosition, on } from "@oscarpalmer/toretto/event";
|
|
3
|
-
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
4
|
-
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
5
|
-
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
6
|
-
import { setStyles, toggleStyles } from "@oscarpalmer/toretto/style";
|
|
7
2
|
import { getNumber } from "@oscarpalmer/atoms/number";
|
|
3
|
+
import { getAttribute, setAttribute } from "@oscarpalmer/toretto/attribute";
|
|
4
|
+
import { dispatch, getPosition, on } from "@oscarpalmer/toretto/event";
|
|
8
5
|
import { findAncestor } from "@oscarpalmer/toretto/find";
|
|
6
|
+
import { setStyles, toggleStyles } from "@oscarpalmer/toretto/style";
|
|
7
|
+
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
8
|
+
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
9
9
|
import supportsTouch from "@oscarpalmer/toretto/touch";
|
|
10
10
|
//#region src/js/resizable/resizable.embedded.ts
|
|
11
11
|
var OuiResizable = class {
|
|
@@ -18,7 +18,6 @@ var OuiResizable = class {
|
|
|
18
18
|
}
|
|
19
19
|
set() {
|
|
20
20
|
const [width, height] = getAndSetDimensions(this.#state.element, this.#state.options);
|
|
21
|
-
console.log("set", width, height);
|
|
22
21
|
this.#state.width = width;
|
|
23
22
|
this.#state.height = height;
|
|
24
23
|
}
|
|
@@ -43,6 +42,15 @@ function addResizable(element, options) {
|
|
|
43
42
|
}
|
|
44
43
|
return item?.instance;
|
|
45
44
|
}
|
|
45
|
+
function cancelResize(item) {
|
|
46
|
+
if (item == null) return;
|
|
47
|
+
setStyles(item.state.element, {
|
|
48
|
+
height: `${item.state.height}px`,
|
|
49
|
+
width: `${item.state.width}px`
|
|
50
|
+
});
|
|
51
|
+
resetResizable();
|
|
52
|
+
dispatch(item.state.element, "resizable:cancel");
|
|
53
|
+
}
|
|
46
54
|
/**
|
|
47
55
|
* Creates _(or retrieves)_ a _OuiResizable_ instance for an element
|
|
48
56
|
*
|
|
@@ -112,12 +120,7 @@ function getXAndY(first, second) {
|
|
|
112
120
|
return [xAsNumber, yAsNumber];
|
|
113
121
|
}
|
|
114
122
|
function onKeydown(event) {
|
|
115
|
-
if (current
|
|
116
|
-
setStyles(current.state.element, {
|
|
117
|
-
height: `${current.state.height}px`,
|
|
118
|
-
width: `${current.state.width}px`
|
|
119
|
-
});
|
|
120
|
-
resetResizable();
|
|
123
|
+
if (current != null && event.key === "Escape") cancelResize(current);
|
|
121
124
|
}
|
|
122
125
|
function onPointerdown(event) {
|
|
123
126
|
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || (supportsTouch.value ? event.type === "mousedown" : event.type === "touchstart" || event.button !== 0)) return;
|
|
@@ -127,10 +130,14 @@ function onPointerdown(event) {
|
|
|
127
130
|
const position = getPosition(event);
|
|
128
131
|
if (stored == null || position == null) return;
|
|
129
132
|
if (supportsTouch.value) event.preventDefault();
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
const dispatched = dispatch(element, "resizable:begin");
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
if (dispatched.defaultPrevented) return;
|
|
136
|
+
current = stored;
|
|
137
|
+
start = position;
|
|
138
|
+
current.state.styles.set();
|
|
139
|
+
styleToggler.set();
|
|
140
|
+
});
|
|
134
141
|
}
|
|
135
142
|
function onPointermove(event) {
|
|
136
143
|
if (current == null) return;
|
|
@@ -142,13 +149,27 @@ function onPointermove(event) {
|
|
|
142
149
|
height,
|
|
143
150
|
width
|
|
144
151
|
});
|
|
152
|
+
const dispatched = dispatch(current.state.element, "resizable:resize", { detail: {
|
|
153
|
+
height,
|
|
154
|
+
width
|
|
155
|
+
} });
|
|
156
|
+
setTimeout(() => {
|
|
157
|
+
if (dispatched.defaultPrevented) cancelResize(current);
|
|
158
|
+
});
|
|
145
159
|
}
|
|
146
160
|
function onPointerup() {
|
|
147
161
|
if (current == null) return;
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
const dispatched = dispatch(current.state.element, "resizable:end");
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
if (current == null || dispatched.defaultPrevented) {
|
|
165
|
+
cancelResize(current);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const { height, width } = current.state.element.getBoundingClientRect();
|
|
169
|
+
current.state.height = height;
|
|
170
|
+
current.state.width = width;
|
|
171
|
+
resetResizable();
|
|
172
|
+
});
|
|
152
173
|
}
|
|
153
174
|
function removeResizable(element) {
|
|
154
175
|
items.get(element)?.instance.destroy();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createResizable, n as OuiResizable, t as CreateOuiResizableOptions } from "../resizable.embedded-
|
|
1
|
+
import { a as createResizable, n as OuiResizable, t as CreateOuiResizableOptions } from "../resizable.embedded-3qoR0Bjm.mjs";
|
|
2
2
|
export { type CreateOuiResizableOptions, type OuiResizable, createResizable as createOuiResizable };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as OuiSortable, f as createSortable } from "../draggable-
|
|
1
|
+
import { d as OuiSortable, f as createSortable } from "../draggable-a6w0J1OD.mjs";
|
|
2
2
|
export { OuiSortable, createSortable };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { attributable } from "../internal/attributable.mjs";
|
|
2
2
|
import { OuiDraggable, addDraggable, getDraggableStates, removeDraggable } from "../internal/draggable.mjs";
|
|
3
|
-
import { getPosition } from "@oscarpalmer/toretto/event";
|
|
4
3
|
import { getAttribute, setAttribute, setAttributes } from "@oscarpalmer/toretto/attribute";
|
|
5
|
-
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
6
|
-
import { setStyle } from "@oscarpalmer/toretto/style";
|
|
7
|
-
import { findAncestor, getElementFromPosition } from "@oscarpalmer/toretto/find";
|
|
8
4
|
import { createElement } from "@oscarpalmer/toretto/create";
|
|
5
|
+
import { dispatch, getPosition } from "@oscarpalmer/toretto/event";
|
|
6
|
+
import { findAncestor, getElementFromPosition } from "@oscarpalmer/toretto/find";
|
|
7
|
+
import { setStyle } from "@oscarpalmer/toretto/style";
|
|
8
|
+
import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
|
|
9
9
|
//#region src/js/sortable/sortable.embedded.ts
|
|
10
10
|
var OuiSortable = class extends OuiDraggable {
|
|
11
11
|
constructor(element, options) {
|
|
@@ -35,7 +35,7 @@ function afterEnd(insert, from, events, elements, position, valid) {
|
|
|
35
35
|
elements.origin?.removeAttribute(ATTRIBUTE_ORIGIN);
|
|
36
36
|
from.state.origin = void 0;
|
|
37
37
|
resetPlaceholders();
|
|
38
|
-
if (!valid || events.some((event) => event
|
|
38
|
+
if (!valid || events.some((event) => event?.defaultPrevented)) return;
|
|
39
39
|
if (insert !== "insert") {
|
|
40
40
|
elements.target.append(elements.origin);
|
|
41
41
|
return;
|
|
@@ -43,8 +43,8 @@ function afterEnd(insert, from, events, elements, position, valid) {
|
|
|
43
43
|
if (position == null) return;
|
|
44
44
|
const { height, top } = elements.target.getBoundingClientRect();
|
|
45
45
|
let insertion;
|
|
46
|
-
if (position.y < top + height / 2) insertion =
|
|
47
|
-
else insertion =
|
|
46
|
+
if (position.y < top + height / 2) insertion = "beforebegin";
|
|
47
|
+
else insertion = "afterend";
|
|
48
48
|
elements.target?.insertAdjacentElement(insertion, elements.origin);
|
|
49
49
|
document.body.removeAttribute(ATTRIBUTE_ACTIVE);
|
|
50
50
|
}
|
|
@@ -130,12 +130,11 @@ function onEnd(event, globals, item, reset) {
|
|
|
130
130
|
bubbles: false,
|
|
131
131
|
cancelable: true
|
|
132
132
|
};
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
item.instance.element
|
|
136
|
-
if (item.instance !== toInstance) toInstance?.element.dispatchEvent(toEvent);
|
|
133
|
+
const dispatchedFrom = dispatch(item.instance.element, "sortable:end", options);
|
|
134
|
+
let dispatchedTo;
|
|
135
|
+
if (item.instance !== toInstance && toInstance != null) dispatchedTo = dispatch(toInstance.element, "sortable:end", options);
|
|
137
136
|
setTimeout(() => {
|
|
138
|
-
afterEnd(insert, item, [
|
|
137
|
+
afterEnd(insert, item, [dispatchedFrom, dispatchedTo], {
|
|
139
138
|
origin,
|
|
140
139
|
target: element
|
|
141
140
|
}, position, valid);
|
|
@@ -165,10 +164,10 @@ function onMove(event, globals, item, position) {
|
|
|
165
164
|
let place;
|
|
166
165
|
if (position.calculated.y < top + height / 2) {
|
|
167
166
|
place = "before";
|
|
168
|
-
toElement.insertAdjacentElement(
|
|
167
|
+
toElement.insertAdjacentElement("beforebegin", placeholder);
|
|
169
168
|
} else {
|
|
170
169
|
place = "after";
|
|
171
|
-
toElement.insertAdjacentElement(
|
|
170
|
+
toElement.insertAdjacentElement("afterend", placeholder);
|
|
172
171
|
}
|
|
173
172
|
setAttribute(placeholder, ATTRIBUTE_PLACEHOLDER_POSITION, place);
|
|
174
173
|
} else placeholder.remove();
|
|
@@ -193,27 +192,23 @@ function setPlaceholder(state, item, origin) {
|
|
|
193
192
|
const element = getDragPlaceholder();
|
|
194
193
|
placeholder.drag.default.innerHTML = "";
|
|
195
194
|
updatePlaceholder(item, element);
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
node: element
|
|
210
|
-
};
|
|
211
|
-
}
|
|
195
|
+
const dispatched = dispatch(item.instance.element, "sortable:placeholder", { detail: {
|
|
196
|
+
origin,
|
|
197
|
+
parent: item.state.element,
|
|
198
|
+
placeholder: element,
|
|
199
|
+
create: (value) => {
|
|
200
|
+
if (!isHTMLOrSVGElement(value)) return;
|
|
201
|
+
const element = value;
|
|
202
|
+
placeholder.drag.custom = element;
|
|
203
|
+
updatePlaceholder(item, element);
|
|
204
|
+
state.element = {
|
|
205
|
+
rectangle: element.getBoundingClientRect(),
|
|
206
|
+
node: element
|
|
207
|
+
};
|
|
212
208
|
}
|
|
213
|
-
});
|
|
214
|
-
item.instance.element.dispatchEvent(event);
|
|
209
|
+
} });
|
|
215
210
|
setTimeout(() => {
|
|
216
|
-
if (!
|
|
211
|
+
if (!dispatched.defaultPrevented && placeholder.drag.custom == null) placeholder.drag.default?.append(element.cloneNode(true));
|
|
217
212
|
document.body.append(placeholder.drag.custom ?? placeholder.drag.default ?? "");
|
|
218
213
|
});
|
|
219
214
|
}
|
|
@@ -248,10 +243,6 @@ const ATTRIBUTE_PLACEHOLDER_DRAG = `${ATTRIBUTE}-placeholder-drag`;
|
|
|
248
243
|
const ATTRIBUTE_PLACEHOLDER_POSITION = `${ATTRIBUTE}-placeholder-position`;
|
|
249
244
|
const ATTRIBUTE_VERTICAL = `${ATTRIBUTE}-vertical`;
|
|
250
245
|
const CONTAINERS = /* @__PURE__ */ new Map();
|
|
251
|
-
const EVENT_END = "sort:end";
|
|
252
|
-
const EVENT_PLACEHOLDER = "sort:placeholder";
|
|
253
|
-
const INSERT_AFTER = "afterend";
|
|
254
|
-
const INSERT_BEFORE = "beforebegin";
|
|
255
246
|
const MESSAGE = "The element must be an instance of HTMLElement or SVGElement";
|
|
256
247
|
const SELECTOR = `[${ATTRIBUTE}]`;
|
|
257
248
|
const SELECTOR_ITEM = `[${ATTRIBUTE}] > *`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as OuiSortable, f as createSortable, t as CreateOuiDraggableOptions } from "../draggable-
|
|
1
|
+
import { d as OuiSortable, f as createSortable, t as CreateOuiDraggableOptions } from "../draggable-a6w0J1OD.mjs";
|
|
2
2
|
export { type CreateOuiDraggableOptions as CreateOuiSortableOptions, type OuiSortable, createSortable };
|