@react-aria/collections 3.0.0-alpha.1 → 3.0.0-nightly.2988

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 (40) hide show
  1. package/README.md +1 -1
  2. package/dist/BaseCollection.main.js +157 -0
  3. package/dist/BaseCollection.main.js.map +1 -0
  4. package/dist/BaseCollection.mjs +151 -0
  5. package/dist/BaseCollection.module.js +151 -0
  6. package/dist/BaseCollection.module.js.map +1 -0
  7. package/dist/CollectionBuilder.main.js +233 -0
  8. package/dist/CollectionBuilder.main.js.map +1 -0
  9. package/dist/CollectionBuilder.mjs +221 -0
  10. package/dist/CollectionBuilder.module.js +221 -0
  11. package/dist/CollectionBuilder.module.js.map +1 -0
  12. package/dist/Document.main.js +316 -0
  13. package/dist/Document.main.js.map +1 -0
  14. package/dist/Document.mjs +311 -0
  15. package/dist/Document.module.js +311 -0
  16. package/dist/Document.module.js.map +1 -0
  17. package/dist/Hidden.main.js +79 -0
  18. package/dist/Hidden.main.js.map +1 -0
  19. package/dist/Hidden.mjs +68 -0
  20. package/dist/Hidden.module.js +68 -0
  21. package/dist/Hidden.module.js.map +1 -0
  22. package/dist/import.mjs +23 -0
  23. package/dist/main.js +27 -348
  24. package/dist/main.js.map +1 -0
  25. package/dist/module.js +17 -318
  26. package/dist/module.js.map +1 -0
  27. package/dist/types.d.ts +81 -24
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/useCachedChildren.main.js +63 -0
  30. package/dist/useCachedChildren.main.js.map +1 -0
  31. package/dist/useCachedChildren.mjs +58 -0
  32. package/dist/useCachedChildren.module.js +58 -0
  33. package/dist/useCachedChildren.module.js.map +1 -0
  34. package/package.json +17 -10
  35. package/src/BaseCollection.ts +211 -0
  36. package/src/CollectionBuilder.tsx +237 -0
  37. package/src/Document.ts +453 -0
  38. package/src/Hidden.tsx +84 -0
  39. package/src/index.ts +19 -0
  40. package/src/useCachedChildren.ts +70 -0
