@tamagui/floating 2.7.7 → 3.0.0-beta.1093.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 (155) hide show
  1. package/dist/cjs/Floating.cjs +9 -11
  2. package/dist/cjs/Floating.native.cjs +36 -0
  3. package/dist/cjs/Floating.native.js +19 -20
  4. package/dist/cjs/Floating.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +44 -46
  6. package/dist/cjs/index.native.cjs +73 -0
  7. package/dist/cjs/index.native.js +44 -45
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/interactions/PopupTriggerMap.cjs +35 -39
  10. package/dist/cjs/interactions/PopupTriggerMap.native.cjs +95 -0
  11. package/dist/cjs/interactions/PopupTriggerMap.native.js +75 -75
  12. package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -1
  13. package/dist/cjs/interactions/createFloatingEvents.cjs +35 -39
  14. package/dist/cjs/interactions/createFloatingEvents.native.cjs +51 -0
  15. package/dist/cjs/interactions/createFloatingEvents.native.js +38 -41
  16. package/dist/cjs/interactions/createFloatingEvents.native.js.map +1 -1
  17. package/dist/cjs/interactions/safePolygon.cjs +262 -252
  18. package/dist/cjs/interactions/safePolygon.native.cjs +293 -0
  19. package/dist/cjs/interactions/safePolygon.native.js +270 -259
  20. package/dist/cjs/interactions/safePolygon.native.js.map +1 -1
  21. package/dist/cjs/interactions/types.cjs +9 -11
  22. package/dist/cjs/interactions/types.native.cjs +18 -0
  23. package/dist/cjs/interactions/types.native.js +9 -10
  24. package/dist/cjs/interactions/types.native.js.map +1 -1
  25. package/dist/cjs/interactions/useClick.cjs +95 -105
  26. package/dist/cjs/interactions/useClick.native.cjs +121 -0
  27. package/dist/cjs/interactions/useClick.native.js +100 -109
  28. package/dist/cjs/interactions/useClick.native.js.map +1 -1
  29. package/dist/cjs/interactions/useDelayGroup.cjs +85 -91
  30. package/dist/cjs/interactions/useDelayGroup.native.cjs +118 -0
  31. package/dist/cjs/interactions/useDelayGroup.native.js +91 -96
  32. package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -1
  33. package/dist/cjs/interactions/useFocus.cjs +107 -115
  34. package/dist/cjs/interactions/useFocus.native.cjs +130 -0
  35. package/dist/cjs/interactions/useFocus.native.js +113 -120
  36. package/dist/cjs/interactions/useFocus.native.js.map +1 -1
  37. package/dist/cjs/interactions/useHover.cjs +320 -335
  38. package/dist/cjs/interactions/useHover.native.cjs +356 -0
  39. package/dist/cjs/interactions/useHover.native.js +332 -347
  40. package/dist/cjs/interactions/useHover.native.js.map +1 -1
  41. package/dist/cjs/interactions/useInnerOffset.cjs +102 -111
  42. package/dist/cjs/interactions/useInnerOffset.native.cjs +131 -0
  43. package/dist/cjs/interactions/useInnerOffset.native.js +112 -120
  44. package/dist/cjs/interactions/useInnerOffset.native.js.map +1 -1
  45. package/dist/cjs/interactions/useInteractions.cjs +76 -92
  46. package/dist/cjs/interactions/useInteractions.native.cjs +199 -0
  47. package/dist/cjs/interactions/useInteractions.native.js +185 -200
  48. package/dist/cjs/interactions/useInteractions.native.js.map +1 -1
  49. package/dist/cjs/interactions/useListNavigation.cjs +404 -390
  50. package/dist/cjs/interactions/useListNavigation.native.cjs +446 -0
  51. package/dist/cjs/interactions/useListNavigation.native.js +416 -401
  52. package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
  53. package/dist/cjs/interactions/useRole.cjs +91 -106
  54. package/dist/cjs/interactions/useRole.native.cjs +120 -0
  55. package/dist/cjs/interactions/useRole.native.js +102 -116
  56. package/dist/cjs/interactions/useRole.native.js.map +1 -1
  57. package/dist/cjs/interactions/useTypeahead.cjs +114 -129
  58. package/dist/cjs/interactions/useTypeahead.native.cjs +143 -0
  59. package/dist/cjs/interactions/useTypeahead.native.js +127 -141
  60. package/dist/cjs/interactions/useTypeahead.native.js.map +1 -1
  61. package/dist/cjs/interactions/utils.cjs +125 -143
  62. package/dist/cjs/interactions/utils.native.cjs +201 -0
  63. package/dist/cjs/interactions/utils.native.js +132 -156
  64. package/dist/cjs/interactions/utils.native.js.map +1 -1
  65. package/dist/cjs/middleware/inner.cjs +73 -101
  66. package/dist/cjs/middleware/inner.native.cjs +101 -0
  67. package/dist/cjs/middleware/inner.native.js +82 -109
  68. package/dist/cjs/middleware/inner.native.js.map +1 -1
  69. package/dist/cjs/useFloating.cjs +33 -46
  70. package/dist/cjs/useFloating.native.cjs +55 -0
  71. package/dist/cjs/useFloating.native.js +36 -48
  72. package/dist/cjs/useFloating.native.js.map +1 -1
  73. package/dist/esm/Floating.mjs +1 -2
  74. package/dist/esm/Floating.native.js +6 -4
  75. package/dist/esm/Floating.native.js.map +1 -1
  76. package/dist/esm/index.js +4 -5
  77. package/dist/esm/index.mjs +4 -5
  78. package/dist/esm/index.native.js +4 -5
  79. package/dist/esm/interactions/PopupTriggerMap.mjs +23 -22
  80. package/dist/esm/interactions/PopupTriggerMap.mjs.map +1 -1
  81. package/dist/esm/interactions/PopupTriggerMap.native.js +62 -58
  82. package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -1
  83. package/dist/esm/interactions/createFloatingEvents.mjs +22 -21
  84. package/dist/esm/interactions/createFloatingEvents.mjs.map +1 -1
  85. package/dist/esm/interactions/createFloatingEvents.native.js +25 -24
  86. package/dist/esm/interactions/createFloatingEvents.native.js.map +1 -1
  87. package/dist/esm/interactions/safePolygon.mjs +250 -234
  88. package/dist/esm/interactions/safePolygon.mjs.map +1 -1
  89. package/dist/esm/interactions/safePolygon.native.js +258 -242
  90. package/dist/esm/interactions/safePolygon.native.js.map +1 -1
  91. package/dist/esm/interactions/types.mjs +0 -2
  92. package/dist/esm/interactions/types.native.js +0 -2
  93. package/dist/esm/interactions/useClick.mjs +83 -87
  94. package/dist/esm/interactions/useClick.mjs.map +1 -1
  95. package/dist/esm/interactions/useClick.native.js +88 -92
  96. package/dist/esm/interactions/useClick.native.js.map +1 -1
  97. package/dist/esm/interactions/useDelayGroup.mjs +68 -65
  98. package/dist/esm/interactions/useDelayGroup.mjs.map +1 -1
  99. package/dist/esm/interactions/useDelayGroup.native.js +74 -71
  100. package/dist/esm/interactions/useDelayGroup.native.js.map +1 -1
  101. package/dist/esm/interactions/useFocus.mjs +95 -97
  102. package/dist/esm/interactions/useFocus.mjs.map +1 -1
  103. package/dist/esm/interactions/useFocus.native.js +101 -103
  104. package/dist/esm/interactions/useFocus.native.js.map +1 -1
  105. package/dist/esm/interactions/useHover.mjs +304 -310
  106. package/dist/esm/interactions/useHover.mjs.map +1 -1
  107. package/dist/esm/interactions/useHover.native.js +316 -323
  108. package/dist/esm/interactions/useHover.native.js.map +1 -1
  109. package/dist/esm/interactions/useInnerOffset.mjs +87 -85
  110. package/dist/esm/interactions/useInnerOffset.mjs.map +1 -1
  111. package/dist/esm/interactions/useInnerOffset.native.js +97 -95
  112. package/dist/esm/interactions/useInnerOffset.native.js.map +1 -1
  113. package/dist/esm/interactions/useInteractions.mjs +65 -75
  114. package/dist/esm/interactions/useInteractions.mjs.map +1 -1
  115. package/dist/esm/interactions/useInteractions.native.js +172 -182
  116. package/dist/esm/interactions/useInteractions.native.js.map +1 -1
  117. package/dist/esm/interactions/useListNavigation.mjs +393 -373
  118. package/dist/esm/interactions/useListNavigation.mjs.map +1 -1
  119. package/dist/esm/interactions/useListNavigation.native.js +405 -385
  120. package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
  121. package/dist/esm/interactions/useRole.mjs +76 -80
  122. package/dist/esm/interactions/useRole.mjs.map +1 -1
  123. package/dist/esm/interactions/useRole.native.js +87 -91
  124. package/dist/esm/interactions/useRole.native.js.map +1 -1
  125. package/dist/esm/interactions/useTypeahead.mjs +102 -111
  126. package/dist/esm/interactions/useTypeahead.mjs.map +1 -1
  127. package/dist/esm/interactions/useTypeahead.native.js +115 -124
  128. package/dist/esm/interactions/useTypeahead.native.js.map +1 -1
  129. package/dist/esm/interactions/utils.mjs +91 -106
  130. package/dist/esm/interactions/utils.mjs.map +1 -1
  131. package/dist/esm/interactions/utils.native.js +98 -120
  132. package/dist/esm/interactions/utils.native.js.map +1 -1
  133. package/dist/esm/middleware/inner.mjs +58 -75
  134. package/dist/esm/middleware/inner.mjs.map +1 -1
  135. package/dist/esm/middleware/inner.native.js +67 -84
  136. package/dist/esm/middleware/inner.native.js.map +1 -1
  137. package/dist/esm/useFloating.mjs +17 -21
  138. package/dist/esm/useFloating.mjs.map +1 -1
  139. package/dist/esm/useFloating.native.js +19 -23
  140. package/dist/esm/useFloating.native.js.map +1 -1
  141. package/package.json +8 -6
  142. package/src/interactions/useInteractions.ts +61 -59
  143. package/src/interactions/useListNavigation.ts +7 -2
  144. package/types/interactions/PopupTriggerMap.d.ts.map +1 -1
  145. package/types/interactions/useInteractions.d.ts +3 -3
  146. package/types/interactions/useInteractions.d.ts.map +1 -1
  147. package/types/interactions/useListNavigation.d.ts.map +1 -1
  148. package/types/middleware/inner.d.ts.map +1 -1
  149. package/types/useFloating.d.ts.map +1 -1
  150. package/dist/esm/Floating.mjs.map +0 -1
  151. package/dist/esm/index.js.map +0 -1
  152. package/dist/esm/index.mjs.map +0 -1
  153. package/dist/esm/index.native.js.map +0 -1
  154. package/dist/esm/interactions/types.mjs.map +0 -1
  155. package/dist/esm/interactions/types.native.js.map +0 -1
