@react-aria/collections 3.0.0-rc.4 → 3.0.0-rc.6

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.
@@ -13,7 +13,7 @@
13
13
  throw new Error('childNodes is not supported');
14
14
  }
15
15
  clone() {
16
- let node = new $23b9f4fcf0fe224b$export$d68d59712b04d9d1(this.type, this.key);
16
+ let node = new this.constructor(this.key);
17
17
  node.value = this.value;
18
18
  node.level = this.level;
19
19
  node.hasChildNodes = this.hasChildNodes;
@@ -32,7 +32,13 @@
32
32
  node.colIndex = this.colIndex;
33
33
  return node;
34
34
  }
35
- constructor(type, key){
35
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
+ filter(collection, newCollection, filterFn) {
37
+ let clone = this.clone();
38
+ newCollection.addDescendants(clone, collection);
39
+ return clone;
40
+ }
41
+ constructor(key){
36
42
  this.value = null;
37
43
  this.level = 0;
38
44
  this.hasChildNodes = false;
@@ -48,10 +54,49 @@
48
54
  this.props = {};
49
55
  this.colSpan = null;
50
56
  this.colIndex = null;
51
- this.type = type;
57
+ this.type = this.constructor.type;
52
58
  this.key = key;
53
59
  }
54
60
  }
61
+ class $23b9f4fcf0fe224b$export$b1918e978f1ee46f extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
62
+ filter(collection, newCollection, filterFn) {
63
+ let [firstKey, lastKey] = $23b9f4fcf0fe224b$var$filterChildren(collection, newCollection, this.firstChildKey, filterFn);
64
+ let newNode = this.clone();
65
+ newNode.firstChildKey = firstKey;
66
+ newNode.lastChildKey = lastKey;
67
+ return newNode;
68
+ }
69
+ }
70
+ class $23b9f4fcf0fe224b$export$5ae2504e948afce5 extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
71
+ }
72
+ $23b9f4fcf0fe224b$export$5ae2504e948afce5.type = 'header';
73
+ class $23b9f4fcf0fe224b$export$8258a0665a675899 extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
74
+ }
75
+ $23b9f4fcf0fe224b$export$8258a0665a675899.type = 'loader';
76
+ class $23b9f4fcf0fe224b$export$fd11f34e1d07f134 extends $23b9f4fcf0fe224b$export$b1918e978f1ee46f {
77
+ filter(collection, newCollection, filterFn) {
78
+ if (filterFn(this.textValue, this)) {
79
+ let clone = this.clone();
80
+ newCollection.addDescendants(clone, collection);
81
+ return clone;
82
+ }
83
+ return null;
84
+ }
85
+ }
86
+ $23b9f4fcf0fe224b$export$fd11f34e1d07f134.type = 'item';
87
+ class $23b9f4fcf0fe224b$export$437f11dc9b403b78 extends $23b9f4fcf0fe224b$export$b1918e978f1ee46f {
88
+ filter(collection, newCollection, filterFn) {
89
+ let filteredSection = super.filter(collection, newCollection, filterFn);
90
+ if (filteredSection) {
91
+ if (filteredSection.lastChildKey !== null) {
92
+ let lastChild = collection.getItem(filteredSection.lastChildKey);
93
+ if (lastChild && lastChild.type !== 'header') return filteredSection;
94
+ }
95
+ }
96
+ return null;
97
+ }
98
+ }
99
+ $23b9f4fcf0fe224b$export$437f11dc9b403b78.type = 'section';
55
100
  class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
56
101
  get size() {
57
102
  return this.itemCount;
@@ -134,6 +179,12 @@ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
134
179
  if (node.type === 'item' && this.keyMap.get(node.key) == null) this.itemCount++;
135
180
  this.keyMap.set(node.key, node);
136
181
  }
182
+ // Deeply add a node and its children to the collection from another collection, primarily used when filtering a collection
183
+ addDescendants(node, oldCollection) {
184
+ this.addNode(node);
185
+ let children = oldCollection.getChildren(node.key);
186
+ for (let child of children)this.addDescendants(child, oldCollection);
187
+ }
137
188
  removeNode(key) {
138
189
  if (this.frozen) throw new Error('Cannot remove a node to a frozen collection');
139
190
  let node = this.keyMap.get(key);
@@ -146,89 +197,10 @@ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
146
197
  this.lastKey = lastKey;
147
198
  this.frozen = !isSSR;
148
199
  }
149
- // TODO: this is pretty specific to menu, will need to check if it is generic enough
150
- // Will need to handle varying levels I assume but will revisit after I get searchable menu working for base menu
151
- // TODO: an alternative is to simply walk the collection and add all item nodes that match the filter and any sections/separators we encounter
152
- // to an array, then walk that new array and fix all the next/Prev keys while adding them to the new collection
153
- UNSTABLE_filter(filterFn) {
154
- let newCollection = new $23b9f4fcf0fe224b$export$408d25a4e12db025();
155
- // This tracks the absolute last node we've visited in the collection when filtering, used for setting up the filteredCollection's lastKey and
156
- // for updating the next/prevKey for every non-filtered node.
157
- let lastNode = null;
158
- for (let node of this){
159
- if (node.type === 'section' && node.hasChildNodes) {
160
- let clonedSection = node.clone();
161
- let lastChildInSection = null;
162
- for (let child of this.getChildren(node.key))if ($23b9f4fcf0fe224b$var$shouldKeepNode(child, filterFn, this, newCollection)) {
163
- let clonedChild = child.clone();
164
- // eslint-disable-next-line max-depth
165
- if (lastChildInSection == null) clonedSection.firstChildKey = clonedChild.key;
166
- // eslint-disable-next-line max-depth
167
- if (newCollection.firstKey == null) newCollection.firstKey = clonedSection.key;
168
- // eslint-disable-next-line max-depth
169
- if (lastChildInSection && lastChildInSection.parentKey === clonedChild.parentKey) {
170
- lastChildInSection.nextKey = clonedChild.key;
171
- clonedChild.prevKey = lastChildInSection.key;
172
- } else clonedChild.prevKey = null;
173
- clonedChild.nextKey = null;
174
- newCollection.addNode(clonedChild);
175
- lastChildInSection = clonedChild;
176
- }
177
- // Add newly filtered section to collection if it has any valid child nodes, otherwise remove it and its header if any
178
- if (lastChildInSection) {
179
- if (lastChildInSection.type !== 'header') {
180
- clonedSection.lastChildKey = lastChildInSection.key;
181
- // If the old prev section was filtered out, will need to attach to whatever came before
182
- // eslint-disable-next-line max-depth
183
- if (lastNode == null) clonedSection.prevKey = null;
184
- else if (lastNode.type === 'section' || lastNode.type === 'separator') {
185
- lastNode.nextKey = clonedSection.key;
186
- clonedSection.prevKey = lastNode.key;
187
- }
188
- clonedSection.nextKey = null;
189
- lastNode = clonedSection;
190
- newCollection.addNode(clonedSection);
191
- } else {
192
- if (newCollection.firstKey === clonedSection.key) newCollection.firstKey = null;
193
- newCollection.removeNode(lastChildInSection.key);
194
- }
195
- }
196
- } else if (node.type === 'separator') {
197
- // will need to check if previous section key exists, if it does then we add the separator to the collection.
198
- // After the full collection is created we'll need to remove it it is the last node in the section (aka no following section after the separator)
199
- let clonedSeparator = node.clone();
200
- clonedSeparator.nextKey = null;
201
- if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'section') {
202
- lastNode.nextKey = clonedSeparator.key;
203
- clonedSeparator.prevKey = lastNode.key;
204
- lastNode = clonedSeparator;
205
- newCollection.addNode(clonedSeparator);
206
- }
207
- } else {
208
- // At this point, the node is either a subdialogtrigger node or a standard row/item
209
- let clonedNode = node.clone();
210
- if ($23b9f4fcf0fe224b$var$shouldKeepNode(clonedNode, filterFn, this, newCollection)) {
211
- if (newCollection.firstKey == null) newCollection.firstKey = clonedNode.key;
212
- if (lastNode != null && lastNode.type !== 'section' && lastNode.type !== 'separator' && lastNode.parentKey === clonedNode.parentKey) {
213
- lastNode.nextKey = clonedNode.key;
214
- clonedNode.prevKey = lastNode.key;
215
- } else clonedNode.prevKey = null;
216
- clonedNode.nextKey = null;
217
- newCollection.addNode(clonedNode);
218
- lastNode = clonedNode;
219
- }
220
- }
221
- }
222
- if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'separator' && lastNode.nextKey === null) {
223
- let lastSection;
224
- if (lastNode.prevKey != null) {
225
- lastSection = newCollection.getItem(lastNode.prevKey);
226
- lastSection.nextKey = null;
227
- }
228
- newCollection.removeNode(lastNode.key);
229
- lastNode = lastSection;
230
- }
231
- newCollection.lastKey = (lastNode === null || lastNode === void 0 ? void 0 : lastNode.key) || null;
200
+ filter(filterFn) {
201
+ let newCollection = new this.constructor();
202
+ let [firstKey, lastKey] = $23b9f4fcf0fe224b$var$filterChildren(this, newCollection, this.firstKey, filterFn);
203
+ newCollection === null || newCollection === void 0 ? void 0 : newCollection.commit(firstKey, lastKey);
232
204
  return newCollection;
233
205
  }
