@react-stately/collections 3.3.5 → 3.3.8
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.
- package/dist/main.js +53 -48
- package/dist/main.js.map +1 -1
- package/dist/module.js +49 -44
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/src/CollectionBuilder.ts +4 -0
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var $
|
|
1
|
+
var $4aZkW$react = require("react");
|
|
2
2
|
|
|
3
3
|
function $parcel$exportWildcard(dest, source) {
|
|
4
4
|
Object.keys(source).forEach(function(key) {
|
|
@@ -22,26 +22,26 @@ function $parcel$interopDefault(a) {
|
|
|
22
22
|
function $parcel$export(e, n, v, s) {
|
|
23
23
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
24
24
|
}
|
|
25
|
-
var $
|
|
25
|
+
var $c870f3b549c61b6b$exports = {};
|
|
26
26
|
|
|
27
|
-
$parcel$export($
|
|
27
|
+
$parcel$export($c870f3b549c61b6b$exports, "Item", () => $c870f3b549c61b6b$export$6d08773d2e66f8f2);
|
|
28
28
|
|
|
29
|
-
function $
|
|
29
|
+
function $c870f3b549c61b6b$var$Item(props) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
|
-
$
|
|
32
|
+
$c870f3b549c61b6b$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
33
33
|
let { childItems: childItems , title: title , children: children } = props;
|
|
34
34
|
let rendered = props.title || props.children;
|
|
35
35
|
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';
|
|
36
36
|
// suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
|
|
37
|
-
if (!textValue && !context
|
|
37
|
+
if (!textValue && !(context === null || context === void 0 ? void 0 : context.suppressTextValueWarning)) console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');
|
|
38
38
|
yield {
|
|
39
39
|
type: 'item',
|
|
40
40
|
props: props,
|
|
41
41
|
rendered: rendered,
|
|
42
42
|
textValue: textValue,
|
|
43
43
|
'aria-label': props['aria-label'],
|
|
44
|
-
hasChildNodes: $
|
|
44
|
+
hasChildNodes: $c870f3b549c61b6b$var$hasChildItems(props),
|
|
45
45
|
*childNodes () {
|
|
46
46
|
if (childItems) for (let child1 of childItems)yield {
|
|
47
47
|
type: 'item',
|
|
@@ -49,7 +49,7 @@ $67609abe41544c2f$var$Item.getCollectionNode = function* getCollectionNode(props
|
|
|
49
49
|
};
|
|
50
50
|
else if (title) {
|
|
51
51
|
let items = [];
|
|
52
|
-
($parcel$interopDefault($
|
|
52
|
+
($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
|
|
53
53
|
items.push({
|
|
54
54
|
type: 'item',
|
|
55
55
|
element: child
|
|
@@ -60,24 +60,24 @@ $67609abe41544c2f$var$Item.getCollectionNode = function* getCollectionNode(props
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
function $
|
|
63
|
+
function $c870f3b549c61b6b$var$hasChildItems(props) {
|
|
64
64
|
if (props.hasChildItems != null) return props.hasChildItems;
|
|
65
65
|
if (props.childItems) return true;
|
|
66
|
-
if (props.title && ($parcel$interopDefault($
|
|
66
|
+
if (props.title && ($parcel$interopDefault($4aZkW$react)).Children.count(props.children) > 0) return true;
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
69
|
// We don't want getCollectionNode to show up in the type definition
|
|
70
|
-
let $
|
|
70
|
+
let $c870f3b549c61b6b$export$6d08773d2e66f8f2 = $c870f3b549c61b6b$var$Item;
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var $
|
|
73
|
+
var $350f13aa4d8b327c$exports = {};
|
|
74
74
|
|
|
75
|
-
$parcel$export($
|
|
75
|
+
$parcel$export($350f13aa4d8b327c$exports, "Section", () => $350f13aa4d8b327c$export$6e2c8f0811a474ce);
|
|
76
76
|
|
|
77
|
-
function $
|
|
77
|
+
function $350f13aa4d8b327c$var$Section(props) {
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
|
-
$
|
|
80
|
+
$350f13aa4d8b327c$var$Section.getCollectionNode = function* getCollectionNode(props) {
|
|
81
81
|
let { children: children , title: title , items: items1 } = props;
|
|
82
82
|
yield {
|
|
83
83
|
type: 'section',
|
|
@@ -94,7 +94,7 @@ $7613fe6c851d27af$var$Section.getCollectionNode = function* getCollectionNode(pr
|
|
|
94
94
|
};
|
|
95
95
|
} else {
|
|
96
96
|
let items = [];
|
|
97
|
-
($parcel$interopDefault($
|
|
97
|
+
($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
|
|
98
98
|
items.push({
|
|
99
99
|
type: 'item',
|
|
100
100
|
element: child
|
|
@@ -106,20 +106,20 @@ $7613fe6c851d27af$var$Section.getCollectionNode = function* getCollectionNode(pr
|
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
108
|
// We don't want getCollectionNode to show up in the type definition
|
|
109
|
-
let $
|
|
109
|
+
let $350f13aa4d8b327c$export$6e2c8f0811a474ce = $350f13aa4d8b327c$var$Section;
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
var $
|
|
112
|
+
var $cade2c06f59a1baa$exports = {};
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
var $
|
|
115
|
+
var $98fc0fafaca75b6a$exports = {};
|
|
116
116
|
|
|
117
|
-
$parcel$export($
|
|
117
|
+
$parcel$export($98fc0fafaca75b6a$exports, "useCollection", () => $98fc0fafaca75b6a$export$6cd28814d92fa9c9);
|
|
118
118
|
|
|
119
|
-
class $
|
|
119
|
+
class $51588fd411aace25$export$bf788dd355e3a401 {
|
|
120
120
|
build(props, context) {
|
|
121
121
|
this.context = context;
|
|
122
|
-
return $
|
|
122
|
+
return $51588fd411aace25$var$iterable(()=>this.iterateCollection(props)
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
*iterateCollection(props) {
|
|
@@ -133,7 +133,7 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
133
133
|
});
|
|
134
134
|
} else {
|
|
135
135
|
let items = [];
|
|
136
|
-
($parcel$interopDefault($
|
|
136
|
+
($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
|
|
137
137
|
items.push(child);
|
|
138
138
|
});
|
|
139
139
|
let index = 0;
|
|
@@ -155,7 +155,8 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
155
155
|
if (partialNode.type === 'cell' && partialNode.key != null) return `${parentKey}${partialNode.key}`;
|
|
156
156
|
let v = partialNode.value;
|
|
157
157
|
if (v != null) {
|
|
158
|
-
|
|
158
|
+
var _key;
|
|
159
|
+
let key = (_key = v.key) !== null && _key !== void 0 ? _key : v.id;
|
|
159
160
|
if (key == null) throw new Error('No key found for item');
|
|
160
161
|
return key;
|
|
161
162
|
}
|
|
@@ -182,7 +183,7 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
182
183
|
}
|
|
183
184
|
// If there's an element with a getCollectionNode function on its type, then it's a supported component.
|
|
184
185
|
// Call this function to get a partial node, and recursively build a full node from there.
|
|
185
|
-
if (($parcel$interopDefault($
|
|
186
|
+
if (($parcel$interopDefault($4aZkW$react)).isValidElement(element)) {
|
|
186
187
|
let type = element.type;
|
|
187
188
|
if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {
|
|
188
189
|
let name = typeof element.type === 'function' ? element.type.name : element.type;
|
|
@@ -200,7 +201,7 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
200
201
|
...childNode,
|
|
201
202
|
key: nodeKey,
|
|
202
203
|
index: index,
|
|
203
|
-
wrapper: $
|
|
204
|
+
wrapper: $51588fd411aace25$var$compose(partialNode.wrapper, childNode.wrapper)
|
|
204
205
|
}, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
|
|
205
206
|
let children = [
|
|
206
207
|
...nodes
|
|
@@ -211,7 +212,7 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
211
212
|
if (node.value) this.cache.set(node.value, node);
|
|
212
213
|
// The partial node may have specified a type for the child in order to specify a constraint.
|
|
213
214
|
// Verify that the full node that was built recursively matches this type.
|
|
214
|
-
if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$
|
|
215
|
+
if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$51588fd411aace25$var$capitalize(node.type)}> in <${$51588fd411aace25$var$capitalize(parentNode.type)}>. Only <${$51588fd411aace25$var$capitalize(partialNode.type)}> is supported.`);
|
|
215
216
|
index++;
|
|
216
217
|
yield node;
|
|
217
218
|
}
|
|
@@ -237,12 +238,16 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
237
238
|
wrapper: partialNode.wrapper,
|
|
238
239
|
shouldInvalidate: partialNode.shouldInvalidate,
|
|
239
240
|
hasChildNodes: partialNode.hasChildNodes,
|
|
240
|
-
childNodes: $
|
|
241
|
+
childNodes: $51588fd411aace25$var$iterable(function*() {
|
|
241
242
|
if (!partialNode.hasChildNodes) return;
|
|
242
243
|
let index = 0;
|
|
243
244
|
for (let child of partialNode.childNodes()){
|
|
244
245
|
// Ensure child keys are globally unique by prepending the parent node's key
|
|
245
|
-
if (child.key != null)
|
|
246
|
+
if (child.key != null) // TODO: Remove this line entirely and enforce that users always provide unique keys.
|
|
247
|
+
// Currently this line will have issues when a parent has a key `a` and a child with key `bc`
|
|
248
|
+
// but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
|
|
249
|
+
// children having a key of `abc`.
|
|
250
|
+
child.key = `${node.key}${child.key}`;
|
|
246
251
|
child.index = index;
|
|
247
252
|
let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
|
|
248
253
|
for (let node1 of nodes){
|
|
@@ -259,7 +264,7 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
259
264
|
}
|
|
260
265
|
}
|
|
261
266
|
// Wraps an iterator function as an iterable object, and caches the results.
|
|
262
|
-
function $
|
|
267
|
+
function $51588fd411aace25$var$iterable(iterator) {
|
|
263
268
|
let cache = [];
|
|
264
269
|
let iterable = null;
|
|
265
270
|
return {
|
|
@@ -273,23 +278,23 @@ function $99f43427f9c89ffa$var$iterable(iterator) {
|
|
|
273
278
|
}
|
|
274
279
|
};
|
|
275
280
|
}
|
|
276
|
-
function $
|
|
281
|
+
function $51588fd411aace25$var$compose(outer, inner) {
|
|
277
282
|
if (outer && inner) return (element)=>outer(inner(element))
|
|
278
283
|
;
|
|
279
284
|
if (outer) return outer;
|
|
280
285
|
if (inner) return inner;
|
|
281
286
|
}
|
|
282
|
-
function $
|
|
287
|
+
function $51588fd411aace25$var$capitalize(str) {
|
|
283
288
|
return str[0].toUpperCase() + str.slice(1);
|
|
284
289
|
}
|
|
285
290
|
|
|
286
291
|
|
|
287
292
|
|
|
288
|
-
function $
|
|
289
|
-
let builder = $
|
|
293
|
+
function $98fc0fafaca75b6a$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
|
|
294
|
+
let builder = $4aZkW$react.useMemo(()=>new $51588fd411aace25$export$bf788dd355e3a401()
|
|
290
295
|
, []);
|
|
291
|
-
let prev = $
|
|
292
|
-
return $
|
|
296
|
+
let prev = $4aZkW$react.useRef(null);
|
|
297
|
+
return $4aZkW$react.useMemo(()=>{
|
|
293
298
|
let nodes = builder.build(props, context);
|
|
294
299
|
prev.current = factory(nodes, prev.current);
|
|
295
300
|
return prev.current;
|
|
@@ -305,26 +310,26 @@ function $df8a726ef7511d2e$export$6cd28814d92fa9c9(props, factory, context, inva
|
|
|
305
310
|
}
|
|
306
311
|
|
|
307
312
|
|
|
308
|
-
var $
|
|
313
|
+
var $e749fe52977fe2c2$exports = {};
|
|
309
314
|
|
|
310
|
-
$parcel$export($
|
|
311
|
-
const $
|
|
312
|
-
function $
|
|
313
|
-
let count = $
|
|
315
|
+
$parcel$export($e749fe52977fe2c2$exports, "getItemCount", () => $e749fe52977fe2c2$export$77d5aafae4e095b2);
|
|
316
|
+
const $e749fe52977fe2c2$var$cache = new WeakMap();
|
|
317
|
+
function $e749fe52977fe2c2$export$77d5aafae4e095b2(collection) {
|
|
318
|
+
let count = $e749fe52977fe2c2$var$cache.get(collection);
|
|
314
319
|
if (count != null) return count;
|
|
315
320
|
count = 0;
|
|
316
|
-
for (let item of collection)if (item.type === 'section') count += $
|
|
321
|
+
for (let item of collection)if (item.type === 'section') count += $e749fe52977fe2c2$export$77d5aafae4e095b2(item.childNodes);
|
|
317
322
|
else count++;
|
|
318
|
-
$
|
|
323
|
+
$e749fe52977fe2c2$var$cache.set(collection, count);
|
|
319
324
|
return count;
|
|
320
325
|
}
|
|
321
326
|
|
|
322
327
|
|
|
323
|
-
$parcel$exportWildcard(module.exports, $
|
|
324
|
-
$parcel$exportWildcard(module.exports, $
|
|
325
|
-
$parcel$exportWildcard(module.exports, $
|
|
326
|
-
$parcel$exportWildcard(module.exports, $
|
|
327
|
-
$parcel$exportWildcard(module.exports, $
|
|
328
|
+
$parcel$exportWildcard(module.exports, $c870f3b549c61b6b$exports);
|
|
329
|
+
$parcel$exportWildcard(module.exports, $350f13aa4d8b327c$exports);
|
|
330
|
+
$parcel$exportWildcard(module.exports, $cade2c06f59a1baa$exports);
|
|
331
|
+
$parcel$exportWildcard(module.exports, $98fc0fafaca75b6a$exports);
|
|
332
|
+
$parcel$exportWildcard(module.exports, $e749fe52977fe2c2$exports);
|
|
328
333
|
|
|
329
334
|
|
|
330
335
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;SCgBS,0BAAI,CAAI,KAAmB,EAAgB,CAAC;IACnD,MAAM,CAAC,IAAI;AACb,CAAC;AAED,0BAAI,CAAC,iBAAiB,GAAG,QAAQ,EAAE,iBAAiB,CAAI,KAAmB,EAAE,OAAY,EAA6B,CAAC;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ately/collections/src/Section.ts","packages/@react-stately/collections/src/types.ts","packages/@react-stately/collections/src/useCollection.ts","packages/@react-stately/collections/src/CollectionBuilder.ts","packages/@react-stately/collections/src/getItemCount.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './Item';\nexport * from './Section';\nexport * from './types';\nexport * from './useCollection';\nexport * from './getItemCount';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>, context: any): Generator<PartialNode<T>> {\n let {childItems, title, children} = props;\n\n let rendered = props.title || props.children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.\n if (!textValue && !context?.suppressTextValueWarning) {\n console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n }\n\n yield {\n type: 'item',\n props: props,\n rendered,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: hasChildItems(props),\n *childNodes() {\n if (childItems) {\n for (let child of childItems) {\n yield {\n type: 'item',\n value: child\n };\n }\n } else if (title) {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child as ItemElement<T>\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n if (props.hasChildItems != null) {\n return props.hasChildItems;\n }\n\n if (props.childItems) {\n return true;\n }\n\n if (props.title && React.Children.count(props.children) > 0) {\n return true;\n }\n\n return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n let {children, title, items} = props;\n yield {\n type: 'section',\n hasChildNodes: true,\n rendered: title,\n 'aria-label': props['aria-label'],\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n \n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemRenderer} from '@react-types/shared';\nimport {Key, ReactElement, ReactNode} from 'react';\n\nexport interface PartialNode<T> {\n type?: string,\n key?: Key,\n value?: T,\n element?: ReactElement,\n wrapper?: (element: ReactElement) => ReactElement,\n rendered?: ReactNode,\n textValue?: string,\n 'aria-label'?: string,\n index?: number,\n renderer?: ItemRenderer<T>,\n hasChildNodes?: boolean,\n childNodes?: () => IterableIterator<PartialNode<T>>,\n props?: any,\n shouldInvalidate?: (context: unknown) => boolean\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;SCgBS,0BAAI,CAAI,KAAmB,EAAgB,CAAC;IACnD,MAAM,CAAC,IAAI;AACb,CAAC;AAED,0BAAI,CAAC,iBAAiB,GAAG,QAAQ,EAAE,iBAAiB,CAAI,KAAmB,EAAE,OAAY,EAA6B,CAAC;IACrH,GAAG,CAAC,CAAC,aAAA,UAAU,UAAE,KAAK,aAAE,QAAQ,EAAA,CAAC,GAAG,KAAK;IAEzC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,QAAQ;IAC5C,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,QAAQ,KAAK,CAAQ,UAAG,QAAQ,GAAG,CAAE,MAAK,KAAK,CAAC,CAAY,gBAAK,CAAE;IAE9G,EA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,KAAwB,EAAE,OAAgC,EAAE,OAAiB,EAAE,YAAwB,GAAG,CAAC,CAAC,EAAK,CAAC;IACrN,GAAG,CAAC,OAAO,GAAG,oBAAO,KAAO,GAAG,CAAC,yCAAiB;MAAO,CAAC,CAAC;IAE1D,GAAG,CAAC,IAAI,GAAG,mBAAM,CAAI,IAAI;IACzB,MAAM,CAAC,oBAAO,KAAO,CAAC;QACpB,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO;QAC1C,MAAM,CAAC,IAAI,CAAC,OAAO;IACrB,EAAsE,AAAtE,oEAAsE;IACtE,EAAuD,AAAvD,qDAAuD;IACvD,CAAC,EAAE,CAAC;QAAA,OAAO;QAAE,KAAK,CAAC,QAAQ;QAAE,KAAK,CAAC,KAAK;QAAE,OAAO;WAAK,YAAY;IAAA,CAAC;AACrE,CAAC;;;;;;AEfD,KAAK,CAAC,2BAAK,GAAG,GAAG,CAAC,OAAO;SAET,yCAAY,CAAI,UAA6B,EAAU,CAAC;IACtE,GAAG,CAAC,KAAK,GAAG,2BAAK,CAAC,GAAG,CAAC,UAAU;IAChC,EAAE,EAAE,KAAK,IAAI,IAAI,EACf,MAAM,CAAC,KAAK;IAGd,KAAK,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,UAAU,CACzB,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,CAAS,UACzB,KAAK,IAAI,yCAAY,CAAC,IAAI,CAAC,UAAU;SAErC,KAAK;IAIT,2BAAK,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK;IAC3B,MAAM,CAAC,KAAK;AACd,CAAC;","sources":["packages/@react-stately/collections/src/index.ts","packages/@react-stately/collections/src/Item.ts","packages/@react-stately/collections/src/Section.ts","packages/@react-stately/collections/src/types.ts","packages/@react-stately/collections/src/useCollection.ts","packages/@react-stately/collections/src/CollectionBuilder.ts","packages/@react-stately/collections/src/getItemCount.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './Item';\nexport * from './Section';\nexport * from './types';\nexport * from './useCollection';\nexport * from './getItemCount';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>, context: any): Generator<PartialNode<T>> {\n let {childItems, title, children} = props;\n\n let rendered = props.title || props.children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.\n if (!textValue && !context?.suppressTextValueWarning) {\n console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n }\n\n yield {\n type: 'item',\n props: props,\n rendered,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: hasChildItems(props),\n *childNodes() {\n if (childItems) {\n for (let child of childItems) {\n yield {\n type: 'item',\n value: child\n };\n }\n } else if (title) {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child as ItemElement<T>\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n if (props.hasChildItems != null) {\n return props.hasChildItems;\n }\n\n if (props.childItems) {\n return true;\n }\n\n if (props.title && React.Children.count(props.children) > 0) {\n return true;\n }\n\n return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n let {children, title, items} = props;\n yield {\n type: 'section',\n hasChildNodes: true,\n rendered: title,\n 'aria-label': props['aria-label'],\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n \n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemRenderer} from '@react-types/shared';\nimport {Key, ReactElement, ReactNode} from 'react';\n\nexport interface PartialNode<T> {\n type?: string,\n key?: Key,\n value?: T,\n element?: ReactElement,\n wrapper?: (element: ReactElement) => ReactElement,\n rendered?: ReactNode,\n textValue?: string,\n 'aria-label'?: string,\n index?: number,\n renderer?: ItemRenderer<T>,\n hasChildNodes?: boolean,\n childNodes?: () => IterableIterator<PartialNode<T>>,\n props?: any,\n shouldInvalidate?: (context: unknown) => boolean\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n // TODO: Remove this line entirely and enforce that users always provide unique keys.\n // Currently this line will have issues when a parent has a key `a` and a child with key `bc`\n // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both\n // children having a key of `abc`.\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import $
|
|
1
|
+
import $tyW6A$react, {useMemo as $tyW6A$useMemo, useRef as $tyW6A$useRef} from "react";
|
|
2
2
|
|
|
3
3
|
function $parcel$export(e, n, v, s) {
|
|
4
4
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
5
5
|
}
|
|
6
|
-
var $
|
|
6
|
+
var $c1d7fb2ec91bae71$exports = {};
|
|
7
7
|
|
|
8
|
-
$parcel$export($
|
|
8
|
+
$parcel$export($c1d7fb2ec91bae71$exports, "Item", () => $c1d7fb2ec91bae71$export$6d08773d2e66f8f2);
|
|
9
9
|
|
|
10
|
-
function $
|
|
10
|
+
function $c1d7fb2ec91bae71$var$Item(props) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
|
-
$
|
|
13
|
+
$c1d7fb2ec91bae71$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
14
14
|
let { childItems: childItems , title: title , children: children } = props;
|
|
15
15
|
let rendered = props.title || props.children;
|
|
16
16
|
let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';
|
|
17
17
|
// suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
|
|
18
|
-
if (!textValue && !context
|
|
18
|
+
if (!textValue && !(context === null || context === void 0 ? void 0 : context.suppressTextValueWarning)) console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');
|
|
19
19
|
yield {
|
|
20
20
|
type: 'item',
|
|
21
21
|
props: props,
|
|
22
22
|
rendered: rendered,
|
|
23
23
|
textValue: textValue,
|
|
24
24
|
'aria-label': props['aria-label'],
|
|
25
|
-
hasChildNodes: $
|
|
25
|
+
hasChildNodes: $c1d7fb2ec91bae71$var$hasChildItems(props),
|
|
26
26
|
*childNodes () {
|
|
27
27
|
if (childItems) for (let child1 of childItems)yield {
|
|
28
28
|
type: 'item',
|
|
@@ -30,7 +30,7 @@ $d80587bf41d0fb18$var$Item.getCollectionNode = function* getCollectionNode(props
|
|
|
30
30
|
};
|
|
31
31
|
else if (title) {
|
|
32
32
|
let items = [];
|
|
33
|
-
$
|
|
33
|
+
$tyW6A$react.Children.forEach(children, (child)=>{
|
|
34
34
|
items.push({
|
|
35
35
|
type: 'item',
|
|
36
36
|
element: child
|
|
@@ -41,24 +41,24 @@ $d80587bf41d0fb18$var$Item.getCollectionNode = function* getCollectionNode(props
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
function $
|
|
44
|
+
function $c1d7fb2ec91bae71$var$hasChildItems(props) {
|
|
45
45
|
if (props.hasChildItems != null) return props.hasChildItems;
|
|
46
46
|
if (props.childItems) return true;
|
|
47
|
-
if (props.title && $
|
|
47
|
+
if (props.title && $tyW6A$react.Children.count(props.children) > 0) return true;
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
// We don't want getCollectionNode to show up in the type definition
|
|
51
|
-
let $
|
|
51
|
+
let $c1d7fb2ec91bae71$export$6d08773d2e66f8f2 = $c1d7fb2ec91bae71$var$Item;
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
var $
|
|
54
|
+
var $9fc4852771d079eb$exports = {};
|
|
55
55
|
|
|
56
|
-
$parcel$export($
|
|
56
|
+
$parcel$export($9fc4852771d079eb$exports, "Section", () => $9fc4852771d079eb$export$6e2c8f0811a474ce);
|
|
57
57
|
|
|
58
|
-
function $
|
|
58
|
+
function $9fc4852771d079eb$var$Section(props) {
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
|
-
$
|
|
61
|
+
$9fc4852771d079eb$var$Section.getCollectionNode = function* getCollectionNode(props) {
|
|
62
62
|
let { children: children , title: title , items: items1 } = props;
|
|
63
63
|
yield {
|
|
64
64
|
type: 'section',
|
|
@@ -75,7 +75,7 @@ $591e4228be66f7fb$var$Section.getCollectionNode = function* getCollectionNode(pr
|
|
|
75
75
|
};
|
|
76
76
|
} else {
|
|
77
77
|
let items = [];
|
|
78
|
-
$
|
|
78
|
+
$tyW6A$react.Children.forEach(children, (child)=>{
|
|
79
79
|
items.push({
|
|
80
80
|
type: 'item',
|
|
81
81
|
element: child
|
|
@@ -87,20 +87,20 @@ $591e4228be66f7fb$var$Section.getCollectionNode = function* getCollectionNode(pr
|
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
// We don't want getCollectionNode to show up in the type definition
|
|
90
|
-
let $
|
|
90
|
+
let $9fc4852771d079eb$export$6e2c8f0811a474ce = $9fc4852771d079eb$var$Section;
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
var $
|
|
93
|
+
var $abe69ec9966cc167$exports = {};
|
|
94
94
|
|
|
95
95
|
|
|
96
|
-
var $
|
|
96
|
+
var $7613b1592d41b092$exports = {};
|
|
97
97
|
|
|
98
|
-
$parcel$export($
|
|
98
|
+
$parcel$export($7613b1592d41b092$exports, "useCollection", () => $7613b1592d41b092$export$6cd28814d92fa9c9);
|
|
99
99
|
|
|
100
|
-
class $
|
|
100
|
+
class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
|
|
101
101
|
build(props, context) {
|
|
102
102
|
this.context = context;
|
|
103
|
-
return $
|
|
103
|
+
return $eb2240fc39a57fa5$var$iterable(()=>this.iterateCollection(props)
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
*iterateCollection(props) {
|
|
@@ -114,7 +114,7 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
114
114
|
});
|
|
115
115
|
} else {
|
|
116
116
|
let items = [];
|
|
117
|
-
$
|
|
117
|
+
$tyW6A$react.Children.forEach(children, (child)=>{
|
|
118
118
|
items.push(child);
|
|
119
119
|
});
|
|
120
120
|
let index = 0;
|
|
@@ -136,7 +136,8 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
136
136
|
if (partialNode.type === 'cell' && partialNode.key != null) return `${parentKey}${partialNode.key}`;
|
|
137
137
|
let v = partialNode.value;
|
|
138
138
|
if (v != null) {
|
|
139
|
-
|
|
139
|
+
var _key;
|
|
140
|
+
let key = (_key = v.key) !== null && _key !== void 0 ? _key : v.id;
|
|
140
141
|
if (key == null) throw new Error('No key found for item');
|
|
141
142
|
return key;
|
|
142
143
|
}
|
|
@@ -163,7 +164,7 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
163
164
|
}
|
|
164
165
|
// If there's an element with a getCollectionNode function on its type, then it's a supported component.
|
|
165
166
|
// Call this function to get a partial node, and recursively build a full node from there.
|
|
166
|
-
if ($
|
|
167
|
+
if ($tyW6A$react.isValidElement(element)) {
|
|
167
168
|
let type = element.type;
|
|
168
169
|
if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {
|
|
169
170
|
let name = typeof element.type === 'function' ? element.type.name : element.type;
|
|
@@ -181,7 +182,7 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
181
182
|
...childNode,
|
|
182
183
|
key: nodeKey,
|
|
183
184
|
index: index,
|
|
184
|
-
wrapper: $
|
|
185
|
+
wrapper: $eb2240fc39a57fa5$var$compose(partialNode.wrapper, childNode.wrapper)
|
|
185
186
|
}, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
|
|
186
187
|
let children = [
|
|
187
188
|
...nodes
|
|
@@ -192,7 +193,7 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
192
193
|
if (node.value) this.cache.set(node.value, node);
|
|
193
194
|
// The partial node may have specified a type for the child in order to specify a constraint.
|
|
194
195
|
// Verify that the full node that was built recursively matches this type.
|
|
195
|
-
if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$
|
|
196
|
+
if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$eb2240fc39a57fa5$var$capitalize(node.type)}> in <${$eb2240fc39a57fa5$var$capitalize(parentNode.type)}>. Only <${$eb2240fc39a57fa5$var$capitalize(partialNode.type)}> is supported.`);
|
|
196
197
|
index++;
|
|
197
198
|
yield node;
|
|
198
199
|
}
|
|
@@ -218,12 +219,16 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
218
219
|
wrapper: partialNode.wrapper,
|
|
219
220
|
shouldInvalidate: partialNode.shouldInvalidate,
|
|
220
221
|
hasChildNodes: partialNode.hasChildNodes,
|
|
221
|
-
childNodes: $
|
|
222
|
+
childNodes: $eb2240fc39a57fa5$var$iterable(function*() {
|
|
222
223
|
if (!partialNode.hasChildNodes) return;
|
|
223
224
|
let index = 0;
|
|
224
225
|
for (let child of partialNode.childNodes()){
|
|
225
226
|
// Ensure child keys are globally unique by prepending the parent node's key
|
|
226
|
-
if (child.key != null)
|
|
227
|
+
if (child.key != null) // TODO: Remove this line entirely and enforce that users always provide unique keys.
|
|
228
|
+
// Currently this line will have issues when a parent has a key `a` and a child with key `bc`
|
|
229
|
+
// but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
|
|
230
|
+
// children having a key of `abc`.
|
|
231
|
+
child.key = `${node.key}${child.key}`;
|
|
227
232
|
child.index = index;
|
|
228
233
|
let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
|
|
229
234
|
for (let node1 of nodes){
|
|
@@ -240,7 +245,7 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
240
245
|
}
|
|
241
246
|
}
|
|
242
247
|
// Wraps an iterator function as an iterable object, and caches the results.
|
|
243
|
-
function $
|
|
248
|
+
function $eb2240fc39a57fa5$var$iterable(iterator) {
|
|
244
249
|
let cache = [];
|
|
245
250
|
let iterable = null;
|
|
246
251
|
return {
|
|
@@ -254,23 +259,23 @@ function $0ef13e8a225e58db$var$iterable(iterator) {
|
|
|
254
259
|
}
|
|
255
260
|
};
|
|
256
261
|
}
|
|
257
|
-
function $
|
|
262
|
+
function $eb2240fc39a57fa5$var$compose(outer, inner) {
|
|
258
263
|
if (outer && inner) return (element)=>outer(inner(element))
|
|
259
264
|
;
|
|
260
265
|
if (outer) return outer;
|
|
261
266
|
if (inner) return inner;
|
|
262
267
|
}
|
|
263
|
-
function $
|
|
268
|
+
function $eb2240fc39a57fa5$var$capitalize(str) {
|
|
264
269
|
return str[0].toUpperCase() + str.slice(1);
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
|
|
268
273
|
|
|
269
|
-
function $
|
|
270
|
-
let builder = $
|
|
274
|
+
function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
|
|
275
|
+
let builder = $tyW6A$useMemo(()=>new $eb2240fc39a57fa5$export$bf788dd355e3a401()
|
|
271
276
|
, []);
|
|
272
|
-
let prev = $
|
|
273
|
-
return $
|
|
277
|
+
let prev = $tyW6A$useRef(null);
|
|
278
|
+
return $tyW6A$useMemo(()=>{
|
|
274
279
|
let nodes = builder.build(props, context);
|
|
275
280
|
prev.current = factory(nodes, prev.current);
|
|
276
281
|
return prev.current;
|
|
@@ -286,22 +291,22 @@ function $b0e94ff142179e1f$export$6cd28814d92fa9c9(props, factory, context, inva
|
|
|
286
291
|
}
|
|
287
292
|
|
|
288
293
|
|
|
289
|
-
var $
|
|
294
|
+
var $453cc9f0df89c0a5$exports = {};
|
|
290
295
|
|
|
291
|
-
$parcel$export($
|
|
292
|
-
const $
|
|
293
|
-
function $
|
|
294
|
-
let count = $
|
|
296
|
+
$parcel$export($453cc9f0df89c0a5$exports, "getItemCount", () => $453cc9f0df89c0a5$export$77d5aafae4e095b2);
|
|
297
|
+
const $453cc9f0df89c0a5$var$cache = new WeakMap();
|
|
298
|
+
function $453cc9f0df89c0a5$export$77d5aafae4e095b2(collection) {
|
|
299
|
+
let count = $453cc9f0df89c0a5$var$cache.get(collection);
|
|
295
300
|
if (count != null) return count;
|
|
296
301
|
count = 0;
|
|
297
|
-
for (let item of collection)if (item.type === 'section') count += $
|
|
302
|
+
for (let item of collection)if (item.type === 'section') count += $453cc9f0df89c0a5$export$77d5aafae4e095b2(item.childNodes);
|
|
298
303
|
else count++;
|
|
299
|
-
$
|
|
304
|
+
$453cc9f0df89c0a5$var$cache.set(collection, count);
|
|
300
305
|
return count;
|
|
301
306
|
}
|
|
302
307
|
|
|
303
308
|
|
|
304
309
|
|
|
305
310
|
|
|
306
|
-
export {$
|
|
311
|
+
export {$c1d7fb2ec91bae71$export$6d08773d2e66f8f2 as Item, $9fc4852771d079eb$export$6e2c8f0811a474ce as Section, $7613b1592d41b092$export$6cd28814d92fa9c9 as useCollection, $453cc9f0df89c0a5$export$77d5aafae4e095b2 as getItemCount};
|
|
307
312
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;SCgBS,0BAAI,CAAI,KAAmB,EAAgB,CAAC;IACnD,MAAM,CAAC,IAAI;AACb,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AAM,CAAC,KAAK;AACd,CAAC;","sources":["packages/@react-stately/collections/src/index.ts","packages/@react-stately/collections/src/Item.ts","packages/@react-stately/collections/src/Section.ts","packages/@react-stately/collections/src/types.ts","packages/@react-stately/collections/src/useCollection.ts","packages/@react-stately/collections/src/CollectionBuilder.ts","packages/@react-stately/collections/src/getItemCount.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './Item';\nexport * from './Section';\nexport * from './types';\nexport * from './useCollection';\nexport * from './getItemCount';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>, context: any): Generator<PartialNode<T>> {\n let {childItems, title, children} = props;\n\n let rendered = props.title || props.children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.\n if (!textValue && !context?.suppressTextValueWarning) {\n console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n }\n\n yield {\n type: 'item',\n props: props,\n rendered,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: hasChildItems(props),\n *childNodes() {\n if (childItems) {\n for (let child of childItems) {\n yield {\n type: 'item',\n value: child\n };\n }\n } else if (title) {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child as ItemElement<T>\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n if (props.hasChildItems != null) {\n return props.hasChildItems;\n }\n\n if (props.childItems) {\n return true;\n }\n\n if (props.title && React.Children.count(props.children) > 0) {\n return true;\n }\n\n return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n let {children, title, items} = props;\n yield {\n type: 'section',\n hasChildNodes: true,\n rendered: title,\n 'aria-label': props['aria-label'],\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n \n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemRenderer} from '@react-types/shared';\nimport {Key, ReactElement, ReactNode} from 'react';\n\nexport interface PartialNode<T> {\n type?: string,\n key?: Key,\n value?: T,\n element?: ReactElement,\n wrapper?: (element: ReactElement) => ReactElement,\n rendered?: ReactNode,\n textValue?: string,\n 'aria-label'?: string,\n index?: number,\n renderer?: ItemRenderer<T>,\n hasChildNodes?: boolean,\n childNodes?: () => IterableIterator<PartialNode<T>>,\n props?: any,\n shouldInvalidate?: (context: unknown) => boolean\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;SCgBS,0BAAI,CAAI,KAAmB,EAAgB,CAAC;IACnD,MAAM,CAAC,IAAI;AACb,CAAC;AAED,0BAAI,CAAC,iBAAiB,GAAG,QAAQ,EAAE,iBAAiB,CAAI,KAAmB,EAAE,OAAY,EAA6B,CAAC;IACrH,GAAG,CAAC,CAAC,aAAA,UAAU,UAAE,KAAK,aAAE,QAAQ,EAAA,CAAC,GAAG,KAAK;IAEzC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,QAAQ;IAC5C,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,QAAQ,KAAK,CAAQ,UAAG,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AAC,KAAK,CAAC,CAAC;AAC3C,CAAC;;;;SDxOe,yCAAa,CAAwE,KAAwB,EAAE,OAAgC,EAAE,OAAiB,EAAE,YAAwB,GAAG,CAAC,CAAC,EAAK,CAAC;IACrN,GAAG,CAAC,OAAO,GAAG,cAAO,KAAO,GAAG,CAAC,yCAAiB;MAAO,CAAC,CAAC;IAE1D,GAAG,CAAC,IAAI,GAAG,aAAM,CAAI,IAAI;IACzB,MAAM,CAAC,cAAO,KAAO,CAAC;QACpB,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO;QAC1C,MAAM,CAAC,IAAI,CAAC,OAAO;IACrB,EAAsE,AAAtE,oEAAsE;IACtE,EAAuD,AAAvD,qDAAuD;IACvD,CAAC,EAAE,CAAC;QAAA,OAAO;QAAE,KAAK,CAAC,QAAQ;QAAE,KAAK,CAAC,KAAK;QAAE,OAAO;WAAK,YAAY;IAAA,CAAC;AACrE,CAAC;;;;;;AEfD,KAAK,CAAC,2BAAK,GAAG,GAAG,CAAC,OAAO;SAET,yCAAY,CAAI,UAA6B,EAAU,CAAC;IACtE,GAAG,CAAC,KAAK,GAAG,2BAAK,CAAC,GAAG,CAAC,UAAU;IAChC,EAAE,EAAE,KAAK,IAAI,IAAI,EACf,MAAM,CAAC,KAAK;IAGd,KAAK,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,UAAU,CACzB,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,CAAS,UACzB,KAAK,IAAI,yCAAY,CAAC,IAAI,CAAC,UAAU;SAErC,KAAK;IAIT,2BAAK,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK;IAC3B,MAAM,CAAC,KAAK;AACd,CAAC;","sources":["packages/@react-stately/collections/src/index.ts","packages/@react-stately/collections/src/Item.ts","packages/@react-stately/collections/src/Section.ts","packages/@react-stately/collections/src/types.ts","packages/@react-stately/collections/src/useCollection.ts","packages/@react-stately/collections/src/CollectionBuilder.ts","packages/@react-stately/collections/src/getItemCount.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './Item';\nexport * from './Section';\nexport * from './types';\nexport * from './useCollection';\nexport * from './getItemCount';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>, context: any): Generator<PartialNode<T>> {\n let {childItems, title, children} = props;\n\n let rendered = props.title || props.children;\n let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.\n if (!textValue && !context?.suppressTextValueWarning) {\n console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n }\n\n yield {\n type: 'item',\n props: props,\n rendered,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: hasChildItems(props),\n *childNodes() {\n if (childItems) {\n for (let child of childItems) {\n yield {\n type: 'item',\n value: child\n };\n }\n } else if (title) {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child as ItemElement<T>\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n if (props.hasChildItems != null) {\n return props.hasChildItems;\n }\n\n if (props.childItems) {\n return true;\n }\n\n if (props.title && React.Children.count(props.children) > 0) {\n return true;\n }\n\n return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n let {children, title, items} = props;\n yield {\n type: 'section',\n hasChildNodes: true,\n rendered: title,\n 'aria-label': props['aria-label'],\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n \n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n items.push({\n type: 'item',\n element: child\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemRenderer} from '@react-types/shared';\nimport {Key, ReactElement, ReactNode} from 'react';\n\nexport interface PartialNode<T> {\n type?: string,\n key?: Key,\n value?: T,\n element?: ReactElement,\n wrapper?: (element: ReactElement) => ReactElement,\n rendered?: ReactNode,\n textValue?: string,\n 'aria-label'?: string,\n index?: number,\n renderer?: ItemRenderer<T>,\n hasChildNodes?: boolean,\n childNodes?: () => IterableIterator<PartialNode<T>>,\n props?: any,\n shouldInvalidate?: (context: unknown) => boolean\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n // TODO: Remove this line entirely and enforce that users always provide unique keys.\n // Currently this line will have issues when a parent has a key `a` and a child with key `bc`\n // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both\n // children having a key of `abc`.\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/collections",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.8",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-types/shared": "^3.
|
|
21
|
+
"@react-types/shared": "^3.12.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "6a503b715e0dbbf92038cd7f08b1bcdde4c78e82"
|
|
30
30
|
}
|
package/src/CollectionBuilder.ts
CHANGED
|
@@ -188,6 +188,10 @@ export class CollectionBuilder<T extends object> {
|
|
|
188
188
|
for (let child of partialNode.childNodes()) {
|
|
189
189
|
// Ensure child keys are globally unique by prepending the parent node's key
|
|
190
190
|
if (child.key != null) {
|
|
191
|
+
// TODO: Remove this line entirely and enforce that users always provide unique keys.
|
|
192
|
+
// Currently this line will have issues when a parent has a key `a` and a child with key `bc`
|
|
193
|
+
// but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
|
|
194
|
+
// children having a key of `abc`.
|
|
191
195
|
child.key = `${node.key}${child.key}`;
|
|
192
196
|
}
|
|
193
197
|
|