@@ -0,0 +1,311 @@
1
+ import {NodeValue as $23b9f4fcf0fe224b$export$f5d856d854e74713} from "./BaseCollection.mjs";
2
+
3
+ /*
4
+ * Copyright 2024 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ class $681cc3c98f569e39$export$410b0c854570d131 {
15
+ *[Symbol.iterator]() {
16
+ let node = this.firstChild;
17
+ while(node){
18
+ yield node;
19
+ node = node.nextSibling;
20
+ }
21
+ }
22
+ get firstChild() {
23
+ return this._firstChild;
24
+ }
25
+ set firstChild(firstChild) {
26
+ this._firstChild = firstChild;
27
+ this.ownerDocument.markDirty(this);
28
+ }
29
+ get lastChild() {
30
+ return this._lastChild;
31
+ }
32
+ set lastChild(lastChild) {
33
+ this._lastChild = lastChild;
34
+ this.ownerDocument.markDirty(this);
35
+ }
36
+ get previousSibling() {
37
+ return this._previousSibling;
38
+ }
39
+ set previousSibling(previousSibling) {
40
+ this._previousSibling = previousSibling;
41
+ this.ownerDocument.markDirty(this);
42
+ }
43
+ get nextSibling() {
44
+ return this._nextSibling;
45
+ }
46
+ set nextSibling(nextSibling) {
47
+ this._nextSibling = nextSibling;
48
+ this.ownerDocument.markDirty(this);
49
+ }
50
+ get parentNode() {
51
+ return this._parentNode;
52
+ }
53
+ set parentNode(parentNode) {
54
+ this._parentNode = parentNode;
55
+ this.ownerDocument.markDirty(this);
56
+ }
57
+ get isConnected() {
58
+ var _this_parentNode;
59
+ return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
60
+ }
61
+ appendChild(child) {
62
+ this.ownerDocument.startTransaction();
63
+ if (child.parentNode) child.parentNode.removeChild(child);
64
+ if (this.firstChild == null) this.firstChild = child;
65
+ if (this.lastChild) {
66
+ this.lastChild.nextSibling = child;
67
+ child.index = this.lastChild.index + 1;
68
+ child.previousSibling = this.lastChild;
69
+ } else {
70
+ child.previousSibling = null;
71
+ child.index = 0;
72
+ }
73
+ child.parentNode = this;
74
+ child.nextSibling = null;
75
+ this.lastChild = child;
76
+ this.ownerDocument.markDirty(this);
77
+ if (child.hasSetProps) // Only add the node to the collection if we already received props for it.
78
+ // Otherwise wait until then so we have the correct id for the node.
79
+ this.ownerDocument.addNode(child);
80
+ this.ownerDocument.endTransaction();
81
+ this.ownerDocument.queueUpdate();
82
+ }
83
+ insertBefore(newNode, referenceNode) {
84
+ if (referenceNode == null) return this.appendChild(newNode);
85
+ this.ownerDocument.startTransaction();
86
+ if (newNode.parentNode) newNode.parentNode.removeChild(newNode);
87
+ newNode.nextSibling = referenceNode;
88
+ newNode.previousSibling = referenceNode.previousSibling;
89
+ newNode.index = referenceNode.index;
90
+ if (this.firstChild === referenceNode) this.firstChild = newNode;
91
+ else if (referenceNode.previousSibling) referenceNode.previousSibling.nextSibling = newNode;
92
+ referenceNode.previousSibling = newNode;
93
+ newNode.parentNode = referenceNode.parentNode;
94
+ let node = referenceNode;
95
+ while(node){
96
+ node.index++;
97
+ node = node.nextSibling;
98
+ }
99
+ if (newNode.hasSetProps) this.ownerDocument.addNode(newNode);
100
+ this.ownerDocument.endTransaction();
101
+ this.ownerDocument.queueUpdate();
102
+ }
103
+ removeChild(child) {
104
+ if (child.parentNode !== this || !this.ownerDocument.isMounted) return;
105
+ this.ownerDocument.startTransaction();
106
+ let node = child.nextSibling;
107
+ while(node){
108
+ node.index--;
109
+ node = node.nextSibling;
110
+ }
111
+ if (child.nextSibling) child.nextSibling.previousSibling = child.previousSibling;
112
+ if (child.previousSibling) child.previousSibling.nextSibling = child.nextSibling;
113
+ if (this.firstChild === child) this.firstChild = child.nextSibling;
114
+ if (this.lastChild === child) this.lastChild = child.previousSibling;
115
+ child.parentNode = null;
116
+ child.nextSibling = null;
117
+ child.previousSibling = null;
118
+ child.index = 0;
119
+ this.ownerDocument.removeNode(child);
120
+ this.ownerDocument.endTransaction();
121
+ this.ownerDocument.queueUpdate();
122
+ }
123
+ addEventListener() {}
124
+ removeEventListener() {}
125
+ constructor(ownerDocument){
126
+ this._firstChild = null;
127
+ this._lastChild = null;
128
+ this._previousSibling = null;
129
+ this._nextSibling = null;
130
+ this._parentNode = null;
131
+ this.ownerDocument = ownerDocument;
132
+ }
133
+ }
134
+ class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export$410b0c854570d131 {
135
+ get index() {
136
+ return this._index;
137
+ }
138
+ set index(index) {
139
+ this._index = index;
140
+ this.ownerDocument.markDirty(this);
141
+ }
142
+ get level() {
143
+ if (this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);
144
+ return 0;
145
+ }
146
+ updateNode() {
147
+ var _this_previousSibling, _this_nextSibling, _this_firstChild, _this_lastChild;
148
+ let node = this.ownerDocument.getMutableNode(this);
149
+ node.index = this.index;
150
+ node.level = this.level;
151
+ node.parentKey = this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd ? this.parentNode.node.key : null;
152
+ var _this_previousSibling_node_key;
153
+ node.prevKey = (_this_previousSibling_node_key = (_this_previousSibling = this.previousSibling) === null || _this_previousSibling === void 0 ? void 0 : _this_previousSibling.node.key) !== null && _this_previousSibling_node_key !== void 0 ? _this_previousSibling_node_key : null;
154
+ var _this_nextSibling_node_key;
155
+ node.nextKey = (_this_nextSibling_node_key = (_this_nextSibling = this.nextSibling) === null || _this_nextSibling === void 0 ? void 0 : _this_nextSibling.node.key) !== null && _this_nextSibling_node_key !== void 0 ? _this_nextSibling_node_key : null;
156
+ node.hasChildNodes = !!this.firstChild;
157
+ var _this_firstChild_node_key;
158
+ node.firstChildKey = (_this_firstChild_node_key = (_this_firstChild = this.firstChild) === null || _this_firstChild === void 0 ? void 0 : _this_firstChild.node.key) !== null && _this_firstChild_node_key !== void 0 ? _this_firstChild_node_key : null;
159
+ var _this_lastChild_node_key;
160
+ node.lastChildKey = (_this_lastChild_node_key = (_this_lastChild = this.lastChild) === null || _this_lastChild === void 0 ? void 0 : _this_lastChild.node.key) !== null && _this_lastChild_node_key !== void 0 ? _this_lastChild_node_key : null;
161
+ }
162
+ setProps(obj, ref, rendered, render) {
163
+ let node = this.ownerDocument.getMutableNode(this);
164
+ let { value: value, textValue: textValue, id: id, ...props } = obj;
165
+ props.ref = ref;
166
+ node.props = props;
167
+ node.rendered = rendered;
168
+ node.render = render;
169
+ node.value = value;
170
+ node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';
171
+ if (id != null && id !== node.key) {
172
+ if (this.hasSetProps) throw new Error('Cannot change the id of an item');
173
+ node.key = id;
174
+ }
175
+ // If this is the first time props have been set, end the transaction started in the constructor
176
+ // so this node can be emitted.
177
+ if (!this.hasSetProps) {
178
+ this.ownerDocument.addNode(this);
179
+ this.ownerDocument.endTransaction();
180
+ this.hasSetProps = true;
181
+ }
182
+ this.ownerDocument.queueUpdate();
183
+ }
184
+ get style() {
185
+ return {};
186
+ }
187
+ hasAttribute() {}
188
+ setAttribute() {}
189
+ setAttributeNS() {}
190
+ removeAttribute() {}
191
+ constructor(type, ownerDocument){
192
+ super(ownerDocument);
193
+ this.nodeType = 8 // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)
194
+ ;
195
+ this._index = 0;
196
+ this.hasSetProps = false;
197
+ this.node = new (0, $23b9f4fcf0fe224b$export$f5d856d854e74713)(type, `react-aria-${++ownerDocument.nodeId}`);
198
+ // Start a transaction so that no updates are emitted from the collection
199
+ // until the props for this node are set. We don't know the real id for the
200
+ // node until then, so we need to avoid emitting collections in an inconsistent state.
201
+ this.ownerDocument.startTransaction();
202
+ }
203
+ }
204
+ class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export$410b0c854570d131 {
205
+ get isConnected() {
206
+ return this.isMounted;
207
+ }
208
+ createElement(type) {
209
+ return new $681cc3c98f569e39$export$dc064fe9e59310fd(type, this);
210
+ }
211
+ /**
212
+ * Lazily gets a mutable instance of a Node. If the node has already
213
+ * been cloned during this update cycle, it just returns the existing one.
214
+ */ getMutableNode(element) {
215
+ let node = element.node;
216
+ if (!this.mutatedNodes.has(element)) {
217
+ node = element.node.clone();
218
+ this.mutatedNodes.add(element);
219
+ element.node = node;
220
+ }
221
+ this.markDirty(element);
222
+ return node;
223
+ }
224
+ getMutableCollection() {
225
+ if (!this.isSSR && !this.collectionMutated) {
226
+ this.collection = this.collection.clone();
227
+ this.collectionMutated = true;
228
+ }
229
+ return this.collection;
230
+ }
231
+ markDirty(node) {
232
+ this.dirtyNodes.add(node);
233
+ }
234
+ startTransaction() {
235
+ this.transactionCount++;
236
+ }
237
+ endTransaction() {
238
+ this.transactionCount--;
239
+ }
240
+ addNode(element) {
241
+ let collection = this.getMutableCollection();
242
+ if (!collection.getItem(element.node.key)) {
243
+ collection.addNode(element.node);
244
+ for (let child of element)this.addNode(child);
245
+ }
246
+ this.markDirty(element);
247
+ }
248
+ removeNode(node) {
249
+ for (let child of node)this.removeNode(child);
250
+ let collection = this.getMutableCollection();
251
+ collection.removeNode(node.node.key);
252
+ this.markDirty(node);
253
+ }
254
+ /** Finalizes the collection update, updating all nodes and freezing the collection. */ getCollection() {
255
+ if (this.transactionCount > 0) return this.collection;
256
+ this.updateCollection();
257
+ return this.collection;
258
+ }
259
+ updateCollection() {
260
+ for (let element of this.dirtyNodes)if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd && element.isConnected) element.updateNode();
261
+ this.dirtyNodes.clear();
262
+ if (this.mutatedNodes.size || this.collectionMutated) {
263
+ var _this_firstChild, _this_lastChild;
264
+ let collection = this.getMutableCollection();
265
+ for (let element of this.mutatedNodes)if (element.isConnected) collection.addNode(element.node);
266
+ var _this_firstChild_node_key, _this_lastChild_node_key;
267
+ collection.commit((_this_firstChild_node_key = (_this_firstChild = this.firstChild) === null || _this_firstChild === void 0 ? void 0 : _this_firstChild.node.key) !== null && _this_firstChild_node_key !== void 0 ? _this_firstChild_node_key : null, (_this_lastChild_node_key = (_this_lastChild = this.lastChild) === null || _this_lastChild === void 0 ? void 0 : _this_lastChild.node.key) !== null && _this_lastChild_node_key !== void 0 ? _this_lastChild_node_key : null, this.isSSR);
268
+ this.mutatedNodes.clear();
269
+ }
270
+ this.collectionMutated = false;
271
+ }
272
+ queueUpdate() {
273
+ // Don't emit any updates if there is a transaction in progress.
274
+ // queueUpdate should be called again after the transaction.
275
+ if (this.dirtyNodes.size === 0 || this.transactionCount > 0) return;
276
+ for (let fn of this.subscriptions)fn();
277
+ }
278
+ subscribe(fn) {
279
+ this.subscriptions.add(fn);
280
+ return ()=>this.subscriptions.delete(fn);
281
+ }
282
+ resetAfterSSR() {
283
+ if (this.isSSR) {
284
+ this.isSSR = false;
285
+ this.firstChild = null;
286
+ this.lastChild = null;
287
+ this.nodeId = 0;
288
+ }
289
+ }
290
+ constructor(collection){
291
+ // @ts-ignore
292
+ super(null);
293
+ this.nodeType = 11 // DOCUMENT_FRAGMENT_NODE
294
+ ;
295
+ this.ownerDocument = this;
296
+ this.dirtyNodes = new Set();
297
+ this.isSSR = false;
298
+ this.nodeId = 0;
299
+ this.nodesByProps = new WeakMap();
300
+ this.isMounted = true;
301
+ this.mutatedNodes = new Set();
302
+ this.subscriptions = new Set();
303
+ this.transactionCount = 0;
304
+ this.collection = collection;
305
+ this.collectionMutated = true;
306
+ }
307
+ }
308
+
309
+
310
+ export {$681cc3c98f569e39$export$410b0c854570d131 as BaseNode, $681cc3c98f569e39$export$dc064fe9e59310fd as ElementNode, $681cc3c98f569e39$export$b34a105447964f9f as Document};
311
+ //# sourceMappingURL=Document.module.js.map
@@ -0,0 +1,311 @@
1
+ import {NodeValue as $23b9f4fcf0fe224b$export$f5d856d854e74713} from "./BaseCollection.module.js";
2
+
3
+ /*
4
+ * Copyright 2024 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ class $681cc3c98f569e39$export$410b0c854570d131 {
15
+ *[Symbol.iterator]() {
16
+ let node = this.firstChild;
17
+ while(node){
18
+ yield node;
19
+ node = node.nextSibling;
20
+ }
21
+ }
22
+ get firstChild() {
23
+ return this._firstChild;
24
+ }
25
+ set firstChild(firstChild) {
26
+ this._firstChild = firstChild;
27
+ this.ownerDocument.markDirty(this);
28
+ }
29
+ get lastChild() {
30
+ return this._lastChild;
31
+ }
32
+ set lastChild(lastChild) {
33
+ this._lastChild = lastChild;
34
+ this.ownerDocument.markDirty(this);
35
+ }
36
+ get previousSibling() {
37
+ return this._previousSibling;
38
+ }
39
+ set previousSibling(previousSibling) {
40
+ this._previousSibling = previousSibling;
41
+ this.ownerDocument.markDirty(this);
42
+ }
43
+ get nextSibling() {
44
+ return this._nextSibling;
45
+ }
46
+ set nextSibling(nextSibling) {
47
+ this._nextSibling = nextSibling;
48
+ this.ownerDocument.markDirty(this);
49
+ }
50
+ get parentNode() {
51
+ return this._parentNode;
52
+ }
53
+ set parentNode(parentNode) {
54
+ this._parentNode = parentNode;
55
+ this.ownerDocument.markDirty(this);
56
+ }
57
+ get isConnected() {
58
+ var _this_parentNode;
59
+ return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
60
+ }
61
+ appendChild(child) {
62
+ this.ownerDocument.startTransaction();
63
+ if (child.parentNode) child.parentNode.removeChild(child);
64
+ if (this.firstChild == null) this.firstChild = child;
65
+ if (this.lastChild) {
66
+ this.lastChild.nextSibling = child;
67
+ child.index = this.lastChild.index + 1;
68
+ child.previousSibling = this.lastChild;
69
+ } else {
70
+ child.previousSibling = null;
71
+ child.index = 0;
72
+ }
73
+ child.parentNode = this;
74
+ child.nextSibling = null;
75
+ this.lastChild = child;
76
+ this.ownerDocument.markDirty(this);
77
+ if (child.hasSetProps) // Only add the node to the collection if we already received props for it.
78
+ // Otherwise wait until then so we have the correct id for the node.
79
+ this.ownerDocument.addNode(child);
80
+ this.ownerDocument.endTransaction();
81
+ this.ownerDocument.queueUpdate();
82
+ }
83
+ insertBefore(newNode, referenceNode) {
84
+ if (referenceNode == null) return this.appendChild(newNode);
85
+ this.ownerDocument.startTransaction();
86
+ if (newNode.parentNode) newNode.parentNode.removeChild(newNode);
87
+ newNode.nextSibling = referenceNode;
88
+ newNode.previousSibling = referenceNode.previousSibling;
89
+ newNode.index = referenceNode.index;
90
+ if (this.firstChild === referenceNode) this.firstChild = newNode;
91
+ else if (referenceNode.previousSibling) referenceNode.previousSibling.nextSibling = newNode;
92
+ referenceNode.previousSibling = newNode;
93
+ newNode.parentNode = referenceNode.parentNode;
94
+ let node = referenceNode;
95
+ while(node){
96
+ node.index++;
97
+ node = node.nextSibling;
98
+ }
99
+ if (newNode.hasSetProps) this.ownerDocument.addNode(newNode);
100
+ this.ownerDocument.endTransaction();
101
+ this.ownerDocument.queueUpdate();
102
+ }
103
+ removeChild(child) {
104
+ if (child.parentNode !== this || !this.ownerDocument.isMounted) return;
105
+ this.ownerDocument.startTransaction();
106
+ let node = child.nextSibling;
107
+ while(node){
108
+ node.index--;
109
+ node = node.nextSibling;
110
+ }
111
+ if (child.nextSibling) child.nextSibling.previousSibling = child.previousSibling;
112
+ if (child.previousSibling) child.previousSibling.nextSibling = child.nextSibling;
113
+ if (this.firstChild === child) this.firstChild = child.nextSibling;
114
+ if (this.lastChild === child) this.lastChild = child.previousSibling;
115
+ child.parentNode = null;
116
+ child.nextSibling = null;
117
+ child.previousSibling = null;
118
+ child.index = 0;
119
+ this.ownerDocument.removeNode(child);
120
+ this.ownerDocument.endTransaction();
121
+ this.ownerDocument.queueUpdate();
122
+ }
123
+ addEventListener() {}
124
+ removeEventListener() {}
125
+ constructor(ownerDocument){
126
+ this._firstChild = null;
127
+ this._lastChild = null;
128
+ this._previousSibling = null;
129
+ this._nextSibling = null;
130
+ this._parentNode = null;
131
+ this.ownerDocument = ownerDocument;
132
+ }
133
+ }
134
+ class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export$410b0c854570d131 {
135
+ get index() {
136
+ return this._index;
137
+ }
138
+ set index(index) {
139
+ this._index = index;
140
+ this.ownerDocument.markDirty(this);
141
+ }
142
+ get level() {
143
+ if (this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);
144
+ return 0;
145
+ }
146
+ updateNode() {
147
+ var _this_previousSibling, _this_nextSibling, _this_firstChild, _this_lastChild;
148
+ let node = this.ownerDocument.getMutableNode(this);
149
+ node.index = this.index;
150
+ node.level = this.level;
151
+ node.parentKey = this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd ? this.parentNode.node.key : null;
152
+ var _this_previousSibling_node_key;
153
+ node.prevKey = (_this_previousSibling_node_key = (_this_previousSibling = this.previousSibling) === null || _this_previousSibling === void 0 ? void 0 : _this_previousSibling.node.key) !== null && _this_previousSibling_node_key !== void 0 ? _this_previousSibling_node_key : null;
154
+ var _this_nextSibling_node_key;
155
+ node.nextKey = (_this_nextSibling_node_key = (_this_nextSibling = this.nextSibling) === null || _this_nextSibling === void 0 ? void 0 : _this_nextSibling.node.key) !== null && _this_nextSibling_node_key !== void 0 ? _this_nextSibling_node_key : null;
156
+ node.hasChildNodes = !!this.firstChild;
157
+ var _this_firstChild_node_key;
158
+ node.firstChildKey = (_this_firstChild_node_key = (_this_firstChild = this.firstChild) === null || _this_firstChild === void 0 ? void 0 : _this_firstChild.node.key) !== null && _this_firstChild_node_key !== void 0 ? _this_firstChild_node_key : null;
159
+ var _this_lastChild_node_key;
160
+ node.lastChildKey = (_this_lastChild_node_key = (_this_lastChild = this.lastChild) === null || _this_lastChild === void 0 ? void 0 : _this_lastChild.node.key) !== null && _this_lastChild_node_key !== void 0 ? _this_lastChild_node_key : null;
161
+ }
162
+ setProps(obj, ref, rendered, render) {
163
+ let node = this.ownerDocument.getMutableNode(this);
164
+ let { value: value, textValue: textValue, id: id, ...props } = obj;
165
+ props.ref = ref;
166
+ node.props = props;
167
+ node.rendered = rendered;
168
+ node.render = render;
169
+ node.value = value;
170
+ node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';
171
+ if (id != null && id !== node.key) {
172
+ if (this.hasSetProps) throw new Error('Cannot change the id of an item');
173
+ node.key = id;
174
+ }
175
+ // If this is the first time props have been set, end the transaction started in the constructor
176
+ // so this node can be emitted.
177
+ if (!this.hasSetProps) {
178
+ this.ownerDocument.addNode(this);
179
+ this.ownerDocument.endTransaction();
180
+ this.hasSetProps = true;
181
+ }
182
+ this.ownerDocument.queueUpdate();
183
+ }
184
+ get style() {
185
+ return {};
186
+ }
187
+ hasAttribute() {}
188
+ setAttribute() {}
189
+ setAttributeNS() {}
190
+ removeAttribute() {}
191
+ constructor(type, ownerDocument){
192
+ super(ownerDocument);
193
+ this.nodeType = 8 // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)
194
+ ;
195
+ this._index = 0;
196
+ this.hasSetProps = false;
197
+ this.node = new (0, $23b9f4fcf0fe224b$export$f5d856d854e74713)(type, `react-aria-${++ownerDocument.nodeId}`);
198
+ // Start a transaction so that no updates are emitted from the collection
199
+ // until the props for this node are set. We don't know the real id for the
200
+ // node until then, so we need to avoid emitting collections in an inconsistent state.
201
+ this.ownerDocument.startTransaction();
202
+ }
203
+ }
204
+ class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export$410b0c854570d131 {
205
+ get isConnected() {
206
+ return this.isMounted;
207
+ }
208
+ createElement(type) {
209
+ return new $681cc3c98f569e39$export$dc064fe9e59310fd(type, this);
210
+ }
211
+ /**
212
+ * Lazily gets a mutable instance of a Node. If the node has already
213
+ * been cloned during this update cycle, it just returns the existing one.
214
+ */ getMutableNode(element) {
215
+ let node = element.node;
216
+ if (!this.mutatedNodes.has(element)) {
217
+ node = element.node.clone();
218
+ this.mutatedNodes.add(element);
219
+ element.node = node;
220
+ }
221
+ this.markDirty(element);
222
+ return node;
223
+ }
224
+ getMutableCollection() {
225
+ if (!this.isSSR && !this.collectionMutated) {
226
+ this.collection = this.collection.clone();
227
+ this.collectionMutated = true;
228
+ }
229
+ return this.collection;
230
+ }
231
+ markDirty(node) {
232
+ this.dirtyNodes.add(node);
233
+ }
234
+ startTransaction() {
235
+ this.transactionCount++;
236
+ }
237
+ endTransaction() {
238
+ this.transactionCount--;
239
+ }
240
+ addNode(element) {
241
+ let collection = this.getMutableCollection();
242
+ if (!collection.getItem(element.node.key)) {
243
+ collection.addNode(element.node);
244
+ for (let child of element)this.addNode(child);
245
+ }
246
+ this.markDirty(element);
247
+ }
248
+ removeNode(node) {
249
+ for (let child of node)this.removeNode(child);
250
+ let collection = this.getMutableCollection();
251
+ collection.removeNode(node.node.key);
252
+ this.markDirty(node);
253
+ }
254
+ /** Finalizes the collection update, updating all nodes and freezing the collection. */ getCollection() {
255
+ if (this.transactionCount > 0) return this.collection;
256
+ this.updateCollection();
257
+ return this.collection;
258
+ }
259
+ updateCollection() {
260
+ for (let element of this.dirtyNodes)if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd && element.isConnected) element.updateNode();
261
+ this.dirtyNodes.clear();
262
+ if (this.mutatedNodes.size || this.collectionMutated) {
263
+ var _this_firstChild, _this_lastChild;
264
+ let collection = this.getMutableCollection();
265
+ for (let element of this.mutatedNodes)if (element.isConnected) collection.addNode(element.node);
266
+ var _this_firstChild_node_key, _this_lastChild_node_key;
267
+ collection.commit((_this_firstChild_node_key = (_this_firstChild = this.firstChild) === null || _this_firstChild === void 0 ? void 0 : _this_firstChild.node.key) !== null && _this_firstChild_node_key !== void 0 ? _this_firstChild_node_key : null, (_this_lastChild_node_key = (_this_lastChild = this.lastChild) === null || _this_lastChild === void 0 ? void 0 : _this_lastChild.node.key) !== null && _this_lastChild_node_key !== void 0 ? _this_lastChild_node_key : null, this.isSSR);
268
+ this.mutatedNodes.clear();
269
+ }
270
+ this.collectionMutated = false;
271
+ }
272
+ queueUpdate() {
273
+ // Don't emit any updates if there is a transaction in progress.
274
+ // queueUpdate should be called again after the transaction.
275
+ if (this.dirtyNodes.size === 0 || this.transactionCount > 0) return;
276
+ for (let fn of this.subscriptions)fn();
277
+ }
278
+ subscribe(fn) {
279
+ this.subscriptions.add(fn);
280
+ return ()=>this.subscriptions.delete(fn);
281
+ }
282
+ resetAfterSSR() {
283
+ if (this.isSSR) {
284
+ this.isSSR = false;
285
+ this.firstChild = null;
286
+ this.lastChild = null;
287
+ this.nodeId = 0;
288
+ }
289
+ }
290
+ constructor(collection){
291
+ // @ts-ignore
292
+ super(null);
293
+ this.nodeType = 11 // DOCUMENT_FRAGMENT_NODE
294
+ ;
295
+ this.ownerDocument = this;
296
+ this.dirtyNodes = new Set();
297
+ this.isSSR = false;
298
+ this.nodeId = 0;
299
+ this.nodesByProps = new WeakMap();
300
+ this.isMounted = true;
301
+ this.mutatedNodes = new Set();
302
+ this.subscriptions = new Set();
303
+ this.transactionCount = 0;
304
+ this.collection = collection;
305
+ this.collectionMutated = true;
306
+ }
307
+ }
308
+
309
+
310
+ export {$681cc3c98f569e39$export$410b0c854570d131 as BaseNode, $681cc3c98f569e39$export$dc064fe9e59310fd as ElementNode, $681cc3c98f569e39$export$b34a105447964f9f as Document};
311
+ //# sourceMappingURL=Document.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAwBM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,IAAI,CAAC,UAAU,GAAG;YAClB,IAAI,CAAC,SAAS,GAAG;YACjB,IAAI,CAAC,MAAM,GAAG;QAChB;IACF;IApIA,YAAY,UAAa,CAAE;QACzB,aAAa;QACb,KAAK,CAAC;aAfR,WAAW,GAAI,yBAAyB;;aACxC,gBAAgB,IAAI;aACpB,aAA+B,IAAI;aACnC,QAAQ;aACR,SAAS;aACT,eAAe,IAAI;aACnB,YAAY;aAGJ,eAAoC,IAAI;aACxC,gBAAiC,IAAI;aACrC,mBAAmB;QAKzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,iBAAiB,GAAG;IAC3B;AAgIF","sources":["packages/@react-aria/collections/src/Document.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\nimport {BaseCollection, Mutable, NodeValue} from './BaseCollection';\nimport {ForwardedRef, ReactElement} from 'react';\nimport {Node} from '@react-types/shared';\n\n// This Collection implementation is perhaps a little unusual. It works by rendering the React tree into a\n// Portal to a fake DOM implementation. This gives us efficient access to the tree of rendered objects, and\n// supports React features like composition and context. We use this fake DOM to access the full set of elements\n// before we render into the real DOM, which allows us to render a subset of the elements (e.g. virtualized scrolling),\n// and compute properties like the total number of items. It also enables keyboard navigation, selection, and other features.\n// React takes care of efficiently rendering components and updating the collection for us via this fake DOM.\n//\n// The DOM is a mutable API, and React expects the node instances to remain stable over time. So the implementation is split\n// into two parts. Each mutable fake DOM node owns an instance of an immutable collection node. When a fake DOM node is updated,\n// it queues a second render for the collection. Multiple updates to a collection can be queued at once. Collection nodes are\n// lazily copied on write, so only the changed nodes need to be cloned. During the second render, the new immutable collection\n// is finalized by updating the map of Key -> Node with the new cloned nodes. Then the new collection is frozen so it can no\n// longer be mutated, and returned to the calling component to render.\n\n/**\n * A mutable node in the fake DOM tree. When mutated, it marks itself as dirty\n * and queues an update with the owner document.\n */\nexport class BaseNode<T> {\n private _firstChild: ElementNode<T> | null = null;\n private _lastChild: ElementNode<T> | null = null;\n private _previousSibling: ElementNode<T> | null = null;\n private _nextSibling: ElementNode<T> | null = null;\n private _parentNode: BaseNode<T> | null = null;\n ownerDocument: Document<T, any>;\n\n constructor(ownerDocument: Document<T, any>) {\n this.ownerDocument = ownerDocument;\n }\n\n *[Symbol.iterator]() {\n let node = this.firstChild;\n while (node) {\n yield node;\n node = node.nextSibling;\n }\n }\n\n get firstChild() {\n return this._firstChild;\n }\n\n set firstChild(firstChild) {\n this._firstChild = firstChild;\n this.ownerDocument.markDirty(this);\n }\n\n get lastChild() {\n return this._lastChild;\n }\n\n set lastChild(lastChild) {\n this._lastChild = lastChild;\n this.ownerDocument.markDirty(this);\n }\n\n get previousSibling() {\n return this._previousSibling;\n }\n\n set previousSibling(previousSibling) {\n this._previousSibling = previousSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get nextSibling() {\n return this._nextSibling;\n }\n\n set nextSibling(nextSibling) {\n this._nextSibling = nextSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get parentNode() {\n return this._parentNode;\n }\n\n set parentNode(parentNode) {\n this._parentNode = parentNode;\n this.ownerDocument.markDirty(this);\n }\n\n get isConnected() {\n return this.parentNode?.isConnected || false;\n }\n\n appendChild(child: ElementNode<T>) {\n this.ownerDocument.startTransaction();\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n\n if (this.firstChild == null) {\n this.firstChild = child;\n }\n\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.index = this.lastChild.index + 1;\n child.previousSibling = this.lastChild;\n } else {\n child.previousSibling = null;\n child.index = 0;\n }\n\n child.parentNode = this;\n child.nextSibling = null;\n this.lastChild = child;\n\n this.ownerDocument.markDirty(this);\n if (child.hasSetProps) {\n // Only add the node to the collection if we already received props for it.\n // Otherwise wait until then so we have the correct id for the node.\n this.ownerDocument.addNode(child);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>) {\n if (referenceNode == null) {\n return this.appendChild(newNode);\n }\n\n this.ownerDocument.startTransaction();\n if (newNode.parentNode) {\n newNode.parentNode.removeChild(newNode);\n }\n\n newNode.nextSibling = referenceNode;\n newNode.previousSibling = referenceNode.previousSibling;\n newNode.index = referenceNode.index;\n\n if (this.firstChild === referenceNode) {\n this.firstChild = newNode;\n } else if (referenceNode.previousSibling) {\n referenceNode.previousSibling.nextSibling = newNode;\n }\n\n referenceNode.previousSibling = newNode;\n newNode.parentNode = referenceNode.parentNode;\n\n let node: ElementNode<T> | null = referenceNode;\n while (node) {\n node.index++;\n node = node.nextSibling;\n }\n\n if (newNode.hasSetProps) {\n this.ownerDocument.addNode(newNode);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n removeChild(child: ElementNode<T>) {\n if (child.parentNode !== this || !this.ownerDocument.isMounted) {\n return;\n }\n\n this.ownerDocument.startTransaction();\n let node = child.nextSibling;\n while (node) {\n node.index--;\n node = node.nextSibling;\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling;\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n }\n\n if (this.firstChild === child) {\n this.firstChild = child.nextSibling;\n }\n\n if (this.lastChild === child) {\n this.lastChild = child.previousSibling;\n }\n\n child.parentNode = null;\n child.nextSibling = null;\n child.previousSibling = null;\n child.index = 0;\n\n this.ownerDocument.removeNode(child);\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n addEventListener() {}\n removeEventListener() {}\n}\n\n/**\n * A mutable element node in the fake DOM tree. It owns an immutable\n * Collection Node which is copied on write.\n */\nexport class ElementNode<T> extends BaseNode<T> {\n nodeType = 8; // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)\n node: NodeValue<T>;\n private _index: number = 0;\n hasSetProps = false;\n\n constructor(type: string, ownerDocument: Document<T, any>) {\n super(ownerDocument);\n this.node = new NodeValue(type, `react-aria-${++ownerDocument.nodeId}`);\n // Start a transaction so that no updates are emitted from the collection\n // until the props for this node are set. We don't know the real id for the\n // node until then, so we need to avoid emitting collections in an inconsistent state.\n this.ownerDocument.startTransaction();\n }\n\n get index() {\n return this._index;\n }\n\n set index(index) {\n this._index = index;\n this.ownerDocument.markDirty(this);\n }\n\n get level(): number {\n if (this.parentNode instanceof ElementNode) {\n return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);\n }\n\n return 0;\n }\n\n updateNode() {\n let node = this.ownerDocument.getMutableNode(this);\n node.index = this.index;\n node.level = this.level;\n node.parentKey = this.parentNode instanceof ElementNode ? this.parentNode.node.key : null;\n node.prevKey = this.previousSibling?.node.key ?? null;\n node.nextKey = this.nextSibling?.node.key ?? null;\n node.hasChildNodes = !!this.firstChild;\n node.firstChildKey = this.firstChild?.node.key ?? null;\n node.lastChildKey = this.lastChild?.node.key ?? null;\n }\n\n setProps<E extends Element>(obj: any, ref: ForwardedRef<E>, rendered?: any, render?: (node: Node<T>) => ReactElement) {\n let node = this.ownerDocument.getMutableNode(this);\n let {value, textValue, id, ...props} = obj;\n props.ref = ref;\n node.props = props;\n node.rendered = rendered;\n node.render = render;\n node.value = value;\n node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';\n if (id != null && id !== node.key) {\n if (this.hasSetProps) {\n throw new Error('Cannot change the id of an item');\n }\n node.key = id;\n }\n\n // If this is the first time props have been set, end the transaction started in the constructor\n // so this node can be emitted.\n if (!this.hasSetProps) {\n this.ownerDocument.addNode(this);\n this.ownerDocument.endTransaction();\n this.hasSetProps = true;\n }\n\n this.ownerDocument.queueUpdate();\n }\n\n get style() {\n return {};\n }\n\n hasAttribute() {}\n setAttribute() {}\n setAttributeNS() {}\n removeAttribute() {}\n}\n\n/**\n * A mutable Document in the fake DOM. It owns an immutable Collection instance,\n * which is lazily copied on write during updates.\n */\nexport class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extends BaseNode<T> {\n nodeType = 11; // DOCUMENT_FRAGMENT_NODE\n ownerDocument = this;\n dirtyNodes: Set<BaseNode<T>> = new Set();\n isSSR = false;\n nodeId = 0;\n nodesByProps = new WeakMap<object, ElementNode<T>>();\n isMounted = true;\n private collection: C;\n private collectionMutated: boolean;\n private mutatedNodes: Set<ElementNode<T>> = new Set();\n private subscriptions: Set<() => void> = new Set();\n private transactionCount = 0;\n\n constructor(collection: C) {\n // @ts-ignore\n super(null);\n this.collection = collection;\n this.collectionMutated = true;\n }\n\n get isConnected() {\n return this.isMounted;\n }\n\n createElement(type: string) {\n return new ElementNode(type, this);\n }\n\n /**\n * Lazily gets a mutable instance of a Node. If the node has already\n * been cloned during this update cycle, it just returns the existing one.\n */\n getMutableNode(element: ElementNode<T>): Mutable<NodeValue<T>> {\n let node = element.node;\n if (!this.mutatedNodes.has(element)) {\n node = element.node.clone();\n this.mutatedNodes.add(element);\n element.node = node;\n }\n this.markDirty(element);\n return node;\n }\n\n private getMutableCollection() {\n if (!this.isSSR && !this.collectionMutated) {\n this.collection = this.collection.clone();\n this.collectionMutated = true;\n }\n\n return this.collection;\n }\n\n markDirty(node: BaseNode<T>) {\n this.dirtyNodes.add(node);\n }\n\n startTransaction() {\n this.transactionCount++;\n }\n\n endTransaction() {\n this.transactionCount--;\n }\n\n addNode(element: ElementNode<T>) {\n let collection = this.getMutableCollection();\n if (!collection.getItem(element.node.key)) {\n collection.addNode(element.node);\n\n for (let child of element) {\n this.addNode(child);\n }\n }\n\n this.markDirty(element);\n }\n\n removeNode(node: ElementNode<T>) {\n for (let child of node) {\n this.removeNode(child);\n }\n\n let collection = this.getMutableCollection();\n collection.removeNode(node.node.key);\n this.markDirty(node);\n }\n\n /** Finalizes the collection update, updating all nodes and freezing the collection. */\n getCollection(): C {\n if (this.transactionCount > 0) {\n return this.collection;\n }\n\n this.updateCollection();\n return this.collection;\n }\n\n updateCollection() {\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode && element.isConnected) {\n element.updateNode();\n }\n }\n\n this.dirtyNodes.clear();\n\n if (this.mutatedNodes.size || this.collectionMutated) {\n let collection = this.getMutableCollection();\n for (let element of this.mutatedNodes) {\n if (element.isConnected) {\n collection.addNode(element.node);\n }\n }\n\n collection.commit(this.firstChild?.node.key ?? null, this.lastChild?.node.key ?? null, this.isSSR);\n this.mutatedNodes.clear();\n }\n\n this.collectionMutated = false;\n }\n\n queueUpdate() {\n // Don't emit any updates if there is a transaction in progress.\n // queueUpdate should be called again after the transaction.\n if (this.dirtyNodes.size === 0 || this.transactionCount > 0) {\n return;\n }\n\n for (let fn of this.subscriptions) {\n fn();\n }\n }\n\n subscribe(fn: () => void) {\n this.subscriptions.add(fn);\n return () => this.subscriptions.delete(fn);\n }\n\n resetAfterSSR() {\n if (this.isSSR) {\n this.isSSR = false;\n this.firstChild = null;\n this.lastChild = null;\n this.nodeId = 0;\n }\n }\n}\n"],"names":[],"version":3,"file":"Document.module.js.map"}