@react-aria/collections 3.0.0-nightly.5042 → 3.0.0-rc.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.
@@ -58,8 +58,21 @@ class $681cc3c98f569e39$export$410b0c854570d131 {
58
58
  var _this_parentNode;
59
59
  return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
60
60
  }
61
+ invalidateChildIndices(child) {
62
+ if (this._minInvalidChildIndex == null || !this._minInvalidChildIndex.isConnected || child.index < this._minInvalidChildIndex.index) {
63
+ this._minInvalidChildIndex = child;
64
+ this.ownerDocument.markDirty(this);
65
+ }
66
+ }
67
+ updateChildIndices() {
68
+ let node = this._minInvalidChildIndex;
69
+ while(node){
70
+ node.index = node.previousSibling ? node.previousSibling.index + 1 : 0;
71
+ node = node.nextSibling;
72
+ }
73
+ this._minInvalidChildIndex = null;
74
+ }
61
75
  appendChild(child) {
62
- this.ownerDocument.startTransaction();
63
76
  if (child.parentNode) child.parentNode.removeChild(child);
64
77
  if (this.firstChild == null) this.firstChild = child;
65
78
  if (this.lastChild) {
@@ -74,41 +87,32 @@ class $681cc3c98f569e39$export$410b0c854570d131 {
74
87
  child.nextSibling = null;
75
88
  this.lastChild = child;
76
89
  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();
90
+ if (this.isConnected) this.ownerDocument.queueUpdate();
82
91
  }
83
92
  insertBefore(newNode, referenceNode) {
84
93
  if (referenceNode == null) return this.appendChild(newNode);
85
- this.ownerDocument.startTransaction();
86
94
  if (newNode.parentNode) newNode.parentNode.removeChild(newNode);
87
95
  newNode.nextSibling = referenceNode;
88
96
  newNode.previousSibling = referenceNode.previousSibling;
89
- newNode.index = referenceNode.index;
97
+ // Ensure that the newNode's index is less than that of the reference node so that
98
+ // invalidateChildIndices will properly use the newNode as the _minInvalidChildIndex, thus making sure
99
+ // we will properly update the indexes of all sibiling nodes after the newNode. The value here doesn't matter
100
+ // since updateChildIndices should calculate the proper indexes.
101
+ newNode.index = referenceNode.index - 1;
90
102
  if (this.firstChild === referenceNode) this.firstChild = newNode;
91
103
  else if (referenceNode.previousSibling) referenceNode.previousSibling.nextSibling = newNode;
92
104
  referenceNode.previousSibling = newNode;
93
105
  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();
106
+ this.invalidateChildIndices(newNode);
107
+ if (this.isConnected) this.ownerDocument.queueUpdate();
102
108
  }
103
109
  removeChild(child) {
104
110
  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;
111
+ if (this._minInvalidChildIndex === child) this._minInvalidChildIndex = null;
112
+ if (child.nextSibling) {
113
+ this.invalidateChildIndices(child.nextSibling);
114
+ child.nextSibling.previousSibling = child.previousSibling;
110
115
  }
111
- if (child.nextSibling) child.nextSibling.previousSibling = child.previousSibling;
112
116
  if (child.previousSibling) child.previousSibling.nextSibling = child.nextSibling;
113
117
  if (this.firstChild === child) this.firstChild = child.nextSibling;
114
118
  if (this.lastChild === child) this.lastChild = child.previousSibling;
@@ -116,18 +120,38 @@ class $681cc3c98f569e39$export$410b0c854570d131 {
116
120
  child.nextSibling = null;
117
121
  child.previousSibling = null;
118
122
  child.index = 0;
119
- this.ownerDocument.removeNode(child);
120
- this.ownerDocument.endTransaction();
121
- this.ownerDocument.queueUpdate();
123
+ this.ownerDocument.markDirty(child);
124
+ if (this.isConnected) this.ownerDocument.queueUpdate();
122
125
  }
123
126
  addEventListener() {}
124
127
  removeEventListener() {}
128
+ get previousVisibleSibling() {
129
+ let node = this.previousSibling;
130
+ while(node && node.isHidden)node = node.previousSibling;
131
+ return node;
132
+ }
133
+ get nextVisibleSibling() {
134
+ let node = this.nextSibling;
135
+ while(node && node.isHidden)node = node.nextSibling;
136
+ return node;
137
+ }
138
+ get firstVisibleChild() {
139
+ let node = this.firstChild;
140
+ while(node && node.isHidden)node = node.nextSibling;
141
+ return node;
142
+ }
143
+ get lastVisibleChild() {
144
+ let node = this.lastChild;
145
+ while(node && node.isHidden)node = node.previousSibling;
146
+ return node;
147
+ }
125
148
  constructor(ownerDocument){
126
149
  this._firstChild = null;
127
150
  this._lastChild = null;
128
151
  this._previousSibling = null;
129
152
  this._nextSibling = null;
130
153
  this._parentNode = null;
154
+ this._minInvalidChildIndex = null;
131
155
  this.ownerDocument = ownerDocument;
132
156
  }
133
157
  }
@@ -143,62 +167,97 @@ class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export
143
167
  if (this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);
144
168
  return 0;
145
169
  }
170
+ /**
171
+ * Lazily gets a mutable instance of a Node. If the node has already
172
+ * been cloned during this update cycle, it just returns the existing one.
173
+ */ getMutableNode() {
174
+ if (!this.isMutated) {
175
+ this.node = this.node.clone();
176
+ this.isMutated = true;
177
+ }
178
+ this.ownerDocument.markDirty(this);
179
+ return this.node;
180
+ }
146
181
  updateNode() {
147
- var _this_previousSibling, _this_nextSibling, _this_firstChild, _this_lastChild;
148
- let node = this.ownerDocument.getMutableNode(this);
182
+ var _this_previousVisibleSibling, _this_firstVisibleChild, _this_lastVisibleChild;
183
+ let nextSibling = this.nextVisibleSibling;
184
+ let node = this.getMutableNode();
149
185
  node.index = this.index;
150
186
  node.level = this.level;
151
187
  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;
188
+ var _this_previousVisibleSibling_node_key;
189
+ node.prevKey = (_this_previousVisibleSibling_node_key = (_this_previousVisibleSibling = this.previousVisibleSibling) === null || _this_previousVisibleSibling === void 0 ? void 0 : _this_previousVisibleSibling.node.key) !== null && _this_previousVisibleSibling_node_key !== void 0 ? _this_previousVisibleSibling_node_key : null;
190
+ var _nextSibling_node_key;
191
+ node.nextKey = (_nextSibling_node_key = nextSibling === null || nextSibling === void 0 ? void 0 : nextSibling.node.key) !== null && _nextSibling_node_key !== void 0 ? _nextSibling_node_key : null;
156
192
  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;
193
+ var _this_firstVisibleChild_node_key;
194
+ node.firstChildKey = (_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : _this_firstVisibleChild.node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null;
195
+ var _this_lastVisibleChild_node_key;
196
+ node.lastChildKey = (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : _this_lastVisibleChild.node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null;
197
+ // Update the colIndex of sibling nodes if this node has a colSpan.
198
+ if ((node.colSpan != null || node.colIndex != null) && nextSibling) {
199
+ var _node_colIndex, _node_colSpan;
200
+ // This queues the next sibling for update, which means this happens recursively.
201
+ let nextColIndex = ((_node_colIndex = node.colIndex) !== null && _node_colIndex !== void 0 ? _node_colIndex : node.index) + ((_node_colSpan = node.colSpan) !== null && _node_colSpan !== void 0 ? _node_colSpan : 1);
202
+ if (nextColIndex !== nextSibling.node.colIndex) {
203
+ let siblingNode = nextSibling.getMutableNode();
204
+ siblingNode.colIndex = nextColIndex;
205
+ }
206
+ }
161
207
  }
162
208
  setProps(obj, ref, rendered, render) {
163
- let node = this.ownerDocument.getMutableNode(this);
164
- let { value: value, textValue: textValue, id: id, ...props } = obj;
209
+ let node = this.getMutableNode();
210
+ let { value: value1, textValue: textValue, id: id, ...props } = obj;
165
211
  props.ref = ref;
166
212
  node.props = props;
167
213
  node.rendered = rendered;
168
214
  node.render = render;
169
- node.value = value;
215
+ node.value = value1;
170
216
  node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';
171
217
  if (id != null && id !== node.key) {
172
218
  if (this.hasSetProps) throw new Error('Cannot change the id of an item');
173
219
  node.key = id;
174
220
  }
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();
221
+ if (props.colSpan != null) node.colSpan = props.colSpan;
222
+ this.hasSetProps = true;
223
+ if (this.isConnected) this.ownerDocument.queueUpdate();
183
224
  }
184
225
  get style() {
185
- return {};
226
+ // React sets display: none to hide elements during Suspense.
227
+ // We'll handle this by setting the element to hidden and invalidating
228
+ // its siblings/parent. Hidden elements remain in the Document, but
229
+ // are removed from the Collection.
230
+ let element = this;
231
+ return {
232
+ get display () {
233
+ return element.isHidden ? 'none' : '';
234
+ },
235
+ set display (value){
236
+ let isHidden = value === 'none';
237
+ if (element.isHidden !== isHidden) {
238
+ var _element_parentNode, _element_parentNode1;
239
+ // Mark parent node dirty if this element is currently the first or last visible child.
240
+ if (((_element_parentNode = element.parentNode) === null || _element_parentNode === void 0 ? void 0 : _element_parentNode.firstVisibleChild) === element || ((_element_parentNode1 = element.parentNode) === null || _element_parentNode1 === void 0 ? void 0 : _element_parentNode1.lastVisibleChild) === element) element.ownerDocument.markDirty(element.parentNode);
241
+ // Mark sibling visible elements dirty.
242
+ let prev = element.previousVisibleSibling;
243
+ let next = element.nextVisibleSibling;
244
+ if (prev) element.ownerDocument.markDirty(prev);
245
+ if (next) element.ownerDocument.markDirty(next);
246
+ // Mark self dirty.
247
+ element.isHidden = isHidden;
248
+ element.ownerDocument.markDirty(element);
249
+ }
250
+ }
251
+ };
186
252
  }
187
253
  hasAttribute() {}
188
254
  setAttribute() {}
189
255
  setAttributeNS() {}
190
256
  removeAttribute() {}
191
257
  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;
258
+ super(ownerDocument), this.nodeType = 8 // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)
259
+ , this.isMutated = true, this._index = 0, this.hasSetProps = false, this.isHidden = false;
197
260
  this.node = new (0, $23b9f4fcf0fe224b$export$d68d59712b04d9d1)(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
261
  }
203
262
  }
204
263
  class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export$410b0c854570d131 {
@@ -208,72 +267,70 @@ class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export
208
267
  createElement(type) {
209
268
  return new $681cc3c98f569e39$export$dc064fe9e59310fd(type, this);
210
269
  }
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
270
  getMutableCollection() {
225
- if (!this.isSSR && !this.collectionMutated) {
226
- this.collection = this.collection.clone();
227
- this.collectionMutated = true;
228
- }
229
- return this.collection;
271
+ if (!this.nextCollection) this.nextCollection = this.collection.clone();
272
+ return this.nextCollection;
230
273
  }
231
274
  markDirty(node) {
232
275
  this.dirtyNodes.add(node);
233
276
  }
234
- startTransaction() {
235
- this.transactionCount++;
236
- }
237
- endTransaction() {
238
- this.transactionCount--;
239
- }
240
277
  addNode(element) {
278
+ if (element.isHidden) return;
241
279
  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);
280
+ if (!collection.getItem(element.node.key)) for (let child of element)this.addNode(child);
281
+ collection.addNode(element.node);
247
282
  }
248
283
  removeNode(node) {
249
284
  for (let child of node)this.removeNode(child);
250
285
  let collection = this.getMutableCollection();
251
286
  collection.removeNode(node.node.key);
252
- this.markDirty(node);
253
287
  }
254
288
  /** Finalizes the collection update, updating all nodes and freezing the collection. */ getCollection() {
255
- if (this.transactionCount > 0) return this.collection;
289
+ // If in a subscription update, return a clone of the existing collection.
290
+ // This ensures React will queue a render. React will call getCollection again
291
+ // during render, at which point all the updates will be complete and we can return
292
+ // the new collection.
293
+ if (this.inSubscription) return this.collection.clone();
294
+ // Reset queuedRender to false when getCollection is called during render.
295
+ this.queuedRender = false;
256
296
  this.updateCollection();
257
297
  return this.collection;
258
298
  }
259
299
  updateCollection() {
260
- for (let element of this.dirtyNodes)if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd && element.isConnected) element.updateNode();
300
+ // First, remove disconnected nodes and update the indices of dirty element children.
301
+ for (let element of this.dirtyNodes)if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd && (!element.isConnected || element.isHidden)) this.removeNode(element);
302
+ else element.updateChildIndices();
303
+ // Next, update dirty collection nodes.
304
+ for (let element of this.dirtyNodes)if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) {
305
+ if (element.isConnected && !element.isHidden) {
306
+ element.updateNode();
307
+ this.addNode(element);
308
+ }
309
+ element.isMutated = false;
310
+ }
261
311
  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();
