@react-stately/list 3.10.8 → 3.10.9-nightly.5014

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.
@@ -26,11 +26,13 @@ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$
26
26
  }
27
27
  getKeyBefore(key) {
28
28
  let node = this.keyMap.get(key);
29
- return node ? node.prevKey : null;
29
+ var _node_prevKey;
30
+ return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
30
31
  }
31
32
  getKeyAfter(key) {
32
33
  let node = this.keyMap.get(key);
33
- return node ? node.nextKey : null;
34
+ var _node_nextKey;
35
+ return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
34
36
  }
35
37
  getFirstKey() {
36
38
  return this.firstKey;
@@ -39,7 +41,8 @@ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$
39
41
  return this.lastKey;
40
42
  }
41
43
  getItem(key) {
42
- return this.keyMap.get(key);
44
+ var _this_keyMap_get;
45
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
43
46
  }
44
47
  at(idx) {
45
48
  const keys = [
@@ -53,13 +56,15 @@ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$
53
56
  }
54
57
  constructor(nodes){
55
58
  this.keyMap = new Map();
59
+ this.firstKey = null;
60
+ this.lastKey = null;
56
61
  this.iterable = nodes;
57
62
  let visit = (node)=>{
58
63
  this.keyMap.set(node.key, node);
59
64
  if (node.childNodes && node.type === 'section') for (let child of node.childNodes)visit(child);
60
65
  };
61
66
  for (let node of nodes)visit(node);
62
- let last;
67
+ let last = null;
63
68
  let index = 0;
64
69
  for (let [key, node] of this.keyMap){
65
70
  if (last) {
@@ -75,7 +80,8 @@ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$
75
80
  // If it isn't the last node, last.nextKey will properly set at start of new loop
76
81
  last.nextKey = undefined;
77
82
  }
78
- this.lastKey = last === null || last === void 0 ? void 0 : last.key;
83
+ var _last_key;
84
+ this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
79
85
  }
80
86
  }
81
87
 
@@ -1 +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"}
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;YACb;QAAd,OAAO,OAAO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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;YAEe;QAAf,IAAI,CAAC,OAAO,GAAG,CAAA,YAAA,iBAAA,2BAAA,KAAM,GAAG,cAAT,uBAAA,YAAa;IAC9B;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 | null = null;\n private lastKey: Key | null = null;\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> | null = null;\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 ?? null;\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 : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : 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) ?? null;\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"}
@@ -20,11 +20,13 @@
20
20
  }
21
21
  getKeyBefore(key) {
22
22
  let node = this.keyMap.get(key);
23
- return node ? node.prevKey : null;
23
+ var _node_prevKey;
24
+ return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
24
25
  }
25
26
  getKeyAfter(key) {
26
27
  let node = this.keyMap.get(key);
27
- return node ? node.nextKey : null;
28
+ var _node_nextKey;
29
+ return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
28
30
  }
29
31
  getFirstKey() {
30
32
  return this.firstKey;
@@ -33,7 +35,8 @@
33
35
  return this.lastKey;
34
36
  }
35
37
  getItem(key) {
36
- return this.keyMap.get(key);
38
+ var _this_keyMap_get;
39
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
37
40
  }
38
41
  at(idx) {
39
42
  const keys = [
@@ -47,13 +50,15 @@
47
50
  }
48
51
  constructor(nodes){
49
52
  this.keyMap = new Map();
53
+ this.firstKey = null;
54
+ this.lastKey = null;
50
55
  this.iterable = nodes;
51
56
  let visit = (node)=>{
52
57
  this.keyMap.set(node.key, node);
53
58
  if (node.childNodes && node.type === 'section') for (let child of node.childNodes)visit(child);
54
59
  };
55
60
  for (let node of nodes)visit(node);
56
- let last;
61
+ let last = null;
57
62
  let index = 0;
58
63
  for (let [key, node] of this.keyMap){
59
64
  if (last) {
@@ -69,7 +74,8 @@
69
74
  // If it isn't the last node, last.nextKey will properly set at start of new loop
70
75
  last.nextKey = undefined;
71
76
  }
72
- this.lastKey = last === null || last === void 0 ? void 0 : last.key;
77
+ var _last_key;
78
+ this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
73
79
  }
74
80
  }
75
81
 
@@ -20,11 +20,13 @@
20
20
  }
