@react-stately/list 3.10.4-nightly.4552 → 3.10.4-nightly.4558

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$d085fb9e920b5ca7);
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ class $c9aa5a224613c979$export$d085fb9e920b5ca7 {
18
+ *[Symbol.iterator]() {
19
+ yield* this.iterable;
20
+ }
21
+ get size() {
22
+ return this.keyMap.size;
23
+ }
24
+ getKeys() {
25
+ return this.keyMap.keys();
26
+ }
27
+ getKeyBefore(key) {
28
+ let node = this.keyMap.get(key);
29
+ return node ? node.prevKey : null;
30
+ }
31
+ getKeyAfter(key) {
32
+ let node = this.keyMap.get(key);
33
+ return node ? node.nextKey : null;
34
+ }
35
+ getFirstKey() {
36
+ return this.firstKey;
37
+ }
38
+ getLastKey() {
39
+ return this.lastKey;
40
+ }
41
+ getItem(key) {
42
+ return this.keyMap.get(key);
43
+ }
44
+ at(idx) {
45
+ const keys = [
46
+ ...this.getKeys()
47
+ ];
48
+ return this.getItem(keys[idx]);
49
+ }
50
+ getChildren(key) {
51
+ let node = this.keyMap.get(key);
52
+ return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
53
+ }
54
+ constructor(nodes){
55
+ this.keyMap = new Map();
56
+ this.iterable = nodes;
57
+ let visit = (node)=>{
58
+ this.keyMap.set(node.key, node);
59
+ if (node.childNodes && node.type === "section") for (let child of node.childNodes)visit(child);
60
+ };
61
+ for (let node of nodes)visit(node);
62
+ let last;
63
+ let index = 0;
64
+ for (let [key, node] of this.keyMap){
65
+ if (last) {
66
+ last.nextKey = key;
67
+ node.prevKey = last.key;
68
+ } else {
69
+ this.firstKey = key;
70
+ node.prevKey = undefined;
71
+ }
72
+ if (node.type === "item") node.index = index++;
73
+ last = node;
74
+ // Set nextKey as undefined since this might be the last node
75
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
76
+ last.nextKey = undefined;
77
+ }
78
+ this.lastKey = last === null || last === void 0 ? void 0 : last.key;
79
+ }
80
+ }
81
+
82
+
83
+ //# sourceMappingURL=ListCollection.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAgDX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC3B,OAAO,OAAO,KAAK,OAAO,GAAG;IAC/B;IAEA,YAAY,GAAQ,EAAE;QACpB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC3B,OAAO,OAAO,KAAK,OAAO,GAAG;IAC/B;IAEA,cAAc;QACZ,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,aAAa;QACX,OAAO,IAAI,CAAC,OAAO;IACrB;IAEA,QAAQ,GAAQ,EAAE;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;IACzB;IAEA,GAAG,GAAW,EAAE;QACd,MAAM,OAAO;eAAI,IAAI,CAAC,OAAO;SAAG;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;IAC/B;IAEA,YAAY,GAAQ,EAAqB;QACvC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC3B,OAAO,CAAA,iBAAA,2BAAA,KAAM,UAAU,KAAI,EAAE;IAC/B;IApFA,YAAY,KAAwB,CAAE;aAL9B,SAA4B,IAAI;QAMtC,IAAI,CAAC,QAAQ,GAAG;QAEhB,IAAI,QAAQ,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE;YAE1B,IAAI,KAAK,UAAU,IAAI,KAAK,IAAI,KAAK,WACnC,KAAK,IAAI,SAAS,KAAK,UAAU,CAC/B,MAAM;QAGZ;QAEA,KAAK,IAAI,QAAQ,MACf,MAAM;QAGR,IAAI;QACJ,IAAI,QAAQ;QACZ,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAE;YACnC,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG;gBACf,KAAK,OAAO,GAAG,KAAK,GAAG;YACzB,OAAO;gBACL,IAAI,CAAC,QAAQ,GAAG;gBAChB,KAAK,OAAO,GAAG;YACjB;YAEA,IAAI,KAAK,IAAI,KAAK,QAChB,KAAK,KAAK,GAAG;YAGf,OAAO;YAEP,6DAA6D;YAC7D,iFAAiF;YACjF,KAAK,OAAO,GAAG;QACjB;QAEA,IAAI,CAAC,OAAO,GAAG,iBAAA,2BAAA,KAAM,GAAG;IAC1B;AA6CF","sources":["packages/@react-stately/list/src/ListCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, Node} from '@react-types/shared';\n\nexport class ListCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key;\n private lastKey: Key;\n\n constructor(nodes: Iterable<Node<T>>) {\n this.iterable = nodes;\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && node.type === 'section') {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T>;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getChildren(key: Key): Iterable<Node<T>> {\n let node = this.keyMap.get(key);\n return node?.childNodes || [];\n }\n}\n"],"names":[],"version":3,"file":"ListCollection.main.js.map"}
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $a02d57049d202695$export$d085fb9e920b5ca7 {
12
+ *[Symbol.iterator]() {
13
+ yield* this.iterable;
14
+ }
15
+ get size() {
16
+ return this.keyMap.size;
17
+ }
18
+ getKeys() {
19
+ return this.keyMap.keys();
20
+ }
21
+ getKeyBefore(key) {
22
+ let node = this.keyMap.get(key);
23
+ return node ? node.prevKey : null;
24
+ }
25
+ getKeyAfter(key) {
26
+ let node = this.keyMap.get(key);
27
+ return node ? node.nextKey : null;
28
+ }
29
+ getFirstKey() {
30
+ return this.firstKey;
31
+ }
32
+ getLastKey() {
33
+ return this.lastKey;
34
+ }
35
+ getItem(key) {
36
+ return this.keyMap.get(key);
37
+ }
38
+ at(idx) {
39
+ const keys = [
40
+ ...this.getKeys()
41
+ ];
42
+ return this.getItem(keys[idx]);
43
+ }
44
+ getChildren(key) {
45
+ let node = this.keyMap.get(key);
46
+ return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
47
+ }
48
+ constructor(nodes){
49
+ this.keyMap = new Map();
50
+ this.iterable = nodes;
51
+ let visit = (node)=>{
52
+ this.keyMap.set(node.key, node);
53
+ if (node.childNodes && node.type === "section") for (let child of node.childNodes)visit(child);
54
+ };
55
+ for (let node of nodes)visit(node);
56
+ let last;
57
+ let index = 0;
58
+ for (let [key, node] of this.keyMap){
59
+ if (last) {
60
+ last.nextKey = key;
61
+ node.prevKey = last.key;
62
+ } else {
63
+ this.firstKey = key;
64
+ node.prevKey = undefined;
65
+ }
66
+ if (node.type === "item") node.index = index++;
67
+ last = node;
68
+ // Set nextKey as undefined since this might be the last node
69
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
70
+ last.nextKey = undefined;
71
+ }
72
+ this.lastKey = last === null || last === void 0 ? void 0 : last.key;
73
+ }
74
+ }
75
+
76
+
77
+ export {$a02d57049d202695$export$d085fb9e920b5ca7 as ListCollection};
78
+ //# sourceMappingURL=ListCollection.mjs.map
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $a02d57049d202695$export$d085fb9e920b5ca7 {
12
+ *[Symbol.iterator]() {
13
+ yield* this.iterable;
14
+ }
15
+ get size() {
16
+ return this.keyMap.size;
17
+ }
18
+ getKeys() {
19
+ return this.keyMap.keys();
20
+ }
21
+ getKeyBefore(key) {
22
+ let node = this.keyMap.get(key);
23
+ return node ? node.prevKey : null;
24
+ }
25
+ getKeyAfter(key) {
26
+ let node = this.keyMap.get(key);
27
+ return node ? node.nextKey : null;
28
+ }
29
+ getFirstKey() {
30
+ return this.firstKey;
31
+ }
32
+ getLastKey() {
33
+ return this.lastKey;
34
+ }
35
+ getItem(key) {
36
+ return this.keyMap.get(key);
37
+ }
38
+ at(idx) {
39
+ const keys = [
40
+ ...this.getKeys()
41
+ ];
42
+ return this.getItem(keys[idx]);
43
+ }
44
+ getChildren(key) {
45
+ let node = this.keyMap.get(key);
46
+ return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
47
+ }
48
+ constructor(nodes){
49
+ this.keyMap = new Map();
50
+ this.iterable = nodes;
51
+ let visit = (node)=>{
52
+ this.keyMap.set(node.key, node);
53
+ if (node.childNodes && node.type === "section") for (let child of node.childNodes)visit(child);
54
+ };
55
+ for (let node of nodes)visit(node);
56
+ let last;
57
+ let index = 0;
58
+ for (let [key, node] of this.keyMap){
59
+ if (last) {
60
+ last.nextKey = key;
61
+ node.prevKey = last.key;
62
+ } else {
63
+ this.firstKey = key;
64
+ node.prevKey = undefined;
65
+ }
66
+ if (node.type === "item") node.index = index++;
67
+ last = node;
68
+ // Set nextKey as undefined since this might be the last node
69
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
70
+ last.nextKey = undefined;
71
+ }
72
+ this.lastKey = last === null || last === void 0 ? void 0 : last.key;
73
+ }
74
+ }
75
+
76
+
77
+ export {$a02d57049d202695$export$d085fb9e920b5ca7 as ListCollection};
78
+ //# sourceMappingURL=ListCollection.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAgDX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAAG;QACnB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC3B,OAAO,OAAO,KAAK,OAAO,GAAG;IAC/B;IAEA,YAAY,GAAQ,EAAE;QACpB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC3B,OAAO,OAAO,KAAK,OAAO,GAAG;IAC/B;IAEA,cAAc;QACZ,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,aAAa;QACX,OAAO,IAAI,CAAC,OAAO;IACrB;IAEA,QAAQ,GAAQ,EAAE;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;IACzB;IAEA,GAAG,GAAW,EAAE;QACd,MAAM,OAAO;eAAI,IAAI,CAAC,OAAO;SAAG;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;IAC/B;IAEA,YAAY,GAAQ,EAAqB;QACvC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC3B,OAAO,CAAA,iBAAA,2BAAA,KAAM,UAAU,KAAI,EAAE;IAC/B;IApFA,YAAY,KAAwB,CAAE;aAL9B,SAA4B,IAAI;QAMtC,IAAI,CAAC,QAAQ,GAAG;QAEhB,IAAI,QAAQ,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE;YAE1B,IAAI,KAAK,UAAU,IAAI,KAAK,IAAI,KAAK,WACnC,KAAK,IAAI,SAAS,KAAK,UAAU,CAC/B,MAAM;QAGZ;QAEA,KAAK,IAAI,QAAQ,MACf,MAAM;QAGR,IAAI;QACJ,IAAI,QAAQ;QACZ,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAE;YACnC,IAAI,MAAM;gBACR,KAAK,OAAO,GAAG;gBACf,KAAK,OAAO,GAAG,KAAK,GAAG;YACzB,OAAO;gBACL,IAAI,CAAC,QAAQ,GAAG;gBAChB,KAAK,OAAO,GAAG;YACjB;YAEA,IAAI,KAAK,IAAI,KAAK,QAChB,KAAK,KAAK,GAAG;YAGf,OAAO;YAEP,6DAA6D;YAC7D,iFAAiF;YACjF,KAAK,OAAO,GAAG;QACjB;QAEA,IAAI,CAAC,OAAO,GAAG,iBAAA,2BAAA,KAAM,GAAG;IAC1B;AA6CF","sources":["packages/@react-stately/list/src/ListCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, Node} from '@react-types/shared';\n\nexport class ListCollection<T> implements Collection<Node<T>> {\n private keyMap: Map<Key, Node<T>> = new Map();\n private iterable: Iterable<Node<T>>;\n private firstKey: Key;\n private lastKey: Key;\n\n constructor(nodes: Iterable<Node<T>>) {\n this.iterable = nodes;\n\n let visit = (node: Node<T>) => {\n this.keyMap.set(node.key, node);\n\n if (node.childNodes && node.type === 'section') {\n for (let child of node.childNodes) {\n visit(child);\n }\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let last: Node<T>;\n let index = 0;\n for (let [key, node] of this.keyMap) {\n if (last) {\n last.nextKey = key;\n node.prevKey = last.key;\n } else {\n this.firstKey = key;\n node.prevKey = undefined;\n }\n\n if (node.type === 'item') {\n node.index = index++;\n }\n\n last = node;\n\n // Set nextKey as undefined since this might be the last node\n // If it isn't the last node, last.nextKey will properly set at start of new loop\n last.nextKey = undefined;\n }\n\n this.lastKey = last?.key;\n }\n\n *[Symbol.iterator]() {\n yield* this.iterable;\n }\n\n get size() {\n return this.keyMap.size;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return this.firstKey;\n }\n\n getLastKey() {\n return this.lastKey;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n\n at(idx: number) {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getChildren(key: Key): Iterable<Node<T>> {\n let node = this.keyMap.get(key);\n return node?.childNodes || [];\n }\n}\n"],"names":[],"version":3,"file":"ListCollection.module.js.map"}
package/dist/import.mjs CHANGED
@@ -1,174 +1,6 @@
1
- import {useMultipleSelectionState as $58Phs$useMultipleSelectionState, SelectionManager as $58Phs$SelectionManager} from "@react-stately/selection";
2
- import {useMemo as $58Phs$useMemo, useCallback as $58Phs$useCallback, useRef as $58Phs$useRef, useEffect as $58Phs$useEffect} from "react";
3
- import {useCollection as $58Phs$useCollection} from "@react-stately/collections";
4
- import {useControlledState as $58Phs$useControlledState} from "@react-stately/utils";
5
-
6
- /*
7
- * Copyright 2020 Adobe. All rights reserved.
8
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License. You may obtain a copy
10
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software distributed under
13
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
- * OF ANY KIND, either express or implied. See the License for the specific language
15
- * governing permissions and limitations under the License.
16
- */ /*
17
- * Copyright 2020 Adobe. All rights reserved.
18
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
- * you may not use this file except in compliance with the License. You may obtain a copy
20
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software distributed under
23
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
- * OF ANY KIND, either express or implied. See the License for the specific language
25
- * governing permissions and limitations under the License.
26
- */ /*
27
- * Copyright 2020 Adobe. All rights reserved.
28
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
29
- * you may not use this file except in compliance with the License. You may obtain a copy
30
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
31
- *
32
- * Unless required by applicable law or agreed to in writing, software distributed under
33
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
34
- * OF ANY KIND, either express or implied. See the License for the specific language
35
- * governing permissions and limitations under the License.
36
- */ class $a02d57049d202695$export$d085fb9e920b5ca7 {
37
- *[Symbol.iterator]() {
38
- yield* this.iterable;
39
- }
40
- get size() {
41
- return this.keyMap.size;
42
- }
43
- getKeys() {
44
- return this.keyMap.keys();
45
- }
46
- getKeyBefore(key) {
47
- let node = this.keyMap.get(key);
48
- return node ? node.prevKey : null;
49
- }
50
- getKeyAfter(key) {
51
- let node = this.keyMap.get(key);
52
- return node ? node.nextKey : null;
53
- }
54
- getFirstKey() {
55
- return this.firstKey;
56
- }
57
- getLastKey() {
58
- return this.lastKey;
59
- }
60
- getItem(key) {
61
- return this.keyMap.get(key);
62
- }
63
- at(idx) {
64
- const keys = [
65
- ...this.getKeys()
66
- ];
67
- return this.getItem(keys[idx]);
68
- }
69
- getChildren(key) {
70
- let node = this.keyMap.get(key);
71
- return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
72
- }
73
- constructor(nodes){
74
- this.keyMap = new Map();
75
- this.iterable = nodes;
76
- let visit = (node)=>{
77
- this.keyMap.set(node.key, node);
78
- if (node.childNodes && node.type === "section") for (let child of node.childNodes)visit(child);
79
- };
80
- for (let node of nodes)visit(node);
81
- let last;
82
- let index = 0;
83
- for (let [key, node] of this.keyMap){
84
- if (last) {
85
- last.nextKey = key;
86
- node.prevKey = last.key;
87
- } else {
88
- this.firstKey = key;
89
- node.prevKey = undefined;
90
- }
91
- if (node.type === "item") node.index = index++;
92
- last = node;
93
- // Set nextKey as undefined since this might be the last node
94
- // If it isn't the last node, last.nextKey will properly set at start of new loop
95
- last.nextKey = undefined;
96
- }
97
- this.lastKey = last === null || last === void 0 ? void 0 : last.key;
98
- }
99
- }
100
-
101
-
102
-
103
-
104
-
105
- function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
106
- let { filter: filter } = props;
107
- let selectionState = (0, $58Phs$useMultipleSelectionState)(props);
108
- let disabledKeys = (0, $58Phs$useMemo)(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [
109
- props.disabledKeys
110
- ]);
111
- let factory = (0, $58Phs$useCallback)((nodes)=>filter ? new (0, $a02d57049d202695$export$d085fb9e920b5ca7)(filter(nodes)) : new (0, $a02d57049d202695$export$d085fb9e920b5ca7)(nodes), [
112
- filter
113
- ]);
114
- let context = (0, $58Phs$useMemo)(()=>({
115
- suppressTextValueWarning: props.suppressTextValueWarning
116
- }), [
117
- props.suppressTextValueWarning
118
- ]);
119
- let collection = (0, $58Phs$useCollection)(props, factory, context);
120
- let selectionManager = (0, $58Phs$useMemo)(()=>new (0, $58Phs$SelectionManager)(collection, selectionState), [
121
- collection,
122
- selectionState
123
- ]);
124
- // Reset focused key if that item is deleted from the collection.
125
- const cachedCollection = (0, $58Phs$useRef)(null);
126
- (0, $58Phs$useEffect)(()=>{
127
- if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
128
- const startItem = cachedCollection.current.getItem(selectionState.focusedKey);
129
- const cachedItemNodes = [
130
- ...cachedCollection.current.getKeys()
131
- ].map((key)=>{
132
- const itemNode = cachedCollection.current.getItem(key);
133
- return itemNode.type === "item" ? itemNode : null;
134
- }).filter((node)=>node !== null);
135
- const itemNodes = [
136
- ...collection.getKeys()
137
- ].map((key)=>{
138
- const itemNode = collection.getItem(key);
139
- return itemNode.type === "item" ? itemNode : null;
140
- }).filter((node)=>node !== null);
141
- const diff = cachedItemNodes.length - itemNodes.length;
142
- let index = Math.min(diff > 1 ? Math.max(startItem.index - diff + 1, 0) : startItem.index, itemNodes.length - 1);
143
- let newNode;
144
- while(index >= 0){
145
- if (!selectionManager.isDisabled(itemNodes[index].key)) {
146
- newNode = itemNodes[index];
147
- break;
148
- }
149
- // Find next, not disabled item.
150
- if (index < itemNodes.length - 1) index++;
151
- else {
152
- if (index > startItem.index) index = startItem.index;
153
- index--;
154
- }
155
- }
156
- selectionState.setFocusedKey(newNode ? newNode.key : null);
157
- }
158
- cachedCollection.current = collection;
159
- }, [
160
- collection,
161
- selectionManager,
162
- selectionState,
163
- selectionState.focusedKey
164
- ]);
165
- return {
166
- collection: collection,
167
- disabledKeys: disabledKeys,
168
- selectionManager: selectionManager
169
- };
170
- }
171
-
1
+ import {useListState as $e72dd72e1c76a225$export$2f645645f7bca764} from "./useListState.mjs";
2
+ import {useSingleSelectListState as $a0d645289fe9b86b$export$e7f05e985daf4b5f} from "./useSingleSelectListState.mjs";
3
+ import {ListCollection as $a02d57049d202695$export$d085fb9e920b5ca7} from "./ListCollection.mjs";
172
4
 
