@react-stately/list 3.12.3 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$
19
19
  yield* this.iterable;
20
20
  }
21
21
  get size() {
22
- return this.keyMap.size;
22
+ return this._size;
23
23
  }
24
24
  getKeys() {
25
25
  return this.keyMap.keys();
@@ -66,6 +66,7 @@ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$
66
66
  for (let node of nodes)visit(node);
67
67
  let last = null;
68
68
  let index = 0;
69
+ let size = 0;
69
70
  for (let [key, node] of this.keyMap){
70
71
  if (last) {
71
72
  last.nextKey = key;
@@ -75,11 +76,15 @@ $parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$export$
75
76
  node.prevKey = undefined;
76
77
  }
77
78
  if (node.type === 'item') node.index = index++;
79
+ // Only count sections and items when determining size so that
80
+ // loaders and separators in RAC/S2 don't influence the emptyState determination
81
+ if (node.type === 'section' || node.type === 'item') size++;
78
82
  last = node;
79
83
  // Set nextKey as undefined since this might be the last node
80
84
  // If it isn't the last node, last.nextKey will properly set at start of new loop
81
85
  last.nextKey = undefined;
82
86
  }
87
+ this._size = size;
83
88
  var _last_key;
84
89
  this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
85
90
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAgDX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAA8B;QAC9C,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,UAAiC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAc;QACjC,IAAI,OAAO,IAAI,CA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AAM;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](): IterableIterator<Node<T>> {\n yield* this.iterable;\n }\n\n get size(): number {\n return this.keyMap.size;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n return this.lastKey;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number): Node<T> | null {\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;IAwDX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAA8B;QAC9C,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK;IACnB;IAEA,UAAiC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAc;QACjC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,YAAY,GAAQ,EAAc;QAChC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC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aAAa,KAAK,IAAI,KAAK,QAC3C;YAGF,OAAO;YAEP,6DAA6D;YAC7D,iFAAiF;YACjF,KAAK,OAAO,GAAG;QACjB;QACA,IAAI,CAAC,KAAK,GAAG;YACE;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 private _size: number;\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 let size = 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 // Only count sections and items when determining size so that\n // loaders and separators in RAC/S2 don't influence the emptyState determination\n if (node.type === 'section' || node.type === 'item') {\n size++;\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 this._size = size;\n this.lastKey = last?.key ?? null;\n }\n\n *[Symbol.iterator](): IterableIterator<Node<T>> {\n yield* this.iterable;\n }\n\n get size(): number {\n return this._size;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n return this.lastKey;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number): Node<T> | null {\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"}
@@ -13,7 +13,7 @@
13
13
  yield* this.iterable;
14
14
  }
15
15
  get size() {
16
- return this.keyMap.size;
16
+ return this._size;
17
17
  }
18
18
  getKeys() {
19
19
  return this.keyMap.keys();
@@ -60,6 +60,7 @@
60
60
  for (let node of nodes)visit(node);
61
61
  let last = null;
62
62
  let index = 0;
63
+ let size = 0;
63
64
  for (let [key, node] of this.keyMap){
64
65
  if (last) {
65
66
  last.nextKey = key;
@@ -69,11 +70,15 @@
69
70
  node.prevKey = undefined;
70
71
  }
71
72
  if (node.type === 'item') node.index = index++;
73
+ // Only count sections and items when determining size so that
74
+ // loaders and separators in RAC/S2 don't influence the emptyState determination
75
+ if (node.type === 'section' || node.type === 'item') size++;
72
76
  last = node;
73
77
  // Set nextKey as undefined since this might be the last node
74
78
  // If it isn't the last node, last.nextKey will properly set at start of new loop
75
79
  last.nextKey = undefined;
76
80
  }
81
+ this._size = size;
77
82
  var _last_key;
78
83
  this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
79
84
  }
@@ -13,7 +13,7 @@
13
13
  yield* this.iterable;
14
14
  }
15
15
  get size() {
16
- return this.keyMap.size;
16
+ return this._size;
17
17
  }