312
+ // Finally, update the collection.
313
+ if (this.nextCollection) {
314
+ var _this_firstVisibleChild, _this_lastVisibleChild;
315
+ var _this_firstVisibleChild_node_key, _this_lastVisibleChild_node_key;
316
+ this.nextCollection.commit((_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : _this_firstVisibleChild.node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null, (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : _this_lastVisibleChild.node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null, this.isSSR);
317
+ if (!this.isSSR) {
318
+ this.collection = this.nextCollection;
319
+ this.nextCollection = null;
320
+ }
269
321
  }
270
- this.collectionMutated = false;
271
322
  }
272
323
  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;
324
+ if (this.dirtyNodes.size === 0 || this.queuedRender) return;
325
+ // Only trigger subscriptions once during an update, when the first item changes.
326
+ // React's useSyncExternalStore will call getCollection immediately, to check whether the snapshot changed.
327
+ // If so, React will queue a render to happen after the current commit to our fake DOM finishes.
328
+ // We track whether getCollection is called in a subscription, and once it is called during render,
329
+ // we reset queuedRender back to false.
330
+ this.queuedRender = true;
331
+ this.inSubscription = true;
276
332
  for (let fn of this.subscriptions)fn();
333
+ this.inSubscription = false;
277
334
  }
278
335
  subscribe(fn) {
279
336
  this.subscriptions.add(fn);
@@ -289,20 +346,10 @@ class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export
289
346
  }