@@ -3,206 +3,188 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
10
  };
11
11
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
19
  };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
21
  var utils_exports = {};
24
22
  __export(utils_exports, {
25
- activeElement: () => activeElement,
26
- clearTimeoutIfSet: () => clearTimeoutIfSet,
27
- contains: () => contains,
28
- enqueueFocus: () => enqueueFocus,
29
- findNonDisabledListIndex: () => findNonDisabledListIndex,
30
- getDocument: () => getDocument,
31
- getMaxListIndex: () => getMaxListIndex,
32
- getMinListIndex: () => getMinListIndex,
33
- getTarget: () => getTarget,
34
- isElement: () => isElement,
35
- isHTMLElement: () => isHTMLElement,
36
- isIndexOutOfListBounds: () => isIndexOutOfListBounds,
37
- isListIndexDisabled: () => isListIndexDisabled,
38
- isMac: () => isMac,
39
- isMouseLikePointerType: () => isMouseLikePointerType,
40
- isSafari: () => isSafari,
41
- isTypeableCombobox: () => isTypeableCombobox,
42
- isTypeableElement: () => isTypeableElement,
43
- isVirtualClick: () => isVirtualClick,
44
- isVirtualPointerEvent: () => isVirtualPointerEvent,
45
- matchesFocusVisible: () => matchesFocusVisible,
46
- stopEvent: () => stopEvent
23
+ activeElement: () => activeElement,
24
+ clearTimeoutIfSet: () => clearTimeoutIfSet,
25
+ contains: () => contains,
26
+ enqueueFocus: () => enqueueFocus,
27
+ findNonDisabledListIndex: () => findNonDisabledListIndex,
28
+ getDocument: () => getDocument,
29
+ getMaxListIndex: () => getMaxListIndex,
30
+ getMinListIndex: () => getMinListIndex,
31
+ getTarget: () => getTarget,
32
+ isElement: () => isElement,
33
+ isHTMLElement: () => isHTMLElement,
34
+ isIndexOutOfListBounds: () => isIndexOutOfListBounds,
35
+ isListIndexDisabled: () => isListIndexDisabled,
36
+ isMac: () => isMac,
37
+ isMouseLikePointerType: () => isMouseLikePointerType,
38
+ isSafari: () => isSafari,
39
+ isTypeableCombobox: () => isTypeableCombobox,
40
+ isTypeableElement: () => isTypeableElement,
41
+ isVirtualClick: () => isVirtualClick,
42
+ isVirtualPointerEvent: () => isVirtualPointerEvent,
43
+ matchesFocusVisible: () => matchesFocusVisible,
44
+ stopEvent: () => stopEvent
47
45
  });