18
18
  getKeys() {
19
19
  return this.keyMap.keys();
@@ -60,6 +60,7 @@
60
60
  for (let node of nodes)visit(node);
61
61
  let last = null;
62
62
  let index = 0;
63
+ let size = 0;
63
64
  for (let [key, node] of this.keyMap){
64
65
  if (last) {
65
66
  last.nextKey = key;
@@ -69,11 +70,15 @@
69
70
  node.prevKey = undefined;
70
71
  }
71
72
  if (node.type === 'item') node.index = index++;
73
+ // Only count sections and items when determining size so that
74
+ // loaders and separators in RAC/S2 don't influence the emptyState determination
75
+ if (node.type === 'section' || node.type === 'item') size++;
72
76
  last = node;
73
77
  // Set nextKey as undefined since this might be the last node
74
78
  // If it isn't the last node, last.nextKey will properly set at start of new loop
75
79
  last.nextKey = undefined;
76
80
  }
81
+ this._size = size;
77
82
  var _last_key;
78
83
  this.lastKey = (_last_key = last === null || last === void 0 ? void 0 : last.key) !== null && _last_key !== void 0 ? _last_key : null;
79
84
  }
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAgDX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAA8B;QAC9C,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,UAAiC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAc;QACjC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,YAAY,GAAQ,EAAc;QAChC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CA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,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](): IterableIterator<Node<T>> {\n yield* this.iterable;\n }\n\n get size(): number {\n return this.keyMap.size;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n return this.lastKey;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number): Node<T> | null {\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;IAwDX,CAAC,CAAC,OAAO,QAAQ,CAAC,GAA8B;QAC9C,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK;IACnB;IAEA,UAAiC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB;IAEA,aAAa,GAAQ,EAAc;QACjC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,YAAY,GAAQ,EAAc;QAChC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACb;QAAd,OAAO,OAAO,CAAA,gBAAA,KAAK,OAAO,cAAZ,2BAAA,gBAAgB,OAAO;IACvC;IAEA,cAA0B;QACxB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,aAAyB;QACvB,OAAO,IAAI,CAAC,OAAO;IACrB;IAEA,QAAQ,GAAQ,EAAkB;YACzB;QAAP,OAAO,CAAA,mBAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CA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,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 private _size: number;\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 let size = 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 // Only count sections and items when determining size so that\n // loaders and separators in RAC/S2 don't influence the emptyState determination\n if (node.type === 'section' || node.type === 'item') {\n size++;\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 this._size = size;\n this.lastKey = last?.key ?? null;\n }\n\n *[Symbol.iterator](): IterableIterator<Node<T>> {\n yield* this.iterable;\n }\n\n get size(): number {\n return this._size;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.prevKey ?? null : null;\n }\n\n getKeyAfter(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node ? node.nextKey ?? null : null;\n }\n\n getFirstKey(): Key | null {\n return this.firstKey;\n }\n\n getLastKey(): Key | null {\n return this.lastKey;\n }\n\n getItem(key: Key): Node<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number): Node<T> | null {\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 function useListState<T extends object>(props: ListProps<T>): ListState<T
40
40
  /**
41
41
  * Filters a collection using the provided filter function and returns a new ListState.
42
42
  */
43
- export function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filter: ((nodeValue: string) => boolean) | null | undefined): ListState<T>;
43
+ export function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): ListState<T>;
44
44
  export interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<SingleSelection, 'disallowEmptySelection'> {
45
45
  /** Filter function to generate a filtered list of nodes. */
46
46
  filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>;
@@ -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,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAI/C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,IAAI,gBAAgB,CAAC,GAAG,CAAC;IAIhC,YAAY,CAAC,GAA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CAAC,CAAC,CAS9J;ACnED,uCAAuC,CAAC,CAAE,SAAQ,oBAAoB,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,wBAAwB,CAAC;IACvH,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,eAAe;IACf,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC;AAED,uCAAuC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC;IAC5D,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,CAAC;IAEjC,6BAA6B;IAC7B,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,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,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, UNSTABLE_useFilteredListState} 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;gBAO/C,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAiDnC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAI/C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,IAAI,gBAAgB,CAAC,GAAG,CAAC;IAIhC,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI;IAKlC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI;IAKjC,WAAW,IAAI,GAAG,GAAG,IAAI;IAIzB,UAAU,IAAI,GAAG,GAAG,IAAI;IAIxB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI;IAIjC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI;IAK/B,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;CAIzC;AC/FD,2BAA2B,CAAC,CAAE,SAAQ,oBAAoB,CAAC,CAAC,EAAE,2BAA2B;IACvF,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,eAAe;IACf,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,cA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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, UNSTABLE_useFilteredListState} from './useListState';\nexport {useSingleSelectListState} from './useSingleSelectListState';\nexport {ListCollection} from './ListCollection';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -53,10 +53,10 @@ function $5450691d3629f6ea$export$2f645645f7bca764(props) {
53
53
  selectionManager: selectionManager
54
54
  };