290
347
  constructor(collection){
291
348
  // @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;
349
+ super(null), this.nodeType = 11 // DOCUMENT_FRAGMENT_NODE
350
+ , this.ownerDocument = this, this.dirtyNodes = new Set(), this.isSSR = false, this.nodeId = 0, this.nodesByProps = new WeakMap(), this.isMounted = true, this.nextCollection = null, this.subscriptions = new Set(), this.queuedRender = false, this.inSubscription = false;
304
351
  this.collection = collection;
305
- this.collectionMutated = true;
352
+ this.nextCollection = collection;
306
353
  }
307
354
  }
308
355
 
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAYX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,IAAI,OAAO,IAAI,CAAC,UAAU;QAC1B,MAAO,KAAM;YACX,MAAM;YACN,OAAO,KAAK,WAAW;QACzB;IACF;IAEA,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,IAAI,WAAW,UAAU,EAAE;QACzB,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,UAAU;IACxB;IAEA,IAAI,UAAU,SAAS,EAAE;QACvB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,gBAAgB;IAC9B;IAEA,IAAI,gBAAgB,eAAe,EAAE;QACnC,IAAI,CAAC,gBAAgB,GAAG;QACxB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,YAAY;IAC1B;IAEA,IAAI,YAAY,WAAW,EAAE;QAC3B,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,IAAI,WAAW,UAAU,EAAE;QACzB,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAA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I,CAAC,aAAa,CAC/B;IAEJ;IAEA,UAAU,EAAc,EAAE;QACxB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACvB,OAAO,IAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IACzC;IAEA,gBAAgB;QACd,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,GAAG;YACb,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, CollectionNode, Mutable} 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: CollectionNode<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 CollectionNode(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<CollectionNode<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"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAaX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAA6B;QAC7C,IAAI,OAAO,IAAI,CAAC,UAAU;QAC1B,MAAO,KAAM;YACX,MAAM;YACN,OAAO,KAAK,WAAW;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AAM,IAAI,CAAC,KAAK;YACxH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACf,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,cAAc;gBACrC,IAAI,CAAC,cAAc,GAAG;YACxB;QACF;IACF;IAEA,cAAoB;QAClB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,YAAY,EACjD;QAGF,iFAAiF;QACjF,2GAA2G;QAC3G,gGAAgG;QAChG,mGAAmG;QACnG,uCAAuC;QACvC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,cAAc,GAAG;QACtB,KAAK,IAAI,MAAM,IAAI,CAAC,aAAa,CAC/B;QAEF,IAAI,CAAC,cAAc,GAAG;IACxB;IAEA,UAAU,EAAc,EAAE;QACxB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACvB,OAAO,IAAe,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClD;IAEA,gBAAsB;QACpB,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,GAAG;YACb,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,YAfR,WAAW,GAAI,yBAAyB;eACxC,gBAAgB,IAAI,OACpB,aAA+B,IAAI,YACnC,QAAQ,YACR,SAAS,QACT,eAAe,IAAI,gBACnB,YAAY,WAEJ,iBAA2B,WAC3B,gBAAiC,IAAI,YACrC,eAAe,YACf,iBAAiB;QAKvB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,cAAc,GAAG;IACxB;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, CollectionNode, Mutable} from './BaseCollection';\nimport {CSSProperties, ForwardedRef, ReactElement, ReactNode} 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 private _minInvalidChildIndex: ElementNode<T> | null = null;\n ownerDocument: Document<T, any>;\n\n constructor(ownerDocument: Document<T, any>) {\n this.ownerDocument = ownerDocument;\n }\n\n *[Symbol.iterator](): Iterator<ElementNode<T>> {\n let node = this.firstChild;\n while (node) {\n yield node;\n node = node.nextSibling;\n }\n }\n\n get firstChild(): ElementNode<T> | null {\n return this._firstChild;\n }\n\n set firstChild(firstChild: ElementNode<T> | null) {\n this._firstChild = firstChild;\n this.ownerDocument.markDirty(this);\n }\n\n get lastChild(): ElementNode<T> | null {\n return this._lastChild;\n }\n\n set lastChild(lastChild: ElementNode<T> | null) {\n this._lastChild = lastChild;\n this.ownerDocument.markDirty(this);\n }\n\n get previousSibling(): ElementNode<T> | null {\n return this._previousSibling;\n }\n\n set previousSibling(previousSibling: ElementNode<T> | null) {\n this._previousSibling = previousSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get nextSibling(): ElementNode<T> | null {\n return this._nextSibling;\n }\n\n set nextSibling(nextSibling: ElementNode<T> | null) {\n this._nextSibling = nextSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get parentNode(): BaseNode<T> | null {\n return this._parentNode;\n }\n\n set parentNode(parentNode: BaseNode<T> | null) {\n this._parentNode = parentNode;\n this.ownerDocument.markDirty(this);\n }\n\n get isConnected(): boolean {\n return this.parentNode?.isConnected || false;\n }\n\n private invalidateChildIndices(child: ElementNode<T>): void {\n if (this._minInvalidChildIndex == null || !this._minInvalidChildIndex.isConnected || child.index < this._minInvalidChildIndex.index) {\n this._minInvalidChildIndex = child;\n this.ownerDocument.markDirty(this);\n }\n }\n\n updateChildIndices(): void {\n let node = this._minInvalidChildIndex;\n while (node) {\n node.index = node.previousSibling ? node.previousSibling.index + 1 : 0;\n node = node.nextSibling;\n }\n this._minInvalidChildIndex = null;\n }\n\n appendChild(child: ElementNode<T>): void {\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 (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>): void {\n if (referenceNode == null) {\n return this.appendChild(newNode);\n }\n\n if (newNode.parentNode) {\n newNode.parentNode.removeChild(newNode);\n }\n\n newNode.nextSibling = referenceNode;\n newNode.previousSibling = referenceNode.previousSibling;\n // Ensure that the newNode's index is less than that of the reference node so that\n // invalidateChildIndices will properly use the newNode as the _minInvalidChildIndex, thus making sure\n // we will properly update the indexes of all sibiling nodes after the newNode. The value here doesn't matter\n // since updateChildIndices should calculate the proper indexes.\n newNode.index = referenceNode.index - 1;\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 this.invalidateChildIndices(newNode);\n if (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n removeChild(child: ElementNode<T>): void {\n if (child.parentNode !== this || !this.ownerDocument.isMounted) {\n return;\n }\n\n if (this._minInvalidChildIndex === child) {\n this._minInvalidChildIndex = null;\n }\n\n if (child.nextSibling) {\n this.invalidateChildIndices(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.markDirty(child);\n if (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n addEventListener(): void {}\n removeEventListener(): void {}\n\n get previousVisibleSibling(): ElementNode<T> | null {\n let node = this.previousSibling;\n while (node && node.isHidden) {\n node = node.previousSibling;\n }\n return node;\n }\n\n get nextVisibleSibling(): ElementNode<T> | null {\n let node = this.nextSibling;\n while (node && node.isHidden) {\n node = node.nextSibling;\n }\n return node;\n }\n\n get firstVisibleChild(): ElementNode<T> | null {\n let node = this.firstChild;\n while (node && node.isHidden) {\n node = node.nextSibling;\n }\n return node;\n }\n\n get lastVisibleChild(): ElementNode<T> | null {\n let node = this.lastChild;\n while (node && node.isHidden) {\n node = node.previousSibling;\n }\n return node;\n }\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: CollectionNode<T>;\n isMutated = true;\n private _index: number = 0;\n hasSetProps = false;\n isHidden = false;\n\n constructor(type: string, ownerDocument: Document<T, any>) {\n super(ownerDocument);\n this.node = new CollectionNode(type, `react-aria-${++ownerDocument.nodeId}`);\n }\n\n get index(): number {\n return this._index;\n }\n\n set index(index: number) {\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 /**\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 private getMutableNode(): Mutable<CollectionNode<T>> {\n if (!this.isMutated) {\n this.node = this.node.clone();\n this.isMutated = true;\n }\n\n this.ownerDocument.markDirty(this);\n return this.node;\n }\n\n updateNode(): void {\n let nextSibling = this.nextVisibleSibling;\n let node = this.getMutableNode();\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.previousVisibleSibling?.node.key ?? null;\n node.nextKey = nextSibling?.node.key ?? null;\n node.hasChildNodes = !!this.firstChild;\n node.firstChildKey = this.firstVisibleChild?.node.key ?? null;\n node.lastChildKey = this.lastVisibleChild?.node.key ?? null;\n\n // Update the colIndex of sibling nodes if this node has a colSpan.\n if ((node.colSpan != null || node.colIndex != null) && nextSibling) {\n // This queues the next sibling for update, which means this happens recursively.\n let nextColIndex = (node.colIndex ?? node.index) + (node.colSpan ?? 1);\n if (nextColIndex !== nextSibling.node.colIndex) {\n let siblingNode = nextSibling.getMutableNode();\n siblingNode.colIndex = nextColIndex;\n }\n }\n }\n\n setProps<E extends Element>(obj: {[key: string]: any}, ref: ForwardedRef<E>, rendered?: ReactNode, render?: (node: Node<T>) => ReactElement): void {\n let node = this.getMutableNode();\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 (props.colSpan != null) {\n node.colSpan = props.colSpan;\n }\n\n this.hasSetProps = true;\n if (this.isConnected) {\n this.ownerDocument.queueUpdate();\n }\n }\n\n get style(): CSSProperties {\n // React sets display: none to hide elements during Suspense.\n // We'll handle this by setting the element to hidden and invalidating\n // its siblings/parent. Hidden elements remain in the Document, but\n // are removed from the Collection.\n let element = this;\n return {\n get display() {\n return element.isHidden ? 'none' : '';\n },\n set display(value) {\n let isHidden = value === 'none';\n if (element.isHidden !== isHidden) {\n // Mark parent node dirty if this element is currently the first or last visible child.\n if (element.parentNode?.firstVisibleChild === element || element.parentNode?.lastVisibleChild === element) {\n element.ownerDocument.markDirty(element.parentNode);\n }\n\n // Mark sibling visible elements dirty.\n let prev = element.previousVisibleSibling;\n let next = element.nextVisibleSibling;\n if (prev) {\n element.ownerDocument.markDirty(prev);\n }\n if (next) {\n element.ownerDocument.markDirty(next);\n }\n\n // Mark self dirty.\n element.isHidden = isHidden;\n element.ownerDocument.markDirty(element);\n }\n }\n };\n }\n\n hasAttribute(): void {}\n setAttribute(): void {}\n setAttributeNS(): void {}\n removeAttribute(): void {}\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 nextCollection: C | null = null;\n private subscriptions: Set<() => void> = new Set();\n private queuedRender = false;\n private inSubscription = false;\n\n constructor(collection: C) {\n // @ts-ignore\n super(null);\n this.collection = collection;\n this.nextCollection = collection;\n }\n\n get isConnected(): boolean {\n return this.isMounted;\n }\n\n createElement(type: string): ElementNode<T> {\n return new ElementNode(type, this);\n }\n\n private getMutableCollection() {\n if (!this.nextCollection) {\n this.nextCollection = this.collection.clone();\n }\n\n return this.nextCollection;\n }\n\n markDirty(node: BaseNode<T>): void {\n this.dirtyNodes.add(node);\n }\n\n private addNode(element: ElementNode<T>): void {\n if (element.isHidden) {\n return;\n }\n\n let collection = this.getMutableCollection();\n if (!collection.getItem(element.node.key)) {\n for (let child of element) {\n this.addNode(child);\n }\n }\n\n collection.addNode(element.node);\n }\n\n private removeNode(node: ElementNode<T>): void {\n for (let child of node) {\n this.removeNode(child);\n }\n\n let collection = this.getMutableCollection();\n collection.removeNode(node.node.key);\n }\n\n /** Finalizes the collection update, updating all nodes and freezing the collection. */\n getCollection(): C {\n // If in a subscription update, return a clone of the existing collection.\n // This ensures React will queue a render. React will call getCollection again\n // during render, at which point all the updates will be complete and we can return\n // the new collection.\n if (this.inSubscription) {\n return this.collection.clone();\n }\n\n // Reset queuedRender to false when getCollection is called during render.\n this.queuedRender = false;\n\n this.updateCollection();\n return this.collection;\n }\n\n updateCollection(): void {\n // First, remove disconnected nodes and update the indices of dirty element children.\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode && (!element.isConnected || element.isHidden)) {\n this.removeNode(element);\n } else {\n element.updateChildIndices();\n }\n }\n\n // Next, update dirty collection nodes.\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode) {\n if (element.isConnected && !element.isHidden) {\n element.updateNode();\n this.addNode(element);\n }\n\n element.isMutated = false;\n }\n }\n\n this.dirtyNodes.clear();\n\n // Finally, update the collection.\n if (this.nextCollection) {\n this.nextCollection.commit(this.firstVisibleChild?.node.key ?? null, this.lastVisibleChild?.node.key ?? null, this.isSSR);\n if (!this.isSSR) {\n this.collection = this.nextCollection;\n this.nextCollection = null;\n }\n }\n }\n\n queueUpdate(): void {\n if (this.dirtyNodes.size === 0 || this.queuedRender) {\n return;\n }\n\n // Only trigger subscriptions once during an update, when the first item changes.\n // React's useSyncExternalStore will call getCollection immediately, to check whether the snapshot changed.\n // If so, React will queue a render to happen after the current commit to our fake DOM finishes.\n // We track whether getCollection is called in a subscription, and once it is called during render,\n // we reset queuedRender back to false.\n this.queuedRender = true;\n this.inSubscription = true;\n for (let fn of this.subscriptions) {\n fn();\n }\n this.inSubscription = false;\n }\n\n subscribe(fn: () => void) {\n this.subscriptions.add(fn);\n return (): boolean => this.subscriptions.delete(fn);\n }\n\n resetAfterSSR(): void {\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"}
@@ -1,6 +1,4 @@
1
- var $a8uUY$reactdom = require("react-dom");
2
1
  var $a8uUY$react = require("react");