48
46
  module.exports = __toCommonJS(utils_exports);
49
47
  function getDocument(node) {
50
- return node?.ownerDocument || document;
48
+ return node?.ownerDocument || document;
51
49
  }
52
50
  function contains(parent, child) {
53
- if (!parent || !child) return false;
54
- const rootNode = child.getRootNode?.();
55
- if (parent.contains(child)) return true;
56
- if (rootNode && isShadowRoot(rootNode)) {
57
- let next = child;
58
- while (next) {
59
- if (parent === next) return true;
60
- next = next.parentNode || next.host;
61
- }
62
- }
63
- return false;
51
+ if (!parent || !child) return false;
52
+ const rootNode = child.getRootNode?.();
53
+ if (parent.contains(child)) return true;
54
+ if (rootNode && isShadowRoot(rootNode)) {
55
+ let next = child;
56
+ while (next) {
57
+ if (parent === next) return true;
58
+ next = next.parentNode || next.host;
59
+ }
60
+ }
61
+ return false;
64
62
  }
65
63
  function isShadowRoot(node) {
66
- return node instanceof ShadowRoot;
64
+ return node instanceof ShadowRoot;
67
65
  }
68
66
  function getTarget(event) {
69
- if ("composedPath" in event) {
70
- return event.composedPath()[0];
71
- }
72
- return event.target;
67
+ if ("composedPath" in event) {
68
+ return event.composedPath()[0];
69
+ }
70
+ return event.target;
73
71
  }
