@react-stately/selection 3.9.1 → 3.9.4
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 +45 -44
- package/dist/main.js.map +1 -1
- package/dist/module.js +43 -42
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
1
|
+
var $83d9f$react = require("react");
|
|
2
|
+
var $83d9f$reactstatelyutils = require("@react-stately/utils");
|
|
3
3
|
|
|
4
4
|
function $parcel$exportWildcard(dest, source) {
|
|
5
5
|
Object.keys(source).forEach(function(key) {
|
|
@@ -20,14 +20,14 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
20
20
|
function $parcel$export(e, n, v, s) {
|
|
21
21
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
22
22
|
}
|
|
23
|
-
var $
|
|
23
|
+
var $1adc19da2128bba9$exports = {};
|
|
24
24
|
|
|
25
|
-
$parcel$export($
|
|
25
|
+
$parcel$export($1adc19da2128bba9$exports, "useMultipleSelectionState", () => $1adc19da2128bba9$export$253fe78d46329472);
|
|
26
26
|
|
|
27
|
-
class $
|
|
27
|
+
class $21c847070f1f9569$export$52baac22726c72bf extends Set {
|
|
28
28
|
constructor(keys, anchorKey, currentKey){
|
|
29
29
|
super(keys);
|
|
30
|
-
if (keys instanceof $
|
|
30
|
+
if (keys instanceof $21c847070f1f9569$export$52baac22726c72bf) {
|
|
31
31
|
this.anchorKey = anchorKey || keys.anchorKey;
|
|
32
32
|
this.currentKey = currentKey || keys.currentKey;
|
|
33
33
|
} else {
|
|
@@ -39,36 +39,36 @@ class $addbfdd9bcbd561f$export$52baac22726c72bf extends Set {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
function $
|
|
42
|
+
function $1adc19da2128bba9$var$equalSets(setA, setB) {
|
|
43
43
|
if (setA.size !== setB.size) return false;
|
|
44
44
|
for (let item of setA){
|
|
45
45
|
if (!setB.has(item)) return false;
|
|
46
46
|
}
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
|
-
function $
|
|
49
|
+
function $1adc19da2128bba9$export$253fe78d46329472(props) {
|
|
50
50
|
let { selectionMode: selectionMode = 'none' , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents } = props;
|
|
51
51
|
// We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
|
|
52
52
|
// But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
|
|
53
|
-
let isFocusedRef = $
|
|
54
|
-
let [, setFocused] = $
|
|
55
|
-
let focusedKeyRef = $
|
|
56
|
-
let childFocusStrategyRef = $
|
|
57
|
-
let [, setFocusedKey] = $
|
|
58
|
-
let selectedKeysProp = $
|
|
53
|
+
let isFocusedRef = $83d9f$react.useRef(false);
|
|
54
|
+
let [, setFocused] = $83d9f$react.useState(false);
|
|
55
|
+
let focusedKeyRef = $83d9f$react.useRef(null);
|
|
56
|
+
let childFocusStrategyRef = $83d9f$react.useRef(null);
|
|
57
|
+
let [, setFocusedKey] = $83d9f$react.useState(null);
|
|
58
|
+
let selectedKeysProp = $83d9f$react.useMemo(()=>$1adc19da2128bba9$var$convertSelection(props.selectedKeys)
|
|
59
59
|
, [
|
|
60
60
|
props.selectedKeys
|
|
61
61
|
]);
|
|
62
|
-
let defaultSelectedKeys = $
|
|
62
|
+
let defaultSelectedKeys = $83d9f$react.useMemo(()=>$1adc19da2128bba9$var$convertSelection(props.defaultSelectedKeys, new $21c847070f1f9569$export$52baac22726c72bf())
|
|
63
63
|
, [
|
|
64
64
|
props.defaultSelectedKeys
|
|
65
65
|
]);
|
|
66
|
-
let [selectedKeys, setSelectedKeys] = $
|
|
67
|
-
let disabledKeysProp = $
|
|
66
|
+
let [selectedKeys, setSelectedKeys] = $83d9f$reactstatelyutils.useControlledState(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
|
|
67
|
+
let disabledKeysProp = $83d9f$react.useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
|
|
68
68
|
, [
|
|
69
69
|
props.disabledKeys
|
|
70
70
|
]);
|
|
71
|
-
let [selectionBehavior, setSelectionBehavior] = $
|
|
71
|
+
let [selectionBehavior, setSelectionBehavior] = $83d9f$react.useState(props.selectionBehavior || 'toggle');
|
|
72
72
|
// If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press
|
|
73
73
|
// to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.
|
|
74
74
|
if (props.selectionBehavior === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) setSelectionBehavior('replace');
|
|
@@ -97,28 +97,22 @@ function $859207c6286de3c2$export$253fe78d46329472(props) {
|
|
|
97
97
|
},
|
|
98
98
|
selectedKeys: selectedKeys,
|
|
99
99
|
setSelectedKeys (keys) {
|
|
100
|
-
if (allowDuplicateSelectionEvents || !$
|
|
100
|
+
if (allowDuplicateSelectionEvents || !$1adc19da2128bba9$var$equalSets(keys, selectedKeys)) setSelectedKeys(keys);
|
|
101
101
|
},
|
|
102
102
|
disabledKeys: disabledKeysProp
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
function $
|
|
105
|
+
function $1adc19da2128bba9$var$convertSelection(selection, defaultValue) {
|
|
106
106
|
if (!selection) return defaultValue;
|
|
107
|
-
return selection === 'all' ? 'all' : new $
|
|
107
|
+
return selection === 'all' ? 'all' : new $21c847070f1f9569$export$52baac22726c72bf(selection);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
var $
|
|
111
|
+
var $8112da6fa5bbc322$exports = {};
|
|
112
112
|
|
|
113
|
-
$parcel$export($
|
|
113
|
+
$parcel$export($8112da6fa5bbc322$exports, "SelectionManager", () => $8112da6fa5bbc322$export$6c8a5aaad13c9852);
|
|
114
114
|
|
|
115
|
-
class $
|
|
116
|
-
constructor(collection, state, options){
|
|
117
|
-
this.collection = collection;
|
|
118
|
-
this.state = state;
|
|
119
|
-
this.allowsCellSelection = options?.allowsCellSelection ?? false;
|
|
120
|
-
this._isSelectAll = null;
|
|
121
|
-
}
|
|
115
|
+
class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
|
|
122
116
|
/**
|
|
123
117
|
* The type of selection that is allowed in the collection.
|
|
124
118
|
*/ get selectionMode() {
|
|
@@ -201,17 +195,17 @@ class $e4d0ec10a0dae1aa$export$6c8a5aaad13c9852 {
|
|
|
201
195
|
let first = null;
|
|
202
196
|
for (let key of this.state.selectedKeys){
|
|
203
197
|
let item = this.collection.getItem(key);
|
|
204
|
-
if (!first || item
|
|
198
|
+
if (!first || (item === null || item === void 0 ? void 0 : item.index) < first.index) first = item;
|
|
205
199
|
}
|
|
206
|
-
return first
|
|
200
|
+
return first === null || first === void 0 ? void 0 : first.key;
|
|
207
201
|
}
|
|
208
202
|
get lastSelectedKey() {
|
|
209
203
|
let last = null;
|
|
210
204
|
for (let key of this.state.selectedKeys){
|
|
211
205
|
let item = this.collection.getItem(key);
|
|
212
|
-
if (!last || item
|
|
206
|
+
if (!last || (item === null || item === void 0 ? void 0 : item.index) > last.index) last = item;
|
|
213
207
|
}
|
|
214
|
-
return last
|
|
208
|
+
return last === null || last === void 0 ? void 0 : last.key;
|
|
215
209
|
}
|
|
216
210
|
/**
|
|
217
211
|
* Extends the selection to the given key.
|
|
@@ -224,13 +218,13 @@ class $e4d0ec10a0dae1aa$export$6c8a5aaad13c9852 {
|
|
|
224
218
|
toKey = this.getKey(toKey);
|
|
225
219
|
let selection;
|
|
226
220
|
// Only select the one key if coming from a select all.
|
|
227
|
-
if (this.state.selectedKeys === 'all') selection = new $
|
|
221
|
+
if (this.state.selectedKeys === 'all') selection = new $21c847070f1f9569$export$52baac22726c72bf([
|
|
228
222
|
toKey
|
|
229
223
|
], toKey, toKey);
|
|
230
224
|
else {
|
|
231
225
|
let selectedKeys = this.state.selectedKeys;
|
|
232
226
|
let anchorKey = selectedKeys.anchorKey || toKey;
|
|
233
|
-
selection = new $
|
|
227
|
+
selection = new $21c847070f1f9569$export$52baac22726c72bf(selectedKeys, anchorKey, toKey);
|
|
234
228
|
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey))selection.delete(key);
|
|
235
229
|
for (let key1 of this.getKeyRange(toKey, anchorKey))if (!this.state.disabledKeys.has(key1)) selection.add(key1);
|
|
236
230
|
}
|
|
@@ -277,7 +271,7 @@ class $e4d0ec10a0dae1aa$export$6c8a5aaad13c9852 {
|
|
|
277
271
|
}
|
|
278
272
|
key = this.getKey(key);
|
|
279
273
|
if (key == null) return;
|
|
280
|
-
let keys = new $
|
|
274
|
+
let keys = new $21c847070f1f9569$export$52baac22726c72bf(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
|
|
281
275
|
if (keys.has(key)) keys.delete(key);
|
|
282
276
|
else {
|
|
283
277
|
keys.add(key);
|
|
@@ -293,7 +287,7 @@ class $e4d0ec10a0dae1aa$export$6c8a5aaad13c9852 {
|
|
|
293
287
|
if (this.selectionMode === 'none') return;
|
|
294
288
|
key = this.getKey(key);
|
|
295
289
|
if (key == null) return;
|
|
296
|
-
this.state.setSelectedKeys(new $
|
|
290
|
+
this.state.setSelectedKeys(new $21c847070f1f9569$export$52baac22726c72bf([
|
|
297
291
|
key
|
|
298
292
|
], key, key));
|
|
299
293
|
}
|
|
@@ -301,7 +295,7 @@ class $e4d0ec10a0dae1aa$export$6c8a5aaad13c9852 {
|
|
|
301
295
|
* Replaces the selection with the given keys.
|
|
302
296
|
*/ setSelectedKeys(keys) {
|
|
303
297
|
if (this.selectionMode === 'none') return;
|
|
304
|
-
let selection = new $
|
|
298
|
+
let selection = new $21c847070f1f9569$export$52baac22726c72bf();
|
|
305
299
|
for (let key of keys){
|
|
306
300
|
key = this.getKey(key);
|
|
307
301
|
if (key != null) {
|
|
@@ -337,7 +331,7 @@ class $e4d0ec10a0dae1aa$export$6c8a5aaad13c9852 {
|
|
|
337
331
|
/**
|
|
338
332
|
* Removes all keys from the selection.
|
|
339
333
|
*/ clearSelection() {
|
|
340
|
-
if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new $
|
|
334
|
+
if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new $21c847070f1f9569$export$52baac22726c72bf());
|
|
341
335
|
}
|
|
342
336
|
/**
|
|
343
337
|
* Toggles between select all and an empty selection.
|
|
@@ -375,15 +369,22 @@ class $e4d0ec10a0dae1aa$export$6c8a5aaad13c9852 {
|
|
|
375
369
|
if (!item || item.type === 'cell' && !this.allowsCellSelection) return false;
|
|
376
370
|
return true;
|
|
377
371
|
}
|
|
372
|
+
constructor(collection, state, options){
|
|
373
|
+
this.collection = collection;
|
|
374
|
+
this.state = state;
|
|
375
|
+
var ref;
|
|
376
|
+
this.allowsCellSelection = (ref = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && ref !== void 0 ? ref : false;
|
|
377
|
+
this._isSelectAll = null;
|
|
378
|
+
}
|
|
378
379
|
}
|
|
379
380
|
|
|
380
381
|
|
|
381
|
-
var $
|
|
382
|
+
var $85467f818ce6e562$exports = {};
|
|
382
383
|
|
|
383
384
|
|
|
384
|
-
$parcel$exportWildcard(module.exports, $
|
|
385
|
-
$parcel$exportWildcard(module.exports, $
|
|
386
|
-
$parcel$exportWildcard(module.exports, $
|
|
385
|
+
$parcel$exportWildcard(module.exports, $1adc19da2128bba9$exports);
|
|
386
|
+
$parcel$exportWildcard(module.exports, $8112da6fa5bbc322$exports);
|
|
387
|
+
$parcel$exportWildcard(module.exports, $85467f818ce6e562$exports);
|
|
387
388
|
|
|
388
389
|
|
|
389
390
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;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E,EAAE,SAAS,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,EACtC,MAAM,CAAC,KAAK;QAGd,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,SAAS,CAAE,CAAC;YAC1B,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,GACvB,MAAM,CAAC,KAAK;QAEhB,CAAC;QAED,GAAG,EAAE,GAAG,CAAC,IAAG,IAAI,YAAY,CAAE,CAAC;YAC7B,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,IAAG,GACpB,MAAM,CAAC,KAAK;QAEhB,CAAC;QAED,MAAM,CAAC,IAAI;IACb,CAAC;IAED,aAAa,CAAC,GAAQ,EAAE,CAAC;QACvB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,KAAK,CAAM,SAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,GACxE,MAAM,CAAC,KAAK;QAGd,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG;QACtC,EAAE,GAAG,IAAI,IAAK,IAAI,CAAC,IAAI,KAAK,CAAM,UAAK,IAAI,CAAC,mBAAmB,EAC7D,MAAM,CAAC,KAAK;QAGd,MAAM,CAAC,IAAI;IACb,CAAC;;;;;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","packages/@react-stately/selection/src/SelectionManager.ts","packages/@react-stately/selection/src/types.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 './useMultipleSelectionState';\nexport * from './SelectionManager';\nexport * from './types';\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 {Key, useMemo, useRef, useState} from 'react';\nimport {MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(props.selectionBehavior || 'toggle');\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (props.selectionBehavior === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Selection {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\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 {Key} from 'react';\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key;\n currentKey: Key;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key, currentKey?: Key) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey || keys.anchorKey;\n this.currentKey = currentKey || keys.currentKey;\n } else {\n this.anchorKey = anchorKey;\n this.currentKey = currentKey;\n }\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 {\n Collection,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {Key} from 'react';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key, childFocusStrategy?: FocusStrategy) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? !this.state.disabledKeys.has(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || item?.index < first.index) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || item?.index > last.index) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey || toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (!this.state.disabledKeys.has(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (fromItem.index <= toItem.index) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n let keys: Key[] = [];\n let key = from;\n while (key) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n this.state.setSelectedKeys(new Selection([key], key, key));\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key) {\n if (!this.state.disabledKeys.has(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys([...item.childNodes][0].key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\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 {FocusStrategy, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport interface FocusState {\n /** Whether the collection is currently focused. */\n readonly isFocused: boolean,\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void,\n /** The current focused key in the collection. */\n readonly focusedKey: Key,\n /** Whether the first or last child of the focused key should receive focus. */\n readonly childFocusStrategy: FocusStrategy,\n /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */\n setFocusedKey(key: Key, child?: FocusStrategy): void\n}\n\nexport interface SingleSelectionState extends FocusState {\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected key in the collection. */\n readonly selectedKey: Key,\n /** Sets the selected key in the collection. */\n setSelectedKey(key: Key): void\n}\n\nexport interface MultipleSelectionState extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Selection,\n /** Sets the selected keys in the collection. */\n setSelectedKeys(keys: Selection): void,\n /** The currently disabled keys in the collection. */\n readonly disabledKeys: Set<Key>\n}\n\nexport interface MultipleSelectionManager extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Set<Key>,\n /** Whether the selection is empty. */\n readonly isEmpty: boolean,\n /** Whether all items in the collection are selected. */\n readonly isSelectAll: boolean,\n /** The first selected key in the collection. */\n readonly firstSelectedKey: Key | null,\n /** The last selected key in the collection. */\n readonly lastSelectedKey: Key | null,\n /** Returns whether a key is selected. */\n isSelected(key: Key): boolean,\n /** Returns whether the current selection is equal to the given selection. */\n isSelectionEqual(selection: Set<Key>): boolean,\n /** Extends the selection to the given key. */\n extendSelection(toKey: Key): void,\n /** Toggles whether the given key is selected. */\n toggleSelection(key: Key): void,\n /** Replaces the selection with only the given key. */\n replaceSelection(key: Key): void,\n /** Replaces the selection with the given keys. */\n setSelectedKeys(keys: Iterable<Key>): void,\n /** Selects all items in the collection. */\n selectAll(): void,\n /** Removes all keys from the selection. */\n clearSelection(): void,\n /** Toggles between select all and an empty selection. */\n toggleSelectAll(): void,\n /**\n * Toggles, replaces, or extends selection to the given key depending\n * on the pointer event and collection's selection mode.\n */\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent): void,\n /** Returns whether the given key can be selected. */\n canSelectItem(key: Key): boolean,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;MEkBa,yCAAS,SAAS,GAAG;gBAIpB,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE,CAAC;QAChF,KAAK,CAAC,IAAI;QACV,EAAE,EAAE,IAAI,YAAY,yCAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,SAAS;YAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,IAAI,CAAC,UAAU;QACjD,CAAC,MAAM,CAAC;YACN,I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,YAAY,CAAE,CAAC;YAC7B,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,IAAG,GACpB,MAAM,CAAC,KAAK;QAEhB,CAAC;QAED,MAAM,CAAC,IAAI;IACb,CAAC;IAED,aAAa,CAAC,GAAQ,EAAE,CAAC;QACvB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,KAAK,CAAM,SAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,GACxE,MAAM,CAAC,KAAK;QAGd,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG;QACtC,EAAE,GAAG,IAAI,IAAK,IAAI,CAAC,IAAI,KAAK,CAAM,UAAK,IAAI,CAAC,mBAAmB,EAC7D,MAAM,CAAC,KAAK;QAGd,MAAM,CAAC,IAAI;IACb,CAAC;gBAjbW,UAAqC,EAAE,KAA6B,EAAE,OAAiC,CAAE,CAAC;QACpH,IAAI,CAAC,UAAU,GAAG,UAAU;QAC5B,IAAI,CAAC,KAAK,GAAG,KAAK;YACS,GAA4B;QAAvD,IAAI,CAAC,mBAAmB,IAAG,GAA4B,GAA5B,OAAO,aAAP,OAAO,KAAP,IAAI,CAAJ,CAA4B,GAA5B,IAAI,CAAJ,CAA4B,GAA5B,OAAO,CAAE,mBAAmB,cAA5B,GAA4B,cAA5B,GAA4B,GAAI,KAAK;QAChE,IAAI,CAAC,YAAY,GAAG,IAAI;IAC1B,CAAC;;;;;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","packages/@react-stately/selection/src/SelectionManager.ts","packages/@react-stately/selection/src/types.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 './useMultipleSelectionState';\nexport * from './SelectionManager';\nexport * from './types';\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 {Key, useMemo, useRef, useState} from 'react';\nimport {MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(props.selectionBehavior || 'toggle');\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (props.selectionBehavior === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Selection {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\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 {Key} from 'react';\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key;\n currentKey: Key;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key, currentKey?: Key) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey || keys.anchorKey;\n this.currentKey = currentKey || keys.currentKey;\n } else {\n this.anchorKey = anchorKey;\n this.currentKey = currentKey;\n }\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 {\n Collection,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {Key} from 'react';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key, childFocusStrategy?: FocusStrategy) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? !this.state.disabledKeys.has(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || item?.index < first.index) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || item?.index > last.index) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey || toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (!this.state.disabledKeys.has(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (fromItem.index <= toItem.index) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n let keys: Key[] = [];\n let key = from;\n while (key) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n this.state.setSelectedKeys(new Selection([key], key, key));\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key) {\n if (!this.state.disabledKeys.has(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys([...item.childNodes][0].key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\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 {FocusStrategy, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport interface FocusState {\n /** Whether the collection is currently focused. */\n readonly isFocused: boolean,\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void,\n /** The current focused key in the collection. */\n readonly focusedKey: Key,\n /** Whether the first or last child of the focused key should receive focus. */\n readonly childFocusStrategy: FocusStrategy,\n /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */\n setFocusedKey(key: Key, child?: FocusStrategy): void\n}\n\nexport interface SingleSelectionState extends FocusState {\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected key in the collection. */\n readonly selectedKey: Key,\n /** Sets the selected key in the collection. */\n setSelectedKey(key: Key): void\n}\n\nexport interface MultipleSelectionState extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Selection,\n /** Sets the selected keys in the collection. */\n setSelectedKeys(keys: Selection): void,\n /** The currently disabled keys in the collection. */\n readonly disabledKeys: Set<Key>\n}\n\nexport interface MultipleSelectionManager extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Set<Key>,\n /** Whether the selection is empty. */\n readonly isEmpty: boolean,\n /** Whether all items in the collection are selected. */\n readonly isSelectAll: boolean,\n /** The first selected key in the collection. */\n readonly firstSelectedKey: Key | null,\n /** The last selected key in the collection. */\n readonly lastSelectedKey: Key | null,\n /** Returns whether a key is selected. */\n isSelected(key: Key): boolean,\n /** Returns whether the current selection is equal to the given selection. */\n isSelectionEqual(selection: Set<Key>): boolean,\n /** Extends the selection to the given key. */\n extendSelection(toKey: Key): void,\n /** Toggles whether the given key is selected. */\n toggleSelection(key: Key): void,\n /** Replaces the selection with only the given key. */\n replaceSelection(key: Key): void,\n /** Replaces the selection with the given keys. */\n setSelectedKeys(keys: Iterable<Key>): void,\n /** Selects all items in the collection. */\n selectAll(): void,\n /** Removes all keys from the selection. */\n clearSelection(): void,\n /** Toggles between select all and an empty selection. */\n toggleSelectAll(): void,\n /**\n * Toggles, replaces, or extends selection to the given key depending\n * on the pointer event and collection's selection mode.\n */\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent): void,\n /** Returns whether the given key can be selected. */\n canSelectItem(key: Key): boolean,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {useRef as $
|
|
2
|
-
import {useControlledState as $
|
|
1
|
+
import {useRef as $Qsto2$useRef, useState as $Qsto2$useState, useMemo as $Qsto2$useMemo} from "react";
|
|
2
|
+
import {useControlledState as $Qsto2$useControlledState} from "@react-stately/utils";
|
|
3
3
|
|
|
4
4
|
function $parcel$export(e, n, v, s) {
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
|
-
var $
|
|
7
|
+
var $7af3f5b51489e0b5$exports = {};
|
|
8
8
|
|
|
9
|
-
$parcel$export($
|
|
9
|
+
$parcel$export($7af3f5b51489e0b5$exports, "useMultipleSelectionState", () => $7af3f5b51489e0b5$export$253fe78d46329472);
|
|
10
10
|
|
|
11
|
-
class $
|
|
11
|
+
class $e40ea825a81a3709$export$52baac22726c72bf extends Set {
|
|
12
12
|
constructor(keys, anchorKey, currentKey){
|
|
13
13
|
super(keys);
|
|
14
|
-
if (keys instanceof $
|
|
14
|
+
if (keys instanceof $e40ea825a81a3709$export$52baac22726c72bf) {
|
|
15
15
|
this.anchorKey = anchorKey || keys.anchorKey;
|
|
16
16
|
this.currentKey = currentKey || keys.currentKey;
|
|
17
17
|
} else {
|
|
@@ -23,36 +23,36 @@ class $c5f55c1d1f0007fc$export$52baac22726c72bf extends Set {
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
function $
|
|
26
|
+
function $7af3f5b51489e0b5$var$equalSets(setA, setB) {
|
|
27
27
|
if (setA.size !== setB.size) return false;
|
|
28
28
|
for (let item of setA){
|
|
29
29
|
if (!setB.has(item)) return false;
|
|
30
30
|
}
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
33
|
-
function $
|
|
33
|
+
function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
|
|
34
34
|
let { selectionMode: selectionMode = 'none' , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents } = props;
|
|
35
35
|
// We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
|
|
36
36
|
// But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
|
|
37
|
-
let isFocusedRef = $
|
|
38
|
-
let [, setFocused] = $
|
|
39
|
-
let focusedKeyRef = $
|
|
40
|
-
let childFocusStrategyRef = $
|
|
41
|
-
let [, setFocusedKey] = $
|
|
42
|
-
let selectedKeysProp = $
|
|
37
|
+
let isFocusedRef = $Qsto2$useRef(false);
|
|
38
|
+
let [, setFocused] = $Qsto2$useState(false);
|
|
39
|
+
let focusedKeyRef = $Qsto2$useRef(null);
|
|
40
|
+
let childFocusStrategyRef = $Qsto2$useRef(null);
|
|
41
|
+
let [, setFocusedKey] = $Qsto2$useState(null);
|
|
42
|
+
let selectedKeysProp = $Qsto2$useMemo(()=>$7af3f5b51489e0b5$var$convertSelection(props.selectedKeys)
|
|
43
43
|
, [
|
|
44
44
|
props.selectedKeys
|
|
45
45
|
]);
|
|
46
|
-
let defaultSelectedKeys = $
|
|
46
|
+
let defaultSelectedKeys = $Qsto2$useMemo(()=>$7af3f5b51489e0b5$var$convertSelection(props.defaultSelectedKeys, new $e40ea825a81a3709$export$52baac22726c72bf())
|
|
47
47
|
, [
|
|
48
48
|
props.defaultSelectedKeys
|
|
49
49
|
]);
|
|
50
|
-
let [selectedKeys, setSelectedKeys] = $
|
|
51
|
-
let disabledKeysProp = $
|
|
50
|
+
let [selectedKeys, setSelectedKeys] = $Qsto2$useControlledState(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
|
|
51
|
+
let disabledKeysProp = $Qsto2$useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
|
|
52
52
|
, [
|
|
53
53
|
props.disabledKeys
|
|
54
54
|
]);
|
|
55
|
-
let [selectionBehavior, setSelectionBehavior] = $
|
|
55
|
+
let [selectionBehavior, setSelectionBehavior] = $Qsto2$useState(props.selectionBehavior || 'toggle');
|
|
56
56
|
// If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press
|
|
57
57
|
// to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.
|
|
58
58
|
if (props.selectionBehavior === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) setSelectionBehavior('replace');
|
|
@@ -81,28 +81,22 @@ function $e961bd55a24935c9$export$253fe78d46329472(props) {
|
|
|
81
81
|
},
|
|
82
82
|
selectedKeys: selectedKeys,
|
|
83
83
|
setSelectedKeys (keys) {
|
|
84
|
-
if (allowDuplicateSelectionEvents || !$
|
|
84
|
+
if (allowDuplicateSelectionEvents || !$7af3f5b51489e0b5$var$equalSets(keys, selectedKeys)) setSelectedKeys(keys);
|
|
85
85
|
},
|
|
86
86
|
disabledKeys: disabledKeysProp
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function $
|
|
89
|
+
function $7af3f5b51489e0b5$var$convertSelection(selection, defaultValue) {
|
|
90
90
|
if (!selection) return defaultValue;
|
|
91
|
-
return selection === 'all' ? 'all' : new $
|
|
91
|
+
return selection === 'all' ? 'all' : new $e40ea825a81a3709$export$52baac22726c72bf(selection);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
var $
|
|
95
|
+
var $d496c0a20b6e58ec$exports = {};
|
|
96
96
|
|
|
97
|
-
$parcel$export($
|
|
97
|
+
$parcel$export($d496c0a20b6e58ec$exports, "SelectionManager", () => $d496c0a20b6e58ec$export$6c8a5aaad13c9852);
|
|
98
98
|
|
|
99
|
-
class $
|
|
100
|
-
constructor(collection, state, options){
|
|
101
|
-
this.collection = collection;
|
|
102
|
-
this.state = state;
|
|
103
|
-
this.allowsCellSelection = options?.allowsCellSelection ?? false;
|
|
104
|
-
this._isSelectAll = null;
|
|
105
|
-
}
|
|
99
|
+
class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
|
|
106
100
|
/**
|
|
107
101
|
* The type of selection that is allowed in the collection.
|
|
108
102
|
*/ get selectionMode() {
|
|
@@ -185,17 +179,17 @@ class $2f812fb5fa7ad073$export$6c8a5aaad13c9852 {
|
|
|
185
179
|
let first = null;
|
|
186
180
|
for (let key of this.state.selectedKeys){
|
|
187
181
|
let item = this.collection.getItem(key);
|
|
188
|
-
if (!first || item
|
|
182
|
+
if (!first || (item === null || item === void 0 ? void 0 : item.index) < first.index) first = item;
|
|
189
183
|
}
|
|
190
|
-
return first
|
|
184
|
+
return first === null || first === void 0 ? void 0 : first.key;
|
|
191
185
|
}
|
|
192
186
|
get lastSelectedKey() {
|
|
193
187
|
let last = null;
|
|
194
188
|
for (let key of this.state.selectedKeys){
|
|
195
189
|
let item = this.collection.getItem(key);
|
|
196
|
-
if (!last || item
|
|
190
|
+
if (!last || (item === null || item === void 0 ? void 0 : item.index) > last.index) last = item;
|
|
197
191
|
}
|
|
198
|
-
return last
|
|
192
|
+
return last === null || last === void 0 ? void 0 : last.key;
|
|
199
193
|
}
|
|
200
194
|
/**
|
|
201
195
|
* Extends the selection to the given key.
|
|
@@ -208,13 +202,13 @@ class $2f812fb5fa7ad073$export$6c8a5aaad13c9852 {
|
|
|
208
202
|
toKey = this.getKey(toKey);
|
|
209
203
|
let selection;
|
|
210
204
|
// Only select the one key if coming from a select all.
|
|
211
|
-
if (this.state.selectedKeys === 'all') selection = new $
|
|
205
|
+
if (this.state.selectedKeys === 'all') selection = new $e40ea825a81a3709$export$52baac22726c72bf([
|
|
212
206
|
toKey
|
|
213
207
|
], toKey, toKey);
|
|
214
208
|
else {
|
|
215
209
|
let selectedKeys = this.state.selectedKeys;
|
|
216
210
|
let anchorKey = selectedKeys.anchorKey || toKey;
|
|
217
|
-
selection = new $
|
|
211
|
+
selection = new $e40ea825a81a3709$export$52baac22726c72bf(selectedKeys, anchorKey, toKey);
|
|
218
212
|
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey))selection.delete(key);
|
|
219
213
|
for (let key1 of this.getKeyRange(toKey, anchorKey))if (!this.state.disabledKeys.has(key1)) selection.add(key1);
|
|
220
214
|
}
|
|
@@ -261,7 +255,7 @@ class $2f812fb5fa7ad073$export$6c8a5aaad13c9852 {
|
|
|
261
255
|
}
|
|
262
256
|
key = this.getKey(key);
|
|
263
257
|
if (key == null) return;
|
|
264
|
-
let keys = new $
|
|
258
|
+
let keys = new $e40ea825a81a3709$export$52baac22726c72bf(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
|
|
265
259
|
if (keys.has(key)) keys.delete(key);
|
|
266
260
|
else {
|
|
267
261
|
keys.add(key);
|
|
@@ -277,7 +271,7 @@ class $2f812fb5fa7ad073$export$6c8a5aaad13c9852 {
|
|
|
277
271
|
if (this.selectionMode === 'none') return;
|
|
278
272
|
key = this.getKey(key);
|
|
279
273
|
if (key == null) return;
|
|
280
|
-
this.state.setSelectedKeys(new $
|
|
274
|
+
this.state.setSelectedKeys(new $e40ea825a81a3709$export$52baac22726c72bf([
|
|
281
275
|
key
|
|
282
276
|
], key, key));
|
|
283
277
|
}
|
|
@@ -285,7 +279,7 @@ class $2f812fb5fa7ad073$export$6c8a5aaad13c9852 {
|
|
|
285
279
|
* Replaces the selection with the given keys.
|
|
286
280
|
*/ setSelectedKeys(keys) {
|
|
287
281
|
if (this.selectionMode === 'none') return;
|
|
288
|
-
let selection = new $
|
|
282
|
+
let selection = new $e40ea825a81a3709$export$52baac22726c72bf();
|
|
289
283
|
for (let key of keys){
|
|
290
284
|
key = this.getKey(key);
|
|
291
285
|
if (key != null) {
|
|
@@ -321,7 +315,7 @@ class $2f812fb5fa7ad073$export$6c8a5aaad13c9852 {
|
|
|
321
315
|
/**
|
|
322
316
|
* Removes all keys from the selection.
|
|
323
317
|
*/ clearSelection() {
|
|
324
|
-
if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new $
|
|
318
|
+
if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new $e40ea825a81a3709$export$52baac22726c72bf());
|
|
325
319
|
}
|
|
326
320
|
/**
|
|
327
321
|
* Toggles between select all and an empty selection.
|
|
@@ -359,13 +353,20 @@ class $2f812fb5fa7ad073$export$6c8a5aaad13c9852 {
|
|
|
359
353
|
if (!item || item.type === 'cell' && !this.allowsCellSelection) return false;
|
|
360
354
|
return true;
|
|
361
355
|
}
|
|
356
|
+
constructor(collection, state, options){
|
|
357
|
+
this.collection = collection;
|
|
358
|
+
this.state = state;
|
|
359
|
+
var ref;
|
|
360
|
+
this.allowsCellSelection = (ref = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && ref !== void 0 ? ref : false;
|
|
361
|
+
this._isSelectAll = null;
|
|
362
|
+
}
|
|
362
363
|
}
|
|
363
364
|
|
|
364
365
|
|
|
365
|
-
var $
|
|
366
|
+
var $63d397230baf7bd4$exports = {};
|
|
366
367
|
|
|
367
368
|
|
|
368
369
|
|
|
369
370
|
|
|
370
|
-
export {$
|
|
371
|
+
export {$7af3f5b51489e0b5$export$253fe78d46329472 as useMultipleSelectionState, $d496c0a20b6e58ec$export$6c8a5aaad13c9852 as SelectionManager};
|
|
371
372
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;MEkBa,yCAAS,SAAS,GAAG;gBAIpB,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE,CAAC;QAChF,KAAK,CAAC,IAAI;QACV,EAAE,EAAE,IAAI,YAAY,yCAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,SAAS;YAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,IAAI,CAAC,UAAU;QACjD,CAAC,MAAM,CAAC;YACN,IAAI,CAAC,SAAS,GAAG,SAAS;YAC1B,IAAI,CAAC,UAAU,GAAG,UAAU;QAC9B,CAAC;IACH,CAAC;;;;;SDbM,+BAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EACzB,MAAM,CAAC,KAAK;IAGd,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,IAAI,CAAE,CAAC;QACtB,EAAE,GAAG,IAAI,CA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tC,EAAE,GAAG,IAAI,IAAK,IAAI,CAAC,IAAI,KAAK,CAAM,UAAK,IAAI,CAAC,mBAAmB,EAC7D,MAAM,CAAC,KAAK;QAGd,MAAM,CAAC,IAAI;IACb,CAAC;;;;;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","packages/@react-stately/selection/src/SelectionManager.ts","packages/@react-stately/selection/src/types.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 './useMultipleSelectionState';\nexport * from './SelectionManager';\nexport * from './types';\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 {Key, useMemo, useRef, useState} from 'react';\nimport {MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(props.selectionBehavior || 'toggle');\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (props.selectionBehavior === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Selection {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\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 {Key} from 'react';\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key;\n currentKey: Key;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key, currentKey?: Key) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey || keys.anchorKey;\n this.currentKey = currentKey || keys.currentKey;\n } else {\n this.anchorKey = anchorKey;\n this.currentKey = currentKey;\n }\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 {\n Collection,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {Key} from 'react';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key, childFocusStrategy?: FocusStrategy) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? !this.state.disabledKeys.has(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || item?.index < first.index) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || item?.index > last.index) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey || toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (!this.state.disabledKeys.has(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (fromItem.index <= toItem.index) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n let keys: Key[] = [];\n let key = from;\n while (key) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n this.state.setSelectedKeys(new Selection([key], key, key));\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key) {\n if (!this.state.disabledKeys.has(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys([...item.childNodes][0].key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\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 {FocusStrategy, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport interface FocusState {\n /** Whether the collection is currently focused. */\n readonly isFocused: boolean,\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void,\n /** The current focused key in the collection. */\n readonly focusedKey: Key,\n /** Whether the first or last child of the focused key should receive focus. */\n readonly childFocusStrategy: FocusStrategy,\n /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */\n setFocusedKey(key: Key, child?: FocusStrategy): void\n}\n\nexport interface SingleSelectionState extends FocusState {\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected key in the collection. */\n readonly selectedKey: Key,\n /** Sets the selected key in the collection. */\n setSelectedKey(key: Key): void\n}\n\nexport interface MultipleSelectionState extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Selection,\n /** Sets the selected keys in the collection. */\n setSelectedKeys(keys: Selection): void,\n /** The currently disabled keys in the collection. */\n readonly disabledKeys: Set<Key>\n}\n\nexport interface MultipleSelectionManager extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Set<Key>,\n /** Whether the selection is empty. */\n readonly isEmpty: boolean,\n /** Whether all items in the collection are selected. */\n readonly isSelectAll: boolean,\n /** The first selected key in the collection. */\n readonly firstSelectedKey: Key | null,\n /** The last selected key in the collection. */\n readonly lastSelectedKey: Key | null,\n /** Returns whether a key is selected. */\n isSelected(key: Key): boolean,\n /** Returns whether the current selection is equal to the given selection. */\n isSelectionEqual(selection: Set<Key>): boolean,\n /** Extends the selection to the given key. */\n extendSelection(toKey: Key): void,\n /** Toggles whether the given key is selected. */\n toggleSelection(key: Key): void,\n /** Replaces the selection with only the given key. */\n replaceSelection(key: Key): void,\n /** Replaces the selection with the given keys. */\n setSelectedKeys(keys: Iterable<Key>): void,\n /** Selects all items in the collection. */\n selectAll(): void,\n /** Removes all keys from the selection. */\n clearSelection(): void,\n /** Toggles between select all and an empty selection. */\n toggleSelectAll(): void,\n /**\n * Toggles, replaces, or extends selection to the given key depending\n * on the pointer event and collection's selection mode.\n */\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent): void,\n /** Returns whether the given key can be selected. */\n canSelectItem(key: Key): boolean,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;MEkBa,yCAAS,SAAS,GAAG;gBAIpB,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE,CAAC;QAChF,KAAK,CAAC,IAAI;QACV,EAAE,EAAE,IAAI,YAAY,yCAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,SAAS;YAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,IAAI,CAAC,UAAU;QACjD,CAAC,MAAM,CAAC;YACN,IAAI,CAAC,SAAS,GAAG,SAAS;YAC1B,IAAI,CAAC,UAAU,GAAG,UAAU;QAC9B,CAAC;IACH,CAAC;;;;;SDbM,+BAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EACzB,MAAM,CAAC,KAAK;IAGd,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,IAAI,CAAE,CAAC;QACtB,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAChB,MAAM,CAAC,KAAK;IAEhB,CAAC;IAED,MAAM,CAAC,IAAI;AACb,CAAC;SAYe,yCAAyB,CAAC,KAAkC,EAA0B,CAAC;IACrG,GAAG,CAAC,CAAC,gBACH,aAAa,GAAG,CAAM,gCACtB,sBAAsB,kCACtB,6BAA6B,EAC/B,CAAC,GAAG,KAAK;IAET,EAA8F,AAA9F,4FAA8F;IAC9F,EAAkG,AAAlG,gGAAkG;IAClG,GAAG,CAAC,YAAY,GAAG,aAAM,CAAC,KAAK;IAC/B,GAAG,I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IAAI,CAAC,mBAAmB,IAAG,GAA4B,GAA5B,OAAO,aAAP,OAAO,KAAP,IAAI,CAAJ,CAA4B,GAA5B,IAAI,CAAJ,CAA4B,GAA5B,OAAO,CAAE,mBAAmB,cAA5B,GAA4B,cAA5B,GAA4B,GAAI,KAAK;QAChE,IAAI,CAAC,YAAY,GAAG,IAAI;IAC1B,CAAC;;;;;","sources":["packages/@react-stately/selection/src/index.ts","packages/@react-stately/selection/src/useMultipleSelectionState.ts","packages/@react-stately/selection/src/Selection.ts","packages/@react-stately/selection/src/SelectionManager.ts","packages/@react-stately/selection/src/types.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 './useMultipleSelectionState';\nexport * from './SelectionManager';\nexport * from './types';\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 {Key, useMemo, useRef, useState} from 'react';\nimport {MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\nimport {useControlledState} from '@react-stately/utils';\n\nfunction equalSets(setA, setB) {\n if (setA.size !== setB.size) {\n return false;\n }\n\n for (let item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport interface MultipleSelectionStateProps extends MultipleSelection {\n /** How multiple selection should behave in the collection. */\n selectionBehavior?: SelectionBehavior,\n /** Whether onSelectionChange should fire even if the new set of keys is the same as the last. */\n allowDuplicateSelectionEvents?: boolean\n}\n\n/**\n * Manages state for multiple selection and focus in a collection.\n */\nexport function useMultipleSelectionState(props: MultipleSelectionStateProps): MultipleSelectionState {\n let {\n selectionMode = 'none' as SelectionMode,\n disallowEmptySelection,\n allowDuplicateSelectionEvents\n } = props;\n\n // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.\n // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).\n let isFocusedRef = useRef(false);\n let [, setFocused] = useState(false);\n let focusedKeyRef = useRef(null);\n let childFocusStrategyRef = useRef(null);\n let [, setFocusedKey] = useState(null);\n let selectedKeysProp = useMemo(() => convertSelection(props.selectedKeys), [props.selectedKeys]);\n let defaultSelectedKeys = useMemo(() => convertSelection(props.defaultSelectedKeys, new Selection()), [props.defaultSelectedKeys]);\n let [selectedKeys, setSelectedKeys] = useControlledState(\n selectedKeysProp,\n defaultSelectedKeys,\n props.onSelectionChange\n );\n let disabledKeysProp = useMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n , [props.disabledKeys]);\n let [selectionBehavior, setSelectionBehavior] = useState(props.selectionBehavior || 'toggle');\n\n // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press\n // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.\n if (props.selectionBehavior === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n return {\n selectionMode,\n disallowEmptySelection,\n selectionBehavior,\n setSelectionBehavior,\n get isFocused() {\n return isFocusedRef.current;\n },\n setFocused(f) {\n isFocusedRef.current = f;\n setFocused(f);\n },\n get focusedKey() {\n return focusedKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocusedKey(k, childFocusStrategy = 'first') {\n focusedKeyRef.current = k;\n childFocusStrategyRef.current = childFocusStrategy;\n setFocusedKey(k);\n },\n selectedKeys,\n setSelectedKeys(keys) {\n if (allowDuplicateSelectionEvents || !equalSets(keys, selectedKeys)) {\n setSelectedKeys(keys);\n }\n },\n disabledKeys: disabledKeysProp\n };\n}\n\nfunction convertSelection(selection: 'all' | Iterable<Key>, defaultValue?: Selection): 'all' | Selection {\n if (!selection) {\n return defaultValue;\n }\n\n return selection === 'all'\n ? 'all'\n : new Selection(selection);\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 {Key} from 'react';\n\n/**\n * A Selection is a special Set containing Keys, which also has an anchor\n * and current selected key for use when range selecting.\n */\nexport class Selection extends Set<Key> {\n anchorKey: Key;\n currentKey: Key;\n\n constructor(keys?: Iterable<Key> | Selection, anchorKey?: Key, currentKey?: Key) {\n super(keys);\n if (keys instanceof Selection) {\n this.anchorKey = anchorKey || keys.anchorKey;\n this.currentKey = currentKey || keys.currentKey;\n } else {\n this.anchorKey = anchorKey;\n this.currentKey = currentKey;\n }\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 {\n Collection,\n FocusStrategy,\n Selection as ISelection,\n LongPressEvent,\n Node,\n PressEvent,\n SelectionBehavior,\n SelectionMode\n} from '@react-types/shared';\nimport {Key} from 'react';\nimport {MultipleSelectionManager, MultipleSelectionState} from './types';\nimport {Selection} from './Selection';\n\ninterface SelectionManagerOptions {\n allowsCellSelection?: boolean\n}\n\n/**\n * An interface for reading and updating multiple selection state.\n */\nexport class SelectionManager implements MultipleSelectionManager {\n private collection: Collection<Node<unknown>>;\n private state: MultipleSelectionState;\n private allowsCellSelection: boolean;\n private _isSelectAll: boolean;\n\n constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) {\n this.collection = collection;\n this.state = state;\n this.allowsCellSelection = options?.allowsCellSelection ?? false;\n this._isSelectAll = null;\n }\n\n /**\n * The type of selection that is allowed in the collection.\n */\n get selectionMode(): SelectionMode {\n return this.state.selectionMode;\n }\n\n /**\n * Whether the collection allows empty selection.\n */\n get disallowEmptySelection(): boolean {\n return this.state.disallowEmptySelection;\n }\n\n /**\n * The selection behavior for the collection.\n */\n get selectionBehavior(): SelectionBehavior {\n return this.state.selectionBehavior;\n }\n\n /**\n * Sets the selection behavior for the collection.\n */\n setSelectionBehavior(selectionBehavior: SelectionBehavior) {\n this.state.setSelectionBehavior(selectionBehavior);\n }\n\n /**\n * Whether the collection is currently focused.\n */\n get isFocused(): boolean {\n return this.state.isFocused;\n }\n\n /**\n * Sets whether the collection is focused.\n */\n setFocused(isFocused: boolean) {\n this.state.setFocused(isFocused);\n }\n\n /**\n * The current focused key in the collection.\n */\n get focusedKey(): Key {\n return this.state.focusedKey;\n }\n\n /** Whether the first or last child of the focused key should receive focus. */\n get childFocusStrategy(): FocusStrategy {\n return this.state.childFocusStrategy;\n }\n\n /**\n * Sets the focused key.\n */\n setFocusedKey(key: Key, childFocusStrategy?: FocusStrategy) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\n\n /**\n * The currently selected keys in the collection.\n */\n get selectedKeys(): Set<Key> {\n return this.state.selectedKeys === 'all'\n ? new Set(this.getSelectAllKeys())\n : this.state.selectedKeys;\n }\n\n /**\n * The raw selection value for the collection.\n * Either 'all' for select all, or a set of keys.\n */\n get rawSelection(): ISelection {\n return this.state.selectedKeys;\n }\n\n /**\n * Returns whether a key is selected.\n */\n isSelected(key: Key) {\n if (this.state.selectionMode === 'none') {\n return false;\n }\n\n key = this.getKey(key);\n return this.state.selectedKeys === 'all'\n ? !this.state.disabledKeys.has(key)\n : this.state.selectedKeys.has(key);\n }\n\n /**\n * Whether the selection is empty.\n */\n get isEmpty(): boolean {\n return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;\n }\n\n /**\n * Whether all items in the collection are selected.\n */\n get isSelectAll(): boolean {\n if (this.isEmpty) {\n return false;\n }\n\n if (this.state.selectedKeys === 'all') {\n return true;\n }\n\n if (this._isSelectAll != null) {\n return this._isSelectAll;\n }\n\n let allKeys = this.getSelectAllKeys();\n let selectedKeys = this.state.selectedKeys;\n this._isSelectAll = allKeys.every(k => selectedKeys.has(k));\n return this._isSelectAll;\n }\n\n get firstSelectedKey(): Key | null {\n let first: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!first || item?.index < first.index) {\n first = item;\n }\n }\n\n return first?.key;\n }\n\n get lastSelectedKey(): Key | null {\n let last: Node<unknown> | null = null;\n for (let key of this.state.selectedKeys) {\n let item = this.collection.getItem(key);\n if (!last || item?.index > last.index) {\n last = item;\n }\n }\n\n return last?.key;\n }\n\n /**\n * Extends the selection to the given key.\n */\n extendSelection(toKey: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.replaceSelection(toKey);\n return;\n }\n\n toKey = this.getKey(toKey);\n\n let selection: Selection;\n\n // Only select the one key if coming from a select all.\n if (this.state.selectedKeys === 'all') {\n selection = new Selection([toKey], toKey, toKey);\n } else {\n let selectedKeys = this.state.selectedKeys as Selection;\n let anchorKey = selectedKeys.anchorKey || toKey;\n selection = new Selection(selectedKeys, anchorKey, toKey);\n for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {\n selection.delete(key);\n }\n\n for (let key of this.getKeyRange(toKey, anchorKey)) {\n if (!this.state.disabledKeys.has(key)) {\n selection.add(key);\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getKeyRange(from: Key, to: Key) {\n let fromItem = this.collection.getItem(from);\n let toItem = this.collection.getItem(to);\n if (fromItem && toItem) {\n if (fromItem.index <= toItem.index) {\n return this.getKeyRangeInternal(from, to);\n }\n\n return this.getKeyRangeInternal(to, from);\n }\n\n return [];\n }\n\n private getKeyRangeInternal(from: Key, to: Key) {\n let keys: Key[] = [];\n let key = from;\n while (key) {\n let item = this.collection.getItem(key);\n if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) {\n keys.push(key);\n }\n\n if (key === to) {\n return keys;\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return [];\n }\n\n private getKey(key: Key) {\n let item = this.collection.getItem(key);\n if (!item) {\n // ¯\\_(ツ)_/¯\n return key;\n }\n\n // If cell selection is allowed, just return the key.\n if (item.type === 'cell' && this.allowsCellSelection) {\n return key;\n }\n\n // Find a parent item to select\n while (item.type !== 'item' && item.parentKey != null) {\n item = this.collection.getItem(item.parentKey);\n }\n\n if (!item || item.type !== 'item') {\n return null;\n }\n\n return item.key;\n }\n\n /**\n * Toggles whether the given key is selected.\n */\n toggleSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single' && !this.isSelected(key)) {\n this.replaceSelection(key);\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n let keys = new Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n // TODO: move anchor to last selected key...\n // Does `current` need to move here too?\n } else {\n keys.add(key);\n keys.anchorKey = key;\n keys.currentKey = key;\n }\n\n if (this.disallowEmptySelection && keys.size === 0) {\n return;\n }\n\n this.state.setSelectedKeys(keys);\n }\n\n /**\n * Replaces the selection with only the given key.\n */\n replaceSelection(key: Key) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n key = this.getKey(key);\n if (key == null) {\n return;\n }\n\n this.state.setSelectedKeys(new Selection([key], key, key));\n }\n\n /**\n * Replaces the selection with the given keys.\n */\n setSelectedKeys(keys: Iterable<Key>) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n let selection = new Selection();\n for (let key of keys) {\n key = this.getKey(key);\n if (key != null) {\n selection.add(key);\n if (this.selectionMode === 'single') {\n break;\n }\n }\n }\n\n this.state.setSelectedKeys(selection);\n }\n\n private getSelectAllKeys() {\n let keys: Key[] = [];\n let addKeys = (key: Key) => {\n while (key) {\n if (!this.state.disabledKeys.has(key)) {\n let item = this.collection.getItem(key);\n if (item.type === 'item') {\n keys.push(key);\n }\n\n // Add child keys. If cell selection is allowed, then include item children too.\n if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {\n addKeys([...item.childNodes][0].key);\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n };\n\n addKeys(this.collection.getFirstKey());\n return keys;\n }\n\n /**\n * Selects all items in the collection.\n */\n selectAll() {\n if (this.selectionMode === 'multiple') {\n this.state.setSelectedKeys('all');\n }\n }\n\n /**\n * Removes all keys from the selection.\n */\n clearSelection() {\n if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {\n this.state.setSelectedKeys(new Selection());\n }\n }\n\n /**\n * Toggles between select all and an empty selection.\n */\n toggleSelectAll() {\n if (this.isSelectAll) {\n this.clearSelection();\n } else {\n this.selectAll();\n }\n }\n\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) {\n if (this.selectionMode === 'none') {\n return;\n }\n\n if (this.selectionMode === 'single') {\n if (this.isSelected(key) && !this.disallowEmptySelection) {\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n } else if (this.selectionBehavior === 'toggle' || (e && (e.pointerType === 'touch' || e.pointerType === 'virtual'))) {\n // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys\n this.toggleSelection(key);\n } else {\n this.replaceSelection(key);\n }\n }\n\n /**\n * Returns whether the current selection is equal to the given selection.\n */\n isSelectionEqual(selection: Set<Key>) {\n if (selection === this.state.selectedKeys) {\n return true;\n }\n\n // Check if the set of keys match.\n let selectedKeys = this.selectedKeys;\n if (selection.size !== selectedKeys.size) {\n return false;\n }\n\n for (let key of selection) {\n if (!selectedKeys.has(key)) {\n return false;\n }\n }\n\n for (let key of selectedKeys) {\n if (!selection.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n canSelectItem(key: Key) {\n if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) {\n return false;\n }\n\n let item = this.collection.getItem(key);\n if (!item || (item.type === 'cell' && !this.allowsCellSelection)) {\n return false;\n }\n\n return true;\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 {FocusStrategy, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport interface FocusState {\n /** Whether the collection is currently focused. */\n readonly isFocused: boolean,\n /** Sets whether the collection is focused. */\n setFocused(isFocused: boolean): void,\n /** The current focused key in the collection. */\n readonly focusedKey: Key,\n /** Whether the first or last child of the focused key should receive focus. */\n readonly childFocusStrategy: FocusStrategy,\n /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */\n setFocusedKey(key: Key, child?: FocusStrategy): void\n}\n\nexport interface SingleSelectionState extends FocusState {\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected key in the collection. */\n readonly selectedKey: Key,\n /** Sets the selected key in the collection. */\n setSelectedKey(key: Key): void\n}\n\nexport interface MultipleSelectionState extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Selection,\n /** Sets the selected keys in the collection. */\n setSelectedKeys(keys: Selection): void,\n /** The currently disabled keys in the collection. */\n readonly disabledKeys: Set<Key>\n}\n\nexport interface MultipleSelectionManager extends FocusState {\n /** The type of selection that is allowed in the collection. */\n readonly selectionMode: SelectionMode,\n /** The selection behavior for the collection. */\n readonly selectionBehavior: SelectionBehavior,\n /** Whether the collection allows empty selection. */\n readonly disallowEmptySelection?: boolean,\n /** The currently selected keys in the collection. */\n readonly selectedKeys: Set<Key>,\n /** Whether the selection is empty. */\n readonly isEmpty: boolean,\n /** Whether all items in the collection are selected. */\n readonly isSelectAll: boolean,\n /** The first selected key in the collection. */\n readonly firstSelectedKey: Key | null,\n /** The last selected key in the collection. */\n readonly lastSelectedKey: Key | null,\n /** Returns whether a key is selected. */\n isSelected(key: Key): boolean,\n /** Returns whether the current selection is equal to the given selection. */\n isSelectionEqual(selection: Set<Key>): boolean,\n /** Extends the selection to the given key. */\n extendSelection(toKey: Key): void,\n /** Toggles whether the given key is selected. */\n toggleSelection(key: Key): void,\n /** Replaces the selection with only the given key. */\n replaceSelection(key: Key): void,\n /** Replaces the selection with the given keys. */\n setSelectedKeys(keys: Iterable<Key>): void,\n /** Selects all items in the collection. */\n selectAll(): void,\n /** Removes all keys from the selection. */\n clearSelection(): void,\n /** Toggles between select all and an empty selection. */\n toggleSelectAll(): void,\n /**\n * Toggles, replaces, or extends selection to the given key depending\n * on the pointer event and collection's selection mode.\n */\n select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent): void,\n /** Returns whether the given key can be selected. */\n canSelectItem(key: Key): boolean,\n /** Sets the selection behavior for the collection. */\n setSelectionBehavior(selectionBehavior: SelectionBehavior): void\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/selection",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.4",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-stately/collections": "^3.3.
|
|
22
|
-
"@react-stately/utils": "^3.4.
|
|
23
|
-
"@react-types/shared": "^3.
|
|
21
|
+
"@react-stately/collections": "^3.3.8",
|
|
22
|
+
"@react-stately/utils": "^3.4.1",
|
|
23
|
+
"@react-types/shared": "^3.12.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "6a503b715e0dbbf92038cd7f08b1bcdde4c78e82"
|
|
32
32
|
}
|