3
- var $a8uUY$reactariassr = require("@react-aria/ssr");
4
2
 
5
3
 
6
4
  function $parcel$interopDefault(a) {
@@ -25,8 +23,6 @@ $parcel$export(module.exports, "useIsHidden", () => $eaaf60978b89fc58$export$b5d
25
23
  * OF ANY KIND, either express or implied. See the License for the specific language
26
24
  * governing permissions and limitations under the License.
27
25
  */
28
-
29
-
30
26
  // React doesn't understand the <template> element, which doesn't have children like a normal element.
31
27
  // It will throw an error during hydration when it expects the firstChild to contain content rendered
32
28
  // on the server, when in reality, the browser will have placed this inside the `content` document fragment.
@@ -44,22 +40,19 @@ if (typeof HTMLTemplateElement !== 'undefined') {
44
40
  });
45
41
  }
46
42
  const $eaaf60978b89fc58$export$94b6d0abf7d33e8c = /*#__PURE__*/ (0, $a8uUY$react.createContext)(false);
47
- // Portal to nowhere
48
- const $eaaf60978b89fc58$var$hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;
49
43
  function $eaaf60978b89fc58$export$8dc98ba7eadeaa56(props) {
50
44
  let isHidden = (0, $a8uUY$react.useContext)($eaaf60978b89fc58$export$94b6d0abf7d33e8c);
51
- let isSSR = (0, $a8uUY$reactariassr.useIsSSR)();
52
45
  if (isHidden) // Don't hide again if we are already hidden.
53
46
  return /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement((0, ($parcel$interopDefault($a8uUY$react))).Fragment, null, props.children);
54
47
  let children = /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement($eaaf60978b89fc58$export$94b6d0abf7d33e8c.Provider, {
55
48
  value: true
56
49
  }, props.children);
57
- // In SSR, portals are not supported by React. Instead, render into a <template>
50
+ // In SSR, portals are not supported by React. Instead, always render into a <template>
58
51
  // element, which the browser will never display to the user. In addition, the
59
- // content is not part of the DOM tree, so it won't affect ids or other accessibility attributes.
60
- return isSSR ? /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement("template", {
52
+ // content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.
53
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($a8uUY$react))).createElement("template", {
61
54
  "data-react-aria-hidden": true
62
- }, children) : /*#__PURE__*/ (0, $a8uUY$reactdom.createPortal)(children, $eaaf60978b89fc58$var$hiddenFragment);
55
+ }, children);
63
56
  }
