@react-aria/utils 3.26.0 → 3.28.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 (90) hide show
  1. package/dist/DOMFunctions.main.js +44 -0
  2. package/dist/DOMFunctions.main.js.map +1 -0
  3. package/dist/DOMFunctions.mjs +37 -0
  4. package/dist/DOMFunctions.module.js +37 -0
  5. package/dist/DOMFunctions.module.js.map +1 -0
  6. package/dist/ShadowTreeWalker.main.js +200 -0
  7. package/dist/ShadowTreeWalker.main.js.map +1 -0
  8. package/dist/ShadowTreeWalker.mjs +194 -0
  9. package/dist/ShadowTreeWalker.module.js +194 -0
  10. package/dist/ShadowTreeWalker.module.js.map +1 -0
  11. package/dist/animation.main.js +97 -0
  12. package/dist/animation.main.js.map +1 -0
  13. package/dist/animation.mjs +91 -0
  14. package/dist/animation.module.js +91 -0
  15. package/dist/animation.module.js.map +1 -0
  16. package/dist/constants.main.js +23 -0
  17. package/dist/constants.main.js.map +1 -0
  18. package/dist/constants.mjs +17 -0
  19. package/dist/constants.module.js +17 -0
  20. package/dist/constants.module.js.map +1 -0
  21. package/dist/domHelpers.main.js +9 -0
  22. package/dist/domHelpers.main.js.map +1 -1
  23. package/dist/domHelpers.mjs +9 -1
  24. package/dist/domHelpers.module.js +9 -1
  25. package/dist/domHelpers.module.js.map +1 -1
  26. package/dist/import.mjs +18 -2
  27. package/dist/inertValue.main.js +19 -0
  28. package/dist/inertValue.main.js.map +1 -0
  29. package/dist/inertValue.mjs +14 -0
  30. package/dist/inertValue.module.js +14 -0
  31. package/dist/inertValue.module.js.map +1 -0
  32. package/dist/isFocusable.main.js +34 -0
  33. package/dist/isFocusable.main.js.map +1 -0
  34. package/dist/isFocusable.mjs +28 -0
  35. package/dist/isFocusable.module.js +28 -0
  36. package/dist/isFocusable.module.js.map +1 -0
  37. package/dist/keyboard.main.js +26 -0
  38. package/dist/keyboard.main.js.map +1 -0
  39. package/dist/keyboard.mjs +21 -0
  40. package/dist/keyboard.module.js +21 -0
  41. package/dist/keyboard.module.js.map +1 -0
  42. package/dist/main.js +31 -0
  43. package/dist/main.js.map +1 -1
  44. package/dist/mergeProps.main.js.map +1 -1
  45. package/dist/mergeProps.module.js.map +1 -1
  46. package/dist/module.js +18 -2
  47. package/dist/module.js.map +1 -1
  48. package/dist/scrollIntoView.main.js +14 -8
  49. package/dist/scrollIntoView.main.js.map +1 -1
  50. package/dist/scrollIntoView.mjs +14 -8
  51. package/dist/scrollIntoView.module.js +14 -8
  52. package/dist/scrollIntoView.module.js.map +1 -1
  53. package/dist/types.d.ts +61 -0
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/useGlobalListeners.main.js +1 -1
  56. package/dist/useGlobalListeners.main.js.map +1 -1
  57. package/dist/useGlobalListeners.mjs +1 -1
  58. package/dist/useGlobalListeners.module.js +1 -1
  59. package/dist/useGlobalListeners.module.js.map +1 -1
  60. package/dist/useId.main.js +26 -21
  61. package/dist/useId.main.js.map +1 -1
  62. package/dist/useId.mjs +28 -23
  63. package/dist/useId.module.js +28 -23
  64. package/dist/useId.module.js.map +1 -1
  65. package/dist/useUpdateEffect.main.js +2 -1
  66. package/dist/useUpdateEffect.main.js.map +1 -1
  67. package/dist/useUpdateEffect.mjs +2 -1
  68. package/dist/useUpdateEffect.module.js +2 -1
  69. package/dist/useUpdateEffect.module.js.map +1 -1
  70. package/dist/useUpdateLayoutEffect.main.js +40 -0
  71. package/dist/useUpdateLayoutEffect.main.js.map +1 -0
  72. package/dist/useUpdateLayoutEffect.mjs +35 -0
  73. package/dist/useUpdateLayoutEffect.module.js +35 -0
  74. package/dist/useUpdateLayoutEffect.module.js.map +1 -0
  75. package/package.json +6 -4
  76. package/src/animation.ts +103 -0
  77. package/src/constants.ts +15 -0
  78. package/src/domHelpers.ts +19 -0
  79. package/src/index.ts +9 -1
  80. package/src/inertValue.ts +11 -0
  81. package/src/isFocusable.ts +28 -0
  82. package/src/keyboard.tsx +27 -0
  83. package/src/mergeProps.ts +1 -1
  84. package/src/scrollIntoView.ts +28 -12
  85. package/src/shadowdom/DOMFunctions.ts +70 -0
  86. package/src/shadowdom/ShadowTreeWalker.ts +319 -0
  87. package/src/useGlobalListeners.ts +2 -1
  88. package/src/useId.ts +24 -15
  89. package/src/useUpdateEffect.ts +3 -2
  90. package/src/useUpdateLayoutEffect.ts +37 -0
