@react-stately/list 3.4.2-nightly.3100 → 3.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
- var $aJ74T$react = require("react");
2
- var $aJ74T$reactstatelyselection = require("@react-stately/selection");
3
- var $aJ74T$reactstatelycollections = require("@react-stately/collections");
4
- var $aJ74T$reactstatelyutils = require("@react-stately/utils");
1
+ var $dX2VC$react = require("react");
2
+ var $dX2VC$reactstatelyselection = require("@react-stately/selection");
3
+ var $dX2VC$reactstatelycollections = require("@react-stately/collections");
4
+ var $dX2VC$reactstatelyutils = require("@react-stately/utils");
5
5
 
6
6
  function $parcel$exportWildcard(dest, source) {
7
7
  Object.keys(source).forEach(function(key) {
@@ -22,41 +22,16 @@ function $parcel$exportWildcard(dest, source) {
22
22
  function $parcel$export(e, n, v, s) {
23
23
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
24
24
  }
25
- var $72e18dacc1c2def6$exports = {};
25
+ var $bc93d2fc549b8670$exports = {};
26
26
 
27
- $parcel$export($72e18dacc1c2def6$exports, "useListState", () => $72e18dacc1c2def6$export$2f645645f7bca764);
27
+ $parcel$export($bc93d2fc549b8670$exports, "useListState", () => $bc93d2fc549b8670$export$2f645645f7bca764);
28
28
 
29
- var $581648861f39f723$exports = {};
29
+ var $e57e1b595464cc8b$exports = {};
30
30
 
31
- $parcel$export($581648861f39f723$exports, "ListCollection", () => $581648861f39f723$export$d085fb9e920b5ca7);
32
- class $581648861f39f723$export$d085fb9e920b5ca7 {
33
- constructor(nodes){
34
- this.keyMap = new Map();
35
- this.iterable = nodes;
36
- let visit = (node)=>{
37
- this.keyMap.set(node.key, node);
38
- if (node.childNodes && node.type === 'section') for (let child of node.childNodes)visit(child);
39
- };
40
- for (let node2 of nodes)visit(node2);
41
- let last;
42
- let index = 0;
43
- for (let [key, node1] of this.keyMap){
44
- if (last) {
45
- last.nextKey = key;
46
- node1.prevKey = last.key;
47
- } else {
48
- this.firstKey = key;
49
- node1.prevKey = undefined;
50
- }
51
- if (node1.type === 'item') node1.index = index++;
52
- last = node1;
53
- // Set nextKey as undefined since this might be the last node
54
- // If it isn't the last node, last.nextKey will properly set at start of new loop
55
- last.nextKey = undefined;
56
- }
57
- this.lastKey = last?.key;
58
- }
59
- *[Symbol.iterator]() {
31
+ $parcel$export($e57e1b595464cc8b$exports, "ListCollection", () => $e57e1b595464cc8b$export$d085fb9e920b5ca7);
32
+ var tmp = Symbol.iterator;
33
+ class $e57e1b595464cc8b$export$d085fb9e920b5ca7 {
34
+ *[tmp]() {
60
35
  yield* this.iterable;
61
36
  }
62
37
  get size() {
@@ -88,31 +63,57 @@ class $581648861f39f723$export$d085fb9e920b5ca7 {
88
63
  ];
89
64
  return this.getItem(keys[idx]);
90
65
  }
66
+ constructor(nodes){
67
+ this.keyMap = new Map();
68
+ this.iterable = nodes;
69
+ let visit = (node)=>{
70
+ this.keyMap.set(node.key, node);
71
+ if (node.childNodes && node.type === 'section') for (let child of node.childNodes)visit(child);
72
+ };
73
+ for (let node2 of nodes)visit(node2);
74
+ let last;
75
+ let index = 0;
76
+ for (let [key, node1] of this.keyMap){
77
+ if (last) {
78
+ last.nextKey = key;
79
+ node1.prevKey = last.key;
80
+ } else {
81
+ this.firstKey = key;
82
+ node1.prevKey = undefined;
83
+ }
84
+ if (node1.type === 'item') node1.index = index++;
85
+ last = node1;
86
+ // Set nextKey as undefined since this might be the last node
87
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
88
+ last.nextKey = undefined;
89
+ }
90
+ this.lastKey = last === null || last === void 0 ? void 0 : last.key;
91
+ }
91
92
  }
92
93
 
93
94
 
94
95
 
95
96
 
96
- function $72e18dacc1c2def6$export$2f645645f7bca764(props) {
97
+ function $bc93d2fc549b8670$export$2f645645f7bca764(props) {
97
98
  let { filter: filter } = props;
98
- let selectionState = $aJ74T$reactstatelyselection.useMultipleSelectionState(props);
99
- let disabledKeys = $aJ74T$react.useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
99
+ let selectionState = $dX2VC$reactstatelyselection.useMultipleSelectionState(props);
100
+ let disabledKeys = $dX2VC$react.useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
100
101
  , [
101
102
  props.disabledKeys
102
103
  ]);
103
- let factory = (nodes)=>filter ? new $581648861f39f723$export$d085fb9e920b5ca7(filter(nodes)) : new $581648861f39f723$export$d085fb9e920b5ca7(nodes)
104
+ let factory = (nodes)=>filter ? new $e57e1b595464cc8b$export$d085fb9e920b5ca7(filter(nodes)) : new $e57e1b595464cc8b$export$d085fb9e920b5ca7(nodes)
104
105
  ;
105
- let context = $aJ74T$react.useMemo(()=>({
106
+ let context = $dX2VC$react.useMemo(()=>({
106
107
  suppressTextValueWarning: props.suppressTextValueWarning
107
108
  })
108
109
  , [
109
110
  props.suppressTextValueWarning
110
111
  ]);
111
- let collection = $aJ74T$reactstatelycollections.useCollection(props, factory, context, [
112
+ let collection = $dX2VC$reactstatelycollections.useCollection(props, factory, context, [
112
113
  filter
113
114
  ]);
114
115
  // Reset focused key if that item is deleted from the collection.
115
- $aJ74T$react.useEffect(()=>{
116
+ $dX2VC$react.useEffect(()=>{
116
117
  if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) selectionState.setFocusedKey(null);
117
118
  }, [
118
119
  collection,
@@ -121,26 +122,27 @@ function $72e18dacc1c2def6$export$2f645645f7bca764(props) {
121
122
  return {
122
123
  collection: collection,
123
124
  disabledKeys: disabledKeys,
124
- selectionManager: new $aJ74T$reactstatelyselection.SelectionManager(collection, selectionState)
125
+ selectionManager: new $dX2VC$reactstatelyselection.SelectionManager(collection, selectionState)
125
126
  };
126
127
  }
127
128
 
128
129
 
129
- var $bb463ca54c041eac$exports = {};
130
+ var $6a9c04de034f6349$exports = {};
130
131
 
131
- $parcel$export($bb463ca54c041eac$exports, "useSingleSelectListState", () => $bb463ca54c041eac$export$e7f05e985daf4b5f);
132
+ $parcel$export($6a9c04de034f6349$exports, "useSingleSelectListState", () => $6a9c04de034f6349$export$e7f05e985daf4b5f);
132
133
 
133
134
 
134
135
 
135
- function $bb463ca54c041eac$export$e7f05e985daf4b5f(props) {
136
- let [selectedKey, setSelectedKey] = $aJ74T$reactstatelyutils.useControlledState(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);
137
- let selectedKeys = $aJ74T$react.useMemo(()=>selectedKey != null ? [
136
+ function $6a9c04de034f6349$export$e7f05e985daf4b5f(props) {
137
+ var _defaultSelectedKey;
138
+ let [selectedKey, setSelectedKey] = $dX2VC$reactstatelyutils.useControlledState(props.selectedKey, (_defaultSelectedKey = props.defaultSelectedKey) !== null && _defaultSelectedKey !== void 0 ? _defaultSelectedKey : null, props.onSelectionChange);
139
+ let selectedKeys = $dX2VC$react.useMemo(()=>selectedKey != null ? [
138
140
  selectedKey
139
141
  ] : []
140
142
  , [
141
143
  selectedKey
142
144
  ]);
143
- let { collection: collection , disabledKeys: disabledKeys , selectionManager: selectionManager } = $72e18dacc1c2def6$export$2f645645f7bca764({
145
+ let { collection: collection , disabledKeys: disabledKeys , selectionManager: selectionManager } = $bc93d2fc549b8670$export$2f645645f7bca764({
144
146
  ...props,
145
147
  selectionMode: 'single',
146
148
  disallowEmptySelection: true,
@@ -167,9 +169,9 @@ function $bb463ca54c041eac$export$e7f05e985daf4b5f(props) {
167
169
 
168
170
 
169
171
 
170
- $parcel$exportWildcard(module.exports, $72e18dacc1c2def6$exports);
171
- $parcel$exportWildcard(module.exports, $bb463ca54c041eac$exports);
172
- $parcel$exportWildcard(module.exports, $581648861f39f723$exports);
172
+ $parcel$exportWildcard(module.exports, $bc93d2fc549b8670$exports);
173
+ $parcel$exportWildcard(module.exports, $6a9c04de034f6349$exports);
174
+ $parcel$exportWildcard(module.exports, $e57e1b595464cc8b$exports);
173
175
 
174
176
 
175
177
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +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AAA,WAAW;IAAA,CAAC;IACxF,GAAG,CAAC,CAAC,aAAA,UAAU,iBAAE,YAAY,qBAAE,gBAAgB,EAAA,CAAC,GAAG,yCAAY,CAAC,CAAC;WAC5D,KAAK;QACR,aAAa,EAAE,CAAQ;QACvB,sBAAsB,EAAE,IAAI;QAC5B,6BAA6B,EAAE,IAAI;sBACnC,YAAY;QACZ,iBAAiB,GAAG,IAAc,GAAK,CAAC;YACtC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,KAAK;YAEpC,EAA6D,AAA7D,2DAA6D;YAC7D,EAAoD,AAApD,kDAAoD;YACpD,EAAE,EAAE,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,iBAAiB,EAChD,KAAK,CAAC,iBAAiB,CAAC,GAAG;YAG7B,cAAc,CAAC,GAAG;QACpB,CAAC;IACH,CAAC;IAED,GAAG,CAAC,YAAY,GAAG,WAAW,IAAI,IAAI,GAClC,UAAU,CAAC,OAAO,CAAC,WAAW,IAC9B,IAAI;IAER,MAAM,CAAC,CAAC;oBACN,UAAU;sBACV,YAAY;0BACZ,gBAAgB;qBAChB,WAAW;wBACX,cAAc;sBACd,YAAY;IACd,CAAC;AACH,CAAC;;","sources":["packages/@react-stately/list/src/index.ts","packages/@react-stately/list/src/useListState.ts","packages/@react-stately/list/src/ListCollection.ts","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\nexport * from './useListState';\nexport * from './useSingleSelectListState';\nexport * from './ListCollection';\n","/*\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, CollectionBase, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionBase<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 = nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context, [filter]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [collection, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager: new SelectionManager(collection, selectionState)\n };\n}\n","/*\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, Node} from '@react-types/shared';\nimport {Key} from 'react';\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","/*\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 {CollectionBase, SingleSelection} from '@react-types/shared';\nimport {Key, useMemo} from 'react';\nimport {ListState, useListState} from './useListState';\nimport {Node} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface SingleSelectListProps<T> extends CollectionBase<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): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T>\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;\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":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UE+DI,MAAM,CAAC,QAAQ;MAhDN,yCAAc;aAgDJ,CAAC;eACb,IAAI,CAAC,QAAQ;IACtB,CAAC;QAEG,IAAI,GAAG,CAAC;QACV,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;QACT,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,YAAY,CAAC,GAAQ,EAAE,CAAC;QACtB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;QAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI;IACnC,CAAC;IAED,WAAW,CAAC,GAAQ,EAAE,CAAC;QACrB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;QAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI;IACnC,CAAC;IAED,WAAW,GAAG,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,QAAQ;IACtB,CAAC;IAED,UAAU,GAAG,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,OAAO;IACrB,CAAC;IAED,OAAO,CAAC,GAAQ,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;IAC5B,CAAC;IAED,EAAE,CAAC,GAAW,EAAE,CA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src/useListState.ts","packages/@react-stately/list/src/ListCollection.ts","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\nexport * from './useListState';\nexport * from './useSingleSelectListState';\nexport * from './ListCollection';\n","/*\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, CollectionBase, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionBase<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 = nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context, [filter]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [collection, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager: new SelectionManager(collection, selectionState)\n };\n}\n","/*\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, Node} from '@react-types/shared';\nimport {Key} from 'react';\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","/*\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 {CollectionBase, SingleSelection} from '@react-types/shared';\nimport {Key, useMemo} from 'react';\nimport {ListState, useListState} from './useListState';\nimport {Node} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface SingleSelectListProps<T> extends CollectionBase<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): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T>\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;\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":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,46 +1,21 @@
1
- import {useMemo as $2vUeM$useMemo, useEffect as $2vUeM$useEffect} from "react";
2
- import {useMultipleSelectionState as $2vUeM$useMultipleSelectionState, SelectionManager as $2vUeM$SelectionManager} from "@react-stately/selection";
3
- import {useCollection as $2vUeM$useCollection} from "@react-stately/collections";
4
- import {useControlledState as $2vUeM$useControlledState} from "@react-stately/utils";
1
+ import {useMemo as $jmOdw$useMemo, useEffect as $jmOdw$useEffect} from "react";
2
+ import {useMultipleSelectionState as $jmOdw$useMultipleSelectionState, SelectionManager as $jmOdw$SelectionManager} from "@react-stately/selection";
3
+ import {useCollection as $jmOdw$useCollection} from "@react-stately/collections";
4
+ import {useControlledState as $jmOdw$useControlledState} from "@react-stately/utils";
5
5
 
6
6
  function $parcel$export(e, n, v, s) {
7
7
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
8
  }
9
- var $22ee28165633d781$exports = {};
9
+ var $4b9a49966c91856a$exports = {};
10
10
 
11
- $parcel$export($22ee28165633d781$exports, "useListState", () => $22ee28165633d781$export$2f645645f7bca764);
11
+ $parcel$export($4b9a49966c91856a$exports, "useListState", () => $4b9a49966c91856a$export$2f645645f7bca764);
12
12
 
13
- var $8b1d221864d202f1$exports = {};
13
+ var $80be09205507c5ec$exports = {};
14
14
 
15
- $parcel$export($8b1d221864d202f1$exports, "ListCollection", () => $8b1d221864d202f1$export$d085fb9e920b5ca7);
16
- class $8b1d221864d202f1$export$d085fb9e920b5ca7 {
17
- constructor(nodes){
18
- this.keyMap = new Map();
19
- this.iterable = nodes;
20
- let visit = (node)=>{
21
- this.keyMap.set(node.key, node);
22
- if (node.childNodes && node.type === 'section') for (let child of node.childNodes)visit(child);
23
- };
24
- for (let node2 of nodes)visit(node2);
25
- let last;
26
- let index = 0;
27
- for (let [key, node1] of this.keyMap){
28
- if (last) {
29
- last.nextKey = key;
30
- node1.prevKey = last.key;
31
- } else {
32
- this.firstKey = key;
33
- node1.prevKey = undefined;
34
- }
35
- if (node1.type === 'item') node1.index = index++;
36
- last = node1;
37
- // Set nextKey as undefined since this might be the last node
38
- // If it isn't the last node, last.nextKey will properly set at start of new loop
39
- last.nextKey = undefined;
40
- }
41
- this.lastKey = last?.key;
42
- }
43
- *[Symbol.iterator]() {
15
+ $parcel$export($80be09205507c5ec$exports, "ListCollection", () => $80be09205507c5ec$export$d085fb9e920b5ca7);
16
+ var tmp = Symbol.iterator;
17
+ class $80be09205507c5ec$export$d085fb9e920b5ca7 {
18
+ *[tmp]() {
44
19
  yield* this.iterable;
45
20
  }
46
21
  get size() {
@@ -72,31 +47,57 @@ class $8b1d221864d202f1$export$d085fb9e920b5ca7 {
72
47
  ];
73
48
  return this.getItem(keys[idx]);
74
49
  }
50
+ constructor(nodes){
51
+ this.keyMap = new Map();
52
+ this.iterable = nodes;
53
+ let visit = (node)=>{
54
+ this.keyMap.set(node.key, node);
55
+ if (node.childNodes && node.type === 'section') for (let child of node.childNodes)visit(child);
56
+ };
57
+ for (let node2 of nodes)visit(node2);
58
+ let last;
59
+ let index = 0;
60
+ for (let [key, node1] of this.keyMap){
61
+ if (last) {
62
+ last.nextKey = key;
63
+ node1.prevKey = last.key;
64
+ } else {
65
+ this.firstKey = key;
66
+ node1.prevKey = undefined;
67
+ }
68
+ if (node1.type === 'item') node1.index = index++;
69
+ last = node1;
70
+ // Set nextKey as undefined since this might be the last node
71
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
72
+ last.nextKey = undefined;
73
+ }
74
+ this.lastKey = last === null || last === void 0 ? void 0 : last.key;
75
+ }
75
76
  }
76
77
 
77
78
 
78
79
 
79
80
 
80
- function $22ee28165633d781$export$2f645645f7bca764(props) {
81
+ function $4b9a49966c91856a$export$2f645645f7bca764(props) {
81
82
  let { filter: filter } = props;
82
- let selectionState = $2vUeM$useMultipleSelectionState(props);
83
- let disabledKeys = $2vUeM$useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
83
+ let selectionState = $jmOdw$useMultipleSelectionState(props);
84
+ let disabledKeys = $jmOdw$useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
84
85
  , [
85
86
  props.disabledKeys
86
87
  ]);
87
- let factory = (nodes)=>filter ? new $8b1d221864d202f1$export$d085fb9e920b5ca7(filter(nodes)) : new $8b1d221864d202f1$export$d085fb9e920b5ca7(nodes)
88
+ let factory = (nodes)=>filter ? new $80be09205507c5ec$export$d085fb9e920b5ca7(filter(nodes)) : new $80be09205507c5ec$export$d085fb9e920b5ca7(nodes)
88
89
  ;
89
- let context = $2vUeM$useMemo(()=>({
90
+ let context = $jmOdw$useMemo(()=>({
90
91
  suppressTextValueWarning: props.suppressTextValueWarning
91
92
  })
92
93
  , [
93
94
  props.suppressTextValueWarning
94
95
  ]);
95
- let collection = $2vUeM$useCollection(props, factory, context, [
96
+ let collection = $jmOdw$useCollection(props, factory, context, [
96
97
  filter
97
98
  ]);
98
99
  // Reset focused key if that item is deleted from the collection.
99
- $2vUeM$useEffect(()=>{
100
+ $jmOdw$useEffect(()=>{
100
101
  if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) selectionState.setFocusedKey(null);
101
102
  }, [
102
103
  collection,
@@ -105,26 +106,27 @@ function $22ee28165633d781$export$2f645645f7bca764(props) {
105
106
  return {
106
107
  collection: collection,
107
108
  disabledKeys: disabledKeys,
108
- selectionManager: new $2vUeM$SelectionManager(collection, selectionState)
109
+ selectionManager: new $jmOdw$SelectionManager(collection, selectionState)
109
110
  };
110
111
  }
111
112
 
112
113
 
113
- var $81c60a02219e0c72$exports = {};
114
+ var $e08e0e9da1306088$exports = {};
114
115
 
115
- $parcel$export($81c60a02219e0c72$exports, "useSingleSelectListState", () => $81c60a02219e0c72$export$e7f05e985daf4b5f);
116
+ $parcel$export($e08e0e9da1306088$exports, "useSingleSelectListState", () => $e08e0e9da1306088$export$e7f05e985daf4b5f);
116
117
 
117
118
 
118
119
 
119
- function $81c60a02219e0c72$export$e7f05e985daf4b5f(props) {
120
- let [selectedKey, setSelectedKey] = $2vUeM$useControlledState(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);
121
- let selectedKeys = $2vUeM$useMemo(()=>selectedKey != null ? [
120
+ function $e08e0e9da1306088$export$e7f05e985daf4b5f(props) {
121
+ var _defaultSelectedKey;
122
+ let [selectedKey, setSelectedKey] = $jmOdw$useControlledState(props.selectedKey, (_defaultSelectedKey = props.defaultSelectedKey) !== null && _defaultSelectedKey !== void 0 ? _defaultSelectedKey : null, props.onSelectionChange);
123
+ let selectedKeys = $jmOdw$useMemo(()=>selectedKey != null ? [
122
124
  selectedKey
123
125
  ] : []
124
126
  , [
125
127
  selectedKey
126
128
  ]);
127
- let { collection: collection , disabledKeys: disabledKeys , selectionManager: selectionManager } = $22ee28165633d781$export$2f645645f7bca764({
129
+ let { collection: collection , disabledKeys: disabledKeys , selectionManager: selectionManager } = $4b9a49966c91856a$export$2f645645f7bca764({
128
130
  ...props,
129
131
  selectionMode: 'single',
130
132
  disallowEmptySelection: true,
@@ -153,5 +155,5 @@ function $81c60a02219e0c72$export$e7f05e985daf4b5f(props) {
153
155
 
154
156
 
155
157
 
156
- export {$22ee28165633d781$export$2f645645f7bca764 as useListState, $81c60a02219e0c72$export$e7f05e985daf4b5f as useSingleSelectListState, $8b1d221864d202f1$export$d085fb9e920b5ca7 as ListCollection};
158
+ export {$4b9a49966c91856a$export$2f645645f7bca764 as useListState, $e08e0e9da1306088$export$e7f05e985daf4b5f as useSingleSelectListState, $80be09205507c5ec$export$d085fb9e920b5ca7 as ListCollection};
157
159
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;MEea,yCAAc;gBAMb,KAAwB,CAAE,CAAC;QANlC,IAsFN,CArFS,MAAM,GAAsB,GAAG,CAAC,GAAG;QAMzC,IAAI,CAAC,QAAQ,GAAG,KAAK;QAErB,GAAG,CAAC,KAAK,IAAI,IAAa,GAAK,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI;YAE9B,EAAE,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,CAAS,UAC5C,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAC/B,KAAK,CAAC,KAAK;QAGjB,CAAC;QAED,GAAG,EAAE,GAAG,CAAC,KAAI,IAAI,KAAK,CACpB,KAAK,CAAC,KAAI;QAGZ,GAAG,CAAC,IAAI;QACR,GAAG,CAAC,KAAK,GAAG,CAAC;QACb,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAI,KAAK,IAAI,CAAC,MAAM,CAAE,CAAC;YACpC,EAAE,EAAE,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC,OAAO,GAAG,GAAG;gBAClB,KA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/@react-stately/list/src/index.ts","packages/@react-stately/list/src/useListState.ts","packages/@react-stately/list/src/ListCollection.ts","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\nexport * from './useListState';\nexport * from './useSingleSelectListState';\nexport * from './ListCollection';\n","/*\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, CollectionBase, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionBase<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 = nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context, [filter]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [collection, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager: new SelectionManager(collection, selectionState)\n };\n}\n","/*\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, Node} from '@react-types/shared';\nimport {Key} from 'react';\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","/*\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 {CollectionBase, SingleSelection} from '@react-types/shared';\nimport {Key, useMemo} from 'react';\nimport {ListState, useListState} from './useListState';\nimport {Node} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface SingleSelectListProps<T> extends CollectionBase<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): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T>\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;\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":"module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;UE+DI,MAAM,CAAC,QAAQ;MAhDN,yCAAc;aAgDJ,CAAC;eACb,IAAI,CAAC,QAAQ;IACtB,CAAC;QAEG,IAAI,GAAG,CAAC;QACV,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;QACT,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;IACzB,CAAC;IAED,YAAY,CAAC,GAAQ,EAAE,CAAC;QACtB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;QAC9B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI;IACnC,CAAC;IAED,WAAW,CAAC,GAAQ,EAA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D,EAAoD,AAApD,kDAAoD;YACpD,EAAE,EAAE,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,iBAAiB,EAChD,KAAK,CAAC,iBAAiB,CAAC,GAAG;YAG7B,cAAc,CAAC,GAAG;QACpB,CAAC;IACH,CAAC;IAED,GAAG,CAAC,YAAY,GAAG,WAAW,IAAI,IAAI,GAClC,UAAU,CAAC,OAAO,CAAC,WAAW,IAC9B,IAAI;IAER,MAAM,CAAC,CAAC;oBACN,UAAU;sBACV,YAAY;0BACZ,gBAAgB;qBAChB,WAAW;wBACX,cAAc;sBACd,YAAY;IACd,CAAC;AACH,CAAC;;","sources":["packages/@react-stately/list/src/index.ts","packages/@react-stately/list/src/useListState.ts","packages/@react-stately/list/src/ListCollection.ts","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\nexport * from './useListState';\nexport * from './useSingleSelectListState';\nexport * from './ListCollection';\n","/*\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, CollectionBase, Node} from '@react-types/shared';\nimport {Key, useEffect, useMemo} from 'react';\nimport {ListCollection} from './ListCollection';\nimport {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface ListProps<T> extends CollectionBase<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 = nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes as Iterable<Node<T>>);\n let context = useMemo(() => ({suppressTextValueWarning: props.suppressTextValueWarning}), [props.suppressTextValueWarning]);\n\n let collection = useCollection(props, factory, context, [filter]);\n\n // Reset focused key if that item is deleted from the collection.\n useEffect(() => {\n if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {\n selectionState.setFocusedKey(null);\n }\n }, [collection, selectionState.focusedKey]);\n\n return {\n collection,\n disabledKeys,\n selectionManager: new SelectionManager(collection, selectionState)\n };\n}\n","/*\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, Node} from '@react-types/shared';\nimport {Key} from 'react';\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","/*\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 {CollectionBase, SingleSelection} from '@react-types/shared';\nimport {Key, useMemo} from 'react';\nimport {ListState, useListState} from './useListState';\nimport {Node} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface SingleSelectListProps<T> extends CollectionBase<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): void,\n\n /** The value of the currently selected item. */\n readonly selectedItem: Node<T>\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;\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":"module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/list",
3
- "version": "3.4.2-nightly.3100+da2aa7467",
3
+ "version": "3.4.3",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,10 +18,10 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/collections": "3.0.0-nightly.1409+da2aa7467",
22
- "@react-stately/selection": "3.0.0-nightly.1409+da2aa7467",
23
- "@react-stately/utils": "3.0.0-nightly.1409+da2aa7467",
24
- "@react-types/shared": "3.0.0-nightly.1409+da2aa7467"
21
+ "@react-stately/collections": "^3.3.6",
22
+ "@react-stately/selection": "^3.9.2",
23
+ "@react-stately/utils": "^3.4.1",
24
+ "@react-types/shared": "^3.11.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -29,5 +29,5 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "da2aa74670fbd93335ff01401ca53826b3602777"
32
+ "gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
33
33
  }