@react-stately/collections 3.4.4 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +117 -58
- package/dist/main.js.map +1 -1
- package/dist/module.js +117 -58
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Section.ts +1 -0
package/dist/main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var $4aZkW$react = require("react");
|
|
2
|
+
var $4aZkW$swchelperslib_define_propertyjs = require("@swc/helpers/lib/_define_property.js");
|
|
2
3
|
|
|
3
4
|
function $parcel$export(e, n, v, s) {
|
|
4
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
@@ -11,33 +12,53 @@ $parcel$export(module.exports, "Item", () => $c870f3b549c61b6b$export$6d08773d2e
|
|
|
11
12
|
$parcel$export(module.exports, "Section", () => $350f13aa4d8b327c$export$6e2c8f0811a474ce);
|
|
12
13
|
$parcel$export(module.exports, "useCollection", () => $98fc0fafaca75b6a$export$6cd28814d92fa9c9);
|
|
13
14
|
$parcel$export(module.exports, "getItemCount", () => $e749fe52977fe2c2$export$77d5aafae4e095b2);
|
|
14
|
-
|
|
15
|
+
/*
|
|
16
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
17
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
+
* governing permissions and limitations under the License.
|
|
25
|
+
*/ /*
|
|
26
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
27
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
29
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
32
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
33
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
34
|
+
* governing permissions and limitations under the License.
|
|
35
|
+
*/
|
|
15
36
|
function $c870f3b549c61b6b$var$Item(props) {
|
|
16
37
|
return null;
|
|
17
38
|
}
|
|
18
39
|
$c870f3b549c61b6b$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
19
40
|
let { childItems: childItems , title: title , children: children } = props;
|
|
20
41
|
let rendered = props.title || props.children;
|
|
21
|
-
let textValue = props.textValue || (typeof rendered ===
|
|
42
|
+
let textValue = props.textValue || (typeof rendered === "string" ? rendered : "") || props["aria-label"] || "";
|
|
22
43
|
// suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
|
|
23
|
-
if (!textValue && !(context === null || context === void 0 ? void 0 : context.suppressTextValueWarning)) console.warn(
|
|
44
|
+
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.");
|
|
24
45
|
yield {
|
|
25
|
-
type:
|
|
46
|
+
type: "item",
|
|
26
47
|
props: props,
|
|
27
48
|
rendered: rendered,
|
|
28
49
|
textValue: textValue,
|
|
29
|
-
|
|
50
|
+
"aria-label": props["aria-label"],
|
|
30
51
|
hasChildNodes: $c870f3b549c61b6b$var$hasChildItems(props),
|
|
31
52
|
*childNodes () {
|
|
32
|
-
if (childItems) for (let
|
|
33
|
-
type:
|
|
34
|
-
value:
|
|
53
|
+
if (childItems) for (let child of childItems)yield {
|
|
54
|
+
type: "item",
|
|
55
|
+
value: child
|
|
35
56
|
};
|
|
36
57
|
else if (title) {
|
|
37
58
|
let items = [];
|
|
38
|
-
($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
|
|
59
|
+
(0, ($parcel$interopDefault($4aZkW$react))).Children.forEach(children, (child)=>{
|
|
39
60
|
items.push({
|
|
40
|
-
type:
|
|
61
|
+
type: "item",
|
|
41
62
|
element: child
|
|
42
63
|
});
|
|
43
64
|
});
|
|
@@ -49,41 +70,52 @@ $c870f3b549c61b6b$var$Item.getCollectionNode = function* getCollectionNode(props
|
|
|
49
70
|
function $c870f3b549c61b6b$var$hasChildItems(props) {
|
|
50
71
|
if (props.hasChildItems != null) return props.hasChildItems;
|
|
51
72
|
if (props.childItems) return true;
|
|
52
|
-
if (props.title && ($parcel$interopDefault($4aZkW$react)).Children.count(props.children) > 0) return true;
|
|
73
|
+
if (props.title && (0, ($parcel$interopDefault($4aZkW$react))).Children.count(props.children) > 0) return true;
|
|
53
74
|
return false;
|
|
54
75
|
}
|
|
55
76
|
// We don't want getCollectionNode to show up in the type definition
|
|
56
77
|
let $c870f3b549c61b6b$export$6d08773d2e66f8f2 = $c870f3b549c61b6b$var$Item;
|
|
57
78
|
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
/*
|
|
81
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
82
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
83
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
84
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
85
|
+
*
|
|
86
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
87
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
88
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
89
|
+
* governing permissions and limitations under the License.
|
|
90
|
+
*/
|
|
60
91
|
function $350f13aa4d8b327c$var$Section(props) {
|
|
61
92
|
return null;
|
|
62
93
|
}
|
|
63
94
|
$350f13aa4d8b327c$var$Section.getCollectionNode = function* getCollectionNode(props) {
|
|
64
|
-
let { children: children , title: title , items:
|
|
95
|
+
let { children: children , title: title , items: items } = props;
|
|
65
96
|
yield {
|
|
66
|
-
type:
|
|
97
|
+
type: "section",
|
|
98
|
+
props: props,
|
|
67
99
|
hasChildNodes: true,
|
|
68
100
|
rendered: title,
|
|
69
|
-
|
|
101
|
+
"aria-label": props["aria-label"],
|
|
70
102
|
*childNodes () {
|
|
71
|
-
if (typeof children ===
|
|
72
|
-
if (!
|
|
73
|
-
for (let item of
|
|
74
|
-
type:
|
|
103
|
+
if (typeof children === "function") {
|
|
104
|
+
if (!items) throw new Error("props.children was a function but props.items is missing");
|
|
105
|
+
for (let item of items)yield {
|
|
106
|
+
type: "item",
|
|
75
107
|
value: item,
|
|
76
108
|
renderer: children
|
|
77
109
|
};
|
|
78
110
|
} else {
|
|
79
|
-
let
|
|
80
|
-
($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
|
|
81
|
-
|
|
82
|
-
type:
|
|
111
|
+
let items1 = [];
|
|
112
|
+
(0, ($parcel$interopDefault($4aZkW$react))).Children.forEach(children, (child)=>{
|
|
113
|
+
items1.push({
|
|
114
|
+
type: "item",
|
|
83
115
|
element: child
|
|
84
116
|
});
|
|
85
117
|
});
|
|
86
|
-
yield*
|
|
118
|
+
yield* items1;
|
|
87
119
|
}
|
|
88
120
|
}
|
|
89
121
|
};
|
|
@@ -92,34 +124,53 @@ $350f13aa4d8b327c$var$Section.getCollectionNode = function* getCollectionNode(pr
|
|
|
92
124
|
let $350f13aa4d8b327c$export$6e2c8f0811a474ce = $350f13aa4d8b327c$var$Section;
|
|
93
125
|
|
|
94
126
|
|
|
127
|
+
/*
|
|
128
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
129
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
130
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
131
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
132
|
+
*
|
|
133
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
134
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
135
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
136
|
+
* governing permissions and limitations under the License.
|
|
137
|
+
*/ /*
|
|
138
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
139
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
140
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
141
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
142
|
+
*
|
|
143
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
144
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
145
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
146
|
+
* governing permissions and limitations under the License.
|
|
147
|
+
*/
|
|
95
148
|
|
|
96
149
|
class $51588fd411aace25$export$bf788dd355e3a401 {
|
|
97
150
|
build(props, context) {
|
|
98
151
|
this.context = context;
|
|
99
|
-
return $51588fd411aace25$var$iterable(()=>this.iterateCollection(props)
|
|
100
|
-
);
|
|
152
|
+
return $51588fd411aace25$var$iterable(()=>this.iterateCollection(props));
|
|
101
153
|
}
|
|
102
154
|
*iterateCollection(props) {
|
|
103
155
|
let { children: children , items: items } = props;
|
|
104
|
-
if (typeof children ===
|
|
105
|
-
if (!items) throw new Error(
|
|
156
|
+
if (typeof children === "function") {
|
|
157
|
+
if (!items) throw new Error("props.children was a function but props.items is missing");
|
|
106
158
|
for (let item of props.items)yield* this.getFullNode({
|
|
107
159
|
value: item
|
|
108
160
|
}, {
|
|
109
161
|
renderer: children
|
|
110
162
|
});
|
|
111
163
|
} else {
|
|
112
|
-
let
|
|
113
|
-
($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
|
|
114
|
-
|
|
164
|
+
let items1 = [];
|
|
165
|
+
(0, ($parcel$interopDefault($4aZkW$react))).Children.forEach(children, (child)=>{
|
|
166
|
+
items1.push(child);
|
|
115
167
|
});
|
|
116
168
|
let index = 0;
|
|
117
|
-
for (let
|
|
169
|
+
for (let item1 of items1){
|
|
118
170
|
let nodes = this.getFullNode({
|
|
119
|
-
element:
|
|
171
|
+
element: item1,
|
|
120
172
|
index: index
|
|
121
|
-
}, {
|
|
122
|
-
});
|
|
173
|
+
}, {});
|
|
123
174
|
for (let node of nodes){
|
|
124
175
|
index++;
|
|
125
176
|
yield node;
|
|
@@ -129,12 +180,12 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
|
|
|
129
180
|
}
|
|
130
181
|
getKey(item, partialNode, state, parentKey) {
|
|
131
182
|
if (item.key != null) return item.key;
|
|
132
|
-
if (partialNode.type ===
|
|
183
|
+
if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
|
|
133
184
|
let v = partialNode.value;
|
|
134
185
|
if (v != null) {
|
|
135
|
-
var
|
|
136
|
-
let key = (
|
|
137
|
-
if (key == null) throw new Error(
|
|
186
|
+
var _v_key;
|
|
187
|
+
let key = (_v_key = v.key) !== null && _v_key !== void 0 ? _v_key : v.id;
|
|
188
|
+
if (key == null) throw new Error("No key found for item");
|
|
138
189
|
return key;
|
|
139
190
|
}
|
|
140
191
|
return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
|
|
@@ -160,10 +211,10 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
|
|
|
160
211
|
}
|
|
161
212
|
// If there's an element with a getCollectionNode function on its type, then it's a supported component.
|
|
162
213
|
// Call this function to get a partial node, and recursively build a full node from there.
|
|
163
|
-
if (($parcel$interopDefault($4aZkW$react)).isValidElement(element)) {
|
|
214
|
+
if ((0, ($parcel$interopDefault($4aZkW$react))).isValidElement(element)) {
|
|
164
215
|
let type = element.type;
|
|
165
|
-
if (typeof type !==
|
|
166
|
-
let name = typeof element.type ===
|
|
216
|
+
if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
|
|
217
|
+
let name = typeof element.type === "function" ? element.type.name : element.type;
|
|
167
218
|
throw new Error(`Unknown element <${name}> in collection.`);
|
|
168
219
|
}
|
|
169
220
|
let childNodes = type.getCollectionNode(element.props, this.context);
|
|
@@ -201,7 +252,7 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
|
|
|
201
252
|
if (partialNode.key == null) return;
|
|
202
253
|
// Create full node
|
|
203
254
|
let builder = this;
|
|
204
|
-
let
|
|
255
|
+
let node1 = {
|
|
205
256
|
type: partialNode.type,
|
|
206
257
|
props: partialNode.props,
|
|
207
258
|
key: partialNode.key,
|
|
@@ -211,7 +262,7 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
|
|
|
211
262
|
index: partialNode.index,
|
|
212
263
|
rendered: partialNode.rendered,
|
|
213
264
|
textValue: partialNode.textValue,
|
|
214
|
-
|
|
265
|
+
"aria-label": partialNode["aria-label"],
|
|
215
266
|
wrapper: partialNode.wrapper,
|
|
216
267
|
shouldInvalidate: partialNode.shouldInvalidate,
|
|
217
268
|
hasChildNodes: partialNode.hasChildNodes,
|
|
@@ -224,20 +275,20 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
|
|
|
224
275
|
// Currently this line will have issues when a parent has a key `a` and a child with key `bc`
|
|
225
276
|
// but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
|
|
226
277
|
// children having a key of `abc`.
|
|
227
|
-
child.key = `${
|
|
278
|
+
child.key = `${node1.key}${child.key}`;
|
|
228
279
|
child.index = index;
|
|
229
|
-
let nodes = builder.getFullNode(child, builder.getChildState(state, child),
|
|
230
|
-
for (let
|
|
280
|
+
let nodes = builder.getFullNode(child, builder.getChildState(state, child), node1.key, node1);
|
|
281
|
+
for (let node of nodes){
|
|
231
282
|
index++;
|
|
232
|
-
yield
|
|
283
|
+
yield node;
|
|
233
284
|
}
|
|
234
285
|
}
|
|
235
286
|
})
|
|
236
287
|
};
|
|
237
|
-
yield
|
|
288
|
+
yield node1;
|
|
238
289
|
}
|
|
239
290
|
constructor(){
|
|
240
|
-
this
|
|
291
|
+
(0, ($parcel$interopDefault($4aZkW$swchelperslib_define_propertyjs)))(this, "cache", new WeakMap());
|
|
241
292
|
}
|
|
242
293
|
}
|
|
243
294
|
// Wraps an iterator function as an iterable object, and caches the results.
|
|
@@ -256,8 +307,7 @@ function $51588fd411aace25$var$iterable(iterator) {
|
|
|
256
307
|
};
|
|
257
308
|
}
|
|
258
309
|
function $51588fd411aace25$var$compose(outer, inner) {
|
|
259
|
-
if (outer && inner) return (element)=>outer(inner(element))
|
|
260
|
-
;
|
|
310
|
+
if (outer && inner) return (element)=>outer(inner(element));
|
|
261
311
|
if (outer) return outer;
|
|
262
312
|
if (inner) return inner;
|
|
263
313
|
}
|
|
@@ -268,10 +318,9 @@ function $51588fd411aace25$var$capitalize(str) {
|
|
|
268
318
|
|
|
269
319
|
|
|
270
320
|
function $98fc0fafaca75b6a$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
|
|
271
|
-
let builder = $4aZkW$react.useMemo(()=>new $51588fd411aace25$export$bf788dd355e3a401()
|
|
272
|
-
,
|
|
273
|
-
|
|
274
|
-
return $4aZkW$react.useMemo(()=>{
|
|
321
|
+
let builder = (0, $4aZkW$react.useMemo)(()=>new (0, $51588fd411aace25$export$bf788dd355e3a401)(), []);
|
|
322
|
+
let prev = (0, $4aZkW$react.useRef)(null);
|
|
323
|
+
return (0, $4aZkW$react.useMemo)(()=>{
|
|
275
324
|
let nodes = builder.build(props, context);
|
|
276
325
|
prev.current = factory(nodes, prev.current);
|
|
277
326
|
return prev.current;
|
|
@@ -287,12 +336,22 @@ function $98fc0fafaca75b6a$export$6cd28814d92fa9c9(props, factory, context, inva
|
|
|
287
336
|
}
|
|
288
337
|
|
|
289
338
|
|
|
290
|
-
|
|
339
|
+
/*
|
|
340
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
341
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
342
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
343
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
344
|
+
*
|
|
345
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
346
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
347
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
348
|
+
* governing permissions and limitations under the License.
|
|
349
|
+
*/ const $e749fe52977fe2c2$var$cache = new WeakMap();
|
|
291
350
|
function $e749fe52977fe2c2$export$77d5aafae4e095b2(collection) {
|
|
292
351
|
let count = $e749fe52977fe2c2$var$cache.get(collection);
|
|
293
352
|
if (count != null) return count;
|
|
294
353
|
count = 0;
|
|
295
|
-
for (let item of collection)if (item.type ===
|
|
354
|
+
for (let item of collection)if (item.type === "section") count += $e749fe52977fe2c2$export$77d5aafae4e095b2(item.childNodes);
|
|
296
355
|
else count++;
|
|
297
356
|
$e749fe52977fe2c2$var$cache.set(collection, count);
|
|
298
357
|
return count;
|
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,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xOe,yCAAa,CAAwE,KAAwB,EAAE,OAAgC,EAAE,OAAiB,EAAE,YAAwB,GAAG,CAAC,CAAC,EAAK,CAAC;IACrN,GAAG,CAAC,OAAO,GAAG,oBAAO,KAAO,GAAG,CAAC,yCAAiB;MAAO,CAAC,CAAC;IAE1D,GAAG,CAAC,IAAI,GAAG,mBAAM,CAAI,IAAI;IACzB,MAAM,CAAC,oBAAO,KAAO,CAAC;QACpB,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO;QAC1C,MAAM,CAAC,IAAI,CAAC,OAAO;IACrB,EAAsE,AAAtE,oEAAsE;IACtE,EAAuD,AAAvD,qDAAuD;IACvD,CAAC,EAAE,CAAC;QAAA,OAAO;QAAE,KAAK,CAAC,QAAQ;QAAE,KAAK,CAAC,KAAK;QAAE,OAAO;WAAK,YAAY;IAAA,CAAC;AACrE,CAAC;;;AEfD,KAAK,CAAC,2BAAK,GAAG,GAAG,CAAC,OAAO;SAET,yCAAY,CAAI,UAA6B,EAAU,CAAC;IACtE,GAAG,CAAC,KAAK,GAAG,2BAAK,CAAC,GAAG,CAAC,UAAU;IAChC,EAAE,EAAE,KAAK,IAAI,IAAI,EACf,MAAM,CAAC,KAAK;IAGd,KAAK,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,UAAU,CACzB,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,CAAS,UACzB,KAAK,IAAI,yCAAY,CAAC,IAAI,CAAC,UAAU;SAErC,KAAK;IAIT,2BAAK,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK;IAC3B,MAAM,CAAC,KAAK;AACd,CAAC;;","sources":["packages/@react-stately/collections/src/index.ts","packages/@react-stately/collections/src/Item.ts","packages/@react-stately/collections/src/Section.ts","packages/@react-stately/collections/src/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 type {PartialNode} from './types';\nexport {Item} from './Item';\nexport {Section} from './Section';\nexport {useCollection} from './useCollection';\nexport {getItemCount} 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 {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n // TODO: Remove this line entirely and enforce that users always provide unique keys.\n // Currently this line will have issues when a parent has a key `a` and a child with key `bc`\n // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both\n // children having a key of `abc`.\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AAIA,SAAS,2BAAQ,KAAmB,EAAgB;IAClD,OAAO,IAAI;AACb;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY,EAA6B;IACpH,IAAI,cAAC,WAAU,SAAE,MAAK,YAAE,SAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAE,AAAD,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,CAAC,CAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,wBAAwB,AAAD,GACjD,QAAQ,IAAI,CAAC;IAGf,MAAM;QACJ,MAAM;QACN,OAAO;kBACP;mBACA;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe,oCAAc;QAC7B,CAAC,cAAa;YACZ,IAAI,YACF,KAAK,IAAI,SAAS,WAChB,MAAM;gBACJ,MAAM;gBACN,OAAO;YACT;iBAEG,IAAI,OAAO;gBAChB,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAK,AAAD,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA,QAAS;oBACxC,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT,CAAC;QACH;IACF;AACF;AAEA,SAAS,oCAAiB,KAAmB,EAAE;IAC7C,IAAI,MAAM,aAAa,IAAI,IAAI,EAC7B,OAAO,MAAM,aA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AO;AAEX;AAEA,SAAS,iCAAW,GAAW,EAAE;IAC/B,OAAO,GAAG,CAAC,EAAE,CAAC,WAAW,KAAK,IAAI,KAAK,CAAC;AAC1C;;CDhPC,GAED;;AAMO,SAAS,0CAAqF,KAAwB,EAAE,OAAgC,EAAE,OAAiB,EAAE,eAA2B,EAAE,EAAK;IACpN,IAAI,UAAU,CAAA,GAAA,oBAAM,EAAE,IAAM,IAAI,CAAA,GAAA,yCAAiB,AAAD,KAAQ,EAAE;IAE1D,IAAI,OAAO,CAAA,GAAA,mBAAK,EAAK,IAAI;IACzB,OAAO,CAAA,GAAA,oBAAO,AAAD,EAAE,IAAM;QACnB,IAAI,QAAQ,QAAQ,KAAK,CAAC,OAAO;QACjC,KAAK,OAAO,GAAG,QAAQ,OAAO,KAAK,OAAO;QAC1C,OAAO,KAAK,OAAO;IACrB,sEAAsE;IACtE,uDAAuD;IACvD,GAAG;QAAC;QAAS,MAAM,QAAQ;QAAE,MAAM,KAAK;QAAE;WAAY;KAAa;AACrE;;;AE7BA;;;;;;;;;;CAUC,GAED,AAEA,MAAM,8BAAQ,IAAI;AAEX,SAAS,0CAAgB,UAA6B,EAAU;IACrE,IAAI,QAAQ,4BAAM,GAAG,CAAC;IACtB,IAAI,SAAS,IAAI,EACf,OAAO;IAGT,QAAQ;IACR,KAAK,IAAI,QAAQ,WACf,IAAI,KAAK,IAAI,KAAK,WAChB,SAAS,0CAAa,KAAK,UAAU;SAErC;IAIJ,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT;","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/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 type {PartialNode} from './types';\nexport {Item} from './Item';\nexport {Section} from './Section';\nexport {useCollection} from './useCollection';\nexport {getItemCount} 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 props: props,\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 {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n // TODO: Remove this line entirely and enforce that users always provide unique keys.\n // Currently this line will have issues when a parent has a key `a` and a child with key `bc`\n // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both\n // children having a key of `abc`.\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
import $tyW6A$react, {useMemo as $tyW6A$useMemo, useRef as $tyW6A$useRef} from "react";
|
|
2
|
+
import $tyW6A$swchelperssrc_define_propertymjs from "@swc/helpers/src/_define_property.mjs";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ /*
|
|
15
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
+
* governing permissions and limitations under the License.
|
|
24
|
+
*/
|
|
4
25
|
function $c1d7fb2ec91bae71$var$Item(props) {
|
|
5
26
|
return null;
|
|
6
27
|
}
|
|
7
28
|
$c1d7fb2ec91bae71$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
8
29
|
let { childItems: childItems , title: title , children: children } = props;
|
|
9
30
|
let rendered = props.title || props.children;
|
|
10
|
-
let textValue = props.textValue || (typeof rendered ===
|
|
31
|
+
let textValue = props.textValue || (typeof rendered === "string" ? rendered : "") || props["aria-label"] || "";
|
|
11
32
|
// suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
|
|
12
|
-
if (!textValue && !(context === null || context === void 0 ? void 0 : context.suppressTextValueWarning)) console.warn(
|
|
33
|
+
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.");
|
|
13
34
|
yield {
|
|
14
|
-
type:
|
|
35
|
+
type: "item",
|
|
15
36
|
props: props,
|
|
16
37
|
rendered: rendered,
|
|
17
38
|
textValue: textValue,
|
|
18
|
-
|
|
39
|
+
"aria-label": props["aria-label"],
|
|
19
40
|
hasChildNodes: $c1d7fb2ec91bae71$var$hasChildItems(props),
|
|
20
41
|
*childNodes () {
|
|
21
|
-
if (childItems) for (let
|
|
22
|
-
type:
|
|
23
|
-
value:
|
|
42
|
+
if (childItems) for (let child of childItems)yield {
|
|
43
|
+
type: "item",
|
|
44
|
+
value: child
|
|
24
45
|
};
|
|
25
46
|
else if (title) {
|
|
26
47
|
let items = [];
|
|
27
|
-
$tyW6A$react.Children.forEach(children, (child)=>{
|
|
48
|
+
(0, $tyW6A$react).Children.forEach(children, (child)=>{
|
|
28
49
|
items.push({
|
|
29
|
-
type:
|
|
50
|
+
type: "item",
|
|
30
51
|
element: child
|
|
31
52
|
});
|
|
32
53
|
});
|
|
@@ -38,41 +59,52 @@ $c1d7fb2ec91bae71$var$Item.getCollectionNode = function* getCollectionNode(props
|
|
|
38
59
|
function $c1d7fb2ec91bae71$var$hasChildItems(props) {
|
|
39
60
|
if (props.hasChildItems != null) return props.hasChildItems;
|
|
40
61
|
if (props.childItems) return true;
|
|
41
|
-
if (props.title && $tyW6A$react.Children.count(props.children) > 0) return true;
|
|
62
|
+
if (props.title && (0, $tyW6A$react).Children.count(props.children) > 0) return true;
|
|
42
63
|
return false;
|
|
43
64
|
}
|
|
44
65
|
// We don't want getCollectionNode to show up in the type definition
|
|
45
66
|
let $c1d7fb2ec91bae71$export$6d08773d2e66f8f2 = $c1d7fb2ec91bae71$var$Item;
|
|
46
67
|
|
|
47
68
|
|
|
48
|
-
|
|
69
|
+
/*
|
|
70
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
71
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
72
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
73
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
74
|
+
*
|
|
75
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
76
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
77
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
78
|
+
* governing permissions and limitations under the License.
|
|
79
|
+
*/
|
|
49
80
|
function $9fc4852771d079eb$var$Section(props) {
|
|
50
81
|
return null;
|
|
51
82
|
}
|
|
52
83
|
$9fc4852771d079eb$var$Section.getCollectionNode = function* getCollectionNode(props) {
|
|
53
|
-
let { children: children , title: title , items:
|
|
84
|
+
let { children: children , title: title , items: items } = props;
|
|
54
85
|
yield {
|
|
55
|
-
type:
|
|
86
|
+
type: "section",
|
|
87
|
+
props: props,
|
|
56
88
|
hasChildNodes: true,
|
|
57
89
|
rendered: title,
|
|
58
|
-
|
|
90
|
+
"aria-label": props["aria-label"],
|
|
59
91
|
*childNodes () {
|
|
60
|
-
if (typeof children ===
|
|
61
|
-
if (!
|
|
62
|
-
for (let item of
|
|
63
|
-
type:
|
|
92
|
+
if (typeof children === "function") {
|
|
93
|
+
if (!items) throw new Error("props.children was a function but props.items is missing");
|
|
94
|
+
for (let item of items)yield {
|
|
95
|
+
type: "item",
|
|
64
96
|
value: item,
|
|
65
97
|
renderer: children
|
|
66
98
|
};
|
|
67
99
|
} else {
|
|
68
|
-
let
|
|
69
|
-
$tyW6A$react.Children.forEach(children, (child)=>{
|
|
70
|
-
|
|
71
|
-
type:
|
|
100
|
+
let items1 = [];
|
|
101
|
+
(0, $tyW6A$react).Children.forEach(children, (child)=>{
|
|
102
|
+
items1.push({
|
|
103
|
+
type: "item",
|
|
72
104
|
element: child
|
|
73
105
|
});
|
|
74
106
|
});
|
|
75
|
-
yield*
|
|
107
|
+
yield* items1;
|
|
76
108
|
}
|
|
77
109
|
}
|
|
78
110
|
};
|
|
@@ -81,34 +113,53 @@ $9fc4852771d079eb$var$Section.getCollectionNode = function* getCollectionNode(pr
|
|
|
81
113
|
let $9fc4852771d079eb$export$6e2c8f0811a474ce = $9fc4852771d079eb$var$Section;
|
|
82
114
|
|
|
83
115
|
|
|
116
|
+
/*
|
|
117
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
118
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
119
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
120
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
121
|
+
*
|
|
122
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
123
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
124
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
125
|
+
* governing permissions and limitations under the License.
|
|
126
|
+
*/ /*
|
|
127
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
128
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
129
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
130
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
131
|
+
*
|
|
132
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
133
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
134
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
135
|
+
* governing permissions and limitations under the License.
|
|
136
|
+
*/
|
|
84
137
|
|
|
85
138
|
class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
|
|
86
139
|
build(props, context) {
|
|
87
140
|
this.context = context;
|
|
88
|
-
return $eb2240fc39a57fa5$var$iterable(()=>this.iterateCollection(props)
|
|
89
|
-
);
|
|
141
|
+
return $eb2240fc39a57fa5$var$iterable(()=>this.iterateCollection(props));
|
|
90
142
|
}
|
|
91
143
|
*iterateCollection(props) {
|
|
92
144
|
let { children: children , items: items } = props;
|
|
93
|
-
if (typeof children ===
|
|
94
|
-
if (!items) throw new Error(
|
|
145
|
+
if (typeof children === "function") {
|
|
146
|
+
if (!items) throw new Error("props.children was a function but props.items is missing");
|
|
95
147
|
for (let item of props.items)yield* this.getFullNode({
|
|
96
148
|
value: item
|
|
97
149
|
}, {
|
|
98
150
|
renderer: children
|
|
99
151
|
});
|
|
100
152
|
} else {
|
|
101
|
-
let
|
|
102
|
-
$tyW6A$react.Children.forEach(children, (child)=>{
|
|
103
|
-
|
|
153
|
+
let items1 = [];
|
|
154
|
+
(0, $tyW6A$react).Children.forEach(children, (child)=>{
|
|
155
|
+
items1.push(child);
|
|
104
156
|
});
|
|
105
157
|
let index = 0;
|
|
106
|
-
for (let
|
|
158
|
+
for (let item1 of items1){
|
|
107
159
|
let nodes = this.getFullNode({
|
|
108
|
-
element:
|
|
160
|
+
element: item1,
|
|
109
161
|
index: index
|
|
110
|
-
}, {
|
|
111
|
-
});
|
|
162
|
+
}, {});
|
|
112
163
|
for (let node of nodes){
|
|
113
164
|
index++;
|
|
114
165
|
yield node;
|
|
@@ -118,12 +169,12 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
|
|
|
118
169
|
}
|
|
119
170
|
getKey(item, partialNode, state, parentKey) {
|
|
120
171
|
if (item.key != null) return item.key;
|
|
121
|
-
if (partialNode.type ===
|
|
172
|
+
if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
|
|
122
173
|
let v = partialNode.value;
|
|
123
174
|
if (v != null) {
|
|
124
|
-
var
|
|
125
|
-
let key = (
|
|
126
|
-
if (key == null) throw new Error(
|
|
175
|
+
var _v_key;
|
|
176
|
+
let key = (_v_key = v.key) !== null && _v_key !== void 0 ? _v_key : v.id;
|
|
177
|
+
if (key == null) throw new Error("No key found for item");
|
|
127
178
|
return key;
|
|
128
179
|
}
|
|
129
180
|
return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
|
|
@@ -149,10 +200,10 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
|
|
|
149
200
|
}
|
|
150
201
|
// If there's an element with a getCollectionNode function on its type, then it's a supported component.
|
|
151
202
|
// Call this function to get a partial node, and recursively build a full node from there.
|
|
152
|
-
if ($tyW6A$react.isValidElement(element)) {
|
|
203
|
+
if ((0, $tyW6A$react).isValidElement(element)) {
|
|
153
204
|
let type = element.type;
|
|
154
|
-
if (typeof type !==
|
|
155
|
-
let name = typeof element.type ===
|
|
205
|
+
if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
|
|
206
|
+
let name = typeof element.type === "function" ? element.type.name : element.type;
|
|
156
207
|
throw new Error(`Unknown element <${name}> in collection.`);
|
|
157
208
|
}
|
|
158
209
|
let childNodes = type.getCollectionNode(element.props, this.context);
|
|
@@ -190,7 +241,7 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
|
|
|
190
241
|
if (partialNode.key == null) return;
|
|
191
242
|
// Create full node
|
|
192
243
|
let builder = this;
|
|
193
|
-
let
|
|
244
|
+
let node1 = {
|
|
194
245
|
type: partialNode.type,
|
|
195
246
|
props: partialNode.props,
|
|
196
247
|
key: partialNode.key,
|
|
@@ -200,7 +251,7 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
|
|
|
200
251
|
index: partialNode.index,
|
|
201
252
|
rendered: partialNode.rendered,
|
|
202
253
|
textValue: partialNode.textValue,
|
|
203
|
-
|
|
254
|
+
"aria-label": partialNode["aria-label"],
|
|
204
255
|
wrapper: partialNode.wrapper,
|
|
205
256
|
shouldInvalidate: partialNode.shouldInvalidate,
|
|
206
257
|
hasChildNodes: partialNode.hasChildNodes,
|
|
@@ -213,20 +264,20 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
|
|
|
213
264
|
// Currently this line will have issues when a parent has a key `a` and a child with key `bc`
|
|
214
265
|
// but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
|
|
215
266
|
// children having a key of `abc`.
|
|
216
|
-
child.key = `${
|
|
267
|
+
child.key = `${node1.key}${child.key}`;
|
|
217
268
|
child.index = index;
|
|
218
|
-
let nodes = builder.getFullNode(child, builder.getChildState(state, child),
|
|
219
|
-
for (let
|
|
269
|
+
let nodes = builder.getFullNode(child, builder.getChildState(state, child), node1.key, node1);
|
|
270
|
+
for (let node of nodes){
|
|
220
271
|
index++;
|
|
221
|
-
yield
|
|
272
|
+
yield node;
|
|
222
273
|
}
|
|
223
274
|
}
|
|
224
275
|
})
|
|
225
276
|
};
|
|
226
|
-
yield
|
|
277
|
+
yield node1;
|
|
227
278
|
}
|
|
228
279
|
constructor(){
|
|
229
|
-
this
|
|
280
|
+
(0, $tyW6A$swchelperssrc_define_propertymjs)(this, "cache", new WeakMap());
|
|
230
281
|
}
|
|
231
282
|
}
|
|
232
283
|
// Wraps an iterator function as an iterable object, and caches the results.
|
|
@@ -245,8 +296,7 @@ function $eb2240fc39a57fa5$var$iterable(iterator) {
|
|
|
245
296
|
};
|
|
246
297
|
}
|
|
247
298
|
function $eb2240fc39a57fa5$var$compose(outer, inner) {
|
|
248
|
-
if (outer && inner) return (element)=>outer(inner(element))
|
|
249
|
-
;
|
|
299
|
+
if (outer && inner) return (element)=>outer(inner(element));
|
|
250
300
|
if (outer) return outer;
|
|
251
301
|
if (inner) return inner;
|
|
252
302
|
}
|
|
@@ -257,10 +307,9 @@ function $eb2240fc39a57fa5$var$capitalize(str) {
|
|
|
257
307
|
|
|
258
308
|
|
|
259
309
|
function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
|
|
260
|
-
let builder = $tyW6A$useMemo(()=>new $eb2240fc39a57fa5$export$bf788dd355e3a401()
|
|
261
|
-
,
|
|
262
|
-
|
|
263
|
-
return $tyW6A$useMemo(()=>{
|
|
310
|
+
let builder = (0, $tyW6A$useMemo)(()=>new (0, $eb2240fc39a57fa5$export$bf788dd355e3a401)(), []);
|
|
311
|
+
let prev = (0, $tyW6A$useRef)(null);
|
|
312
|
+
return (0, $tyW6A$useMemo)(()=>{
|
|
264
313
|
let nodes = builder.build(props, context);
|
|
265
314
|
prev.current = factory(nodes, prev.current);
|
|
266
315
|
return prev.current;
|
|
@@ -276,12 +325,22 @@ function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context, inva
|
|
|
276
325
|
}
|
|
277
326
|
|
|
278
327
|
|
|
279
|
-
|
|
328
|
+
/*
|
|
329
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
330
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
331
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
332
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
333
|
+
*
|
|
334
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
335
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
336
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
337
|
+
* governing permissions and limitations under the License.
|
|
338
|
+
*/ const $453cc9f0df89c0a5$var$cache = new WeakMap();
|
|
280
339
|
function $453cc9f0df89c0a5$export$77d5aafae4e095b2(collection) {
|
|
281
340
|
let count = $453cc9f0df89c0a5$var$cache.get(collection);
|
|
282
341
|
if (count != null) return count;
|
|
283
342
|
count = 0;
|
|
284
|
-
for (let item of collection)if (item.type ===
|
|
343
|
+
for (let item of collection)if (item.type === "section") count += $453cc9f0df89c0a5$export$77d5aafae4e095b2(item.childNodes);
|
|
285
344
|
else count++;
|
|
286
345
|
$453cc9f0df89c0a5$var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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/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 type {PartialNode} from './types';\nexport {Item} from './Item';\nexport {Section} from './Section';\nexport {useCollection} from './useCollection';\nexport {getItemCount} 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 {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n // TODO: Remove this line entirely and enforce that users always provide unique keys.\n // Currently this line will have issues when a parent has a key `a` and a child with key `bc`\n // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both\n // children having a key of `abc`.\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AAIA,SAAS,2BAAQ,KAAmB,EAAgB;IAClD,OAAO,IAAI;AACb;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY,EAA6B;IACpH,IAAI,cAAC,WAAU,SAAE,MAAK,YAAE,SAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAE,AAAD,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,CAAC,CAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,wBAAwB,AAAD,GAC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B,UAA6B,EAAU;IACrE,IAAI,QAAQ,4BAAM,GAAG,CAAC;IACtB,IAAI,SAAS,IAAI,EACf,OAAO;IAGT,QAAQ;IACR,KAAK,IAAI,QAAQ,WACf,IAAI,KAAK,IAAI,KAAK,WAChB,SAAS,0CAAa,KAAK,UAAU;SAErC;IAIJ,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT;","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/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 type {PartialNode} from './types';\nexport {Item} from './Item';\nexport {Section} from './Section';\nexport {useCollection} from './useCollection';\nexport {getItemCount} 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 props: props,\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 {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n let prev = useRef<C>(null);\n return useMemo(() => {\n let nodes = builder.build(props, context);\n prev.current = factory(nodes, prev.current);\n return prev.current;\n // Don't invalidate when any prop changes, just the two we care about.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n private context?: unknown;\n private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n build(props: CollectionBase<T>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: CollectionBase<T>) {\n let {children, items} = props;\n\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n for (let item of props.items) {\n yield* this.getFullNode({\n value: item\n }, {renderer: children});\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n items.push(child);\n });\n\n let index = 0;\n for (let item of items) {\n let nodes = this.getFullNode({\n element: item,\n index: index\n }, {});\n\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n }\n }\n\n private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n if (item.key != null) {\n return item.key;\n }\n\n if (partialNode.type === 'cell' && partialNode.key != null) {\n return `${parentKey}${partialNode.key}`;\n }\n\n let v = partialNode.value as any;\n if (v != null) {\n let key = v.key ?? v.id;\n if (key == null) {\n throw new Error('No key found for item');\n }\n\n return key;\n }\n\n return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n }\n\n private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n return {\n renderer: partialNode.renderer || state.renderer\n };\n }\n\n private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n // If there's a value instead of an element on the node, and a parent renderer function is available,\n // use it to render an element for the value.\n let element = partialNode.element;\n if (!element && partialNode.value && state && state.renderer) {\n let cached = this.cache.get(partialNode.value);\n if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n cached.index = partialNode.index;\n cached.parentKey = parentNode ? parentNode.key : null;\n yield cached;\n return;\n }\n\n element = state.renderer(partialNode.value);\n }\n\n // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n // Call this function to get a partial node, and recursively build a full node from there.\n if (React.isValidElement(element)) {\n let type = element.type as any;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let name = typeof element.type === 'function' ? element.type.name : element.type;\n throw new Error(`Unknown element <${name}> in collection.`);\n }\n\n let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n let index = partialNode.index;\n let result = childNodes.next();\n while (!result.done && result.value) {\n let childNode = result.value;\n\n partialNode.index = index;\n\n let nodeKey = childNode.key;\n if (!nodeKey) {\n nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n }\n\n let nodes = this.getFullNode({\n ...childNode,\n key: nodeKey,\n index,\n wrapper: compose(partialNode.wrapper, childNode.wrapper)\n }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n let children = [...nodes];\n for (let node of children) {\n // Cache the node based on its value\n node.value = childNode.value || partialNode.value;\n if (node.value) {\n this.cache.set(node.value, node);\n }\n\n // The partial node may have specified a type for the child in order to specify a constraint.\n // Verify that the full node that was built recursively matches this type.\n if (partialNode.type && node.type !== partialNode.type) {\n throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n }\n\n index++;\n yield node;\n }\n\n result = childNodes.next(children);\n }\n\n return;\n }\n\n // Ignore invalid elements\n if (partialNode.key == null) {\n return;\n }\n\n // Create full node\n let builder = this;\n let node: Node<T> = {\n type: partialNode.type,\n props: partialNode.props,\n key: partialNode.key,\n parentKey: parentNode ? parentNode.key : null,\n value: partialNode.value,\n level: parentNode ? parentNode.level + 1 : 0,\n index: partialNode.index,\n rendered: partialNode.rendered,\n textValue: partialNode.textValue,\n 'aria-label': partialNode['aria-label'],\n wrapper: partialNode.wrapper,\n shouldInvalidate: partialNode.shouldInvalidate,\n hasChildNodes: partialNode.hasChildNodes,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes) {\n return;\n }\n\n let index = 0;\n for (let child of partialNode.childNodes()) {\n // Ensure child keys are globally unique by prepending the parent node's key\n if (child.key != null) {\n // TODO: Remove this line entirely and enforce that users always provide unique keys.\n // Currently this line will have issues when a parent has a key `a` and a child with key `bc`\n // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both\n // children having a key of `abc`.\n child.key = `${node.key}${child.key}`;\n }\n\n child.index = index;\n let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n for (let node of nodes) {\n index++;\n yield node;\n }\n }\n })\n };\n\n yield node;\n }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n let cache = [];\n let iterable = null;\n return {\n *[Symbol.iterator]() {\n for (let item of cache) {\n yield item;\n }\n\n if (!iterable) {\n iterable = iterator();\n }\n\n for (let item of iterable) {\n cache.push(item);\n yield item;\n }\n }\n };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n if (outer && inner) {\n return (element) => outer(inner(element));\n }\n\n if (outer) {\n return outer;\n }\n\n if (inner) {\n return inner;\n }\n}\n\nfunction capitalize(str: string) {\n return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n let count = cache.get(collection);\n if (count != null) {\n return count;\n }\n\n count = 0;\n for (let item of collection) {\n if (item.type === 'section') {\n count += getItemCount(item.childNodes);\n } else {\n count++;\n }\n }\n\n cache.set(collection, count);\n return count;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAeA,6BAA6B,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,YAAY,CAAC;IAClD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAA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AY,GAAE,KAAK,CAAC,GAAG,CAAM,GAAG,CAAC,CAWpN;ACbD,6BAA6B,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAiBrE","sources":["packages/@react-stately/collections/src/packages/@react-stately/collections/src/types.ts","packages/@react-stately/collections/src/packages/@react-stately/collections/src/Item.ts","packages/@react-stately/collections/src/packages/@react-stately/collections/src/Section.ts","packages/@react-stately/collections/src/packages/@react-stately/collections/src/CollectionBuilder.ts","packages/@react-stately/collections/src/packages/@react-stately/collections/src/useCollection.ts","packages/@react-stately/collections/src/packages/@react-stately/collections/src/getItemCount.ts","packages/@react-stately/collections/src/packages/@react-stately/collections/src/index.ts","packages/@react-stately/collections/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\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 type {PartialNode} from './types';\nexport {Item} from './Item';\nexport {Section} from './Section';\nexport {useCollection} from './useCollection';\nexport {getItemCount} from './getItemCount';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/collections",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
20
|
+
"@react-types/shared": "^3.16.0",
|
|
21
|
+
"@swc/helpers": "^0.4.14"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
|
|
30
30
|
}
|
package/src/Section.ts
CHANGED