@react-aria/collections 3.0.0-alpha.1 → 3.0.0-nightly.2988

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/BaseCollection.main.js +157 -0
  3. package/dist/BaseCollection.main.js.map +1 -0
  4. package/dist/BaseCollection.mjs +151 -0
  5. package/dist/BaseCollection.module.js +151 -0
  6. package/dist/BaseCollection.module.js.map +1 -0
  7. package/dist/CollectionBuilder.main.js +233 -0
  8. package/dist/CollectionBuilder.main.js.map +1 -0
  9. package/dist/CollectionBuilder.mjs +221 -0
  10. package/dist/CollectionBuilder.module.js +221 -0
  11. package/dist/CollectionBuilder.module.js.map +1 -0
  12. package/dist/Document.main.js +316 -0
  13. package/dist/Document.main.js.map +1 -0
  14. package/dist/Document.mjs +311 -0
  15. package/dist/Document.module.js +311 -0
  16. package/dist/Document.module.js.map +1 -0
  17. package/dist/Hidden.main.js +79 -0
  18. package/dist/Hidden.main.js.map +1 -0
  19. package/dist/Hidden.mjs +68 -0
  20. package/dist/Hidden.module.js +68 -0
  21. package/dist/Hidden.module.js.map +1 -0
  22. package/dist/import.mjs +23 -0
  23. package/dist/main.js +27 -348
  24. package/dist/main.js.map +1 -0
  25. package/dist/module.js +17 -318
  26. package/dist/module.js.map +1 -0
  27. package/dist/types.d.ts +81 -24
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/useCachedChildren.main.js +63 -0
  30. package/dist/useCachedChildren.main.js.map +1 -0
  31. package/dist/useCachedChildren.mjs +58 -0
  32. package/dist/useCachedChildren.module.js +58 -0
  33. package/dist/useCachedChildren.module.js.map +1 -0
  34. package/package.json +17 -10
  35. package/src/BaseCollection.ts +211 -0
  36. package/src/CollectionBuilder.tsx +237 -0
  37. package/src/Document.ts +453 -0
  38. package/src/Hidden.tsx +84 -0
  39. package/src/index.ts +19 -0
  40. package/src/useCachedChildren.ts +70 -0
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # @react-aria/collections
2
2
 