55
55
  }
56
- function $5450691d3629f6ea$export$ba9d38c0f1bf2b36(state, filter) {
57
- let collection = (0, $5RsKl$react.useMemo)(()=>filter ? state.collection.UNSTABLE_filter(filter) : state.collection, [
56
+ function $5450691d3629f6ea$export$ba9d38c0f1bf2b36(state, filterFn) {
57
+ let collection = (0, $5RsKl$react.useMemo)(()=>filterFn ? state.collection.filter(filterFn) : state.collection, [
58
58
  state.collection,
59
- filter
59
+ filterFn
60
60
  ]);
61
61
  let selectionManager = state.selectionManager.withCollection(collection);
62
62
  $5450691d3629f6ea$var$useFocusedKeyReset(collection, selectionManager);
@@ -1 +1 @@
1
- {"mappings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AAA,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,iBAAiB,aAAa,CAAC,UAAU,QAAQ,GAAG,GAAG;QACzD;QACA,iBAAiB,OAAO,GAAG;IAC7B,GAAG;QAAC;QAAY;KAAiB;AACnC","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, LayoutDelegate, 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 * A delegate object that provides layout information for items in the collection.\n * This can be used to override the behavior of shift selection.\n */\n layoutDelegate?: LayoutDelegate\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, layoutDelegate} = 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, {layoutDelegate})\n , [collection, selectionState, layoutDelegate]\n );\n\n useFocusedKeyReset(collection, selectionManager);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new ListState.\n */\nexport function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filter: ((nodeValue: string) => boolean) | null | undefined): ListState<T> {\n let collection = useMemo(() => filter ? state.collection.UNSTABLE_filter!(filter) : state.collection, [state.collection, filter]);\n let selectionManager = state.selectionManager.withCollection(collection);\n useFocusedKeyReset(collection, selectionManager);\n return {\n collection,\n selectionManager,\n disabledKeys: state.disabledKeys\n };\n}\n\nfunction useFocusedKeyReset<T>(collection: Collection<Node<T>>, selectionManager: SelectionManager) {\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 (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {\n const startItem = cachedCollection.current.getItem(selectionManager.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 selectionManager.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager]);\n}\n"],"names":[],"version":3,"file":"useListState.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,SAAS,0CAA+B,KAAmB;IAChE,IAAI,UAAC,MAAM,kBAAE,cAAc,EAAC,GAAG;IAE/B,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,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A,gCAAA,UAAW,KAAK,cAAhB,+BAAA,oBAAoB,CAAA,GAC/B,QAAS,CAAA,oBAAA,sBAAA,gCAAA,UAAW,KAAK,cAAhB,+BAAA,oBAAoB;oBAE/B;gBACF;YACF;YACA,iBAAiB,aAAa,CAAC,UAAU,QAAQ,GAAG,GAAG;QACzD;QACA,iBAAiB,OAAO,GAAG;IAC7B,GAAG;QAAC;QAAY;KAAiB;AACnC","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, LayoutDelegate, 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 * A delegate object that provides layout information for items in the collection.\n * This can be used to override the behavior of shift selection.\n */\n layoutDelegate?: LayoutDelegate\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, layoutDelegate} = 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, {layoutDelegate})\n , [collection, selectionState, layoutDelegate]\n );\n\n useFocusedKeyReset(collection, selectionManager);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new ListState.\n */\nexport function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): ListState<T> {\n let collection = useMemo(() => filterFn ? state.collection.filter!(filterFn) : state.collection, [state.collection, filterFn]);\n let selectionManager = state.selectionManager.withCollection(collection);\n useFocusedKeyReset(collection, selectionManager);\n return {\n collection,\n selectionManager,\n disabledKeys: state.disabledKeys\n };\n}\n\nfunction useFocusedKeyReset<T>(collection: Collection<Node<T>>, selectionManager: SelectionManager) {\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 (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {\n const startItem = cachedCollection.current.getItem(selectionManager.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 selectionManager.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager]);\n}\n"],"names":[],"version":3,"file":"useListState.main.js.map"}
@@ -46,10 +46,10 @@ function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
46
46
  selectionManager: selectionManager
47
47
  };
48
48
  }