74
72
  function activeElement(doc) {
75
- let el = doc.activeElement;
76
- while (el?.shadowRoot?.activeElement != null) {
77
- el = el.shadowRoot.activeElement;
78
- }
79
- return el;
73
+ let el = doc.activeElement;
74
+ while (el?.shadowRoot?.activeElement != null) {
75
+ el = el.shadowRoot.activeElement;
76
+ }
77
+ return el;
80
78
  }
81
79
  function isHTMLElement(value) {
82
- return value instanceof HTMLElement;
80
+ return value instanceof HTMLElement;
83
81
  }
84
82
  function isElement(value) {
85
- return value instanceof Element;
83
+ return value instanceof Element;
86
84
  }
87
85
  const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
88
86
  function isTypeableElement(element) {
89
- return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
87
+ return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
90
88
  }
91
89
  function isTypeableCombobox(element) {
92
- if (!element) return false;
93
- return element.getAttribute("role") === "combobox" && isTypeableElement(element);
90
+ if (!element) return false;
91
+ return element.getAttribute("role") === "combobox" && isTypeableElement(element);
94
92
  }
95
93
  function getPlatform() {
96
- const uaData = navigator.userAgentData;
97
- if (uaData?.platform) return uaData.platform;
98
- return navigator.platform;
94
+ const uaData = navigator.userAgentData;
95
+ if (uaData?.platform) return uaData.platform;
96
+ return navigator.platform;
99
97
  }
100
98
  function getUserAgent() {
101
- const uaData = navigator.userAgentData;
102
- if (uaData && Array.isArray(uaData.brands)) {
103
- return uaData.brands.map(({
104
- brand,
105
- version
106
- }) => `${brand}/${version}`).join(" ");
107
- }
108
- return navigator.userAgent;
99
+ const uaData = navigator.userAgentData;
100
+ if (uaData && Array.isArray(uaData.brands)) {
101
+ return uaData.brands.map(({ brand, version }) => `${brand}/${version}`).join(" ");
102
+ }
103
+ return navigator.userAgent;
109
104
  }
110
105
  function isSafari() {
111
- return /apple/i.test(navigator.vendor);
106
+ return /apple/i.test(navigator.vendor);
112
107
  }
113
108
  function isMac() {
114
- return getPlatform().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
109
+ return getPlatform().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
115
110
  }