21
21
  getKeyBefore(key) {
22
22
  let node = this.keyMap.get(key);
23
- return node ? node.prevKey : null;
23
+ var _node_prevKey;
24
+ return node ? (_node_prevKey = node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null : null;
24
25
  }
25
26
  getKeyAfter(key) {
26
27
  let node = this.keyMap.get(key);
27
- return node ? node.nextKey : null;
28
+ var _node_nextKey;
29
+ return node ? (_node_nextKey = node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null : null;
28
30
  }
29
31
  getFirstKey() {
30
32
  return this.firstKey;
@@ -33,7 +35,8 @@
33
35
  return this.lastKey;
34
36
  }
35
37
  getItem(key) {
36
- return this.keyMap.get(key);
38
+ var _this_keyMap_get;
39
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
37
40
  }
38
41
  at(idx) {
39
42
  const keys = [
@@ -47,13 +50,15 @@
47
50
  }
48
51
  constructor(nodes){
49
52
  this.keyMap = new Map();
53
+ this.firstKey = null;
54
+ this.lastKey = null;
50
55
  this.iterable = nodes;
51
56
  let visit = (node)=>{
52
57
  this.keyMap.set(node.key, node);
53
58
  if (node.childNodes && node.type === 'section') for (let child of node.childNodes)visit(child);
54
59
  };
55
60
  for (let node of nodes)visit(node);
56
- let last;
61
+ let last = null;
57
62
  let index = 0;
58
63
  for (let [key, node] of this.keyMap){
59
64
  if (last) {
@@ -69,7 +74,8 @@
69
74
  // If it isn't the last node, last.nextKey will properly set at start of new loop
70
75
  last.nextKey = undefined;
71
76
  }
72
- this.lastKey = last === null || last === void 0 ? void 0 : last.key;
77
+ var _last_key;
78
+ this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
73
79
  }
74
80
  }
75
81
 
@@ -1 +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"}
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,C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AK,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;YAEe;QAAf,IAAI,CAAC,OAAO,GAAG,CAAA,YAAA,iBAAA,2BAAA,KAAM,GAAG,cAAT,uBAAA,YAAa;IAC9B;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 | null = null;\n private lastKey: Key | null = null;\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> | null = null;\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 ?? null;\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 : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : 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) ?? null;\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/types.d.ts CHANGED
@@ -40,7 +40,7 @@ export interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<S
40
40
  }
41
41
  export interface SingleSelectListState<T> extends ListState<T> {
42
42
  /** The key for the currently selected item. */
43
- readonly selectedKey: Key;
43
+ readonly selectedKey: Key | null;
44
44
  /** Sets the selected key. */
45
45
  setSelectedKey(key: Key | null): void;
46
46
  /** The value of the currently selected item. */
@@ -1 +1 @@
1
- {"mappings":";;AAcA,4BAA4B,CAAC,CAAE,YAAW,WAAW,KAAK,CAAC,CAAC,CAAC;gBAM/C,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IA0CnC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIlB,IAAI,IAAI,WAEP;IAED,OAAO;IAIP,YAAY,CAAC,GAAG,EAAE,GAAG;IAKrB,WAAW,CAAC,GAAG,EAAE,GAAG;IAKpB,WAAW;IAIX,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,GAAG,IAAI,CAAC;IAEtC,gDAAgD;IAChD,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAA;CACtC;AAED;;;GAGG;AACH,yCAAyC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAkCpH","sources":["packages/@react-stately/list/src/packages/@react-stately/list/src/ListCollection.ts","packages/@react-stately/list/src/packages/@react-stately/list/src/useListState.ts","packages/@react-stately/list/src/packages/@react-stately/list/src/useSingleSelectListState.ts","packages/@react-stately/list/src/packages/@react-stately/list/src/index.ts","packages/@react-stately/list/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {ListProps, ListState} from './useListState';\nexport type {SingleSelectListProps, SingleSelectListState} from './useSingleSelectListState';\nexport {useListState} from './useListState';\nexport {useSingleSelectListState} from './useSingleSelectListState';\nexport {ListCollection} from './ListCollection';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAcA,4BAA4B,CAAC,CAAE,YAAW,WAAW,KAAK,CAAC,CAAC,CAAC;gBAM/C,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IA0CnC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIlB,IAAI,IAAI,WAEP;IAED,OAAO;IAIP,YAAY,CAAC,GAAG,EAAE,GAAG;IAKrB,WAAW,CAAC,GAAG,EAAE,GAAG;IAKpB,WAAW;IAIX,UAAU;IAIV,OAAO,CAAC,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,CAAC;IAEtC,gDAAgD;IAChD,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAA;CACtC;AAED;;;GAGG;AACH,yCAAyC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAsCpH","sources":["packages/@react-stately/list/src/packages/@react-stately/list/src/ListCollection.ts","packages/@react-stately/list/src/packages/@react-stately/list/src/useListState.ts","packages/@react-stately/list/src/packages/@react-stately/list/src/useSingleSelectListState.ts","packages/@react-stately/list/src/packages/@react-stately/list/src/index.ts","packages/@react-stately/list/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {ListProps, ListState} from './useListState';\nexport type {SingleSelectListProps, SingleSelectListState} from './useSingleSelectListState';\nexport {useListState} from './useListState';\nexport {useSingleSelectListState} from './useSingleSelectListState';\nexport {ListCollection} from './ListCollection';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -45,23 +45,25 @@ function $5450691d3629f6ea$export$2f645645f7bca764(props) {
45
45
  // Reset focused key if that item is deleted from the collection.
46
46
  const cachedCollection = (0, $5RsKl$react.useRef)(null);
47
47
  (0, $5RsKl$react.useEffect)(()=>{
48
- if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
48
+ if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey) && cachedCollection.current) {
49
49
  const startItem = cachedCollection.current.getItem(selectionState.focusedKey);
50
50
  const cachedItemNodes = [
51
51
  ...cachedCollection.current.getKeys()
52
52
  ].map((key)=>{
53
53
  const itemNode = cachedCollection.current.getItem(key);
54
- return itemNode.type === 'item' ? itemNode : null;
54
+ return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
55
55
  }).filter((node)=>node !== null);
56
56
  const itemNodes = [
57
57
  ...collection.getKeys()
58
58
  ].map((key)=>{
59
59
  const itemNode = collection.getItem(key);
60
- return itemNode.type === 'item' ? itemNode : null;
60
+ return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
61
61
  }).filter((node)=>node !== null);
62
- const diff = cachedItemNodes.length - itemNodes.length;
63
- let index = Math.min(diff > 1 ? Math.max(startItem.index - diff + 1, 0) : startItem.index, itemNodes.length - 1);
64
- let newNode;
62
+ var _cachedItemNodes_length, _itemNodes_length;
63
+ const diff = ((_cachedItemNodes_length = cachedItemNodes === null || cachedItemNodes === void 0 ? void 0 : cachedItemNodes.length) !== null && _cachedItemNodes_length !== void 0 ? _cachedItemNodes_length : 0) - ((_itemNodes_length = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length !== void 0 ? _itemNodes_length : 0);
64
+ var _startItem_index, _startItem_index1, _itemNodes_length1;
65
+ let index = Math.min(diff > 1 ? Math.max(((_startItem_index = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0) - diff + 1, 0) : (_startItem_index1 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index1 !== void 0 ? _startItem_index1 : 0, ((_itemNodes_length1 = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length1 !== void 0 ? _itemNodes_length1 : 0) - 1);
66
+ let newNode = null;
65
67
  let isReverseSearching = false;
66
68
  while(index >= 0){
67
69
  if (!selectionManager.isDisabled(itemNodes[index].key)) {
@@ -72,7 +74,8 @@ function $5450691d3629f6ea$export$2f645645f7bca764(props) {
72
74
  if (index < itemNodes.length - 1 && !isReverseSearching) index++;
73
75
  else {
74
76
  isReverseSearching = true;
75
- if (index > startItem.index) index = startItem.index;
77
+ var _startItem_index2, _startItem_index3;
78
+ if (index > ((_startItem_index2 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index2 !== void 0 ? _startItem_index2 : 0)) index = (_startItem_index3 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index3 !== void 0 ? _startItem_index3 : 0;
76
79
  index--;
77
80
  }
78
81
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA8BM,SAAS,0CAA+B,KAAmB;IAChE,IAAI,UAAC,MAAM,EAAC,GAAG;IAEf,IAAI,iBAAiB,CAAA,GAAA,sDAAwB,EAAE;IAC/C,IAAI,eAAe,CAAA,GAAA,oBAAM,EAAE,IACzB,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,YAAY,IAAI,IAAI,OACvD;QAAC,MAAM,YAAY;KAAC;IAEtB,IAAI,UAAU,CAAA,GAAA,wBAAU,EAAE,CAAA,QAAS,SAAS,IAAI,CAAA,GAAA,wCAAa,EAAE,OAAO,UAAU,IAAI,CAAA,GAAA,wCAAa,EAAE,QAA6B;QAAC;KAAO;IACxI,IAAI,UAAU,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;YAAC,0BAA0B,MAAM,wBAAwB;QAAA,CAAA,GAAI;QAAC,MAAM,wBAAwB;KAAC;IAE1H,IAAI,aAAa,CAAA,GAAA,4CAAY,EAAE,OAAO,SAAS;IAE/C,IAAI,mBAAmB,CAAA,GAAA,oBAAM,EAAE,IAC7B,IAAI,CAAA,GAAA,6CAAe,EAAE,YAAY,iBAC/B;QAAC;QAAY;KAAe;IAGhC,iEAAiE;IACjE,MAAM,mBAAmB,CAAA,GAAA,mBAAK,EAAE;IAChC,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,eAAe,UAAU,IAAI,QAAQ,CA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AACF","sources":["packages/@react-stately/list/src/useListState.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, CollectionStateBase, Key, Node} from '@react-types/shared';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCallback, useEffect, useMemo, useRef} from 'react';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionStateBase<T>, MultipleSelectionStateProps {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface ListState<T> {\n /** A collection of items in the list. */\n collection: Collection<Node<T>>,\n\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>,\n\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for list-like components. Handles building a collection\n * of items from props, and manages multiple selection state.\n */\nexport function useListState<T extends object>(props: ListProps<T>): ListState<T> {\n let {filter} = props;\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let factory = useCallback(nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>), [filter]);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context);\n\n let selectionManager = useMemo(() =>\n new SelectionManager(collection, selectionState)\n , [collection, selectionState]\n );\n\n // Reset focused key if that item is deleted from the collection.\n const cachedCollection = useRef(null);\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {\n const startItem = cachedCollection.current.getItem(selectionState.focusedKey);\n const cachedItemNodes = [...cachedCollection.current.getKeys()].map(\n key => {\n const itemNode = cachedCollection.current.getItem(key);\n return itemNode.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const itemNodes = [...collection.getKeys()].map(\n key => {\n const itemNode = collection.getItem(key);\n return itemNode.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const diff = cachedItemNodes.length - itemNodes.length;\n let index = Math.min(\n (\n diff > 1 ?\n Math.max(startItem.index - diff + 1, 0) :\n startItem.index\n ),\n itemNodes.length - 1);\n let newNode:Node<T>;\n let isReverseSearching = false;\n while (index >= 0) {\n if (!selectionManager.isDisabled(itemNodes[index].key)) {\n newNode = itemNodes[index];\n break;\n }\n // Find next, not disabled item.\n if (index < itemNodes.length - 1 && !isReverseSearching) {\n index++;\n // Otherwise, find previous, not disabled item.\n } else {\n isReverseSearching = true;\n if (index > startItem.index) {\n index = startItem.index;\n }\n index--;\n }\n }\n selectionState.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager, selectionState, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n"],"names":[],"version":3,"file":"useListState.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA8BM,SAAS,0CAA+B,KAAmB;IAChE,IAAI,UAAC,MAAM,EAAC,GAAG;IAEf,IAAI,iBAAiB,CAAA,GAAA,sDAAwB,EAAE;IAC/C,IAAI,eAAe,CAAA,GAAA,oBAAM,EAAE,IACzB,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,YAAY,IAAI,IAAI,OACvD;QAAC,MAAM,YAAY;KAAC;IAEtB,IAAI,UAAU,CAA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AAM,cAAvB,qCAAA,0BAA2B,CAAA,IAAM,CAAA,CAAA,oBAAA,sBAAA,gCAAA,UAAW,MAAM,cAAjB,+BAAA,oBAAqB,CAAA;gBAI9D,kBACV,mBAED;YANH,IAAI,QAAQ,KAAK,GAAG,CAEhB,OAAO,IACP,KAAK,GAAG,CAAC,AAAC,CAAA,CAAA,mBAAA,sBAAA,gCAAA,UAAW,KAAK,cAAhB,8BAAA,mBAAoB,CAAA,IAAK,OAAO,GAAG,KAC7C,CAAA,oBAAA,sBAAA,gCAAA,UAAW,KAAK,cAAhB,+BAAA,oBAAoB,GAEtB,AAAC,CAAA,CAAA,qBAAA,sBAAA,gCAAA,UAAW,MAAM,cAAjB,gCAAA,qBAAqB,CAAA,IAAK;YAC7B,IAAI,UAA0B;YAC9B,IAAI,qBAAqB;YACzB,MAAO,SAAS,EAAG;gBACjB,IAAI,CAAC,iBAAiB,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,GAAG;oBACtD,UAAU,SAAS,CAAC,MAAM;oBAC1B;gBACF;gBACA,gCAAgC;gBAChC,IAAI,QAAQ,UAAU,MAAM,GAAG,KAAK,CAAC,oBACnC;qBAEK;oBACL,qBAAqB;wBACR,mBACF;oBADX,IAAI,QAAS,CAAA,CAAA,oBAAA,sBAAA,gCAAA,UAAW,KAAK,cAAhB,+BAAA,oBAAoB,CAAA,GAC/B,QAAS,CAAA,oBAAA,sBAAA,gCAAA,UAAW,KAAK,cAAhB,+BAAA,oBAAoB;oBAE/B;gBACF;YACF;YACA,eAAe,aAAa,CAAC,UAAU,QAAQ,GAAG,GAAG;QACvD;QACA,iBAAiB,OAAO,GAAG;IAC7B,GAAG;QAAC;QAAY;QAAkB;QAAgB,eAAe,UAAU;KAAC;IAE5E,OAAO;oBACL;sBACA;0BACA;IACF;AACF","sources":["packages/@react-stately/list/src/useListState.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, CollectionStateBase, Key, Node} from '@react-types/shared';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCallback, useEffect, useMemo, useRef} from 'react';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionStateBase<T>, MultipleSelectionStateProps {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface ListState<T> {\n /** A collection of items in the list. */\n collection: Collection<Node<T>>,\n\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>,\n\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for list-like components. Handles building a collection\n * of items from props, and manages multiple selection state.\n */\nexport function useListState<T extends object>(props: ListProps<T>): ListState<T> {\n let {filter} = props;\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let factory = useCallback(nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>), [filter]);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context);\n\n let selectionManager = useMemo(() =>\n new SelectionManager(collection, selectionState)\n , [collection, selectionState]\n );\n\n // Reset focused key if that item is deleted from the collection.\n const cachedCollection = useRef<Collection<Node<T>> | null>(null);\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey) && cachedCollection.current) {\n const startItem = cachedCollection.current.getItem(selectionState.focusedKey);\n const cachedItemNodes = [...cachedCollection.current.getKeys()].map(\n key => {\n const itemNode = cachedCollection.current!.getItem(key);\n return itemNode?.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const itemNodes = [...collection.getKeys()].map(\n key => {\n const itemNode = collection.getItem(key);\n return itemNode?.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const diff: number = (cachedItemNodes?.length ?? 0) - (itemNodes?.length ?? 0);\n let index = Math.min(\n (\n diff > 1 ?\n Math.max((startItem?.index ?? 0) - diff + 1, 0) :\n startItem?.index ?? 0\n ),\n (itemNodes?.length ?? 0) - 1);\n let newNode: Node<T> | null = null;\n let isReverseSearching = false;\n while (index >= 0) {\n if (!selectionManager.isDisabled(itemNodes[index].key)) {\n newNode = itemNodes[index];\n break;\n }\n // Find next, not disabled item.\n if (index < itemNodes.length - 1 && !isReverseSearching) {\n index++;\n // Otherwise, find previous, not disabled item.\n } else {\n isReverseSearching = true;\n if (index > (startItem?.index ?? 0)) {\n index = (startItem?.index ?? 0);\n }\n index--;\n }\n }\n selectionState.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager, selectionState, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n"],"names":[],"version":3,"file":"useListState.main.js.map"}
@@ -39,23 +39,25 @@ function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
39
39
  // Reset focused key if that item is deleted from the collection.
40
40
  const cachedCollection = (0, $d5vlZ$useRef)(null);
41
41
  (0, $d5vlZ$useEffect)(()=>{
42
- if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
42
+ if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey) && cachedCollection.current) {
43
43
  const startItem = cachedCollection.current.getItem(selectionState.focusedKey);
44
44
  const cachedItemNodes = [
45
45
  ...cachedCollection.current.getKeys()
46
46
  ].map((key)=>{
47
47
  const itemNode = cachedCollection.current.getItem(key);
48
- return itemNode.type === 'item' ? itemNode : null;
48
+ return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
49
49
  }).filter((node)=>node !== null);
50
50
  const itemNodes = [
51
51
  ...collection.getKeys()
52
52
  ].map((key)=>{
53
53
  const itemNode = collection.getItem(key);
54
- return itemNode.type === 'item' ? itemNode : null;
54
+ return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
55
55
  }).filter((node)=>node !== null);
56
- const diff = cachedItemNodes.length - itemNodes.length;
57
- let index = Math.min(diff > 1 ? Math.max(startItem.index - diff + 1, 0) : startItem.index, itemNodes.length - 1);
58
- let newNode;
56
+ var _cachedItemNodes_length, _itemNodes_length;
57
+ const diff = ((_cachedItemNodes_length = cachedItemNodes === null || cachedItemNodes === void 0 ? void 0 : cachedItemNodes.length) !== null && _cachedItemNodes_length !== void 0 ? _cachedItemNodes_length : 0) - ((_itemNodes_length = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length !== void 0 ? _itemNodes_length : 0);
58
+ var _startItem_index, _startItem_index1, _itemNodes_length1;
59
+ let index = Math.min(diff > 1 ? Math.max(((_startItem_index = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0) - diff + 1, 0) : (_startItem_index1 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index1 !== void 0 ? _startItem_index1 : 0, ((_itemNodes_length1 = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length1 !== void 0 ? _itemNodes_length1 : 0) - 1);
60
+ let newNode = null;
59
61
  let isReverseSearching = false;
60
62
  while(index >= 0){
61
63
  if (!selectionManager.isDisabled(itemNodes[index].key)) {
@@ -66,7 +68,8 @@ function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
66
68
  if (index < itemNodes.length - 1 && !isReverseSearching) index++;
67
69
  else {
68
70
  isReverseSearching = true;
69
- if (index > startItem.index) index = startItem.index;
71
+ var _startItem_index2, _startItem_index3;
72
+ if (index > ((_startItem_index2 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index2 !== void 0 ? _startItem_index2 : 0)) index = (_startItem_index3 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index3 !== void 0 ? _startItem_index3 : 0;
70
73
  index--;
71
74
  }
72
75
  }
@@ -39,23 +39,25 @@ function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
39
39
  // Reset focused key if that item is deleted from the collection.
40
40
  const cachedCollection = (0, $d5vlZ$useRef)(null);
41
41
  (0, $d5vlZ$useEffect)(()=>{
42
- if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
42
+ if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey) && cachedCollection.current) {
43
43
  const startItem = cachedCollection.current.getItem(selectionState.focusedKey);
44
44
  const cachedItemNodes = [
45
45
  ...cachedCollection.current.getKeys()
46
46
  ].map((key)=>{
47
47
  const itemNode = cachedCollection.current.getItem(key);
48
- return itemNode.type === 'item' ? itemNode : null;
48
+ return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
49
49
  }).filter((node)=>node !== null);
50
50
  const itemNodes = [
51
51
  ...collection.getKeys()
52
52
  ].map((key)=>{
53
53
  const itemNode = collection.getItem(key);
54
- return itemNode.type === 'item' ? itemNode : null;
54
+ return (itemNode === null || itemNode === void 0 ? void 0 : itemNode.type) === 'item' ? itemNode : null;
55
55
  }).filter((node)=>node !== null);
56
- const diff = cachedItemNodes.length - itemNodes.length;
57
- let index = Math.min(diff > 1 ? Math.max(startItem.index - diff + 1, 0) : startItem.index, itemNodes.length - 1);
58
- let newNode;
56
+ var _cachedItemNodes_length, _itemNodes_length;
57
+ const diff = ((_cachedItemNodes_length = cachedItemNodes === null || cachedItemNodes === void 0 ? void 0 : cachedItemNodes.length) !== null && _cachedItemNodes_length !== void 0 ? _cachedItemNodes_length : 0) - ((_itemNodes_length = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length !== void 0 ? _itemNodes_length : 0);
58
+ var _startItem_index, _startItem_index1, _itemNodes_length1;
59
+ let index = Math.min(diff > 1 ? Math.max(((_startItem_index = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index !== void 0 ? _startItem_index : 0) - diff + 1, 0) : (_startItem_index1 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index1 !== void 0 ? _startItem_index1 : 0, ((_itemNodes_length1 = itemNodes === null || itemNodes === void 0 ? void 0 : itemNodes.length) !== null && _itemNodes_length1 !== void 0 ? _itemNodes_length1 : 0) - 1);
60
+ let newNode = null;
59
61
  let isReverseSearching = false;
60
62
  while(index >= 0){
61
63
  if (!selectionManager.isDisabled(itemNodes[index].key)) {
@@ -66,7 +68,8 @@ function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
66
68
  if (index < itemNodes.length - 1 && !isReverseSearching) index++;
67
69
  else {
68
70
  isReverseSearching = true;
69
- if (index > startItem.index) index = startItem.index;
71
+ var _startItem_index2, _startItem_index3;
72
+ if (index > ((_startItem_index2 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index2 !== void 0 ? _startItem_index2 : 0)) index = (_startItem_index3 = startItem === null || startItem === void 0 ? void 0 : startItem.index) !== null && _startItem_index3 !== void 0 ? _startItem_index3 : 0;
70
73
  index--;
71
74
  }
72
75
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA8BM,SAAS,0CAA+B,KAAmB;IAChE,IAAI,UAAC,MAAM,EAAC,GAAG;IAEf,IAAI,iBAAiB,CAAA,GAAA,gCAAwB,EAAE;IAC/C,IAAI,eAAe,CAAA,GAAA,cAAM,EAAE,IACzB,MAAM,YAAY,G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D,IAAI,QAAQ,KAAK,GAAG,CAEhB,OAAO,IACP,KAAK,GAAG,CAAC,UAAU,KAAK,GAAG,OAAO,GAAG,KACrC,UAAU,KAAK,EAEjB,UAAU,MAAM,GAAG;YACrB,IAAI;YACJ,IAAI,qBAAqB;YACzB,MAAO,SAAS,EAAG;gBACjB,IAAI,CAAC,iBAAiB,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,GAAG;oBACtD,UAAU,SAAS,CAAC,MAAM;oBAC1B;gBACF;gBACA,gCAAgC;gBAChC,IAAI,QAAQ,UAAU,MAAM,GAAG,KAAK,CAAC,oBACnC;qBAEK;oBACL,qBAAqB;oBACrB,IAAI,QAAQ,UAAU,KAAK,EACzB,QAAQ,UAAU,KAAK;oBAEzB;gBACF;YACF;YACA,eAAe,aAAa,CAAC,UAAU,QAAQ,GAAG,GAAG;QACvD;QACA,iBAAiB,OAAO,GAAG;IAC7B,GAAG;QAAC;QAAY;QAAkB;QAAgB,eAAe,UAAU;KAAC;IAE5E,OAAO;oBACL;sBACA;0BACA;IACF;AACF","sources":["packages/@react-stately/list/src/useListState.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, CollectionStateBase, Key, Node} from '@react-types/shared';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCallback, useEffect, useMemo, useRef} from 'react';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionStateBase<T>, MultipleSelectionStateProps {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface ListState<T> {\n /** A collection of items in the list. */\n collection: Collection<Node<T>>,\n\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>,\n\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for list-like components. Handles building a collection\n * of items from props, and manages multiple selection state.\n */\nexport function useListState<T extends object>(props: ListProps<T>): ListState<T> {\n let {filter} = props;\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let factory = useCallback(nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>), [filter]);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context);\n\n let selectionManager = useMemo(() =>\n new SelectionManager(collection, selectionState)\n , [collection, selectionState]\n );\n\n // Reset focused key if that item is deleted from the collection.\n const cachedCollection = useRef(null);\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {\n const startItem = cachedCollection.current.getItem(selectionState.focusedKey);\n const cachedItemNodes = [...cachedCollection.current.getKeys()].map(\n key => {\n const itemNode = cachedCollection.current.getItem(key);\n return itemNode.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const itemNodes = [...collection.getKeys()].map(\n key => {\n const itemNode = collection.getItem(key);\n return itemNode.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const diff = cachedItemNodes.length - itemNodes.length;\n let index = Math.min(\n (\n diff > 1 ?\n Math.max(startItem.index - diff + 1, 0) :\n startItem.index\n ),\n itemNodes.length - 1);\n let newNode:Node<T>;\n let isReverseSearching = false;\n while (index >= 0) {\n if (!selectionManager.isDisabled(itemNodes[index].key)) {\n newNode = itemNodes[index];\n break;\n }\n // Find next, not disabled item.\n if (index < itemNodes.length - 1 && !isReverseSearching) {\n index++;\n // Otherwise, find previous, not disabled item.\n } else {\n isReverseSearching = true;\n if (index > startItem.index) {\n index = startItem.index;\n }\n index--;\n }\n }\n selectionState.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager, selectionState, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n"],"names":[],"version":3,"file":"useListState.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA8BM,SAAS,0CAA+B,KAAmB;IAChE,IAAI,UAAC,MAAM,EAAC,GAAG;IAEf,IAAI,iBAAiB,CAAA,GAAA,gCAAwB,EAAE;IAC/C,IAAI,eAAe,CAAA,GAAA,cAAM,EAAE,IACzB,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,YAAY,IAAI,IAAI,OACvD;QAAC,MAAM,YAAY;KAAC;IAEtB,IAAI,UAAU,CAAA,GAAA,kBAAU,EAAE,CAAA,QAAS,SAAS,IAAI,CAAA,GAAA,yCAAa,EAAE,OAAO,UAAU,IAAI,CAAA,GAAA,yCAAa,EAAE,QAA6B;QAAC;KAAO;IACxI,IAAI,UAAU,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YAAC,0BAA0B,MAAM,wBAAwB;QAAA,CAAA,GAAI;QAAC,MAAM,wBAAwB;KAAC;IAE1H,IAAI,aAAa,CAAA,GAAA,oBAAY,EAAE,OAAO,SAAS;IAE/C,IAAI,mBAAmB,CAAA,GAAA,cAAM,EAAE,IAC7B,IAAI,CAAA,GAAA,uBAAe,EAAE,YAAY,iBAC/B;QAAC;QAAY;KAAe;IAGhC,iEAAiE;IACjE,MAAM,mBAAmB,CAAA,GAAA,aAAK,EAA8B;IAC5D,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,eAAe,UAAU,IAAI,QAAQ,CAAC,WAAW,OAA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M,CAAC,GAAG,GAAG;oBACtD,UAAU,SAAS,CAAC,MAAM;oBAC1B;gBACF;gBACA,gCAAgC;gBAChC,IAAI,QAAQ,UAAU,MAAM,GAAG,KAAK,CAAC,oBACnC;qBAEK;oBACL,qBAAqB;wBACR,mBACF;oBADX,IAAI,QAAS,CAAA,CAAA,oBAAA,sBAAA,gCAAA,UAAW,KAAK,cAAhB,+BAAA,oBAAoB,CAAA,GAC/B,QAAS,CAAA,oBAAA,sBAAA,gCAAA,UAAW,KAAK,cAAhB,+BAAA,oBAAoB;oBAE/B;gBACF;YACF;YACA,eAAe,aAAa,CAAC,UAAU,QAAQ,GAAG,GAAG;QACvD;QACA,iBAAiB,OAAO,GAAG;IAC7B,GAAG;QAAC;QAAY;QAAkB;QAAgB,eAAe,UAAU;KAAC;IAE5E,OAAO;oBACL;sBACA;0BACA;IACF;AACF","sources":["packages/@react-stately/list/src/useListState.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, CollectionStateBase, Key, Node} from '@react-types/shared';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCallback, useEffect, useMemo, useRef} from 'react';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionStateBase<T>, MultipleSelectionStateProps {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface ListState<T> {\n /** A collection of items in the list. */\n collection: Collection<Node<T>>,\n\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>,\n\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager\n}\n\n/**\n * Provides state management for list-like components. Handles building a collection\n * of items from props, and manages multiple selection state.\n */\nexport function useListState<T extends object>(props: ListProps<T>): ListState<T> {\n let {filter} = props;\n\n let selectionState = useMultipleSelectionState(props);\n let disabledKeys = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n\n let factory = useCallback(nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>), [filter]);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context);\n\n let selectionManager = useMemo(() =>\n new SelectionManager(collection, selectionState)\n , [collection, selectionState]\n );\n\n // Reset focused key if that item is deleted from the collection.\n const cachedCollection = useRef<Collection<Node<T>> | null>(null);\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey) && cachedCollection.current) {\n const startItem = cachedCollection.current.getItem(selectionState.focusedKey);\n const cachedItemNodes = [...cachedCollection.current.getKeys()].map(\n key => {\n const itemNode = cachedCollection.current!.getItem(key);\n return itemNode?.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const itemNodes = [...collection.getKeys()].map(\n key => {\n const itemNode = collection.getItem(key);\n return itemNode?.type === 'item' ? itemNode : null;\n }\n ).filter(node => node !== null);\n const diff: number = (cachedItemNodes?.length ?? 0) - (itemNodes?.length ?? 0);\n let index = Math.min(\n (\n diff > 1 ?\n Math.max((startItem?.index ?? 0) - diff + 1, 0) :\n startItem?.index ?? 0\n ),\n (itemNodes?.length ?? 0) - 1);\n let newNode: Node<T> | null = null;\n let isReverseSearching = false;\n while (index >= 0) {\n if (!selectionManager.isDisabled(itemNodes[index].key)) {\n newNode = itemNodes[index];\n break;\n }\n // Find next, not disabled item.\n if (index < itemNodes.length - 1 && !isReverseSearching) {\n index++;\n // Otherwise, find previous, not disabled item.\n } else {\n isReverseSearching = true;\n if (index > (startItem?.index ?? 0)) {\n index = (startItem?.index ?? 0);\n }\n index--;\n }\n }\n selectionState.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager, selectionState, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n"],"names":[],"version":3,"file":"useListState.module.js.map"}
@@ -36,6 +36,8 @@ function $b9e99587a092d199$export$e7f05e985daf4b5f(props) {
36
36
  allowDuplicateSelectionEvents: true,
37
37
  selectedKeys: selectedKeys,
38
38
  onSelectionChange: (keys)=>{
39
+ // impossible, but TS doesn't know that
40
+ if (keys === 'all') return;
39
41
  var _keys_values_next_value;
40
42
  let key = (_keys_values_next_value = keys.values().next().value) !== null && _keys_values_next_value !== void 0 ? _keys_values_next_value : null;
41
43
  // Always fire onSelectionChange, even if the key is the same
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAA2C,KAA+B;QACd;IAA1E,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,2CAAiB,EAAE,MAAM,WAAW,EAAE,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,MAAM,MAAM,iBAAiB;IACnI,IAAI,eAAe,CAAA,GAAA,oBAAM,EAAE,IAAM,eAAe,OAAO;YAAC;SAAY,GAAG,EAAE,EAAE;QAAC;KAAY;IACxF,IAAI,cAAC,UAAU,gBAAE,YAAY,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,sCAAW,EAAE;QAC9D,GAAG,KAAK;QACR,eAAe;QACf,wBAAwB;QACxB,+BAA+B;sBAC/B;QACA,mBAAmB,CAAC;gBACR;YAAV,IAAI,MAAM,CAAA,0BAAA,KAAK,MAAM,GAAG,IAAI,GAAG,KAAK,cAA1B,qCAAA,0BAA8B;YAExC,6DAA6D;YAC7D,oDAAoD;YACpD,IAAI,QAAQ,eAAe,MAAM,iBAAiB,EAChD,MAAM,iBAAiB,CAAC;YAG1B,eAAe;QACjB;IACF;IAEA,IAAI,eAAe,eAAe,OAC9B,WAAW,OAAO,CAAC,eACnB;IAEJ,OAAO;oBACL;sBACA;0BACA;qBACA;wBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/list/src/useSingleSelectListState.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 {CollectionStateBase, Key, Node, SingleSelection} from '@react-types/shared';\nimport {ListState, useListState} from './useListState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<SingleSelection, 'disallowEmptySelection'> {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface SingleSelectListState<T> extends ListState<T> {\n /** The key for the currently selected item. */\n readonly selectedKey: Key,\n\n /** Sets the selected key. */\n setSelectedKey(key: Key | null): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T> | null\n}\n\n/**\n * Provides state management for list-like components with single selection.\n * Handles building a collection of items from props, and manages selection state.\n */\nexport function useSingleSelectListState<T extends object>(props: SingleSelectListProps<T>): SingleSelectListState<T> {\n let [selectedKey, setSelectedKey] = useControlledState(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);\n let selectedKeys = useMemo(() => selectedKey != null ? [selectedKey] : [], [selectedKey]);\n let {collection, disabledKeys, selectionManager} = useListState({\n ...props,\n selectionMode: 'single',\n disallowEmptySelection: true,\n allowDuplicateSelectionEvents: true,\n selectedKeys,\n onSelectionChange: (keys: Set<Key>) => {\n let key = keys.values().next().value ?? null;\n\n // Always fire onSelectionChange, even if the key is the same\n // as the current key (useControlledState does not).\n if (key === selectedKey && props.onSelectionChange) {\n props.onSelectionChange(key);\n }\n\n setSelectedKey(key);\n }\n });\n\n let selectedItem = selectedKey != null\n ? collection.getItem(selectedKey)\n : null;\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n selectedKey,\n setSelectedKey,\n selectedItem\n };\n}\n"],"names":[],"version":3,"file":"useSingleSelectListState.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAA2C,KAA+B;QACd;IAA1E,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,2CAAiB,EAAE,MAAM,WAAW,EAAE,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,MAAM,MAAM,iBAAiB;IACnI,IAAI,eAAe,CAAA,GAAA,oBAAM,EAAE,IAAM,eAAe,OAAO;YAAC;SAAY,GAAG,EAAE,EAAE;QAAC;KAAY;IACxF,IAAI,cAAC,UAAU,gBAAE,YAAY,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,sCAAW,EAAE;QAC9D,GAAG,KAAK;QACR,eAAe;QACf,wBAAwB;QACxB,+BAA+B;sBAC/B;QACA,mBAAmB,CAAC;YAClB,uCAAuC;YACvC,IAAI,SAAS,OACX;gBAEQ;YAAV,IAAI,MAAM,CAAA,0BAAA,KAAK,MAAM,GAAG,IAAI,GAAG,KAAK,cAA1B,qCAAA,0BAA8B;YAExC,6DAA6D;YAC7D,oDAAoD;YACpD,IAAI,QAAQ,eAAe,MAAM,iBAAiB,EAChD,MAAM,iBAAiB,CAAC;YAG1B,eAAe;QACjB;IACF;IAEA,IAAI,eAAe,eAAe,OAC9B,WAAW,OAAO,CAAC,eACnB;IAEJ,OAAO;oBACL;sBACA;0BACA;qBACA;wBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/list/src/useSingleSelectListState.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 {CollectionStateBase, Key, Node, Selection, SingleSelection} from '@react-types/shared';\nimport {ListState, useListState} from './useListState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<SingleSelection, 'disallowEmptySelection'> {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface SingleSelectListState<T> extends ListState<T> {\n /** The key for the currently selected item. */\n readonly selectedKey: Key | null,\n\n /** Sets the selected key. */\n setSelectedKey(key: Key | null): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T> | null\n}\n\n/**\n * Provides state management for list-like components with single selection.\n * Handles building a collection of items from props, and manages selection state.\n */\nexport function useSingleSelectListState<T extends object>(props: SingleSelectListProps<T>): SingleSelectListState<T> {\n let [selectedKey, setSelectedKey] = useControlledState(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);\n let selectedKeys = useMemo(() => selectedKey != null ? [selectedKey] : [], [selectedKey]);\n let {collection, disabledKeys, selectionManager} = useListState({\n ...props,\n selectionMode: 'single',\n disallowEmptySelection: true,\n allowDuplicateSelectionEvents: true,\n selectedKeys,\n onSelectionChange: (keys: Selection) => {\n // impossible, but TS doesn't know that\n if (keys === 'all') {\n return;\n }\n let key = keys.values().next().value ?? null;\n\n // Always fire onSelectionChange, even if the key is the same\n // as the current key (useControlledState does not).\n if (key === selectedKey && props.onSelectionChange) {\n props.onSelectionChange(key);\n }\n\n setSelectedKey(key);\n }\n });\n\n let selectedItem = selectedKey != null\n ? collection.getItem(selectedKey)\n : null;\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n selectedKey,\n setSelectedKey,\n selectedItem\n };\n}\n"],"names":[],"version":3,"file":"useSingleSelectListState.main.js.map"}
@@ -30,6 +30,8 @@ function $a0d645289fe9b86b$export$e7f05e985daf4b5f(props) {
30
30
  allowDuplicateSelectionEvents: true,
31
31
  selectedKeys: selectedKeys,
32
32
  onSelectionChange: (keys)=>{
33
+ // impossible, but TS doesn't know that
34
+ if (keys === 'all') return;
33
35
  var _keys_values_next_value;
34
36
  let key = (_keys_values_next_value = keys.values().next().value) !== null && _keys_values_next_value !== void 0 ? _keys_values_next_value : null;
35
37
  // Always fire onSelectionChange, even if the key is the same
@@ -30,6 +30,8 @@ function $a0d645289fe9b86b$export$e7f05e985daf4b5f(props) {
30
30
  allowDuplicateSelectionEvents: true,
31
31
  selectedKeys: selectedKeys,
32
32
  onSelectionChange: (keys)=>{
33
+ // impossible, but TS doesn't know that
34
+ if (keys === 'all') return;
33
35
  var _keys_values_next_value;
34
36
  let key = (_keys_values_next_value = keys.values().next().value) !== null && _keys_values_next_value !== void 0 ? _keys_values_next_value : null;
35
37
  // Always fire onSelectionChange, even if the key is the same
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAA2C,KAA+B;QACd;IAA1E,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,WAAW,EAAE,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,MAAM,MAAM,iBAAiB;IACnI,IAAI,eAAe,CAAA,GAAA,cAAM,EAAE,IAAM,eAAe,OAAO;YAAC;SAAY,GAAG,EAAE,EAAE;QAAC;KAAY;IACxF,IAAI,cAAC,UAAU,gBAAE,YAAY,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,yCAAW,EAAE;QAC9D,GAAG,KAAK;QACR,eAAe;QACf,wBAAwB;QACxB,+BAA+B;sBAC/B;QACA,mBAAmB,CAAC;gBACR;YAAV,IAAI,MAAM,CAAA,0BAAA,KAAK,MAAM,GAAG,IAAI,GAAG,KAAK,cAA1B,qCAAA,0BAA8B;YAExC,6DAA6D;YAC7D,oDAAoD;YACpD,IAAI,QAAQ,eAAe,MAAM,iBAAiB,EAChD,MAAM,iBAAiB,CAAC;YAG1B,eAAe;QACjB;IACF;IAEA,IAAI,eAAe,eAAe,OAC9B,WAAW,OAAO,CAAC,eACnB;IAEJ,OAAO;oBACL;sBACA;0BACA;qBACA;wBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/list/src/useSingleSelectListState.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 {CollectionStateBase, Key, Node, SingleSelection} from '@react-types/shared';\nimport {ListState, useListState} from './useListState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<SingleSelection, 'disallowEmptySelection'> {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface SingleSelectListState<T> extends ListState<T> {\n /** The key for the currently selected item. */\n readonly selectedKey: Key,\n\n /** Sets the selected key. */\n setSelectedKey(key: Key | null): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T> | null\n}\n\n/**\n * Provides state management for list-like components with single selection.\n * Handles building a collection of items from props, and manages selection state.\n */\nexport function useSingleSelectListState<T extends object>(props: SingleSelectListProps<T>): SingleSelectListState<T> {\n let [selectedKey, setSelectedKey] = useControlledState(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);\n let selectedKeys = useMemo(() => selectedKey != null ? [selectedKey] : [], [selectedKey]);\n let {collection, disabledKeys, selectionManager} = useListState({\n ...props,\n selectionMode: 'single',\n disallowEmptySelection: true,\n allowDuplicateSelectionEvents: true,\n selectedKeys,\n onSelectionChange: (keys: Set<Key>) => {\n let key = keys.values().next().value ?? null;\n\n // Always fire onSelectionChange, even if the key is the same\n // as the current key (useControlledState does not).\n if (key === selectedKey && props.onSelectionChange) {\n props.onSelectionChange(key);\n }\n\n setSelectedKey(key);\n }\n });\n\n let selectedItem = selectedKey != null\n ? collection.getItem(selectedKey)\n : null;\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n selectedKey,\n setSelectedKey,\n selectedItem\n };\n}\n"],"names":[],"version":3,"file":"useSingleSelectListState.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAA2C,KAA+B;QACd;IAA1E,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,WAAW,EAAE,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,MAAM,MAAM,iBAAiB;IACnI,IAAI,eAAe,CAAA,GAAA,cAAM,EAAE,IAAM,eAAe,OAAO;YAAC;SAAY,GAAG,EAAE,EAAE;QAAC;KAAY;IACxF,IAAI,cAAC,UAAU,gBAAE,YAAY,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,yCAAW,EAAE;QAC9D,GAAG,KAAK;QACR,eAAe;QACf,wBAAwB;QACxB,+BAA+B;sBAC/B;QACA,mBAAmB,CAAC;YAClB,uCAAuC;YACvC,IAAI,SAAS,OACX;gBAEQ;YAAV,IAAI,MAAM,CAAA,0BAAA,KAAK,MAAM,GAAG,IAAI,GAAG,KAAK,cAA1B,qCAAA,0BAA8B;YAExC,6DAA6D;YAC7D,oDAAoD;YACpD,IAAI,QAAQ,eAAe,MAAM,iBAAiB,EAChD,MAAM,iBAAiB,CAAC;YAG1B,eAAe;QACjB;IACF;IAEA,IAAI,eAAe,eAAe,OAC9B,WAAW,OAAO,CAAC,eACnB;IAEJ,OAAO;oBACL;sBACA;0BACA;qBACA;wBACA;sBACA;IACF;AACF","sources":["packages/@react-stately/list/src/useSingleSelectListState.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 {CollectionStateBase, Key, Node, Selection, SingleSelection} from '@react-types/shared';\nimport {ListState, useListState} from './useListState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<SingleSelection, 'disallowEmptySelection'> {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>,\n /** @private */\n suppressTextValueWarning?: boolean\n}\n\nexport interface SingleSelectListState<T> extends ListState<T> {\n /** The key for the currently selected item. */\n readonly selectedKey: Key | null,\n\n /** Sets the selected key. */\n setSelectedKey(key: Key | null): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T> | null\n}\n\n/**\n * Provides state management for list-like components with single selection.\n * Handles building a collection of items from props, and manages selection state.\n */\nexport function useSingleSelectListState<T extends object>(props: SingleSelectListProps<T>): SingleSelectListState<T> {\n let [selectedKey, setSelectedKey] = useControlledState(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);\n let selectedKeys = useMemo(() => selectedKey != null ? [selectedKey] : [], [selectedKey]);\n let {collection, disabledKeys, selectionManager} = useListState({\n ...props,\n selectionMode: 'single',\n disallowEmptySelection: true,\n allowDuplicateSelectionEvents: true,\n selectedKeys,\n onSelectionChange: (keys: Selection) => {\n // impossible, but TS doesn't know that\n if (keys === 'all') {\n return;\n }\n let key = keys.values().next().value ?? null;\n\n // Always fire onSelectionChange, even if the key is the same\n // as the current key (useControlledState does not).\n if (key === selectedKey && props.onSelectionChange) {\n props.onSelectionChange(key);\n }\n\n setSelectedKey(key);\n }\n });\n\n let selectedItem = selectedKey != null\n ? collection.getItem(selectedKey)\n : null;\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n selectedKey,\n setSelectedKey,\n selectedItem\n };\n}\n"],"names":[],"version":3,"file":"useSingleSelectListState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/list",
3
- "version": "3.10.8",
3
+ "version": "3.10.9-nightly.5014+8f3c0ea09",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,10 +22,10 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/collections": "^3.10.9",
26
- "@react-stately/selection": "^3.16.2",
27
- "@react-stately/utils": "^3.10.3",
28
- "@react-types/shared": "^3.24.1",
25
+ "@react-stately/collections": "3.0.0-nightly.3086+8f3c0ea09",
26
+ "@react-stately/selection": "3.0.0-nightly.3086+8f3c0ea09",
27
+ "@react-stately/utils": "3.0.0-nightly.3086+8f3c0ea09",
28
+ "@react-types/shared": "3.0.0-nightly.3086+8f3c0ea09",
29
29
  "@swc/helpers": "^0.5.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "faf0e18467231422cb7a06eb92a74d04e271f1e8"
37
+ "gitHead": "8f3c0ea0931107eceba0127fb524b79b46eb838b"
38
38
  }
@@ -15,8 +15,8 @@ import {Collection, Key, Node} from '@react-types/shared';
15
15
  export class ListCollection<T> implements Collection<Node<T>> {
16
16
  private keyMap: Map<Key, Node<T>> = new Map();
17
17
  private iterable: Iterable<Node<T>>;
18
- private firstKey: Key;
19
- private lastKey: Key;
18
+ private firstKey: Key | null = null;
19
+ private lastKey: Key | null = null;
20
20
 
21
21
  constructor(nodes: Iterable<Node<T>>) {
22
22
  this.iterable = nodes;
@@ -35,7 +35,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
35
35
  visit(node);
36
36
  }
37
37
 
38
- let last: Node<T>;
38
+ let last: Node<T> | null = null;
39
39
  let index = 0;
40
40
  for (let [key, node] of this.keyMap) {
41
41
  if (last) {
@@ -57,7 +57,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
57
57
  last.nextKey = undefined;
58
58
  }
59
59
 
60
- this.lastKey = last?.key;
60
+ this.lastKey = last?.key ?? null;
61
61
  }
62
62
 
63
63
  *[Symbol.iterator]() {
@@ -74,12 +74,12 @@ export class ListCollection<T> implements Collection<Node<T>> {
74
74
 
75
75
  getKeyBefore(key: Key) {
76
76
  let node = this.keyMap.get(key);
77
- return node ? node.prevKey : null;
77
+ return node ? node.prevKey ?? null : null;
78
78
  }
79
79
 
80
80
  getKeyAfter(key: Key) {
81
81
  let node = this.keyMap.get(key);
82
- return node ? node.nextKey : null;
82
+ return node ? node.nextKey ?? null : null;
83
83
  }
84
84
 
85
85
  getFirstKey() {
@@ -91,7 +91,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
91
91
  }
92
92
 
93
93
  getItem(key: Key) {
94
- return this.keyMap.get(key);
94
+ return this.keyMap.get(key) ?? null;
95
95
  }
96
96
 
97
97
  at(idx: number) {
@@ -57,31 +57,31 @@ export function useListState<T extends object>(props: ListProps<T>): ListState<T
57
57
  );
58
58
 
59
59
  // Reset focused key if that item is deleted from the collection.
60
- const cachedCollection = useRef(null);
60
+ const cachedCollection = useRef<Collection<Node<T>> | null>(null);
61
61
  useEffect(() => {
62
- if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
62
+ if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey) && cachedCollection.current) {
63
63
  const startItem = cachedCollection.current.getItem(selectionState.focusedKey);
64
64
  const cachedItemNodes = [...cachedCollection.current.getKeys()].map(
65
65
  key => {
66
- const itemNode = cachedCollection.current.getItem(key);
67
- return itemNode.type === 'item' ? itemNode : null;
66
+ const itemNode = cachedCollection.current!.getItem(key);
67
+ return itemNode?.type === 'item' ? itemNode : null;
68
68
  }
69
69
  ).filter(node => node !== null);
70
70
  const itemNodes = [...collection.getKeys()].map(
71
71
  key => {
72
72
  const itemNode = collection.getItem(key);
73
- return itemNode.type === 'item' ? itemNode : null;
73
+ return itemNode?.type === 'item' ? itemNode : null;
74
74
  }
75
75
  ).filter(node => node !== null);
76
- const diff = cachedItemNodes.length - itemNodes.length;
76
+ const diff: number = (cachedItemNodes?.length ?? 0) - (itemNodes?.length ?? 0);
77
77
  let index = Math.min(
78
78
  (
79
79
  diff > 1 ?
80
- Math.max(startItem.index - diff + 1, 0) :
81
- startItem.index
80
+ Math.max((startItem?.index ?? 0) - diff + 1, 0) :
81
+ startItem?.index ?? 0
82
82
  ),
83
- itemNodes.length - 1);
84
- let newNode:Node<T>;
83
+ (itemNodes?.length ?? 0) - 1);
84
+ let newNode: Node<T> | null = null;
85
85
  let isReverseSearching = false;
86
86
  while (index >= 0) {
87
87
  if (!selectionManager.isDisabled(itemNodes[index].key)) {
@@ -94,8 +94,8 @@ export function useListState<T extends object>(props: ListProps<T>): ListState<T
94
94
  // Otherwise, find previous, not disabled item.
95
95
  } else {
96
96
  isReverseSearching = true;
97
- if (index > startItem.index) {
98
- index = startItem.index;
97
+ if (index > (startItem?.index ?? 0)) {
98
+ index = (startItem?.index ?? 0);
99
99
  }
100
100
  index--;
101
101
  }
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {CollectionStateBase, Key, Node, SingleSelection} from '@react-types/shared';
13
+ import {CollectionStateBase, Key, Node, Selection, SingleSelection} from '@react-types/shared';
14
14
  import {ListState, useListState} from './useListState';
15
15
  import {useControlledState} from '@react-stately/utils';
16
16
  import {useMemo} from 'react';
@@ -24,7 +24,7 @@ export interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<S
24
24
 
25
25
  export interface SingleSelectListState<T> extends ListState<T> {
26
26
  /** The key for the currently selected item. */
27
- readonly selectedKey: Key,
27
+ readonly selectedKey: Key | null,
28
28
 
29
29
  /** Sets the selected key. */
30
30
  setSelectedKey(key: Key | null): void,
@@ -46,7 +46,11 @@ export function useSingleSelectListState<T extends object>(props: SingleSelectLi
46
46
  disallowEmptySelection: true,
47
47
  allowDuplicateSelectionEvents: true,
48
48
  selectedKeys,
49
- onSelectionChange: (keys: Set<Key>) => {
49
+ onSelectionChange: (keys: Selection) => {
50
+ // impossible, but TS doesn't know that
51
+ if (keys === 'all') {
52
+ return;
53
+ }
50
54
  let key = keys.values().next().value ?? null;
51
55
 
52
56
  // Always fire onSelectionChange, even if the key is the same