173
5
  /*
174
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -183,42 +15,6 @@ function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
183
15
  */
184
16
 
185
17
 
186
- function $a0d645289fe9b86b$export$e7f05e985daf4b5f(props) {
187
- var _props_defaultSelectedKey;
188
- let [selectedKey, setSelectedKey] = (0, $58Phs$useControlledState)(props.selectedKey, (_props_defaultSelectedKey = props.defaultSelectedKey) !== null && _props_defaultSelectedKey !== void 0 ? _props_defaultSelectedKey : null, props.onSelectionChange);
189
- let selectedKeys = (0, $58Phs$useMemo)(()=>selectedKey != null ? [
190
- selectedKey
191
- ] : [], [
192
- selectedKey
193
- ]);
194
- let { collection: collection, disabledKeys: disabledKeys, selectionManager: selectionManager } = (0, $e72dd72e1c76a225$export$2f645645f7bca764)({
195
- ...props,
196
- selectionMode: "single",
197
- disallowEmptySelection: true,
198
- allowDuplicateSelectionEvents: true,
199
- selectedKeys: selectedKeys,
200
- onSelectionChange: (keys)=>{
201
- var _keys_values_next_value;
202
- let key = (_keys_values_next_value = keys.values().next().value) !== null && _keys_values_next_value !== void 0 ? _keys_values_next_value : null;
203
- // Always fire onSelectionChange, even if the key is the same
204
- // as the current key (useControlledState does not).
205
- if (key === selectedKey && props.onSelectionChange) props.onSelectionChange(key);
206
- setSelectedKey(key);
207
- }
208
- });
209
- let selectedItem = selectedKey != null ? collection.getItem(selectedKey) : null;
210
- return {
211
- collection: collection,
212
- disabledKeys: disabledKeys,
213
- selectionManager: selectionManager,
214
- selectedKey: selectedKey,
215
- setSelectedKey: setSelectedKey,
216
- selectedItem: selectedItem
217
- };
218
- }
219
-
220
-
221
-
222
18
 
223
19
 
224
20
  export {$e72dd72e1c76a225$export$2f645645f7bca764 as useListState, $a0d645289fe9b86b$export$e7f05e985daf4b5f as useSingleSelectListState, $a02d57049d202695$export$d085fb9e920b5ca7 as ListCollection};