116
111
  function isJSDOM() {
117
- return getUserAgent().includes("jsdom/");
112
+ return getUserAgent().includes("jsdom/");
118
113
  }
119
114
  function matchesFocusVisible(element) {
120
- if (!element || isJSDOM()) return true;
121
- try {
122
- return element.matches(":focus-visible");
123
- } catch {
124
- return true;
125
- }
115
+ if (!element || isJSDOM()) return true;
116
+ try {
117
+ return element.matches(":focus-visible");
118
+ } catch {
119
+ return true;
120
+ }
126
121
  }
127
122
  function isMouseLikePointerType(pointerType, strict) {
128
- const values = ["mouse", "pen"];
129
- if (!strict) {
130
- values.push("", void 0);
131
- }
132
- return values.includes(pointerType);
123
+ const values = ["mouse", "pen"];
124
+ if (!strict) {
125
+ values.push("", void 0);
126
+ }
127
+ return values.includes(pointerType);
133
128
  }
134
129
  function clearTimeoutIfSet(timeoutRef) {
135
- if (timeoutRef.current !== -1) {
136
- clearTimeout(timeoutRef.current);
137
- timeoutRef.current = -1;
138
- }
130
+ if (timeoutRef.current !== -1) {
131
+ clearTimeout(timeoutRef.current);
132
+ timeoutRef.current = -1;
133
+ }
139
134
  }
140
135
  function stopEvent(event) {
141
- event.preventDefault();
142
- event.stopPropagation();
136
+ event.preventDefault();
137
+ event.stopPropagation();
143
138
  }
144
139
  function isVirtualClick(event) {
145
- if (event.mozInputSource === 0 && event.isTrusted) return true;
146
- if (isAndroid() && event.pointerType) {
147
- return event.type === "click" && event.buttons === 1;
148
- }
149
- return event.detail === 0 && !event.pointerType;
140
+ if (event.mozInputSource === 0 && event.isTrusted) return true;
141
+ if (isAndroid() && event.pointerType) {
142
+ return event.type === "click" && event.buttons === 1;
143
+ }
144
+ return event.detail === 0 && !event.pointerType;
150
145
  }
151
146
  function isVirtualPointerEvent(event) {
152
- if (isJSDOM()) return false;
153
- return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
147
+ if (isJSDOM()) return false;
148
+ return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
154
149
  }
155
150
  function isAndroid() {
156
- const re = /android/i;
157
- return re.test(getPlatform()) || re.test(getUserAgent());
151
+ const re = /android/i;
152
+ return re.test(getPlatform()) || re.test(getUserAgent());
158
153
  }
159
154
  let rafId = 0;
160
155
  function enqueueFocus(el, options = {}) {
161
- const {
162
- preventScroll = false,
163
- cancelPrevious = true,
164
- sync = false
165
- } = options;
166
- cancelPrevious && cancelAnimationFrame(rafId);
167
- const exec = () => el?.focus({
168
- preventScroll
169
- });
170
- if (sync) {
171
- exec();
172
- } else {
173
- rafId = requestAnimationFrame(exec);
174
- }
156
+ const { preventScroll = false, cancelPrevious = true, sync = false } = options;
157
+ cancelPrevious && cancelAnimationFrame(rafId);
158
+ const exec = () => el?.focus({ preventScroll });
159
+ if (sync) {
160
+ exec();
161
+ } else {
162
+ rafId = requestAnimationFrame(exec);
163
+ }
175
164
  }
176
165
  function isListIndexDisabled(listRef, index, disabledIndices) {
177
- if (typeof disabledIndices === "function") return disabledIndices(index);
178
- if (disabledIndices) return disabledIndices.includes(index);
179
- const element = listRef.current[index];
180
- return element == null || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true";
181
- }
182
- function findNonDisabledListIndex(listRef, {
183
- startingIndex = -1,
184
- decrement = false,
185
- disabledIndices,
186
- amount = 1
187
- } = {}) {
188
- let index = startingIndex;
189
- do {
190
- index += decrement ? -amount : amount;
191
- } while (index >= 0 && index <= listRef.current.length - 1 && isListIndexDisabled(listRef, index, disabledIndices));
192
- return index;
166
+ if (typeof disabledIndices === "function") return disabledIndices(index);
167
+ if (disabledIndices) return disabledIndices.includes(index);
168
+ const element = listRef.current[index];
169
+ return element == null || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true";
170
+ }
171
+ function findNonDisabledListIndex(listRef, { startingIndex = -1, decrement = false, disabledIndices, amount = 1 } = {}) {
172
+ let index = startingIndex;
173
+ do {
174
+ index += decrement ? -amount : amount;
175
+ } while (index >= 0 && index <= listRef.current.length - 1 && isListIndexDisabled(listRef, index, disabledIndices));
176
+ return index;
193
177
  }
