@oscarpalmer/oui 0.26.1 → 0.27.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 (64) hide show
  1. package/dist/css/floatable.css +0 -2
  2. package/dist/css/message.css +1 -0
  3. package/dist/css/reset.css +1 -0
  4. package/dist/js/dialog.d.mts +2 -0
  5. package/dist/js/dialog.mjs +16 -1
  6. package/dist/js/draggable-zszaW1qS.d.mts +155 -0
  7. package/dist/js/floatable/floatable.embedded.d.mts +2 -0
  8. package/dist/js/floatable/{embedded.mjs → floatable.embedded.mjs} +16 -11
  9. package/dist/js/floatable/floatable.standalone.d.mts +2 -0
  10. package/dist/js/floatable/floatable.standalone.mjs +2 -0
  11. package/dist/js/{embedded-CSOh5njI.d.mts → floatable.embedded-YxGwzgbE.d.mts} +5 -2
  12. package/dist/js/focus-trap/focus-trap.embedded.d.mts +2 -0
  13. package/dist/js/focus-trap/{embedded.mjs → focus-trap.embedded.mjs} +17 -15
  14. package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -0
  15. package/dist/js/focus-trap/focus-trap.standalone.mjs +2 -0
  16. package/dist/js/{embedded-CHK82Uh5.d.mts → focus-trap.embedded-DR8NpZfr.d.mts} +18 -18
  17. package/dist/js/index.d.mts +4 -3
  18. package/dist/js/index.mjs +8 -7
  19. package/dist/js/internal/draggable.d.mts +2 -2
  20. package/dist/js/internal/draggable.mjs +146 -94
  21. package/dist/js/movable/movable.embedded.d.mts +2 -0
  22. package/dist/js/movable/movable.embedded.mjs +184 -0
  23. package/dist/js/movable/movable.standalone.d.mts +2 -0
  24. package/dist/js/movable/movable.standalone.mjs +2 -0
  25. package/dist/js/popover.d.mts +2 -2
  26. package/dist/js/popover.mjs +4 -3
  27. package/dist/js/sortable/sortable.embedded.d.mts +2 -0
  28. package/dist/js/{sortable.mjs → sortable/sortable.embedded.mjs} +88 -63
  29. package/dist/js/sortable/sortable.standalone.d.mts +2 -0
  30. package/dist/js/sortable/sortable.standalone.mjs +2 -0
  31. package/dist/js/splitter.mjs +5 -5
  32. package/dist/js/toolbar.mjs +6 -6
  33. package/dist/js/tooltip.d.mts +2 -2
  34. package/dist/js/tooltip.mjs +36 -33
  35. package/package.json +11 -11
  36. package/src/css/floatable.scss +0 -2
  37. package/src/css/message.scss +1 -0
  38. package/src/css/reset.scss +1 -0
  39. package/src/js/dialog.ts +31 -1
  40. package/src/js/floatable/{embedded.ts → floatable.embedded.ts} +18 -10
  41. package/src/js/floatable/floatable.standalone.ts +6 -0
  42. package/src/js/focus-trap/{embedded.ts → focus-trap.embedded.ts} +20 -17
  43. package/src/js/focus-trap/focus-trap.standalone.ts +1 -0
  44. package/src/js/index.ts +4 -4
  45. package/src/js/internal/draggable.ts +309 -168
  46. package/src/js/movable/movable.embedded.ts +328 -0
  47. package/src/js/movable/movable.standalone.ts +2 -0
  48. package/src/js/popover.ts +3 -2
  49. package/src/js/{sortable.ts → sortable/sortable.embedded.ts} +170 -103
  50. package/src/js/sortable/sortable.standalone.ts +2 -0
  51. package/src/js/tooltip.ts +49 -43
  52. package/dist/js/floatable/embedded.d.mts +0 -2
  53. package/dist/js/floatable/standalone.d.mts +0 -2
  54. package/dist/js/floatable/standalone.mjs +0 -2
  55. package/dist/js/focus-trap/embedded.d.mts +0 -2
  56. package/dist/js/focus-trap/standalone.d.mts +0 -2
  57. package/dist/js/focus-trap/standalone.mjs +0 -6
  58. package/dist/js/movable-dNqBctx3.d.mts +0 -101
  59. package/dist/js/movable.d.mts +0 -2
  60. package/dist/js/movable.mjs +0 -152
  61. package/dist/js/sortable.d.mts +0 -2
  62. package/src/js/floatable/standalone.ts +0 -1
  63. package/src/js/focus-trap/standalone.ts +0 -6
  64. package/src/js/movable.ts +0 -260