@@ -0,0 +1,194 @@
1
+ import {nodeContains as $d4ee10de306f2510$export$4282f70798064fe0} from "./DOMFunctions.module.js";
2
+ import {shadowDOM as $bJKXg$shadowDOM} from "@react-stately/flags";
3
+
4
+ // https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/ShadowTreeWalker.ts
5
+
6
+
7
+ class $dfc540311bf7f109$export$63eb3ababa9c55c4 {
8
+ get currentNode() {
9
+ return this._currentNode;
10
+ }
11
+ set currentNode(node) {
12
+ if (!(0, $d4ee10de306f2510$export$4282f70798064fe0)(this.root, node)) throw new Error('Cannot set currentNode to a node that is not contained by the root node.');
13
+ const walkers = [];
14
+ let curNode = node;
15
+ let currentWalkerCurrentNode = node;
16
+ this._currentNode = node;
17
+ while(curNode && curNode !== this.root)if (curNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
18
+ const shadowRoot = curNode;
19
+ const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {
20
+ acceptNode: this._acceptNode
21
+ });
22
+ walkers.push(walker);
23
+ walker.currentNode = currentWalkerCurrentNode;
24
+ this._currentSetFor.add(walker);
25
+ curNode = currentWalkerCurrentNode = shadowRoot.host;
26
+ } else curNode = curNode.parentNode;
27
+ const walker = this._doc.createTreeWalker(this.root, this.whatToShow, {
28
+ acceptNode: this._acceptNode
29
+ });
30
+ walkers.push(walker);
31
+ walker.currentNode = currentWalkerCurrentNode;
32
+ this._currentSetFor.add(walker);
33
+ this._walkerStack = walkers;
34
+ }
35
+ get doc() {
36
+ return this._doc;
37
+ }
38
+ firstChild() {
39
+ let currentNode = this.currentNode;
40
+ let newNode = this.nextNode();
41
+ if (!(0, $d4ee10de306f2510$export$4282f70798064fe0)(currentNode, newNode)) {
42
+ this.currentNode = currentNode;
43
+ return null;
44
+ }
45
+ if (newNode) this.currentNode = newNode;
46
+ return newNode;
47
+ }
48
+ lastChild() {
49
+ let walker = this._walkerStack[0];
50
+ let newNode = walker.lastChild();
51
+ if (newNode) this.currentNode = newNode;
52
+ return newNode;
53
+ }
54
+ nextNode() {
55
+ const nextNode = this._walkerStack[0].nextNode();
56
+ if (nextNode) {
57
+ const shadowRoot = nextNode.shadowRoot;
58
+ if (shadowRoot) {
59
+ var _this_filter;
60
+ let nodeResult;
61
+ if (typeof this.filter === 'function') nodeResult = this.filter(nextNode);
62
+ else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) nodeResult = this.filter.acceptNode(nextNode);
63
+ if (nodeResult === NodeFilter.FILTER_ACCEPT) {
64
+ this.currentNode = nextNode;
65
+ return nextNode;
66
+ }
67
+ // _acceptNode should have added new walker for this shadow,
68
+ // go in recursively.
69
+ let newNode = this.nextNode();
70
+ if (newNode) this.currentNode = newNode;
71
+ return newNode;
72
+ }
73
+ if (nextNode) this.currentNode = nextNode;
74
+ return nextNode;
75
+ } else {
76
+ if (this._walkerStack.length > 1) {
77
+ this._walkerStack.shift();
78
+ let newNode = this.nextNode();
79
+ if (newNode) this.currentNode = newNode;
80
+ return newNode;
81
+ } else return null;
82
+ }
83
+ }
84
+ previousNode() {
85
+ const currentWalker = this._walkerStack[0];
86
+ if (currentWalker.currentNode === currentWalker.root) {
87
+ if (this._currentSetFor.has(currentWalker)) {
88
+ this._currentSetFor.delete(currentWalker);
89
+ if (this._walkerStack.length > 1) {
90
+ this._walkerStack.shift();
91
+ let newNode = this.previousNode();
92
+ if (newNode) this.currentNode = newNode;
93
+ return newNode;
94
+ } else return null;
95
+ }
96
+ return null;
97
+ }
98
+ const previousNode = currentWalker.previousNode();
99
+ if (previousNode) {
100
+ const shadowRoot = previousNode.shadowRoot;
101
+ if (shadowRoot) {
102
+ var _this_filter;
103
+ let nodeResult;
104
+ if (typeof this.filter === 'function') nodeResult = this.filter(previousNode);
105
+ else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) nodeResult = this.filter.acceptNode(previousNode);
106
+ if (nodeResult === NodeFilter.FILTER_ACCEPT) {
107
+ if (previousNode) this.currentNode = previousNode;
108
+ return previousNode;
109
+ }
110
+ // _acceptNode should have added new walker for this shadow,
111
+ // go in recursively.
112
+ let newNode = this.lastChild();
113
+ if (newNode) this.currentNode = newNode;
114
+ return newNode;
115
+ }
116
+ if (previousNode) this.currentNode = previousNode;
117
+ return previousNode;
118
+ } else {
119
+ if (this._walkerStack.length > 1) {
120
+ this._walkerStack.shift();
121
+ let newNode = this.previousNode();
122
+ if (newNode) this.currentNode = newNode;
123
+ return newNode;
124
+ } else return null;
125
+ }
126
+ }
127
+ /**
128
+ * @deprecated
129
+ */ nextSibling() {
130
+ // if (__DEV__) {
131
+ // throw new Error("Method not implemented.");
132
+ // }
133
+ return null;
134
+ }
135
+ /**
136
+ * @deprecated
137
+ */ previousSibling() {
138
+ // if (__DEV__) {
139
+ // throw new Error("Method not implemented.");
140
+ // }
141
+ return null;
142
+ }
143
+ /**
144
+ * @deprecated
145
+ */ parentNode() {
146
+ // if (__DEV__) {
147
+ // throw new Error("Method not implemented.");
148
+ // }
149
+ return null;
150
+ }
151
+ constructor(doc, root, whatToShow, filter){
152
+ this._walkerStack = [];
153
+ this._currentSetFor = new Set();
154
+ this._acceptNode = (node)=>{
155
+ if (node.nodeType === Node.ELEMENT_NODE) {
156
+ const shadowRoot = node.shadowRoot;
157
+ if (shadowRoot) {
158
+ const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {
159
+ acceptNode: this._acceptNode
160
+ });
161
+ this._walkerStack.unshift(walker);
162
+ return NodeFilter.FILTER_ACCEPT;
163
+ } else {
164
+ var _this_filter;
165
+ if (typeof this.filter === 'function') return this.filter(node);
166
+ else if ((_this_filter = this.filter) === null || _this_filter === void 0 ? void 0 : _this_filter.acceptNode) return this.filter.acceptNode(node);
167
+ else if (this.filter === null) return NodeFilter.FILTER_ACCEPT;
168
+ }
169
+ }
170
+ return NodeFilter.FILTER_SKIP;
171
+ };
172
+ this._doc = doc;
173
+ this.root = root;
174
+ this.filter = filter !== null && filter !== void 0 ? filter : null;
175
+ this.whatToShow = whatToShow !== null && whatToShow !== void 0 ? whatToShow : NodeFilter.SHOW_ALL;
176
+ this._currentNode = root;
177
+ this._walkerStack.unshift(doc.createTreeWalker(root, whatToShow, this._acceptNode));
178
+ const shadowRoot = root.shadowRoot;
179
+ if (shadowRoot) {
180
+ const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {
181
+ acceptNode: this._acceptNode
182
+ });
183
+ this._walkerStack.unshift(walker);
184
+ }
185
+ }
186
+ }
187
+ function $dfc540311bf7f109$export$4d0f8be8b12a7ef6(doc, root, whatToShow, filter) {
188
+ if ((0, $bJKXg$shadowDOM)()) return new $dfc540311bf7f109$export$63eb3ababa9c55c4(doc, root, whatToShow, filter);
189
+ return doc.createTreeWalker(root, whatToShow, filter);
190
+ }
191
+
192
+
193
+ export {$dfc540311bf7f109$export$63eb3ababa9c55c4 as ShadowTreeWalker, $dfc540311bf7f109$export$4d0f8be8b12a7ef6 as createShadowTreeWalker};
194
+ //# sourceMappingURL=ShadowTreeWalker.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA,0HAA0H;;;AAKnH,MAAM;IAmEX,IAAW,cAAoB;QAC7B,OAAO,IAAI,CAAC,YAAY;IAC1B;IAEA,IAAW,YAAY,IAAU,EAAE;QACjC,IAAI,CAAC,CAAA,GAAA,yCAAW,EAAE,IAAI,CAAC,IAAI,EAAE,OAC3B,MAAM,IAAI,MACR;QAIJ,MAAM,UAAwB,EAAE;QAChC,IAAI,UAAmC;QACvC,IAAI,2BAA2B;QAE/B,IAAI,CAAC,Y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KAAK,MAAM,YAAY;IAErD,OAAO,IAAI,gBAAgB,CAAC,MAAM,YAAY;AAChD","sources":["packages/@react-aria/utils/src/shadowdom/ShadowTreeWalker.ts"],"sourcesContent":["// https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/ShadowTreeWalker.ts\n\nimport {nodeContains} from './DOMFunctions';\nimport {shadowDOM} from '@react-stately/flags';\n\nexport class ShadowTreeWalker implements TreeWalker {\n public readonly filter: NodeFilter | null;\n public readonly root: Node;\n public readonly whatToShow: number;\n\n private _doc: Document;\n private _walkerStack: Array<TreeWalker> = [];\n private _currentNode: Node;\n private _currentSetFor: Set<TreeWalker> = new Set();\n\n constructor(\n doc: Document,\n root: Node,\n whatToShow?: number,\n filter?: NodeFilter | null\n ) {\n this._doc = doc;\n this.root = root;\n this.filter = filter ?? null;\n this.whatToShow = whatToShow ?? NodeFilter.SHOW_ALL;\n this._currentNode = root;\n\n this._walkerStack.unshift(\n doc.createTreeWalker(root, whatToShow, this._acceptNode)\n );\n\n const shadowRoot = (root as Element).shadowRoot;\n\n if (shadowRoot) {\n const walker = this._doc.createTreeWalker(\n shadowRoot,\n this.whatToShow,\n {acceptNode: this._acceptNode}\n );\n\n this._walkerStack.unshift(walker);\n }\n }\n\n private _acceptNode = (node: Node): number => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const shadowRoot = (node as Element).shadowRoot;\n\n if (shadowRoot) {\n const walker = this._doc.createTreeWalker(\n shadowRoot,\n this.whatToShow,\n {acceptNode: this._acceptNode}\n );\n\n this._walkerStack.unshift(walker);\n\n return NodeFilter.FILTER_ACCEPT;\n } else {\n if (typeof this.filter === 'function') {\n return this.filter(node);\n } else if (this.filter?.acceptNode) {\n return this.filter.acceptNode(node);\n } else if (this.filter === null) {\n return NodeFilter.FILTER_ACCEPT;\n }\n }\n }\n\n return NodeFilter.FILTER_SKIP;\n };\n\n public get currentNode(): Node {\n return this._currentNode;\n }\n\n public set currentNode(node: Node) {\n if (!nodeContains(this.root, node)) {\n throw new Error(\n 'Cannot set currentNode to a node that is not contained by the root node.'\n );\n }\n\n const walkers: TreeWalker[] = [];\n let curNode: Node | null | undefined = node;\n let currentWalkerCurrentNode = node;\n\n this._currentNode = node;\n\n while (curNode && curNode !== this.root) {\n if (curNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n const shadowRoot = curNode as ShadowRoot;\n\n const walker = this._doc.createTreeWalker(\n shadowRoot,\n this.whatToShow,\n {acceptNode: this._acceptNode}\n );\n\n walkers.push(walker);\n\n walker.currentNode = currentWalkerCurrentNode;\n\n this._currentSetFor.add(walker);\n\n curNode = currentWalkerCurrentNode = shadowRoot.host;\n } else {\n curNode = curNode.parentNode;\n }\n }\n\n const walker = this._doc.createTreeWalker(\n this.root,\n this.whatToShow,\n {acceptNode: this._acceptNode}\n );\n\n walkers.push(walker);\n\n walker.currentNode = currentWalkerCurrentNode;\n\n this._currentSetFor.add(walker);\n\n this._walkerStack = walkers;\n }\n\n public get doc(): Document {\n return this._doc;\n }\n\n public firstChild(): Node | null {\n let currentNode = this.currentNode;\n let newNode = this.nextNode();\n if (!nodeContains(currentNode, newNode)) {\n this.currentNode = currentNode;\n return null;\n }\n if (newNode) {\n this.currentNode = newNode;\n }\n return newNode;\n }\n\n public lastChild(): Node | null {\n let walker = this._walkerStack[0];\n let newNode = walker.lastChild();\n if (newNode) {\n this.currentNode = newNode;\n }\n return newNode;\n }\n\n public nextNode(): Node | null {\n const nextNode = this._walkerStack[0].nextNode();\n\n if (nextNode) {\n const shadowRoot = (nextNode as Element).shadowRoot;\n\n if (shadowRoot) {\n let nodeResult: number | undefined;\n\n if (typeof this.filter === 'function') {\n nodeResult = this.filter(nextNode);\n } else if (this.filter?.acceptNode) {\n nodeResult = this.filter.acceptNode(nextNode);\n }\n\n if (nodeResult === NodeFilter.FILTER_ACCEPT) {\n this.currentNode = nextNode;\n return nextNode;\n }\n\n // _acceptNode should have added new walker for this shadow,\n // go in recursively.\n let newNode = this.nextNode();\n if (newNode) {\n this.currentNode = newNode;\n }\n return newNode;\n }\n\n if (nextNode) {\n this.currentNode = nextNode;\n }\n return nextNode;\n } else {\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n\n let newNode = this.nextNode();\n if (newNode) {\n this.currentNode = newNode;\n }\n return newNode;\n } else {\n return null;\n }\n }\n }\n\n public previousNode(): Node | null {\n const currentWalker = this._walkerStack[0];\n\n if (currentWalker.currentNode === currentWalker.root) {\n if (this._currentSetFor.has(currentWalker)) {\n this._currentSetFor.delete(currentWalker);\n\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n let newNode = this.previousNode();\n if (newNode) {\n this.currentNode = newNode;\n }\n return newNode;\n } else {\n return null;\n }\n }\n\n return null;\n }\n\n const previousNode = currentWalker.previousNode();\n\n if (previousNode) {\n const shadowRoot = (previousNode as Element).shadowRoot;\n\n if (shadowRoot) {\n let nodeResult: number | undefined;\n\n if (typeof this.filter === 'function') {\n nodeResult = this.filter(previousNode);\n } else if (this.filter?.acceptNode) {\n nodeResult = this.filter.acceptNode(previousNode);\n }\n\n if (nodeResult === NodeFilter.FILTER_ACCEPT) {\n if (previousNode) {\n this.currentNode = previousNode;\n }\n return previousNode;\n }\n\n // _acceptNode should have added new walker for this shadow,\n // go in recursively.\n let newNode = this.lastChild();\n if (newNode) {\n this.currentNode = newNode;\n }\n return newNode;\n }\n\n if (previousNode) {\n this.currentNode = previousNode;\n }\n return previousNode;\n } else {\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n\n let newNode = this.previousNode();\n if (newNode) {\n this.currentNode = newNode;\n }\n return newNode;\n } else {\n return null;\n }\n }\n }\n\n /**\n * @deprecated\n */\n public nextSibling(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n\n return null;\n }\n\n /**\n * @deprecated\n */\n public previousSibling(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n\n return null;\n }\n\n /**\n * @deprecated\n */\n public parentNode(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n\n return null;\n }\n}\n\n/**\n * ShadowDOM safe version of document.createTreeWalker.\n */\nexport function createShadowTreeWalker(\n doc: Document,\n root: Node,\n whatToShow?: number,\n filter?: NodeFilter | null\n) {\n if (shadowDOM()) {\n return new ShadowTreeWalker(doc, root, whatToShow, filter);\n }\n return doc.createTreeWalker(root, whatToShow, filter);\n}\n"],"names":[],"version":3,"file":"ShadowTreeWalker.module.js.map"}
@@ -0,0 +1,97 @@
1
+ var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
2
+ var $bsryd$reactdom = require("react-dom");
3
+ var $bsryd$react = require("react");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useEnterAnimation", () => $5bd06107f98811f5$export$6d3443f2c48bfc20);
11
+ $parcel$export(module.exports, "useExitAnimation", () => $5bd06107f98811f5$export$45fda7c47f93fd48);
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */
23
+
24
+
25
+ function $5bd06107f98811f5$export$6d3443f2c48bfc20(ref, isReady = true) {
26
+ let [isEntering, setEntering] = (0, $bsryd$react.useState)(true);
27
+ let isAnimationReady = isEntering && isReady;
28
+ // There are two cases for entry animations:
29
+ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
30
+ // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
31
+ //
32
+ // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
33
+ // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
34
+ (0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
35
+ if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
36
+ for (let animation of ref.current.getAnimations())if (animation instanceof CSSTransition) animation.cancel();
37
+ }
38
+ }, [
39
+ ref,
40
+ isAnimationReady
41
+ ]);
42
+ $5bd06107f98811f5$var$useAnimation(ref, isAnimationReady, (0, $bsryd$react.useCallback)(()=>setEntering(false), []));
43
+ return isAnimationReady;
44
+ }
45
+ function $5bd06107f98811f5$export$45fda7c47f93fd48(ref, isOpen) {
46
+ let [exitState, setExitState] = (0, $bsryd$react.useState)(isOpen ? 'open' : 'closed');
47
+ switch(exitState){
48
+ case 'open':
49
+ // If isOpen becomes false, set the state to exiting.
50
+ if (!isOpen) setExitState('exiting');
51
+ break;
52
+ case 'closed':
53
+ case 'exiting':
54
+ // If we are exiting and isOpen becomes true, the animation was interrupted.
55
+ // Reset the state to open.
56
+ if (isOpen) setExitState('open');
57
+ break;
58
+ }
59
+ let isExiting = exitState === 'exiting';
60
+ $5bd06107f98811f5$var$useAnimation(ref, isExiting, (0, $bsryd$react.useCallback)(()=>{
61
+ // Set the state to closed, which will cause the element to be unmounted.
62
+ setExitState((state)=>state === 'exiting' ? 'closed' : state);
63
+ }, []));
64
+ return isExiting;
65
+ }
66
+ function $5bd06107f98811f5$var$useAnimation(ref, isActive, onEnd) {
67
+ (0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
68
+ if (isActive && ref.current) {
69
+ if (!('getAnimations' in ref.current)) {
70
+ // JSDOM
71
+ onEnd();
72
+ return;
73
+ }
74
+ let animations = ref.current.getAnimations();
75
+ if (animations.length === 0) {
76
+ onEnd();
77
+ return;
78
+ }
79
+ let canceled = false;
80
+ Promise.all(animations.map((a)=>a.finished)).then(()=>{
81
+ if (!canceled) (0, $bsryd$reactdom.flushSync)(()=>{
82
+ onEnd();
83
+ });
84
+ }).catch(()=>{});
85
+ return ()=>{
86
+ canceled = true;
87
+ };
88
+ }
89
+ }, [
90
+ ref,
91
+ isActive,
92
+ onEnd
93
+ ]);
94
+ }
95
+
96
+
97
+ //# sourceMappingURL=animation.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAMM,SAAS,0CAAkB,GAAkC,EAAE,UAAmB,IAAI;IAC3F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IACzC,IAAI,mBAAmB,cAAc;IAErC,4CAA4C;IAC5C,kIAAkI;IAClI,4IAA4I;IAC5I,EAAE;IACF,mJAAmJ;IACnJ,+FAA+F;IAC/F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,oBAAoB,IAAI,OAAO,IAAI,mBAAmB,IAAI,OAAO,EAAE;YACrE,KAAK,IAAI,aAAa,IAAI,OAAO,CAAC,aAAa,GAC7C,IAAI,qBAAqB,eACvB,UAAU,MAAM;QAGtB;IACF,GAAG;QAAC;QAAK;KAAiB;IAE1B,mCAAa,KAAK,kBAAkB,CAAA,GAAA,wBAAU,EAAE,IAAM,YAAY,QAAQ,EAAE;IAC5E,OAAO;AACT;AAEO,SAAS,0CAAiB,GAAkC,EAAE,MAAe;IAClF,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAiC,SAAS,SAAS;IAE1F,OAAQ;QACN,KAAK;YACH,qDAAqD;YACrD,IAAI,CAAC,QACH,aAAa;YAEf;QACF,KAAK;QACL,KAAK;YACH,4EAA4E;YAC5E,2BAA2B;YAC3B,IAAI,QACF,aAAa;YAEf;IACJ;IAEA,IAAI,YAAY,cAAc;IAC9B,mCACE,KACA,WACA,CAAA,GAAA,wBAAU,EAAE;QACV,yEAAyE;QACzE,aAAa,CAAA,QAAS,UAAU,YAAY,WAAW;IACzD,GAAG,EAAE;IAGP,OAAO;AACT;AAEA,SAAS,mCAAa,GAAkC,EAAE,QAAiB,EAAE,KAAiB;IAC5F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,YAAY,IAAI,OAAO,EAAE;YAC3B,IAAI,CAAE,CAAA,mBAAmB,IAAI,OAAO,AAAD,GAAI;gBACrC,QAAQ;gBACR;gBACA;YACF;YAEA,IAAI,aAAa,IAAI,OAAO,CAAC,aAAa;YAC1C,IAAI,WAAW,MAAM,KAAK,GAAG;gBAC3B;gBACA;YACF;YAEA,IAAI,WAAW;YACf,QAAQ,GAAG,CAAC,WAAW,GAAG,CAAC,CAAA,IAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;gBAChD,IAAI,CAAC,UACH,CAAA,GAAA,yBAAQ,EAAE;oBACR;gBACF;YAEJ,GAAG,KAAK,CAAC,KAAO;YAEhB,OAAO;gBACL,WAAW;YACb;QACF;IACF,GAAG;QAAC;QAAK;QAAU;KAAM;AAC3B","sources":["packages/@react-aria/utils/src/animation.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport {RefObject, useCallback, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {\n let [isEntering, setEntering] = useState(true);\n let isAnimationReady = isEntering && isReady;\n \n // There are two cases for entry animations:\n // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.\n // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.\n //\n // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).\n // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).\n useLayoutEffect(() => {\n if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {\n for (let animation of ref.current.getAnimations()) {\n if (animation instanceof CSSTransition) {\n animation.cancel();\n }\n }\n }\n }, [ref, isAnimationReady]);\n\n useAnimation(ref, isAnimationReady, useCallback(() => setEntering(false), []));\n return isAnimationReady;\n}\n\nexport function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {\n let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');\n\n switch (exitState) {\n case 'open':\n // If isOpen becomes false, set the state to exiting.\n if (!isOpen) {\n setExitState('exiting');\n }\n break;\n case 'closed':\n case 'exiting':\n // If we are exiting and isOpen becomes true, the animation was interrupted.\n // Reset the state to open.\n if (isOpen) {\n setExitState('open');\n }\n break;\n }\n\n let isExiting = exitState === 'exiting';\n useAnimation(\n ref,\n isExiting,\n useCallback(() => {\n // Set the state to closed, which will cause the element to be unmounted.\n setExitState(state => state === 'exiting' ? 'closed' : state);\n }, [])\n );\n\n return isExiting;\n}\n\nfunction useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {\n useLayoutEffect(() => {\n if (isActive && ref.current) {\n if (!('getAnimations' in ref.current)) {\n // JSDOM\n onEnd();\n return;\n }\n \n let animations = ref.current.getAnimations();\n if (animations.length === 0) {\n onEnd();\n return;\n }\n\n let canceled = false;\n Promise.all(animations.map(a => a.finished)).then(() => {\n if (!canceled) {\n flushSync(() => {\n onEnd();\n });\n }\n }).catch(() => {});\n \n return () => {\n canceled = true;\n };\n }\n }, [ref, isActive, onEnd]);\n}\n"],"names":[],"version":3,"file":"animation.main.js.map"}
@@ -0,0 +1,91 @@
1
+ import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
2
+ import {flushSync as $jJMAe$flushSync} from "react-dom";
3
+ import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback} from "react";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $d3f049242431219c$export$6d3443f2c48bfc20(ref, isReady = true) {
19
+ let [isEntering, setEntering] = (0, $jJMAe$useState)(true);
20
+ let isAnimationReady = isEntering && isReady;
21
+ // There are two cases for entry animations:
22
+ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
23
+ // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
24
+ //
25
+ // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
26
+ // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
27
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
28
+ if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
29
+ for (let animation of ref.current.getAnimations())if (animation instanceof CSSTransition) animation.cancel();
30
+ }
31
+ }, [
32
+ ref,
33
+ isAnimationReady
34
+ ]);
35
+ $d3f049242431219c$var$useAnimation(ref, isAnimationReady, (0, $jJMAe$useCallback)(()=>setEntering(false), []));
36
+ return isAnimationReady;
37
+ }
38
+ function $d3f049242431219c$export$45fda7c47f93fd48(ref, isOpen) {
39
+ let [exitState, setExitState] = (0, $jJMAe$useState)(isOpen ? 'open' : 'closed');
40
+ switch(exitState){
41
+ case 'open':
42
+ // If isOpen becomes false, set the state to exiting.
43
+ if (!isOpen) setExitState('exiting');
44
+ break;
45
+ case 'closed':
46
+ case 'exiting':
47
+ // If we are exiting and isOpen becomes true, the animation was interrupted.
48
+ // Reset the state to open.
49
+ if (isOpen) setExitState('open');
50
+ break;
51
+ }
52
+ let isExiting = exitState === 'exiting';
53
+ $d3f049242431219c$var$useAnimation(ref, isExiting, (0, $jJMAe$useCallback)(()=>{
54
+ // Set the state to closed, which will cause the element to be unmounted.
55
+ setExitState((state)=>state === 'exiting' ? 'closed' : state);
56
+ }, []));
57
+ return isExiting;
58
+ }
59
+ function $d3f049242431219c$var$useAnimation(ref, isActive, onEnd) {
60
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
61
+ if (isActive && ref.current) {
62
+ if (!('getAnimations' in ref.current)) {
63
+ // JSDOM
64
+ onEnd();
65
+ return;
66
+ }
67
+ let animations = ref.current.getAnimations();
68
+ if (animations.length === 0) {
69
+ onEnd();
70
+ return;
71
+ }
72
+ let canceled = false;
73
+ Promise.all(animations.map((a)=>a.finished)).then(()=>{
74
+ if (!canceled) (0, $jJMAe$flushSync)(()=>{
75
+ onEnd();
76
+ });
77
+ }).catch(()=>{});
78
+ return ()=>{
79
+ canceled = true;
80
+ };
81
+ }
82
+ }, [
83
+ ref,
84
+ isActive,
85
+ onEnd
86
+ ]);
87
+ }
88
+
89
+
90
+ export {$d3f049242431219c$export$6d3443f2c48bfc20 as useEnterAnimation, $d3f049242431219c$export$45fda7c47f93fd48 as useExitAnimation};
91
+ //# sourceMappingURL=animation.module.js.map
@@ -0,0 +1,91 @@
1
+ import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
2
+ import {flushSync as $jJMAe$flushSync} from "react-dom";
3
+ import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback} from "react";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $d3f049242431219c$export$6d3443f2c48bfc20(ref, isReady = true) {
19
+ let [isEntering, setEntering] = (0, $jJMAe$useState)(true);
20
+ let isAnimationReady = isEntering && isReady;
21
+ // There are two cases for entry animations:
22
+ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
23
+ // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
24
+ //
25
+ // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
26
+ // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
27
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
28
+ if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
29
+ for (let animation of ref.current.getAnimations())if (animation instanceof CSSTransition) animation.cancel();
30
+ }
31
+ }, [
32
+ ref,
33
+ isAnimationReady
34
+ ]);
35
+ $d3f049242431219c$var$useAnimation(ref, isAnimationReady, (0, $jJMAe$useCallback)(()=>setEntering(false), []));
36
+ return isAnimationReady;
37
+ }
38
+ function $d3f049242431219c$export$45fda7c47f93fd48(ref, isOpen) {
39
+ let [exitState, setExitState] = (0, $jJMAe$useState)(isOpen ? 'open' : 'closed');
40
+ switch(exitState){
41
+ case 'open':
42
+ // If isOpen becomes false, set the state to exiting.
43
+ if (!isOpen) setExitState('exiting');
44
+ break;
45
+ case 'closed':
46
+ case 'exiting':
47
+ // If we are exiting and isOpen becomes true, the animation was interrupted.
48
+ // Reset the state to open.
49
+ if (isOpen) setExitState('open');
50
+ break;
51
+ }
52
+ let isExiting = exitState === 'exiting';
53
+ $d3f049242431219c$var$useAnimation(ref, isExiting, (0, $jJMAe$useCallback)(()=>{
54
+ // Set the state to closed, which will cause the element to be unmounted.
55
+ setExitState((state)=>state === 'exiting' ? 'closed' : state);
56
+ }, []));
57
+ return isExiting;
58
+ }
59
+ function $d3f049242431219c$var$useAnimation(ref, isActive, onEnd) {
60
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
61
+ if (isActive && ref.current) {
62
+ if (!('getAnimations' in ref.current)) {
63
+ // JSDOM
64
+ onEnd();
65
+ return;
66
+ }
67
+ let animations = ref.current.getAnimations();
68
+ if (animations.length === 0) {
69
+ onEnd();
70
+ return;
71
+ }
72
+ let canceled = false;
73
+ Promise.all(animations.map((a)=>a.finished)).then(()=>{
74
+ if (!canceled) (0, $jJMAe$flushSync)(()=>{
75
+ onEnd();
76
+ });
77
+ }).catch(()=>{});
78
+ return ()=>{
79
+ canceled = true;
80
+ };
81
+ }
82
+ }, [
83
+ ref,
84
+ isActive,
85
+ onEnd
86
+ ]);
87
+ }
88
+
89
+
90
+ export {$d3f049242431219c$export$6d3443f2c48bfc20 as useEnterAnimation, $d3f049242431219c$export$45fda7c47f93fd48 as useExitAnimation};
91
+ //# sourceMappingURL=animation.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAMM,SAAS,0CAAkB,GAAkC,EAAE,UAAmB,IAAI;IAC3F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IACzC,IAAI,mBAAmB,cAAc;IAErC,4CAA4C;IAC5C,kIAAkI;IAClI,4IAA4I;IAC5I,EAAE;IACF,mJAAmJ;IACnJ,+FAA+F;IAC/F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,oBAAoB,IAAI,OAAO,IAAI,mBAAmB,IAAI,OAAO,EAAE;YACrE,KAAK,IAAI,aAAa,IAAI,OAAO,CAAC,aAAa,GAC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\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport {RefObject, useCallback, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {\n let [isEntering, setEntering] = useState(true);\n let isAnimationReady = isEntering && isReady;\n \n // There are two cases for entry animations:\n // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.\n // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.\n //\n // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).\n // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).\n useLayoutEffect(() => {\n if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {\n for (let animation of ref.current.getAnimations()) {\n if (animation instanceof CSSTransition) {\n animation.cancel();\n }\n }\n }\n }, [ref, isAnimationReady]);\n\n useAnimation(ref, isAnimationReady, useCallback(() => setEntering(false), []));\n return isAnimationReady;\n}\n\nexport function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {\n let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');\n\n switch (exitState) {\n case 'open':\n // If isOpen becomes false, set the state to exiting.\n if (!isOpen) {\n setExitState('exiting');\n }\n break;\n case 'closed':\n case 'exiting':\n // If we are exiting and isOpen becomes true, the animation was interrupted.\n // Reset the state to open.\n if (isOpen) {\n setExitState('open');\n }\n break;\n }\n\n let isExiting = exitState === 'exiting';\n useAnimation(\n ref,\n isExiting,\n useCallback(() => {\n // Set the state to closed, which will cause the element to be unmounted.\n setExitState(state => state === 'exiting' ? 'closed' : state);\n }, [])\n );\n\n return isExiting;\n}\n\nfunction useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {\n useLayoutEffect(() => {\n if (isActive && ref.current) {\n if (!('getAnimations' in ref.current)) {\n // JSDOM\n onEnd();\n return;\n }\n \n let animations = ref.current.getAnimations();\n if (animations.length === 0) {\n onEnd();\n return;\n }\n\n let canceled = false;\n Promise.all(animations.map(a => a.finished)).then(() => {\n if (!canceled) {\n flushSync(() => {\n onEnd();\n });\n }\n }).catch(() => {});\n \n return () => {\n canceled = true;\n };\n }\n }, [ref, isActive, onEnd]);\n}\n"],"names":[],"version":3,"file":"animation.module.js.map"}
@@ -0,0 +1,23 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "CLEAR_FOCUS_EVENT", () => $a0850d0add29d276$export$447a38995de2c711);
7
+ $parcel$export(module.exports, "FOCUS_EVENT", () => $a0850d0add29d276$export$831c820ad60f9d12);
8
+ /*
9
+ * Copyright 2024 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */ // Custom event names for updating the autocomplete's aria-activedecendant.
19
+ const $a0850d0add29d276$export$447a38995de2c711 = 'react-aria-clear-focus';
20
+ const $a0850d0add29d276$export$831c820ad60f9d12 = 'react-aria-focus';
21
+
22
+
23
+ //# sourceMappingURL=constants.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAED,2EAA2E;AACpE,MAAM,4CAAoB;AAC1B,MAAM,4CAAc","sources":["packages/@react-aria/utils/src/constants.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Custom event names for updating the autocomplete's aria-activedecendant.\nexport const CLEAR_FOCUS_EVENT = 'react-aria-clear-focus';\nexport const FOCUS_EVENT = 'react-aria-focus';\n"],"names":[],"version":3,"file":"constants.main.js.map"}
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ // Custom event names for updating the autocomplete's aria-activedecendant.
12
+ const $5671b20cf9b562b2$export$447a38995de2c711 = 'react-aria-clear-focus';
13
+ const $5671b20cf9b562b2$export$831c820ad60f9d12 = 'react-aria-focus';
14
+
15
+
16
+ export {$5671b20cf9b562b2$export$447a38995de2c711 as CLEAR_FOCUS_EVENT, $5671b20cf9b562b2$export$831c820ad60f9d12 as FOCUS_EVENT};
17
+ //# sourceMappingURL=constants.module.js.map
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ // Custom event names for updating the autocomplete's aria-activedecendant.
12
+ const $5671b20cf9b562b2$export$447a38995de2c711 = 'react-aria-clear-focus';
13
+ const $5671b20cf9b562b2$export$831c820ad60f9d12 = 'react-aria-focus';
14
+
15
+
16
+ export {$5671b20cf9b562b2$export$447a38995de2c711 as CLEAR_FOCUS_EVENT, $5671b20cf9b562b2$export$831c820ad60f9d12 as FOCUS_EVENT};
17
+ //# sourceMappingURL=constants.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAED,2EAA2E;AACpE,MAAM,4CAAoB;AAC1B,MAAM,4CAAc","sources":["packages/@react-aria/utils/src/constants.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Custom event names for updating the autocomplete's aria-activedecendant.\nexport const CLEAR_FOCUS_EVENT = 'react-aria-clear-focus';\nexport const FOCUS_EVENT = 'react-aria-focus';\n"],"names":[],"version":3,"file":"constants.module.js.map"}
@@ -5,6 +5,7 @@ function $parcel$export(e, n, v, s) {
5
5
 
6
6
  $parcel$export(module.exports, "getOwnerDocument", () => $aaa611146751592e$export$b204af158042fbac);
7
7
  $parcel$export(module.exports, "getOwnerWindow", () => $aaa611146751592e$export$f21a1ffae260145a);
8
+ $parcel$export(module.exports, "isShadowRoot", () => $aaa611146751592e$export$af51f0f06c0f328a);
8
9
  const $aaa611146751592e$export$b204af158042fbac = (el)=>{
9
10
  var _el_ownerDocument;
10
11
  return (_el_ownerDocument = el === null || el === void 0 ? void 0 : el.ownerDocument) !== null && _el_ownerDocument !== void 0 ? _el_ownerDocument : document;
@@ -14,6 +15,14 @@ const $aaa611146751592e$export$f21a1ffae260145a = (el)=>{
14
15
  const doc = $aaa611146751592e$export$b204af158042fbac(el);
15
16
  return doc.defaultView || window;
16
17
  };
18
+ /**
19
+ * Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType property.
20
+ */ function $aaa611146751592e$var$isNode(value) {
21
+ return value !== null && typeof value === 'object' && 'nodeType' in value && typeof value.nodeType === 'number';
22
+ }
23
+ function $aaa611146751592e$export$af51f0f06c0f328a(node) {
24
+ return $aaa611146751592e$var$isNode(node) && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && 'host' in node;
25
+ }
17
26
 
18
27
 
19
28
  //# sourceMappingURL=domHelpers.main.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAO,MAAM,4CAAmB,CAAC;QACxB;IAAP,OAAO,CAAA,oBAAA,eAAA,yBAAA,GAAI,aAAa,cAAjB,+BAAA,oBAAqB;AAC9B;AAEO,MAAM,4CAAiB,CAC5B;IAEA,IAAI,MAAM,YAAY,MAAM,GAAG,MAAM,KAAK,IACxC,OAAO;IAGT,MAAM,MAAM,0CAAiB;IAC7B,OAAO,IAAI,WAAW,IAAI;AAC5B","sources":["packages/@react-aria/utils/src/domHelpers.ts"],"sourcesContent":["export const getOwnerDocument = (el: Element | null | undefined): Document => {\n return el?.ownerDocument ?? document;\n};\n\nexport const getOwnerWindow = (\n el: (Window & typeof global) | Element | null | undefined\n): Window & typeof global => {\n if (el && 'window' in el && el.window === el) {\n return el;\n }\n\n const doc = getOwnerDocument(el as Element | null | undefined);\n return doc.defaultView || window;\n};\n"],"names":[],"version":3,"file":"domHelpers.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAO,MAAM,4CAAmB,CAAC;QACxB;IAAP,OAAO,CAAA,oBAAA,eAAA,yBAAA,GAAI,aAAa,cAAjB,+BAAA,oBAAqB;AAC9B;AAEO,MAAM,4CAAiB,CAC5B;IAEA,IAAI,MAAM,YAAY,MAAM,GAAG,MAAM,KAAK,IACxC,OAAO;IAGT,MAAM,MAAM,0CAAiB;IAC7B,OAAO,IAAI,WAAW,IAAI;AAC5B;AAEA;;CAEC,GACD,SAAS,6BAAO,KAAc;IAC5B,OAAO,UAAU,QACf,OAAO,UAAU,YACjB,cAAc,SACd,OAAO,AAAC,MAAe,QAAQ,KAAK;AACxC;AAKO,SAAS,0CAAa,IAAiB;IAC5C,OAAO,6BAAO,SACZ,KAAK,QAAQ,KAAK,KAAK,sBAAsB,IAC7C,UAAU;AACd","sources":["packages/@react-aria/utils/src/domHelpers.ts"],"sourcesContent":["export const getOwnerDocument = (el: Element | null | undefined): Document => {\n return el?.ownerDocument ?? document;\n};\n\nexport const getOwnerWindow = (\n el: (Window & typeof global) | Element | null | undefined\n): Window & typeof global => {\n if (el && 'window' in el && el.window === el) {\n return el;\n }\n\n const doc = getOwnerDocument(el as Element | null | undefined);\n return doc.defaultView || window;\n};\n\n/**\n * Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType property.\n */\nfunction isNode(value: unknown): value is Node {\n return value !== null &&\n typeof value === 'object' &&\n 'nodeType' in value &&\n typeof (value as Node).nodeType === 'number';\n}\n/**\n * Type guard that checks if a node is a ShadowRoot. Uses nodeType and host property checks to\n * distinguish ShadowRoot from other DocumentFragments.\n */\nexport function isShadowRoot(node: Node | null): node is ShadowRoot {\n return isNode(node) &&\n node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&\n 'host' in node;\n}\n"],"names":[],"version":3,"file":"domHelpers.main.js.map"}