64
57
  function $eaaf60978b89fc58$export$86427a43e3e48ebb(fn) {
65
58
  let Wrapper = (props, ref)=>{
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAOD,sGAAsG;AACtG,qGAAqG;AACrG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esContent":["/*\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 {createPortal} from 'react-dom';\nimport {forwardRefType} from '@react-types/shared';\nimport React, {createContext, forwardRef, ReactElement, ReactNode, useContext} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\n// React doesn't understand the <template> element, which doesn't have children like a normal element.\n// It will throw an error during hydration when it expects the firstChild to contain content rendered\n// on the server, when in reality, the browser will have placed this inside the `content` document fragment.\n// This monkey patches the firstChild property for our special hidden template elements to work around this error.\n// See https://github.com/facebook/react/issues/19932\nif (typeof HTMLTemplateElement !== 'undefined') {\n const getFirstChild = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild')!.get!;\n Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {\n configurable: true,\n enumerable: true,\n get: function () {\n if (this.dataset.reactAriaHidden) {\n return this.content.firstChild;\n } else {\n return getFirstChild.call(this);\n }\n }\n });\n}\n\nexport const HiddenContext = createContext<boolean>(false);\n\n// Portal to nowhere\nconst hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;\n\nexport function Hidden(props: {children: ReactNode}) {\n let isHidden = useContext(HiddenContext);\n let isSSR = useIsSSR();\n if (isHidden) {\n // Don't hide again if we are already hidden.\n return <>{props.children}</>;\n }\n\n let children = (\n <HiddenContext.Provider value>\n {props.children}\n </HiddenContext.Provider>\n );\n\n // In SSR, portals are not supported by React. Instead, render into a <template>\n // element, which the browser will never display to the user. In addition, the\n // content is not part of the DOM tree, so it won't affect ids or other accessibility attributes.\n return isSSR\n ? <template data-react-aria-hidden>{children}</template>\n : createPortal(children, hiddenFragment!);\n}\n\n/** Creates a component that forwards its ref and returns null if it is in a hidden subtree. */\n// Note: this function is handled specially in the documentation generator. If you change it, you'll need to update DocsTransformer as well.\nexport function createHideableComponent<T, P = {}>(fn: (props: P, ref: React.Ref<T>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null {\n let Wrapper = (props: P, ref: React.Ref<T>) => {\n let isHidden = useContext(HiddenContext);\n if (isHidden) {\n return null;\n }\n\n return fn(props, ref);\n };\n // @ts-ignore - for react dev tools\n Wrapper.displayName = fn.displayName || fn.name;\n return (forwardRef as forwardRefType)(Wrapper);\n}\n\n/** Returns whether the component is in a hidden subtree. */\nexport function useIsHidden(): boolean {\n return useContext(HiddenContext);\n}\n"],"names":[],"version":3,"file":"Hidden.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAKD,sGAAsG;AACtG,qGAAqG;AACrG,4GAA4G;AAC5G,kHAAkH;AAClH,qDAAqD;AACrD,IAAI,OAAO,wBAAwB,aAAa;IAC9C,MAAM,gBAAgB,OAAO,wBAAwB,CAAC,KAAK,SAAS,EAAE,cAAe,GAAG;IACxF,OAAO,cAAc,CAAC,oBAAoB,SAAS,EAAE,cAAc;QACjE,cAAc;QACd,YAAY;QACZ,KAAK;YACH,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,EAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU;iBAE9B,OAAO,cAAc,IAAI,CAAC,IAAI;QAElC;IACF;AACF;AAEO,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAW;AAE7C,SAAS,0CAAO,KAA4B;IACjD,IAAI,WAAW,CAAA,GAAA,uBAAS,EAAE;IAC1B,IAAI,UACF,6CAA6C;IAC7C,qBAAO,sHAAG,MAAM,QAAQ;IAG1B,IAAI,yBACF,0DAAC,0CAAc,QAAQ;QAAC,OAAA;OACrB,MAAM,QAAQ;IAInB,uFAAuF;IACvF,8EAA8E;IAC9E,4GAA4G;IAC5G,qBAAO,0DAAC;QAAS,0BAAA;OAAwB;AAC3C;AAIO,SAAS,0CAAmC,EAAwD;IACzG,IAAI,UAAU,CAAC,OAAU;QACvB,IAAI,WAAW,CAAA,GAAA,uBAAS,EAAE;QAC1B,IAAI,UACF,OAAO;QAGT,OAAO,GAAG,OAAO;IACnB;IACA,mCAAmC;IACnC,QAAQ,WAAW,GAAG,GAAG,WAAW,IAAI,GAAG,IAAI;IAC/C,OAAO,AAAC,CAAA,GAAA,uBAAS,EAAqB;AACxC;AAGO,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB","sources":["packages/@react-aria/collections/src/Hidden.tsx"],"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 {forwardRefType} from '@react-types/shared';\nimport React, {createContext, forwardRef, JSX, ReactElement, ReactNode, useContext} from 'react';\n\n// React doesn't understand the <template> element, which doesn't have children like a normal element.\n// It will throw an error during hydration when it expects the firstChild to contain content rendered\n// on the server, when in reality, the browser will have placed this inside the `content` document fragment.\n// This monkey patches the firstChild property for our special hidden template elements to work around this error.\n// See https://github.com/facebook/react/issues/19932\nif (typeof HTMLTemplateElement !== 'undefined') {\n const getFirstChild = Object.getOwnPropertyDescriptor(Node.prototype, 'firstChild')!.get!;\n Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {\n configurable: true,\n enumerable: true,\n get: function () {\n if (this.dataset.reactAriaHidden) {\n return this.content.firstChild;\n } else {\n return getFirstChild.call(this);\n }\n }\n });\n}\n\nexport const HiddenContext = createContext<boolean>(false);\n\nexport function Hidden(props: {children: ReactNode}): JSX.Element {\n let isHidden = useContext(HiddenContext);\n if (isHidden) {\n // Don't hide again if we are already hidden.\n return <>{props.children}</>;\n }\n\n let children = (\n <HiddenContext.Provider value>\n {props.children}\n </HiddenContext.Provider>\n );\n\n // In SSR, portals are not supported by React. Instead, always render into a <template>\n // element, which the browser will never display to the user. In addition, the\n // content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.\n return <template data-react-aria-hidden>{children}</template>;\n}\n\n/** Creates a component that forwards its ref and returns null if it is in a hidden subtree. */\n// Note: this function is handled specially in the documentation generator. If you change it, you'll need to update DocsTransformer as well.\nexport function createHideableComponent<T, P = {}>(fn: (props: P, ref: React.Ref<T>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null {\n let Wrapper = (props: P, ref: React.Ref<T>) => {\n let isHidden = useContext(HiddenContext);\n if (isHidden) {\n return null;\n }\n\n return fn(props, ref);\n };\n // @ts-ignore - for react dev tools\n Wrapper.displayName = fn.displayName || fn.name;\n return (forwardRef as forwardRefType)(Wrapper);\n}\n\n/** Returns whether the component is in a hidden subtree. */\nexport function useIsHidden(): boolean {\n return useContext(HiddenContext);\n}\n"],"names":[],"version":3,"file":"Hidden.main.js.map"}
package/dist/Hidden.mjs CHANGED
@@ -1,6 +1,4 @@
1
- import {createPortal as $8SdCi$createPortal} from "react-dom";
2
1
  import $8SdCi$react, {createContext as $8SdCi$createContext, useContext as $8SdCi$useContext, forwardRef as $8SdCi$forwardRef} from "react";
3
- import {useIsSSR as $8SdCi$useIsSSR} from "@react-aria/ssr";
4
2
 
5
3
  /*
6
4
  * Copyright 2024 Adobe. All rights reserved.
@@ -13,8 +11,6 @@ import {useIsSSR as $8SdCi$useIsSSR} from "@react-aria/ssr";
13
11
  * OF ANY KIND, either express or implied. See the License for the specific language
14
12
  * governing permissions and limitations under the License.
15
13
  */
16
-
17
-
18
14
  // React doesn't understand the <template> element, which doesn't have children like a normal element.
19
15
  // It will throw an error during hydration when it expects the firstChild to contain content rendered
20
16
  // on the server, when in reality, the browser will have placed this inside the `content` document fragment.
@@ -32,22 +28,19 @@ if (typeof HTMLTemplateElement !== 'undefined') {
32
28
  });
33
29
  }
