@react-stately/collections 3.5.0 → 3.6.0

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.
@@ -0,0 +1,353 @@
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";
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
+ */
25
+ function $c1d7fb2ec91bae71$var$Item(props) {
26
+ return null;
27
+ }
28
+ $c1d7fb2ec91bae71$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
29
+ let { childItems: childItems , title: title , children: children } = props;
30
+ let rendered = props.title || props.children;
31
+ let textValue = props.textValue || (typeof rendered === "string" ? rendered : "") || props["aria-label"] || "";
32
+ // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.
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.");
34
+ yield {
35
+ type: "item",
36
+ props: props,
37
+ rendered: rendered,
38
+ textValue: textValue,
39
+ "aria-label": props["aria-label"],
40
+ hasChildNodes: $c1d7fb2ec91bae71$var$hasChildItems(props),
41
+ *childNodes () {
42
+ if (childItems) for (let child of childItems)yield {
43
+ type: "item",
44
+ value: child
45
+ };
46
+ else if (title) {
47
+ let items = [];
48
+ (0, $tyW6A$react).Children.forEach(children, (child)=>{
49
+ items.push({
50
+ type: "item",
51
+ element: child
52
+ });
53
+ });
54
+ yield* items;
55
+ }
56
+ }
57
+ };
58
+ };
59
+ function $c1d7fb2ec91bae71$var$hasChildItems(props) {
60
+ if (props.hasChildItems != null) return props.hasChildItems;
61
+ if (props.childItems) return true;
62
+ if (props.title && (0, $tyW6A$react).Children.count(props.children) > 0) return true;
63
+ return false;
64
+ }
65
+ // We don't want getCollectionNode to show up in the type definition
66
+ let $c1d7fb2ec91bae71$export$6d08773d2e66f8f2 = $c1d7fb2ec91bae71$var$Item;
67
+
68
+
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
+ */
80
+ function $9fc4852771d079eb$var$Section(props) {
81
+ return null;
82
+ }
83
+ $9fc4852771d079eb$var$Section.getCollectionNode = function* getCollectionNode(props) {
84
+ let { children: children , title: title , items: items } = props;
85
+ yield {
86
+ type: "section",
87
+ props: props,
88
+ hasChildNodes: true,
89
+ rendered: title,
90
+ "aria-label": props["aria-label"],
91
+ *childNodes () {
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",
96
+ value: item,
97
+ renderer: children
98
+ };
99
+ } else {
100
+ let items1 = [];
101
+ (0, $tyW6A$react).Children.forEach(children, (child)=>{
102
+ items1.push({
103
+ type: "item",
104
+ element: child
105
+ });
106
+ });
107
+ yield* items1;
108
+ }
109
+ }
110
+ };
111
+ };
112
+ // We don't want getCollectionNode to show up in the type definition
113
+ let $9fc4852771d079eb$export$6e2c8f0811a474ce = $9fc4852771d079eb$var$Section;
114
+
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
+ */
137
+
138
+ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
139
+ build(props, context) {
140
+ this.context = context;
141
+ return $eb2240fc39a57fa5$var$iterable(()=>this.iterateCollection(props));
142
+ }
143
+ *iterateCollection(props) {
144
+ let { children: children , items: items } = props;
145
+ if (typeof children === "function") {
146
+ if (!items) throw new Error("props.children was a function but props.items is missing");
147
+ for (let item of props.items)yield* this.getFullNode({
148
+ value: item
149
+ }, {
150
+ renderer: children
151
+ });
152
+ } else {
153
+ let items1 = [];
154
+ (0, $tyW6A$react).Children.forEach(children, (child)=>{
155
+ items1.push(child);
156
+ });
157
+ let index = 0;
158
+ for (let item1 of items1){
159
+ let nodes = this.getFullNode({
160
+ element: item1,
161
+ index: index
162
+ }, {});
163
+ for (let node of nodes){
164
+ index++;
165
+ yield node;
166
+ }
167
+ }
168
+ }
169
+ }
170
+ getKey(item, partialNode, state, parentKey) {
171
+ if (item.key != null) return item.key;
172
+ if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
173
+ let v = partialNode.value;
174
+ if (v != null) {
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");
178
+ return key;
179
+ }
180
+ return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
181
+ }
182
+ getChildState(state, partialNode) {
183
+ return {
184
+ renderer: partialNode.renderer || state.renderer
185
+ };
186
+ }
187
+ *getFullNode(partialNode, state, parentKey, parentNode) {
188
+ // If there's a value instead of an element on the node, and a parent renderer function is available,
189
+ // use it to render an element for the value.
190
+ let element = partialNode.element;
191
+ if (!element && partialNode.value && state && state.renderer) {
192
+ let cached = this.cache.get(partialNode.value);
193
+ if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {
194
+ cached.index = partialNode.index;
195
+ cached.parentKey = parentNode ? parentNode.key : null;
196
+ yield cached;
197
+ return;
198
+ }
199
+ element = state.renderer(partialNode.value);
200
+ }
201
+ // If there's an element with a getCollectionNode function on its type, then it's a supported component.
202
+ // Call this function to get a partial node, and recursively build a full node from there.
203
+ if ((0, $tyW6A$react).isValidElement(element)) {
204
+ let type = element.type;
205
+ if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
206
+ let name = typeof element.type === "function" ? element.type.name : element.type;
207
+ throw new Error(`Unknown element <${name}> in collection.`);
208
+ }
209
+ let childNodes = type.getCollectionNode(element.props, this.context);
210
+ let index = partialNode.index;
211
+ let result = childNodes.next();
212
+ while(!result.done && result.value){
213
+ let childNode = result.value;
214
+ partialNode.index = index;
215
+ let nodeKey = childNode.key;
216
+ if (!nodeKey) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
217
+ let nodes = this.getFullNode({
218
+ ...childNode,
219
+ key: nodeKey,
220
+ index: index,
221
+ wrapper: $eb2240fc39a57fa5$var$compose(partialNode.wrapper, childNode.wrapper)
222
+ }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
223
+ let children = [
224
+ ...nodes
225
+ ];
226
+ for (let node of children){
227
+ // Cache the node based on its value
228
+ node.value = childNode.value || partialNode.value;
229
+ if (node.value) this.cache.set(node.value, node);
230
+ // The partial node may have specified a type for the child in order to specify a constraint.
231
+ // Verify that the full node that was built recursively matches this type.
232
+ if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$eb2240fc39a57fa5$var$capitalize(node.type)}> in <${$eb2240fc39a57fa5$var$capitalize(parentNode.type)}>. Only <${$eb2240fc39a57fa5$var$capitalize(partialNode.type)}> is supported.`);
233
+ index++;
234
+ yield node;
235
+ }
236
+ result = childNodes.next(children);
237
+ }
238
+ return;
239
+ }
240
+ // Ignore invalid elements
241
+ if (partialNode.key == null) return;
242
+ // Create full node
243
+ let builder = this;
244
+ let node1 = {
245
+ type: partialNode.type,
246
+ props: partialNode.props,
247
+ key: partialNode.key,
248
+ parentKey: parentNode ? parentNode.key : null,
249
+ value: partialNode.value,
250
+ level: parentNode ? parentNode.level + 1 : 0,
251
+ index: partialNode.index,
252
+ rendered: partialNode.rendered,
253
+ textValue: partialNode.textValue,
254
+ "aria-label": partialNode["aria-label"],
255
+ wrapper: partialNode.wrapper,
256
+ shouldInvalidate: partialNode.shouldInvalidate,
257
+ hasChildNodes: partialNode.hasChildNodes,
258
+ childNodes: $eb2240fc39a57fa5$var$iterable(function*() {
259
+ if (!partialNode.hasChildNodes) return;
260
+ let index = 0;
261
+ for (let child of partialNode.childNodes()){
262
+ // Ensure child keys are globally unique by prepending the parent node's key
263
+ if (child.key != null) // TODO: Remove this line entirely and enforce that users always provide unique keys.
264
+ // Currently this line will have issues when a parent has a key `a` and a child with key `bc`
265
+ // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
266
+ // children having a key of `abc`.
267
+ child.key = `${node1.key}${child.key}`;
268
+ child.index = index;
269
+ let nodes = builder.getFullNode(child, builder.getChildState(state, child), node1.key, node1);
270
+ for (let node of nodes){
271
+ index++;
272
+ yield node;
273
+ }
274
+ }
275
+ })
276
+ };
277
+ yield node1;
278
+ }
279
+ constructor(){
280
+ (0, $tyW6A$swchelperssrc_define_propertymjs)(this, "cache", new WeakMap());
281
+ }
282
+ }
283
+ // Wraps an iterator function as an iterable object, and caches the results.
284
+ function $eb2240fc39a57fa5$var$iterable(iterator) {
285
+ let cache = [];
286
+ let iterable = null;
287
+ return {
288
+ *[Symbol.iterator] () {
289
+ for (let item of cache)yield item;
290
+ if (!iterable) iterable = iterator();
291
+ for (let item1 of iterable){
292
+ cache.push(item1);
293
+ yield item1;
294
+ }
295
+ }
296
+ };
297
+ }
298
+ function $eb2240fc39a57fa5$var$compose(outer, inner) {
299
+ if (outer && inner) return (element)=>outer(inner(element));
300
+ if (outer) return outer;
301
+ if (inner) return inner;
302
+ }
303
+ function $eb2240fc39a57fa5$var$capitalize(str) {
304
+ return str[0].toUpperCase() + str.slice(1);
305
+ }
306
+
307
+
308
+
309
+ function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
310
+ let builder = (0, $tyW6A$useMemo)(()=>new (0, $eb2240fc39a57fa5$export$bf788dd355e3a401)(), []);
311
+ let prev = (0, $tyW6A$useRef)(null);
312
+ return (0, $tyW6A$useMemo)(()=>{
313
+ let nodes = builder.build(props, context);
314
+ prev.current = factory(nodes, prev.current);
315
+ return prev.current;
316
+ // Don't invalidate when any prop changes, just the two we care about.
317
+ // eslint-disable-next-line react-hooks/exhaustive-deps
318
+ }, [
319
+ builder,
320
+ props.children,
321
+ props.items,
322
+ context,
323
+ ...invalidators
324
+ ]);
325
+ }
326
+
327
+
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();
339
+ function $453cc9f0df89c0a5$export$77d5aafae4e095b2(collection) {
340
+ let count = $453cc9f0df89c0a5$var$cache.get(collection);
341
+ if (count != null) return count;
342
+ count = 0;
343
+ for (let item of collection)if (item.type === "section") count += $453cc9f0df89c0a5$export$77d5aafae4e095b2(item.childNodes);
344
+ else count++;
345
+ $453cc9f0df89c0a5$var$cache.set(collection, count);
346
+ return count;
347
+ }
348
+
349
+
350
+
351
+
352
+ export {$c1d7fb2ec91bae71$export$6d08773d2e66f8f2 as Item, $9fc4852771d079eb$export$6e2c8f0811a474ce as Section, $7613b1592d41b092$export$6cd28814d92fa9c9 as useCollection, $453cc9f0df89c0a5$export$77d5aafae4e095b2 as getItemCount};
353
+ //# sourceMappingURL=module.js.map
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 === 'string' ? rendered : '') || props['aria-label'] || '';
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('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');
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: 'item',
46
+ type: "item",
26
47
  props: props,
27
48
  rendered: rendered,
28
49
  textValue: textValue,
29
- 'aria-label': props['aria-label'],
50
+ "aria-label": props["aria-label"],
30
51
  hasChildNodes: $c870f3b549c61b6b$var$hasChildItems(props),
31
52
  *childNodes () {
32
- if (childItems) for (let child1 of childItems)yield {
33
- type: 'item',
34
- value: child1
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: 'item',
61
+ type: "item",
41
62
  element: child
42
63
  });
43
64
  });
@@ -49,42 +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: items1 } = props;
95
+ let { children: children , title: title , items: items } = props;
65
96
  yield {
66
- type: 'section',
97
+ type: "section",
67
98
  props: props,
68
99
  hasChildNodes: true,
69
100
  rendered: title,
70
- 'aria-label': props['aria-label'],
101
+ "aria-label": props["aria-label"],
71
102
  *childNodes () {
72
- if (typeof children === 'function') {
73
- if (!items1) throw new Error('props.children was a function but props.items is missing');
74
- for (let item of items1)yield {
75
- type: 'item',
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",
76
107
  value: item,
77
108
  renderer: children
78
109
  };
79
110
  } else {
80
- let items = [];
81
- ($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
82
- items.push({
83
- type: 'item',
111
+ let items1 = [];
112
+ (0, ($parcel$interopDefault($4aZkW$react))).Children.forEach(children, (child)=>{
113
+ items1.push({
114
+ type: "item",
84
115
  element: child
85
116
  });
86
117
  });
87
- yield* items;
118
+ yield* items1;
88
119
  }
89
120
  }
90
121
  };
@@ -93,34 +124,53 @@ $350f13aa4d8b327c$var$Section.getCollectionNode = function* getCollectionNode(pr
93
124
  let $350f13aa4d8b327c$export$6e2c8f0811a474ce = $350f13aa4d8b327c$var$Section;
94
125
 
95
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
+ */
96
148
 
97
149
  class $51588fd411aace25$export$bf788dd355e3a401 {
98
150
  build(props, context) {
99
151
  this.context = context;
100
- return $51588fd411aace25$var$iterable(()=>this.iterateCollection(props)
101
- );
152
+ return $51588fd411aace25$var$iterable(()=>this.iterateCollection(props));
102
153
  }
103
154
  *iterateCollection(props) {
104
155
  let { children: children , items: items } = props;
105
- if (typeof children === 'function') {
106
- if (!items) throw new Error('props.children was a function but props.items is missing');
156
+ if (typeof children === "function") {
157
+ if (!items) throw new Error("props.children was a function but props.items is missing");
107
158
  for (let item of props.items)yield* this.getFullNode({
108
159
  value: item
109
160
  }, {
110
161
  renderer: children
111
162
  });
112
163
  } else {
113
- let items = [];
114
- ($parcel$interopDefault($4aZkW$react)).Children.forEach(children, (child)=>{
115
- items.push(child);
164
+ let items1 = [];
165
+ (0, ($parcel$interopDefault($4aZkW$react))).Children.forEach(children, (child)=>{
166
+ items1.push(child);
116
167
  });
117
168
  let index = 0;
118
- for (let item of items){
169
+ for (let item1 of items1){
119
170
  let nodes = this.getFullNode({
120
- element: item,
171
+ element: item1,
121
172
  index: index
122
- }, {
123
- });
173
+ }, {});
124
174
  for (let node of nodes){
125
175
  index++;
126
176
  yield node;
@@ -130,12 +180,12 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
130
180
  }
131
181
  getKey(item, partialNode, state, parentKey) {
132
182
  if (item.key != null) return item.key;
133
- if (partialNode.type === 'cell' && partialNode.key != null) return `${parentKey}${partialNode.key}`;
183
+ if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
134
184
  let v = partialNode.value;
135
185
  if (v != null) {
136
- var _key;
137
- let key = (_key = v.key) !== null && _key !== void 0 ? _key : v.id;
138
- if (key == null) throw new Error('No key found for item');
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");
139
189
  return key;
140
190
  }
141
191
  return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
@@ -161,10 +211,10 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
161
211
  }
162
212
  // If there's an element with a getCollectionNode function on its type, then it's a supported component.
163
213
  // Call this function to get a partial node, and recursively build a full node from there.
164
- if (($parcel$interopDefault($4aZkW$react)).isValidElement(element)) {
214
+ if ((0, ($parcel$interopDefault($4aZkW$react))).isValidElement(element)) {
165
215
  let type = element.type;
166
- if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {
167
- let name = typeof element.type === 'function' ? element.type.name : element.type;
216
+ if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
217
+ let name = typeof element.type === "function" ? element.type.name : element.type;
168
218
  throw new Error(`Unknown element <${name}> in collection.`);
169
219
  }
170
220
  let childNodes = type.getCollectionNode(element.props, this.context);
@@ -202,7 +252,7 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
202
252
  if (partialNode.key == null) return;
203
253
  // Create full node
204
254
  let builder = this;
205
- let node = {
255
+ let node1 = {
206
256
  type: partialNode.type,
207
257
  props: partialNode.props,
208
258
  key: partialNode.key,
@@ -212,7 +262,7 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
212
262
  index: partialNode.index,
213
263
  rendered: partialNode.rendered,
214
264
  textValue: partialNode.textValue,
215
- 'aria-label': partialNode['aria-label'],
265
+ "aria-label": partialNode["aria-label"],
216
266
  wrapper: partialNode.wrapper,
217
267
  shouldInvalidate: partialNode.shouldInvalidate,
218
268
  hasChildNodes: partialNode.hasChildNodes,
@@ -225,20 +275,20 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
225
275
  // Currently this line will have issues when a parent has a key `a` and a child with key `bc`
226
276
  // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
227
277
  // children having a key of `abc`.
228
- child.key = `${node.key}${child.key}`;
278
+ child.key = `${node1.key}${child.key}`;
229
279
  child.index = index;
230
- let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
231
- for (let node1 of nodes){
280
+ let nodes = builder.getFullNode(child, builder.getChildState(state, child), node1.key, node1);
281
+ for (let node of nodes){
232
282
  index++;
233
- yield node1;
283
+ yield node;
234
284
  }
235
285
  }
236
286
  })
237
287
  };
238
- yield node;
288
+ yield node1;
239
289
  }
240
290
  constructor(){
241
- this.cache = new WeakMap();
291
+ (0, ($parcel$interopDefault($4aZkW$swchelperslib_define_propertyjs)))(this, "cache", new WeakMap());
242
292
  }
243
293
  }
244
294
  // Wraps an iterator function as an iterable object, and caches the results.
@@ -257,8 +307,7 @@ function $51588fd411aace25$var$iterable(iterator) {
257
307
  };
258
308
  }
259
309
  function $51588fd411aace25$var$compose(outer, inner) {
260
- if (outer && inner) return (element)=>outer(inner(element))
261
- ;
310
+ if (outer && inner) return (element)=>outer(inner(element));
262
311
  if (outer) return outer;
263
312
  if (inner) return inner;
264
313
  }
@@ -269,10 +318,9 @@ function $51588fd411aace25$var$capitalize(str) {
269
318
 
270
319
 
271
320
  function $98fc0fafaca75b6a$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
272
- let builder = $4aZkW$react.useMemo(()=>new $51588fd411aace25$export$bf788dd355e3a401()
273
- , []);
274
- let prev = $4aZkW$react.useRef(null);
275
- 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)(()=>{
276
324
  let nodes = builder.build(props, context);
277
325
  prev.current = factory(nodes, prev.current);
278
326
  return prev.current;
@@ -288,12 +336,22 @@ function $98fc0fafaca75b6a$export$6cd28814d92fa9c9(props, factory, context, inva
288
336
  }
289
337
 
290
338
 
291
- const $e749fe52977fe2c2$var$cache = new WeakMap();
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();
292
350
  function $e749fe52977fe2c2$export$77d5aafae4e095b2(collection) {
293
351
  let count = $e749fe52977fe2c2$var$cache.get(collection);
294
352
  if (count != null) return count;
295
353
  count = 0;
296
- for (let item of collection)if (item.type === 'section') count += $e749fe52977fe2c2$export$77d5aafae4e095b2(item.childNodes);
354
+ for (let item of collection)if (item.type === "section") count += $e749fe52977fe2c2$export$77d5aafae4e095b2(item.childNodes);
297
355
  else count++;
298
356
  $e749fe52977fe2c2$var$cache.set(collection, count);
299
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,QA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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 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"}
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,GA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.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 === 'string' ? rendered : '') || props['aria-label'] || '';
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('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');
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: 'item',
35
+ type: "item",
15
36
  props: props,
16
37
  rendered: rendered,
17
38
  textValue: textValue,
18
- 'aria-label': props['aria-label'],
39
+ "aria-label": props["aria-label"],
19
40
  hasChildNodes: $c1d7fb2ec91bae71$var$hasChildItems(props),
20
41
  *childNodes () {
21
- if (childItems) for (let child1 of childItems)yield {
22
- type: 'item',
23
- value: child1
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: 'item',
50
+ type: "item",
30
51
  element: child
31
52
  });
32
53
  });
@@ -38,42 +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: items1 } = props;
84
+ let { children: children , title: title , items: items } = props;
54
85
  yield {
55
- type: 'section',
86
+ type: "section",
56
87
  props: props,
57
88
  hasChildNodes: true,
58
89
  rendered: title,
59
- 'aria-label': props['aria-label'],
90
+ "aria-label": props["aria-label"],
60
91
  *childNodes () {
61
- if (typeof children === 'function') {
62
- if (!items1) throw new Error('props.children was a function but props.items is missing');
63
- for (let item of items1)yield {
64
- type: 'item',
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",
65
96
  value: item,
66
97
  renderer: children
67
98
  };
68
99
  } else {
69
- let items = [];
70
- $tyW6A$react.Children.forEach(children, (child)=>{
71
- items.push({
72
- type: 'item',
100
+ let items1 = [];
101
+ (0, $tyW6A$react).Children.forEach(children, (child)=>{
102
+ items1.push({
103
+ type: "item",
73
104
  element: child
74
105
  });
75
106
  });
76
- yield* items;
107
+ yield* items1;
77
108
  }
78
109
  }
79
110
  };
@@ -82,34 +113,53 @@ $9fc4852771d079eb$var$Section.getCollectionNode = function* getCollectionNode(pr
82
113
  let $9fc4852771d079eb$export$6e2c8f0811a474ce = $9fc4852771d079eb$var$Section;
83
114
 
84
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
+ */
85
137
 
86
138
  class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
87
139
  build(props, context) {
88
140
  this.context = context;
89
- return $eb2240fc39a57fa5$var$iterable(()=>this.iterateCollection(props)
90
- );
141
+ return $eb2240fc39a57fa5$var$iterable(()=>this.iterateCollection(props));
91
142
  }
92
143
  *iterateCollection(props) {
93
144
  let { children: children , items: items } = props;
94
- if (typeof children === 'function') {
95
- if (!items) throw new Error('props.children was a function but props.items is missing');
145
+ if (typeof children === "function") {
146
+ if (!items) throw new Error("props.children was a function but props.items is missing");
96
147
  for (let item of props.items)yield* this.getFullNode({
97
148
  value: item
98
149
  }, {
99
150
  renderer: children
100
151
  });
101
152
  } else {
102
- let items = [];
103
- $tyW6A$react.Children.forEach(children, (child)=>{
104
- items.push(child);
153
+ let items1 = [];
154
+ (0, $tyW6A$react).Children.forEach(children, (child)=>{
155
+ items1.push(child);
105
156
  });
106
157
  let index = 0;
107
- for (let item of items){
158
+ for (let item1 of items1){
108
159
  let nodes = this.getFullNode({
109
- element: item,
160
+ element: item1,
110
161
  index: index
111
- }, {
112
- });
162
+ }, {});
113
163
  for (let node of nodes){
114
164
  index++;
115
165
  yield node;
@@ -119,12 +169,12 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
119
169
  }
120
170
  getKey(item, partialNode, state, parentKey) {
121
171
  if (item.key != null) return item.key;
122
- if (partialNode.type === 'cell' && partialNode.key != null) return `${parentKey}${partialNode.key}`;
172
+ if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
123
173
  let v = partialNode.value;
124
174
  if (v != null) {
125
- var _key;
126
- let key = (_key = v.key) !== null && _key !== void 0 ? _key : v.id;
127
- if (key == null) throw new Error('No key found for item');
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");
128
178
  return key;
129
179
  }
130
180
  return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
@@ -150,10 +200,10 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
150
200
  }
151
201
  // If there's an element with a getCollectionNode function on its type, then it's a supported component.
152
202
  // Call this function to get a partial node, and recursively build a full node from there.
153
- if ($tyW6A$react.isValidElement(element)) {
203
+ if ((0, $tyW6A$react).isValidElement(element)) {
154
204
  let type = element.type;
155
- if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {
156
- let name = typeof element.type === 'function' ? element.type.name : element.type;
205
+ if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
206
+ let name = typeof element.type === "function" ? element.type.name : element.type;
157
207
  throw new Error(`Unknown element <${name}> in collection.`);
158
208
  }
159
209
  let childNodes = type.getCollectionNode(element.props, this.context);
@@ -191,7 +241,7 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
191
241
  if (partialNode.key == null) return;
192
242
  // Create full node
193
243
  let builder = this;
194
- let node = {
244
+ let node1 = {
195
245
  type: partialNode.type,
196
246
  props: partialNode.props,
197
247
  key: partialNode.key,
@@ -201,7 +251,7 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
201
251
  index: partialNode.index,
202
252
  rendered: partialNode.rendered,
203
253
  textValue: partialNode.textValue,
204
- 'aria-label': partialNode['aria-label'],
254
+ "aria-label": partialNode["aria-label"],
205
255
  wrapper: partialNode.wrapper,
206
256
  shouldInvalidate: partialNode.shouldInvalidate,
207
257
  hasChildNodes: partialNode.hasChildNodes,
@@ -214,20 +264,20 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
214
264
  // Currently this line will have issues when a parent has a key `a` and a child with key `bc`
215
265
  // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
216
266
  // children having a key of `abc`.
217
- child.key = `${node.key}${child.key}`;
267
+ child.key = `${node1.key}${child.key}`;
218
268
  child.index = index;
219
- let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
220
- for (let node1 of nodes){
269
+ let nodes = builder.getFullNode(child, builder.getChildState(state, child), node1.key, node1);
270
+ for (let node of nodes){
221
271
  index++;
222
- yield node1;
272
+ yield node;
223
273
  }
224
274
  }
225
275
  })
226
276
  };
227
- yield node;
277
+ yield node1;
228
278
  }
229
279
  constructor(){
230
- this.cache = new WeakMap();
280
+ (0, $tyW6A$swchelperssrc_define_propertymjs)(this, "cache", new WeakMap());
231
281
  }
232
282
  }
233
283
  // Wraps an iterator function as an iterable object, and caches the results.
@@ -246,8 +296,7 @@ function $eb2240fc39a57fa5$var$iterable(iterator) {
246
296
  };
247
297
  }
248
298
  function $eb2240fc39a57fa5$var$compose(outer, inner) {
249
- if (outer && inner) return (element)=>outer(inner(element))
250
- ;
299
+ if (outer && inner) return (element)=>outer(inner(element));
251
300
  if (outer) return outer;
252
301
  if (inner) return inner;
253
302
  }
@@ -258,10 +307,9 @@ function $eb2240fc39a57fa5$var$capitalize(str) {
258
307
 
259
308
 
260
309
  function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context, invalidators = []) {
261
- let builder = $tyW6A$useMemo(()=>new $eb2240fc39a57fa5$export$bf788dd355e3a401()
262
- , []);
263
- let prev = $tyW6A$useRef(null);
264
- 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)(()=>{
265
313
  let nodes = builder.build(props, context);
266
314
  prev.current = factory(nodes, prev.current);
267
315
  return prev.current;
@@ -277,12 +325,22 @@ function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context, inva
277
325
  }
278
326
 
279
327
 
280
- const $453cc9f0df89c0a5$var$cache = new WeakMap();
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();
281
339
  function $453cc9f0df89c0a5$export$77d5aafae4e095b2(collection) {
282
340
  let count = $453cc9f0df89c0a5$var$cache.get(collection);
283
341
  if (count != null) return count;
284
342
  count = 0;
285
- for (let item of collection)if (item.type === 'section') count += $453cc9f0df89c0a5$export$77d5aafae4e095b2(item.childNodes);
343
+ for (let item of collection)if (item.type === "section") count += $453cc9f0df89c0a5$export$77d5aafae4e095b2(item.childNodes);
286
344
  else count++;
287
345
  $453cc9f0df89c0a5$var$cache.set(collection, count);
288
346
  return count;
@@ -1 +1 @@
1
- {"mappings":";;;SCgBS,0BAAI,CAAI,KAAmB,EAAgB,CAAC;IACnD,MAAM,CAAC,IAAI;AACb,CAAC;AAED,0BAAI,CAA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AGd,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 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"}
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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S,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/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-stately/collections",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,8 +22,8 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-types/shared": "^3.16.0"
25
+ "@react-types/shared": "^3.17.0",
26
+ "@swc/helpers": "^0.4.14"
22
27
  },
23
28
  "peerDependencies": {
24
29
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -26,5 +31,5 @@
26
31
  "publishConfig": {
27
32
  "access": "public"
28
33
  },
29
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
34
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
30
35
  }