@react-aria/collections 3.0.0-nightly.3006 → 3.0.0-nightly.3018
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseCollection.main.js +3 -3
- package/dist/BaseCollection.main.js.map +1 -1
- package/dist/BaseCollection.mjs +3 -3
- package/dist/BaseCollection.module.js +3 -3
- package/dist/BaseCollection.module.js.map +1 -1
- package/dist/Document.main.js +1 -1
- package/dist/Document.main.js.map +1 -1
- package/dist/Document.mjs +2 -2
- package/dist/Document.module.js +2 -2
- package/dist/Document.module.js.map +1 -1
- package/dist/import.mjs +2 -2
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -2
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/BaseCollection.ts +5 -5
- package/src/Document.ts +4 -4
- package/src/index.ts +1 -1
|
@@ -3,7 +3,7 @@ function $parcel$export(e, n, v, s) {
|
|
|
3
3
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
$parcel$export(module.exports, "
|
|
6
|
+
$parcel$export(module.exports, "CollectionNode", () => $499e2959ba1abacc$export$d68d59712b04d9d1);
|
|
7
7
|
$parcel$export(module.exports, "BaseCollection", () => $499e2959ba1abacc$export$408d25a4e12db025);
|
|
8
8
|
/*
|
|
9
9
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -15,12 +15,12 @@ $parcel$export(module.exports, "BaseCollection", () => $499e2959ba1abacc$export$
|
|
|
15
15
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
16
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
17
|
* governing permissions and limitations under the License.
|
|
18
|
-
*/ class $499e2959ba1abacc$export$
|
|
18
|
+
*/ class $499e2959ba1abacc$export$d68d59712b04d9d1 {
|
|
19
19
|
get childNodes() {
|
|
20
20
|
throw new Error('childNodes is not supported');
|
|
21
21
|
}
|
|
22
22
|
clone() {
|
|
23
|
-
let node = new $499e2959ba1abacc$export$
|
|
23
|
+
let node = new $499e2959ba1abacc$export$d68d59712b04d9d1(this.type, this.key);
|
|
24
24
|
node.value = this.value;
|
|
25
25
|
node.level = this.level;
|
|
26
26
|
node.hasChildNodes = this.hasChildNodes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAUM,MAAM;IAuBX,IAAI,aAAgC;QAClC,MAAM,IAAI,MAAM;IAClB;IAEA,
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAUM,MAAM;IAuBX,IAAI,aAAgC;QAClC,MAAM,IAAI,MAAM;IAClB;IAEA,QAA2B;QACzB,IAAI,OAAmC,IAAI,0CAAe,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;QAC7E,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,aAAa,GAAG,IAAI,CAAC,aAAa;QACvC,KAAK,QAAQ,GAAG,IAAI,CAAC,QAAQ;QAC7B,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS;QAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa;QACvC,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS;QAC/B,KAAK,OAAO,GAAG,IAAI,CAAC,OAAO;QAC3B,KAAK,OAAO,GAAG,IAAI,CAAC,OAAO;QAC3B,KAAK,aAAa,GAAG,IAAI,CAAC,aAAa;QACvC,KAAK,YAAY,GAAG,IAAI,CAAC,YAAY;QACrC,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,MAAM,GAAG,IAAI,CAAC,MAAM;QACzB,OAAO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A,QAAc;QACZ,uFAAuF;QACvF,yCAAyC;QACzC,sDAAsD;QACtD,IAAI,cAAmB,IAAI,CAAC,WAAW;QACvC,IAAI,aAAmB,IAAI;QAC3B,WAAW,MAAM,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM;QACvC,WAAW,QAAQ,GAAG,IAAI,CAAC,QAAQ;QACnC,WAAW,OAAO,GAAG,IAAI,CAAC,OAAO;QACjC,OAAO;IACT;IAEA,QAAQ,IAAuB,EAAE;QAC/B,IAAI,IAAI,CAAC,MAAM,EACb,MAAM,IAAI,MAAM;QAGlB,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,SAAsC,IAAI;aAC1C,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 CollectionNode<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(): CollectionNode<T> {\n let node: Mutable<CollectionNode<T>> = new CollectionNode(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, CollectionNode<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: CollectionNode<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"}
|
package/dist/BaseCollection.mjs
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
|
-
*/ class $23b9f4fcf0fe224b$export$
|
|
11
|
+
*/ class $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
|
|
12
12
|
get childNodes() {
|
|
13
13
|
throw new Error('childNodes is not supported');
|
|
14
14
|
}
|
|
15
15
|
clone() {
|
|
16
|
-
let node = new $23b9f4fcf0fe224b$export$
|
|
16
|
+
let node = new $23b9f4fcf0fe224b$export$d68d59712b04d9d1(this.type, this.key);
|
|
17
17
|
node.value = this.value;
|
|
18
18
|
node.level = this.level;
|
|
19
19
|
node.hasChildNodes = this.hasChildNodes;
|
|
@@ -147,5 +147,5 @@ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
export {$23b9f4fcf0fe224b$export$
|
|
150
|
+
export {$23b9f4fcf0fe224b$export$d68d59712b04d9d1 as CollectionNode, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection};
|
|
151
151
|
//# sourceMappingURL=BaseCollection.module.js.map
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
|
-
*/ class $23b9f4fcf0fe224b$export$
|
|
11
|
+
*/ class $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
|
|
12
12
|
get childNodes() {
|
|
13
13
|
throw new Error('childNodes is not supported');
|
|
14
14
|
}
|
|
15
15
|
clone() {
|
|
16
|
-
let node = new $23b9f4fcf0fe224b$export$
|
|
16
|
+
let node = new $23b9f4fcf0fe224b$export$d68d59712b04d9d1(this.type, this.key);
|
|
17
17
|
node.value = this.value;
|
|
18
18
|
node.level = this.level;
|
|
19
19
|
node.hasChildNodes = this.hasChildNodes;
|
|
@@ -147,5 +147,5 @@ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
export {$23b9f4fcf0fe224b$export$
|
|
150
|
+
export {$23b9f4fcf0fe224b$export$d68d59712b04d9d1 as CollectionNode, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection};
|
|
151
151
|
//# sourceMappingURL=BaseCollection.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAUM,MAAM;IAuBX,IAAI,aAAgC;QAClC,MAAM,IAAI,MAAM;IAClB;IAEA,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAUM,MAAM;IAuBX,IAAI,aAAgC;QAClC,MAAM,IAAI,MAAM;IAClB;IAEA,QAA2B;QACzB,IAAI,OAAmC,IAAI,0CAAe,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;QAC7E,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK;QACvB,KAAK,aAAa,GAAG,IAAI,CAAC,aAAa;QACvC,KAAK,QAAQ,GAAG,IAAI,CAAC,QAAQ;QAC7B,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS;QAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa;QAC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*\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 CollectionNode<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(): CollectionNode<T> {\n let node: Mutable<CollectionNode<T>> = new CollectionNode(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, CollectionNode<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: CollectionNode<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"}
|
package/dist/Document.main.js
CHANGED
|
@@ -200,7 +200,7 @@ class $c20afee375f3b2d6$export$dc064fe9e59310fd extends $c20afee375f3b2d6$export
|
|
|
200
200
|
;
|
|
201
201
|
this._index = 0;
|
|
202
202
|
this.hasSetProps = false;
|
|
203
|
-
this.node = new (0, $499e2959ba1abacc$exports.
|
|
203
|
+
this.node = new (0, $499e2959ba1abacc$exports.CollectionNode)(type, `react-aria-${++ownerDocument.nodeId}`);
|
|
204
204
|
// Start a transaction so that no updates are emitted from the collection
|
|
205
205
|
// until the props for this node are set. We don't know the real id for the
|
|
206
206
|
// node until then, so we need to avoid emitting collections in an inconsistent state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAYX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,IAAI,OAAO,IAAI,CAAC,UAAU;QAC1B,MAAO,KAAM;YACX,MAAM;YACN,OAAO,KAAK,WAAW;QACzB;IACF;IAEA,IAAI,aAAa;QACf,OAA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aACxC,gBAAgB,IAAI;aACpB,aAA+B,IAAI;aACnC,QAAQ;aACR,SAAS;aACT,eAAe,IAAI;aACnB,YAAY;aAGJ,eAAoC,IAAI;aACxC,gBAAiC,IAAI;aACrC,mBAAmB;QAKzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,iBAAiB,GAAG;IAC3B;AAgIF","sources":["packages/@react-aria/collections/src/Document.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 {BaseCollection, Mutable, NodeValue} from './BaseCollection';\nimport {ForwardedRef, ReactElement} from 'react';\nimport {Node} from '@react-types/shared';\n\n// This Collection implementation is perhaps a little unusual. It works by rendering the React tree into a\n// Portal to a fake DOM implementation. This gives us efficient access to the tree of rendered objects, and\n// supports React features like composition and context. We use this fake DOM to access the full set of elements\n// before we render into the real DOM, which allows us to render a subset of the elements (e.g. virtualized scrolling),\n// and compute properties like the total number of items. It also enables keyboard navigation, selection, and other features.\n// React takes care of efficiently rendering components and updating the collection for us via this fake DOM.\n//\n// The DOM is a mutable API, and React expects the node instances to remain stable over time. So the implementation is split\n// into two parts. Each mutable fake DOM node owns an instance of an immutable collection node. When a fake DOM node is updated,\n// it queues a second render for the collection. Multiple updates to a collection can be queued at once. Collection nodes are\n// lazily copied on write, so only the changed nodes need to be cloned. During the second render, the new immutable collection\n// is finalized by updating the map of Key -> Node with the new cloned nodes. Then the new collection is frozen so it can no\n// longer be mutated, and returned to the calling component to render.\n\n/**\n * A mutable node in the fake DOM tree. When mutated, it marks itself as dirty\n * and queues an update with the owner document.\n */\nexport class BaseNode<T> {\n private _firstChild: ElementNode<T> | null = null;\n private _lastChild: ElementNode<T> | null = null;\n private _previousSibling: ElementNode<T> | null = null;\n private _nextSibling: ElementNode<T> | null = null;\n private _parentNode: BaseNode<T> | null = null;\n ownerDocument: Document<T, any>;\n\n constructor(ownerDocument: Document<T, any>) {\n this.ownerDocument = ownerDocument;\n }\n\n *[Symbol.iterator]() {\n let node = this.firstChild;\n while (node) {\n yield node;\n node = node.nextSibling;\n }\n }\n\n get firstChild() {\n return this._firstChild;\n }\n\n set firstChild(firstChild) {\n this._firstChild = firstChild;\n this.ownerDocument.markDirty(this);\n }\n\n get lastChild() {\n return this._lastChild;\n }\n\n set lastChild(lastChild) {\n this._lastChild = lastChild;\n this.ownerDocument.markDirty(this);\n }\n\n get previousSibling() {\n return this._previousSibling;\n }\n\n set previousSibling(previousSibling) {\n this._previousSibling = previousSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get nextSibling() {\n return this._nextSibling;\n }\n\n set nextSibling(nextSibling) {\n this._nextSibling = nextSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get parentNode() {\n return this._parentNode;\n }\n\n set parentNode(parentNode) {\n this._parentNode = parentNode;\n this.ownerDocument.markDirty(this);\n }\n\n get isConnected() {\n return this.parentNode?.isConnected || false;\n }\n\n appendChild(child: ElementNode<T>) {\n this.ownerDocument.startTransaction();\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n\n if (this.firstChild == null) {\n this.firstChild = child;\n }\n\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.index = this.lastChild.index + 1;\n child.previousSibling = this.lastChild;\n } else {\n child.previousSibling = null;\n child.index = 0;\n }\n\n child.parentNode = this;\n child.nextSibling = null;\n this.lastChild = child;\n\n this.ownerDocument.markDirty(this);\n if (child.hasSetProps) {\n // Only add the node to the collection if we already received props for it.\n // Otherwise wait until then so we have the correct id for the node.\n this.ownerDocument.addNode(child);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>) {\n if (referenceNode == null) {\n return this.appendChild(newNode);\n }\n\n this.ownerDocument.startTransaction();\n if (newNode.parentNode) {\n newNode.parentNode.removeChild(newNode);\n }\n\n newNode.nextSibling = referenceNode;\n newNode.previousSibling = referenceNode.previousSibling;\n newNode.index = referenceNode.index;\n\n if (this.firstChild === referenceNode) {\n this.firstChild = newNode;\n } else if (referenceNode.previousSibling) {\n referenceNode.previousSibling.nextSibling = newNode;\n }\n\n referenceNode.previousSibling = newNode;\n newNode.parentNode = referenceNode.parentNode;\n\n let node: ElementNode<T> | null = referenceNode;\n while (node) {\n node.index++;\n node = node.nextSibling;\n }\n\n if (newNode.hasSetProps) {\n this.ownerDocument.addNode(newNode);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n removeChild(child: ElementNode<T>) {\n if (child.parentNode !== this || !this.ownerDocument.isMounted) {\n return;\n }\n\n this.ownerDocument.startTransaction();\n let node = child.nextSibling;\n while (node) {\n node.index--;\n node = node.nextSibling;\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling;\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n }\n\n if (this.firstChild === child) {\n this.firstChild = child.nextSibling;\n }\n\n if (this.lastChild === child) {\n this.lastChild = child.previousSibling;\n }\n\n child.parentNode = null;\n child.nextSibling = null;\n child.previousSibling = null;\n child.index = 0;\n\n this.ownerDocument.removeNode(child);\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n addEventListener() {}\n removeEventListener() {}\n}\n\n/**\n * A mutable element node in the fake DOM tree. It owns an immutable\n * Collection Node which is copied on write.\n */\nexport class ElementNode<T> extends BaseNode<T> {\n nodeType = 8; // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)\n node: NodeValue<T>;\n private _index: number = 0;\n hasSetProps = false;\n\n constructor(type: string, ownerDocument: Document<T, any>) {\n super(ownerDocument);\n this.node = new NodeValue(type, `react-aria-${++ownerDocument.nodeId}`);\n // Start a transaction so that no updates are emitted from the collection\n // until the props for this node are set. We don't know the real id for the\n // node until then, so we need to avoid emitting collections in an inconsistent state.\n this.ownerDocument.startTransaction();\n }\n\n get index() {\n return this._index;\n }\n\n set index(index) {\n this._index = index;\n this.ownerDocument.markDirty(this);\n }\n\n get level(): number {\n if (this.parentNode instanceof ElementNode) {\n return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);\n }\n\n return 0;\n }\n\n updateNode() {\n let node = this.ownerDocument.getMutableNode(this);\n node.index = this.index;\n node.level = this.level;\n node.parentKey = this.parentNode instanceof ElementNode ? this.parentNode.node.key : null;\n node.prevKey = this.previousSibling?.node.key ?? null;\n node.nextKey = this.nextSibling?.node.key ?? null;\n node.hasChildNodes = !!this.firstChild;\n node.firstChildKey = this.firstChild?.node.key ?? null;\n node.lastChildKey = this.lastChild?.node.key ?? null;\n }\n\n setProps<E extends Element>(obj: any, ref: ForwardedRef<E>, rendered?: any, render?: (node: Node<T>) => ReactElement) {\n let node = this.ownerDocument.getMutableNode(this);\n let {value, textValue, id, ...props} = obj;\n props.ref = ref;\n node.props = props;\n node.rendered = rendered;\n node.render = render;\n node.value = value;\n node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';\n if (id != null && id !== node.key) {\n if (this.hasSetProps) {\n throw new Error('Cannot change the id of an item');\n }\n node.key = id;\n }\n\n // If this is the first time props have been set, end the transaction started in the constructor\n // so this node can be emitted.\n if (!this.hasSetProps) {\n this.ownerDocument.addNode(this);\n this.ownerDocument.endTransaction();\n this.hasSetProps = true;\n }\n\n this.ownerDocument.queueUpdate();\n }\n\n get style() {\n return {};\n }\n\n hasAttribute() {}\n setAttribute() {}\n setAttributeNS() {}\n removeAttribute() {}\n}\n\n/**\n * A mutable Document in the fake DOM. It owns an immutable Collection instance,\n * which is lazily copied on write during updates.\n */\nexport class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extends BaseNode<T> {\n nodeType = 11; // DOCUMENT_FRAGMENT_NODE\n ownerDocument = this;\n dirtyNodes: Set<BaseNode<T>> = new Set();\n isSSR = false;\n nodeId = 0;\n nodesByProps = new WeakMap<object, ElementNode<T>>();\n isMounted = true;\n private collection: C;\n private collectionMutated: boolean;\n private mutatedNodes: Set<ElementNode<T>> = new Set();\n private subscriptions: Set<() => void> = new Set();\n private transactionCount = 0;\n\n constructor(collection: C) {\n // @ts-ignore\n super(null);\n this.collection = collection;\n this.collectionMutated = true;\n }\n\n get isConnected() {\n return this.isMounted;\n }\n\n createElement(type: string) {\n return new ElementNode(type, this);\n }\n\n /**\n * Lazily gets a mutable instance of a Node. If the node has already\n * been cloned during this update cycle, it just returns the existing one.\n */\n getMutableNode(element: ElementNode<T>): Mutable<NodeValue<T>> {\n let node = element.node;\n if (!this.mutatedNodes.has(element)) {\n node = element.node.clone();\n this.mutatedNodes.add(element);\n element.node = node;\n }\n this.markDirty(element);\n return node;\n }\n\n private getMutableCollection() {\n if (!this.isSSR && !this.collectionMutated) {\n this.collection = this.collection.clone();\n this.collectionMutated = true;\n }\n\n return this.collection;\n }\n\n markDirty(node: BaseNode<T>) {\n this.dirtyNodes.add(node);\n }\n\n startTransaction() {\n this.transactionCount++;\n }\n\n endTransaction() {\n this.transactionCount--;\n }\n\n addNode(element: ElementNode<T>) {\n let collection = this.getMutableCollection();\n if (!collection.getItem(element.node.key)) {\n collection.addNode(element.node);\n\n for (let child of element) {\n this.addNode(child);\n }\n }\n\n this.markDirty(element);\n }\n\n removeNode(node: ElementNode<T>) {\n for (let child of node) {\n this.removeNode(child);\n }\n\n let collection = this.getMutableCollection();\n collection.removeNode(node.node.key);\n this.markDirty(node);\n }\n\n /** Finalizes the collection update, updating all nodes and freezing the collection. */\n getCollection(): C {\n if (this.transactionCount > 0) {\n return this.collection;\n }\n\n this.updateCollection();\n return this.collection;\n }\n\n updateCollection() {\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode && element.isConnected) {\n element.updateNode();\n }\n }\n\n this.dirtyNodes.clear();\n\n if (this.mutatedNodes.size || this.collectionMutated) {\n let collection = this.getMutableCollection();\n for (let element of this.mutatedNodes) {\n if (element.isConnected) {\n collection.addNode(element.node);\n }\n }\n\n collection.commit(this.firstChild?.node.key ?? null, this.lastChild?.node.key ?? null, this.isSSR);\n this.mutatedNodes.clear();\n }\n\n this.collectionMutated = false;\n }\n\n queueUpdate() {\n // Don't emit any updates if there is a transaction in progress.\n // queueUpdate should be called again after the transaction.\n if (this.dirtyNodes.size === 0 || this.transactionCount > 0) {\n return;\n }\n\n for (let fn of this.subscriptions) {\n fn();\n }\n }\n\n subscribe(fn: () => void) {\n this.subscriptions.add(fn);\n return () => this.subscriptions.delete(fn);\n }\n\n resetAfterSSR() {\n if (this.isSSR) {\n this.isSSR = false;\n this.firstChild = null;\n this.lastChild = null;\n this.nodeId = 0;\n }\n }\n}\n"],"names":[],"version":3,"file":"Document.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAYX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,IAAI,OAAO,IAAI,CAAC,UAAU;QAC1B,MAAO,KAAM;YACX,MAAM;YACN,OAAO,KAAK,WAAW;QACzB;IACF;IAEA,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,IAAI,WAAW,UAAU,EAAE;QACzB,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,UAAU;IACxB;IAEA,IAAI,UAAU,SAAS,EAAE;QACvB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,gBAAgB;IAC9B;I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AI,CAAC,UAAU,cAAf,uCAAA,iBAAiB,IAAI,CAAC,GAAG,cAAzB,uCAAA,4BAA6B,MAAM,CAAA,4BAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,sCAAA,gBAAgB,IAAI,CAAC,GAAG,cAAxB,sCAAA,2BAA4B,MAAM,IAAI,CAAC,KAAK;YACjG,IAAI,CAAC,YAAY,CAAC,KAAK;QACzB;QAEA,IAAI,CAAC,iBAAiB,GAAG;IAC3B;IAEA,cAAc;QACZ,gEAAgE;QAChE,4DAA4D;QAC5D,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,gBAAgB,GAAG,GACxD;QAGF,KAAK,IAAI,MAAM,IAAI,CAAC,aAAa,CAC/B;IAEJ;IAEA,UAAU,EAAc,EAAE;QACxB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACvB,OAAO,IAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IACzC;IAEA,gBAAgB;QACd,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,GAAG;YACb,IAAI,CAAC,UAAU,GAAG;YAClB,IAAI,CAAC,SAAS,GAAG;YACjB,IAAI,CAAC,MAAM,GAAG;QAChB;IACF;IApIA,YAAY,UAAa,CAAE;QACzB,aAAa;QACb,KAAK,CAAC;aAfR,WAAW,GAAI,yBAAyB;;aACxC,gBAAgB,IAAI;aACpB,aAA+B,IAAI;aACnC,QAAQ;aACR,SAAS;aACT,eAAe,IAAI;aACnB,YAAY;aAGJ,eAAoC,IAAI;aACxC,gBAAiC,IAAI;aACrC,mBAAmB;QAKzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,iBAAiB,GAAG;IAC3B;AAgIF","sources":["packages/@react-aria/collections/src/Document.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 {BaseCollection, CollectionNode, Mutable} from './BaseCollection';\nimport {ForwardedRef, ReactElement} from 'react';\nimport {Node} from '@react-types/shared';\n\n// This Collection implementation is perhaps a little unusual. It works by rendering the React tree into a\n// Portal to a fake DOM implementation. This gives us efficient access to the tree of rendered objects, and\n// supports React features like composition and context. We use this fake DOM to access the full set of elements\n// before we render into the real DOM, which allows us to render a subset of the elements (e.g. virtualized scrolling),\n// and compute properties like the total number of items. It also enables keyboard navigation, selection, and other features.\n// React takes care of efficiently rendering components and updating the collection for us via this fake DOM.\n//\n// The DOM is a mutable API, and React expects the node instances to remain stable over time. So the implementation is split\n// into two parts. Each mutable fake DOM node owns an instance of an immutable collection node. When a fake DOM node is updated,\n// it queues a second render for the collection. Multiple updates to a collection can be queued at once. Collection nodes are\n// lazily copied on write, so only the changed nodes need to be cloned. During the second render, the new immutable collection\n// is finalized by updating the map of Key -> Node with the new cloned nodes. Then the new collection is frozen so it can no\n// longer be mutated, and returned to the calling component to render.\n\n/**\n * A mutable node in the fake DOM tree. When mutated, it marks itself as dirty\n * and queues an update with the owner document.\n */\nexport class BaseNode<T> {\n private _firstChild: ElementNode<T> | null = null;\n private _lastChild: ElementNode<T> | null = null;\n private _previousSibling: ElementNode<T> | null = null;\n private _nextSibling: ElementNode<T> | null = null;\n private _parentNode: BaseNode<T> | null = null;\n ownerDocument: Document<T, any>;\n\n constructor(ownerDocument: Document<T, any>) {\n this.ownerDocument = ownerDocument;\n }\n\n *[Symbol.iterator]() {\n let node = this.firstChild;\n while (node) {\n yield node;\n node = node.nextSibling;\n }\n }\n\n get firstChild() {\n return this._firstChild;\n }\n\n set firstChild(firstChild) {\n this._firstChild = firstChild;\n this.ownerDocument.markDirty(this);\n }\n\n get lastChild() {\n return this._lastChild;\n }\n\n set lastChild(lastChild) {\n this._lastChild = lastChild;\n this.ownerDocument.markDirty(this);\n }\n\n get previousSibling() {\n return this._previousSibling;\n }\n\n set previousSibling(previousSibling) {\n this._previousSibling = previousSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get nextSibling() {\n return this._nextSibling;\n }\n\n set nextSibling(nextSibling) {\n this._nextSibling = nextSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get parentNode() {\n return this._parentNode;\n }\n\n set parentNode(parentNode) {\n this._parentNode = parentNode;\n this.ownerDocument.markDirty(this);\n }\n\n get isConnected() {\n return this.parentNode?.isConnected || false;\n }\n\n appendChild(child: ElementNode<T>) {\n this.ownerDocument.startTransaction();\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n\n if (this.firstChild == null) {\n this.firstChild = child;\n }\n\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.index = this.lastChild.index + 1;\n child.previousSibling = this.lastChild;\n } else {\n child.previousSibling = null;\n child.index = 0;\n }\n\n child.parentNode = this;\n child.nextSibling = null;\n this.lastChild = child;\n\n this.ownerDocument.markDirty(this);\n if (child.hasSetProps) {\n // Only add the node to the collection if we already received props for it.\n // Otherwise wait until then so we have the correct id for the node.\n this.ownerDocument.addNode(child);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>) {\n if (referenceNode == null) {\n return this.appendChild(newNode);\n }\n\n this.ownerDocument.startTransaction();\n if (newNode.parentNode) {\n newNode.parentNode.removeChild(newNode);\n }\n\n newNode.nextSibling = referenceNode;\n newNode.previousSibling = referenceNode.previousSibling;\n newNode.index = referenceNode.index;\n\n if (this.firstChild === referenceNode) {\n this.firstChild = newNode;\n } else if (referenceNode.previousSibling) {\n referenceNode.previousSibling.nextSibling = newNode;\n }\n\n referenceNode.previousSibling = newNode;\n newNode.parentNode = referenceNode.parentNode;\n\n let node: ElementNode<T> | null = referenceNode;\n while (node) {\n node.index++;\n node = node.nextSibling;\n }\n\n if (newNode.hasSetProps) {\n this.ownerDocument.addNode(newNode);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n removeChild(child: ElementNode<T>) {\n if (child.parentNode !== this || !this.ownerDocument.isMounted) {\n return;\n }\n\n this.ownerDocument.startTransaction();\n let node = child.nextSibling;\n while (node) {\n node.index--;\n node = node.nextSibling;\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling;\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n }\n\n if (this.firstChild === child) {\n this.firstChild = child.nextSibling;\n }\n\n if (this.lastChild === child) {\n this.lastChild = child.previousSibling;\n }\n\n child.parentNode = null;\n child.nextSibling = null;\n child.previousSibling = null;\n child.index = 0;\n\n this.ownerDocument.removeNode(child);\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n addEventListener() {}\n removeEventListener() {}\n}\n\n/**\n * A mutable element node in the fake DOM tree. It owns an immutable\n * Collection Node which is copied on write.\n */\nexport class ElementNode<T> extends BaseNode<T> {\n nodeType = 8; // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)\n node: CollectionNode<T>;\n private _index: number = 0;\n hasSetProps = false;\n\n constructor(type: string, ownerDocument: Document<T, any>) {\n super(ownerDocument);\n this.node = new CollectionNode(type, `react-aria-${++ownerDocument.nodeId}`);\n // Start a transaction so that no updates are emitted from the collection\n // until the props for this node are set. We don't know the real id for the\n // node until then, so we need to avoid emitting collections in an inconsistent state.\n this.ownerDocument.startTransaction();\n }\n\n get index() {\n return this._index;\n }\n\n set index(index) {\n this._index = index;\n this.ownerDocument.markDirty(this);\n }\n\n get level(): number {\n if (this.parentNode instanceof ElementNode) {\n return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);\n }\n\n return 0;\n }\n\n updateNode() {\n let node = this.ownerDocument.getMutableNode(this);\n node.index = this.index;\n node.level = this.level;\n node.parentKey = this.parentNode instanceof ElementNode ? this.parentNode.node.key : null;\n node.prevKey = this.previousSibling?.node.key ?? null;\n node.nextKey = this.nextSibling?.node.key ?? null;\n node.hasChildNodes = !!this.firstChild;\n node.firstChildKey = this.firstChild?.node.key ?? null;\n node.lastChildKey = this.lastChild?.node.key ?? null;\n }\n\n setProps<E extends Element>(obj: any, ref: ForwardedRef<E>, rendered?: any, render?: (node: Node<T>) => ReactElement) {\n let node = this.ownerDocument.getMutableNode(this);\n let {value, textValue, id, ...props} = obj;\n props.ref = ref;\n node.props = props;\n node.rendered = rendered;\n node.render = render;\n node.value = value;\n node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';\n if (id != null && id !== node.key) {\n if (this.hasSetProps) {\n throw new Error('Cannot change the id of an item');\n }\n node.key = id;\n }\n\n // If this is the first time props have been set, end the transaction started in the constructor\n // so this node can be emitted.\n if (!this.hasSetProps) {\n this.ownerDocument.addNode(this);\n this.ownerDocument.endTransaction();\n this.hasSetProps = true;\n }\n\n this.ownerDocument.queueUpdate();\n }\n\n get style() {\n return {};\n }\n\n hasAttribute() {}\n setAttribute() {}\n setAttributeNS() {}\n removeAttribute() {}\n}\n\n/**\n * A mutable Document in the fake DOM. It owns an immutable Collection instance,\n * which is lazily copied on write during updates.\n */\nexport class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extends BaseNode<T> {\n nodeType = 11; // DOCUMENT_FRAGMENT_NODE\n ownerDocument = this;\n dirtyNodes: Set<BaseNode<T>> = new Set();\n isSSR = false;\n nodeId = 0;\n nodesByProps = new WeakMap<object, ElementNode<T>>();\n isMounted = true;\n private collection: C;\n private collectionMutated: boolean;\n private mutatedNodes: Set<ElementNode<T>> = new Set();\n private subscriptions: Set<() => void> = new Set();\n private transactionCount = 0;\n\n constructor(collection: C) {\n // @ts-ignore\n super(null);\n this.collection = collection;\n this.collectionMutated = true;\n }\n\n get isConnected() {\n return this.isMounted;\n }\n\n createElement(type: string) {\n return new ElementNode(type, this);\n }\n\n /**\n * Lazily gets a mutable instance of a Node. If the node has already\n * been cloned during this update cycle, it just returns the existing one.\n */\n getMutableNode(element: ElementNode<T>): Mutable<CollectionNode<T>> {\n let node = element.node;\n if (!this.mutatedNodes.has(element)) {\n node = element.node.clone();\n this.mutatedNodes.add(element);\n element.node = node;\n }\n this.markDirty(element);\n return node;\n }\n\n private getMutableCollection() {\n if (!this.isSSR && !this.collectionMutated) {\n this.collection = this.collection.clone();\n this.collectionMutated = true;\n }\n\n return this.collection;\n }\n\n markDirty(node: BaseNode<T>) {\n this.dirtyNodes.add(node);\n }\n\n startTransaction() {\n this.transactionCount++;\n }\n\n endTransaction() {\n this.transactionCount--;\n }\n\n addNode(element: ElementNode<T>) {\n let collection = this.getMutableCollection();\n if (!collection.getItem(element.node.key)) {\n collection.addNode(element.node);\n\n for (let child of element) {\n this.addNode(child);\n }\n }\n\n this.markDirty(element);\n }\n\n removeNode(node: ElementNode<T>) {\n for (let child of node) {\n this.removeNode(child);\n }\n\n let collection = this.getMutableCollection();\n collection.removeNode(node.node.key);\n this.markDirty(node);\n }\n\n /** Finalizes the collection update, updating all nodes and freezing the collection. */\n getCollection(): C {\n if (this.transactionCount > 0) {\n return this.collection;\n }\n\n this.updateCollection();\n return this.collection;\n }\n\n updateCollection() {\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode && element.isConnected) {\n element.updateNode();\n }\n }\n\n this.dirtyNodes.clear();\n\n if (this.mutatedNodes.size || this.collectionMutated) {\n let collection = this.getMutableCollection();\n for (let element of this.mutatedNodes) {\n if (element.isConnected) {\n collection.addNode(element.node);\n }\n }\n\n collection.commit(this.firstChild?.node.key ?? null, this.lastChild?.node.key ?? null, this.isSSR);\n this.mutatedNodes.clear();\n }\n\n this.collectionMutated = false;\n }\n\n queueUpdate() {\n // Don't emit any updates if there is a transaction in progress.\n // queueUpdate should be called again after the transaction.\n if (this.dirtyNodes.size === 0 || this.transactionCount > 0) {\n return;\n }\n\n for (let fn of this.subscriptions) {\n fn();\n }\n }\n\n subscribe(fn: () => void) {\n this.subscriptions.add(fn);\n return () => this.subscriptions.delete(fn);\n }\n\n resetAfterSSR() {\n if (this.isSSR) {\n this.isSSR = false;\n this.firstChild = null;\n this.lastChild = null;\n this.nodeId = 0;\n }\n }\n}\n"],"names":[],"version":3,"file":"Document.main.js.map"}
|
package/dist/Document.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {CollectionNode as $23b9f4fcf0fe224b$export$d68d59712b04d9d1} from "./BaseCollection.mjs";
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -194,7 +194,7 @@ class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export
|
|
|
194
194
|
;
|
|
195
195
|
this._index = 0;
|
|
196
196
|
this.hasSetProps = false;
|
|
197
|
-
this.node = new (0, $23b9f4fcf0fe224b$export$
|
|
197
|
+
this.node = new (0, $23b9f4fcf0fe224b$export$d68d59712b04d9d1)(type, `react-aria-${++ownerDocument.nodeId}`);
|
|
198
198
|
// Start a transaction so that no updates are emitted from the collection
|
|
199
199
|
// until the props for this node are set. We don't know the real id for the
|
|
200
200
|
// node until then, so we need to avoid emitting collections in an inconsistent state.
|
package/dist/Document.module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {CollectionNode as $23b9f4fcf0fe224b$export$d68d59712b04d9d1} from "./BaseCollection.module.js";
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -194,7 +194,7 @@ class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export
|
|
|
194
194
|
;
|
|
195
195
|
this._index = 0;
|
|
196
196
|
this.hasSetProps = false;
|
|
197
|
-
this.node = new (0, $23b9f4fcf0fe224b$export$
|
|
197
|
+
this.node = new (0, $23b9f4fcf0fe224b$export$d68d59712b04d9d1)(type, `react-aria-${++ownerDocument.nodeId}`);
|
|
198
198
|
// Start a transaction so that no updates are emitted from the collection
|
|
199
199
|
// until the props for this node are set. We don't know the real id for the
|
|
200
200
|
// node until then, so we need to avoid emitting collections in an inconsistent state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAYX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,IAAI,OAAO,IAAI,CAAC,UAAU;QAC1B,MAAO,KAAM;YACX,MAAM;YACN,OAAO,KAAK,WAAW;QACzB;IACF;IAEA,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,IAAI,WAAW,UAAU,EAAE;QACzB,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,UAAU;IACxB;IAEA,IAAI,UAAU,SAAS,EAAE;QACvB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,gBAAgB;IAC9B;IAEA,IAAI,gBAAgB,eAAe,EAAE;QACnC,IAAI,CAAC,gBAAgB,GAAG;QACxB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,YAAY;IAC1B;IAEA,IAAI,YAAY,WAAW,EAAE;QAC3B,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI;IACnC;IAEA,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,IAAI,WAAW,UAAU,EAAE;QACzB,IAAI,CAAC,WAAW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CAAC,gBAAgB,GAAG,GACxD;QAGF,KAAK,IAAI,MAAM,IAAI,CAAC,aAAa,CAC/B;IAEJ;IAEA,UAAU,EAAc,EAAE;QACxB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACvB,OAAO,IAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IACzC;IAEA,gBAAgB;QACd,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,GAAG;YACb,IAAI,CAAC,UAAU,GAAG;YAClB,IAAI,CAAC,SAAS,GAAG;YACjB,IAAI,CAAC,MAAM,GAAG;QAChB;IACF;IApIA,YAAY,UAAa,CAAE;QACzB,aAAa;QACb,KAAK,CAAC;aAfR,WAAW,GAAI,yBAAyB;;aACxC,gBAAgB,IAAI;aACpB,aAA+B,IAAI;aACnC,QAAQ;aACR,SAAS;aACT,eAAe,IAAI;aACnB,YAAY;aAGJ,eAAoC,IAAI;aACxC,gBAAiC,IAAI;aACrC,mBAAmB;QAKzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,iBAAiB,GAAG;IAC3B;AAgIF","sources":["packages/@react-aria/collections/src/Document.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 {BaseCollection, Mutable, NodeValue} from './BaseCollection';\nimport {ForwardedRef, ReactElement} from 'react';\nimport {Node} from '@react-types/shared';\n\n// This Collection implementation is perhaps a little unusual. It works by rendering the React tree into a\n// Portal to a fake DOM implementation. This gives us efficient access to the tree of rendered objects, and\n// supports React features like composition and context. We use this fake DOM to access the full set of elements\n// before we render into the real DOM, which allows us to render a subset of the elements (e.g. virtualized scrolling),\n// and compute properties like the total number of items. It also enables keyboard navigation, selection, and other features.\n// React takes care of efficiently rendering components and updating the collection for us via this fake DOM.\n//\n// The DOM is a mutable API, and React expects the node instances to remain stable over time. So the implementation is split\n// into two parts. Each mutable fake DOM node owns an instance of an immutable collection node. When a fake DOM node is updated,\n// it queues a second render for the collection. Multiple updates to a collection can be queued at once. Collection nodes are\n// lazily copied on write, so only the changed nodes need to be cloned. During the second render, the new immutable collection\n// is finalized by updating the map of Key -> Node with the new cloned nodes. Then the new collection is frozen so it can no\n// longer be mutated, and returned to the calling component to render.\n\n/**\n * A mutable node in the fake DOM tree. When mutated, it marks itself as dirty\n * and queues an update with the owner document.\n */\nexport class BaseNode<T> {\n private _firstChild: ElementNode<T> | null = null;\n private _lastChild: ElementNode<T> | null = null;\n private _previousSibling: ElementNode<T> | null = null;\n private _nextSibling: ElementNode<T> | null = null;\n private _parentNode: BaseNode<T> | null = null;\n ownerDocument: Document<T, any>;\n\n constructor(ownerDocument: Document<T, any>) {\n this.ownerDocument = ownerDocument;\n }\n\n *[Symbol.iterator]() {\n let node = this.firstChild;\n while (node) {\n yield node;\n node = node.nextSibling;\n }\n }\n\n get firstChild() {\n return this._firstChild;\n }\n\n set firstChild(firstChild) {\n this._firstChild = firstChild;\n this.ownerDocument.markDirty(this);\n }\n\n get lastChild() {\n return this._lastChild;\n }\n\n set lastChild(lastChild) {\n this._lastChild = lastChild;\n this.ownerDocument.markDirty(this);\n }\n\n get previousSibling() {\n return this._previousSibling;\n }\n\n set previousSibling(previousSibling) {\n this._previousSibling = previousSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get nextSibling() {\n return this._nextSibling;\n }\n\n set nextSibling(nextSibling) {\n this._nextSibling = nextSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get parentNode() {\n return this._parentNode;\n }\n\n set parentNode(parentNode) {\n this._parentNode = parentNode;\n this.ownerDocument.markDirty(this);\n }\n\n get isConnected() {\n return this.parentNode?.isConnected || false;\n }\n\n appendChild(child: ElementNode<T>) {\n this.ownerDocument.startTransaction();\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n\n if (this.firstChild == null) {\n this.firstChild = child;\n }\n\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.index = this.lastChild.index + 1;\n child.previousSibling = this.lastChild;\n } else {\n child.previousSibling = null;\n child.index = 0;\n }\n\n child.parentNode = this;\n child.nextSibling = null;\n this.lastChild = child;\n\n this.ownerDocument.markDirty(this);\n if (child.hasSetProps) {\n // Only add the node to the collection if we already received props for it.\n // Otherwise wait until then so we have the correct id for the node.\n this.ownerDocument.addNode(child);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>) {\n if (referenceNode == null) {\n return this.appendChild(newNode);\n }\n\n this.ownerDocument.startTransaction();\n if (newNode.parentNode) {\n newNode.parentNode.removeChild(newNode);\n }\n\n newNode.nextSibling = referenceNode;\n newNode.previousSibling = referenceNode.previousSibling;\n newNode.index = referenceNode.index;\n\n if (this.firstChild === referenceNode) {\n this.firstChild = newNode;\n } else if (referenceNode.previousSibling) {\n referenceNode.previousSibling.nextSibling = newNode;\n }\n\n referenceNode.previousSibling = newNode;\n newNode.parentNode = referenceNode.parentNode;\n\n let node: ElementNode<T> | null = referenceNode;\n while (node) {\n node.index++;\n node = node.nextSibling;\n }\n\n if (newNode.hasSetProps) {\n this.ownerDocument.addNode(newNode);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n removeChild(child: ElementNode<T>) {\n if (child.parentNode !== this || !this.ownerDocument.isMounted) {\n return;\n }\n\n this.ownerDocument.startTransaction();\n let node = child.nextSibling;\n while (node) {\n node.index--;\n node = node.nextSibling;\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling;\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n }\n\n if (this.firstChild === child) {\n this.firstChild = child.nextSibling;\n }\n\n if (this.lastChild === child) {\n this.lastChild = child.previousSibling;\n }\n\n child.parentNode = null;\n child.nextSibling = null;\n child.previousSibling = null;\n child.index = 0;\n\n this.ownerDocument.removeNode(child);\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n addEventListener() {}\n removeEventListener() {}\n}\n\n/**\n * A mutable element node in the fake DOM tree. It owns an immutable\n * Collection Node which is copied on write.\n */\nexport class ElementNode<T> extends BaseNode<T> {\n nodeType = 8; // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)\n node: NodeValue<T>;\n private _index: number = 0;\n hasSetProps = false;\n\n constructor(type: string, ownerDocument: Document<T, any>) {\n super(ownerDocument);\n this.node = new NodeValue(type, `react-aria-${++ownerDocument.nodeId}`);\n // Start a transaction so that no updates are emitted from the collection\n // until the props for this node are set. We don't know the real id for the\n // node until then, so we need to avoid emitting collections in an inconsistent state.\n this.ownerDocument.startTransaction();\n }\n\n get index() {\n return this._index;\n }\n\n set index(index) {\n this._index = index;\n this.ownerDocument.markDirty(this);\n }\n\n get level(): number {\n if (this.parentNode instanceof ElementNode) {\n return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);\n }\n\n return 0;\n }\n\n updateNode() {\n let node = this.ownerDocument.getMutableNode(this);\n node.index = this.index;\n node.level = this.level;\n node.parentKey = this.parentNode instanceof ElementNode ? this.parentNode.node.key : null;\n node.prevKey = this.previousSibling?.node.key ?? null;\n node.nextKey = this.nextSibling?.node.key ?? null;\n node.hasChildNodes = !!this.firstChild;\n node.firstChildKey = this.firstChild?.node.key ?? null;\n node.lastChildKey = this.lastChild?.node.key ?? null;\n }\n\n setProps<E extends Element>(obj: any, ref: ForwardedRef<E>, rendered?: any, render?: (node: Node<T>) => ReactElement) {\n let node = this.ownerDocument.getMutableNode(this);\n let {value, textValue, id, ...props} = obj;\n props.ref = ref;\n node.props = props;\n node.rendered = rendered;\n node.render = render;\n node.value = value;\n node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';\n if (id != null && id !== node.key) {\n if (this.hasSetProps) {\n throw new Error('Cannot change the id of an item');\n }\n node.key = id;\n }\n\n // If this is the first time props have been set, end the transaction started in the constructor\n // so this node can be emitted.\n if (!this.hasSetProps) {\n this.ownerDocument.addNode(this);\n this.ownerDocument.endTransaction();\n this.hasSetProps = true;\n }\n\n this.ownerDocument.queueUpdate();\n }\n\n get style() {\n return {};\n }\n\n hasAttribute() {}\n setAttribute() {}\n setAttributeNS() {}\n removeAttribute() {}\n}\n\n/**\n * A mutable Document in the fake DOM. It owns an immutable Collection instance,\n * which is lazily copied on write during updates.\n */\nexport class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extends BaseNode<T> {\n nodeType = 11; // DOCUMENT_FRAGMENT_NODE\n ownerDocument = this;\n dirtyNodes: Set<BaseNode<T>> = new Set();\n isSSR = false;\n nodeId = 0;\n nodesByProps = new WeakMap<object, ElementNode<T>>();\n isMounted = true;\n private collection: C;\n private collectionMutated: boolean;\n private mutatedNodes: Set<ElementNode<T>> = new Set();\n private subscriptions: Set<() => void> = new Set();\n private transactionCount = 0;\n\n constructor(collection: C) {\n // @ts-ignore\n super(null);\n this.collection = collection;\n this.collectionMutated = true;\n }\n\n get isConnected() {\n return this.isMounted;\n }\n\n createElement(type: string) {\n return new ElementNode(type, this);\n }\n\n /**\n * Lazily gets a mutable instance of a Node. If the node has already\n * been cloned during this update cycle, it just returns the existing one.\n */\n getMutableNode(element: ElementNode<T>): Mutable<NodeValue<T>> {\n let node = element.node;\n if (!this.mutatedNodes.has(element)) {\n node = element.node.clone();\n this.mutatedNodes.add(element);\n element.node = node;\n }\n this.markDirty(element);\n return node;\n }\n\n private getMutableCollection() {\n if (!this.isSSR && !this.collectionMutated) {\n this.collection = this.collection.clone();\n this.collectionMutated = true;\n }\n\n return this.collection;\n }\n\n markDirty(node: BaseNode<T>) {\n this.dirtyNodes.add(node);\n }\n\n startTransaction() {\n this.transactionCount++;\n }\n\n endTransaction() {\n this.transactionCount--;\n }\n\n addNode(element: ElementNode<T>) {\n let collection = this.getMutableCollection();\n if (!collection.getItem(element.node.key)) {\n collection.addNode(element.node);\n\n for (let child of element) {\n this.addNode(child);\n }\n }\n\n this.markDirty(element);\n }\n\n removeNode(node: ElementNode<T>) {\n for (let child of node) {\n this.removeNode(child);\n }\n\n let collection = this.getMutableCollection();\n collection.removeNode(node.node.key);\n this.markDirty(node);\n }\n\n /** Finalizes the collection update, updating all nodes and freezing the collection. */\n getCollection(): C {\n if (this.transactionCount > 0) {\n return this.collection;\n }\n\n this.updateCollection();\n return this.collection;\n }\n\n updateCollection() {\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode && element.isConnected) {\n element.updateNode();\n }\n }\n\n this.dirtyNodes.clear();\n\n if (this.mutatedNodes.size || this.collectionMutated) {\n let collection = this.getMutableCollection();\n for (let element of this.mutatedNodes) {\n if (element.isConnected) {\n collection.addNode(element.node);\n }\n }\n\n collection.commit(this.firstChild?.node.key ?? null, this.lastChild?.node.key ?? null, this.isSSR);\n this.mutatedNodes.clear();\n }\n\n this.collectionMutated = false;\n }\n\n queueUpdate() {\n // Don't emit any updates if there is a transaction in progress.\n // queueUpdate should be called again after the transaction.\n if (this.dirtyNodes.size === 0 || this.transactionCount > 0) {\n return;\n }\n\n for (let fn of this.subscriptions) {\n fn();\n }\n }\n\n subscribe(fn: () => void) {\n this.subscriptions.add(fn);\n return () => this.subscriptions.delete(fn);\n }\n\n resetAfterSSR() {\n if (this.isSSR) {\n this.isSSR = false;\n this.firstChild = null;\n this.lastChild = null;\n this.nodeId = 0;\n }\n }\n}\n"],"names":[],"version":3,"file":"Document.module.js.map"}
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAYX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,IAAI,OAAO,IAAI,CAAC,UAAU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AChB;IACF;IApIA,YAAY,UAAa,CAAE;QACzB,aAAa;QACb,KAAK,CAAC;aAfR,WAAW,GAAI,yBAAyB;;aACxC,gBAAgB,IAAI;aACpB,aAA+B,IAAI;aACnC,QAAQ;aACR,SAAS;aACT,eAAe,IAAI;aACnB,YAAY;aAGJ,eAAoC,IAAI;aACxC,gBAAiC,IAAI;aACrC,mBAAmB;QAKzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,iBAAiB,GAAG;IAC3B;AAgIF","sources":["packages/@react-aria/collections/src/Document.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 {BaseCollection, CollectionNode, Mutable} from './BaseCollection';\nimport {ForwardedRef, ReactElement} from 'react';\nimport {Node} from '@react-types/shared';\n\n// This Collection implementation is perhaps a little unusual. It works by rendering the React tree into a\n// Portal to a fake DOM implementation. This gives us efficient access to the tree of rendered objects, and\n// supports React features like composition and context. We use this fake DOM to access the full set of elements\n// before we render into the real DOM, which allows us to render a subset of the elements (e.g. virtualized scrolling),\n// and compute properties like the total number of items. It also enables keyboard navigation, selection, and other features.\n// React takes care of efficiently rendering components and updating the collection for us via this fake DOM.\n//\n// The DOM is a mutable API, and React expects the node instances to remain stable over time. So the implementation is split\n// into two parts. Each mutable fake DOM node owns an instance of an immutable collection node. When a fake DOM node is updated,\n// it queues a second render for the collection. Multiple updates to a collection can be queued at once. Collection nodes are\n// lazily copied on write, so only the changed nodes need to be cloned. During the second render, the new immutable collection\n// is finalized by updating the map of Key -> Node with the new cloned nodes. Then the new collection is frozen so it can no\n// longer be mutated, and returned to the calling component to render.\n\n/**\n * A mutable node in the fake DOM tree. When mutated, it marks itself as dirty\n * and queues an update with the owner document.\n */\nexport class BaseNode<T> {\n private _firstChild: ElementNode<T> | null = null;\n private _lastChild: ElementNode<T> | null = null;\n private _previousSibling: ElementNode<T> | null = null;\n private _nextSibling: ElementNode<T> | null = null;\n private _parentNode: BaseNode<T> | null = null;\n ownerDocument: Document<T, any>;\n\n constructor(ownerDocument: Document<T, any>) {\n this.ownerDocument = ownerDocument;\n }\n\n *[Symbol.iterator]() {\n let node = this.firstChild;\n while (node) {\n yield node;\n node = node.nextSibling;\n }\n }\n\n get firstChild() {\n return this._firstChild;\n }\n\n set firstChild(firstChild) {\n this._firstChild = firstChild;\n this.ownerDocument.markDirty(this);\n }\n\n get lastChild() {\n return this._lastChild;\n }\n\n set lastChild(lastChild) {\n this._lastChild = lastChild;\n this.ownerDocument.markDirty(this);\n }\n\n get previousSibling() {\n return this._previousSibling;\n }\n\n set previousSibling(previousSibling) {\n this._previousSibling = previousSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get nextSibling() {\n return this._nextSibling;\n }\n\n set nextSibling(nextSibling) {\n this._nextSibling = nextSibling;\n this.ownerDocument.markDirty(this);\n }\n\n get parentNode() {\n return this._parentNode;\n }\n\n set parentNode(parentNode) {\n this._parentNode = parentNode;\n this.ownerDocument.markDirty(this);\n }\n\n get isConnected() {\n return this.parentNode?.isConnected || false;\n }\n\n appendChild(child: ElementNode<T>) {\n this.ownerDocument.startTransaction();\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n\n if (this.firstChild == null) {\n this.firstChild = child;\n }\n\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.index = this.lastChild.index + 1;\n child.previousSibling = this.lastChild;\n } else {\n child.previousSibling = null;\n child.index = 0;\n }\n\n child.parentNode = this;\n child.nextSibling = null;\n this.lastChild = child;\n\n this.ownerDocument.markDirty(this);\n if (child.hasSetProps) {\n // Only add the node to the collection if we already received props for it.\n // Otherwise wait until then so we have the correct id for the node.\n this.ownerDocument.addNode(child);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>) {\n if (referenceNode == null) {\n return this.appendChild(newNode);\n }\n\n this.ownerDocument.startTransaction();\n if (newNode.parentNode) {\n newNode.parentNode.removeChild(newNode);\n }\n\n newNode.nextSibling = referenceNode;\n newNode.previousSibling = referenceNode.previousSibling;\n newNode.index = referenceNode.index;\n\n if (this.firstChild === referenceNode) {\n this.firstChild = newNode;\n } else if (referenceNode.previousSibling) {\n referenceNode.previousSibling.nextSibling = newNode;\n }\n\n referenceNode.previousSibling = newNode;\n newNode.parentNode = referenceNode.parentNode;\n\n let node: ElementNode<T> | null = referenceNode;\n while (node) {\n node.index++;\n node = node.nextSibling;\n }\n\n if (newNode.hasSetProps) {\n this.ownerDocument.addNode(newNode);\n }\n\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n removeChild(child: ElementNode<T>) {\n if (child.parentNode !== this || !this.ownerDocument.isMounted) {\n return;\n }\n\n this.ownerDocument.startTransaction();\n let node = child.nextSibling;\n while (node) {\n node.index--;\n node = node.nextSibling;\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling;\n }\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n }\n\n if (this.firstChild === child) {\n this.firstChild = child.nextSibling;\n }\n\n if (this.lastChild === child) {\n this.lastChild = child.previousSibling;\n }\n\n child.parentNode = null;\n child.nextSibling = null;\n child.previousSibling = null;\n child.index = 0;\n\n this.ownerDocument.removeNode(child);\n this.ownerDocument.endTransaction();\n this.ownerDocument.queueUpdate();\n }\n\n addEventListener() {}\n removeEventListener() {}\n}\n\n/**\n * A mutable element node in the fake DOM tree. It owns an immutable\n * Collection Node which is copied on write.\n */\nexport class ElementNode<T> extends BaseNode<T> {\n nodeType = 8; // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)\n node: CollectionNode<T>;\n private _index: number = 0;\n hasSetProps = false;\n\n constructor(type: string, ownerDocument: Document<T, any>) {\n super(ownerDocument);\n this.node = new CollectionNode(type, `react-aria-${++ownerDocument.nodeId}`);\n // Start a transaction so that no updates are emitted from the collection\n // until the props for this node are set. We don't know the real id for the\n // node until then, so we need to avoid emitting collections in an inconsistent state.\n this.ownerDocument.startTransaction();\n }\n\n get index() {\n return this._index;\n }\n\n set index(index) {\n this._index = index;\n this.ownerDocument.markDirty(this);\n }\n\n get level(): number {\n if (this.parentNode instanceof ElementNode) {\n return this.parentNode.level + (this.node.type === 'item' ? 1 : 0);\n }\n\n return 0;\n }\n\n updateNode() {\n let node = this.ownerDocument.getMutableNode(this);\n node.index = this.index;\n node.level = this.level;\n node.parentKey = this.parentNode instanceof ElementNode ? this.parentNode.node.key : null;\n node.prevKey = this.previousSibling?.node.key ?? null;\n node.nextKey = this.nextSibling?.node.key ?? null;\n node.hasChildNodes = !!this.firstChild;\n node.firstChildKey = this.firstChild?.node.key ?? null;\n node.lastChildKey = this.lastChild?.node.key ?? null;\n }\n\n setProps<E extends Element>(obj: any, ref: ForwardedRef<E>, rendered?: any, render?: (node: Node<T>) => ReactElement) {\n let node = this.ownerDocument.getMutableNode(this);\n let {value, textValue, id, ...props} = obj;\n props.ref = ref;\n node.props = props;\n node.rendered = rendered;\n node.render = render;\n node.value = value;\n node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || '';\n if (id != null && id !== node.key) {\n if (this.hasSetProps) {\n throw new Error('Cannot change the id of an item');\n }\n node.key = id;\n }\n\n // If this is the first time props have been set, end the transaction started in the constructor\n // so this node can be emitted.\n if (!this.hasSetProps) {\n this.ownerDocument.addNode(this);\n this.ownerDocument.endTransaction();\n this.hasSetProps = true;\n }\n\n this.ownerDocument.queueUpdate();\n }\n\n get style() {\n return {};\n }\n\n hasAttribute() {}\n setAttribute() {}\n setAttributeNS() {}\n removeAttribute() {}\n}\n\n/**\n * A mutable Document in the fake DOM. It owns an immutable Collection instance,\n * which is lazily copied on write during updates.\n */\nexport class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extends BaseNode<T> {\n nodeType = 11; // DOCUMENT_FRAGMENT_NODE\n ownerDocument = this;\n dirtyNodes: Set<BaseNode<T>> = new Set();\n isSSR = false;\n nodeId = 0;\n nodesByProps = new WeakMap<object, ElementNode<T>>();\n isMounted = true;\n private collection: C;\n private collectionMutated: boolean;\n private mutatedNodes: Set<ElementNode<T>> = new Set();\n private subscriptions: Set<() => void> = new Set();\n private transactionCount = 0;\n\n constructor(collection: C) {\n // @ts-ignore\n super(null);\n this.collection = collection;\n this.collectionMutated = true;\n }\n\n get isConnected() {\n return this.isMounted;\n }\n\n createElement(type: string) {\n return new ElementNode(type, this);\n }\n\n /**\n * Lazily gets a mutable instance of a Node. If the node has already\n * been cloned during this update cycle, it just returns the existing one.\n */\n getMutableNode(element: ElementNode<T>): Mutable<CollectionNode<T>> {\n let node = element.node;\n if (!this.mutatedNodes.has(element)) {\n node = element.node.clone();\n this.mutatedNodes.add(element);\n element.node = node;\n }\n this.markDirty(element);\n return node;\n }\n\n private getMutableCollection() {\n if (!this.isSSR && !this.collectionMutated) {\n this.collection = this.collection.clone();\n this.collectionMutated = true;\n }\n\n return this.collection;\n }\n\n markDirty(node: BaseNode<T>) {\n this.dirtyNodes.add(node);\n }\n\n startTransaction() {\n this.transactionCount++;\n }\n\n endTransaction() {\n this.transactionCount--;\n }\n\n addNode(element: ElementNode<T>) {\n let collection = this.getMutableCollection();\n if (!collection.getItem(element.node.key)) {\n collection.addNode(element.node);\n\n for (let child of element) {\n this.addNode(child);\n }\n }\n\n this.markDirty(element);\n }\n\n removeNode(node: ElementNode<T>) {\n for (let child of node) {\n this.removeNode(child);\n }\n\n let collection = this.getMutableCollection();\n collection.removeNode(node.node.key);\n this.markDirty(node);\n }\n\n /** Finalizes the collection update, updating all nodes and freezing the collection. */\n getCollection(): C {\n if (this.transactionCount > 0) {\n return this.collection;\n }\n\n this.updateCollection();\n return this.collection;\n }\n\n updateCollection() {\n for (let element of this.dirtyNodes) {\n if (element instanceof ElementNode && element.isConnected) {\n element.updateNode();\n }\n }\n\n this.dirtyNodes.clear();\n\n if (this.mutatedNodes.size || this.collectionMutated) {\n let collection = this.getMutableCollection();\n for (let element of this.mutatedNodes) {\n if (element.isConnected) {\n collection.addNode(element.node);\n }\n }\n\n collection.commit(this.firstChild?.node.key ?? null, this.lastChild?.node.key ?? null, this.isSSR);\n this.mutatedNodes.clear();\n }\n\n this.collectionMutated = false;\n }\n\n queueUpdate() {\n // Don't emit any updates if there is a transaction in progress.\n // queueUpdate should be called again after the transaction.\n if (this.dirtyNodes.size === 0 || this.transactionCount > 0) {\n return;\n }\n\n for (let fn of this.subscriptions) {\n fn();\n }\n }\n\n subscribe(fn: () => void) {\n this.subscriptions.add(fn);\n return () => this.subscriptions.delete(fn);\n }\n\n resetAfterSSR() {\n if (this.isSSR) {\n this.isSSR = false;\n this.firstChild = null;\n this.lastChild = null;\n this.nodeId = 0;\n }\n }\n}\n"],"names":[],"version":3,"file":"Document.module.js.map"}
|
package/dist/import.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Collection as $e1995378a142960e$export$fb8073518f34e6ec, CollectionBuilder as $e1995378a142960e$export$bf788dd355e3a401, createBranchComponent as $e1995378a142960e$export$e953bb1cd0f19726, createLeafComponent as $e1995378a142960e$export$18af5c7a9e9b3664} from "./CollectionBuilder.mjs";
|
|
2
2
|
import {createHideableComponent as $f39a9eba43920ace$export$86427a43e3e48ebb, useIsHidden as $f39a9eba43920ace$export$b5d7cc18bb8d2b59} from "./Hidden.mjs";
|
|
3
3
|
import {useCachedChildren as $e948873055cbafe4$export$727c8fc270210f13} from "./useCachedChildren.mjs";
|
|
4
|
-
import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025,
|
|
4
|
+
import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025, CollectionNode as $23b9f4fcf0fe224b$export$d68d59712b04d9d1} from "./BaseCollection.mjs";
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -19,5 +19,5 @@ import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025, NodeValue a
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
export {$e1995378a142960e$export$bf788dd355e3a401 as CollectionBuilder, $e1995378a142960e$export$fb8073518f34e6ec as Collection, $e1995378a142960e$export$18af5c7a9e9b3664 as createLeafComponent, $e1995378a142960e$export$e953bb1cd0f19726 as createBranchComponent, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden, $e948873055cbafe4$export$727c8fc270210f13 as useCachedChildren, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection, $23b9f4fcf0fe224b$export$
|
|
22
|
+
export {$e1995378a142960e$export$bf788dd355e3a401 as CollectionBuilder, $e1995378a142960e$export$fb8073518f34e6ec as Collection, $e1995378a142960e$export$18af5c7a9e9b3664 as createLeafComponent, $e1995378a142960e$export$e953bb1cd0f19726 as createBranchComponent, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden, $e948873055cbafe4$export$727c8fc270210f13 as useCachedChildren, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection, $23b9f4fcf0fe224b$export$d68d59712b04d9d1 as CollectionNode};
|
|
23
23
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -16,7 +16,7 @@ $parcel$export(module.exports, "createHideableComponent", () => $eaaf60978b89fc5
|
|
|
16
16
|
$parcel$export(module.exports, "useIsHidden", () => $eaaf60978b89fc58$exports.useIsHidden);
|
|
17
17
|
$parcel$export(module.exports, "useCachedChildren", () => $245f3f827bea6653$exports.useCachedChildren);
|
|
18
18
|
$parcel$export(module.exports, "BaseCollection", () => $499e2959ba1abacc$exports.BaseCollection);
|
|
19
|
-
$parcel$export(module.exports, "
|
|
19
|
+
$parcel$export(module.exports, "CollectionNode", () => $499e2959ba1abacc$exports.CollectionNode);
|
|
20
20
|
/*
|
|
21
21
|
* Copyright 2024 Adobe. All rights reserved.
|
|
22
22
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/collections/src/index.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\nexport {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/collections/src/index.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\nexport {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection, CollectionNode} from './BaseCollection';\n\nexport type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';\nexport type {CachedChildrenOptions} from './useCachedChildren';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Collection as $e1995378a142960e$export$fb8073518f34e6ec, CollectionBuilder as $e1995378a142960e$export$bf788dd355e3a401, createBranchComponent as $e1995378a142960e$export$e953bb1cd0f19726, createLeafComponent as $e1995378a142960e$export$18af5c7a9e9b3664} from "./CollectionBuilder.module.js";
|
|
2
2
|
import {createHideableComponent as $f39a9eba43920ace$export$86427a43e3e48ebb, useIsHidden as $f39a9eba43920ace$export$b5d7cc18bb8d2b59} from "./Hidden.module.js";
|
|
3
3
|
import {useCachedChildren as $e948873055cbafe4$export$727c8fc270210f13} from "./useCachedChildren.module.js";
|
|
4
|
-
import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025,
|
|
4
|
+
import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025, CollectionNode as $23b9f4fcf0fe224b$export$d68d59712b04d9d1} from "./BaseCollection.module.js";
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -19,5 +19,5 @@ import {BaseCollection as $23b9f4fcf0fe224b$export$408d25a4e12db025, NodeValue a
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
export {$e1995378a142960e$export$bf788dd355e3a401 as CollectionBuilder, $e1995378a142960e$export$fb8073518f34e6ec as Collection, $e1995378a142960e$export$18af5c7a9e9b3664 as createLeafComponent, $e1995378a142960e$export$e953bb1cd0f19726 as createBranchComponent, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden, $e948873055cbafe4$export$727c8fc270210f13 as useCachedChildren, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection, $23b9f4fcf0fe224b$export$
|
|
22
|
+
export {$e1995378a142960e$export$bf788dd355e3a401 as CollectionBuilder, $e1995378a142960e$export$fb8073518f34e6ec as Collection, $e1995378a142960e$export$18af5c7a9e9b3664 as createLeafComponent, $e1995378a142960e$export$e953bb1cd0f19726 as createBranchComponent, $f39a9eba43920ace$export$86427a43e3e48ebb as createHideableComponent, $f39a9eba43920ace$export$b5d7cc18bb8d2b59 as useIsHidden, $e948873055cbafe4$export$727c8fc270210f13 as useCachedChildren, $23b9f4fcf0fe224b$export$408d25a4e12db025 as BaseCollection, $23b9f4fcf0fe224b$export$d68d59712b04d9d1 as CollectionNode};
|
|
23
23
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/collections/src/index.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\nexport {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection,
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/collections/src/index.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\nexport {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection, CollectionNode} from './BaseCollection';\n\nexport type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';\nexport type {CachedChildrenOptions} from './useCachedChildren';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection as _Collection1, Key, Node } from "@react-types/shared";
|
|
2
2
|
import React, { ReactElement, ReactNode, ForwardedRef, JSX } from "react";
|
|
3
3
|
/** An immutable object representing a Node in a Collection. */
|
|
4
|
-
export class
|
|
4
|
+
export class CollectionNode<T> implements Node<T> {
|
|
5
5
|
readonly type: string;
|
|
6
6
|
readonly key: Key;
|
|
7
7
|
readonly value: T | null;
|
|
@@ -20,7 +20,7 @@ export class NodeValue<T> implements Node<T> {
|
|
|
20
20
|
readonly render?: (node: Node<any>) => ReactElement;
|
|
21
21
|
constructor(type: string, key: Key);
|
|
22
22
|
get childNodes(): Iterable<Node<T>>;
|
|
23
|
-
clone():
|
|
23
|
+
clone(): CollectionNode<T>;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* An immutable Collection implementation. Updates are only allowed
|
|
@@ -39,7 +39,7 @@ export class BaseCollection<T> implements _Collection1<Node<T>> {
|
|
|
39
39
|
getItem(key: Key): Node<T> | null;
|
|
40
40
|
at(): Node<T>;
|
|
41
41
|
clone(): this;
|
|
42
|
-
addNode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AAM,EAAE,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,SAAS,EAAE,WAAW,GAAE,CAAC,KAAK,EAAE,CAAC,KAAK,SAAiC,iEAStP;AAMD,iCAAiC,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC;CAAG;AAIvE,qFAAqF;AACrF,2BAA2B,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,GAAG,IAAI,OAAO,CA2BnF","sources":["packages/@react-aria/collections/src/packages/@react-aria/collections/src/BaseCollection.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/Document.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/useCachedChildren.ts","packages/@react-aria/collections/src/packages/@react-aria/collections/src/Hidden.tsx","packages/@react-aria/collections/src/packages/@react-aria/collections/src/CollectionBuilder.tsx","packages/@react-aria/collections/src/packages/@react-aria/collections/src/index.ts","packages/@react-aria/collections/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"/*\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\nexport {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';\nexport {createHideableComponent, useIsHidden} from './Hidden';\nexport {useCachedChildren} from './useCachedChildren';\nexport {BaseCollection, CollectionNode} from './BaseCollection';\n\nexport type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';\nexport type {CachedChildrenOptions} from './useCachedChildren';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/collections",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.3018+927758756",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/ssr": "3.9.5-nightly.
|
|
26
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
27
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-aria/ssr": "3.9.5-nightly.4730+927758756",
|
|
26
|
+
"@react-aria/utils": "3.0.0-nightly.3018+927758756",
|
|
27
|
+
"@react-types/shared": "3.0.0-nightly.3018+927758756",
|
|
28
28
|
"@swc/helpers": "^0.5.0",
|
|
29
29
|
"use-sync-external-store": "^1.2.0"
|
|
30
30
|
},
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "92775875627ef8a038a4708b1a7addf11809bf35"
|
|
39
39
|
}
|
package/src/BaseCollection.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type Mutable<T> = {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** An immutable object representing a Node in a Collection. */
|
|
21
|
-
export class
|
|
21
|
+
export class CollectionNode<T> implements Node<T> {
|
|
22
22
|
readonly type: string;
|
|
23
23
|
readonly key: Key;
|
|
24
24
|
readonly value: T | null = null;
|
|
@@ -45,8 +45,8 @@ export class NodeValue<T> implements Node<T> {
|
|
|
45
45
|
throw new Error('childNodes is not supported');
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
clone():
|
|
49
|
-
let node: Mutable<
|
|
48
|
+
clone(): CollectionNode<T> {
|
|
49
|
+
let node: Mutable<CollectionNode<T>> = new CollectionNode(this.type, this.key);
|
|
50
50
|
node.value = this.value;
|
|
51
51
|
node.level = this.level;
|
|
52
52
|
node.hasChildNodes = this.hasChildNodes;
|
|
@@ -71,7 +71,7 @@ export class NodeValue<T> implements Node<T> {
|
|
|
71
71
|
* custom collection behaviors.
|
|
72
72
|
*/
|
|
73
73
|
export class BaseCollection<T> implements ICollection<Node<T>> {
|
|
74
|
-
private keyMap: Map<Key,
|
|
74
|
+
private keyMap: Map<Key, CollectionNode<T>> = new Map();
|
|
75
75
|
private firstKey: Key | null = null;
|
|
76
76
|
private lastKey: Key | null = null;
|
|
77
77
|
private frozen = false;
|
|
@@ -183,7 +183,7 @@ export class BaseCollection<T> implements ICollection<Node<T>> {
|
|
|
183
183
|
return collection;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
addNode(node:
|
|
186
|
+
addNode(node: CollectionNode<T>) {
|
|
187
187
|
if (this.frozen) {
|
|
188
188
|
throw new Error('Cannot add a node to a frozen collection');
|
|
189
189
|
}
|
package/src/Document.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {BaseCollection,
|
|
13
|
+
import {BaseCollection, CollectionNode, Mutable} from './BaseCollection';
|
|
14
14
|
import {ForwardedRef, ReactElement} from 'react';
|
|
15
15
|
import {Node} from '@react-types/shared';
|
|
16
16
|
|
|
@@ -220,13 +220,13 @@ export class BaseNode<T> {
|
|
|
220
220
|
*/
|
|
221
221
|
export class ElementNode<T> extends BaseNode<T> {
|
|
222
222
|
nodeType = 8; // COMMENT_NODE (we'd use ELEMENT_NODE but React DevTools will fail to get its dimensions)
|
|
223
|
-
node:
|
|
223
|
+
node: CollectionNode<T>;
|
|
224
224
|
private _index: number = 0;
|
|
225
225
|
hasSetProps = false;
|
|
226
226
|
|
|
227
227
|
constructor(type: string, ownerDocument: Document<T, any>) {
|
|
228
228
|
super(ownerDocument);
|
|
229
|
-
this.node = new
|
|
229
|
+
this.node = new CollectionNode(type, `react-aria-${++ownerDocument.nodeId}`);
|
|
230
230
|
// Start a transaction so that no updates are emitted from the collection
|
|
231
231
|
// until the props for this node are set. We don't know the real id for the
|
|
232
232
|
// node until then, so we need to avoid emitting collections in an inconsistent state.
|
|
@@ -336,7 +336,7 @@ export class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extend
|
|
|
336
336
|
* Lazily gets a mutable instance of a Node. If the node has already
|
|
337
337
|
* been cloned during this update cycle, it just returns the existing one.
|
|
338
338
|
*/
|
|
339
|
-
getMutableNode(element: ElementNode<T>): Mutable<
|
|
339
|
+
getMutableNode(element: ElementNode<T>): Mutable<CollectionNode<T>> {
|
|
340
340
|
let node = element.node;
|
|
341
341
|
if (!this.mutatedNodes.has(element)) {
|
|
342
342
|
node = element.node.clone();
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
export {CollectionBuilder, Collection, createLeafComponent, createBranchComponent} from './CollectionBuilder';
|
|
14
14
|
export {createHideableComponent, useIsHidden} from './Hidden';
|
|
15
15
|
export {useCachedChildren} from './useCachedChildren';
|
|
16
|
-
export {BaseCollection,
|
|
16
|
+
export {BaseCollection, CollectionNode} from './BaseCollection';
|
|
17
17
|
|
|
18
18
|
export type {CollectionBuilderProps, CollectionProps} from './CollectionBuilder';
|
|
19
19
|
export type {CachedChildrenOptions} from './useCachedChildren';
|