@oscarpalmer/oui 0.26.0 → 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 (66) 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 +6 -0
  5. package/dist/js/dialog.mjs +23 -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} +22 -17
  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-ai6cqURc.d.mts → floatable.embedded-YxGwzgbE.d.mts} +13 -10
  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 +3 -2
  26. package/dist/js/popover.mjs +8 -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.d.mts +24 -0
  32. package/dist/js/splitter.mjs +33 -9
  33. package/dist/js/toolbar.mjs +6 -6
  34. package/dist/js/tooltip.d.mts +12 -2
  35. package/dist/js/tooltip.mjs +49 -33
  36. package/package.json +11 -11
  37. package/src/css/floatable.scss +0 -2
  38. package/src/css/message.scss +1 -0
  39. package/src/css/reset.scss +1 -0
  40. package/src/js/dialog.ts +42 -1
  41. package/src/js/floatable/{embedded.ts → floatable.embedded.ts} +26 -18
  42. package/src/js/floatable/floatable.standalone.ts +6 -0
  43. package/src/js/focus-trap/{embedded.ts → focus-trap.embedded.ts} +20 -17
  44. package/src/js/focus-trap/focus-trap.standalone.ts +1 -0
  45. package/src/js/index.ts +4 -4
  46. package/src/js/internal/draggable.ts +309 -168
  47. package/src/js/movable/movable.embedded.ts +328 -0
  48. package/src/js/movable/movable.standalone.ts +2 -0
  49. package/src/js/popover.ts +11 -2
  50. package/src/js/{sortable.ts → sortable/sortable.embedded.ts} +170 -103
  51. package/src/js/sortable/sortable.standalone.ts +2 -0
  52. package/src/js/splitter.ts +28 -4
  53. package/src/js/tooltip.ts +66 -43
  54. package/dist/js/floatable/embedded.d.mts +0 -2
  55. package/dist/js/floatable/standalone.d.mts +0 -2
  56. package/dist/js/floatable/standalone.mjs +0 -2
  57. package/dist/js/focus-trap/embedded.d.mts +0 -2
  58. package/dist/js/focus-trap/standalone.d.mts +0 -2
  59. package/dist/js/focus-trap/standalone.mjs +0 -6
  60. package/dist/js/movable-dNqBctx3.d.mts +0 -101
  61. package/dist/js/movable.d.mts +0 -2
  62. package/dist/js/movable.mjs +0 -152
  63. package/dist/js/sortable.d.mts +0 -2
  64. package/src/js/floatable/standalone.ts +0 -1
  65. package/src/js/focus-trap/standalone.ts +0 -6
  66. package/src/js/movable.ts +0 -260
@@ -4,6 +4,7 @@ import {on} from '@oscarpalmer/toretto/event';
4
4
  import {findAncestor} from '@oscarpalmer/toretto/find';
5
5
  import {getFocusable} from '@oscarpalmer/toretto/focusable';
6
6
  import {isHTMLOrSVGElement} from '@oscarpalmer/toretto/is';
7
+ import {attributable} from '../internal/attributable';
7
8
 
8
9
  // #region Types
9
10
 
