@oscarpalmer/oui 0.24.0 → 0.26.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.
Files changed (52) hide show
  1. package/dist/css/{tooltip.css → floatable.css} +59 -24
  2. package/dist/css/reset.css +17 -0
  3. package/dist/js/dialog.d.mts +38 -0
  4. package/dist/js/dialog.mjs +92 -0
  5. package/dist/js/embedded-CHK82Uh5.d.mts +76 -0
  6. package/dist/js/embedded-ai6cqURc.d.mts +68 -0
  7. package/dist/js/floatable/embedded.d.mts +2 -0
  8. package/dist/js/floatable/embedded.mjs +157 -0
  9. package/dist/js/floatable/standalone.d.mts +2 -0
  10. package/dist/js/floatable/standalone.mjs +2 -0
  11. package/dist/js/focus-trap/embedded.d.mts +2 -26
  12. package/dist/js/focus-trap/embedded.mjs +158 -80
  13. package/dist/js/focus-trap/standalone.d.mts +2 -1
  14. package/dist/js/focus-trap/standalone.mjs +3 -3
  15. package/dist/js/index.d.mts +6 -3
  16. package/dist/js/index.mjs +9 -5
  17. package/dist/js/internal/draggable.d.mts +2 -2
  18. package/dist/js/internal/draggable.mjs +3 -3
  19. package/dist/js/{movable-BKFgoaOl.d.mts → movable-dNqBctx3.d.mts} +16 -16
  20. package/dist/js/movable.d.mts +2 -2
  21. package/dist/js/movable.mjs +4 -4
  22. package/dist/js/popover.d.mts +38 -1
  23. package/dist/js/popover.mjs +83 -44
  24. package/dist/js/sortable.d.mts +2 -2
  25. package/dist/js/sortable.mjs +5 -5
  26. package/dist/js/splitter.mjs +49 -48
  27. package/dist/js/toolbar.d.mts +1 -0
  28. package/dist/js/toolbar.mjs +107 -0
  29. package/dist/js/tooltip.d.mts +27 -1
  30. package/dist/js/tooltip.mjs +85 -49
  31. package/package.json +14 -2
  32. package/src/css/{tooltip.scss → floatable.scss} +47 -5
  33. package/src/css/mixins.scss +0 -2
  34. package/src/css/reset.scss +17 -0
  35. package/src/js/dialog.ts +188 -0
  36. package/src/js/floatable/embedded.ts +323 -0
  37. package/src/js/floatable/standalone.ts +1 -0
  38. package/src/js/focus-trap/embedded.ts +219 -93
  39. package/src/js/focus-trap/standalone.ts +4 -2
  40. package/src/js/index.ts +6 -4
  41. package/src/js/internal/draggable.ts +20 -20
  42. package/src/js/movable.ts +17 -17
  43. package/src/js/popover.ts +143 -61
  44. package/src/js/sortable.ts +26 -26
  45. package/src/js/splitter.ts +98 -96
  46. package/src/js/toolbar.ts +214 -0
  47. package/src/js/tooltip.ts +138 -54
  48. package/dist/css/popover.css +0 -30
  49. package/dist/js/floatable.d.mts +0 -59
  50. package/dist/js/floatable.mjs +0 -130
  51. package/src/css/popover.scss +0 -10
  52. package/src/js/floatable.ts +0 -237
@@ -1,67 +1,144 @@
1
- import { clamp } from "@oscarpalmer/atoms/number";
2
1
  import { on } from "@oscarpalmer/toretto/event";
2
+ import { isPlainObject } from "@oscarpalmer/atoms/is";
3
+ import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
4
+ import { clamp } from "@oscarpalmer/atoms/number";
3
5
  import { findAncestor } from "@oscarpalmer/toretto/find";
4
6
  import { getFocusable } from "@oscarpalmer/toretto/focusable";
5
7
  //#region src/js/focus-trap/embedded.ts
