@react-stately/collections 3.3.5 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +48 -47
- package/dist/main.js.map +1 -1
- package/dist/module.js +44 -43
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var $
|
|
1
|
+
var $dYkgH$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 $142b9cf4f8001539$exports = {};
|
|
26
26
|
|
|
27
|
-
$parcel$export($
|
|
27
|
+
$parcel$export($142b9cf4f8001539$exports, "Item", () => $142b9cf4f8001539$export$6d08773d2e66f8f2);
|
|
28
28
|
|
|
29
|
-
function $
|
|
29
|
+
function $142b9cf4f8001539$var$Item(props) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
|
-
$
|
|
32
|
+
$142b9cf4f8001539$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: $142b9cf4f8001539$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($dYkgH$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 $142b9cf4f8001539$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($dYkgH$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 $142b9cf4f8001539$export$6d08773d2e66f8f2 = $142b9cf4f8001539$var$Item;
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var $
|
|
73
|
+
var $f3d0e3ed1185df8b$exports = {};
|
|
74
74
|
|
|
75
|
-
$parcel$export($
|
|
75
|
+
$parcel$export($f3d0e3ed1185df8b$exports, "Section", () => $f3d0e3ed1185df8b$export$6e2c8f0811a474ce);
|
|
76
76
|
|
|
77
|
-
function $
|
|
77
|
+
function $f3d0e3ed1185df8b$var$Section(props) {
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
|
-
$
|
|
80
|
+
$f3d0e3ed1185df8b$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($dYkgH$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 $f3d0e3ed1185df8b$export$6e2c8f0811a474ce = $f3d0e3ed1185df8b$var$Section;
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
var $
|
|
112
|
+
var $28a3d5356acd329a$exports = {};
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
var $
|
|
115
|
+
var $4093b371372b64e9$exports = {};
|
|
116
116
|
|
|
117
|
-
$parcel$export($
|
|
117
|
+
$parcel$export($4093b371372b64e9$exports, "useCollection", () => $4093b371372b64e9$export$6cd28814d92fa9c9);
|
|
118
118
|
|
|
119
|
-
class $
|
|
119
|
+
class $7e3892142760f002$export$bf788dd355e3a401 {
|
|
120
120
|
build(props, context) {
|
|
121
121
|
this.context = context;
|
|
122
|
-
return $
|
|
122
|
+
return $7e3892142760f002$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($dYkgH$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($dYkgH$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: $7e3892142760f002$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 <${$7e3892142760f002$var$capitalize(node.type)}> in <${$7e3892142760f002$var$capitalize(parentNode.type)}>. Only <${$7e3892142760f002$var$capitalize(partialNode.type)}> is supported.`);
|
|
215
216
|
index++;
|
|
216
217
|
yield node;
|
|
217
218
|
}
|
|
@@ -237,7 +238,7 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
237
238
|
wrapper: partialNode.wrapper,
|
|
238
239
|
shouldInvalidate: partialNode.shouldInvalidate,
|
|
239
240
|
hasChildNodes: partialNode.hasChildNodes,
|
|
240
|
-
childNodes: $
|
|
241
|
+
childNodes: $7e3892142760f002$var$iterable(function*() {
|
|
241
242
|
if (!partialNode.hasChildNodes) return;
|
|
242
243
|
let index = 0;
|
|
243
244
|
for (let child of partialNode.childNodes()){
|
|
@@ -259,7 +260,7 @@ class $99f43427f9c89ffa$export$bf788dd355e3a401 {
|
|
|
259
260
|
}
|
|
260
261
|
}
|
|
261
262
|
// Wraps an iterator function as an iterable object, and caches the results.
|
|
262
|
-
function $
|
|
263
|
+
function $7e3892142760f002$var$iterable(iterator) {
|
|
263
264
|
let cache = [];
|
|
264
265
|
let iterable = null;
|
|
265
266
|
return {
|
|
@@ -273,23 +274,23 @@ function $99f43427f9c89ffa$var$iterable(iterator) {
|
|
|
273
274
|
}
|
|
274
275
|
};
|
|
275
276
|
}
|
|
276
|
-
function $
|
|
277
|
+
function $7e3892142760f002$var$compose(outer, inner) {
|
|
277
278
|
if (outer && inner) return (element)=>outer(inner(element))
|
|
278
279
|
;
|
|
279
280
|
if (outer) return outer;
|
|
280
281
|
if (inner) return inner;
|
|
281
282
|
}
|
|
282
|
-
function $
|
|
283
|
+
function $7e3892142760f002$var$capitalize(str) {
|
|
283
284
|
return str[0].toUpperCase() + str.slice(1);
|
|
284
285
|
}
|
|
285
286
|
|
|
286
287
|
|
|
287
288
|
|
|
288
|
-
function $
|
|
289
|
-
let builder = $
|
|
289
|
+
function $4093b371372b64e9$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
|
|
290
|
+
let builder = $dYkgH$react.useMemo(()=>new $7e3892142760f002$export$bf788dd355e3a401()
|
|
290
291
|
, []);
|
|
291
|
-
let prev = $
|
|
292
|
-
return $
|
|
292
|
+
let prev = $dYkgH$react.useRef(null);
|
|
293
|
+
return $dYkgH$react.useMemo(()=>{
|
|
293
294
|
let nodes = builder.build(props, context);
|
|
294
295
|
prev.current = factory(nodes, prev.current);
|
|
295
296
|
return prev.current;
|
|
@@ -305,26 +306,26 @@ function $df8a726ef7511d2e$export$6cd28814d92fa9c9(props, factory, context, inva
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
|
|
308
|
-
var $
|
|
309
|
+
var $8d44657300ecdb6a$exports = {};
|
|
309
310
|
|
|
310
|
-
$parcel$export($
|
|
311
|
-
const $
|
|
312
|
-
function $
|
|
313
|
-
let count = $
|
|
311
|
+
$parcel$export($8d44657300ecdb6a$exports, "getItemCount", () => $8d44657300ecdb6a$export$77d5aafae4e095b2);
|
|
312
|
+
const $8d44657300ecdb6a$var$cache = new WeakMap();
|
|
313
|
+
function $8d44657300ecdb6a$export$77d5aafae4e095b2(collection) {
|
|
314
|
+
let count = $8d44657300ecdb6a$var$cache.get(collection);
|
|
314
315
|
if (count != null) return count;
|
|
315
316
|
count = 0;
|
|
316
|
-
for (let item of collection)if (item.type === 'section') count += $
|
|
317
|
+
for (let item of collection)if (item.type === 'section') count += $8d44657300ecdb6a$export$77d5aafae4e095b2(item.childNodes);
|
|
317
318
|
else count++;
|
|
318
|
-
$
|
|
319
|
+
$8d44657300ecdb6a$var$cache.set(collection, count);
|
|
319
320
|
return count;
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
|
|
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, $
|
|
324
|
+
$parcel$exportWildcard(module.exports, $142b9cf4f8001539$exports);
|
|
325
|
+
$parcel$exportWildcard(module.exports, $f3d0e3ed1185df8b$exports);
|
|
326
|
+
$parcel$exportWildcard(module.exports, $28a3d5356acd329a$exports);
|
|
327
|
+
$parcel$exportWildcard(module.exports, $4093b371372b64e9$exports);
|
|
328
|
+
$parcel$exportWildcard(module.exports, $8d44657300ecdb6a$exports);
|
|
328
329
|
|
|
329
330
|
|
|
330
331
|
//# 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;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,EAAqG,AAArG,mGAAqG;IACrG,EAAE,GAAG,SAAS,KAAK,OAAO,EAAE,wBAAwB,EAClD,OAAO,CAAC,IAAI,CA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AG,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 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,EAAqG,AAArG,mGAAqG;IACrG,EAAE,GAAG,SAAS,MAAK,OAAO,aAAP,OAAO,KAAP,IAAI,CAAJ,CAAiC,GAAjC,IAAI,CAAJ,CAAiC,GAAjC,OAAO,CAAE,wBAAwB,GAClD,OAAO,CAAC,IAAI,CAAC,CAAwH;UAGjI,CAAC;QACL,IAAI,EAAE,CAAM;QACZ,KAAK,EAAE,KAAK;kBACZ,QAAQ;mBACR,SAAS;QACT,CAAY,aAAE,KAAK,CAAC,CAAY;QAChC,aAAa,EAAE,mCAAa,CAAC,KAAK;SACjC,UAAU,IAAG,CAAC;YACb,EAAE,EAAE,UAAU,EACZ,GAAG,EAAE,GAAG,C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AC,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 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 $dXgez$react, {useMemo as $dXgez$useMemo, useRef as $dXgez$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 $89e587cd0f107a73$exports = {};
|
|
7
7
|
|
|
8
|
-
$parcel$export($
|
|
8
|
+
$parcel$export($89e587cd0f107a73$exports, "Item", () => $89e587cd0f107a73$export$6d08773d2e66f8f2);
|
|
9
9
|
|
|
10
|
-
function $
|
|
10
|
+
function $89e587cd0f107a73$var$Item(props) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
|
-
$
|
|
13
|
+
$89e587cd0f107a73$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: $89e587cd0f107a73$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
|
+
$dXgez$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 $89e587cd0f107a73$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 && $dXgez$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 $89e587cd0f107a73$export$6d08773d2e66f8f2 = $89e587cd0f107a73$var$Item;
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
var $
|
|
54
|
+
var $c8f15027e29c0fc9$exports = {};
|
|
55
55
|
|
|
56
|
-
$parcel$export($
|
|
56
|
+
$parcel$export($c8f15027e29c0fc9$exports, "Section", () => $c8f15027e29c0fc9$export$6e2c8f0811a474ce);
|
|
57
57
|
|
|
58
|
-
function $
|
|
58
|
+
function $c8f15027e29c0fc9$var$Section(props) {
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
|
-
$
|
|
61
|
+
$c8f15027e29c0fc9$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
|
+
$dXgez$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 $c8f15027e29c0fc9$export$6e2c8f0811a474ce = $c8f15027e29c0fc9$var$Section;
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
var $
|
|
93
|
+
var $f2e94723ef6058b9$exports = {};
|
|
94
94
|
|
|
95
95
|
|
|
96
|
-
var $
|
|
96
|
+
var $54e9526d7573190f$exports = {};
|
|
97
97
|
|
|
98
|
-
$parcel$export($
|
|
98
|
+
$parcel$export($54e9526d7573190f$exports, "useCollection", () => $54e9526d7573190f$export$6cd28814d92fa9c9);
|
|
99
99
|
|
|
100
|
-
class $
|
|
100
|
+
class $04d34f0d1495595c$export$bf788dd355e3a401 {
|
|
101
101
|
build(props, context) {
|
|
102
102
|
this.context = context;
|
|
103
|
-
return $
|
|
103
|
+
return $04d34f0d1495595c$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
|
+
$dXgez$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 ($dXgez$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: $04d34f0d1495595c$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 <${$04d34f0d1495595c$var$capitalize(node.type)}> in <${$04d34f0d1495595c$var$capitalize(parentNode.type)}>. Only <${$04d34f0d1495595c$var$capitalize(partialNode.type)}> is supported.`);
|
|
196
197
|
index++;
|
|
197
198
|
yield node;
|
|
198
199
|
}
|
|
@@ -218,7 +219,7 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
218
219
|
wrapper: partialNode.wrapper,
|
|
219
220
|
shouldInvalidate: partialNode.shouldInvalidate,
|
|
220
221
|
hasChildNodes: partialNode.hasChildNodes,
|
|
221
|
-
childNodes: $
|
|
222
|
+
childNodes: $04d34f0d1495595c$var$iterable(function*() {
|
|
222
223
|
if (!partialNode.hasChildNodes) return;
|
|
223
224
|
let index = 0;
|
|
224
225
|
for (let child of partialNode.childNodes()){
|
|
@@ -240,7 +241,7 @@ class $0ef13e8a225e58db$export$bf788dd355e3a401 {
|
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
// Wraps an iterator function as an iterable object, and caches the results.
|
|
243
|
-
function $
|
|
244
|
+
function $04d34f0d1495595c$var$iterable(iterator) {
|
|
244
245
|
let cache = [];
|
|
245
246
|
let iterable = null;
|
|
246
247
|
return {
|
|
@@ -254,23 +255,23 @@ function $0ef13e8a225e58db$var$iterable(iterator) {
|
|
|
254
255
|
}
|
|
255
256
|
};
|
|
256
257
|
}
|
|
257
|
-
function $
|
|
258
|
+
function $04d34f0d1495595c$var$compose(outer, inner) {
|
|
258
259
|
if (outer && inner) return (element)=>outer(inner(element))
|
|
259
260
|
;
|
|
260
261
|
if (outer) return outer;
|
|
261
262
|
if (inner) return inner;
|
|
262
263
|
}
|
|
263
|
-
function $
|
|
264
|
+
function $04d34f0d1495595c$var$capitalize(str) {
|
|
264
265
|
return str[0].toUpperCase() + str.slice(1);
|
|
265
266
|
}
|
|
266
267
|
|
|
267
268
|
|
|
268
269
|
|
|
269
|
-
function $
|
|
270
|
-
let builder = $
|
|
270
|
+
function $54e9526d7573190f$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
|
|
271
|
+
let builder = $dXgez$useMemo(()=>new $04d34f0d1495595c$export$bf788dd355e3a401()
|
|
271
272
|
, []);
|
|
272
|
-
let prev = $
|
|
273
|
-
return $
|
|
273
|
+
let prev = $dXgez$useRef(null);
|
|
274
|
+
return $dXgez$useMemo(()=>{
|
|
274
275
|
let nodes = builder.build(props, context);
|
|
275
276
|
prev.current = factory(nodes, prev.current);
|
|
276
277
|
return prev.current;
|
|
@@ -286,22 +287,22 @@ function $b0e94ff142179e1f$export$6cd28814d92fa9c9(props, factory, context, inva
|
|
|
286
287
|
}
|
|
287
288
|
|
|
288
289
|
|
|
289
|
-
var $
|
|
290
|
+
var $c6b7d36982dcfffc$exports = {};
|
|
290
291
|
|
|
291
|
-
$parcel$export($
|
|
292
|
-
const $
|
|
293
|
-
function $
|
|
294
|
-
let count = $
|
|
292
|
+
$parcel$export($c6b7d36982dcfffc$exports, "getItemCount", () => $c6b7d36982dcfffc$export$77d5aafae4e095b2);
|
|
293
|
+
const $c6b7d36982dcfffc$var$cache = new WeakMap();
|
|
294
|
+
function $c6b7d36982dcfffc$export$77d5aafae4e095b2(collection) {
|
|
295
|
+
let count = $c6b7d36982dcfffc$var$cache.get(collection);
|
|
295
296
|
if (count != null) return count;
|
|
296
297
|
count = 0;
|
|
297
|
-
for (let item of collection)if (item.type === 'section') count += $
|
|
298
|
+
for (let item of collection)if (item.type === 'section') count += $c6b7d36982dcfffc$export$77d5aafae4e095b2(item.childNodes);
|
|
298
299
|
else count++;
|
|
299
|
-
$
|
|
300
|
+
$c6b7d36982dcfffc$var$cache.set(collection, count);
|
|
300
301
|
return count;
|
|
301
302
|
}
|
|
302
303
|
|
|
303
304
|
|
|
304
305
|
|
|
305
306
|
|
|
306
|
-
export {$
|
|
307
|
+
export {$89e587cd0f107a73$export$6d08773d2e66f8f2 as Item, $c8f15027e29c0fc9$export$6e2c8f0811a474ce as Section, $54e9526d7573190f$export$6cd28814d92fa9c9 as useCollection, $c6b7d36982dcfffc$export$77d5aafae4e095b2 as getItemCount};
|
|
307
308
|
//# sourceMappingURL=module.js.map
|
package/dist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AI,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 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,KA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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":"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.6",
|
|
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.11.
|
|
21
|
+
"@react-types/shared": "^3.11.1"
|
|
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": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
|
|
30
30
|
}
|