@@ -14,14 +15,14 @@ export class OuiFocusTrap {
14
15
  readonly #state: OuiFocusTrapState;
15
16
 
16
17
  /**
17
- * Is focused maintained within the _FocusTrap_ when clicking outside of it?
18
+ * Is focused maintained within the _focus trap_ when clicking outside of it?
18
19
  */
19
20
  get contain(): boolean {
20
21
  return this.#state.element.hasAttribute(ATTRIBUTE_FOCUSTRAP_CONTAIN);
21
22
  }
22
23
 
23
24
  /**
24
- * Should focus be maintained within the _FocusTrap_ when clicking outside of it?
25
+ * Should focus be maintained within the _focus trap_ when clicking outside of it?
25
26
  */
26
27
  set contain(value: boolean) {
27
28
  if (value === true) {
@@ -32,14 +33,14 @@ export class OuiFocusTrap {
32
33
  }
33
34
 
34
35
  /**
35
- * Is the _FocusTrap_ disabled?
36
+ * Is the _focus trap_ disabled?
36
37
  */
37
38
  get disabled(): boolean {
38
39
  return this.#state.disabled;
39
40
  }
40
41
 
41
42
  /**
42
- * Should the _FocusTrap_ be disabled?
43
+ * Should the _focus trap_ be disabled?
43
44
  */
44
45
  set disabled(value: boolean) {
45
46
  if (value === true) {
@@ -50,14 +51,14 @@ export class OuiFocusTrap {
50
51
  }
51
52
 
52
53
  /**
53
- * Is focus allowed to escape when pressing _Escape_ within the _FocusTrap_?
54
+ * Is focus allowed to escape when pressing _Escape_ within the _focus trap_?
54
55
  */
55
56
  get noescape(): boolean {
56
57
  return this.#state.element.hasAttribute(ATTRIBUTE_FOCUSTRAP_NOESCAPE);
57
58
  }
58
59
 
59
60
  /**
60
- * Should the _FocusTrap_ allow focus to escape when pressing _Escape_?
61
+ * Should the _focus trap_ allow focus to escape when pressing _Escape_?
61
62
  */
62
63
  set noescape(value: boolean) {
63
64
  if (value === true) {
@@ -82,7 +83,7 @@ export class OuiFocusTrap {
82
83
  }
83
84
 
84
85
  /**
85
- * Destroys the _FocusTrap_
86
+ * Destroys the _focus trap_
86
87
  */
87
88
  destroy(): void {
88
89
  if (this.#destroyed) {
@@ -105,7 +106,7 @@ export class OuiFocusTrap {
105
106
  }
106
107
 
107
108
  /**
108
- * Disables the _FocusTrap_
109
+ * Disables the _focus trap_
109
110
  */
110
111
  disable(): void {
111
112
  if (!this.#destroyed && !(this.disabled || this.#state.options.noescape)) {
@@ -114,7 +115,7 @@ export class OuiFocusTrap {
114
115
  }
115
116
 
116
117
  /**
117
- * Enables the _FocusTrap_
118
+ * Enables the _focus trap_
118
119
  */
119
120
  enable(): void {
120
121
  if (!this.#destroyed && this.disabled) {
@@ -123,9 +124,9 @@ export class OuiFocusTrap {
123
124
  }
124
125
 
125
126
  /**
126
- * Focuses the _FocusTrap_
127
+ * Focuses the _focus trap_
127
128
  *
128
- * @param last When `true`, focuses the last focusable element within the _FocusTrap_ instead of the first
129
+ * @param last When `true`, focuses the last focusable element within the _focus trap_ instead of the first
129
130
  */
130
131
  focus(last: boolean): void {
131
132
  if (!this.#destroyed && !this.disabled) {
@@ -134,13 +135,13 @@ export class OuiFocusTrap {
134
135
  }
135
136
  }
136
137
 
137
- type OuiFocusTrapOptions = {
138
+ export type OuiFocusTrapOptions = {
138
139
  /**
139
- * Should focus be maintained within the _FocusTrap_ when clicking outside of it?
140
+ * Should focus be maintained within the _focus trap_ when clicking outside of it?
140
141
  */
141
142
  contain?: boolean;
142
143
  /**
143
- * Should the _FocusTrap_ allow focus to escape when pressing _Escape_?
144
+ * Should the _focus trap_ allow focus to escape when pressing _Escape_?
144
145
  */
145
146
  noescape?: boolean;
146
147
  };
@@ -156,11 +157,11 @@ type OuiFocusTrapState = {
156
157
  // #region Functions
157
158
 
158
159
  /**
159
- * Creates _(or retrieves)_ a _FocusTrap_ for an element
160
+ * Creates _(or retrieves)_ a _focus trap_ for an element
160
161
  *
161
162
  * @param element Element to trap focus within
162
- * @param options _FocusTrap_ options
163
- * @returns _FocusTrap_ instance
163
+ * @param options _Focus trap_ options
164
+ * @returns _Focus trap_ instance
164
165
  */
165
166
  export function createFocusTrap(element: HTMLElement, options?: OuiFocusTrapOptions): OuiFocusTrap {
166
167
  if (!isHTMLOrSVGElement(element)) {
@@ -399,6 +400,8 @@ let lastTarget: HTMLElement | undefined;
399
400
 
400
401
  // #region Initialization
401
402
 
403
+ attributable(ATTRIBUTE_FOCUSTRAP, createFocusTrap, removeFocusTrap);
404
+
402
405
  on(document, 'focusin', onFocusIn, EVENT_OPTIONS);
403
406
  on(document, 'keydown', onKeydown, EVENT_OPTIONS);
404
407
  on(document, 'mousedown', onPointerdown, EVENT_OPTIONS);
@@ -0,0 +1 @@
1
+ export {createFocusTrap, type OuiFocusTrap, type OuiFocusTrapOptions} from './focus-trap.embedded';
package/src/js/index.ts CHANGED
@@ -1,10 +1,10 @@
1
- import './movable';
2
- import './sortable';
1
+ import './sortable/sortable.embedded';
3
2
  import './toolbar';
4
3
 
5
4
  export * from './dialog';
6
- export * from './floatable/standalone';
7
- export * from './focus-trap/standalone';
5
+ export * from './floatable/floatable.standalone';
6
+ export * from './focus-trap/focus-trap.standalone';
7
+ export * from './movable/movable.standalone';
8
8
  export * from './popover';
9
9
  export * from './splitter';
10
10
  export * from './tooltip';