34
30
  const $f39a9eba43920ace$export$94b6d0abf7d33e8c = /*#__PURE__*/ (0, $8SdCi$createContext)(false);
35
- // Portal to nowhere
36
- const $f39a9eba43920ace$var$hiddenFragment = typeof DocumentFragment !== 'undefined' ? new DocumentFragment() : null;
37
31
  function $f39a9eba43920ace$export$8dc98ba7eadeaa56(props) {
38
32
  let isHidden = (0, $8SdCi$useContext)($f39a9eba43920ace$export$94b6d0abf7d33e8c);
39
- let isSSR = (0, $8SdCi$useIsSSR)();
40
33
  if (isHidden) // Don't hide again if we are already hidden.
41
34
  return /*#__PURE__*/ (0, $8SdCi$react).createElement((0, $8SdCi$react).Fragment, null, props.children);
42
35
  let children = /*#__PURE__*/ (0, $8SdCi$react).createElement($f39a9eba43920ace$export$94b6d0abf7d33e8c.Provider, {
43
36
  value: true
44
37
  }, props.children);
45
- // In SSR, portals are not supported by React. Instead, render into a <template>
38
+ // In SSR, portals are not supported by React. Instead, always render into a <template>
46
39
  // element, which the browser will never display to the user. In addition, the
47
- // content is not part of the DOM tree, so it won't affect ids or other accessibility attributes.
48
- return isSSR ? /*#__PURE__*/ (0, $8SdCi$react).createElement("template", {
40
+ // content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.
41
+ return /*#__PURE__*/ (0, $8SdCi$react).createElement("template", {
49
42
  "data-react-aria-hidden": true
50
- }, children) : /*#__PURE__*/ (0, $8SdCi$createPortal)(children, $f39a9eba43920ace$var$hiddenFragment);
43
+ }, children);
51
44
  }
52
45
  function $f39a9eba43920ace$export$86427a43e3e48ebb(fn) {
53
46
  let Wrapper = (props, ref)=>{