49
- function $e72dd72e1c76a225$export$ba9d38c0f1bf2b36(state, filter) {
50
- let collection = (0, $d5vlZ$useMemo)(()=>filter ? state.collection.UNSTABLE_filter(filter) : state.collection, [
49
+ function $e72dd72e1c76a225$export$ba9d38c0f1bf2b36(state, filterFn) {
50
+ let collection = (0, $d5vlZ$useMemo)(()=>filterFn ? state.collection.filter(filterFn) : state.collection, [
51
51
  state.collection,
52
- filter
52
+ filterFn
53
53
  ]);
54
54
  let selectionManager = state.selectionManager.withCollection(collection);
55
55
  $e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager);
@@ -46,10 +46,10 @@ function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
46
46
  selectionManager: selectionManager
47
47
  };
48
48
  }
49
- function $e72dd72e1c76a225$export$ba9d38c0f1bf2b36(state, filter) {
50
- let collection = (0, $d5vlZ$useMemo)(()=>filter ? state.collection.UNSTABLE_filter(filter) : state.collection, [
49
+ function $e72dd72e1c76a225$export$ba9d38c0f1bf2b36(state, filterFn) {
50
+ let collection = (0, $d5vlZ$useMemo)(()=>filterFn ? state.collection.filter(filterFn) : state.collection, [
51
51
  state.collection,
52
- filter
52
+ filterFn
53
53
  ]);
54
54
  let selectionManager = state.selectionManager.withCollection(collection);
55
55
  $e72dd72e1c76a225$var$useFocusedKeyReset(collection, selectionManager);
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,SAAS,0CAA+B,KAAmB;IAChE,IAAI,UAAC,MAAM,kBAAE,cAAc,EAAC,GAAG;IAE/B,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,gBAAgB;4BAAC;QAAc,IAC9D;QAAC;QAAY;QAAgB;KAAe;IAGhD,yCAAmB,YAAY;IAE/B,OAAO;oBACL;sBACA;0BACA;IACF;AACF;AAKO,SAAS,0CAAgD,KAAmB,EAAE,MAA2D;IAC9I,IAAI,aAAa,CAAA,GAAA,cAAM,EAAE,IAAM,SAAS,MAAM,UAAU,CAAC,eAAe,CAAE,UAAU,MAAM,UAAU,EAA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A,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,iBAAiB,aAAa,CAAC,UAAU,QAAQ,GAAG,GAAG;QACzD;QACA,iBAAiB,OAAO,GAAG;IAC7B,GAAG;QAAC;QAAY;KAAiB;AACnC","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, LayoutDelegate, 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 * A delegate object that provides layout information for items in the collection.\n * This can be used to override the behavior of shift selection.\n */\n layoutDelegate?: LayoutDelegate\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, layoutDelegate} = 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, {layoutDelegate})\n , [collection, selectionState, layoutDelegate]\n );\n\n useFocusedKeyReset(collection, selectionManager);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new ListState.\n */\nexport function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filter: ((nodeValue: string) => boolean) | null | undefined): ListState<T> {\n let collection = useMemo(() => filter ? state.collection.UNSTABLE_filter!(filter) : state.collection, [state.collection, filter]);\n let selectionManager = state.selectionManager.withCollection(collection);\n useFocusedKeyReset(collection, selectionManager);\n return {\n collection,\n selectionManager,\n disabledKeys: state.disabledKeys\n };\n}\n\nfunction useFocusedKeyReset<T>(collection: Collection<Node<T>>, selectionManager: SelectionManager) {\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 (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {\n const startItem = cachedCollection.current.getItem(selectionManager.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 selectionManager.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager]);\n}\n"],"names":[],"version":3,"file":"useListState.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,SAAS,0CAA+B,KAAmB;IAChE,IAAI,UAAC,MAAM,kBAAE,cAAc,EAAC,GAAG;IAE/B,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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,iBAAiB,aAAa,CAAC,UAAU,QAAQ,GAAG,GAAG;QACzD;QACA,iBAAiB,OAAO,GAAG;IAC7B,GAAG;QAAC;QAAY;KAAiB;AACnC","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, LayoutDelegate, 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 * A delegate object that provides layout information for items in the collection.\n * This can be used to override the behavior of shift selection.\n */\n layoutDelegate?: LayoutDelegate\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, layoutDelegate} = 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, {layoutDelegate})\n , [collection, selectionState, layoutDelegate]\n );\n\n useFocusedKeyReset(collection, selectionManager);\n\n return {\n collection,\n disabledKeys,\n selectionManager\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new ListState.\n */\nexport function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): ListState<T> {\n let collection = useMemo(() => filterFn ? state.collection.filter!(filterFn) : state.collection, [state.collection, filterFn]);\n let selectionManager = state.selectionManager.withCollection(collection);\n useFocusedKeyReset(collection, selectionManager);\n return {\n collection,\n selectionManager,\n disabledKeys: state.disabledKeys\n };\n}\n\nfunction useFocusedKeyReset<T>(collection: Collection<Node<T>>, selectionManager: SelectionManager) {\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 (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {\n const startItem = cachedCollection.current.getItem(selectionManager.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 selectionManager.setFocusedKey(newNode ? newNode.key : null);\n }\n cachedCollection.current = collection;\n }, [collection, selectionManager]);\n}\n"],"names":[],"version":3,"file":"useListState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/list",
3
- "version": "3.12.3",
3
+ "version": "3.13.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -26,10 +26,10 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-stately/collections": "^3.12.5",
30
- "@react-stately/selection": "^3.20.3",
31
- "@react-stately/utils": "^3.10.7",
32
- "@react-types/shared": "^3.30.0",
29
+ "@react-stately/collections": "^3.12.7",
30
+ "@react-stately/selection": "^3.20.5",
31
+ "@react-stately/utils": "^3.10.8",
32
+ "@react-types/shared": "^3.32.0",
33
33
  "@swc/helpers": "^0.5.0"