6
- var FocusTrap = class {
7
- disabled = false;
8
- connected = true;
9
- element;
10
- embedded;
8
+ var OuiFocusTrap = class {
9
+ #destroyed = false;
10
+ #tabIndex;
11
+ #state;
12
+ /**
13
+ * Is focused maintained within the _FocusTrap_ when clicking outside of it?
14
+ */
11
15
  get contain() {
12
- return this.element.hasAttribute(FOCUS_TRAP_CONTAIN);
13
- }
16
+ return this.#state.element.hasAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN);
17
+ }
18
+ /**
19
+ * Should focus be maintained within the _FocusTrap_ when clicking outside of it?
20
+ */
21
+ set contain(value) {
22
+ if (value === true) this.#state.element.setAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN, "");
23
+ else if (value === false) this.#state.element.removeAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN);
24
+ }
25
+ /**
26
+ * Is the _FocusTrap_ disabled?
27
+ */
28
+ get disabled() {
29
+ return this.#state.disabled;
30
+ }
31
+ /**
32
+ * Should the _FocusTrap_ be disabled?
33
+ */
34
+ set disabled(value) {
35
+ if (value === true) this.disable();
36
+ else if (value === false) this.enable();
37
+ }
38
+ /**
39
+ * Is focus allowed to escape when pressing _Escape_ within the _FocusTrap_?
40
+ */
14
41
  get noescape() {
15
- return this.element.hasAttribute(FOCUS_TRAP_NOESCAPE);
16
- }
17
- constructor(element, options) {
18
- this.element = element;
19
- this.embedded = options != null;
20
- element.setAttribute("tabindex", "-1");
21
- if (options != null) element.setAttribute(FOCUS_TRAP_SELECTOR, "");
22
- if (options?.noescape) element.setAttribute(FOCUS_TRAP_NOESCAPE, "");
23
- }
24
- connect() {
25
- setConnected(this, true);
26
- }
42
+ return this.#state.element.hasAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE);
43
+ }
44
+ /**
45
+ * Should the _FocusTrap_ allow focus to escape when pressing _Escape_?
46
+ */
47
+ set noescape(value) {
48
+ if (value === true) this.#state.element.setAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE, "");
49
+ else if (value === false) this.#state.element.removeAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE);
50
+ }
51
+ constructor(state) {
52
+ this.#state = state;
53
+ this.#tabIndex = state.element.tabIndex;
54
+ state.element.tabIndex = -1;
55
+ state.element.setAttribute(ATTRIBUTE_FOCUSTRAP, "");
56
+ this.contain = state.options.contain;
57
+ this.noescape = state.options.noescape;
58
+ states.set(this, state);
59
+ }
60
+ /**
61
+ * Destroys the _FocusTrap_
62
+ */
27
63
  destroy() {
28
- this.element = void 0;
29
- }
64
+ if (this.#destroyed) return;
65
+ this.#destroyed = true;
66
+ disabled.delete(this);
67
+ instances.delete(this.#state.element);
68
+ states.delete(this);
69
+ this.#state.element.tabIndex = this.#tabIndex;
70
+ this.#state.element.removeAttribute(ATTRIBUTE_FOCUSTRAP);
71
+ this.#state.element.removeAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN);
72
+ this.#state.element.removeAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE);
73
+ this.#state.element = void 0;
74
+ }
75
+ /**
76
+ * Disables the _FocusTrap_
77
+ */
30
78
  disable() {
31
- if (!(this.disabled || this.noescape)) setDisabled(this, true);
32
- }
33
- disconnect() {
34
- setConnected(this, false);
79
+ if (!this.#destroyed && !(this.disabled || this.#state.options.noescape)) setDisabled(this, this.#state, true);
35
80
  }
81
+ /**
82
+ * Enables the _FocusTrap_
83
+ */
36
84
  enable() {
37
- if (this.disabled) setDisabled(this, false);
85
+ if (!this.#destroyed && this.disabled) setDisabled(this, this.#state, false);
38
86
  }
87
+ /**
88
+ * Focuses the _FocusTrap_
89
+ *
90
+ * @param last When `true`, focuses the last focusable element within the _FocusTrap_ instead of the first
91
+ */
39
92
  focus(last) {
40
- tabToTrap(this, getFocusable(this.element), this.element, last ? -1 : 0);
93
+ if (!this.#destroyed && !this.disabled) tabToTrap(this, getFocusable(this.#state.element), this.#state.element, last ? -1 : 0);
41
94
  }
42
95
  };
96
+ /**
97
+ * Creates _(or retrieves)_ a _FocusTrap_ for an element
98
+ *
99
+ * @param element Element to trap focus within
100
+ * @param options _FocusTrap_ options
101
+ * @returns _FocusTrap_ instance
102
+ */
43
103
  function createFocusTrap(element, options) {
44
- let focusTrap = FOCUSTRAPS_ALL.get(element);
45
- if (focusTrap == null) {
46
- focusTrap = new FocusTrap(element, options);
47
- FOCUSTRAPS_ALL.set(element, focusTrap);
104
+ if (!isHTMLOrSVGElement(element)) throw new TypeError(MESSAGE);
105
+ let instance = instances.get(element);
106
+ if (instance == null) {
107
+ instance = new OuiFocusTrap(getState(element, options));
108
+ instances.set(element, instance);
48
109
  }
49
- return focusTrap;
110
+ return instance;
111
+ }
112
+ function getOptions(element, input) {
113
+ const options = isPlainObject(input) ? input : {};
114
+ return {
115
+ contain: typeof options.contain === "boolean" ? options.contain : element.hasAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN),
116
+ noescape: typeof options.noescape === "boolean" ? options.noescape : element.hasAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE)
117
+ };
118
+ }
119
+ function getState(element, options) {
120
+ return {
121
+ element,
122
+ disabled: false,
123
+ options: getOptions(element, options)
124
+ };
50
125
  }
51
126
  function onEscape(event) {
52
- let element = findAncestor(event, ATTRIBUTE_SELECTOR);
53
- let focusTrap = FOCUSTRAPS_ALL.get(element);
54
- if (element == null || focusTrap == null) return;
55
- while (focusTrap.disabled) {
56
- element = findAncestor(focusTrap.element.parentElement, ATTRIBUTE_SELECTOR);
57
- focusTrap = FOCUSTRAPS_ALL.get(element);
58
- if (element == null || focusTrap == null) return;
59
- if (!focusTrap.disabled) break;
60
- }
61
- focusTrap?.disable();
127
+ let element = findAncestor(event, SELECTOR);
128
+ let instance = instances.get(element);
129
+ let state = states.get(instance);
130
+ if (element == null || instance == null || state == null) return;
131
+ while (state.disabled) {
132
+ element = findAncestor(state.element.parentElement, SELECTOR);
133
+ instance = instances.get(element);
134
+ state = states.get(instance);
135
+ if (element == null || instance == null || state == null) return;
136
+ if (!state.disabled) break;
137
+ }
138
+ instance?.disable();
62
139
  }
63
140
  function onFocusIn(event) {
64
- lastTarget = FOCUSTRAPS_ALL.get(findAncestor(event, ATTRIBUTE_SELECTOR)) == null ? void 0 : event.target;
141
+ lastTarget = instances.get(findAncestor(event, SELECTOR)) == null ? void 0 : event.target;
65
142
  }
66
143
  function onKeydown(event) {
67
144
  switch (event.key) {
@@ -75,82 +152,83 @@ function onKeydown(event) {
75
152
  }
76
153
  }
77
154
  function onPointerdown(event) {
78
- const lastFocusTrap = findAncestor(lastTarget, ATTRIBUTE_SELECTOR);
79
- const nextFocusTrap = findAncestor(event, ATTRIBUTE_SELECTOR);
80
- if (lastFocusTrap != null && nextFocusTrap !== lastFocusTrap) {
81
- if (FOCUSTRAPS_ALL.get(lastFocusTrap)?.contain ?? false) {
155
+ const last = findAncestor(lastTarget, SELECTOR);
156
+ const next = findAncestor(event, SELECTOR);
157
+ if (last != null && next !== last) {
158
+ if (states.get(instances.get(last))?.options.contain ?? false) {
82
159
  event.preventDefault();
83
160
  lastTarget?.focus();
84
161
  }
85
162
  }
86
- if (FOCUSTRAPS_DISABLED.size === 0) return;
87
- for (const focusTrap of FOCUSTRAPS_DISABLED) if (focusTrap.element !== nextFocusTrap) focusTrap.enable();
163
+ if (disabled.size === 0) return;
164
+ for (const focusTrap of disabled) {
165
+ const state = states.get(focusTrap);
166
+ if (state != null && state.element !== next) focusTrap.enable();
167
+ }
88
168
  }
89
169
  function onTab(event) {
90
- const element = findAncestor(event, ATTRIBUTE_SELECTOR);
91
- const focusTrap = FOCUSTRAPS_ALL.get(element);
92
- if (focusTrap == null) return;
93
- if (!focusTrap.disabled) event.preventDefault();
170
+ const element = findAncestor(event, SELECTOR);
171
+ const instance = instances.get(element);
172
+ if (instance == null) return;
173
+ if (!instance.disabled) event.preventDefault();
94
174
  const elements = getFocusable(element);
95
175
  const index = elements.indexOf(event.target);
96
- if (index === -1 || elements.length === 0) tabToTrap(focusTrap, elements, element);
97
- else tabToElement(focusTrap, elements, index, event.shiftKey ? -1 : 1);
176
+ if (index === -1 || elements.length === 0) tabToTrap(instance, elements, element);
177
+ else tabToElement(instance, elements, index, event.shiftKey ? -1 : 1);
98
178
  }
99
179
  function removeFocusTrap(element) {
100
- FOCUSTRAPS_ALL.get(element)?.destroy();
101
- FOCUSTRAPS_ALL.delete(element);
102
- }
103
- function setConnected(focusTrap, value) {
104
- if (!focusTrap.embedded || focusTrap.connected === value) return;
105
- focusTrap.connected = value;
180
+ instances.get(element)?.destroy();
181
+ instances.delete(element);
106
182
  }
107
- function setDisabled(focusTrap, value) {
108
- focusTrap.disabled = value;
109
- if (value) FOCUSTRAPS_DISABLED.add(focusTrap);
110
- else FOCUSTRAPS_DISABLED.delete(focusTrap);
183
+ function setDisabled(focusTrap, state, value) {
184
+ state.disabled = value;
185
+ if (value) disabled.add(focusTrap);
186
+ else disabled.delete(focusTrap);
111
187
  }
112
- function tabToElement(focusTrap, elements, index, modifier) {
188
+ function tabToElement(instance, elements, index, modifier) {
113
189
  const { length } = elements;
114
190
  const next = clamp(index + modifier, 0, length - 1, true);
115
- if (focusTrap.disabled) {
191
+ if (instance.disabled) {
116
192
  if (index === length - 1 && next === 0 || index === 0 && next === length - 1) {
117
193
  lastTarget = void 0;
118
- focusTrap.enable();
194
+ instance.enable();
119
195
  }
120
196
  return;
121
197
  }
122
198
  const element = elements[next];
123
- const elementFocusTrap = FOCUSTRAPS_ALL.get(element);
199
+ const elementFocusTrap = instances.get(element);
124
200
  if (elementFocusTrap != null) elementFocusTrap.focus(modifier === -1);
125
201
  else {
126
202
  elements[next].focus();
127
203
  lastTarget = elements[next];
128
204
  }
129
205
  }
130
- function tabToTrap(focusTrap, elements, element, index) {
131
- if (focusTrap.disabled) {
206
+ function tabToTrap(instance, elements, element, index) {
207
+ if (instance.disabled) {
132
208
  lastTarget = void 0;
133
- focusTrap.enable();
209
+ instance.enable();
134
210
  } else {
135
211
  const next = elements.length === 0 ? element : elements.at(index ?? 0);
136
212
  next.focus();
137
213
  lastTarget = next;
138
214
  }
139
215
  }
140
- const FOCUS_TRAP_SELECTOR = "oui-focus-trap";
141
- const ATTRIBUTE_SELECTOR = `[${FOCUS_TRAP_SELECTOR}]`;
216
+ const ATTRIBUTE_FOCUSTRAP = "oui-focus-trap";
217
+ const ATTRIBUTE_FOCUSTRAP_CONTAIN = `${ATTRIBUTE_FOCUSTRAP}-contain`;
218
+ const ATTRIBUTE_FOCUSTRAP_NOESCAPE = `${ATTRIBUTE_FOCUSTRAP}-noescape`;
142
219
  const EVENT_OPTIONS = {
143
220
  capture: true,
144
221
  passive: false
145
222
  };
146
- const FOCUS_TRAP_CONTAIN = `${FOCUS_TRAP_SELECTOR}-contain`;
147
- const FOCUS_TRAP_NOESCAPE = `${FOCUS_TRAP_SELECTOR}-noescape`;
148
- const FOCUSTRAPS_ALL = /* @__PURE__ */ new WeakMap();
149
- const FOCUSTRAPS_DISABLED = /* @__PURE__ */ new Set();
223
+ const MESSAGE = "Element must be an HTMLElement or SVGElement";
224
+ const SELECTOR = `[${ATTRIBUTE_FOCUSTRAP}]`;
225
+ const disabled = /* @__PURE__ */ new Set();
226
+ const instances = /* @__PURE__ */ new WeakMap();
227
+ const states = /* @__PURE__ */ new WeakMap();
150
228
  let lastTarget;
151
229
  on(document, "focusin", onFocusIn, EVENT_OPTIONS);
152
230
  on(document, "keydown", onKeydown, EVENT_OPTIONS);
153
231
  on(document, "mousedown", onPointerdown, EVENT_OPTIONS);
154
232
  on(document, "touchstart", onPointerdown, EVENT_OPTIONS);
155
233
  //#endregion
156
- export { FOCUS_TRAP_CONTAIN, FOCUS_TRAP_NOESCAPE, FOCUS_TRAP_SELECTOR, FocusTrap, createFocusTrap, removeFocusTrap };
234
+ export { ATTRIBUTE_FOCUSTRAP, ATTRIBUTE_FOCUSTRAP_CONTAIN, ATTRIBUTE_FOCUSTRAP_NOESCAPE, OuiFocusTrap, createFocusTrap, removeFocusTrap };
@@ -1 +1,2 @@
1
- export { };
1
+ import { a as createFocusTrap, i as OuiFocusTrap } from "../embedded-CHK82Uh5.mjs";
2
+ export { type OuiFocusTrap, createFocusTrap };
@@ -1,6 +1,6 @@
1
1
  import { attributable } from "../internal/attributable.mjs";
2
- import { FOCUS_TRAP_SELECTOR, createFocusTrap, removeFocusTrap } from "./embedded.mjs";
2
+ import { ATTRIBUTE_FOCUSTRAP, createFocusTrap, removeFocusTrap } from "./embedded.mjs";
3
3
  //#region src/js/focus-trap/standalone.ts
4
- attributable(FOCUS_TRAP_SELECTOR, createFocusTrap, removeFocusTrap);
4
+ attributable(ATTRIBUTE_FOCUSTRAP, createFocusTrap, removeFocusTrap);
5
5
  //#endregion
6
- export {};
6
+ export { createFocusTrap };
@@ -1,4 +1,7 @@
1
- import { getFloatable } from "./floatable.mjs";
1
+ import { OuiDialog, getDialog } from "./dialog.mjs";
2
+ import { i as OuiFloatablePosition, n as OuiFloatable, o as createFloatable } from "./embedded-ai6cqURc.mjs";
3
+ import { a as createFocusTrap, i as OuiFocusTrap } from "./embedded-CHK82Uh5.mjs";
4
+ import { OuiPopover, getPopover } from "./popover.mjs";
2
5
  import { OuiSplitterElement } from "./splitter.mjs";
3
- import { setTooltipDelay } from "./tooltip.mjs";
4
- export { OuiSplitterElement, getFloatable, setTooltipDelay };
6
+ import { OuiTooltip, getTooltip, setTooltipDelay } from "./tooltip.mjs";
7
+ export { type OuiDialog, type OuiFloatable, type OuiFloatablePosition, type OuiFocusTrap, type OuiPopover, OuiSplitterElement, type OuiTooltip, createFloatable, createFocusTrap, getDialog, getPopover, getTooltip, setTooltipDelay };
package/dist/js/index.mjs CHANGED
@@ -1,8 +1,12 @@
1
- import { getFloatable } from "./floatable.mjs";
2
- import "./focus-trap/standalone.mjs";
1
+ import { createFloatable } from "./floatable/embedded.mjs";
2
+ import { getDialog } from "./dialog.mjs";
3
3
  import "./movable.mjs";
4
- import "./popover.mjs";
5
4
  import "./sortable.mjs";
5
+ import "./toolbar.mjs";
6
+ import "./floatable/standalone.mjs";
7
+ import { createFocusTrap } from "./focus-trap/embedded.mjs";
8
+ import "./focus-trap/standalone.mjs";
9
+ import { getPopover } from "./popover.mjs";
6
10
  import { OuiSplitterElement } from "./splitter.mjs";
7
- import { setTooltipDelay } from "./tooltip.mjs";
8
- export { OuiSplitterElement, getFloatable, setTooltipDelay };
11
+ import { getTooltip, setTooltipDelay } from "./tooltip.mjs";
12
+ export { OuiSplitterElement, createFloatable, createFocusTrap, getDialog, getPopover, getTooltip, setTooltipDelay };
@@ -1,2 +1,2 @@
1
- import { a as DraggableState, i as DraggableBound, n as DragMovePosition, o as addDraggable, r as Draggable, s as removeDraggable } from "../movable-BKFgoaOl.mjs";
2
- export { DragMovePosition, Draggable, DraggableBound, DraggableState, addDraggable, removeDraggable };
1
+ import { a as OuiDraggable, i as DraggableState, n as DragMovePosition, o as addDraggable, r as DraggableBound, s as removeDraggable } from "../movable-dNqBctx3.mjs";
2
+ export { DragMovePosition, DraggableBound, DraggableState, OuiDraggable, addDraggable, removeDraggable };
@@ -1,10 +1,10 @@
1
- import { clamp } from "@oscarpalmer/atoms/number";
2
1
  import { getPosition, on } from "@oscarpalmer/toretto/event";
2
+ import { clamp } from "@oscarpalmer/atoms/number";
3
3
  import { findAncestor } from "@oscarpalmer/toretto/find";
4
4
  import { toggleStyles } from "@oscarpalmer/toretto/style";
5
5
  import supportsTouch from "@oscarpalmer/toretto/touch";
6
6
  //#region src/js/internal/draggable.ts
7
- var Draggable = class {
7
+ var OuiDraggable = class {
8
8
  prefix;
9
9
  element;
10
10
  options;
@@ -212,4 +212,4 @@ on(document, "pointerup", onPointerup);
212
212
  on(document, "touchcancel", onPointerup, { passive: false });
213
213
  on(document, "touchstart", onPointerdown, { passive: false });
214
214
  //#endregion
215
- export { Draggable, addDraggable, removeDraggable };
215
+ export { OuiDraggable, addDraggable, removeDraggable };
@@ -1,7 +1,7 @@
1
1
  import { EventPosition, PlainObject } from "@oscarpalmer/atoms/models";
2
2
 
3
3
  //#region src/js/sortable.d.ts
4
- declare class Sortable extends Draggable {
4
+ declare class OuiSortable extends OuiDraggable {
5
5
  connections: string | null;
6
6
  origin: HTMLElement | undefined;
7
7
  get dragged(): HTMLElement;
@@ -9,7 +9,7 @@ declare class Sortable extends Draggable {
9
9
  }
10
10
  //#endregion
11
11
  //#region src/js/internal/draggable.d.ts
12
- declare abstract class Draggable {
12
+ declare abstract class OuiDraggable {
13
13
  prefix: string;
14
14
  element: HTMLElement;
15
15
  options: DraggableOptions;
@@ -22,10 +22,10 @@ declare abstract class Draggable {
22
22
  constructor(prefix: string, element: HTMLElement, options: DraggableOptions);
23
23
  destroy(): void;
24
24
  }
25
- type DragBegin = (event: MouseEvent | TouchEvent, state: DraggableState, draggable: Draggable, element: HTMLElement, handle: HTMLElement, position: EventPosition) => void;
26
- type DragCancel = (state: DraggableState, draggable: Draggable) => void;
27
- type DragEnd = (event: MouseEvent | TouchEvent, state: DraggableState, draggable: Draggable, reset: () => void) => void;
28
- type DragMove = (event: MouseEvent | TouchEvent, state: DraggableState, draggable: Draggable, position: DragMovePosition) => PlainObject | undefined;
25
+ type DragBegin = (event: MouseEvent | TouchEvent, state: DraggableState, draggable: OuiDraggable, element: HTMLElement, handle: HTMLElement, position: EventPosition) => void;
26
+ type DragCancel = (state: DraggableState, draggable: OuiDraggable) => void;
27
+ type DragEnd = (event: MouseEvent | TouchEvent, state: DraggableState, draggable: OuiDraggable, reset: () => void) => void;
28
+ type DragMove = (event: MouseEvent | TouchEvent, state: DraggableState, draggable: OuiDraggable, position: DragMovePosition) => PlainObject | undefined;
29
29
  type DragMovePosition = {
30
30
  calculated: EventPosition;
31
31
  original: EventPosition;
@@ -35,8 +35,8 @@ type DraggableBound<Property extends keyof DraggableInstances = keyof DraggableI
35
35
  property: Property;
36
36
  };
37
37
  type DraggableInstances = {
38
- movable?: Movable;
39
- sortable?: Sortable;
38
+ movable?: OuiMovable;
39
+ sortable?: OuiSortable;
40
40
  };
41
41
  type DraggableOptions = {
42
42
  container: DraggableOptionsContainer;
@@ -46,17 +46,17 @@ type DraggableOptions = {
46
46
  };
47
47
  type DraggableOptionsContainer = {
48
48
  attribute: string;
49
- map: Map<HTMLElement, Set<Draggable>>;
49
+ map: Map<HTMLElement, Set<OuiDraggable>>;
50
50
  onDestroy?: DraggableOptionsContainerOnDestroy;
51
51
  onInitialize?: DraggableOptionsContainerOnInitialize;
52
52
  };
53
- type DraggableOptionsContainerOnDestroy = (draggable: Draggable, container: HTMLElement, empty: boolean) => void;
54
- type DraggableOptionsContainerOnInitialize = (draggable: Draggable) => void;
53
+ type DraggableOptionsContainerOnDestroy = (draggable: OuiDraggable, container: HTMLElement, empty: boolean) => void;
54
+ type DraggableOptionsContainerOnInitialize = (draggable: OuiDraggable) => void;
55
55
  type DraggableOptionsDirection = {
56
56
  attribute: string;
57
57
  onAfter?: DraggableOptionsDirectionOnAfter;
58
58
  };
59
- type DraggableOptionsDirectionOnAfter = (draggable: Draggable) => void;
59
+ type DraggableOptionsDirectionOnAfter = (draggable: OuiDraggable) => void;
60
60
  type DraggableOptionsDrag = {
61
61
  onBegin: DragBegin;
62
62
  onCancel: DragCancel;
@@ -67,8 +67,8 @@ type DraggableOptionsPosition = {
67
67
  getOffset: DraggableOptionsPositionGetOffset;
68
68
  getOriginal: DraggableOptionsPositionGetOriginal;
69
69
  };
70
- type DraggableOptionsPositionGetOffset = (state: DraggableState, draggable: Draggable, element: HTMLElement, position: EventPosition) => EventPosition;
71
- type DraggableOptionsPositionGetOriginal = (state: DraggableState, draggable: Draggable, position: EventPosition) => EventPosition;
70
+ type DraggableOptionsPositionGetOffset = (state: DraggableState, draggable: OuiDraggable, element: HTMLElement, position: EventPosition) => EventPosition;
71
+ type DraggableOptionsPositionGetOriginal = (state: DraggableState, draggable: OuiDraggable, position: EventPosition) => EventPosition;
72
72
  type DraggableState = {
73
73
  container: DOMRect | undefined;
74
74
  element: DraggableStateElement | undefined;
@@ -87,7 +87,7 @@ declare function removeDraggable<Property extends keyof DraggableInstances, Inst
87
87
  }, element: HTMLElement): void;
88
88
  //#endregion
89
89
  //#region src/js/movable.d.ts
90
- declare class Movable extends Draggable {
90
+ declare class OuiMovable extends OuiDraggable {
91
91
  inset: string;
92
92
  moved: boolean;
93
93
  offset: Partial<EventPosition> | undefined;
@@ -98,4 +98,4 @@ declare class Movable extends Draggable {
98
98
  destroy(): void;
99
99
  }
100
100
  //#endregion
101
- export { DraggableState as a, Sortable as c, DraggableBound as i, DragMovePosition as n, addDraggable as o, Draggable as r, removeDraggable as s, Movable as t };
101
+ export { OuiDraggable as a, OuiSortable as c, DraggableState as i, DragMovePosition as n, addDraggable as o, DraggableBound as r, removeDraggable as s, OuiMovable as t };
@@ -1,2 +1,2 @@
1
- import { t as Movable } from "./movable-BKFgoaOl.mjs";
2
- export { Movable };
1
+ import { t as OuiMovable } from "./movable-dNqBctx3.mjs";
2
+ export { OuiMovable };
@@ -1,8 +1,8 @@
1
1
  import { attributable } from "./internal/attributable.mjs";
2
- import { Draggable, addDraggable, removeDraggable } from "./internal/draggable.mjs";
2
+ import { OuiDraggable, addDraggable, removeDraggable } from "./internal/draggable.mjs";
3
3
  import { getPosition, on } from "@oscarpalmer/toretto/event";
4
4
  //#region src/js/movable.ts
5
- var Movable = class extends Draggable {
5
+ var OuiMovable = class extends OuiDraggable {
6
6
  inset;
7
7
  moved = false;
8
8
  offset;
@@ -142,11 +142,11 @@ const EVENT_END = "move:end";
142
142
  const MOVED = /* @__PURE__ */ new Set();
143
143
  const SELECTOR_HANDLE = `[${ATTRIBUTE}-handle]`;
144
144
  const bound = {
145
- constructor: Movable,
145
+ constructor: OuiMovable,
146
146
  property: "movable"
147
147
  };
148
148
  const resizer = new ResizeObserver(onResize);
149
149
  attributable(ATTRIBUTE, addDraggable.bind(bound), removeDraggable.bind(bound));
150
150
  on(document, "scroll", onScroll);
151
151
  //#endregion
152
- export { Movable };
152
+ export { OuiMovable };
@@ -1 +1,38 @@
1
- export { };
1
+ import { n as OuiFloatable } from "./embedded-ai6cqURc.mjs";
2
+ import { i as OuiFocusTrap } from "./embedded-CHK82Uh5.mjs";
3
+ import { RemovableEventListener } from "@oscarpalmer/toretto/models";
4
+
5
+ //#region src/js/popover.d.ts
6
+ declare class OuiPopover {
7
+ #private;
8
+ /**
9
+ * Is the popover open?
10
+ */
11
+ get open(): boolean;
12
+ constructor(state: OuiPopoverState);
13
+ /**
14
+ * Closes the popover
15
+ */
16
+ hide(): void;
17
+ /**
18
+ * Opens the popover
19
+ */
20
+ show(): void;
21
+ }
22
+ type OuiPopoverState = {
23
+ anchor: HTMLElement;
24
+ content: HTMLElement;
25
+ floatable: OuiFloatable;
26
+ focusTrap?: OuiFocusTrap;
27
+ listeners: RemovableEventListener[];
28
+ popover: OuiPopover;
29
+ };
30
+ /**
31
+ * Get the _OuiPopover_ for an element
32
+ *
33
+ * @param element Element to get _OuiPopover_ for
34
+ * @returns _OuiPopover_ instance
35
+ */
36
+ declare function getPopover(element: HTMLElement): OuiPopover | undefined;
37
+ //#endregion
38
+ export { type OuiPopover, getPopover };