@react-stately/collections 3.10.9 → 3.12.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.
@@ -28,17 +28,26 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
28
28
  }
29
29
  *iterateCollection(props) {
30
30
  let { children: children, items: items } = props;
31
- if (typeof children === 'function') {
31
+ if ((0, ($parcel$interopDefault($ioO2y$react))).isValidElement(children) && children.type === (0, ($parcel$interopDefault($ioO2y$react))).Fragment) yield* this.iterateCollection({
32
+ children: children.props.children,
33
+ items: items
34
+ });
35
+ else if (typeof children === 'function') {
32
36
  if (!items) throw new Error('props.children was a function but props.items is missing');
33
- for (let item of props.items)yield* this.getFullNode({
34
- value: item
35
- }, {
36
- renderer: children
37
- });
37
+ let index = 0;
38
+ for (let item of items){
39
+ yield* this.getFullNode({
40
+ value: item,
41
+ index: index
42
+ }, {
43
+ renderer: children
44
+ });
45
+ index++;
46
+ }
38
47
  } else {
39
48
  let items = [];
40
49
  (0, ($parcel$interopDefault($ioO2y$react))).Children.forEach(children, (child)=>{
41
- items.push(child);
50
+ if (child) items.push(child);
42
51
  });
43
52
  let index = 0;
44
53
  for (let item of items){
@@ -71,6 +80,19 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
71
80
  };
72
81
  }
73
82
  *getFullNode(partialNode, state, parentKey, parentNode) {
83
+ if ((0, ($parcel$interopDefault($ioO2y$react))).isValidElement(partialNode.element) && partialNode.element.type === (0, ($parcel$interopDefault($ioO2y$react))).Fragment) {
84
+ let children = [];
85
+ (0, ($parcel$interopDefault($ioO2y$react))).Children.forEach(partialNode.element.props.children, (child)=>{
86
+ children.push(child);
87
+ });
88
+ var _partialNode_index;
89
+ let index = (_partialNode_index = partialNode.index) !== null && _partialNode_index !== void 0 ? _partialNode_index : 0;
90
+ for (const child of children)yield* this.getFullNode({
91
+ element: child,
92
+ index: index++
93
+ }, state, parentKey, parentNode);
94
+ return;
95
+ }
74
96
  // If there's a value instead of an element on the node, and a parent renderer function is available,
75
97
  // use it to render an element for the value.
76
98
  let element = partialNode.element;
@@ -89,17 +111,19 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
89
111
  if ((0, ($parcel$interopDefault($ioO2y$react))).isValidElement(element)) {
90
112
  let type = element.type;
91
113
  if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {
92
- let name = typeof element.type === 'function' ? element.type.name : element.type;
114
+ let name = element.type;
93
115
  throw new Error(`Unknown element <${name}> in collection.`);
94
116
  }
95
117
  let childNodes = type.getCollectionNode(element.props, this.context);
96
- let index = partialNode.index;
118
+ var _partialNode_index1;
119
+ let index = (_partialNode_index1 = partialNode.index) !== null && _partialNode_index1 !== void 0 ? _partialNode_index1 : 0;
97
120
  let result = childNodes.next();
98
121
  while(!result.done && result.value){
99
122
  let childNode = result.value;
100
123
  partialNode.index = index;
101
- let nodeKey = childNode.key;
102
- if (!nodeKey) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
124
+ var _childNode_key;
125
+ let nodeKey = (_childNode_key = childNode.key) !== null && _childNode_key !== void 0 ? _childNode_key : null;
126
+ if (nodeKey == null) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
103
127
  let nodes = this.getFullNode({
104
128
  ...childNode,
105
129
  key: nodeKey,
@@ -110,12 +134,14 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
110
134
  ...nodes
111
135
  ];
112
136
  for (let node of children){
137
+ var _childNode_value, _ref;
113
138
  // Cache the node based on its value
114
- node.value = childNode.value || partialNode.value;
139
+ node.value = (_ref = (_childNode_value = childNode.value) !== null && _childNode_value !== void 0 ? _childNode_value : partialNode.value) !== null && _ref !== void 0 ? _ref : null;
115
140
  if (node.value) this.cache.set(node.value, node);
141
+ var _parentNode_type;
116
142
  // The partial node may have specified a type for the child in order to specify a constraint.
117
143
  // Verify that the full node that was built recursively matches this type.
118
- if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$51588fd411aace25$var$capitalize(node.type)}> in <${$51588fd411aace25$var$capitalize(parentNode.type)}>. Only <${$51588fd411aace25$var$capitalize(partialNode.type)}> is supported.`);
144
+ if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$51588fd411aace25$var$capitalize(node.type)}> in <${$51588fd411aace25$var$capitalize((_parentNode_type = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) !== null && _parentNode_type !== void 0 ? _parentNode_type : 'unknown parent type')}>. Only <${$51588fd411aace25$var$capitalize(partialNode.type)}> is supported.`);
119
145
  index++;
120
146
  yield node;
121
147
  }
@@ -124,25 +150,26 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
124
150
  return;
125
151
  }
126
152
  // Ignore invalid elements
127
- if (partialNode.key == null) return;
153
+ if (partialNode.key == null || partialNode.type == null) return;
128
154
  // Create full node
129
155
  let builder = this;
156
+ var _partialNode_value, _partialNode_textValue;
130
157
  let node = {
131
158
  type: partialNode.type,
132
159
  props: partialNode.props,
133
160
  key: partialNode.key,
134
161
  parentKey: parentNode ? parentNode.key : null,
135
- value: partialNode.value,
162
+ value: (_partialNode_value = partialNode.value) !== null && _partialNode_value !== void 0 ? _partialNode_value : null,
136
163
  level: parentNode ? parentNode.level + 1 : 0,
137
164
  index: partialNode.index,
138
165
  rendered: partialNode.rendered,
139
- textValue: partialNode.textValue,
166
+ textValue: (_partialNode_textValue = partialNode.textValue) !== null && _partialNode_textValue !== void 0 ? _partialNode_textValue : '',
140
167
  'aria-label': partialNode['aria-label'],
141
168
  wrapper: partialNode.wrapper,
142
169
  shouldInvalidate: partialNode.shouldInvalidate,
143
- hasChildNodes: partialNode.hasChildNodes,
170
+ hasChildNodes: partialNode.hasChildNodes || false,
144
171
  childNodes: $51588fd411aace25$var$iterable(function*() {
145
- if (!partialNode.hasChildNodes) return;
172
+ if (!partialNode.hasChildNodes || !partialNode.childNodes) return;
146
173
  let index = 0;
147
174
  for (let child of partialNode.childNodes()){
148
175
  // Ensure child keys are globally unique by prepending the parent node's key
@@ -151,8 +178,10 @@ class $51588fd411aace25$export$bf788dd355e3a401 {
151
178
  // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
152
179
  // children having a key of `abc`.
153
180
  child.key = `${node.key}${child.key}`;
154
- child.index = index;
155
- let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
181
+ let nodes = builder.getFullNode({
182
+ ...child,
183
+ index: index
184
+ }, builder.getChildState(state, child), node.key, node);
156
185
  for (let node of nodes){
157
186
  index++;
158
187
  yield node;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAIX,MAAM,KAAwB,EAAE,OAAiB,EAAE;QACjD,IAAI,CAAC,OAAO,GAAG;QACf,OAAO,+BAAS,IAAM,IAAI,CAAC,iBAAiB,CAAC;IAC/C;IAEA,CAAS,kBAAkB,KAAwB,EAAE;QACnD,IAAI,YAAC,QAAQ,SAAE,KAAK,EAAC,GAAG;QAExB,IAAI,OAAO,aAAa,YAAY;YAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;YAGlB,KAAK,IAAI,QAAQ,MAAM,KAAK,CAC1B,OAAO,IAAI,CAAC,WAAW,CAAC;gBACtB,OAAO;YACT,GAAG;gBAAC,UAAU;YAAQ;QAE1B,OAAO;YACL,IAAI,QAAgC,EAAE;YACtC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;gBAC/B,MAAM,IAAI,CAAC;YACb;YAEA,IAAI,QAAQ;YACZ,KAAK,IAAI,QAAQ,MAAO;gBACtB,IAAI,QAAQ,IAAI,CAAC,WAAW,CAAC;oBAC3B,SAAS;oBACT,OAAO;gBACT,GAAG,CAAC;gBAEJ,KAAK,IAAI,QAAQ,MAAO;oBACtB;oBACA,MAAM;gBACR;YACF;QACF;IACF;IAEQ,OAAO,IAA0B,EAAE,WAA2B,EAAE,KAA6B,EAAE,SAAe,EAAO;QAC3H,IAAI,KA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C;AAEA,4EAA4E;AAC5E,SAAS,+BAAY,QAAyC;IAC5D,IAAI,QAAQ,EAAE;IACd,IAAI,WAAW;IACf,OAAO;QACL,CAAC,CAAC,OAAO,QAAQ,CAAC;YAChB,KAAK,IAAI,QAAQ,MACf,MAAM;YAGR,IAAI,CAAC,UACH,WAAW;YAGb,KAAK,IAAI,QAAQ,SAAU;gBACzB,MAAM,IAAI,CAAC;gBACX,MAAM;YACR;QACF;IACF;AACF;AAGA,SAAS,8BAAQ,KAAqB,EAAE,KAAqB;IAC3D,IAAI,SAAS,OACX,OAAO,CAAC,UAAY,MAAM,MAAM;IAGlC,IAAI,OACF,OAAO;IAGT,IAAI,OACF,OAAO;AAEX;AAEA,SAAS,iCAAW,GAAW;IAC7B,OAAO,GAAG,CAAC,EAAE,CAAC,WAAW,KAAK,IAAI,KAAK,CAAC;AAC1C","sources":["packages/@react-stately/collections/src/CollectionBuilder.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\nimport {CollectionBase, CollectionElement, Key, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {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"],"names":[],"version":3,"file":"CollectionBuilder.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAcM,MAAM;IAIX,MAAM,KAAiC,EAAE,OAAiB,EAAE;QAC1D,IAAI,CAAC,OAAO,GAAG;QACf,OAAO,+BAAS,IAAM,IAAI,CAAC,iBAAiB,CAAC;IAC/C;IAEA,CAAS,kBAAkB,KAAiC,EAAsB;QAChF,IAAI,YAAC,QAAQ,SAAE,KAAK,EAAC,GAAG;QAExB,IAAI,CAAA,GAAA,sCAAI,EAAE,cAAc,CAAmC,aAAa,SAAS,IAAI,KAAK,CAAA,GAAA,sCAAI,EAAE,QAAQ,EACtG,OAAO,IAAI,CAAC,iBAAiB,CAAC;YAC5B,UAAU,SAAS,KAAK,CAAC,QAAQ;mBACjC;QACF;aACK,IAAI,OAAO,aAAa,YAAY;YACzC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;YAGlB,IAAI,QAAQ;YACZ,KAAK,IAAI,QAAQ,MAAO;gBACtB,OAAO,IAAI,CAAC,WA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6B,IAAI;;AAuN3C;AAEA,4EAA4E;AAC5E,SAAS,+BAAY,QAAyC;IAC5D,IAAI,QAAwB,EAAE;IAC9B,IAAI,WAA6C;IACjD,OAAO;QACL,CAAC,CAAC,OAAO,QAAQ,CAAC;YAChB,KAAK,IAAI,QAAQ,MACf,MAAM;YAGR,IAAI,CAAC,UACH,WAAW;YAGb,KAAK,IAAI,QAAQ,SAAU;gBACzB,MAAM,IAAI,CAAC;gBACX,MAAM;YACR;QACF;IACF;AACF;AAGA,SAAS,8BAAQ,KAAqB,EAAE,KAAqB;IAC3D,IAAI,SAAS,OACX,OAAO,CAAC,UAAY,MAAM,MAAM;IAGlC,IAAI,OACF,OAAO;IAGT,IAAI,OACF,OAAO;AAEX;AAEA,SAAS,iCAAW,GAAW;IAC7B,OAAO,GAAG,CAAC,EAAE,CAAC,WAAW,KAAK,IAAI,KAAK,CAAC;AAC1C","sources":["packages/@react-stately/collections/src/CollectionBuilder.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\nimport {CollectionBase, CollectionElement, Key, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement | null\n}\n\ninterface CollectReactElement<T> extends ReactElement {\n getCollectionNode(props: any, context: any): Generator<PartialNode<T>, void, Node<T>[]>\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: Partial<CollectionBase<T>>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: Partial<CollectionBase<T>>): Generator<Node<T>> {\n let {children, items} = props;\n\n if (React.isValidElement<{children: CollectionElement<T>}>(children) && children.type === React.Fragment) {\n yield* this.iterateCollection({\n children: children.props.children,\n items\n });\n } else if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n let index = 0;\n for (let item of items) {\n yield* this.getFullNode({\n value: item,\n index\n }, {renderer: children});\n index++;\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n if (child) {\n items.push(child);\n }\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: NonNullable<CollectionElement<T>>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key | null): 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> & {index: number}, state: CollectionBuilderState, parentKey?: Key | null, parentNode?: Node<T>): Generator<Node<T>> {\n if (React.isValidElement<{children: CollectionElement<T>}>(partialNode.element) && partialNode.element.type === React.Fragment) {\n let children: CollectionElement<T>[] = [];\n\n React.Children.forEach(partialNode.element.props.children, child => {\n children.push(child);\n });\n\n let index = partialNode.index ?? 0;\n\n for (const child of children) {\n yield* this.getFullNode({\n element: child,\n index: index++\n }, state, parentKey, parentNode);\n }\n\n return;\n }\n\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 unknown as CollectReactElement<T>;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let 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 ?? 0;\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 ?? null;\n if (nodeKey == null) {\n nodeKey = childNode.element ? null : this.getKey(element as NonNullable<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 ?? null;\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 ?? 'unknown parent 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 || partialNode.type == 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 ?? null,\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 || false,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes || !partialNode.childNodes) {\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 let nodes = builder.getFullNode({...child, index}, 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: Array<Node<T>> = [];\n let iterable: null | IterableIterator<Node<T>> = 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 | undefined {\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"],"names":[],"version":3,"file":"CollectionBuilder.main.js.map"}
@@ -18,17 +18,26 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
18
18
  }
19
19
  *iterateCollection(props) {
20
20
  let { children: children, items: items } = props;
21
- if (typeof children === 'function') {
21
+ if ((0, $fzaAv$react).isValidElement(children) && children.type === (0, $fzaAv$react).Fragment) yield* this.iterateCollection({
22
+ children: children.props.children,
23
+ items: items
24
+ });
25
+ else if (typeof children === 'function') {
22
26
  if (!items) throw new Error('props.children was a function but props.items is missing');
23
- for (let item of props.items)yield* this.getFullNode({
24
- value: item
25
- }, {
26
- renderer: children
27
- });
27
+ let index = 0;
28
+ for (let item of items){
29
+ yield* this.getFullNode({
30
+ value: item,
31
+ index: index
32
+ }, {
33
+ renderer: children
34
+ });
35
+ index++;
36
+ }
28
37
  } else {
29
38
  let items = [];
30
39
  (0, $fzaAv$react).Children.forEach(children, (child)=>{
31
- items.push(child);
40
+ if (child) items.push(child);
32
41
  });
33
42
  let index = 0;
34
43
  for (let item of items){
@@ -61,6 +70,19 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
61
70
  };
62
71
  }
63
72
  *getFullNode(partialNode, state, parentKey, parentNode) {
73
+ if ((0, $fzaAv$react).isValidElement(partialNode.element) && partialNode.element.type === (0, $fzaAv$react).Fragment) {
74
+ let children = [];
75
+ (0, $fzaAv$react).Children.forEach(partialNode.element.props.children, (child)=>{
76
+ children.push(child);
77
+ });
78
+ var _partialNode_index;
79
+ let index = (_partialNode_index = partialNode.index) !== null && _partialNode_index !== void 0 ? _partialNode_index : 0;
80
+ for (const child of children)yield* this.getFullNode({
81
+ element: child,
82
+ index: index++
83
+ }, state, parentKey, parentNode);
84
+ return;
85
+ }
64
86
  // If there's a value instead of an element on the node, and a parent renderer function is available,
65
87
  // use it to render an element for the value.
66
88
  let element = partialNode.element;
@@ -79,17 +101,19 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
79
101
  if ((0, $fzaAv$react).isValidElement(element)) {
80
102
  let type = element.type;
81
103
  if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {
82
- let name = typeof element.type === 'function' ? element.type.name : element.type;
104
+ let name = element.type;
83
105
  throw new Error(`Unknown element <${name}> in collection.`);
84
106
  }
85
107
  let childNodes = type.getCollectionNode(element.props, this.context);
86
- let index = partialNode.index;
108
+ var _partialNode_index1;
109
+ let index = (_partialNode_index1 = partialNode.index) !== null && _partialNode_index1 !== void 0 ? _partialNode_index1 : 0;
87
110
  let result = childNodes.next();
88
111
  while(!result.done && result.value){
89
112
  let childNode = result.value;
90
113
  partialNode.index = index;
91
- let nodeKey = childNode.key;
92
- if (!nodeKey) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
114
+ var _childNode_key;
115
+ let nodeKey = (_childNode_key = childNode.key) !== null && _childNode_key !== void 0 ? _childNode_key : null;
116
+ if (nodeKey == null) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
93
117
  let nodes = this.getFullNode({
94
118
  ...childNode,
95
119
  key: nodeKey,
@@ -100,12 +124,14 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
100
124
  ...nodes
101
125
  ];
102
126
  for (let node of children){
127
+ var _childNode_value, _ref;
103
128
  // Cache the node based on its value
104
- node.value = childNode.value || partialNode.value;
129
+ node.value = (_ref = (_childNode_value = childNode.value) !== null && _childNode_value !== void 0 ? _childNode_value : partialNode.value) !== null && _ref !== void 0 ? _ref : null;
105
130
  if (node.value) this.cache.set(node.value, node);
131
+ var _parentNode_type;
106
132
  // The partial node may have specified a type for the child in order to specify a constraint.
107
133
  // Verify that the full node that was built recursively matches this type.
108
- 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.`);
134
+ if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$eb2240fc39a57fa5$var$capitalize(node.type)}> in <${$eb2240fc39a57fa5$var$capitalize((_parentNode_type = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) !== null && _parentNode_type !== void 0 ? _parentNode_type : 'unknown parent type')}>. Only <${$eb2240fc39a57fa5$var$capitalize(partialNode.type)}> is supported.`);
109
135
  index++;
110
136
  yield node;
111
137
  }
@@ -114,25 +140,26 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
114
140
  return;
115
141
  }
116
142
  // Ignore invalid elements
117
- if (partialNode.key == null) return;
143
+ if (partialNode.key == null || partialNode.type == null) return;
118
144
  // Create full node
119
145
  let builder = this;
146
+ var _partialNode_value, _partialNode_textValue;
120
147
  let node = {
121
148
  type: partialNode.type,
122
149
  props: partialNode.props,
123
150
  key: partialNode.key,
124
151
  parentKey: parentNode ? parentNode.key : null,
125
- value: partialNode.value,
152
+ value: (_partialNode_value = partialNode.value) !== null && _partialNode_value !== void 0 ? _partialNode_value : null,
126
153
  level: parentNode ? parentNode.level + 1 : 0,
127
154
  index: partialNode.index,
128
155
  rendered: partialNode.rendered,
129
- textValue: partialNode.textValue,
156
+ textValue: (_partialNode_textValue = partialNode.textValue) !== null && _partialNode_textValue !== void 0 ? _partialNode_textValue : '',
130
157
  'aria-label': partialNode['aria-label'],
131
158
  wrapper: partialNode.wrapper,
132
159
  shouldInvalidate: partialNode.shouldInvalidate,
133
- hasChildNodes: partialNode.hasChildNodes,
160
+ hasChildNodes: partialNode.hasChildNodes || false,
134
161
  childNodes: $eb2240fc39a57fa5$var$iterable(function*() {
135
- if (!partialNode.hasChildNodes) return;
162
+ if (!partialNode.hasChildNodes || !partialNode.childNodes) return;
136
163
  let index = 0;
137
164
  for (let child of partialNode.childNodes()){
138
165
  // Ensure child keys are globally unique by prepending the parent node's key
@@ -141,8 +168,10 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
141
168
  // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
142
169
  // children having a key of `abc`.
143
170
  child.key = `${node.key}${child.key}`;
144
- child.index = index;
145
- let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
171
+ let nodes = builder.getFullNode({
172
+ ...child,
173
+ index: index
174
+ }, builder.getChildState(state, child), node.key, node);
146
175
  for (let node of nodes){
147
176
  index++;
148
177
  yield node;
@@ -18,17 +18,26 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
18
18
  }
19
19
  *iterateCollection(props) {
20
20
  let { children: children, items: items } = props;
21
- if (typeof children === 'function') {
21
+ if ((0, $fzaAv$react).isValidElement(children) && children.type === (0, $fzaAv$react).Fragment) yield* this.iterateCollection({
22
+ children: children.props.children,
23
+ items: items
24
+ });
25
+ else if (typeof children === 'function') {
22
26
  if (!items) throw new Error('props.children was a function but props.items is missing');
23
- for (let item of props.items)yield* this.getFullNode({
24
- value: item
25
- }, {
26
- renderer: children
27
- });
27
+ let index = 0;
28
+ for (let item of items){
29
+ yield* this.getFullNode({
30
+ value: item,
31
+ index: index
32
+ }, {
33
+ renderer: children
34
+ });
35
+ index++;
36
+ }
28
37
  } else {
29
38
  let items = [];
30
39
  (0, $fzaAv$react).Children.forEach(children, (child)=>{
31
- items.push(child);
40
+ if (child) items.push(child);
32
41
  });
33
42
  let index = 0;
34
43
  for (let item of items){
@@ -61,6 +70,19 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
61
70
  };
62
71
  }
63
72
  *getFullNode(partialNode, state, parentKey, parentNode) {
73
+ if ((0, $fzaAv$react).isValidElement(partialNode.element) && partialNode.element.type === (0, $fzaAv$react).Fragment) {
74
+ let children = [];
75
+ (0, $fzaAv$react).Children.forEach(partialNode.element.props.children, (child)=>{
76
+ children.push(child);
77
+ });
78
+ var _partialNode_index;
79
+ let index = (_partialNode_index = partialNode.index) !== null && _partialNode_index !== void 0 ? _partialNode_index : 0;
80
+ for (const child of children)yield* this.getFullNode({
81
+ element: child,
82
+ index: index++
83
+ }, state, parentKey, parentNode);
84
+ return;
85
+ }
64
86
  // If there's a value instead of an element on the node, and a parent renderer function is available,
65
87
  // use it to render an element for the value.
66
88
  let element = partialNode.element;
@@ -79,17 +101,19 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
79
101
  if ((0, $fzaAv$react).isValidElement(element)) {
80
102
  let type = element.type;
81
103
  if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {
82
- let name = typeof element.type === 'function' ? element.type.name : element.type;
104
+ let name = element.type;
83
105
  throw new Error(`Unknown element <${name}> in collection.`);
84
106
  }
85
107
  let childNodes = type.getCollectionNode(element.props, this.context);
86
- let index = partialNode.index;
108
+ var _partialNode_index1;
109
+ let index = (_partialNode_index1 = partialNode.index) !== null && _partialNode_index1 !== void 0 ? _partialNode_index1 : 0;
87
110
  let result = childNodes.next();
88
111
  while(!result.done && result.value){
89
112
  let childNode = result.value;
90
113
  partialNode.index = index;
91
- let nodeKey = childNode.key;
92
- if (!nodeKey) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
114
+ var _childNode_key;
115
+ let nodeKey = (_childNode_key = childNode.key) !== null && _childNode_key !== void 0 ? _childNode_key : null;
116
+ if (nodeKey == null) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
93
117
  let nodes = this.getFullNode({
94
118
  ...childNode,
95
119
  key: nodeKey,
@@ -100,12 +124,14 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
100
124
  ...nodes
101
125
  ];
102
126
  for (let node of children){
127
+ var _childNode_value, _ref;
103
128
  // Cache the node based on its value
104
- node.value = childNode.value || partialNode.value;
129
+ node.value = (_ref = (_childNode_value = childNode.value) !== null && _childNode_value !== void 0 ? _childNode_value : partialNode.value) !== null && _ref !== void 0 ? _ref : null;
105
130
  if (node.value) this.cache.set(node.value, node);
131
+ var _parentNode_type;
106
132
  // The partial node may have specified a type for the child in order to specify a constraint.
107
133
  // Verify that the full node that was built recursively matches this type.
108
- 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.`);
134
+ if (partialNode.type && node.type !== partialNode.type) throw new Error(`Unsupported type <${$eb2240fc39a57fa5$var$capitalize(node.type)}> in <${$eb2240fc39a57fa5$var$capitalize((_parentNode_type = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) !== null && _parentNode_type !== void 0 ? _parentNode_type : 'unknown parent type')}>. Only <${$eb2240fc39a57fa5$var$capitalize(partialNode.type)}> is supported.`);
109
135
  index++;
110
136
  yield node;
111
137
  }
@@ -114,25 +140,26 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
114
140
  return;
115
141
  }
116
142
  // Ignore invalid elements
117
- if (partialNode.key == null) return;
143
+ if (partialNode.key == null || partialNode.type == null) return;
118
144
  // Create full node
119
145
  let builder = this;
146
+ var _partialNode_value, _partialNode_textValue;
120
147
  let node = {
121
148
  type: partialNode.type,
122
149
  props: partialNode.props,
123
150
  key: partialNode.key,
124
151
  parentKey: parentNode ? parentNode.key : null,
125
- value: partialNode.value,
152
+ value: (_partialNode_value = partialNode.value) !== null && _partialNode_value !== void 0 ? _partialNode_value : null,
126
153
  level: parentNode ? parentNode.level + 1 : 0,
127
154
  index: partialNode.index,
128
155
  rendered: partialNode.rendered,
129
- textValue: partialNode.textValue,
156
+ textValue: (_partialNode_textValue = partialNode.textValue) !== null && _partialNode_textValue !== void 0 ? _partialNode_textValue : '',
130
157
  'aria-label': partialNode['aria-label'],
131
158
  wrapper: partialNode.wrapper,
132
159
  shouldInvalidate: partialNode.shouldInvalidate,
133
- hasChildNodes: partialNode.hasChildNodes,
160
+ hasChildNodes: partialNode.hasChildNodes || false,
134
161
  childNodes: $eb2240fc39a57fa5$var$iterable(function*() {
135
- if (!partialNode.hasChildNodes) return;
162
+ if (!partialNode.hasChildNodes || !partialNode.childNodes) return;
136
163
  let index = 0;
137
164
  for (let child of partialNode.childNodes()){
138
165
  // Ensure child keys are globally unique by prepending the parent node's key
@@ -141,8 +168,10 @@ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
141
168
  // but another parent has key `ab` and its child has a key `c`. The combined keys would result in both
142
169
  // children having a key of `abc`.
143
170
  child.key = `${node.key}${child.key}`;
144
- child.index = index;
145
- let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);
171
+ let nodes = builder.getFullNode({
172
+ ...child,
173
+ index: index
174
+ }, builder.getChildState(state, child), node.key, node);
146
175
  for (let node of nodes){
147
176
  index++;
148
177
  yield node;
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAIX,MAAM,KAAwB,EAAE,OAAiB,EAAE;QACjD,IAAI,CAAC,OAAO,GAAG;QACf,OAAO,+BAAS,IAAM,IAAI,CAAC,iBAAiB,CAAC;IAC/C;IAEA,CAAS,kBAAkB,KAAwB,EAAE;QACnD,IAAI,YAAC,QAAQ,SAAE,KAAK,EAAC,GAAG;QAExB,IAAI,OAAO,aAAa,YAAY;YAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;YAGlB,KAAK,IAAI,QAAQ,MAAM,KAAK,CAC1B,OAAO,IAAI,CAAC,WAAW,CAAC;gBACtB,OAAO;YACT,GAAG;gBAAC,UAAU;YAAQ;QAE1B,OAAO;YACL,IAAI,QAAgC,EAAE;YACtC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;gBAC/B,MAAM,IAAI,CAAC;YACb;YAEA,IAAI,QAAQ;YACZ,KAAK,IAAI,QAAQ,MAAO;gBACtB,IAAI,QAAQ,IAAI,CAAC,WAAW,CAAC;oBAC3B,SAAS;oBACT,OAAO;gBACT,GAAG,CAAC;gBAEJ,KAAK,IAAI,QAAQ,MAAO;oBACtB;oBACA,MAAM;gBACR;YACF;QACF;IACF;IAEQ,OAAO,IAA0B,EAAE,WAA2B,EAAE,KAA6B,EAAE,SAAe,EAAO;QAC3H,IAAI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L3C;AAEA,4EAA4E;AAC5E,SAAS,+BAAY,QAAyC;IAC5D,IAAI,QAAQ,EAAE;IACd,IAAI,WAAW;IACf,OAAO;QACL,CAAC,CAAC,OAAO,QAAQ,CAAC;YAChB,KAAK,IAAI,QAAQ,MACf,MAAM;YAGR,IAAI,CAAC,UACH,WAAW;YAGb,KAAK,IAAI,QAAQ,SAAU;gBACzB,MAAM,IAAI,CAAC;gBACX,MAAM;YACR;QACF;IACF;AACF;AAGA,SAAS,8BAAQ,KAAqB,EAAE,KAAqB;IAC3D,IAAI,SAAS,OACX,OAAO,CAAC,UAAY,MAAM,MAAM;IAGlC,IAAI,OACF,OAAO;IAGT,IAAI,OACF,OAAO;AAEX;AAEA,SAAS,iCAAW,GAAW;IAC7B,OAAO,GAAG,CAAC,EAAE,CAAC,WAAW,KAAK,IAAI,KAAK,CAAC;AAC1C","sources":["packages/@react-stately/collections/src/CollectionBuilder.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\nimport {CollectionBase, CollectionElement, Key, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {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"],"names":[],"version":3,"file":"CollectionBuilder.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAcM,MAAM;IAIX,MAAM,KAAiC,EAAE,OAAiB,EAAE;QAC1D,IAAI,CAAC,OAAO,GAAG;QACf,OAAO,+BAAS,IAAM,IAAI,CAAC,iBAAiB,CAAC;IAC/C;IAEA,CAAS,kBAAkB,KAAiC,EAAsB;QAChF,IAAI,YAAC,QAAQ,SAAE,KAAK,EAAC,GAAG;QAExB,IAAI,CAAA,GAAA,YAAI,EAAE,cAAc,CAAmC,aAAa,SAAS,IAAI,KAAK,CAAA,GAAA,YAAI,EAAE,QAAQ,EACtG,OAAO,IAAI,CAAC,iBAAiB,CAAC;YAC5B,UAAU,SAAS,KAAK,CAAC,QAAQ;mBACjC;QACF;aACK,IAAI,OAAO,aAAa,YAAY;YACzC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;YAGlB,IAAI,QAAQ;YACZ,KAAK,IAAI,QAAQ,MAAO;gBACtB,OAAO,IAAI,CAAC,WAAW,CAAC;oB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;AAEA,4EAA4E;AAC5E,SAAS,+BAAY,QAAyC;IAC5D,IAAI,QAAwB,EAAE;IAC9B,IAAI,WAA6C;IACjD,OAAO;QACL,CAAC,CAAC,OAAO,QAAQ,CAAC;YAChB,KAAK,IAAI,QAAQ,MACf,MAAM;YAGR,IAAI,CAAC,UACH,WAAW;YAGb,KAAK,IAAI,QAAQ,SAAU;gBACzB,MAAM,IAAI,CAAC;gBACX,MAAM;YACR;QACF;IACF;AACF;AAGA,SAAS,8BAAQ,KAAqB,EAAE,KAAqB;IAC3D,IAAI,SAAS,OACX,OAAO,CAAC,UAAY,MAAM,MAAM;IAGlC,IAAI,OACF,OAAO;IAGT,IAAI,OACF,OAAO;AAEX;AAEA,SAAS,iCAAW,GAAW;IAC7B,OAAO,GAAG,CAAC,EAAE,CAAC,WAAW,KAAK,IAAI,KAAK,CAAC;AAC1C","sources":["packages/@react-stately/collections/src/CollectionBuilder.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\nimport {CollectionBase, CollectionElement, Key, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n renderer?: (value: any) => ReactElement | null\n}\n\ninterface CollectReactElement<T> extends ReactElement {\n getCollectionNode(props: any, context: any): Generator<PartialNode<T>, void, Node<T>[]>\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: Partial<CollectionBase<T>>, context?: unknown) {\n this.context = context;\n return iterable(() => this.iterateCollection(props));\n }\n\n private *iterateCollection(props: Partial<CollectionBase<T>>): Generator<Node<T>> {\n let {children, items} = props;\n\n if (React.isValidElement<{children: CollectionElement<T>}>(children) && children.type === React.Fragment) {\n yield* this.iterateCollection({\n children: children.props.children,\n items\n });\n } else if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n\n let index = 0;\n for (let item of items) {\n yield* this.getFullNode({\n value: item,\n index\n }, {renderer: children});\n index++;\n }\n } else {\n let items: CollectionElement<T>[] = [];\n React.Children.forEach(children, child => {\n if (child) {\n items.push(child);\n }\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: NonNullable<CollectionElement<T>>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key | null): 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> & {index: number}, state: CollectionBuilderState, parentKey?: Key | null, parentNode?: Node<T>): Generator<Node<T>> {\n if (React.isValidElement<{children: CollectionElement<T>}>(partialNode.element) && partialNode.element.type === React.Fragment) {\n let children: CollectionElement<T>[] = [];\n\n React.Children.forEach(partialNode.element.props.children, child => {\n children.push(child);\n });\n\n let index = partialNode.index ?? 0;\n\n for (const child of children) {\n yield* this.getFullNode({\n element: child,\n index: index++\n }, state, parentKey, parentNode);\n }\n\n return;\n }\n\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 unknown as CollectReactElement<T>;\n if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n let 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 ?? 0;\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 ?? null;\n if (nodeKey == null) {\n nodeKey = childNode.element ? null : this.getKey(element as NonNullable<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 ?? null;\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 ?? 'unknown parent 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 || partialNode.type == 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 ?? null,\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 || false,\n childNodes: iterable(function *() {\n if (!partialNode.hasChildNodes || !partialNode.childNodes) {\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 let nodes = builder.getFullNode({...child, index}, 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: Array<Node<T>> = [];\n let iterable: null | IterableIterator<Node<T>> = 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 | undefined {\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"],"names":[],"version":3,"file":"CollectionBuilder.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,2BAAQ,KAAmB;IAClC,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY;IACvF,IAAI,cAAC,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,EAAC,oBAAA,8BAAA,QAAS,wBAAwB,GAClD,QAAQ,IAAI,CAAC;IAGf,MAAM;QACJ,MAAM;QACN,OAAO;kBACP;mBACA;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe,oCAAc;QAC7B,CAAC;YACC,IAAI,YACF,KAAK,IAAI,SAAS,WAChB,MAAM;gBACJ,MAAM;gBACN,OAAO;YACT;iBAEG,IAAI,OAAO;gBAChB,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,SAAS,oCAAiB,KAAmB;IAC3C,IAAI,MAAM,aAAa,IAAI,MACzB,OAAO,MAAM,aAAa;IAG5B,IAAI,MAAM,UAAU,EAClB,OAAO;IAGT,IAAI,MAAM,KAAK,IAAI,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,IAAI,GACxD,OAAO;IAGT,OAAO;AACT;AAEA,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/collections/src/Item.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\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {JSX, 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"],"names":[],"version":3,"file":"Item.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,2BAAQ,KAAmB;IAClC,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY;IACvF,IAAI,cAAC,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,EAAC,oBAAA,8BAAA,QAAS,wBAAwB,GAClD,QAAQ,IAAI,CAAC;IAGf,MAAM;QACJ,MAAM;QACN,OAAO;kBACP;mBACA;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe,oCAAc;QAC7B,CAAC;YACC,IAAI,YACF,KAAK,IAAI,SAAS,WAChB,MAAM;gBACJ,MAAM;gBACN,OAAO;YACT;iBAEG,IAAI,OAAO;gBAChB,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,SAAS,oCAAiB,KAAmB;IAC3C,IAAI,MAAM,aAAa,IAAI,MACzB,OAAO,MAAM,aAAa;IAG5B,IAAI,MAAM,UAAU,EAClB,OAAO;IAGT,IAAI,MAAM,KAAK,IAAI,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,IAAI,GACxD,OAAO;IAGT,OAAO;AACT;AAEA,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/collections/src/Item.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\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {JSX, ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement | null { // 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"],"names":[],"version":3,"file":"Item.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,2BAAQ,KAAmB;IAClC,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY;IACvF,IAAI,cAAC,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,EAAC,oBAAA,8BAAA,QAAS,wBAAwB,GAClD,QAAQ,IAAI,CAAC;IAGf,MAAM;QACJ,MAAM;QACN,OAAO;kBACP;mBACA;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe,oCAAc;QAC7B,CAAC;YACC,IAAI,YACF,KAAK,IAAI,SAAS,WAChB,MAAM;gBACJ,MAAM;gBACN,OAAO;YACT;iBAEG,IAAI,OAAO;gBAChB,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,SAAS,oCAAiB,KAAmB;IAC3C,IAAI,MAAM,aAAa,IAAI,MACzB,OAAO,MAAM,aAAa;IAG5B,IAAI,MAAM,UAAU,EAClB,OAAO;IAGT,IAAI,MAAM,KAAK,IAAI,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,IAAI,GACxD,OAAO;IAGT,OAAO;AACT;AAEA,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/collections/src/Item.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\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {JSX, 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"],"names":[],"version":3,"file":"Item.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,2BAAQ,KAAmB;IAClC,OAAO;AACT;AAEA,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAmB,EAAE,OAAY;IACvF,IAAI,cAAC,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAC,GAAG;IAEpC,IAAI,WAAW,MAAM,KAAK,IAAI,MAAM,QAAQ;IAC5C,IAAI,YAAY,MAAM,SAAS,IAAK,CAAA,OAAO,aAAa,WAAW,WAAW,EAAC,KAAM,KAAK,CAAC,aAAa,IAAI;IAE5G,qGAAqG;IACrG,IAAI,CAAC,aAAa,EAAC,oBAAA,8BAAA,QAAS,wBAAwB,GAClD,QAAQ,IAAI,CAAC;IAGf,MAAM;QACJ,MAAM;QACN,OAAO;kBACP;mBACA;QACA,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe,oCAAc;QAC7B,CAAC;YACC,IAAI,YACF,KAAK,IAAI,SAAS,WAChB,MAAM;gBACJ,MAAM;gBACN,OAAO;YACT;iBAEG,IAAI,OAAO;gBAChB,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,SAAS,oCAAiB,KAAmB;IAC3C,IAAI,MAAM,aAAa,IAAI,MACzB,OAAO,MAAM,aAAa;IAG5B,IAAI,MAAM,UAAU,EAClB,OAAO;IAGT,IAAI,MAAM,KAAK,IAAI,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,IAAI,GACxD,OAAO;IAGT,OAAO;AACT;AAEA,oEAAoE;AACpE,IAAI,4CAAQ","sources":["packages/@react-stately/collections/src/Item.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\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {JSX, ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement | null { // 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"],"names":[],"version":3,"file":"Item.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,8BAAW,KAAsB;IACxC,OAAO;AACT;AAEA,8BAAQ,iBAAiB,GAAG,UAAU,kBAAqB,KAAsB;IAC/E,IAAI,YAAC,QAAQ,SAAE,KAAK,SAAE,KAAK,EAAC,GAAG;IAC/B,MAAM;QACJ,MAAM;QACN,OAAO;QACP,eAAe;QACf,UAAU;QACV,cAAc,KAAK,CAAC,aAAa;QACjC,CAAC;YACC,IAAI,OAAO,aAAa,YAAY;gBAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;gBAGlB,KAAK,IAAI,QAAQ,MACf,MAAM;oBACJ,MAAM;oBACN,OAAO;oBACP,UAAU;gBACZ;YAEJ,OAAO;gBACL,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,oEAAoE;AACpE,IAAI,4CAAW","sources":["packages/@react-stately/collections/src/Section.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\nimport {PartialNode} from './types';\nimport React, {JSX, 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"],"names":[],"version":3,"file":"Section.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,SAAS,8BAAW,KAAsB;IACxC,OAAO;AACT;AAEA,8BAAQ,iBAAiB,GAAG,UAAU,kBAAqB,KAAsB;IAC/E,IAAI,YAAC,QAAQ,SAAE,KAAK,SAAE,KAAK,EAAC,GAAG;IAC/B,MAAM;QACJ,MAAM;QACN,OAAO;QACP,eAAe;QACf,UAAU;QACV,cAAc,KAAK,CAAC,aAAa;QACjC,CAAC;YACC,IAAI,OAAO,aAAa,YAAY;gBAClC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;gBAGlB,KAAK,IAAI,QAAQ,MACf,MAAM;oBACJ,MAAM;oBACN,OAAO;oBACP,UAAU;gBACZ;YAEJ,OAAO;gBACL,IAAI,QAA0B,EAAE;gBAChC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;oBAC/B,MAAM,IAAI,CAAC;wBACT,MAAM;wBACN,SAAS;oBACX;gBACF;gBAEA,OAAO;YACT;QACF;IACF;AACF;AAEA,oEAAoE;AACpE,IAAI,4CAAW","sources":["packages/@react-stately/collections/src/Section.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\nimport {PartialNode} from './types';\nimport React, {JSX, ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement | null { // 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"],"names":[],"version":3,"file":"Section.main.js.map"}