194
178
  function getMinListIndex(listRef, disabledIndices) {
195
- return findNonDisabledListIndex(listRef, {
196
- disabledIndices
197
- });
179
+ return findNonDisabledListIndex(listRef, { disabledIndices });
198
180
  }
199
181
  function getMaxListIndex(listRef, disabledIndices) {
200
- return findNonDisabledListIndex(listRef, {
201
- decrement: true,
202
- startingIndex: listRef.current.length,
203
- disabledIndices
204
- });
182
+ return findNonDisabledListIndex(listRef, {
183
+ decrement: true,
184
+ startingIndex: listRef.current.length,
185
+ disabledIndices
186
+ });
205
187
  }
206
188
  function isIndexOutOfListBounds(listRef, index) {
207
- return index < 0 || index >= listRef.current.length;
208
- }
189
+ return index < 0 || index >= listRef.current.length;
190
+ }
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var utils_exports = {};
24
+ __export(utils_exports, {
25
+ activeElement: () => activeElement,
26
+ clearTimeoutIfSet: () => clearTimeoutIfSet,
27
+ contains: () => contains,
28
+ enqueueFocus: () => enqueueFocus,
29
+ findNonDisabledListIndex: () => findNonDisabledListIndex,
30
+ getDocument: () => getDocument,
31
+ getMaxListIndex: () => getMaxListIndex,
32
+ getMinListIndex: () => getMinListIndex,
33
+ getTarget: () => getTarget,
34
+ isElement: () => isElement,
35
+ isHTMLElement: () => isHTMLElement,
36
+ isIndexOutOfListBounds: () => isIndexOutOfListBounds,
37
+ isListIndexDisabled: () => isListIndexDisabled,
38
+ isMac: () => isMac,
39
+ isMouseLikePointerType: () => isMouseLikePointerType,
40
+ isSafari: () => isSafari,
41
+ isTypeableCombobox: () => isTypeableCombobox,
42
+ isTypeableElement: () => isTypeableElement,
43
+ isVirtualClick: () => isVirtualClick,
44
+ isVirtualPointerEvent: () => isVirtualPointerEvent,
45
+ matchesFocusVisible: () => matchesFocusVisible,
46
+ stopEvent: () => stopEvent
47
+ });
48
+ module.exports = __toCommonJS(utils_exports);
49
+ function getDocument(node) {
50
+ return (node === null || node === void 0 ? void 0 : node.ownerDocument) || document;
51
+ }
52
+ function contains(parent, child) {
53
+ var _child_getRootNode;
54
+ if (!parent || !child) return false;
55
+ var rootNode = (_child_getRootNode = child.getRootNode) === null || _child_getRootNode === void 0 ? void 0 : _child_getRootNode.call(child);
56
+ if (parent.contains(child)) return true;
57
+ if (rootNode && isShadowRoot(rootNode)) {
58
+ var next = child;
59
+ while (next) {
60
+ if (parent === next) return true;
61
+ next = next.parentNode || next.host;
62
+ }
63
+ }
64
+ return false;
65
+ }
66
+ function isShadowRoot(node) {
67
+ return node instanceof ShadowRoot;
68
+ }
69
+ function getTarget(event) {
70
+ if ("composedPath" in event) {
71
+ return event.composedPath()[0];
72
+ }
73
+ return event.target;
74
+ }
75
+ function activeElement(doc) {
76
+ var _el_shadowRoot;
77
+ var el = doc.activeElement;
78
+ while ((el === null || el === void 0 ? void 0 : (_el_shadowRoot = el.shadowRoot) === null || _el_shadowRoot === void 0 ? void 0 : _el_shadowRoot.activeElement) != null) {
79
+ el = el.shadowRoot.activeElement;
80
+ }
81
+ return el;
82
+ }
83
+ function isHTMLElement(value) {
84
+ return value instanceof HTMLElement;
85
+ }
86
+ function isElement(value) {
87
+ return value instanceof Element;
88
+ }
89
+ var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
90
+ function isTypeableElement(element) {
91
+ return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
92
+ }
93
+ function isTypeableCombobox(element) {
94
+ if (!element) return false;
95
+ return element.getAttribute("role") === "combobox" && isTypeableElement(element);
96
+ }
97
+ function getPlatform() {
98
+ var uaData = navigator.userAgentData;
99
+ if (uaData === null || uaData === void 0 ? void 0 : uaData.platform) return uaData.platform;
100
+ return navigator.platform;
101
+ }
102
+ function getUserAgent() {
103
+ var uaData = navigator.userAgentData;
104
+ if (uaData && Array.isArray(uaData.brands)) {
105
+ return uaData.brands.map(function(param) {
106
+ var { brand, version } = param;
107
+ return `${brand}/${version}`;
108
+ }).join(" ");
109
+ }
110
+ return navigator.userAgent;
111
+ }
112
+ function isSafari() {
113
+ return /apple/i.test(navigator.vendor);
114
+ }
115
+ function isMac() {
116
+ return getPlatform().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
117
+ }
118
+ function isJSDOM() {
119
+ return getUserAgent().includes("jsdom/");
120
+ }
121
+ function matchesFocusVisible(element) {
122
+ if (!element || isJSDOM()) return true;
123
+ try {
124
+ return element.matches(":focus-visible");
125
+ } catch (e) {
126
+ return true;
127
+ }
128
+ }
129
+ function isMouseLikePointerType(pointerType, strict) {
130
+ var values = ["mouse", "pen"];
131
+ if (!strict) {
132
+ values.push("", void 0);
133
+ }
134
+ return values.includes(pointerType);
135
+ }
136
+ function clearTimeoutIfSet(timeoutRef) {
137
+ if (timeoutRef.current !== -1) {
138
+ clearTimeout(timeoutRef.current);
139
+ timeoutRef.current = -1;
140
+ }
141
+ }
142
+ function stopEvent(event) {
143
+ event.preventDefault();
144
+ event.stopPropagation();
145
+ }
146
+ function isVirtualClick(event) {
147
+ if (event.mozInputSource === 0 && event.isTrusted) return true;
148
+ if (isAndroid() && event.pointerType) {
149
+ return event.type === "click" && event.buttons === 1;
150
+ }
151
+ return event.detail === 0 && !event.pointerType;
152
+ }
153
+ function isVirtualPointerEvent(event) {
154
+ if (isJSDOM()) return false;
155
+ return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
156
+ }
157
+ function isAndroid() {
158
+ var re = /android/i;
159
+ return re.test(getPlatform()) || re.test(getUserAgent());
160
+ }
161
+ var rafId = 0;
162
+ function enqueueFocus(el) {
163
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
164
+ var { preventScroll = false, cancelPrevious = true, sync = false } = options;
165
+ cancelPrevious && cancelAnimationFrame(rafId);
166
+ var exec = function() {
167
+ return el === null || el === void 0 ? void 0 : el.focus({ preventScroll });
168
+ };
169
+ if (sync) {
170
+ exec();
171
+ } else {
172
+ rafId = requestAnimationFrame(exec);
173
+ }
174
+ }
175
+ function isListIndexDisabled(listRef, index, disabledIndices) {
176
+ if (typeof disabledIndices === "function") return disabledIndices(index);
177
+ if (disabledIndices) return disabledIndices.includes(index);
178
+ var element = listRef.current[index];
179
+ return element == null || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true";
180
+ }
181
+ function findNonDisabledListIndex(listRef) {
182
+ var { startingIndex = -1, decrement = false, disabledIndices, amount = 1 } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
183
+ var index = startingIndex;
184
+ do {
185
+ index += decrement ? -amount : amount;
186
+ } while (index >= 0 && index <= listRef.current.length - 1 && isListIndexDisabled(listRef, index, disabledIndices));
187
+ return index;
188
+ }
189
+ function getMinListIndex(listRef, disabledIndices) {
190
+ return findNonDisabledListIndex(listRef, { disabledIndices });
191
+ }
192
+ function getMaxListIndex(listRef, disabledIndices) {
193
+ return findNonDisabledListIndex(listRef, {
194
+ decrement: true,
195
+ startingIndex: listRef.current.length,
196
+ disabledIndices
197
+ });
198
+ }
199
+ function isIndexOutOfListBounds(listRef, index) {
200
+ return index < 0 || index >= listRef.current.length;
201
+ }