@@ -86,8 +86,6 @@ var)) {
86
86
  :where([oui-tooltip-content]) {
87
87
  max-width: 48ch;
88
88
  padding: 0.75em 1em;
89
- overflow: visible;
90
- opacity: 0;
91
89
  background-color: var(--oui-absolute);
92
90
  border-radius: 0.25rem;
93
91
  font-size: 0.875rem;
@@ -19,6 +19,7 @@
19
19
  line-height: 1.25;
20
20
  }
21
21
  :where(.oui-message h2, .oui-message h3, .oui-message h4, .oui-message h5, .oui-message h6) {
22
+ color: var(--oui-foreground, var(--oui-gray-10));
22
23
  font-size: 1em;
23
24
  font-weight: bold;
24
25
  }
@@ -126,6 +126,7 @@ summary) {
126
126
 
127
127
  :where(dialog) {
128
128
  display: none !important;
129
+ overflow: visible;
129
130
  overscroll-behavior: contain;
130
131
  border: none;
131
132
  color: currentcolor;
@@ -1,3 +1,4 @@
1
+ import { h as OuiMovable } from "./draggable-zszaW1qS.mjs";
1
2
  import { RemovableEventListener } from "@oscarpalmer/toretto/models";
2
3
 
3
4
  //#region src/js/dialog.d.ts
@@ -30,6 +31,7 @@ type OuiDialogState = {
30
31
  element: HTMLDialogElement;
31
32
  listeners: RemovableEventListener[];
32
33
  modal: boolean;
34
+ movable?: OuiMovable;
33
35
  };
34
36
  /**
35
37
  * Get the _OuiDialog_ for an element
@@ -1,5 +1,7 @@
1
- import { getOnBeforeToggleListener } from "./floatable/embedded.mjs";
1
+ import { getOnBeforeToggleListener } from "./floatable/floatable.embedded.mjs";
2
2
  import { attributable } from "./internal/attributable.mjs";
3
+ import { ATTRIBUTE_MOVABLE_HANDLE, createMovable } from "./movable/movable.embedded.mjs";
4
+ import "./movable/movable.standalone.mjs";
3
5
  import { on } from "@oscarpalmer/toretto/event";
4
6
  //#region src/js/dialog.ts
5
7
  var OuiDialog = class {
@@ -59,6 +61,12 @@ function destroyDialog(state) {
59
61
  function getDialog(element) {
60
62
  return states.get(element)?.dialog;
61
63
  }
64
+ function getMovable(element) {
65
+ const handles = element.querySelectorAll(SELECTOR_MOVER);
66
+ if (handles.length === 0) return;
67
+ for (const handle of handles) handle.setAttribute(ATTRIBUTE_MOVABLE_HANDLE, "");
68
+ return createMovable(element, { container: element.getAttribute(ATTRIBUTE_CONTAINER) ?? void 0 });
69
+ }
62
70
  function getState(element) {
63
71
  const state = {
64
72
  element,
@@ -69,14 +77,19 @@ function getState(element) {
69
77
  const modal = source instanceof HTMLButtonElement && source.command === COMMAND_SHOW_MODAL || element.matches(SELECTOR_MODAL);
70
78
  element.setAttribute(ARIA_MODAL, String(modal));
71
79
  element.setAttribute(ATTRIBUTE_OPEN, "");
80
+ element.focus();
72
81
  } else {
73
82
  element.removeAttribute(ATTRIBUTE_OPEN);
74
83
  element.setAttribute(ARIA_MODAL, String(state.modal));
84
+ element.style.inset = "";
85
+ element.style.position = "";
86
+ element.style.transform = "";
75
87
  }
76
88
  })],
77
89
  modal: element.getAttribute(ARIA_MODAL) === TRUE
78
90
  };
79
91
  state.dialog = new OuiDialog(state);
92
+ state.movable = getMovable(element);
80
93
  return state;
81
94
  }
82
95
  function removeDialog(element) {
@@ -87,10 +100,12 @@ function removeDialog(element) {
87
100
  }
88
101
  const ARIA_MODAL = "aria-modal";
89
102
  const ATTRIBUTE = "oui-dialog";
103
+ const ATTRIBUTE_CONTAINER = `${ATTRIBUTE}-container`;
90
104
  const ATTRIBUTE_OPEN = `${ATTRIBUTE}-open`;
91
105
  const COMMAND_SHOW_MODAL = "show-modal";
92
106
  const EVENT_TOGGLE = "toggle";
93
107
  const MESSAGE = "The element must be an instance of HTMLDialogElement";
108
+ const SELECTOR_MOVER = `[${ATTRIBUTE}-mover]`;
94
109
  const SELECTOR_MODAL = ":modal";
95
110
  const TRUE = "true";
96
111
  const states = /* @__PURE__ */ new WeakMap();
@@ -0,0 +1,155 @@
1
+ import { StyleToggler } from "@oscarpalmer/toretto/style";
2
+ import { EventPosition, PlainObject } from "@oscarpalmer/atoms/models";
3
+
4
+ //#region src/js/movable/movable.embedded.d.ts
5
+ declare class OuiMovable extends OuiDraggable<OuiMovableState> {
6
+ #private;
7
+ constructor(element: HTMLElement, options?: CreateOuiDraggableOptions);
8
+ /**
9
+ * Destroys the _Movable_
10
+ */
11
+ destroy(): void;
12
+ }
13
+ type OuiMovableState = {
14
+ hasHandles?: boolean;
15
+ moved: boolean;
16
+ offset?: Partial<EventPosition>;
17
+ style: OuiMovableStyle;
18
+ };
19
+ type OuiMovableStyle = {
20
+ inset: string;
21
+ position: string;
22
+ };
23
+ /**
24
+ * Creates _(or retrieves)_ a _OuiMovable_ instance for an element
25
+ *
26
+ * @param element Element to make movable
27
+ * @returns _OuiMovable_ instance
28
+ */
29
+ declare function createMovable(element: HTMLElement, options?: CreateOuiDraggableOptions): OuiMovable;
30
+ declare const ATTRIBUTE_MOVABLE = "oui-movable";
31
+ declare const ATTRIBUTE_MOVABLE_HANDLE = "oui-movable-handle";
32
+ //#endregion
33
+ //#region src/js/sortable/sortable.embedded.d.ts
34
+ declare class OuiSortable extends OuiDraggable<OuiSortableState> {
35
+ constructor(element: HTMLElement, options?: CreateOuiDraggableOptions);
36
+ }
37
+ type OuiSortableState = {
38
+ connections: string | null;
39
+ origin?: HTMLElement;
40
+ };
41
+ /**
42
+ * Creates _(or retrieves)_ a _OuiSortable_ instance for an element
43
+ *
44
+ * @param element Element to make sortable
45
+ * @returns _OuiSortable_ instance
46
+ */
47
+ declare function createSortable(element: HTMLElement, options?: CreateOuiDraggableOptions): OuiSortable;
48
+ //#endregion
49
+ //#region src/js/internal/draggable.d.ts
50
+ type CreateOuiDraggableOptions = {
51
+ /**
52
+ * Container to hold the draggable element and restrict its movement within. Can be `body`, `document`, `window`, a _CSS_ selector, or an element. _(If not provided, the draggable element will not have any constraints)_
53
+ */
54
+ container?: string | HTMLElement;
55
+ /**
56
+ * Direction in which the element can be dragged. _(If not provided, the element can be dragged in any direction)_
57
+ */
58
+ direction?: OuiDraggableDirection;
59
+ };
60
+ type OuiDraggableDirection = 'horizontal' | 'vertical' | 'x' | 'y';
61
+ declare abstract class OuiDraggable<ExtraState extends PlainObject = PlainObject> {
62
+ #private;
63
+ get element(): HTMLElement;
64
+ constructor(name: keyof OuiDraggableStates, event: string, attribute: string, element: HTMLElement, options: OuiDraggableOptions<ExtraState>, extras: ExtraState);
65
+ destroy(): void;
66
+ }
67
+ type OuiDragBegin<State extends PlainObject = PlainObject> = (event: MouseEvent | TouchEvent, globals: OuiDraggableGlobals, item: OuiDraggableItem<State>, element: HTMLElement, handle: HTMLElement, position: EventPosition) => void;
68
+ type OuiDragCancel<State extends PlainObject = PlainObject> = (globals: OuiDraggableGlobals, item: OuiDraggableItem<State>) => void;
69
+ type OuiDragEnd<State extends PlainObject = PlainObject> = (event: MouseEvent | TouchEvent, globals: OuiDraggableGlobals, item: OuiDraggableItem<State>, reset: () => void) => void;
70
+ type OuiDragMove<State extends PlainObject = PlainObject> = (event: MouseEvent | TouchEvent, globals: OuiDraggableGlobals, item: OuiDraggableItem<State>, position: OuiDragMovePosition) => PlainObject | undefined;
71
+ type OuiDragMovePosition = {
72
+ calculated: EventPosition;
73
+ original: EventPosition;
74
+ };
75
+ type OuiDraggableBound<Property extends keyof OuiDraggableInstances = keyof OuiDraggableInstances, Instance extends OuiDraggableInstances[Property] = OuiDraggableInstances[Property]> = {
76
+ constructor: new (element: HTMLElement, options?: CreateOuiDraggableOptions) => Instance;
77
+ property: Property;
78
+ };
79
+ type OuiDraggableGlobals = {
80
+ container?: DOMRect;
81
+ element?: OuiDraggableGlobalsElement;
82
+ instances: WeakMap<HTMLElement, OuiDraggableInstances>;
83
+ offset?: EventPosition;
84
+ original?: EventPosition;
85
+ states: WeakMap<HTMLElement, OuiDraggableStates>;
86
+ };
87
+ type OuiDraggableGlobalsElement = {
88
+ node: HTMLElement;
89
+ rectangle: DOMRect;
90
+ };
91
+ type OuiDraggableInstances = {
92
+ movable?: OuiMovable;
93
+ sortable?: OuiSortable;
94
+ };
95
+ type OuiDraggableItem<ExtraState extends PlainObject = PlainObject> = {
96
+ instance: OuiDraggable<ExtraState>;
97
+ state: OuiDraggableState & ExtraState;
98
+ };
99
+ type OuiDraggableOptions<ExtraState extends PlainObject = PlainObject> = {
100
+ container: OuiDraggableOptionsContainer<ExtraState>;
101
+ direction: OuiDraggableOptionsDirection<ExtraState>;
102
+ drag: OuiDraggableOptionsDrag<ExtraState>;
103
+ input?: CreateOuiDraggableOptions;
104
+ position: OuiDraggableOptionsPosition<ExtraState>;
105
+ getDragged(): HTMLElement;
106
+ getOrigin(): HTMLElement | undefined;
107
+ };
108
+ type OuiDraggableOptionsContainer<ExtraState extends PlainObject = PlainObject> = {
109
+ attribute: string;
110
+ map: Map<HTMLElement, Set<OuiDraggable>>;
111
+ onDestroy?: OuiDraggableOptionsContainerOnDestroy<ExtraState>;
112
+ onInitialize?: OuiDraggableOptionsContainerOnInitialize;
113
+ };
114
+ type OuiDraggableOptionsContainerOnDestroy<ExtraState extends PlainObject = PlainObject> = (item: OuiDraggableItem<ExtraState>, container: HTMLElement, empty: boolean) => void;
115
+ type OuiDraggableOptionsContainerOnInitialize<ExtraState extends PlainObject = PlainObject> = (item: OuiDraggableItem<ExtraState>) => void;
116
+ type OuiDraggableOptionsDirection<ExtraState extends PlainObject = PlainObject> = {
117
+ attribute: string;
118
+ onAfter?: OuiDraggableOptionsDirectionOnAfter<ExtraState>;
119
+ };
120
+ type OuiDraggableOptionsDirectionOnAfter<ExtraState extends PlainObject = PlainObject> = (item: OuiDraggableItem<ExtraState>) => void;
121
+ type OuiDraggableOptionsDrag<ExtraState extends PlainObject = PlainObject> = {
122
+ onBegin: OuiDragBegin<ExtraState>;
123
+ onCancel: OuiDragCancel<ExtraState>;
124
+ onEnd: OuiDragEnd<ExtraState>;
125
+ onMove: OuiDragMove<ExtraState>;
126
+ };
127
+ type OuiDraggableOptionsPosition<ExtraState extends PlainObject = PlainObject> = {
128
+ getOffset: OuiDraggableOptionsPositionGetOffset<ExtraState>;
129
+ getOriginal: OuiDraggableOptionsPositionGetOriginal<ExtraState>;
130
+ };
131
+ type OuiDraggableOptionsPositionGetOffset<ExtraState extends PlainObject = PlainObject> = (globals: OuiDraggableGlobals, item: OuiDraggableItem<ExtraState>, element: HTMLElement, position: EventPosition) => EventPosition;
132
+ type OuiDraggableOptionsPositionGetOriginal<ExtraState extends PlainObject = PlainObject> = (globals: OuiDraggableGlobals, item: OuiDraggableItem<ExtraState>, position: EventPosition) => EventPosition;
133
+ type OuiDraggableState = {
134
+ attribute: string;
135
+ container?: HTMLElement;
136
+ element: HTMLElement;
137
+ event: string;
138
+ hasHandles?: boolean;
139
+ horizontal: boolean;
140
+ options: OuiDraggableOptions;
141
+ styling: StyleToggler;
142
+ vertical: boolean;
143
+ };
144
+ type OuiDraggableStates = {
145
+ movable?: OuiDraggableState;
146
+ sortable?: OuiDraggableState;
147
+ };
148
+ declare function addDraggable<Property extends keyof OuiDraggableInstances, Instance extends OuiDraggableInstances[Property]>(this: OuiDraggableBound<Property, Instance>, element: HTMLElement, options?: CreateOuiDraggableOptions): Instance;
149
+ declare function getDraggableStates(element: HTMLElement): OuiDraggableStates | undefined;
150
+ declare function removeDraggable<Property extends keyof OuiDraggableInstances, Instance extends OuiDraggableInstances[Property]>(this: {
151
+ constructor: new (element: HTMLElement) => Instance;
152
+ property: Property;
153
+ }, element: HTMLElement): void;
154
+ //#endregion
155
+ export { OuiDraggableGlobals as a, addDraggable as c, OuiSortable as d, createSortable as f, createMovable as g, OuiMovable as h, OuiDraggableBound as i, getDraggableStates as l, ATTRIBUTE_MOVABLE_HANDLE as m, OuiDragMovePosition as n, OuiDraggableItem as o, ATTRIBUTE_MOVABLE as p, OuiDraggable as r, OuiDraggableState as s, CreateOuiDraggableOptions as t, removeDraggable as u };
@@ -0,0 +1,2 @@
1
+ import { a as OuiFloatableOptions, c as createFloatable, i as OuiFloatable, l as getOnBeforeToggleListener, n as CreateOuiFloatableOptions, o as OuiFloatablePosition, r as FLOATABLE_STATE_OPEN, s as createEmbeddedFloatable, t as ATTRIBUTE_FLOATABLE, u as removeFloatable } from "../floatable.embedded-YxGwzgbE.mjs";
2
+ export { ATTRIBUTE_FLOATABLE, CreateOuiFloatableOptions, FLOATABLE_STATE_OPEN, OuiFloatable, OuiFloatableOptions, OuiFloatablePosition, createEmbeddedFloatable, createFloatable, getOnBeforeToggleListener, removeFloatable };
@@ -1,7 +1,7 @@
1
1
  import { on } from "@oscarpalmer/toretto/event";
2
2
  import { isPlainObject } from "@oscarpalmer/atoms/is";
3
3
  import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
4
- //#region src/js/floatable/embedded.ts
4
+ //#region src/js/floatable/floatable.embedded.ts
5
5
  var OuiFloatable = class {
6
6
  #destroyed = false;
7
7
  #state;
@@ -25,9 +25,8 @@ var OuiFloatable = class {
25
25
  content.setAttribute(ATTRIBUTE_FLOATABLE, "");
26
26
  content.popover = "manual";
27
27
  }
28
- const anchorName = getAnchorName(anchor);
29
- anchor.style.anchorName = anchorName;
30
- content.style.positionAnchor = anchorName;
28
+ anchor.style.anchorName = state.name;
29
+ content.style.positionAnchor = state.name;
31
30
  }
32
31
  /**
33
32
  * Destroy the floatable, removing it from the DOM and cleaning up references
@@ -79,24 +78,27 @@ function createEmbeddedFloatable(anchor, content, options) {
79
78
  */
80
79
  function createFloatable(anchor, content, options) {
81
80
  const { open, position } = getOptions(options);
82
- const floatable = createInstance(anchor, content, { position }, true);
81
+ const floatable = createInstance(anchor, content, {
82
+ position,
83
+ reusable: false
84
+ }, true);
83
85
  floatable?.update(position);
84
86
  if (open) floatable?.show();
85
87
  return floatable;
86
88
  }
87
89
  function createInstance(anchor, content, options, standalone) {
88
90
  if (!isHTMLOrSVGElement(anchor) || !isHTMLOrSVGElement(content)) throw new TypeError(MESSAGE);
89
- let floatable = instances.get(content);
91
+ let floatable = options.reusable ? void 0 : instances.get(content);
90
92
  if (floatable == null) {
91
93
  floatable = new OuiFloatable(getState(anchor, content, options), standalone);
92
- instances.set(content, floatable);
94
+ if (!options.reusable) instances.set(content, floatable);
93
95
  }
94
96
  return floatable;
95
97
  }
96
98
  function getOnBeforeToggleListener(element) {
97
99
  return on(element, EVENT_BEFORE, (event) => {
98
100
  const { newState, source } = event;
99
- if (newState === STATE_OPEN && source?.getAttribute(ARIA_DISABLED) === TRUE) event.preventDefault();
101
+ if (newState === "open" && source?.getAttribute(ARIA_DISABLED) === TRUE) event.preventDefault();
100
102
  }, { passive: false });
101
103
  }
102
104
  function getOptions(input) {
@@ -117,6 +119,7 @@ function getState(anchor, content, options) {
117
119
  return {
118
120
  anchor,
119
121
  content,
122
+ name: getAnchorName(anchor),
120
123
  options
121
124
  };
122
125
  }
@@ -125,7 +128,9 @@ function removeFloatable(content) {
125
128
  instances.delete(content);
126
129
  }
127
130
  function setPosition(state, override) {
128
- const area = AREAS[getPosition$1(state, override)];
131
+ const position = getPosition$1(state, override);
132
+ const area = AREAS[position];
133
+ state.content.style.positionAnchor = state.name;
129
134
  state.content.style.positionArea = area;
130
135
  state.content.setAttribute(ATTRIBUTE_POSITION, POSITIONS[area]);
131
136
  }
@@ -147,11 +152,11 @@ const ARIA_DISABLED = "aria-disabled";
147
152
  const ATTRIBUTE_FLOATABLE = "oui-floatable";
148
153
  const ATTRIBUTE_POSITION = "oui-position";
149
154
  const EVENT_BEFORE = "beforetoggle";
155
+ const FLOATABLE_STATE_OPEN = "open";
150
156
  const MESSAGE = "Anchor and content must be an HTMLElement or SVGElement";
151
157
  const POSITIONS = Object.fromEntries(Object.entries(AREAS).map(([position, area]) => [area, position]));
152
- const STATE_OPEN = "open";
153
158
  const TRUE = "true";
154
159
  const instances = /* @__PURE__ */ new WeakMap();
155
160
  let index = 0;
156
161
  //#endregion
157
- export { ATTRIBUTE_FLOATABLE, OuiFloatable, createEmbeddedFloatable, createFloatable, getOnBeforeToggleListener, removeFloatable };
162
+ export { ATTRIBUTE_FLOATABLE, FLOATABLE_STATE_OPEN, OuiFloatable, createEmbeddedFloatable, createFloatable, getOnBeforeToggleListener, removeFloatable };
@@ -0,0 +1,2 @@
1
+ import { c as createFloatable, i as OuiFloatable, n as CreateOuiFloatableOptions, o as OuiFloatablePosition } from "../floatable.embedded-YxGwzgbE.mjs";
2
+ export { type CreateOuiFloatableOptions, type OuiFloatable, type OuiFloatablePosition, createFloatable };
@@ -0,0 +1,2 @@
1
+ import { createFloatable } from "./floatable.embedded.mjs";
2
+ export { createFloatable };
@@ -1,6 +1,6 @@
1
1
  import { RemovableEventListener } from "@oscarpalmer/toretto/models";
2
2
 
3
- //#region src/js/floatable/embedded.d.ts
3
+ //#region src/js/floatable/floatable.embedded.d.ts
4
4
  type CreateOuiFloatableOptions = {
5
5
  /**
6
6
  * Open the floatable when created? _(defaults to `true`)_
@@ -44,11 +44,13 @@ declare class OuiFloatable {
44
44
  type OuiFloatableOptions = {
45
45
  attribute?: string;
46
46
  position: OuiFloatablePosition;
47
+ reusable: boolean;
47
48
  };
48
49
  type OuiFloatablePosition = 'above' | 'above-end' | 'above-start' | 'below' | 'below-end' | 'below-start' | 'end' | 'end-bottom' | 'end-top' | 'start' | 'start-bottom' | 'start-top';
49
50
  type OuiFloatableState = {
50
51
  anchor: HTMLElement;
51
52
  content: HTMLElement;
53
+ name: string;
52
54
  options: OuiFloatableOptions;
53
55
  };
54
56
  declare function createEmbeddedFloatable(anchor: HTMLElement, content: HTMLElement, options: OuiFloatableOptions): OuiFloatable;
@@ -64,5 +66,6 @@ declare function createFloatable(anchor: HTMLElement, content: HTMLElement, opti
64
66
  declare function getOnBeforeToggleListener(element: HTMLElement): RemovableEventListener;
65
67
  declare function removeFloatable(content: HTMLElement): void;
66
68
  declare const ATTRIBUTE_FLOATABLE = "oui-floatable";
69
+ declare const FLOATABLE_STATE_OPEN = "open";
67
70
  //#endregion
68
- export { createEmbeddedFloatable as a, removeFloatable as c, OuiFloatablePosition as i, OuiFloatable as n, createFloatable as o, OuiFloatableOptions as r, getOnBeforeToggleListener as s, ATTRIBUTE_FLOATABLE as t };
71
+ export { OuiFloatableOptions as a, createFloatable as c, OuiFloatable as i, getOnBeforeToggleListener as l, CreateOuiFloatableOptions as n, OuiFloatablePosition as o, FLOATABLE_STATE_OPEN as r, createEmbeddedFloatable as s, ATTRIBUTE_FLOATABLE as t, removeFloatable as u };
@@ -0,0 +1,2 @@
1
+ import { a as OuiFocusTrapOptions, i as OuiFocusTrap, n as ATTRIBUTE_FOCUSTRAP_CONTAIN, o as createFocusTrap, r as ATTRIBUTE_FOCUSTRAP_NOESCAPE, s as removeFocusTrap, t as ATTRIBUTE_FOCUSTRAP } from "../focus-trap.embedded-DR8NpZfr.mjs";
2
+ export { ATTRIBUTE_FOCUSTRAP, ATTRIBUTE_FOCUSTRAP_CONTAIN, ATTRIBUTE_FOCUSTRAP_NOESCAPE, OuiFocusTrap, OuiFocusTrapOptions, createFocusTrap, removeFocusTrap };
@@ -1,48 +1,49 @@
1
+ import { attributable } from "../internal/attributable.mjs";
1
2
  import { on } from "@oscarpalmer/toretto/event";
2
3
  import { isPlainObject } from "@oscarpalmer/atoms/is";
3
4
  import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
4
5
  import { clamp } from "@oscarpalmer/atoms/number";
5
6
  import { findAncestor } from "@oscarpalmer/toretto/find";
6
7
  import { getFocusable } from "@oscarpalmer/toretto/focusable";
7
- //#region src/js/focus-trap/embedded.ts
8
+ //#region src/js/focus-trap/focus-trap.embedded.ts
8
9
  var OuiFocusTrap = class {
9
10
  #destroyed = false;
10
11
  #tabIndex;
11
12
  #state;
12
13
  /**
13
- * Is focused maintained within the _FocusTrap_ when clicking outside of it?
14
+ * Is focused maintained within the _focus trap_ when clicking outside of it?
14
15
  */
15
16
  get contain() {
16
17
  return this.#state.element.hasAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN);
17
18
  }
18
19
  /**
19
- * Should focus be maintained within the _FocusTrap_ when clicking outside of it?
20
+ * Should focus be maintained within the _focus trap_ when clicking outside of it?
20
21
  */
21
22
  set contain(value) {
22
23
  if (value === true) this.#state.element.setAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN, "");
23
24
  else if (value === false) this.#state.element.removeAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN);
24
25
  }
25
26
  /**
26
- * Is the _FocusTrap_ disabled?
27
+ * Is the _focus trap_ disabled?
27
28
  */
28
29
  get disabled() {
29
30
  return this.#state.disabled;
30
31
  }
31
32
  /**
32
- * Should the _FocusTrap_ be disabled?
33
+ * Should the _focus trap_ be disabled?
33
34
  */
34
35
  set disabled(value) {
35
36
  if (value === true) this.disable();
36
37
  else if (value === false) this.enable();
37
38
  }
38
39
  /**
39
- * Is focus allowed to escape when pressing _Escape_ within the _FocusTrap_?
40
+ * Is focus allowed to escape when pressing _Escape_ within the _focus trap_?
40
41
  */
41
42
  get noescape() {
42
43
  return this.#state.element.hasAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE);
43
44
  }
44
45
  /**
45
- * Should the _FocusTrap_ allow focus to escape when pressing _Escape_?
46
+ * Should the _focus trap_ allow focus to escape when pressing _Escape_?
46
47
  */
47
48
  set noescape(value) {
48
49
  if (value === true) this.#state.element.setAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE, "");
@@ -58,7 +59,7 @@ var OuiFocusTrap = class {
58
59
  states.set(this, state);
59
60
  }
60
61
  /**
61
- * Destroys the _FocusTrap_
62
+ * Destroys the _focus trap_
62
63
  */
63
64
  destroy() {
64
65
  if (this.#destroyed) return;
@@ -73,32 +74,32 @@ var OuiFocusTrap = class {
73
74
  this.#state.element = void 0;
74
75
  }
75
76
  /**
76
- * Disables the _FocusTrap_
77
+ * Disables the _focus trap_
77
78
  */
78
79
  disable() {
79
80
  if (!this.#destroyed && !(this.disabled || this.#state.options.noescape)) setDisabled(this, this.#state, true);
80
81
  }
81
82
  /**
82
- * Enables the _FocusTrap_
83
+ * Enables the _focus trap_
83
84
  */
84
85
  enable() {
85
86
  if (!this.#destroyed && this.disabled) setDisabled(this, this.#state, false);
86
87
  }
87
88
  /**
88
- * Focuses the _FocusTrap_
89
+ * Focuses the _focus trap_
89
90
  *
90
- * @param last When `true`, focuses the last focusable element within the _FocusTrap_ instead of the first
91
+ * @param last When `true`, focuses the last focusable element within the _focus trap_ instead of the first
91
92
  */
92
93
  focus(last) {
93
94
  if (!this.#destroyed && !this.disabled) tabToTrap(this, getFocusable(this.#state.element), this.#state.element, last ? -1 : 0);
94
95
  }
95
96
  };
96
97
  /**
97
- * Creates _(or retrieves)_ a _FocusTrap_ for an element
98
+ * Creates _(or retrieves)_ a _focus trap_ for an element
98
99
  *
99
100
  * @param element Element to trap focus within
100
- * @param options _FocusTrap_ options
101
- * @returns _FocusTrap_ instance
101
+ * @param options _Focus trap_ options
102
+ * @returns _Focus trap_ instance
102
103
  */
103
104
  function createFocusTrap(element, options) {
104
105
  if (!isHTMLOrSVGElement(element)) throw new TypeError(MESSAGE);
@@ -226,6 +227,7 @@ const disabled = /* @__PURE__ */ new Set();
226
227
  const instances = /* @__PURE__ */ new WeakMap();
227
228
  const states = /* @__PURE__ */ new WeakMap();
228
229
  let lastTarget;
230
+ attributable(ATTRIBUTE_FOCUSTRAP, createFocusTrap, removeFocusTrap);
229
231
  on(document, "focusin", onFocusIn, EVENT_OPTIONS);
230
232
  on(document, "keydown", onKeydown, EVENT_OPTIONS);
231
233
  on(document, "mousedown", onPointerdown, EVENT_OPTIONS);
@@ -0,0 +1,2 @@
1
+ import { a as OuiFocusTrapOptions, i as OuiFocusTrap, o as createFocusTrap } from "../focus-trap.embedded-DR8NpZfr.mjs";
2
+ export { type OuiFocusTrap, type OuiFocusTrapOptions, createFocusTrap };
@@ -0,0 +1,2 @@
1
+ import { createFocusTrap } from "./focus-trap.embedded.mjs";
2
+ export { createFocusTrap };
@@ -1,57 +1,57 @@
1
- //#region src/js/focus-trap/embedded.d.ts
1
+ //#region src/js/focus-trap/focus-trap.embedded.d.ts
2
2
  declare class OuiFocusTrap {
3
3
  #private;
4
4
  /**
5
- * Is focused maintained within the _FocusTrap_ when clicking outside of it?
5
+ * Is focused maintained within the _focus trap_ when clicking outside of it?
6
6
  */
7
7
  get contain(): boolean;
8
8
  /**
9
- * Should focus be maintained within the _FocusTrap_ when clicking outside of it?
9
+ * Should focus be maintained within the _focus trap_ when clicking outside of it?
10
10
  */
11
11
  set contain(value: boolean);
12
12
  /**
13
- * Is the _FocusTrap_ disabled?
13
+ * Is the _focus trap_ disabled?
14
14
  */
15
15
  get disabled(): boolean;
16
16
  /**
17
- * Should the _FocusTrap_ be disabled?
17
+ * Should the _focus trap_ be disabled?
18
18
  */
19
19
  set disabled(value: boolean);
20
20
  /**
21
- * Is focus allowed to escape when pressing _Escape_ within the _FocusTrap_?
21
+ * Is focus allowed to escape when pressing _Escape_ within the _focus trap_?
22
22
  */
23
23
  get noescape(): boolean;
24
24
  /**
25
- * Should the _FocusTrap_ allow focus to escape when pressing _Escape_?
25
+ * Should the _focus trap_ allow focus to escape when pressing _Escape_?
26
26
  */
27
27
  set noescape(value: boolean);
28
28
  constructor(state: OuiFocusTrapState);
29
29
  /**
30
- * Destroys the _FocusTrap_
30
+ * Destroys the _focus trap_
31
31
  */
32
32
  destroy(): void;
33
33
  /**
34
- * Disables the _FocusTrap_
34
+ * Disables the _focus trap_
35
35
  */
36
36
  disable(): void;
37
37
  /**
38
- * Enables the _FocusTrap_
38
+ * Enables the _focus trap_
39
39
  */
40
40
  enable(): void;
41
41
  /**
42
- * Focuses the _FocusTrap_
42
+ * Focuses the _focus trap_
43
43
  *
44
- * @param last When `true`, focuses the last focusable element within the _FocusTrap_ instead of the first
44
+ * @param last When `true`, focuses the last focusable element within the _focus trap_ instead of the first
45
45
  */
46
46
  focus(last: boolean): void;
47
47
  }
48
48
  type OuiFocusTrapOptions = {
49
49
  /**
50
- * Should focus be maintained within the _FocusTrap_ when clicking outside of it?
50
+ * Should focus be maintained within the _focus trap_ when clicking outside of it?
51
51
  */
52
52
  contain?: boolean;
53
53
  /**
54
- * Should the _FocusTrap_ allow focus to escape when pressing _Escape_?
54
+ * Should the _focus trap_ allow focus to escape when pressing _Escape_?
55
55
  */
56
56
  noescape?: boolean;
57
57
  };
@@ -61,11 +61,11 @@ type OuiFocusTrapState = {
61
61
  options: Required<OuiFocusTrapOptions>;
62
62
  };
63
63
  /**
64
- * Creates _(or retrieves)_ a _FocusTrap_ for an element
64
+ * Creates _(or retrieves)_ a _focus trap_ for an element
65
65
  *
66
66
  * @param element Element to trap focus within
67
- * @param options _FocusTrap_ options
68
- * @returns _FocusTrap_ instance
67
+ * @param options _Focus trap_ options
68
+ * @returns _Focus trap_ instance
69
69
  */
70
70
  declare function createFocusTrap(element: HTMLElement, options?: OuiFocusTrapOptions): OuiFocusTrap;
71
71
  declare function removeFocusTrap(element: HTMLElement): void;
@@ -73,4 +73,4 @@ declare const ATTRIBUTE_FOCUSTRAP = "oui-focus-trap";
73
73
  declare const ATTRIBUTE_FOCUSTRAP_CONTAIN = "oui-focus-trap-contain";
74
74
  declare const ATTRIBUTE_FOCUSTRAP_NOESCAPE = "oui-focus-trap-noescape";
75
75
  //#endregion
76
- export { createFocusTrap as a, OuiFocusTrap as i, ATTRIBUTE_FOCUSTRAP_CONTAIN as n, removeFocusTrap as o, ATTRIBUTE_FOCUSTRAP_NOESCAPE as r, ATTRIBUTE_FOCUSTRAP as t };
76
+ export { OuiFocusTrapOptions as a, OuiFocusTrap as i, ATTRIBUTE_FOCUSTRAP_CONTAIN as n, createFocusTrap as o, ATTRIBUTE_FOCUSTRAP_NOESCAPE as r, removeFocusTrap as s, ATTRIBUTE_FOCUSTRAP as t };
@@ -1,7 +1,8 @@
1
+ import { g as createMovable, h as OuiMovable, t as CreateOuiDraggableOptions } from "./draggable-zszaW1qS.mjs";
1
2
  import { OuiDialog, getDialog } from "./dialog.mjs";
2
- import { i as OuiFloatablePosition, n as OuiFloatable, o as createFloatable } from "./embedded-CSOh5njI.mjs";
3
- import { a as createFocusTrap, i as OuiFocusTrap } from "./embedded-CHK82Uh5.mjs";
3
+ import { c as createFloatable, i as OuiFloatable, n as CreateOuiFloatableOptions, o as OuiFloatablePosition } from "./floatable.embedded-YxGwzgbE.mjs";
4
+ import { a as OuiFocusTrapOptions, i as OuiFocusTrap, o as createFocusTrap } from "./focus-trap.embedded-DR8NpZfr.mjs";
4
5
  import { OuiPopover, getPopover } from "./popover.mjs";
5
6
  import { OuiSplitterElement } from "./splitter.mjs";
6
7
  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 };
8
+ export { type CreateOuiFloatableOptions, type CreateOuiDraggableOptions as CreateOuiMovableOptions, type OuiDialog, type OuiFloatable, type OuiFloatablePosition, type OuiFocusTrap, type OuiFocusTrapOptions, type OuiMovable, type OuiPopover, OuiSplitterElement, type OuiTooltip, createFloatable, createFocusTrap, createMovable, getDialog, getPopover, getTooltip, setTooltipDelay };
package/dist/js/index.mjs CHANGED
@@ -1,12 +1,13 @@
1
- import { createFloatable } from "./floatable/embedded.mjs";
1
+ import { createFloatable } from "./floatable/floatable.embedded.mjs";
2
+ import { createMovable } from "./movable/movable.embedded.mjs";
3
+ import "./movable/movable.standalone.mjs";
2
4
  import { getDialog } from "./dialog.mjs";
3
- import "./movable.mjs";
4
- import "./sortable.mjs";
5
+ import "./sortable/sortable.embedded.mjs";
5
6
  import "./toolbar.mjs";
6
- import "./floatable/standalone.mjs";
7
- import { createFocusTrap } from "./focus-trap/embedded.mjs";
8
- import "./focus-trap/standalone.mjs";
7
+ import "./floatable/floatable.standalone.mjs";
8
+ import { createFocusTrap } from "./focus-trap/focus-trap.embedded.mjs";
9
+ import "./focus-trap/focus-trap.standalone.mjs";
9
10
  import { getPopover } from "./popover.mjs";
10
11
  import { OuiSplitterElement } from "./splitter.mjs";
11
12
  import { getTooltip, setTooltipDelay } from "./tooltip.mjs";
12
- export { OuiSplitterElement, createFloatable, createFocusTrap, getDialog, getPopover, getTooltip, setTooltipDelay };
13
+ export { OuiSplitterElement, createFloatable, createFocusTrap, createMovable, getDialog, getPopover, getTooltip, setTooltipDelay };
@@ -1,2 +1,2 @@
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
+ 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-zszaW1qS.mjs";
2
+ export { CreateOuiDraggableOptions, OuiDragMovePosition, OuiDraggable, OuiDraggableBound, OuiDraggableGlobals, OuiDraggableItem, OuiDraggableState, addDraggable, getDraggableStates, removeDraggable };