@ariakit/core 0.0.1 → 0.1.1

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 (163) hide show
  1. package/.eslintignore +6 -0
  2. package/CHANGELOG.md +24 -0
  3. package/checkbox/checkbox-store/package.json +7 -0
  4. package/cjs/__chunks/2YFRPUZP.cjs +30 -0
  5. package/cjs/__chunks/3BBA3Z5G.cjs +143 -0
  6. package/cjs/__chunks/3KP2MDG6.cjs +1491 -0
  7. package/cjs/__chunks/5D5Y5EI4.cjs +146 -0
  8. package/cjs/__chunks/7ZXWQTAY.cjs +71 -0
  9. package/cjs/__chunks/AZVDLKO3.cjs +286 -0
  10. package/cjs/__chunks/EFEGT32M.cjs +12 -0
  11. package/cjs/__chunks/EIDN2CWH.cjs +57 -0
  12. package/cjs/__chunks/GDZQUFNP.cjs +30 -0
  13. package/cjs/__chunks/NX5OHIMM.cjs +169 -0
  14. package/cjs/__chunks/OFNGELMA.cjs +182 -0
  15. package/cjs/checkbox/checkbox-store.cjs +27 -0
  16. package/cjs/checkbox/checkbox-store.d.ts +34 -0
  17. package/cjs/collection/collection-store.cjs +9 -0
  18. package/cjs/collection/collection-store.d.ts +65 -0
  19. package/cjs/combobox/combobox-store.cjs +163 -0
  20. package/cjs/combobox/combobox-store.d.ts +67 -0
  21. package/cjs/composite/composite-overflow-store.cjs +15 -0
  22. package/cjs/composite/composite-overflow-store.d.ts +10 -0
  23. package/cjs/composite/composite-store.cjs +11 -0
  24. package/cjs/composite/composite-store.d.ts +202 -0
  25. package/cjs/dialog/dialog-store.cjs +9 -0
  26. package/cjs/dialog/dialog-store.d.ts +10 -0
  27. package/cjs/disclosure/disclosure-store.cjs +8 -0
  28. package/cjs/disclosure/disclosure-store.d.ts +87 -0
  29. package/cjs/form/form-store.cjs +241 -0
  30. package/cjs/form/form-store.d.ts +236 -0
  31. package/cjs/form/types.cjs +1 -0
  32. package/cjs/form/types.d.ts +38 -0
  33. package/cjs/hovercard/hovercard-store.cjs +11 -0
  34. package/cjs/hovercard/hovercard-store.d.ts +45 -0
  35. package/cjs/index.cjs +5 -0
  36. package/cjs/index.d.ts +2 -0
  37. package/cjs/menu/menu-bar-store.cjs +27 -0
  38. package/cjs/menu/menu-bar-store.d.ts +10 -0
  39. package/cjs/menu/menu-store.cjs +108 -0
  40. package/cjs/menu/menu-store.d.ts +70 -0
  41. package/cjs/popover/popover-store.cjs +10 -0
  42. package/cjs/popover/popover-store.d.ts +150 -0
  43. package/cjs/radio/radio-store.cjs +41 -0
  44. package/cjs/radio/radio-store.d.ts +36 -0
  45. package/cjs/select/select-store.cjs +164 -0
  46. package/cjs/select/select-store.d.ts +87 -0
  47. package/cjs/tab/tab-store.cjs +126 -0
  48. package/cjs/tab/tab-store.d.ts +78 -0
  49. package/cjs/toolbar/toolbar-store.cjs +27 -0
  50. package/cjs/toolbar/toolbar-store.d.ts +21 -0
  51. package/cjs/tooltip/tooltip-store.cjs +98 -0
  52. package/cjs/tooltip/tooltip-store.d.ts +28 -0
  53. package/cjs/tsconfig.build.tsbuildinfo +1 -0
  54. package/cjs/utils/array.cjs +12 -0
  55. package/cjs/utils/array.d.ts +29 -0
  56. package/cjs/utils/dom.cjs +38 -0
  57. package/cjs/utils/dom.d.ts +105 -0
  58. package/cjs/utils/events.cjs +132 -0
  59. package/cjs/utils/events.d.ts +73 -0
  60. package/cjs/utils/focus.cjs +222 -0
  61. package/cjs/utils/focus.d.ts +117 -0
  62. package/cjs/utils/misc.cjs +40 -0
  63. package/cjs/utils/misc.d.ts +111 -0
  64. package/cjs/utils/platform.cjs +15 -0
  65. package/cjs/utils/platform.d.ts +20 -0
  66. package/cjs/utils/store.cjs +9 -0
  67. package/cjs/utils/store.d.ts +99 -0
  68. package/cjs/utils/types.cjs +1 -0
  69. package/cjs/utils/types.d.ts +72 -0
  70. package/collection/collection-store/package.json +7 -0
  71. package/combobox/combobox-store/package.json +7 -0
  72. package/composite/composite-overflow-store/package.json +7 -0
  73. package/composite/composite-store/package.json +7 -0
  74. package/dialog/dialog-store/package.json +7 -0
  75. package/disclosure/disclosure-store/package.json +7 -0
  76. package/esm/__chunks/5XEKIOCW.js +30 -0
  77. package/esm/__chunks/6U25WEDX.js +286 -0
  78. package/esm/__chunks/6UPCMUXT.js +1491 -0
  79. package/esm/__chunks/ADRUFBEO.js +12 -0
  80. package/esm/__chunks/DXA3K2FY.js +30 -0
  81. package/esm/__chunks/HCKYJLMC.js +71 -0
  82. package/esm/__chunks/KLKI3AIB.js +146 -0
  83. package/esm/__chunks/L7KN5AYP.js +169 -0
  84. package/esm/__chunks/RX3ZUQ6U.js +57 -0
  85. package/esm/__chunks/UOJSZ35L.js +143 -0
  86. package/esm/__chunks/UVCATTRC.js +182 -0
  87. package/esm/checkbox/checkbox-store.d.ts +34 -0
  88. package/esm/checkbox/checkbox-store.js +27 -0
  89. package/esm/collection/collection-store.d.ts +65 -0
  90. package/esm/collection/collection-store.js +9 -0
  91. package/esm/combobox/combobox-store.d.ts +67 -0
  92. package/esm/combobox/combobox-store.js +163 -0
  93. package/esm/composite/composite-overflow-store.d.ts +10 -0
  94. package/esm/composite/composite-overflow-store.js +15 -0
  95. package/esm/composite/composite-store.d.ts +202 -0
  96. package/esm/composite/composite-store.js +11 -0
  97. package/esm/dialog/dialog-store.d.ts +10 -0
  98. package/esm/dialog/dialog-store.js +9 -0
  99. package/esm/disclosure/disclosure-store.d.ts +87 -0
  100. package/esm/disclosure/disclosure-store.js +8 -0
  101. package/esm/form/form-store.d.ts +236 -0
  102. package/esm/form/form-store.js +241 -0
  103. package/esm/form/types.d.ts +38 -0
  104. package/esm/form/types.js +0 -0
  105. package/esm/hovercard/hovercard-store.d.ts +45 -0
  106. package/esm/hovercard/hovercard-store.js +11 -0
  107. package/esm/index.d.ts +2 -0
  108. package/esm/index.js +5 -0
  109. package/esm/menu/menu-bar-store.d.ts +10 -0
  110. package/esm/menu/menu-bar-store.js +27 -0
  111. package/esm/menu/menu-store.d.ts +70 -0
  112. package/esm/menu/menu-store.js +108 -0
  113. package/esm/popover/popover-store.d.ts +150 -0
  114. package/esm/popover/popover-store.js +10 -0
  115. package/esm/radio/radio-store.d.ts +36 -0
  116. package/esm/radio/radio-store.js +41 -0
  117. package/esm/select/select-store.d.ts +87 -0
  118. package/esm/select/select-store.js +164 -0
  119. package/esm/tab/tab-store.d.ts +78 -0
  120. package/esm/tab/tab-store.js +126 -0
  121. package/esm/toolbar/toolbar-store.d.ts +21 -0
  122. package/esm/toolbar/toolbar-store.js +27 -0
  123. package/esm/tooltip/tooltip-store.d.ts +28 -0
  124. package/esm/tooltip/tooltip-store.js +98 -0
  125. package/esm/tsconfig.build.tsbuildinfo +1 -0
  126. package/esm/utils/array.d.ts +29 -0
  127. package/esm/utils/array.js +12 -0
  128. package/esm/utils/dom.d.ts +105 -0
  129. package/esm/utils/dom.js +38 -0
  130. package/esm/utils/events.d.ts +73 -0
  131. package/esm/utils/events.js +132 -0
  132. package/esm/utils/focus.d.ts +117 -0
  133. package/esm/utils/focus.js +222 -0
  134. package/esm/utils/misc.d.ts +111 -0
  135. package/esm/utils/misc.js +40 -0
  136. package/esm/utils/platform.d.ts +20 -0
  137. package/esm/utils/platform.js +15 -0
  138. package/esm/utils/store.d.ts +99 -0
  139. package/esm/utils/store.js +9 -0
  140. package/esm/utils/types.d.ts +72 -0
  141. package/esm/utils/types.js +0 -0
  142. package/form/form-store/package.json +7 -0
  143. package/form/types/package.json +7 -0
  144. package/hovercard/hovercard-store/package.json +7 -0
  145. package/license +21 -0
  146. package/menu/menu-bar-store/package.json +7 -0
  147. package/menu/menu-store/package.json +7 -0
  148. package/package.json +137 -6
  149. package/popover/popover-store/package.json +7 -0
  150. package/radio/radio-store/package.json +7 -0
  151. package/select/select-store/package.json +7 -0
  152. package/tab/tab-store/package.json +7 -0
  153. package/toolbar/toolbar-store/package.json +7 -0
  154. package/tooltip/tooltip-store/package.json +7 -0
  155. package/tsconfig.build.json +4 -0
  156. package/utils/array/package.json +7 -0
  157. package/utils/dom/package.json +7 -0
  158. package/utils/events/package.json +7 -0
  159. package/utils/focus/package.json +7 -0
  160. package/utils/misc/package.json +7 -0
  161. package/utils/platform/package.json +7 -0
  162. package/utils/store/package.json +7 -0
  163. package/utils/types/package.json +7 -0
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Returns `true` if `event` has been fired within a React Portal element.
3
+ */
4
+ export declare function isPortalEvent(event: Pick<Event, "currentTarget" | "target">): boolean;
5
+ /**
6
+ * Returns `true` if `event.target` and `event.currentTarget` are the same.
7
+ */
8
+ export declare function isSelfTarget(event: Pick<Event, "target" | "currentTarget">): boolean;
9
+ /**
10
+ * Checks whether the user event is triggering a page navigation in a new tab.
11
+ */
12
+ export declare function isOpeningInNewTab(event: Pick<MouseEvent, "currentTarget" | "metaKey" | "ctrlKey">): boolean;
13
+ /**
14
+ * Checks whether the user event is triggering a download.
15
+ */
16
+ export declare function isDownloading(event: Pick<MouseEvent, "altKey" | "currentTarget">): boolean;
17
+ /**
18
+ * Creates and dispatches an event.
19
+ * @example
20
+ * fireEvent(document.getElementById("id"), "blur", {
21
+ * bubbles: true,
22
+ * cancelable: true,
23
+ * });
24
+ */
25
+ export declare function fireEvent(element: Element, type: string, eventInit?: EventInit): boolean;
26
+ /**
27
+ * Creates and dispatches a blur event.
28
+ * @example
29
+ * fireBlurEvent(document.getElementById("id"));
30
+ */
31
+ export declare function fireBlurEvent(element: Element, eventInit?: FocusEventInit): boolean;
32
+ /**
33
+ * Creates and dispatches a focus event.
34
+ * @example
35
+ * fireFocusEvent(document.getElementById("id"));
36
+ */
37
+ export declare function fireFocusEvent(element: Element, eventInit?: FocusEventInit): boolean;
38
+ /**
39
+ * Creates and dispatches a keyboard event.
40
+ * @example
41
+ * fireKeyboardEvent(document.getElementById("id"), "keydown", {
42
+ * key: "ArrowDown",
43
+ * shiftKey: true,
44
+ * });
45
+ */
46
+ export declare function fireKeyboardEvent(element: Element, type: string, eventInit?: KeyboardEventInit): boolean;
47
+ /**
48
+ * Creates and dispatches a click event.
49
+ * @example
50
+ * fireClickEvent(document.getElementById("id"));
51
+ */
52
+ export declare function fireClickEvent(element: Element, eventInit?: PointerEventInit): boolean;
53
+ /**
54
+ * Checks whether the focus/blur event is happening from/to outside of the
55
+ * container element.
56
+ * @example
57
+ * const element = document.getElementById("id");
58
+ * element.addEventListener("blur", (event) => {
59
+ * if (isFocusEventOutside(event)) {
60
+ * // ...
61
+ * }
62
+ * });
63
+ */
64
+ export declare function isFocusEventOutside(event: Pick<FocusEvent, "currentTarget" | "relatedTarget">, container?: Element | null): boolean;
65
+ /**
66
+ * Runs a callback on the next animation frame, but before a certain event.
67
+ */
68
+ export declare function queueBeforeEvent(element: Element, type: string, callback: () => void): number;
69
+ /**
70
+ * Adds a global event listener, including on child frames.
71
+ */
72
+ export declare function addGlobalEventListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
73
+ export declare function addGlobalEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
@@ -0,0 +1,222 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+
5
+
6
+
7
+
8
+ var _OFNGELMAcjs = require('../__chunks/OFNGELMA.cjs');
9
+
10
+ // src/utils/focus.ts
11
+ var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
12
+ function hasNegativeTabIndex(element) {
13
+ const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
14
+ return tabIndex < 0;
15
+ }
16
+ function isFocusable(element) {
17
+ return _OFNGELMAcjs.matches.call(void 0, element, selector) && _OFNGELMAcjs.isVisible.call(void 0, element);
18
+ }
19
+ function isTabbable(element) {
20
+ return isFocusable(element) && !hasNegativeTabIndex(element);
21
+ }
22
+ function getAllFocusableIn(container, includeContainer) {
23
+ const elements = Array.from(
24
+ container.querySelectorAll(selector)
25
+ );
26
+ if (includeContainer) {
27
+ elements.unshift(container);
28
+ }
29
+ const focusableElements = elements.filter(isFocusable);
30
+ focusableElements.forEach((element, i) => {
31
+ if (_OFNGELMAcjs.isFrame.call(void 0, element) && element.contentDocument) {
32
+ const frameBody = element.contentDocument.body;
33
+ focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody));
34
+ }
35
+ });
36
+ return focusableElements;
37
+ }
38
+ function getAllFocusable(includeBody) {
39
+ return getAllFocusableIn(document.body, includeBody);
40
+ }
41
+ function getFirstFocusableIn(container, includeContainer) {
42
+ const [first] = getAllFocusableIn(container, includeContainer);
43
+ return first || null;
44
+ }
45
+ function getFirstFocusable(includeBody) {
46
+ return getFirstFocusableIn(document.body, includeBody);
47
+ }
48
+ function getAllTabbableIn(container, includeContainer, fallbackToFocusable) {
49
+ const elements = Array.from(
50
+ container.querySelectorAll(selector)
51
+ );
52
+ const tabbableElements = elements.filter(isTabbable);
53
+ if (includeContainer && isTabbable(container)) {
54
+ tabbableElements.unshift(container);
55
+ }
56
+ tabbableElements.forEach((element, i) => {
57
+ if (_OFNGELMAcjs.isFrame.call(void 0, element) && element.contentDocument) {
58
+ const frameBody = element.contentDocument.body;
59
+ const allFrameTabbable = getAllTabbableIn(
60
+ frameBody,
61
+ false,
62
+ fallbackToFocusable
63
+ );
64
+ tabbableElements.splice(i, 1, ...allFrameTabbable);
65
+ }
66
+ });
67
+ if (!tabbableElements.length && fallbackToFocusable) {
68
+ return elements;
69
+ }
70
+ return tabbableElements;
71
+ }
72
+ function getAllTabbable(fallbackToFocusable) {
73
+ return getAllTabbableIn(document.body, false, fallbackToFocusable);
74
+ }
75
+ function getFirstTabbableIn(container, includeContainer, fallbackToFocusable) {
76
+ const [first] = getAllTabbableIn(
77
+ container,
78
+ includeContainer,
79
+ fallbackToFocusable
80
+ );
81
+ return first || null;
82
+ }
83
+ function getFirstTabbable(fallbackToFocusable) {
84
+ return getFirstTabbableIn(document.body, false, fallbackToFocusable);
85
+ }
86
+ function getLastTabbableIn(container, includeContainer, fallbackToFocusable) {
87
+ const allTabbable = getAllTabbableIn(
88
+ container,
89
+ includeContainer,
90
+ fallbackToFocusable
91
+ );
92
+ return allTabbable[allTabbable.length - 1] || null;
93
+ }
94
+ function getLastTabbable(fallbackToFocusable) {
95
+ return getLastTabbableIn(document.body, false, fallbackToFocusable);
96
+ }
97
+ function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) {
98
+ const activeElement = _OFNGELMAcjs.getActiveElement.call(void 0, container);
99
+ const allFocusable = getAllFocusableIn(container, includeContainer);
100
+ const activeIndex = allFocusable.indexOf(activeElement);
101
+ const nextFocusableElements = allFocusable.slice(activeIndex + 1);
102
+ return nextFocusableElements.find(isTabbable) || (fallbackToFirst ? allFocusable.find(isTabbable) : null) || (fallbackToFocusable ? nextFocusableElements[0] : null) || null;
103
+ }
104
+ function getNextTabbable(fallbackToFirst, fallbackToFocusable) {
105
+ return getNextTabbableIn(
106
+ document.body,
107
+ false,
108
+ fallbackToFirst,
109
+ fallbackToFocusable
110
+ );
111
+ }
112
+ function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) {
113
+ const activeElement = _OFNGELMAcjs.getActiveElement.call(void 0, container);
114
+ const allFocusable = getAllFocusableIn(container, includeContainer).reverse();
115
+ const activeIndex = allFocusable.indexOf(activeElement);
116
+ const previousFocusableElements = allFocusable.slice(activeIndex + 1);
117
+ return previousFocusableElements.find(isTabbable) || (fallbackToLast ? allFocusable.find(isTabbable) : null) || (fallbackToFocusable ? previousFocusableElements[0] : null) || null;
118
+ }
119
+ function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) {
120
+ return getPreviousTabbableIn(
121
+ document.body,
122
+ false,
123
+ fallbackToFirst,
124
+ fallbackToFocusable
125
+ );
126
+ }
127
+ function getClosestFocusable(element) {
128
+ while (element && !isFocusable(element)) {
129
+ element = _OFNGELMAcjs.closest.call(void 0, element, selector);
130
+ }
131
+ return element || null;
132
+ }
133
+ function hasFocus(element) {
134
+ const activeElement = _OFNGELMAcjs.getActiveElement.call(void 0, element);
135
+ if (!activeElement)
136
+ return false;
137
+ if (activeElement === element)
138
+ return true;
139
+ const activeDescendant = activeElement.getAttribute("aria-activedescendant");
140
+ if (!activeDescendant)
141
+ return false;
142
+ return activeDescendant === element.id;
143
+ }
144
+ function hasFocusWithin(element) {
145
+ const activeElement = _OFNGELMAcjs.getActiveElement.call(void 0, element);
146
+ if (!activeElement)
147
+ return false;
148
+ if (_OFNGELMAcjs.contains.call(void 0, element, activeElement))
149
+ return true;
150
+ const activeDescendant = activeElement.getAttribute("aria-activedescendant");
151
+ if (!activeDescendant)
152
+ return false;
153
+ if (!("id" in element))
154
+ return false;
155
+ if (activeDescendant === element.id)
156
+ return true;
157
+ return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
158
+ }
159
+ function focusIfNeeded(element) {
160
+ if (!hasFocusWithin(element) && isFocusable(element)) {
161
+ element.focus();
162
+ }
163
+ }
164
+ function disableFocus(element) {
165
+ const currentTabindex = _nullishCoalesce(element.getAttribute("tabindex"), () => ( ""));
166
+ element.setAttribute("data-tabindex", currentTabindex);
167
+ element.setAttribute("tabindex", "-1");
168
+ }
169
+ function disableFocusIn(container, includeContainer) {
170
+ const tabbableElements = getAllTabbableIn(container, includeContainer);
171
+ tabbableElements.forEach(disableFocus);
172
+ }
173
+ function restoreFocusIn(container) {
174
+ const elements = container.querySelectorAll("[data-tabindex]");
175
+ const restoreTabIndex = (element) => {
176
+ const tabindex = element.getAttribute("data-tabindex");
177
+ element.removeAttribute("data-tabindex");
178
+ if (tabindex) {
179
+ element.setAttribute("tabindex", tabindex);
180
+ } else {
181
+ element.removeAttribute("tabindex");
182
+ }
183
+ };
184
+ if (container.hasAttribute("data-tabindex")) {
185
+ restoreTabIndex(container);
186
+ }
187
+ elements.forEach(restoreTabIndex);
188
+ }
189
+ function focusIntoView(element, options) {
190
+ if (!("scrollIntoView" in element)) {
191
+ element.focus();
192
+ } else {
193
+ element.focus({ preventScroll: true });
194
+ element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
195
+ }
196
+ }
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+ exports.disableFocus = disableFocus; exports.disableFocusIn = disableFocusIn; exports.focusIfNeeded = focusIfNeeded; exports.focusIntoView = focusIntoView; exports.getAllFocusable = getAllFocusable; exports.getAllFocusableIn = getAllFocusableIn; exports.getAllTabbable = getAllTabbable; exports.getAllTabbableIn = getAllTabbableIn; exports.getClosestFocusable = getClosestFocusable; exports.getFirstFocusable = getFirstFocusable; exports.getFirstFocusableIn = getFirstFocusableIn; exports.getFirstTabbable = getFirstTabbable; exports.getFirstTabbableIn = getFirstTabbableIn; exports.getLastTabbable = getLastTabbable; exports.getLastTabbableIn = getLastTabbableIn; exports.getNextTabbable = getNextTabbable; exports.getNextTabbableIn = getNextTabbableIn; exports.getPreviousTabbable = getPreviousTabbable; exports.getPreviousTabbableIn = getPreviousTabbableIn; exports.hasFocus = hasFocus; exports.hasFocusWithin = hasFocusWithin; exports.isFocusable = isFocusable; exports.isTabbable = isTabbable; exports.restoreFocusIn = restoreFocusIn;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Checks whether `element` is focusable or not.
3
+ * @example
4
+ * isFocusable(document.querySelector("input")); // true
5
+ * isFocusable(document.querySelector("input[tabindex='-1']")); // true
6
+ * isFocusable(document.querySelector("input[hidden]")); // false
7
+ * isFocusable(document.querySelector("input:disabled")); // false
8
+ */
9
+ export declare function isFocusable(element: Element): element is HTMLElement;
10
+ /**
11
+ * Checks whether `element` is tabbable or not.
12
+ * @example
13
+ * isTabbable(document.querySelector("input")); // true
14
+ * isTabbable(document.querySelector("input[tabindex='-1']")); // false
15
+ * isTabbable(document.querySelector("input[hidden]")); // false
16
+ * isTabbable(document.querySelector("input:disabled")); // false
17
+ */
18
+ export declare function isTabbable(element: Element): element is HTMLElement;
19
+ /**
20
+ * Returns all the focusable elements in `container`.
21
+ */
22
+ export declare function getAllFocusableIn(container: HTMLElement, includeContainer?: boolean): HTMLElement[];
23
+ /**
24
+ * Returns all the focusable elements in the document.
25
+ */
26
+ export declare function getAllFocusable(includeBody?: boolean): HTMLElement[];
27
+ /**
28
+ * Returns the first focusable element in `container`.
29
+ */
30
+ export declare function getFirstFocusableIn(container: HTMLElement, includeContainer?: boolean): HTMLElement | null;
31
+ /**
32
+ * Returns the first focusable element in the document.
33
+ */
34
+ export declare function getFirstFocusable(includeBody?: boolean): HTMLElement | null;
35
+ /**
36
+ * Returns all the tabbable elements in `container`, including the container
37
+ * itself.
38
+ */
39
+ export declare function getAllTabbableIn(container: HTMLElement, includeContainer?: boolean, fallbackToFocusable?: boolean): HTMLElement[];
40
+ /**
41
+ * Returns all the tabbable elements in the document.
42
+ */
43
+ export declare function getAllTabbable(fallbackToFocusable?: boolean): HTMLElement[];
44
+ /**
45
+ * Returns the first tabbable element in `container`, including the container
46
+ * itself if it's tabbable.
47
+ */
48
+ export declare function getFirstTabbableIn(container: HTMLElement, includeContainer?: boolean, fallbackToFocusable?: boolean): HTMLElement | null;
49
+ /**
50
+ * Returns the first tabbable element in the document.
51
+ */
52
+ export declare function getFirstTabbable(fallbackToFocusable?: boolean): HTMLElement | null;
53
+ /**
54
+ * Returns the last tabbable element in `container`, including the container
55
+ * itself if it's tabbable.
56
+ */
57
+ export declare function getLastTabbableIn(container: HTMLElement, includeContainer?: boolean, fallbackToFocusable?: boolean): HTMLElement | null;
58
+ /**
59
+ * Returns the last tabbable element in the document.
60
+ */
61
+ export declare function getLastTabbable(fallbackToFocusable?: boolean): HTMLElement | null;
62
+ /**
63
+ * Returns the next tabbable element in `container`.
64
+ */
65
+ export declare function getNextTabbableIn(container: HTMLElement, includeContainer?: boolean, fallbackToFirst?: boolean, fallbackToFocusable?: boolean): HTMLElement | null;
66
+ /**
67
+ * Returns the next tabbable element in the document.
68
+ */
69
+ export declare function getNextTabbable(fallbackToFirst?: boolean, fallbackToFocusable?: boolean): HTMLElement | null;
70
+ /**
71
+ * Returns the previous tabbable element in `container`.
72
+ *
73
+ */
74
+ export declare function getPreviousTabbableIn(container: HTMLElement, includeContainer?: boolean, fallbackToLast?: boolean, fallbackToFocusable?: boolean): HTMLElement | null;
75
+ /**
76
+ * Returns the previous tabbable element in the document.
77
+ */
78
+ export declare function getPreviousTabbable(fallbackToFirst?: boolean, fallbackToFocusable?: boolean): HTMLElement | null;
79
+ /**
80
+ * Returns the closest focusable element.
81
+ */
82
+ export declare function getClosestFocusable(element?: HTMLElement | null): HTMLElement | null;
83
+ /**
84
+ * Checks if `element` has focus. Elements that are referenced by
85
+ * `aria-activedescendant` are also considered.
86
+ * @example
87
+ * hasFocus(document.getElementById("id"));
88
+ */
89
+ export declare function hasFocus(element: Element): boolean;
90
+ /**
91
+ * Checks if `element` has focus within. Elements that are referenced by
92
+ * `aria-activedescendant` are also considered.
93
+ * @example
94
+ * hasFocusWithin(document.getElementById("id"));
95
+ */
96
+ export declare function hasFocusWithin(element: Node | Element): boolean;
97
+ /**
98
+ * Focus on an element only if it's not already focused.
99
+ */
100
+ export declare function focusIfNeeded(element: HTMLElement): void;
101
+ /**
102
+ * Disable focus on `element`.
103
+ */
104
+ export declare function disableFocus(element: HTMLElement): void;
105
+ /**
106
+ * Makes elements inside container not tabbable.
107
+ */
108
+ export declare function disableFocusIn(container: HTMLElement, includeContainer?: boolean): void;
109
+ /**
110
+ * Restores tabbable elements inside container that were affected by
111
+ * disableFocusIn.
112
+ */
113
+ export declare function restoreFocusIn(container: HTMLElement): void;
114
+ /**
115
+ * Focus on element and scroll into view.
116
+ */
117
+ export declare function focusIntoView(element: HTMLElement, options?: ScrollIntoViewOptions): void;
@@ -0,0 +1,40 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ var _5D5Y5EI4cjs = require('../__chunks/5D5Y5EI4.cjs');
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+ exports.afterPaint = _5D5Y5EI4cjs.afterPaint; exports.applyState = _5D5Y5EI4cjs.applyState; exports.beforePaint = _5D5Y5EI4cjs.beforePaint; exports.chain = _5D5Y5EI4cjs.chain; exports.cx = _5D5Y5EI4cjs.cx; exports.defaultValue = _5D5Y5EI4cjs.defaultValue; exports.getKeys = _5D5Y5EI4cjs.getKeys; exports.hasOwnProperty = _5D5Y5EI4cjs.hasOwnProperty; exports.identity = _5D5Y5EI4cjs.identity; exports.invariant = _5D5Y5EI4cjs.invariant; exports.isEmpty = _5D5Y5EI4cjs.isEmpty; exports.isInteger = _5D5Y5EI4cjs.isInteger; exports.isObject = _5D5Y5EI4cjs.isObject; exports.noop = _5D5Y5EI4cjs.noop; exports.normalizeString = _5D5Y5EI4cjs.normalizeString; exports.omit = _5D5Y5EI4cjs.omit; exports.pick = _5D5Y5EI4cjs.pick; exports.shallowEqual = _5D5Y5EI4cjs.shallowEqual;
@@ -0,0 +1,111 @@
1
+ import type { AnyFunction, AnyObject, SetStateAction } from "./types.js";
2
+ /**
3
+ * Empty function.
4
+ */
5
+ export declare function noop(..._: any[]): any;
6
+ /**
7
+ * Compares two objects.
8
+ * @example
9
+ * shallowEqual({ a: "a" }, {}); // false
10
+ * shallowEqual({ a: "a" }, { b: "b" }); // false
11
+ * shallowEqual({ a: "a" }, { a: "a" }); // true
12
+ * shallowEqual({ a: "a" }, { a: "a", b: "b" }); // false
13
+ */
14
+ export declare function shallowEqual(a?: AnyObject, b?: AnyObject): boolean;
15
+ /**
16
+ * Receives a `setState` argument and calls it with `currentValue` if it's a
17
+ * function. Otherwise return the argument as the new value.
18
+ * @example
19
+ * applyState((value) => value + 1, 1); // 2
20
+ * applyState(2, 1); // 2
21
+ */
22
+ export declare function applyState<T>(argument: SetStateAction<T>, currentValue: T | (() => T)): T;
23
+ /**
24
+ * Checks whether `arg` is an object or not.
25
+ * @returns {boolean}
26
+ */
27
+ export declare function isObject(arg: any): arg is Record<any, unknown>;
28
+ /**
29
+ * Checks whether `arg` is empty or not.
30
+ * @example
31
+ * isEmpty([]); // true
32
+ * isEmpty(["a"]); // false
33
+ * isEmpty({}); // true
34
+ * isEmpty({ a: "a" }); // false
35
+ * isEmpty(); // true
36
+ * isEmpty(null); // true
37
+ * isEmpty(undefined); // true
38
+ * isEmpty(""); // true
39
+ */
40
+ export declare function isEmpty(arg: any): boolean;
41
+ /**
42
+ * Checks whether `arg` is an integer or not.
43
+ * @example
44
+ * isInteger(1); // true
45
+ * isInteger(1.5); // false
46
+ * isInteger("1"); // true
47
+ * isInteger("1.5"); // false
48
+ */
49
+ export declare function isInteger(arg: any): boolean;
50
+ /**
51
+ * Checks whether `prop` is an own property of `obj` or not.
52
+ */
53
+ export declare function hasOwnProperty<T extends AnyObject>(object: T, prop: keyof any): prop is keyof T;
54
+ /**
55
+ * Receives functions as arguments and returns a new function that calls all.
56
+ */
57
+ export declare function chain<T>(...fns: T[]): (...args: T extends AnyFunction ? Parameters<T> : never) => void;
58
+ /**
59
+ * Returns a string with the truthy values of `args` separated by space.
60
+ */
61
+ export declare function cx(...args: Array<string | null | false | 0 | undefined>): string | undefined;
62
+ /**
63
+ * Removes diatrics from a string.
64
+ */
65
+ export declare function normalizeString(str: string): string;
66
+ /**
67
+ * Omits specific keys from an object.
68
+ * @example
69
+ * omit({ a: "a", b: "b" }, ["a"]); // { b: "b" }
70
+ */
71
+ export declare function omit<T extends AnyObject, K extends keyof T>(object: T, keys: ReadonlyArray<K> | K[]): Omit<T, K>;
72
+ /**
73
+ * Picks specific keys from an object.
74
+ * @example
75
+ * pick({ a: "a", b: "b" }, ["a"]); // { a: "a" }
76
+ */
77
+ export declare function pick<T extends AnyObject, K extends keyof T>(object: T, paths: ReadonlyArray<K> | K[]): Pick<T, K>;
78
+ /**
79
+ * Returns the same argument.
80
+ */
81
+ export declare function identity<T>(value: T): T;
82
+ /**
83
+ * Runs right before the next paint.
84
+ */
85
+ export declare function beforePaint(cb?: () => void): () => void;
86
+ /**
87
+ * Runs after the next paint.
88
+ */
89
+ export declare function afterPaint(cb?: () => void): () => void;
90
+ /**
91
+ * Asserts that a condition is true, otherwise throws an error.
92
+ * @example
93
+ * invariant(
94
+ * condition,
95
+ * process.env.NODE_ENV !== "production" && "Invariant failed"
96
+ * );
97
+ */
98
+ export declare function invariant(condition: any, message?: string | boolean): asserts condition;
99
+ /**
100
+ * Similar to `Object.keys` but returns a type-safe array of keys.
101
+ */
102
+ export declare function getKeys<T extends object>(obj: T): (keyof T)[];
103
+ /**
104
+ * Returns the first value that is not `undefined`.
105
+ */
106
+ export declare function defaultValue<T extends readonly any[]>(...values: T): DefaultValue<T>;
107
+ type DefinedArray<T extends readonly any[]> = {
108
+ [K in keyof T as undefined extends T[K] ? never : K]: undefined extends T[K] ? [Exclude<T[K], undefined>, never] : [T[K]];
109
+ };
110
+ type DefaultValue<T extends readonly any[]> = DefinedArray<T>[keyof DefinedArray<T>] extends [any, never] ? T[number] : DefinedArray<T>[keyof DefinedArray<T>][0];
111
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _2YFRPUZPcjs = require('../__chunks/2YFRPUZP.cjs');
8
+ require('../__chunks/OFNGELMA.cjs');
9
+
10
+
11
+
12
+
13
+
14
+
15
+ exports.isApple = _2YFRPUZPcjs.isApple; exports.isFirefox = _2YFRPUZPcjs.isFirefox; exports.isMac = _2YFRPUZPcjs.isMac; exports.isSafari = _2YFRPUZPcjs.isSafari; exports.isTouchDevice = _2YFRPUZPcjs.isTouchDevice;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Detects if the device has touch capabilities.
3
+ */
4
+ export declare function isTouchDevice(): boolean;
5
+ /**
6
+ * Detects Apple device.
7
+ */
8
+ export declare function isApple(): boolean;
9
+ /**
10
+ * Detects Safari browser.
11
+ */
12
+ export declare function isSafari(): boolean;
13
+ /**
14
+ * Detects Firefox browser.
15
+ */
16
+ export declare function isFirefox(): boolean;
17
+ /**
18
+ * Detects Mac computer.
19
+ */
20
+ export declare function isMac(): boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _3BBA3Z5Gcjs = require('../__chunks/3BBA3Z5G.cjs');
5
+ require('../__chunks/5D5Y5EI4.cjs');
6
+
7
+
8
+
9
+ exports.createStore = _3BBA3Z5Gcjs.createStore; exports.mergeStore = _3BBA3Z5Gcjs.mergeStore;