34
34
  },
35
35
  "peerDependencies": {
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "265b4d7f107905ee1c6e87a8af1613ab440a6849"
41
+ "gitHead": "2c58ed3ddd9be9100af9b1d0cfd137fcdc95ba2d"
42
42
  }
@@ -17,6 +17,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
17
17
  private iterable: Iterable<Node<T>>;
18
18
  private firstKey: Key | null = null;
19
19
  private lastKey: Key | null = null;
20
+ private _size: number;
20
21
 
21
22
  constructor(nodes: Iterable<Node<T>>) {
22
23
  this.iterable = nodes;
@@ -37,6 +38,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
37
38
 
38
39
  let last: Node<T> | null = null;
39
40
  let index = 0;
41
+ let size = 0;
40
42
  for (let [key, node] of this.keyMap) {
41
43
  if (last) {
42
44
  last.nextKey = key;
@@ -50,13 +52,19 @@ export class ListCollection<T> implements Collection<Node<T>> {
50
52
  node.index = index++;
51
53
  }
52
54
 
55
+ // Only count sections and items when determining size so that
56
+ // loaders and separators in RAC/S2 don't influence the emptyState determination
57
+ if (node.type === 'section' || node.type === 'item') {
58
+ size++;
59
+ }
60
+
53
61
  last = node;
54
62
 
55
63
  // Set nextKey as undefined since this might be the last node
56
64
  // If it isn't the last node, last.nextKey will properly set at start of new loop
57
65
  last.nextKey = undefined;
58
66
  }
59
-
67
+ this._size = size;
60
68
  this.lastKey = last?.key ?? null;
61
69
  }
62
70
 
@@ -65,7 +73,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
65
73
  }
66
74
 
67
75
  get size(): number {
68
- return this.keyMap.size;
76
+ return this._size;
69
77
  }
70
78
 
71
79
  getKeys(): IterableIterator<Key> {
@@ -73,8 +73,8 @@ export function useListState<T extends object>(props: ListProps<T>): ListState<T
73
73
  /**
74
74
  * Filters a collection using the provided filter function and returns a new ListState.
75
75
  */
76
- export function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filter: ((nodeValue: string) => boolean) | null | undefined): ListState<T> {
77
- let collection = useMemo(() => filter ? state.collection.UNSTABLE_filter!(filter) : state.collection, [state.collection, filter]);
76
+ export function UNSTABLE_useFilteredListState<T extends object>(state: ListState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): ListState<T> {
77
+ let collection = useMemo(() => filterFn ? state.collection.filter!(filterFn) : state.collection, [state.collection, filterFn]);
78
78
  let selectionManager = state.selectionManager.withCollection(collection);
79
79
  useFocusedKeyReset(collection, selectionManager);
80
80
  return {