234
206
  constructor(){
@@ -239,22 +211,50 @@ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
239
211
  this.itemCount = 0;
240
212
  }
241
213
  }
242
- function $23b9f4fcf0fe224b$var$shouldKeepNode(node, filterFn, oldCollection, newCollection) {
243
- if (node.type === 'subdialogtrigger' || node.type === 'submenutrigger') {
244
- // Subdialog wrapper should only have one child, if it passes the filter add it to the new collection since we don't need to
245
- // do any extra handling for its first/next key
246
- let triggerChild = [
247
- ...oldCollection.getChildren(node.key)
248
- ][0];
249
- if (triggerChild && filterFn(triggerChild.textValue)) {
250
- let clonedChild = triggerChild.clone();
251
- newCollection.addNode(clonedChild);
252
- return true;
253
- } else return false;
254
- } else if (node.type === 'header') return true;
255
- else return filterFn(node.textValue);
214
+ function $23b9f4fcf0fe224b$var$filterChildren(collection, newCollection, firstChildKey, filterFn) {
215
+ // loop over the siblings for firstChildKey
216
+ // create new nodes based on calling node.filter for each child
217
+ // if it returns null then don't include it, otherwise update its prev/next keys
218
+ // add them to the newCollection
219
+ if (firstChildKey == null) return [
220
+ null,
221
+ null
222
+ ];
223
+ let firstNode = null;
224
+ let lastNode = null;
225
+ let currentNode = collection.getItem(firstChildKey);
226
+ while(currentNode != null){
227
+ let newNode = currentNode.filter(collection, newCollection, filterFn);
228
+ if (newNode != null) {
229
+ newNode.nextKey = null;
230
+ if (lastNode) {
231
+ newNode.prevKey = lastNode.key;
232
+ lastNode.nextKey = newNode.key;
233
+ }
234
+ if (firstNode == null) firstNode = newNode;
235
+ newCollection.addNode(newNode);
236
+ lastNode = newNode;
237
+ }
238
+ currentNode = currentNode.nextKey ? collection.getItem(currentNode.nextKey) : null;
239
+ }
240
+ // TODO: this is pretty specific to dividers but doesn't feel like there is a good way to get around it since we only can know
241
+ // to filter the last separator in a collection only after performing a filter for the rest of the contents after it
242
+ // Its gross that it needs to live here, might be nice if somehow we could have this live in the separator code
243
+ if (lastNode && lastNode.type === 'separator') {
244
+ let prevKey = lastNode.prevKey;
245
+ newCollection.removeNode(lastNode.key);
246
+ if (prevKey) {
247
+ lastNode = newCollection.getItem(prevKey);
248
+ lastNode.nextKey = null;
249
+ } else lastNode = null;
250
+ }
251
+ var _firstNode_key, _lastNode_key;
252
+ return [
253
+ (_firstNode_key = firstNode === null || firstNode === void 0 ? void 0 : firstNode.key) !== null && _firstNode_key !== void 0 ? _firstNode_key : null,
254
+ (_lastNode_key = lastNode === null || lastNode === void 0 ? void 0 : lastNode.key) !== null && _lastNode_key !== void 0 ? _lastNode_key : null
255
+ ];
256
256
  }
257
257
 
258
258
 
259
- export {$23b9f4fcf0fe224b$export$d68d59712b04d9d1 as CollectionNode, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection};
259
+ export {$23b9f4fcf0fe224b$export$d68d59712b04d9d1 as CollectionNode, $23b9f4fcf0fe224b$export$b1918e978f1ee46f as FilterableNode, $23b9f4fcf0fe224b$export$5ae2504e948afce5 as HeaderNode, $23b9f4fcf0fe224b$export$8258a0665a675899 as LoaderNode, $23b9f4fcf0fe224b$export$fd11f34e1d07f134 as ItemNode, $23b9f4fcf0fe224b$export$437f11dc9b403b78 as SectionNode, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection};
260
260
  //# sourceMappingURL=BaseCollection.module.js.map
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAUM,MAAM;IAyBX,IAAI,aAAgC;QAClC,MAAM,IAAI,MAAM;IAClB;IAEA,QAA2B;QACzB,IAAI,OAAmC,IAAI,0CAAe,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;QAC7E,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,aAAa,GAAG,IAAI,CAAC,aAAa;QACvC,KAAK,QAAQ,GAAG,IAAI,CAAC,QAAQ;QAC7B,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS;QAC/B,I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AAW,OAAO,GAAG;oBAGvB,WAAW,OAAO,GAAG;oBACrB,cAAc,OAAO,CAAC;oBACtB,WAAW;gBACb;YACF;QACF;QAEA,IAAI,CAAA,qBAAA,+BAAA,SAAU,IAAI,MAAK,eAAe,SAAS,OAAO,KAAK,MAAM;YAC/D,IAAI;YACJ,IAAI,SAAS,OAAO,IAAI,MAAM;gBAC5B,cAAc,cAAc,OAAO,CAAC,SAAS,OAAO;gBACpD,YAAY,OAAO,GAAG;YACxB;YACA,cAAc,UAAU,CAAC,SAAS,GAAG;YACrC,WAAW;QACb;QAEA,cAAc,OAAO,GAAG,CAAA,qBAAA,+BAAA,SAAU,GAAG,KAAI;QAEzC,OAAO;IACT;;aAnQQ,SAAsC,IAAI;aAC1C,WAAuB;aACvB,UAAsB;aACtB,SAAS;aACT,YAAoB;;AAgQ9B;AAEA,SAAS,qCAAkB,IAAa,EAAE,QAAwC,EAAE,aAAgC,EAAE,aAAgC;IACpJ,IAAI,KAAK,IAAI,KAAK,sBAAsB,KAAK,IAAI,KAAK,kBAAkB;QACtE,4HAA4H;QAC5H,+CAA+C;QAC/C,IAAI,eAAe;eAAI,cAAc,WAAW,CAAC,KAAK,GAAG;SAAE,CAAC,EAAE;QAC9D,IAAI,gBAAgB,SAAS,aAAa,SAAS,GAAG;YACpD,IAAI,cAA0C,AAAC,aAAmC,KAAK;YACvF,cAAc,OAAO,CAAC;YACtB,OAAO;QACT,OACE,OAAO;IAEX,OAAO,IAAI,KAAK,IAAI,KAAK,UACvB,OAAO;SAEP,OAAO,SAAS,KAAK,SAAS;AAElC","sources":["packages/@react-aria/collections/src/BaseCollection.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 {Collection as ICollection, Key, Node} from '@react-types/shared';\nimport {ReactElement, ReactNode} from 'react';\n\nexport type Mutable<T> = {\n -readonly[P in keyof T]: T[P]\n}\n\n/** An immutable object representing a Node in a Collection. */\nexport class CollectionNode<T> implements Node<T> {\n readonly type: string;\n readonly key: Key;\n readonly value: T | null = null;\n readonly level: number = 0;\n readonly hasChildNodes: boolean = false;\n readonly rendered: ReactNode = null;\n readonly textValue: string = '';\n readonly 'aria-label'?: string = undefined;\n readonly index: number = 0;\n readonly parentKey: Key | null = null;\n readonly prevKey: Key | null = null;\n readonly nextKey: Key | null = null;\n readonly firstChildKey: Key | null = null;\n readonly lastChildKey: Key | null = null;\n readonly props: any = {};\n readonly render?: (node: Node<any>) => ReactElement;\n readonly colSpan: number | null = null;\n readonly colIndex: number | null = null;\n\n constructor(type: string, key: Key) {\n this.type = type;\n this.key = key;\n }\n\n get childNodes(): Iterable<Node<T>> {\n throw new Error('childNodes is not supported');\n }\n\n clone(): CollectionNode<T> {\n let node: Mutable<CollectionNode<T>> = new CollectionNode(this.type, this.key);\n node.value = this.value;\n node.level = this.level;\n node.hasChildNodes = this.hasChildNodes;\n node.rendered = this.rendered;\n node.textValue = this.textValue;\n node['aria-label'] = this['aria-label'];\n node.index = this.index;\n node.parentKey = this.parentKey;\n node.prevKey = this.prevKey;\n node.nextKey = this.nextKey;\n node.firstChildKey = this.firstChildKey;\n node.lastChildKey = this.lastChildKey;\n node.props = this.props;\n node.render = this.render;\n node.colSpan = this.colSpan;\n node.colIndex = this.colIndex;\n return node;\n }\n}\n\n/**\n * An immutable Collection implementation. Updates are only allowed\n * when it is not marked as frozen. This can be subclassed to implement\n * custom collection behaviors.\n */\nexport class BaseCollection<T> implements ICollection<Node<T>> {\n private keyMap: Map<Key, CollectionNode<T>> = new Map();\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n private frozen = false;\n private itemCount: number = 0;\n\n get size(): number {\n return this.itemCount;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n *[Symbol.iterator](): IterableIterator<Node<T>> {\n let node: Node<T> | undefined = this.firstKey != null ? this.keyMap.get(this.firstKey) : undefined;\n while (node) {\n yield node;\n node = node.nextKey != null ? this.keyMap.get(node.nextKey) : undefined;\n }\n }\n\n getChildren(key: Key): Iterable<Node<T>> {\n let keyMap = this.keyMap;\n return {\n *[Symbol.iterator]() {\n let parent = keyMap.get(key);\n let node = parent?.firstChildKey != null ? keyMap.get(parent.firstChildKey) : null;\n while (node) {\n yield node as Node<T>;\n node = node.nextKey != null ? keyMap.get(node.nextKey) : undefined;\n }\n }\n };\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.prevKey != null) {\n node = this.keyMap.get(node.prevKey);\n\n while (node && node.type !== 'item' && node.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n return node.parentKey;\n }\n\n getKeyAfter(key: Key): Key | null {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.type !== 'item' && node.firstChildKey != null) {\n return node.firstChildKey;\n }\n\n while (node) {\n if (node.nextKey != null) {\n return node.nextKey;\n }\n\n if (node.parentKey != null) {\n node = this.keyMap.get(node.parentKey);\n } else {\n return null;\n }\n }\n\n return null;\n }\n\n getFirstKey(): Key | null {\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;\n while (node?.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(): Node<T> {\n throw new Error('Not implemented');\n }\n\n clone(): this {\n // We need to clone using this.constructor so that subclasses have the right prototype.\n // TypeScript isn't happy about this yet.\n // https://github.com/microsoft/TypeScript/issues/3841\n let Constructor: any = this.constructor;\n let collection: this = new Constructor();\n collection.keyMap = new Map(this.keyMap);\n collection.firstKey = this.firstKey;\n collection.lastKey = this.lastKey;\n collection.itemCount = this.itemCount;\n return collection;\n }\n\n addNode(node: CollectionNode<T>): void {\n if (this.frozen) {\n throw new Error('Cannot add a node to a frozen collection');\n }\n\n if (node.type === 'item' && this.keyMap.get(node.key) == null) {\n this.itemCount++;\n }\n\n this.keyMap.set(node.key, node);\n }\n\n removeNode(key: Key): void {\n if (this.frozen) {\n throw new Error('Cannot remove a node to a frozen collection');\n }\n\n let node = this.keyMap.get(key);\n if (node != null && node.type === 'item') {\n this.itemCount--;\n }\n\n this.keyMap.delete(key);\n }\n\n commit(firstKey: Key | null, lastKey: Key | null, isSSR = false): void {\n if (this.frozen) {\n throw new Error('Cannot commit a frozen collection');\n }\n\n this.firstKey = firstKey;\n this.lastKey = lastKey;\n this.frozen = !isSSR;\n }\n\n // TODO: this is pretty specific to menu, will need to check if it is generic enough\n // Will need to handle varying levels I assume but will revisit after I get searchable menu working for base menu\n // TODO: an alternative is to simply walk the collection and add all item nodes that match the filter and any sections/separators we encounter\n // to an array, then walk that new array and fix all the next/Prev keys while adding them to the new collection\n UNSTABLE_filter(filterFn: (nodeValue: string) => boolean): BaseCollection<T> {\n let newCollection = new BaseCollection<T>();\n // This tracks the absolute last node we've visited in the collection when filtering, used for setting up the filteredCollection's lastKey and\n // for updating the next/prevKey for every non-filtered node.\n let lastNode: Mutable<CollectionNode<T>> | null = null;\n\n for (let node of this) {\n if (node.type === 'section' && node.hasChildNodes) {\n let clonedSection: Mutable<CollectionNode<T>> = (node as CollectionNode<T>).clone();\n let lastChildInSection: Mutable<CollectionNode<T>> | null = null;\n for (let child of this.getChildren(node.key)) {\n if (shouldKeepNode(child, filterFn, this, newCollection)) {\n let clonedChild: Mutable<CollectionNode<T>> = (child as CollectionNode<T>).clone();\n // eslint-disable-next-line max-depth\n if (lastChildInSection == null) {\n clonedSection.firstChildKey = clonedChild.key;\n }\n\n // eslint-disable-next-line max-depth\n if (newCollection.firstKey == null) {\n newCollection.firstKey = clonedSection.key;\n }\n\n // eslint-disable-next-line max-depth\n if (lastChildInSection && lastChildInSection.parentKey === clonedChild.parentKey) {\n lastChildInSection.nextKey = clonedChild.key;\n clonedChild.prevKey = lastChildInSection.key;\n } else {\n clonedChild.prevKey = null;\n }\n\n clonedChild.nextKey = null;\n newCollection.addNode(clonedChild);\n lastChildInSection = clonedChild;\n }\n }\n\n // Add newly filtered section to collection if it has any valid child nodes, otherwise remove it and its header if any\n if (lastChildInSection) {\n if (lastChildInSection.type !== 'header') {\n clonedSection.lastChildKey = lastChildInSection.key;\n\n // If the old prev section was filtered out, will need to attach to whatever came before\n // eslint-disable-next-line max-depth\n if (lastNode == null) {\n clonedSection.prevKey = null;\n } else if (lastNode.type === 'section' || lastNode.type === 'separator') {\n lastNode.nextKey = clonedSection.key;\n clonedSection.prevKey = lastNode.key;\n }\n clonedSection.nextKey = null;\n lastNode = clonedSection;\n newCollection.addNode(clonedSection);\n } else {\n if (newCollection.firstKey === clonedSection.key) {\n newCollection.firstKey = null;\n }\n newCollection.removeNode(lastChildInSection.key);\n }\n }\n } else if (node.type === 'separator') {\n // will need to check if previous section key exists, if it does then we add the separator to the collection.\n // After the full collection is created we'll need to remove it it is the last node in the section (aka no following section after the separator)\n let clonedSeparator: Mutable<CollectionNode<T>> = (node as CollectionNode<T>).clone();\n clonedSeparator.nextKey = null;\n if (lastNode?.type === 'section') {\n lastNode.nextKey = clonedSeparator.key;\n clonedSeparator.prevKey = lastNode.key;\n lastNode = clonedSeparator;\n newCollection.addNode(clonedSeparator);\n }\n } else {\n // At this point, the node is either a subdialogtrigger node or a standard row/item\n let clonedNode: Mutable<CollectionNode<T>> = (node as CollectionNode<T>).clone();\n if (shouldKeepNode(clonedNode, filterFn, this, newCollection)) {\n if (newCollection.firstKey == null) {\n newCollection.firstKey = clonedNode.key;\n }\n\n if (lastNode != null && (lastNode.type !== 'section' && lastNode.type !== 'separator') && lastNode.parentKey === clonedNode.parentKey) {\n lastNode.nextKey = clonedNode.key;\n clonedNode.prevKey = lastNode.key;\n } else {\n clonedNode.prevKey = null;\n }\n\n clonedNode.nextKey = null;\n newCollection.addNode(clonedNode);\n lastNode = clonedNode;\n }\n }\n }\n\n if (lastNode?.type === 'separator' && lastNode.nextKey === null) {\n let lastSection;\n if (lastNode.prevKey != null) {\n lastSection = newCollection.getItem(lastNode.prevKey) as Mutable<CollectionNode<T>>;\n lastSection.nextKey = null;\n }\n newCollection.removeNode(lastNode.key);\n lastNode = lastSection;\n }\n\n newCollection.lastKey = lastNode?.key || null;\n\n return newCollection;\n }\n}\n\nfunction shouldKeepNode<T>(node: Node<T>, filterFn: (nodeValue: string) => boolean, oldCollection: BaseCollection<T>, newCollection: BaseCollection<T>): boolean {\n if (node.type === 'subdialogtrigger' || node.type === 'submenutrigger') {\n // Subdialog wrapper should only have one child, if it passes the filter add it to the new collection since we don't need to\n // do any extra handling for its first/next key\n let triggerChild = [...oldCollection.getChildren(node.key)][0];\n if (triggerChild && filterFn(triggerChild.textValue)) {\n let clonedChild: Mutable<CollectionNode<T>> = (triggerChild as CollectionNode<T>).clone();\n newCollection.addNode(clonedChild);\n return true;\n } else {\n return false;\n }\n } else if (node.type === 'header') {\n return true;\n } else {\n return filterFn(node.textValue);\n }\n}\n"],"names":[],"version":3,"file":"BaseCollection.module.js.map"}
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAYM,MAAM;IA0BX,IAAI,aAAgC;QAClC,MAAM,IAAI,MAAM;IAClB;IAEA,QAAc;QACZ,IAAI,OAAsB,IAAK,IAAI,CAAC,WAAW,CAAS,IAAI,CAAC,GAAG;QAChE,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,aAAa,GAAG,IAAI,CAAC,aAAa;QACvC,KAAK,QAAQ,GAAG,I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AAS,GAAG;gBAC9B,SAAS,OAAO,GAAG,QAAQ,GAAG;YAChC;YAEA,IAAI,aAAa,MACf,YAAY;YAGd,cAAc,OAAO,CAAC;YACtB,WAAW;QACb;QAEA,cAAc,YAAY,OAAO,GAAG,WAAW,OAAO,CAAC,YAAY,OAAO,IAAI;IAChF;IAEA,8HAA8H;IAC9H,oHAAoH;IACpH,+GAA+G;IAC/G,IAAI,YAAY,SAAS,IAAI,KAAK,aAAa;QAC7C,IAAI,UAAU,SAAS,OAAO;QAC9B,cAAc,UAAU,CAAC,SAAS,GAAG;QAErC,IAAI,SAAS;YACX,WAAW,cAAc,OAAO,CAAC;YACjC,SAAS,OAAO,GAAG;QACrB,OACE,WAAW;IAEf;QAEQ,gBAAwB;IAAhC,OAAO;QAAC,CAAA,iBAAA,sBAAA,gCAAA,UAAW,GAAG,cAAd,4BAAA,iBAAkB;QAAM,CAAA,gBAAA,qBAAA,+BAAA,SAAU,GAAG,cAAb,2BAAA,gBAAiB;KAAK;AACxD","sources":["packages/@react-aria/collections/src/BaseCollection.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 {Collection as ICollection, Key, Node} from '@react-types/shared';\nimport {ReactElement, ReactNode} from 'react';\n\nexport type Mutable<T> = {\n -readonly[P in keyof T]: T[P]\n}\n\ntype FilterFn<T> = (textValue: string, node: Node<T>) => boolean;\n\n/** An immutable object representing a Node in a Collection. */\nexport class CollectionNode<T> implements Node<T> {\n static readonly type: string;\n readonly type: string;\n readonly key: Key;\n readonly value: T | null = null;\n readonly level: number = 0;\n readonly hasChildNodes: boolean = false;\n readonly rendered: ReactNode = null;\n readonly textValue: string = '';\n readonly 'aria-label'?: string = undefined;\n readonly index: number = 0;\n readonly parentKey: Key | null = null;\n readonly prevKey: Key | null = null;\n readonly nextKey: Key | null = null;\n readonly firstChildKey: Key | null = null;\n readonly lastChildKey: Key | null = null;\n readonly props: any = {};\n readonly render?: (node: Node<any>) => ReactElement;\n readonly colSpan: number | null = null;\n readonly colIndex: number | null = null;\n\n constructor(key: Key) {\n this.type = (this.constructor as typeof CollectionNode).type;\n this.key = key;\n }\n\n get childNodes(): Iterable<Node<T>> {\n throw new Error('childNodes is not supported');\n }\n\n clone(): this {\n let node: Mutable<this> = new (this.constructor as any)(this.key);\n node.value = this.value;\n node.level = this.level;\n node.hasChildNodes = this.hasChildNodes;\n node.rendered = this.rendered;\n node.textValue = this.textValue;\n node['aria-label'] = this['aria-label'];\n node.index = this.index;\n node.parentKey = this.parentKey;\n node.prevKey = this.prevKey;\n node.nextKey = this.nextKey;\n node.firstChildKey = this.firstChildKey;\n node.lastChildKey = this.lastChildKey;\n node.props = this.props;\n node.render = this.render;\n node.colSpan = this.colSpan;\n node.colIndex = this.colIndex;\n return node;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): CollectionNode<T> | null {\n let clone = this.clone();\n newCollection.addDescendants(clone, collection);\n return clone;\n }\n}\n\nexport class FilterableNode<T> extends CollectionNode<T> {\n filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): CollectionNode<T> | null {\n let [firstKey, lastKey] = filterChildren(collection, newCollection, this.firstChildKey, filterFn);\n let newNode: Mutable<CollectionNode<T>> = this.clone();\n newNode.firstChildKey = firstKey;\n newNode.lastChildKey = lastKey;\n return newNode;\n }\n}\n\nexport class HeaderNode extends CollectionNode<unknown> {\n static readonly type = 'header';\n}\n\nexport class LoaderNode extends CollectionNode<unknown> {\n static readonly type = 'loader';\n}\n\nexport class ItemNode<T> extends FilterableNode<T> {\n static readonly type = 'item';\n\n filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): ItemNode<T> | null {\n if (filterFn(this.textValue, this)) {\n let clone = this.clone();\n newCollection.addDescendants(clone, collection);\n return clone;\n }\n\n return null;\n }\n}\n\nexport class SectionNode<T> extends FilterableNode<T> {\n static readonly type = 'section';\n\n filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: FilterFn<T>): SectionNode<T> | null {\n let filteredSection = super.filter(collection, newCollection, filterFn);\n if (filteredSection) {\n if (filteredSection.lastChildKey !== null) {\n let lastChild = collection.getItem(filteredSection.lastChildKey);\n if (lastChild && lastChild.type !== 'header') {\n return filteredSection;\n }\n }\n }\n\n return null;\n }\n}\n\n/**\n * An immutable Collection implementation. Updates are only allowed\n * when it is not marked as frozen. This can be subclassed to implement\n * custom collection behaviors.\n */\nexport class BaseCollection<T> implements ICollection<Node<T>> {\n private keyMap: Map<Key, CollectionNode<T>> = new Map();\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n private frozen = false;\n private itemCount: number = 0;\n\n get size(): number {\n return this.itemCount;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n *[Symbol.iterator](): IterableIterator<Node<T>> {\n let node: Node<T> | undefined = this.firstKey != null ? this.keyMap.get(this.firstKey) : undefined;\n while (node) {\n yield node;\n node = node.nextKey != null ? this.keyMap.get(node.nextKey) : undefined;\n }\n }\n\n getChildren(key: Key): Iterable<Node<T>> {\n let keyMap = this.keyMap;\n return {\n *[Symbol.iterator]() {\n let parent = keyMap.get(key);\n let node = parent?.firstChildKey != null ? keyMap.get(parent.firstChildKey) : null;\n while (node) {\n yield node as Node<T>;\n node = node.nextKey != null ? keyMap.get(node.nextKey) : undefined;\n }\n }\n };\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.prevKey != null) {\n node = this.keyMap.get(node.prevKey);\n\n while (node && node.type !== 'item' && node.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n return node.parentKey;\n }\n\n getKeyAfter(key: Key): Key | null {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.type !== 'item' && node.firstChildKey != null) {\n return node.firstChildKey;\n }\n\n while (node) {\n if (node.nextKey != null) {\n return node.nextKey;\n }\n\n if (node.parentKey != null) {\n node = this.keyMap.get(node.parentKey);\n } else {\n return null;\n }\n }\n\n return null;\n }\n\n getFirstKey(): Key | null {\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;\n while (node?.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(): Node<T> {\n throw new Error('Not implemented');\n }\n\n clone(): this {\n // We need to clone using this.constructor so that subclasses have the right prototype.\n // TypeScript isn't happy about this yet.\n // https://github.com/microsoft/TypeScript/issues/3841\n let Constructor: any = this.constructor;\n let collection: this = new Constructor();\n collection.keyMap = new Map(this.keyMap);\n collection.firstKey = this.firstKey;\n collection.lastKey = this.lastKey;\n collection.itemCount = this.itemCount;\n return collection;\n }\n\n addNode(node: CollectionNode<T>): void {\n if (this.frozen) {\n throw new Error('Cannot add a node to a frozen collection');\n }\n\n if (node.type === 'item' && this.keyMap.get(node.key) == null) {\n this.itemCount++;\n }\n\n this.keyMap.set(node.key, node);\n }\n\n // Deeply add a node and its children to the collection from another collection, primarily used when filtering a collection\n addDescendants(node: CollectionNode<T>, oldCollection: BaseCollection<T>): void {\n this.addNode(node);\n let children = oldCollection.getChildren(node.key);\n for (let child of children) {\n this.addDescendants(child as CollectionNode<T>, oldCollection);\n }\n }\n\n removeNode(key: Key): void {\n if (this.frozen) {\n throw new Error('Cannot remove a node to a frozen collection');\n }\n\n let node = this.keyMap.get(key);\n if (node != null && node.type === 'item') {\n this.itemCount--;\n }\n\n this.keyMap.delete(key);\n }\n\n commit(firstKey: Key | null, lastKey: Key | null, isSSR = false): void {\n if (this.frozen) {\n throw new Error('Cannot commit a frozen collection');\n }\n\n this.firstKey = firstKey;\n this.lastKey = lastKey;\n this.frozen = !isSSR;\n }\n\n filter(filterFn: FilterFn<T>): this {\n let newCollection = new (this.constructor as any)();\n let [firstKey, lastKey] = filterChildren(this, newCollection, this.firstKey, filterFn);\n newCollection?.commit(firstKey, lastKey);\n return newCollection;\n }\n}\n\nfunction filterChildren<T>(collection: BaseCollection<T>, newCollection: BaseCollection<T>, firstChildKey: Key | null, filterFn: FilterFn<T>): [Key | null, Key | null] {\n // loop over the siblings for firstChildKey\n // create new nodes based on calling node.filter for each child\n // if it returns null then don't include it, otherwise update its prev/next keys\n // add them to the newCollection\n if (firstChildKey == null) {\n return [null, null];\n }\n\n let firstNode: Node<T> | null = null;\n let lastNode: Node<T> | null = null;\n let currentNode = collection.getItem(firstChildKey);\n\n while (currentNode != null) {\n let newNode: Mutable<CollectionNode<T>> | null = (currentNode as CollectionNode<T>).filter(collection, newCollection, filterFn);\n if (newNode != null) {\n newNode.nextKey = null;\n if (lastNode) {\n newNode.prevKey = lastNode.key;\n lastNode.nextKey = newNode.key;\n }\n\n if (firstNode == null) {\n firstNode = newNode;\n }\n\n newCollection.addNode(newNode);\n lastNode = newNode;\n }\n\n currentNode = currentNode.nextKey ? collection.getItem(currentNode.nextKey) : null;\n }\n\n // TODO: this is pretty specific to dividers but doesn't feel like there is a good way to get around it since we only can know\n // to filter the last separator in a collection only after performing a filter for the rest of the contents after it\n // Its gross that it needs to live here, might be nice if somehow we could have this live in the separator code\n if (lastNode && lastNode.type === 'separator') {\n let prevKey = lastNode.prevKey;\n newCollection.removeNode(lastNode.key);\n\n if (prevKey) {\n lastNode = newCollection.getItem(prevKey) as Mutable<CollectionNode<T>>;\n lastNode.nextKey = null;\n } else {\n lastNode = null;\n }\n }\n\n return [firstNode?.key ?? null, lastNode?.key ?? null];\n}\n"],"names":[],"version":3,"file":"BaseCollection.module.js.map"}
@@ -127,27 +127,36 @@ function $f20386e2aa690b4a$var$useCollectionDocument(createCollection) {
127
127
  };
128
128
  }
129
129
  const $f20386e2aa690b4a$var$SSRContext = /*#__PURE__*/ (0, $4ftIM$react.createContext)(null);
130
- function $f20386e2aa690b4a$var$useSSRCollectionNode(Type, props, ref, rendered, children, render) {
130
+ function $f20386e2aa690b4a$var$createCollectionNodeClass(type) {
131
+ var _class;
132
+ let NodeClass = (_class = class extends (0, $499e2959ba1abacc$exports.CollectionNode) {
133
+ }, _class.type = type, _class);
134
+ return NodeClass;
135
+ }
136
+ function $f20386e2aa690b4a$var$useSSRCollectionNode(CollectionNodeClass, props, ref, rendered, children, render) {
137
+ // To prevent breaking change, if CollectionNodeClass is a string, create a CollectionNodeClass using the string as the type
138
+ if (typeof CollectionNodeClass === 'string') CollectionNodeClass = $f20386e2aa690b4a$var$createCollectionNodeClass(CollectionNodeClass);
131
139
  // During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.
132
140
  // Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.
133
141
  // Therefore we can create elements in our collection document during render so that they are in the
134
142
  // collection by the time we need to use the collection to render to the real DOM.
135
143
  // After hydration, we switch to client rendering using the portal.
136
144
  let itemRef = (0, $4ftIM$react.useCallback)((element)=>{
137
- element === null || element === void 0 ? void 0 : element.setProps(props, ref, rendered, render);
145
+ element === null || element === void 0 ? void 0 : element.setProps(props, ref, CollectionNodeClass, rendered, render);
138
146
  }, [
139
147
  props,
140
148
  ref,
141
149
  rendered,
142
- render
150
+ render,
151
+ CollectionNodeClass
143
152
  ]);
144
153
  let parentNode = (0, $4ftIM$react.useContext)($f20386e2aa690b4a$var$SSRContext);
145
154
  if (parentNode) {
146
155
  // Guard against double rendering in strict mode.
147
156
  let element = parentNode.ownerDocument.nodesByProps.get(props);
148
157
  if (!element) {
149
- element = parentNode.ownerDocument.createElement(Type);
150
- element.setProps(props, ref, rendered, render);
158
+ element = parentNode.ownerDocument.createElement(CollectionNodeClass.type);
159
+ element.setProps(props, ref, CollectionNodeClass, rendered, render);
151
160
  parentNode.appendChild(element);
152
161
  parentNode.ownerDocument.updateCollection();
153
162
  parentNode.ownerDocument.nodesByProps.set(props, element);
@@ -157,11 +166,11 @@ function $f20386e2aa690b4a$var$useSSRCollectionNode(Type, props, ref, rendered,
157
166
  }, children) : null;
158
167
  }
159
168
  // @ts-ignore
160
- return /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(Type, {
169
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(CollectionNodeClass.type, {
161
170
  ref: itemRef
162
171
  }, children);
163
172
  }
164
- function $f20386e2aa690b4a$export$18af5c7a9e9b3664(type, render) {
173
+ function $f20386e2aa690b4a$export$18af5c7a9e9b3664(CollectionNodeClass, render) {
165
174
  let Component = ({ node: node })=>render(node.props, node.props.ref, node);
166
175
  let Result = (0, $4ftIM$react.forwardRef)((props, ref)=>{
167
176
  let focusableProps = (0, $4ftIM$react.useContext)((0, $4ftIM$reactariainteractions.FocusableContext));
@@ -170,7 +179,7 @@ function $f20386e2aa690b4a$export$18af5c7a9e9b3664(type, render) {
170
179
  if (render.length >= 3) throw new Error(render.name + ' cannot be rendered outside a collection.');
171
180
  return render(props, ref);
172
181
  }
173
- return $f20386e2aa690b4a$var$useSSRCollectionNode(type, props, ref, 'children' in props ? props.children : null, null, (node)=>// Forward FocusableContext to real DOM tree so tooltips work.
182
+ return $f20386e2aa690b4a$var$useSSRCollectionNode(CollectionNodeClass, props, ref, 'children' in props ? props.children : null, null, (node)=>// Forward FocusableContext to real DOM tree so tooltips work.
174
183
  /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement((0, $4ftIM$reactariainteractions.FocusableContext).Provider, {
175
184
  value: focusableProps
176
185
  }, /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(Component, {
@@ -181,12 +190,12 @@ function $f20386e2aa690b4a$export$18af5c7a9e9b3664(type, render) {
181
190
  Result.displayName = render.name;
182
191
  return Result;
183
192
  }
184
- function $f20386e2aa690b4a$export$e953bb1cd0f19726(type, render, useChildren = $f20386e2aa690b4a$var$useCollectionChildren) {
193
+ function $f20386e2aa690b4a$export$e953bb1cd0f19726(CollectionNodeClass, render, useChildren = $f20386e2aa690b4a$var$useCollectionChildren) {
185
194
  let Component = ({ node: node })=>render(node.props, node.props.ref, node);
186
195
  let Result = (0, $4ftIM$react.forwardRef)((props, ref)=>{
187
196
  let children = useChildren(props);
188
197
  var _useSSRCollectionNode;
189
- return (_useSSRCollectionNode = $f20386e2aa690b4a$var$useSSRCollectionNode(type, props, ref, null, children, (node)=>/*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(Component, {
198
+ return (_useSSRCollectionNode = $f20386e2aa690b4a$var$useSSRCollectionNode(CollectionNodeClass, props, ref, null, children, (node)=>/*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement(Component, {
190
199
  node: node
191
200
  }))) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /*#__PURE__*/ (0, ($parcel$interopDefault($4ftIM$react))).createElement((0, ($parcel$interopDefault($4ftIM$react))).Fragment, null);
192
201
  });
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAcD,MAAM,2DAAuB,CAAA,GAAA,0BAAY,EAAE;AAC3C,MAAM,gEAA4B,CAAA,GAAA,0BAAY,EAA6C;AAWpF,SAAS,0CAAoD,KAAgC;IAClG,gGAAgG;IAChG,IAAI,MAAM,CAAA,GAAA,uBAAS,EAAE;IACrB,IAAI,KACF,gFAAgF;IAChF,4DAA4D;IAC5D,oFAAoF;IACpF,yDAAyD;IACzD,kEAAkE;IAClE,OAAO,MAAM,OA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":["/*\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} from './BaseCollection';\nimport {BaseNode, Document, ElementNode} from './Document';\nimport {CachedChildrenOptions, useCachedChildren} from './useCachedChildren';\nimport {createPortal} from 'react-dom';\nimport {FocusableContext} from '@react-aria/interactions';\nimport {forwardRefType, Node} from '@react-types/shared';\nimport {Hidden} from './Hidden';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactElement, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useSyncExternalStore as useSyncExternalStoreShim} from 'use-sync-external-store/shim/index.js';\n\nconst ShallowRenderContext = createContext(false);\nconst CollectionDocumentContext = createContext<Document<any, BaseCollection<any>> | null>(null);\n\nexport interface CollectionBuilderProps<C extends BaseCollection<object>> {\n content: ReactNode,\n children: (collection: C) => ReactNode,\n createCollection?: () => C\n}\n\n/**\n * Builds a `Collection` from the children provided to the `content` prop, and passes it to the child render prop function.\n */\nexport function CollectionBuilder<C extends BaseCollection<object>>(props: CollectionBuilderProps<C>): ReactElement {\n // If a document was provided above us, we're already in a hidden tree. Just render the content.\n let doc = useContext(CollectionDocumentContext);\n if (doc) {\n // The React types prior to 18 did not allow returning ReactNode from components\n // even though the actual implementation since React 16 did.\n // We must return ReactElement so that TS does not complain that <CollectionBuilder>\n // is not a valid JSX element with React 16 and 17 types.\n // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544\n return props.content as ReactElement;\n }\n\n // Otherwise, render a hidden copy of the children so that we can build the collection before constructing the state.\n // This should always come before the real DOM content so we have built the collection by the time it renders during SSR.\n\n // This is fine. CollectionDocumentContext never changes after mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n let {collection, document} = useCollectionDocument(props.createCollection);\n return (\n <>\n <Hidden>\n <CollectionDocumentContext.Provider value={document}>\n {props.content}\n </CollectionDocumentContext.Provider>\n </Hidden>\n <CollectionInner render={props.children} collection={collection} />\n </>\n );\n}\n\nfunction CollectionInner({collection, render}) {\n return render(collection);\n}\n\ninterface CollectionDocumentResult<T, C extends BaseCollection<T>> {\n collection: C,\n document: Document<T, C>\n}\n\n// React 16 and 17 don't support useSyncExternalStore natively, and the shim provided by React does not support getServerSnapshot.\n// This wrapper uses the shim, but additionally calls getServerSnapshot during SSR (according to SSRProvider).\nfunction useSyncExternalStoreFallback<C>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => C, getServerSnapshot: () => C): C {\n let isSSR = useIsSSR();\n let isSSRRef = useRef(isSSR);\n // This is read immediately inside the wrapper, which also runs during render.\n // We just need a ref to avoid invalidating the callback itself, which\n // would cause React to re-run the callback more than necessary.\n // eslint-disable-next-line rulesdir/pure-render\n isSSRRef.current = isSSR;\n\n let getSnapshotWrapper = useCallback(() => {\n return isSSRRef.current ? getServerSnapshot() : getSnapshot();\n }, [getSnapshot, getServerSnapshot]);\n return useSyncExternalStoreShim(subscribe, getSnapshotWrapper);\n}\n\nconst useSyncExternalStore = typeof React['useSyncExternalStore'] === 'function'\n ? React['useSyncExternalStore']\n : useSyncExternalStoreFallback;\n\nfunction useCollectionDocument<T extends object, C extends BaseCollection<T>>(createCollection?: () => C): CollectionDocumentResult<T, C> {\n // The document instance is mutable, and should never change between renders.\n // useSyncExternalStore is used to subscribe to updates, which vends immutable Collection objects.\n let [document] = useState(() => new Document<T, C>(createCollection?.() || new BaseCollection() as C));\n let subscribe = useCallback((fn: () => void) => document.subscribe(fn), [document]);\n let getSnapshot = useCallback(() => {\n let collection = document.getCollection();\n if (document.isSSR) {\n // After SSR is complete, reset the document to empty so it is ready for React to render the portal into.\n // We do this _after_ getting the collection above so that the collection still has content in it from SSR\n // during the current render, before React has finished the client render.\n document.resetAfterSSR();\n }\n return collection;\n }, [document]);\n let getServerSnapshot = useCallback(() => {\n document.isSSR = true;\n return document.getCollection();\n }, [document]);\n let collection = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n useLayoutEffect(() => {\n document.isMounted = true;\n return () => {\n // Mark unmounted so we can skip all of the collection updates caused by\n // React calling removeChild on every item in the collection.\n document.isMounted = false;\n };\n }, [document]);\n return {collection, document};\n}\n\nconst SSRContext = createContext<BaseNode<any> | null>(null);\n\nfunction useSSRCollectionNode<T extends Element>(Type: string, props: object, ref: ForwardedRef<T>, rendered?: any, children?: ReactNode, render?: (node: Node<T>) => ReactElement) {\n // During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.\n // Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.\n // Therefore we can create elements in our collection document during render so that they are in the\n // collection by the time we need to use the collection to render to the real DOM.\n // After hydration, we switch to client rendering using the portal.\n let itemRef = useCallback((element: ElementNode<any> | null) => {\n element?.setProps(props, ref, rendered, render);\n }, [props, ref, rendered, render]);\n let parentNode = useContext(SSRContext);\n if (parentNode) {\n // Guard against double rendering in strict mode.\n let element = parentNode.ownerDocument.nodesByProps.get(props);\n if (!element) {\n element = parentNode.ownerDocument.createElement(Type);\n element.setProps(props, ref, rendered, render);\n parentNode.appendChild(element);\n parentNode.ownerDocument.updateCollection();\n parentNode.ownerDocument.nodesByProps.set(props, element);\n }\n\n return children\n ? <SSRContext.Provider value={element}>{children}</SSRContext.Provider>\n : null;\n }\n\n // @ts-ignore\n return <Type ref={itemRef}>{children}</Type>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>) => ReactElement | null): (props: P & React.RefAttributes<E>) => ReactElement | null;\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null): (props: P & React.RefAttributes<E>) => ReactElement | null;\nexport function createLeafComponent<P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>, node?: any) => ReactElement | null): (props: P & React.RefAttributes<any>) => ReactElement | null {\n let Component = ({node}) => render(node.props, node.props.ref, node);\n let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {\n let focusableProps = useContext(FocusableContext);\n let isShallow = useContext(ShallowRenderContext);\n if (!isShallow) {\n if (render.length >= 3) {\n throw new Error(render.name + ' cannot be rendered outside a collection.');\n }\n return render(props, ref);\n }\n\n return useSSRCollectionNode(\n type,\n props,\n ref,\n 'children' in props ? props.children : null,\n null,\n node => (\n // Forward FocusableContext to real DOM tree so tooltips work.\n <FocusableContext.Provider value={focusableProps}>\n <Component node={node} />\n </FocusableContext.Provider>\n )\n );\n });\n // @ts-ignore\n Result.displayName = render.name;\n return Result;\n}\n\nexport function createBranchComponent<T extends object, P extends {children?: any}, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null, useChildren: (props: P) => ReactNode = useCollectionChildren): (props: P & React.RefAttributes<E>) => ReactElement | null {\n let Component = ({node}) => render(node.props, node.props.ref, node);\n let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {\n let children = useChildren(props);\n return useSSRCollectionNode(type, props, ref, null, children, node => <Component node={node} />) ?? <></>;\n });\n // @ts-ignore\n Result.displayName = render.name;\n return Result;\n}\n\nfunction useCollectionChildren<T extends object>(options: CachedChildrenOptions<T>) {\n return useCachedChildren({...options, addIdAndValue: true});\n}\n\nexport interface CollectionProps<T> extends CachedChildrenOptions<T> {}\n\nconst CollectionContext = createContext<CachedChildrenOptions<unknown> | null>(null);\n\n/** A Collection renders a list of items, automatically managing caching and keys. */\nexport function Collection<T extends object>(props: CollectionProps<T>): JSX.Element {\n let ctx = useContext(CollectionContext)!;\n let dependencies = (ctx?.dependencies || []).concat(props.dependencies);\n let idScope = props.idScope || ctx?.idScope;\n let children = useCollectionChildren({\n ...props,\n idScope,\n dependencies\n });\n\n let doc = useContext(CollectionDocumentContext);\n if (doc) {\n children = <CollectionRoot>{children}</CollectionRoot>;\n }\n\n // Propagate dependencies and idScope to child collections.\n ctx = useMemo(() => ({\n dependencies,\n idScope\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [idScope, ...dependencies]);\n\n return (\n <CollectionContext.Provider value={ctx}>\n {children}\n </CollectionContext.Provider>\n );\n}\n\nfunction CollectionRoot({children}) {\n let doc = useContext(CollectionDocumentContext);\n let wrappedChildren = useMemo(() => (\n <CollectionDocumentContext.Provider value={null}>\n <ShallowRenderContext.Provider value>\n {children}\n </ShallowRenderContext.Provider>\n </CollectionDocumentContext.Provider>\n ), [children]);\n // During SSR, we render the content directly, and append nodes to the document during render.\n // The collection children return null so that nothing is actually rendered into the HTML.\n return useIsSSR()\n ? <SSRContext.Provider value={doc}>{wrappedChildren}</SSRContext.Provider>\n : createPortal(wrappedChildren, doc as unknown as Element);\n}\n"],"names":[],"version":3,"file":"CollectionBuilder.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAcD,MAAM,2DAAuB,CAAA,GAAA,0BAAY,EAAE;AAC3C,MAAM,gEAA4B,CAAA,GAAA,0BAAY,EAA6C;AAWpF,SAAS,0CAAoD,KAAgC;IAClG,gGAAgG;IAChG,IAAI,MAAM,CAAA,GAAA,uBAAS,EAAE;IACrB,IAAI,KACF,gFAAgF;IAChF,4DAA4D;IAC5D,oFAAoF;IACpF,yDAAyD;IACzD,kEAAkE;IAClE,OAAO,MAAM,OAAO;IAGtB,qHAAqH;IACrH,yHAAyH;IAEzH,wEAAwE;IACxE,sDAAsD;IACtD,IAAI,cAAC,UAAU,YAAE,QAAQ,EAAC,GAAG,4CAAsB,MAA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AAQ;QAAC,OAAO;OAAM,iCAClC,CAAA,GAAA,4BAAW,EAAE,iBAAiB;AACpC","sources":["packages/@react-aria/collections/src/CollectionBuilder.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 {BaseCollection, CollectionNode} from './BaseCollection';\nimport {BaseNode, Document, ElementNode} from './Document';\nimport {CachedChildrenOptions, useCachedChildren} from './useCachedChildren';\nimport {createPortal} from 'react-dom';\nimport {FocusableContext} from '@react-aria/interactions';\nimport {forwardRefType, Key, Node} from '@react-types/shared';\nimport {Hidden} from './Hidden';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactElement, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useSyncExternalStore as useSyncExternalStoreShim} from 'use-sync-external-store/shim/index.js';\n\nconst ShallowRenderContext = createContext(false);\nconst CollectionDocumentContext = createContext<Document<any, BaseCollection<any>> | null>(null);\n\nexport interface CollectionBuilderProps<C extends BaseCollection<object>> {\n content: ReactNode,\n children: (collection: C) => ReactNode,\n createCollection?: () => C\n}\n\n/**\n * Builds a `Collection` from the children provided to the `content` prop, and passes it to the child render prop function.\n */\nexport function CollectionBuilder<C extends BaseCollection<object>>(props: CollectionBuilderProps<C>): ReactElement {\n // If a document was provided above us, we're already in a hidden tree. Just render the content.\n let doc = useContext(CollectionDocumentContext);\n if (doc) {\n // The React types prior to 18 did not allow returning ReactNode from components\n // even though the actual implementation since React 16 did.\n // We must return ReactElement so that TS does not complain that <CollectionBuilder>\n // is not a valid JSX element with React 16 and 17 types.\n // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544\n return props.content as ReactElement;\n }\n\n // Otherwise, render a hidden copy of the children so that we can build the collection before constructing the state.\n // This should always come before the real DOM content so we have built the collection by the time it renders during SSR.\n\n // This is fine. CollectionDocumentContext never changes after mounting.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n let {collection, document} = useCollectionDocument(props.createCollection);\n return (\n <>\n <Hidden>\n <CollectionDocumentContext.Provider value={document}>\n {props.content}\n </CollectionDocumentContext.Provider>\n </Hidden>\n <CollectionInner render={props.children} collection={collection} />\n </>\n );\n}\n\nfunction CollectionInner({collection, render}) {\n return render(collection);\n}\n\ninterface CollectionDocumentResult<T, C extends BaseCollection<T>> {\n collection: C,\n document: Document<T, C>\n}\n\n// React 16 and 17 don't support useSyncExternalStore natively, and the shim provided by React does not support getServerSnapshot.\n// This wrapper uses the shim, but additionally calls getServerSnapshot during SSR (according to SSRProvider).\nfunction useSyncExternalStoreFallback<C>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => C, getServerSnapshot: () => C): C {\n let isSSR = useIsSSR();\n let isSSRRef = useRef(isSSR);\n // This is read immediately inside the wrapper, which also runs during render.\n // We just need a ref to avoid invalidating the callback itself, which\n // would cause React to re-run the callback more than necessary.\n // eslint-disable-next-line rulesdir/pure-render\n isSSRRef.current = isSSR;\n\n let getSnapshotWrapper = useCallback(() => {\n return isSSRRef.current ? getServerSnapshot() : getSnapshot();\n }, [getSnapshot, getServerSnapshot]);\n return useSyncExternalStoreShim(subscribe, getSnapshotWrapper);\n}\n\nconst useSyncExternalStore = typeof React['useSyncExternalStore'] === 'function'\n ? React['useSyncExternalStore']\n : useSyncExternalStoreFallback;\n\nfunction useCollectionDocument<T extends object, C extends BaseCollection<T>>(createCollection?: () => C): CollectionDocumentResult<T, C> {\n // The document instance is mutable, and should never change between renders.\n // useSyncExternalStore is used to subscribe to updates, which vends immutable Collection objects.\n let [document] = useState(() => new Document<T, C>(createCollection?.() || new BaseCollection() as C));\n let subscribe = useCallback((fn: () => void) => document.subscribe(fn), [document]);\n let getSnapshot = useCallback(() => {\n let collection = document.getCollection();\n if (document.isSSR) {\n // After SSR is complete, reset the document to empty so it is ready for React to render the portal into.\n // We do this _after_ getting the collection above so that the collection still has content in it from SSR\n // during the current render, before React has finished the client render.\n document.resetAfterSSR();\n }\n return collection;\n }, [document]);\n let getServerSnapshot = useCallback(() => {\n document.isSSR = true;\n return document.getCollection();\n }, [document]);\n let collection = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n useLayoutEffect(() => {\n document.isMounted = true;\n return () => {\n // Mark unmounted so we can skip all of the collection updates caused by\n // React calling removeChild on every item in the collection.\n document.isMounted = false;\n };\n }, [document]);\n return {collection, document};\n}\n\nconst SSRContext = createContext<BaseNode<any> | null>(null);\n\nexport type CollectionNodeClass<T> = {\n new (key: Key): CollectionNode<T>,\n readonly type: string\n};\n\nfunction createCollectionNodeClass(type: string): CollectionNodeClass<any> {\n let NodeClass = class extends CollectionNode<any> {\n static readonly type = type;\n };\n return NodeClass;\n}\n\nfunction useSSRCollectionNode<T extends Element>(CollectionNodeClass: CollectionNodeClass<T> | string, props: object, ref: ForwardedRef<T>, rendered?: any, children?: ReactNode, render?: (node: Node<any>) => ReactElement) {\n // To prevent breaking change, if CollectionNodeClass is a string, create a CollectionNodeClass using the string as the type\n if (typeof CollectionNodeClass === 'string') {\n CollectionNodeClass = createCollectionNodeClass(CollectionNodeClass);\n }\n\n // During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.\n // Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.\n // Therefore we can create elements in our collection document during render so that they are in the\n // collection by the time we need to use the collection to render to the real DOM.\n // After hydration, we switch to client rendering using the portal.\n let itemRef = useCallback((element: ElementNode<any> | null) => {\n element?.setProps(props, ref, CollectionNodeClass, rendered, render);\n }, [props, ref, rendered, render, CollectionNodeClass]);\n let parentNode = useContext(SSRContext);\n if (parentNode) {\n // Guard against double rendering in strict mode.\n let element = parentNode.ownerDocument.nodesByProps.get(props);\n if (!element) {\n element = parentNode.ownerDocument.createElement(CollectionNodeClass.type);\n element.setProps(props, ref, CollectionNodeClass, rendered, render);\n parentNode.appendChild(element);\n parentNode.ownerDocument.updateCollection();\n parentNode.ownerDocument.nodesByProps.set(props, element);\n }\n\n return children\n ? <SSRContext.Provider value={element}>{children}</SSRContext.Provider>\n : null;\n }\n\n // @ts-ignore\n return <CollectionNodeClass.type ref={itemRef}>{children}</CollectionNodeClass.type>;\n}\n\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null;\nexport function createLeafComponent<T extends object, P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null;\nexport function createLeafComponent<P extends object, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node?: any) => ReactElement | null): (props: P & React.RefAttributes<any>) => ReactElement | null {\n let Component = ({node}) => render(node.props, node.props.ref, node);\n let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {\n let focusableProps = useContext(FocusableContext);\n let isShallow = useContext(ShallowRenderContext);\n if (!isShallow) {\n if (render.length >= 3) {\n throw new Error(render.name + ' cannot be rendered outside a collection.');\n }\n return render(props, ref);\n }\n\n return useSSRCollectionNode(\n CollectionNodeClass,\n props,\n ref,\n 'children' in props ? props.children : null,\n null,\n node => (\n // Forward FocusableContext to real DOM tree so tooltips work.\n <FocusableContext.Provider value={focusableProps}>\n <Component node={node} />\n </FocusableContext.Provider>\n )\n );\n });\n // @ts-ignore\n Result.displayName = render.name;\n return Result;\n}\n\nexport function createBranchComponent<T extends object, P extends {children?: any}, E extends Element>(CollectionNodeClass: CollectionNodeClass<any> | string, render: (props: P, ref: ForwardedRef<E>, node: Node<T>) => ReactElement | null, useChildren: (props: P) => ReactNode = useCollectionChildren): (props: P & React.RefAttributes<E>) => ReactElement | null {\n let Component = ({node}) => render(node.props, node.props.ref, node);\n let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {\n let children = useChildren(props);\n return useSSRCollectionNode(CollectionNodeClass, props, ref, null, children, node => <Component node={node} />) ?? <></>;\n });\n // @ts-ignore\n Result.displayName = render.name;\n return Result;\n}\n\nfunction useCollectionChildren<T extends object>(options: CachedChildrenOptions<T>) {\n return useCachedChildren({...options, addIdAndValue: true});\n}\n\nexport interface CollectionProps<T> extends CachedChildrenOptions<T> {}\n\nconst CollectionContext = createContext<CachedChildrenOptions<unknown> | null>(null);\n\n/** A Collection renders a list of items, automatically managing caching and keys. */\nexport function Collection<T extends object>(props: CollectionProps<T>): JSX.Element {\n let ctx = useContext(CollectionContext)!;\n let dependencies = (ctx?.dependencies || []).concat(props.dependencies);\n let idScope = props.idScope || ctx?.idScope;\n let children = useCollectionChildren({\n ...props,\n idScope,\n dependencies\n });\n\n let doc = useContext(CollectionDocumentContext);\n if (doc) {\n children = <CollectionRoot>{children}</CollectionRoot>;\n }\n\n // Propagate dependencies and idScope to child collections.\n ctx = useMemo(() => ({\n dependencies,\n idScope\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [idScope, ...dependencies]);\n\n return (\n <CollectionContext.Provider value={ctx}>\n {children}\n </CollectionContext.Provider>\n );\n}\n\nfunction CollectionRoot({children}) {\n let doc = useContext(CollectionDocumentContext);\n let wrappedChildren = useMemo(() => (\n <CollectionDocumentContext.Provider value={null}>\n <ShallowRenderContext.Provider value>\n {children}\n </ShallowRenderContext.Provider>\n </CollectionDocumentContext.Provider>\n ), [children]);\n // During SSR, we render the content directly, and append nodes to the document during render.\n // The collection children return null so that nothing is actually rendered into the HTML.\n return useIsSSR()\n ? <SSRContext.Provider value={doc}>{wrappedChildren}</SSRContext.Provider>\n : createPortal(wrappedChildren, doc as unknown as Element);\n}\n"],"names":[],"version":3,"file":"CollectionBuilder.main.js.map"}
@@ -1,4 +1,4 @@
1
- import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025} from "./BaseCollection.mjs";
1
+ import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025, CollectionNode as $23b9f4fcf0fe224b$export$d68d59712b04d9d1} from "./BaseCollection.mjs";
2
2
  import {Document as $681cc3c98f569e39$export$b34a105447964f9f} from "./Document.mjs";
3
3
  import {useCachedChildren as $e948873055cbafe4$export$727c8fc270210f13} from "./useCachedChildren.mjs";
4
4
  import {Hidden as $f39a9eba43920ace$export$8dc98ba7eadeaa56} from "./Hidden.mjs";
@@ -114,27 +114,36 @@ function $e1995378a142960e$var$useCollectionDocument(createCollection) {
114
114
  };
115
115
  }
116
116
  const $e1995378a142960e$var$SSRContext = /*#__PURE__*/ (0, $95feo$createContext)(null);
117
- function $e1995378a142960e$var$useSSRCollectionNode(Type, props, ref, rendered, children, render) {
117
+ function $e1995378a142960e$var$createCollectionNodeClass(type) {
118
+ var _class;
119
+ let NodeClass = (_class = class extends (0, $23b9f4fcf0fe224b$export$d68d59712b04d9d1) {
120
+ }, _class.type = type, _class);
121
+ return NodeClass;
122
+ }
123
+ function $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, rendered, children, render) {
124
+ // To prevent breaking change, if CollectionNodeClass is a string, create a CollectionNodeClass using the string as the type
125
+ if (typeof CollectionNodeClass === 'string') CollectionNodeClass = $e1995378a142960e$var$createCollectionNodeClass(CollectionNodeClass);
118
126
  // During SSR, portals are not supported, so the collection children will be wrapped in an SSRContext.
119
127
  // Since SSR occurs only once, we assume that the elements are rendered in order and never re-render.
120
128
  // Therefore we can create elements in our collection document during render so that they are in the
121
129
  // collection by the time we need to use the collection to render to the real DOM.
122
130
  // After hydration, we switch to client rendering using the portal.
123
131
  let itemRef = (0, $95feo$useCallback)((element)=>{
124
- element === null || element === void 0 ? void 0 : element.setProps(props, ref, rendered, render);
132
+ element === null || element === void 0 ? void 0 : element.setProps(props, ref, CollectionNodeClass, rendered, render);
125
133
  }, [
126
134
  props,
127
135
  ref,
128
136
  rendered,
129
- render
137
+ render,
138
+ CollectionNodeClass
130
139
  ]);
131
140
  let parentNode = (0, $95feo$useContext)($e1995378a142960e$var$SSRContext);
132
141
  if (parentNode) {
133
142
  // Guard against double rendering in strict mode.
134
143
  let element = parentNode.ownerDocument.nodesByProps.get(props);
135
144
  if (!element) {
136
- element = parentNode.ownerDocument.createElement(Type);
137
- element.setProps(props, ref, rendered, render);
145
+ element = parentNode.ownerDocument.createElement(CollectionNodeClass.type);
146
+ element.setProps(props, ref, CollectionNodeClass, rendered, render);
138
147
  parentNode.appendChild(element);
139
148
  parentNode.ownerDocument.updateCollection();
140
149
  parentNode.ownerDocument.nodesByProps.set(props, element);
@@ -144,11 +153,11 @@ function $e1995378a142960e$var$useSSRCollectionNode(Type, props, ref, rendered,
144
153
  }, children) : null;
145
154
  }
146
155
  // @ts-ignore
147
- return /*#__PURE__*/ (0, $95feo$react).createElement(Type, {
156
+ return /*#__PURE__*/ (0, $95feo$react).createElement(CollectionNodeClass.type, {
148
157
  ref: itemRef
149
158
  }, children);
150
159
  }
151
- function $e1995378a142960e$export$18af5c7a9e9b3664(type, render) {
160
+ function $e1995378a142960e$export$18af5c7a9e9b3664(CollectionNodeClass, render) {
152
161
  let Component = ({ node: node })=>render(node.props, node.props.ref, node);
153
162
  let Result = (0, $95feo$forwardRef)((props, ref)=>{
154
163
  let focusableProps = (0, $95feo$useContext)((0, $95feo$FocusableContext));
@@ -157,7 +166,7 @@ function $e1995378a142960e$export$18af5c7a9e9b3664(type, render) {
157
166
  if (render.length >= 3) throw new Error(render.name + ' cannot be rendered outside a collection.');
158
167
  return render(props, ref);
159
168
  }
160
- return $e1995378a142960e$var$useSSRCollectionNode(type, props, ref, 'children' in props ? props.children : null, null, (node)=>// Forward FocusableContext to real DOM tree so tooltips work.
169
+ return $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, 'children' in props ? props.children : null, null, (node)=>// Forward FocusableContext to real DOM tree so tooltips work.
161
170
  /*#__PURE__*/ (0, $95feo$react).createElement((0, $95feo$FocusableContext).Provider, {
162
171
  value: focusableProps
163
172
  }, /*#__PURE__*/ (0, $95feo$react).createElement(Component, {
@@ -168,12 +177,12 @@ function $e1995378a142960e$export$18af5c7a9e9b3664(type, render) {
168
177
  Result.displayName = render.name;
169
178
  return Result;
170
179
  }
171
- function $e1995378a142960e$export$e953bb1cd0f19726(type, render, useChildren = $e1995378a142960e$var$useCollectionChildren) {
180
+ function $e1995378a142960e$export$e953bb1cd0f19726(CollectionNodeClass, render, useChildren = $e1995378a142960e$var$useCollectionChildren) {
172
181
  let Component = ({ node: node })=>render(node.props, node.props.ref, node);
173
182
  let Result = (0, $95feo$forwardRef)((props, ref)=>{
174
183
  let children = useChildren(props);
175
184
  var _useSSRCollectionNode;
176
- return (_useSSRCollectionNode = $e1995378a142960e$var$useSSRCollectionNode(type, props, ref, null, children, (node)=>/*#__PURE__*/ (0, $95feo$react).createElement(Component, {
185
+ return (_useSSRCollectionNode = $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, null, children, (node)=>/*#__PURE__*/ (0, $95feo$react).createElement(Component, {
177
186
  node: node
178
187
  }))) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /*#__PURE__*/ (0, $95feo$react).createElement((0, $95feo$react).Fragment, null);
179
188
  });