3
- This package is part of [react-spectrum](https://github.com/adobe-private/react-spectrum-v3). See the repo for more details.
3
+ This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
@@ -0,0 +1,157 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "NodeValue", () => $499e2959ba1abacc$export$f5d856d854e74713);
7
+ $parcel$export(module.exports, "BaseCollection", () => $499e2959ba1abacc$export$408d25a4e12db025);
8
+ /*
9
+ * Copyright 2024 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */ class $499e2959ba1abacc$export$f5d856d854e74713 {
19
+ get childNodes() {
20
+ throw new Error('childNodes is not supported');
21
+ }
22
+ clone() {
23
+ let node = new $499e2959ba1abacc$export$f5d856d854e74713(this.type, this.key);
24
+ node.value = this.value;
25
+ node.level = this.level;
26
+ node.hasChildNodes = this.hasChildNodes;
27
+ node.rendered = this.rendered;
28
+ node.textValue = this.textValue;
29
+ node['aria-label'] = this['aria-label'];
30
+ node.index = this.index;
31
+ node.parentKey = this.parentKey;
32
+ node.prevKey = this.prevKey;
33
+ node.nextKey = this.nextKey;
34
+ node.firstChildKey = this.firstChildKey;
35
+ node.lastChildKey = this.lastChildKey;
36
+ node.props = this.props;
37
+ node.render = this.render;
38
+ return node;
39
+ }
40
+ constructor(type, key){
41
+ this.value = null;
42
+ this.level = 0;
43
+ this.hasChildNodes = false;
44
+ this.rendered = null;
45
+ this.textValue = '';
46
+ this['aria-label'] = undefined;
47
+ this.index = 0;
48
+ this.parentKey = null;
49
+ this.prevKey = null;
50
+ this.nextKey = null;
51
+ this.firstChildKey = null;
52
+ this.lastChildKey = null;
53
+ this.props = {};
54
+ this.type = type;
55
+ this.key = key;
56
+ }
57
+ }
58
+ class $499e2959ba1abacc$export$408d25a4e12db025 {
59
+ get size() {
60
+ return this.keyMap.size;
61
+ }
62
+ getKeys() {
63
+ return this.keyMap.keys();
64
+ }
65
+ *[Symbol.iterator]() {
66
+ let node = this.firstKey != null ? this.keyMap.get(this.firstKey) : undefined;
67
+ while(node){
68
+ yield node;
69
+ node = node.nextKey != null ? this.keyMap.get(node.nextKey) : undefined;
70
+ }
71
+ }
72
+ getChildren(key) {
73
+ let keyMap = this.keyMap;
74
+ return {
75
+ *[Symbol.iterator] () {
76
+ let parent = keyMap.get(key);
77
+ let node = (parent === null || parent === void 0 ? void 0 : parent.firstChildKey) != null ? keyMap.get(parent.firstChildKey) : null;
78
+ while(node){
79
+ yield node;
80
+ node = node.nextKey != null ? keyMap.get(node.nextKey) : undefined;
81
+ }
82
+ }
83
+ };
84
+ }
85
+ getKeyBefore(key) {
86
+ let node = this.keyMap.get(key);
87
+ if (!node) return null;
88
+ if (node.prevKey != null) {
89
+ node = this.keyMap.get(node.prevKey);
90
+ while(node && node.type !== 'item' && node.lastChildKey != null)node = this.keyMap.get(node.lastChildKey);
91
+ var _node_key;
92
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
93
+ }
94
+ return node.parentKey;
95
+ }
96
+ getKeyAfter(key) {
97
+ let node = this.keyMap.get(key);
98
+ if (!node) return null;
99
+ if (node.type !== 'item' && node.firstChildKey != null) return node.firstChildKey;
100
+ while(node){
101
+ if (node.nextKey != null) return node.nextKey;
102
+ if (node.parentKey != null) node = this.keyMap.get(node.parentKey);
103
+ else return null;
104
+ }
105
+ return null;
106
+ }
107
+ getFirstKey() {
108
+ return this.firstKey;
109
+ }
110
+ getLastKey() {
111
+ let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;
112
+ while((node === null || node === void 0 ? void 0 : node.lastChildKey) != null)node = this.keyMap.get(node.lastChildKey);
113
+ var _node_key;
114
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
115
+ }
116
+ getItem(key) {
117
+ var _this_keyMap_get;
118
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
119
+ }
120
+ at() {
121
+ throw new Error('Not implemented');
122
+ }
123
+ clone() {
124
+ // We need to clone using this.constructor so that subclasses have the right prototype.
125
+ // TypeScript isn't happy about this yet.
126
+ // https://github.com/microsoft/TypeScript/issues/3841
127
+ let Constructor = this.constructor;
128
+ let collection = new Constructor();
129
+ collection.keyMap = new Map(this.keyMap);
130
+ collection.firstKey = this.firstKey;
131
+ collection.lastKey = this.lastKey;
132
+ return collection;
133
+ }
134
+ addNode(node) {
135
+ if (this.frozen) throw new Error('Cannot add a node to a frozen collection');
136
+ this.keyMap.set(node.key, node);
137
+ }
138
+ removeNode(key) {
139
+ if (this.frozen) throw new Error('Cannot remove a node to a frozen collection');
140
+ this.keyMap.delete(key);
141
+ }
142
+ commit(firstKey, lastKey, isSSR = false) {
143
+ if (this.frozen) throw new Error('Cannot commit a frozen collection');
144
+ this.firstKey = firstKey;
145
+ this.lastKey = lastKey;
146
+ this.frozen = !isSSR;
147
+ }
148
+ constructor(){
149
+ this.keyMap = new Map();
150
+ this.firstKey = null;
151
+ this.lastKey = null;
152
+ this.frozen = false;
153
+ }
154
+ }
155
+
156
+
157
+ //# sourceMappingURL=BaseCollection.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAUM,MAAM;IAuBX,IAAI,aAAgC;QAClC,MAAM,IAAI,MAAM;IAClB;IAEA,QAAsB;QACpB,IAAI,OAA8B,IA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AoB,EAAE,OAAmB,EAAE,QAAQ,KAAK,EAAE;QAC/D,IAAI,IAAI,CAAC,MAAM,EACb,MAAM,IAAI,MAAM;QAGlB,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,MAAM,GAAG,CAAC;IACjB;;aAxIQ,SAAiC,IAAI;aACrC,WAAuB;aACvB,UAAsB;aACtB,SAAS;;AAsInB","sources":["packages/@react-aria/collections/src/BaseCollection.ts"],"sourcesContent":["/*\n * Copyright 2024 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 as ICollection, Key, Node} from '@react-types/shared';\nimport {ReactElement, ReactNode} from 'react';\n\nexport type Mutable<T> = {\n -readonly[P in keyof T]: T[P]\n}\n\n/** An immutable object representing a Node in a Collection. */\nexport class NodeValue<T> implements Node<T> {\n readonly type: string;\n readonly key: Key;\n readonly value: T | null = null;\n readonly level: number = 0;\n readonly hasChildNodes: boolean = false;\n readonly rendered: ReactNode = null;\n readonly textValue: string = '';\n readonly 'aria-label'?: string = undefined;\n readonly index: number = 0;\n readonly parentKey: Key | null = null;\n readonly prevKey: Key | null = null;\n readonly nextKey: Key | null = null;\n readonly firstChildKey: Key | null = null;\n readonly lastChildKey: Key | null = null;\n readonly props: any = {};\n readonly render?: (node: Node<any>) => ReactElement;\n\n constructor(type: string, key: Key) {\n this.type = type;\n this.key = key;\n }\n\n get childNodes(): Iterable<Node<T>> {\n throw new Error('childNodes is not supported');\n }\n\n clone(): NodeValue<T> {\n let node: Mutable<NodeValue<T>> = new NodeValue(this.type, this.key);\n node.value = this.value;\n node.level = this.level;\n node.hasChildNodes = this.hasChildNodes;\n node.rendered = this.rendered;\n node.textValue = this.textValue;\n node['aria-label'] = this['aria-label'];\n node.index = this.index;\n node.parentKey = this.parentKey;\n node.prevKey = this.prevKey;\n node.nextKey = this.nextKey;\n node.firstChildKey = this.firstChildKey;\n node.lastChildKey = this.lastChildKey;\n node.props = this.props;\n node.render = this.render;\n return node;\n }\n}\n\n/**\n * An immutable Collection implementation. Updates are only allowed\n * when it is not marked as frozen. This can be subclassed to implement\n * custom collection behaviors.\n */\nexport class BaseCollection<T> implements ICollection<Node<T>> {\n private keyMap: Map<Key, NodeValue<T>> = new Map();\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n private frozen = false;\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n *[Symbol.iterator]() {\n let node: Node<T> | undefined = this.firstKey != null ? this.keyMap.get(this.firstKey) : undefined;\n while (node) {\n yield node;\n node = node.nextKey != null ? this.keyMap.get(node.nextKey) : undefined;\n }\n }\n\n getChildren(key: Key): Iterable<Node<T>> {\n let keyMap = this.keyMap;\n return {\n *[Symbol.iterator]() {\n let parent = keyMap.get(key);\n let node = parent?.firstChildKey != null ? keyMap.get(parent.firstChildKey) : null;\n while (node) {\n yield node as Node<T>;\n node = node.nextKey != null ? keyMap.get(node.nextKey) : undefined;\n }\n }\n };\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.prevKey != null) {\n node = this.keyMap.get(node.prevKey);\n\n while (node && node.type !== 'item' && node.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n return node.parentKey;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.type !== 'item' && node.firstChildKey != null) {\n return node.firstChildKey;\n }\n\n while (node) {\n if (node.nextKey != null) {\n return node.nextKey;\n }\n\n if (node.parentKey != null) {\n node = this.keyMap.get(node.parentKey);\n } else {\n return null;\n }\n }\n\n return null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;\n while (node?.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(): Node<T> {\n throw new Error('Not implemented');\n }\n\n clone(): this {\n // We need to clone using this.constructor so that subclasses have the right prototype.\n // TypeScript isn't happy about this yet.\n // https://github.com/microsoft/TypeScript/issues/3841\n let Constructor: any = this.constructor;\n let collection: this = new Constructor();\n collection.keyMap = new Map(this.keyMap);\n collection.firstKey = this.firstKey;\n collection.lastKey = this.lastKey;\n return collection;\n }\n\n addNode(node: NodeValue<T>) {\n if (this.frozen) {\n throw new Error('Cannot add a node to a frozen collection');\n }\n\n this.keyMap.set(node.key, node);\n }\n\n removeNode(key: Key) {\n if (this.frozen) {\n throw new Error('Cannot remove a node to a frozen collection');\n }\n\n this.keyMap.delete(key);\n }\n\n commit(firstKey: Key | null, lastKey: Key | null, isSSR = false) {\n if (this.frozen) {\n throw new Error('Cannot commit a frozen collection');\n }\n\n this.firstKey = firstKey;\n this.lastKey = lastKey;\n this.frozen = !isSSR;\n }\n}\n"],"names":[],"version":3,"file":"BaseCollection.main.js.map"}
@@ -0,0 +1,151 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $23b9f4fcf0fe224b$export$f5d856d854e74713 {
12
+ get childNodes() {
13
+ throw new Error('childNodes is not supported');
14
+ }
15
+ clone() {
16
+ let node = new $23b9f4fcf0fe224b$export$f5d856d854e74713(this.type, this.key);
17
+ node.value = this.value;
18
+ node.level = this.level;
19
+ node.hasChildNodes = this.hasChildNodes;
20
+ node.rendered = this.rendered;
21
+ node.textValue = this.textValue;
22
+ node['aria-label'] = this['aria-label'];
23
+ node.index = this.index;
24
+ node.parentKey = this.parentKey;
25
+ node.prevKey = this.prevKey;
26
+ node.nextKey = this.nextKey;
27
+ node.firstChildKey = this.firstChildKey;
28
+ node.lastChildKey = this.lastChildKey;
29
+ node.props = this.props;
30
+ node.render = this.render;
31
+ return node;
32
+ }
33
+ constructor(type, key){
34
+ this.value = null;
35
+ this.level = 0;
36
+ this.hasChildNodes = false;
37
+ this.rendered = null;
38
+ this.textValue = '';
39
+ this['aria-label'] = undefined;
40
+ this.index = 0;
41
+ this.parentKey = null;
42
+ this.prevKey = null;
43
+ this.nextKey = null;
44
+ this.firstChildKey = null;
45
+ this.lastChildKey = null;
46
+ this.props = {};
47
+ this.type = type;
48
+ this.key = key;
49
+ }
50
+ }
51
+ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
52
+ get size() {
53
+ return this.keyMap.size;
54
+ }
55
+ getKeys() {
56
+ return this.keyMap.keys();
57
+ }
58
+ *[Symbol.iterator]() {
59
+ let node = this.firstKey != null ? this.keyMap.get(this.firstKey) : undefined;
60
+ while(node){
61
+ yield node;
62
+ node = node.nextKey != null ? this.keyMap.get(node.nextKey) : undefined;
63
+ }
64
+ }
65
+ getChildren(key) {
66
+ let keyMap = this.keyMap;
67
+ return {
68
+ *[Symbol.iterator] () {
69
+ let parent = keyMap.get(key);
70
+ let node = (parent === null || parent === void 0 ? void 0 : parent.firstChildKey) != null ? keyMap.get(parent.firstChildKey) : null;
71
+ while(node){
72
+ yield node;
73
+ node = node.nextKey != null ? keyMap.get(node.nextKey) : undefined;
74
+ }
75
+ }
76
+ };
77
+ }
78
+ getKeyBefore(key) {
79
+ let node = this.keyMap.get(key);
80
+ if (!node) return null;
81
+ if (node.prevKey != null) {
82
+ node = this.keyMap.get(node.prevKey);
83
+ while(node && node.type !== 'item' && node.lastChildKey != null)node = this.keyMap.get(node.lastChildKey);
84
+ var _node_key;
85
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
86
+ }
87
+ return node.parentKey;
88
+ }
89
+ getKeyAfter(key) {
90
+ let node = this.keyMap.get(key);
91
+ if (!node) return null;
92
+ if (node.type !== 'item' && node.firstChildKey != null) return node.firstChildKey;
93
+ while(node){
94
+ if (node.nextKey != null) return node.nextKey;
95
+ if (node.parentKey != null) node = this.keyMap.get(node.parentKey);
96
+ else return null;
97
+ }
98
+ return null;
99
+ }
100
+ getFirstKey() {
101
+ return this.firstKey;
102
+ }
103
+ getLastKey() {
104
+ let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;
105
+ while((node === null || node === void 0 ? void 0 : node.lastChildKey) != null)node = this.keyMap.get(node.lastChildKey);
106
+ var _node_key;
107
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
108
+ }
109
+ getItem(key) {
110
+ var _this_keyMap_get;
111
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
112
+ }
113
+ at() {
114
+ throw new Error('Not implemented');
115
+ }
116
+ clone() {
117
+ // We need to clone using this.constructor so that subclasses have the right prototype.
118
+ // TypeScript isn't happy about this yet.
119
+ // https://github.com/microsoft/TypeScript/issues/3841
120
+ let Constructor = this.constructor;
121
+ let collection = new Constructor();
122
+ collection.keyMap = new Map(this.keyMap);
123
+ collection.firstKey = this.firstKey;
124
+ collection.lastKey = this.lastKey;
125
+ return collection;
126
+ }
127
+ addNode(node) {
128
+ if (this.frozen) throw new Error('Cannot add a node to a frozen collection');
129
+ this.keyMap.set(node.key, node);
130
+ }
131
+ removeNode(key) {
132
+ if (this.frozen) throw new Error('Cannot remove a node to a frozen collection');
133
+ this.keyMap.delete(key);
134
+ }
135
+ commit(firstKey, lastKey, isSSR = false) {
136
+ if (this.frozen) throw new Error('Cannot commit a frozen collection');
137
+ this.firstKey = firstKey;
138
+ this.lastKey = lastKey;
139
+ this.frozen = !isSSR;
140
+ }
141
+ constructor(){
142
+ this.keyMap = new Map();
143
+ this.firstKey = null;
144
+ this.lastKey = null;
145
+ this.frozen = false;
146
+ }
147
+ }
148
+
149
+
150
+ export {$23b9f4fcf0fe224b$export$f5d856d854e74713 as NodeValue, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection};
151
+ //# sourceMappingURL=BaseCollection.module.js.map
@@ -0,0 +1,151 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $23b9f4fcf0fe224b$export$f5d856d854e74713 {
12
+ get childNodes() {
13
+ throw new Error('childNodes is not supported');
14
+ }
15
+ clone() {
16
+ let node = new $23b9f4fcf0fe224b$export$f5d856d854e74713(this.type, this.key);
17
+ node.value = this.value;
18
+ node.level = this.level;
19
+ node.hasChildNodes = this.hasChildNodes;
20
+ node.rendered = this.rendered;
21
+ node.textValue = this.textValue;
22
+ node['aria-label'] = this['aria-label'];
23
+ node.index = this.index;
24
+ node.parentKey = this.parentKey;
25
+ node.prevKey = this.prevKey;
26
+ node.nextKey = this.nextKey;
27
+ node.firstChildKey = this.firstChildKey;
28
+ node.lastChildKey = this.lastChildKey;
29
+ node.props = this.props;
30
+ node.render = this.render;
31
+ return node;
32
+ }
33
+ constructor(type, key){
34
+ this.value = null;
35
+ this.level = 0;
36
+ this.hasChildNodes = false;
37
+ this.rendered = null;
38
+ this.textValue = '';
39
+ this['aria-label'] = undefined;
40
+ this.index = 0;
41
+ this.parentKey = null;
42
+ this.prevKey = null;
43
+ this.nextKey = null;
44
+ this.firstChildKey = null;
45
+ this.lastChildKey = null;
46
+ this.props = {};
47
+ this.type = type;
48
+ this.key = key;
49
+ }
50
+ }
51
+ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
52
+ get size() {
53
+ return this.keyMap.size;
54
+ }
55
+ getKeys() {
56
+ return this.keyMap.keys();
57
+ }
58
+ *[Symbol.iterator]() {
59
+ let node = this.firstKey != null ? this.keyMap.get(this.firstKey) : undefined;
60
+ while(node){
61
+ yield node;
62
+ node = node.nextKey != null ? this.keyMap.get(node.nextKey) : undefined;
63
+ }
64
+ }
65
+ getChildren(key) {
66
+ let keyMap = this.keyMap;
67
+ return {
68
+ *[Symbol.iterator] () {
69
+ let parent = keyMap.get(key);
70
+ let node = (parent === null || parent === void 0 ? void 0 : parent.firstChildKey) != null ? keyMap.get(parent.firstChildKey) : null;
71
+ while(node){
72
+ yield node;
73
+ node = node.nextKey != null ? keyMap.get(node.nextKey) : undefined;
74
+ }
75
+ }
76
+ };
77
+ }
78
+ getKeyBefore(key) {
79
+ let node = this.keyMap.get(key);
80
+ if (!node) return null;
81
+ if (node.prevKey != null) {
82
+ node = this.keyMap.get(node.prevKey);
83
+ while(node && node.type !== 'item' && node.lastChildKey != null)node = this.keyMap.get(node.lastChildKey);
84
+ var _node_key;
85
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
86
+ }
87
+ return node.parentKey;
88
+ }
89
+ getKeyAfter(key) {
90
+ let node = this.keyMap.get(key);
91
+ if (!node) return null;
92
+ if (node.type !== 'item' && node.firstChildKey != null) return node.firstChildKey;
93
+ while(node){
94
+ if (node.nextKey != null) return node.nextKey;
95
+ if (node.parentKey != null) node = this.keyMap.get(node.parentKey);
96
+ else return null;
97
+ }
98
+ return null;
99
+ }
100
+ getFirstKey() {
101
+ return this.firstKey;
102
+ }
103
+ getLastKey() {
104
+ let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;
105
+ while((node === null || node === void 0 ? void 0 : node.lastChildKey) != null)node = this.keyMap.get(node.lastChildKey);
106
+ var _node_key;
107
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
108
+ }
109
+ getItem(key) {
110
+ var _this_keyMap_get;
111
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
112
+ }
113
+ at() {
114
+ throw new Error('Not implemented');
115
+ }
116
+ clone() {
117
+ // We need to clone using this.constructor so that subclasses have the right prototype.
118
+ // TypeScript isn't happy about this yet.
119
+ // https://github.com/microsoft/TypeScript/issues/3841
120
+ let Constructor = this.constructor;
121
+ let collection = new Constructor();
122
+ collection.keyMap = new Map(this.keyMap);
123
+ collection.firstKey = this.firstKey;
124
+ collection.lastKey = this.lastKey;
125
+ return collection;
126
+ }
127
+ addNode(node) {
128
+ if (this.frozen) throw new Error('Cannot add a node to a frozen collection');
129
+ this.keyMap.set(node.key, node);
130
+ }
131
+ removeNode(key) {
132
+ if (this.frozen) throw new Error('Cannot remove a node to a frozen collection');
133
+ this.keyMap.delete(key);
134
+ }
135
+ commit(firstKey, lastKey, isSSR = false) {
136
+ if (this.frozen) throw new Error('Cannot commit a frozen collection');
137
+ this.firstKey = firstKey;
138
+ this.lastKey = lastKey;
139
+ this.frozen = !isSSR;
140
+ }
141
+ constructor(){
142
+ this.keyMap = new Map();
143
+ this.firstKey = null;
144
+ this.lastKey = null;
145
+ this.frozen = false;
146
+ }
147
+ }
148
+
149
+
150
+ export {$23b9f4fcf0fe224b$export$f5d856d854e74713 as NodeValue, $23b9f4fcf0fe224b$export$408d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,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE;IAC5B;IAEA,WAAW,GAAQ,EAAE;QACnB,IAAI,IAAI,CAAC,MAAM,EACb,MAAM,IAAI,MAAM;QAGlB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IACrB;IAEA,OAAO,QAAoB,EAAE,OAAmB,EAAE,QAAQ,KAAK,EAAE;QAC/D,IAAI,IAAI,CAAC,MAAM,EACb,MAAM,IAAI,MAAM;QAGlB,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,MAAM,GAAG,CAAC;IACjB;;aAxIQ,SAAiC,IAAI;aACrC,WAAuB;aACvB,UAAsB;aACtB,SAAS;;AAsInB","sources":["packages/@react-aria/collections/src/BaseCollection.ts"],"sourcesContent":["/*\n * Copyright 2024 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 as ICollection, Key, Node} from '@react-types/shared';\nimport {ReactElement, ReactNode} from 'react';\n\nexport type Mutable<T> = {\n -readonly[P in keyof T]: T[P]\n}\n\n/** An immutable object representing a Node in a Collection. */\nexport class NodeValue<T> implements Node<T> {\n readonly type: string;\n readonly key: Key;\n readonly value: T | null = null;\n readonly level: number = 0;\n readonly hasChildNodes: boolean = false;\n readonly rendered: ReactNode = null;\n readonly textValue: string = '';\n readonly 'aria-label'?: string = undefined;\n readonly index: number = 0;\n readonly parentKey: Key | null = null;\n readonly prevKey: Key | null = null;\n readonly nextKey: Key | null = null;\n readonly firstChildKey: Key | null = null;\n readonly lastChildKey: Key | null = null;\n readonly props: any = {};\n readonly render?: (node: Node<any>) => ReactElement;\n\n constructor(type: string, key: Key) {\n this.type = type;\n this.key = key;\n }\n\n get childNodes(): Iterable<Node<T>> {\n throw new Error('childNodes is not supported');\n }\n\n clone(): NodeValue<T> {\n let node: Mutable<NodeValue<T>> = new NodeValue(this.type, this.key);\n node.value = this.value;\n node.level = this.level;\n node.hasChildNodes = this.hasChildNodes;\n node.rendered = this.rendered;\n node.textValue = this.textValue;\n node['aria-label'] = this['aria-label'];\n node.index = this.index;\n node.parentKey = this.parentKey;\n node.prevKey = this.prevKey;\n node.nextKey = this.nextKey;\n node.firstChildKey = this.firstChildKey;\n node.lastChildKey = this.lastChildKey;\n node.props = this.props;\n node.render = this.render;\n return node;\n }\n}\n\n/**\n * An immutable Collection implementation. Updates are only allowed\n * when it is not marked as frozen. This can be subclassed to implement\n * custom collection behaviors.\n */\nexport class BaseCollection<T> implements ICollection<Node<T>> {\n private keyMap: Map<Key, NodeValue<T>> = new Map();\n private firstKey: Key | null = null;\n private lastKey: Key | null = null;\n private frozen = false;\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n *[Symbol.iterator]() {\n let node: Node<T> | undefined = this.firstKey != null ? this.keyMap.get(this.firstKey) : undefined;\n while (node) {\n yield node;\n node = node.nextKey != null ? this.keyMap.get(node.nextKey) : undefined;\n }\n }\n\n getChildren(key: Key): Iterable<Node<T>> {\n let keyMap = this.keyMap;\n return {\n *[Symbol.iterator]() {\n let parent = keyMap.get(key);\n let node = parent?.firstChildKey != null ? keyMap.get(parent.firstChildKey) : null;\n while (node) {\n yield node as Node<T>;\n node = node.nextKey != null ? keyMap.get(node.nextKey) : undefined;\n }\n }\n };\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.prevKey != null) {\n node = this.keyMap.get(node.prevKey);\n\n while (node && node.type !== 'item' && node.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n return node.parentKey;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n if (!node) {\n return null;\n }\n\n if (node.type !== 'item' && node.firstChildKey != null) {\n return node.firstChildKey;\n }\n\n while (node) {\n if (node.nextKey != null) {\n return node.nextKey;\n }\n\n if (node.parentKey != null) {\n node = this.keyMap.get(node.parentKey);\n } else {\n return null;\n }\n }\n\n return null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;\n while (node?.lastChildKey != null) {\n node = this.keyMap.get(node.lastChildKey);\n }\n\n return node?.key ?? null;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(): Node<T> {\n throw new Error('Not implemented');\n }\n\n clone(): this {\n // We need to clone using this.constructor so that subclasses have the right prototype.\n // TypeScript isn't happy about this yet.\n // https://github.com/microsoft/TypeScript/issues/3841\n let Constructor: any = this.constructor;\n let collection: this = new Constructor();\n collection.keyMap = new Map(this.keyMap);\n collection.firstKey = this.firstKey;\n collection.lastKey = this.lastKey;\n return collection;\n }\n\n addNode(node: NodeValue<T>) {\n if (this.frozen) {\n throw new Error('Cannot add a node to a frozen collection');\n }\n\n this.keyMap.set(node.key, node);\n }\n\n removeNode(key: Key) {\n if (this.frozen) {\n throw new Error('Cannot remove a node to a frozen collection');\n }\n\n this.keyMap.delete(key);\n }\n\n commit(firstKey: Key | null, lastKey: Key | null, isSSR = false) {\n if (this.frozen) {\n throw new Error('Cannot commit a frozen collection');\n }\n\n this.firstKey = firstKey;\n this.lastKey = lastKey;\n this.frozen = !isSSR;\n }\n}\n"],"names":[],"version":3,"file":"BaseCollection.module.js.map"}