@react-stately/selection 3.11.1 → 3.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -7,8 +7,38 @@ function $parcel$export(e, n, v, s) {
7
7
 
8
8
  $parcel$export(module.exports, "useMultipleSelectionState", () => $1adc19da2128bba9$export$253fe78d46329472);
9
9
  $parcel$export(module.exports, "SelectionManager", () => $8112da6fa5bbc322$export$6c8a5aaad13c9852);
10
-
11
- class $21c847070f1f9569$export$52baac22726c72bf extends Set {
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */ /*
21
+ * Copyright 2020 Adobe. All rights reserved.
22
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License. You may obtain a copy
24
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software distributed under
27
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
+ * OF ANY KIND, either express or implied. See the License for the specific language
29
+ * governing permissions and limitations under the License.
30
+ */
31
+ /*
32
+ * Copyright 2020 Adobe. All rights reserved.
33
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
34
+ * you may not use this file except in compliance with the License. You may obtain a copy
35
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing, software distributed under
38
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
39
+ * OF ANY KIND, either express or implied. See the License for the specific language
40
+ * governing permissions and limitations under the License.
41
+ */ class $21c847070f1f9569$export$52baac22726c72bf extends Set {
12
42
  constructor(keys, anchorKey, currentKey){
13
43
  super(keys);
14
44
  if (keys instanceof $21c847070f1f9569$export$52baac22726c72bf) {
@@ -31,34 +61,31 @@ function $1adc19da2128bba9$var$equalSets(setA, setB) {
31
61
  return true;
32
62
  }
33
63
  function $1adc19da2128bba9$export$253fe78d46329472(props) {
34
- let { selectionMode: selectionMode = 'none' , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents , selectionBehavior: selectionBehaviorProp = 'toggle' , disabledBehavior: disabledBehavior = 'all' } = props;
64
+ let { selectionMode: selectionMode = "none" , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents , selectionBehavior: selectionBehaviorProp = "toggle" , disabledBehavior: disabledBehavior = "all" } = props;
35
65
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
36
66
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
37
- let isFocusedRef = $83d9f$react.useRef(false);
38
- let [, setFocused] = $83d9f$react.useState(false);
39
- let focusedKeyRef = $83d9f$react.useRef(null);
40
- let childFocusStrategyRef = $83d9f$react.useRef(null);
41
- let [, setFocusedKey] = $83d9f$react.useState(null);
42
- let selectedKeysProp = $83d9f$react.useMemo(()=>$1adc19da2128bba9$var$convertSelection(props.selectedKeys)
43
- , [
67
+ let isFocusedRef = (0, $83d9f$react.useRef)(false);
68
+ let [, setFocused] = (0, $83d9f$react.useState)(false);
69
+ let focusedKeyRef = (0, $83d9f$react.useRef)(null);
70
+ let childFocusStrategyRef = (0, $83d9f$react.useRef)(null);
71
+ let [, setFocusedKey] = (0, $83d9f$react.useState)(null);
72
+ let selectedKeysProp = (0, $83d9f$react.useMemo)(()=>$1adc19da2128bba9$var$convertSelection(props.selectedKeys), [
44
73
  props.selectedKeys
45
74
  ]);
46
- let defaultSelectedKeys = $83d9f$react.useMemo(()=>$1adc19da2128bba9$var$convertSelection(props.defaultSelectedKeys, new $21c847070f1f9569$export$52baac22726c72bf())
47
- , [
75
+ let defaultSelectedKeys = (0, $83d9f$react.useMemo)(()=>$1adc19da2128bba9$var$convertSelection(props.defaultSelectedKeys, new (0, $21c847070f1f9569$export$52baac22726c72bf)()), [
48
76
  props.defaultSelectedKeys
49
77
  ]);
50
- let [selectedKeys, setSelectedKeys] = $83d9f$reactstatelyutils.useControlledState(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
51
- let disabledKeysProp = $83d9f$react.useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
52
- , [
78
+ let [selectedKeys, setSelectedKeys] = (0, $83d9f$reactstatelyutils.useControlledState)(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
79
+ let disabledKeysProp = (0, $83d9f$react.useMemo)(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [
53
80
  props.disabledKeys
54
81
  ]);
55
- let [selectionBehavior, setSelectionBehavior] = $83d9f$react.useState(selectionBehaviorProp);
82
+ let [selectionBehavior, setSelectionBehavior] = (0, $83d9f$react.useState)(selectionBehaviorProp);
56
83
  // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press
57
84
  // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.
58
- if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) setSelectionBehavior('replace');
85
+ if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0) setSelectionBehavior("replace");
59
86
  // If the selectionBehavior prop changes, update the state as well.
60
- let lastSelectionBehavior = $83d9f$react.useRef(selectionBehaviorProp);
61
- $83d9f$react.useEffect(()=>{
87
+ let lastSelectionBehavior = (0, $83d9f$react.useRef)(selectionBehaviorProp);
88
+ (0, $83d9f$react.useEffect)(()=>{
62
89
  if (selectionBehaviorProp !== lastSelectionBehavior.current) {
63
90
  setSelectionBehavior(selectionBehaviorProp);
64
91
  lastSelectionBehavior.current = selectionBehaviorProp;
@@ -84,7 +111,7 @@ function $1adc19da2128bba9$export$253fe78d46329472(props) {
84
111
  get childFocusStrategy () {
85
112
  return childFocusStrategyRef.current;
86
113
  },
87
- setFocusedKey (k, childFocusStrategy = 'first') {
114
+ setFocusedKey (k, childFocusStrategy = "first") {
88
115
  focusedKeyRef.current = k;
89
116
  childFocusStrategyRef.current = childFocusStrategy;
90
117
  setFocusedKey(k);
@@ -99,11 +126,21 @@ function $1adc19da2128bba9$export$253fe78d46329472(props) {
99
126
  }
100
127
  function $1adc19da2128bba9$var$convertSelection(selection, defaultValue) {
101
128
  if (!selection) return defaultValue;
102
- return selection === 'all' ? 'all' : new $21c847070f1f9569$export$52baac22726c72bf(selection);
129
+ return selection === "all" ? "all" : new (0, $21c847070f1f9569$export$52baac22726c72bf)(selection);
103
130
  }
104
131
 
105
132
 
106
-
133
+ /*
134
+ * Copyright 2020 Adobe. All rights reserved.
135
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
136
+ * you may not use this file except in compliance with the License. You may obtain a copy
137
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
138
+ *
139
+ * Unless required by applicable law or agreed to in writing, software distributed under
140
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
141
+ * OF ANY KIND, either express or implied. See the License for the specific language
142
+ * governing permissions and limitations under the License.
143
+ */
107
144
  class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
108
145
  /**
109
146
  * The type of selection that is allowed in the collection.
@@ -151,7 +188,7 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
151
188
  /**
152
189
  * The currently selected keys in the collection.
153
190
  */ get selectedKeys() {
154
- return this.state.selectedKeys === 'all' ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
191
+ return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
155
192
  }
156
193
  /**
157
194
  * The raw selection value for the collection.
@@ -162,25 +199,24 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
162
199
  /**
163
200
  * Returns whether a key is selected.
164
201
  */ isSelected(key) {
165
- if (this.state.selectionMode === 'none') return false;
202
+ if (this.state.selectionMode === "none") return false;
166
203
  key = this.getKey(key);
167
- return this.state.selectedKeys === 'all' ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
204
+ return this.state.selectedKeys === "all" ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
168
205
  }
169
206
  /**
170
207
  * Whether the selection is empty.
171
208
  */ get isEmpty() {
172
- return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;
209
+ return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
173
210
  }
174
211
  /**
175
212
  * Whether all items in the collection are selected.
176
213
  */ get isSelectAll() {
177
214
  if (this.isEmpty) return false;
178
- if (this.state.selectedKeys === 'all') return true;
215
+ if (this.state.selectedKeys === "all") return true;
179
216
  if (this._isSelectAll != null) return this._isSelectAll;
180
217
  let allKeys = this.getSelectAllKeys();
181
218
  let selectedKeys = this.state.selectedKeys;
182
- this._isSelectAll = allKeys.every((k)=>selectedKeys.has(k)
183
- );
219
+ this._isSelectAll = allKeys.every((k)=>selectedKeys.has(k));
184
220
  return this._isSelectAll;
185
221
  }
186
222
  get firstSelectedKey() {
@@ -208,21 +244,21 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
208
244
  /**
209
245
  * Extends the selection to the given key.
210
246
  */ extendSelection(toKey) {
211
- if (this.selectionMode === 'none') return;
212
- if (this.selectionMode === 'single') {
247
+ if (this.selectionMode === "none") return;
248
+ if (this.selectionMode === "single") {
213
249
  this.replaceSelection(toKey);
214
250
  return;
215
251
  }
216
252
  toKey = this.getKey(toKey);
217
253
  let selection;
218
254
  // Only select the one key if coming from a select all.
219
- if (this.state.selectedKeys === 'all') selection = new $21c847070f1f9569$export$52baac22726c72bf([
255
+ if (this.state.selectedKeys === "all") selection = new (0, $21c847070f1f9569$export$52baac22726c72bf)([
220
256
  toKey
221
257
  ], toKey, toKey);
222
258
  else {
223
259
  let selectedKeys = this.state.selectedKeys;
224
260
  let anchorKey = selectedKeys.anchorKey || toKey;
225
- selection = new $21c847070f1f9569$export$52baac22726c72bf(selectedKeys, anchorKey, toKey);
261
+ selection = new (0, $21c847070f1f9569$export$52baac22726c72bf)(selectedKeys, anchorKey, toKey);
226
262
  for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey))selection.delete(key);
227
263
  for (let key1 of this.getKeyRange(toKey, anchorKey))if (this.canSelectItem(key1)) selection.add(key1);
228
264
  }
@@ -242,7 +278,7 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
242
278
  let key = from;
243
279
  while(key){
244
280
  let item = this.collection.getItem(key);
245
- if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
281
+ if (item && item.type === "item" || item.type === "cell" && this.allowsCellSelection) keys.push(key);
246
282
  if (key === to) return keys;
247
283
  key = this.collection.getKeyAfter(key);
248
284
  }
@@ -253,23 +289,23 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
253
289
  if (!item) // ¯\_(ツ)_/¯
254
290
  return key;
255
291
  // If cell selection is allowed, just return the key.
256
- if (item.type === 'cell' && this.allowsCellSelection) return key;
292
+ if (item.type === "cell" && this.allowsCellSelection) return key;
257
293
  // Find a parent item to select
258
- while(item.type !== 'item' && item.parentKey != null)item = this.collection.getItem(item.parentKey);
259
- if (!item || item.type !== 'item') return null;
294
+ while(item.type !== "item" && item.parentKey != null)item = this.collection.getItem(item.parentKey);
295
+ if (!item || item.type !== "item") return null;
260
296
  return item.key;
261
297
  }
262
298
  /**
263
299
  * Toggles whether the given key is selected.
264
300
  */ toggleSelection(key) {
265
- if (this.selectionMode === 'none') return;
266
- if (this.selectionMode === 'single' && !this.isSelected(key)) {
301
+ if (this.selectionMode === "none") return;
302
+ if (this.selectionMode === "single" && !this.isSelected(key)) {
267
303
  this.replaceSelection(key);
268
304
  return;
269
305
  }
270
306
  key = this.getKey(key);
271
307
  if (key == null) return;
272
- let keys = new $21c847070f1f9569$export$52baac22726c72bf(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
308
+ let keys = new (0, $21c847070f1f9569$export$52baac22726c72bf)(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
273
309
  if (keys.has(key)) keys.delete(key);
274
310
  else if (this.canSelectItem(key)) {
275
311
  keys.add(key);
@@ -282,24 +318,24 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
282
318
  /**
283
319
  * Replaces the selection with only the given key.
284
320
  */ replaceSelection(key) {
285
- if (this.selectionMode === 'none') return;
321
+ if (this.selectionMode === "none") return;
286
322
  key = this.getKey(key);
287
323
  if (key == null) return;
288
- let selection = this.canSelectItem(key) ? new $21c847070f1f9569$export$52baac22726c72bf([
324
+ let selection = this.canSelectItem(key) ? new (0, $21c847070f1f9569$export$52baac22726c72bf)([
289
325
  key
290
- ], key, key) : new $21c847070f1f9569$export$52baac22726c72bf();
326
+ ], key, key) : new (0, $21c847070f1f9569$export$52baac22726c72bf)();
291
327
  this.state.setSelectedKeys(selection);
292
328
  }
293
329
  /**
294
330
  * Replaces the selection with the given keys.
295
331
  */ setSelectedKeys(keys) {
296
- if (this.selectionMode === 'none') return;
297
- let selection = new $21c847070f1f9569$export$52baac22726c72bf();
332
+ if (this.selectionMode === "none") return;
333
+ let selection = new (0, $21c847070f1f9569$export$52baac22726c72bf)();
298
334
  for (let key of keys){
299
335
  key = this.getKey(key);
300
336
  if (key != null) {
301
337
  selection.add(key);
302
- if (this.selectionMode === 'single') break;
338
+ if (this.selectionMode === "single") break;
303
339
  }
304
340
  }
305
341
  this.state.setSelectedKeys(selection);
@@ -310,9 +346,9 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
310
346
  while(key){
311
347
  if (this.canSelectItem(key)) {
312
348
  let item = this.collection.getItem(key);
313
- if (item.type === 'item') keys.push(key);
349
+ if (item.type === "item") keys.push(key);
314
350
  // Add child keys. If cell selection is allowed, then include item children too.
315
- if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) addKeys([
351
+ if (item.hasChildNodes && (this.allowsCellSelection || item.type !== "item")) addKeys([
316
352
  ...item.childNodes
317
353
  ][0].key);
318
354
  }
@@ -325,12 +361,12 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
325
361
  /**
326
362
  * Selects all items in the collection.
327
363
  */ selectAll() {
328
- if (this.selectionMode === 'multiple') this.state.setSelectedKeys('all');
364
+ if (this.selectionMode === "multiple") this.state.setSelectedKeys("all");
329
365
  }
330
366
  /**
331
367
  * Removes all keys from the selection.
332
368
  */ clearSelection() {
333
- if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new $21c847070f1f9569$export$52baac22726c72bf());
369
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $21c847070f1f9569$export$52baac22726c72bf)());
334
370
  }
335
371
  /**
336
372
  * Toggles between select all and an empty selection.
@@ -339,11 +375,11 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
339
375
  else this.selectAll();
340
376
  }
341
377
  select(key, e) {
342
- if (this.selectionMode === 'none') return;
343
- if (this.selectionMode === 'single') {
378
+ if (this.selectionMode === "none") return;
379
+ if (this.selectionMode === "single") {
344
380
  if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
345
381
  else this.replaceSelection(key);
346
- } else if (this.selectionBehavior === 'toggle' || e && (e.pointerType === 'touch' || e.pointerType === 'virtual')) // 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
382
+ } else if (this.selectionBehavior === "toggle" || e && (e.pointerType === "touch" || e.pointerType === "virtual")) // 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
347
383
  this.toggleSelection(key);
348
384
  else this.replaceSelection(key);
349
385
  }
@@ -357,25 +393,25 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
357
393
  for (let key of selection){
358
394
  if (!selectedKeys.has(key)) return false;
359
395
  }
360
- for (let key2 of selectedKeys){
361
- if (!selection.has(key2)) return false;
396
+ for (let key1 of selectedKeys){
397
+ if (!selection.has(key1)) return false;
362
398
  }
363
399
  return true;
364
400
  }
365
401
  canSelectItem(key) {
366
- if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) return false;
402
+ if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key)) return false;
367
403
  let item = this.collection.getItem(key);
368
- if (!item || item.type === 'cell' && !this.allowsCellSelection) return false;
404
+ if (!item || item.type === "cell" && !this.allowsCellSelection) return false;
369
405
  return true;
370
406
  }
371
407
  isDisabled(key) {
372
- return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';
408
+ return this.state.disabledKeys.has(key) && this.state.disabledBehavior === "all";
373
409
  }
374
410
  constructor(collection, state, options){
375
411
  this.collection = collection;
376
412
  this.state = state;
377
- var ref;
378
- this.allowsCellSelection = (ref = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && ref !== void 0 ? ref : false;
413
+ var _options_allowsCellSelection;
414
+ this.allowsCellSelection = (_options_allowsCellSelection = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && _options_allowsCellSelection !== void 0 ? _options_allowsCellSelection : false;
379
415
  this._isSelectAll = null;
380
416
  }
381
417
  }
package/dist/main.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;YAC9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;QACtC,EAAE,GAAG,IAAI,IAAK,IAAI,CAAC,IAAI,KAAK,CAAM,UAAK,IAAI,CAAC,mBAAmB,EAC7D,MAAM,CAAC,KAAK;QAGd,MAAM,CAAC,IAAI;IACb,CAAC;IAED,UAAU,CAAC,GAAQ,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,gBAAgB,KAAK,CAAK;IAClF,CAAC;gBAncW,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"],"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 type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\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 /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\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 selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\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(selectionBehaviorProp);\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 (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\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 disabledBehavior\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 DisabledBehavior,\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 if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\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.canSelectItem(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 get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\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.canSelectItem(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 if (this.canSelectItem(key)) {\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 let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\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.canSelectItem(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 isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;CAUC,GAED,AAMO,MAAM,kDAAkB;IAI7B,YAAY,IAAgC,EAAE,SAAe,EAAE,UAAgB,CAAE;QAC/E,KAAK,CAAC;QACN,IAAI,gBAAgB,2CAAW;YAC7B,IAAI,CAAC,SAAS,GAAG,aAAa,KAAK,SAAS;YAC5C,IAAI,CAAC,UAAU,GAAG,cAAc,KAAK,UAAU;QACjD,OAAO;YACL,IAAI,CAAC,SAAS,GAAG;YACjB,IAAI,CAAC,UAAU,GAAG;QACpB,CAAC;IACH;AACF;;;;ADdA,SAAS,gCAAU,IAAI,EAAE,IAAI,EAAE;IAC7B,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,EACzB,OAAO,KAAK;IAGd,KAAK,IAAI,QAAQ,KAAM;QACrB,IAAI,CAAC,KAAK,GAAG,CAAC,OACZ,OAAO,KAAK;IAEhB;IAEA,OAAO,IAAI;AACb;AAcO,SAAS,0CAA0B,KAAkC,EAA0B;IACpG,IA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CAAC,MACpB,OAAO,KAAK;QAEhB;QAEA,KAAK,IAAI,QAAO,aAAc;YAC5B,IAAI,CAAC,UAAU,GAAG,CAAC,OACjB,OAAO,KAAK;QAEhB;QAEA,OAAO,IAAI;IACb;IAEA,cAAc,GAAQ,EAAE;QACtB,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,KAAK,UAAU,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,MACrE,OAAO,KAAK;QAGd,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QACnC,IAAI,CAAC,QAAS,KAAK,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,mBAAmB,EAC7D,OAAO,KAAK;QAGd,OAAO,IAAI;IACb;IAEA,WAAW,GAAQ,EAAE;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,gBAAgB,KAAK;IAC7E;IAncA,YAAY,UAAqC,EAAE,KAA6B,EAAE,OAAiC,CAAE;QACnH,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,KAAK,GAAG;YACc;QAA3B,IAAI,CAAC,mBAAmB,GAAG,CAAA,+BAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,mBAAmB,cAA5B,0CAAA,+BAAgC,KAAK;QAChE,IAAI,CAAC,YAAY,GAAG,IAAI;IAC1B;AA+bF;","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"],"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 type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\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 /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\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 selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\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(selectionBehaviorProp);\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 (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\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 disabledBehavior\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 DisabledBehavior,\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 if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\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.canSelectItem(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 get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\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.canSelectItem(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 if (this.canSelectItem(key)) {\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 let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\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.canSelectItem(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 isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,8 +1,38 @@
1
1
  import {useRef as $Qsto2$useRef, useState as $Qsto2$useState, useMemo as $Qsto2$useMemo, useEffect as $Qsto2$useEffect} from "react";
2
2
  import {useControlledState as $Qsto2$useControlledState} from "@react-stately/utils";
3
3
 
4
-
5
- class $e40ea825a81a3709$export$52baac22726c72bf extends Set {
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+ /*
26
+ * Copyright 2020 Adobe. All rights reserved.
27
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
28
+ * you may not use this file except in compliance with the License. You may obtain a copy
29
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
30
+ *
31
+ * Unless required by applicable law or agreed to in writing, software distributed under
32
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
33
+ * OF ANY KIND, either express or implied. See the License for the specific language
34
+ * governing permissions and limitations under the License.
35
+ */ class $e40ea825a81a3709$export$52baac22726c72bf extends Set {
6
36
  constructor(keys, anchorKey, currentKey){
7
37
  super(keys);
8
38
  if (keys instanceof $e40ea825a81a3709$export$52baac22726c72bf) {
@@ -25,34 +55,31 @@ function $7af3f5b51489e0b5$var$equalSets(setA, setB) {
25
55
  return true;
26
56
  }
27
57
  function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
28
- let { selectionMode: selectionMode = 'none' , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents , selectionBehavior: selectionBehaviorProp = 'toggle' , disabledBehavior: disabledBehavior = 'all' } = props;
58
+ let { selectionMode: selectionMode = "none" , disallowEmptySelection: disallowEmptySelection , allowDuplicateSelectionEvents: allowDuplicateSelectionEvents , selectionBehavior: selectionBehaviorProp = "toggle" , disabledBehavior: disabledBehavior = "all" } = props;
29
59
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
30
60
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
31
- let isFocusedRef = $Qsto2$useRef(false);
32
- let [, setFocused] = $Qsto2$useState(false);
33
- let focusedKeyRef = $Qsto2$useRef(null);
34
- let childFocusStrategyRef = $Qsto2$useRef(null);
35
- let [, setFocusedKey] = $Qsto2$useState(null);
36
- let selectedKeysProp = $Qsto2$useMemo(()=>$7af3f5b51489e0b5$var$convertSelection(props.selectedKeys)
37
- , [
61
+ let isFocusedRef = (0, $Qsto2$useRef)(false);
62
+ let [, setFocused] = (0, $Qsto2$useState)(false);
63
+ let focusedKeyRef = (0, $Qsto2$useRef)(null);
64
+ let childFocusStrategyRef = (0, $Qsto2$useRef)(null);
65
+ let [, setFocusedKey] = (0, $Qsto2$useState)(null);
66
+ let selectedKeysProp = (0, $Qsto2$useMemo)(()=>$7af3f5b51489e0b5$var$convertSelection(props.selectedKeys), [
38
67
  props.selectedKeys
39
68
  ]);
40
- let defaultSelectedKeys = $Qsto2$useMemo(()=>$7af3f5b51489e0b5$var$convertSelection(props.defaultSelectedKeys, new $e40ea825a81a3709$export$52baac22726c72bf())
41
- , [
69
+ let defaultSelectedKeys = (0, $Qsto2$useMemo)(()=>$7af3f5b51489e0b5$var$convertSelection(props.defaultSelectedKeys, new (0, $e40ea825a81a3709$export$52baac22726c72bf)()), [
42
70
  props.defaultSelectedKeys
43
71
  ]);
44
- let [selectedKeys, setSelectedKeys] = $Qsto2$useControlledState(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
45
- let disabledKeysProp = $Qsto2$useMemo(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set()
46
- , [
72
+ let [selectedKeys, setSelectedKeys] = (0, $Qsto2$useControlledState)(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
73
+ let disabledKeysProp = (0, $Qsto2$useMemo)(()=>props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [
47
74
  props.disabledKeys
48
75
  ]);
49
- let [selectionBehavior, setSelectionBehavior] = $Qsto2$useState(selectionBehaviorProp);
76
+ let [selectionBehavior, setSelectionBehavior] = (0, $Qsto2$useState)(selectionBehaviorProp);
50
77
  // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press
51
78
  // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.
52
- if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) setSelectionBehavior('replace');
79
+ if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0) setSelectionBehavior("replace");
53
80
  // If the selectionBehavior prop changes, update the state as well.
54
- let lastSelectionBehavior = $Qsto2$useRef(selectionBehaviorProp);
55
- $Qsto2$useEffect(()=>{
81
+ let lastSelectionBehavior = (0, $Qsto2$useRef)(selectionBehaviorProp);
82
+ (0, $Qsto2$useEffect)(()=>{
56
83
  if (selectionBehaviorProp !== lastSelectionBehavior.current) {
57
84
  setSelectionBehavior(selectionBehaviorProp);
58
85
  lastSelectionBehavior.current = selectionBehaviorProp;
@@ -78,7 +105,7 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
78
105
  get childFocusStrategy () {
79
106
  return childFocusStrategyRef.current;
80
107
  },
81
- setFocusedKey (k, childFocusStrategy = 'first') {
108
+ setFocusedKey (k, childFocusStrategy = "first") {
82
109
  focusedKeyRef.current = k;
83
110
  childFocusStrategyRef.current = childFocusStrategy;
84
111
  setFocusedKey(k);
@@ -93,11 +120,21 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
93
120
  }
94
121
  function $7af3f5b51489e0b5$var$convertSelection(selection, defaultValue) {
95
122
  if (!selection) return defaultValue;
96
- return selection === 'all' ? 'all' : new $e40ea825a81a3709$export$52baac22726c72bf(selection);
123
+ return selection === "all" ? "all" : new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selection);
97
124
  }
98
125
 
99
126
 
100
-
127
+ /*
128
+ * Copyright 2020 Adobe. All rights reserved.
129
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
130
+ * you may not use this file except in compliance with the License. You may obtain a copy
131
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
132
+ *
133
+ * Unless required by applicable law or agreed to in writing, software distributed under
134
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
135
+ * OF ANY KIND, either express or implied. See the License for the specific language
136
+ * governing permissions and limitations under the License.
137
+ */
101
138
  class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
102
139
  /**
103
140
  * The type of selection that is allowed in the collection.
@@ -145,7 +182,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
145
182
  /**
146
183
  * The currently selected keys in the collection.
147
184
  */ get selectedKeys() {
148
- return this.state.selectedKeys === 'all' ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
185
+ return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
149
186
  }
150
187
  /**
151
188
  * The raw selection value for the collection.
@@ -156,25 +193,24 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
156
193
  /**
157
194
  * Returns whether a key is selected.
158
195
  */ isSelected(key) {
159
- if (this.state.selectionMode === 'none') return false;
196
+ if (this.state.selectionMode === "none") return false;
160
197
  key = this.getKey(key);
161
- return this.state.selectedKeys === 'all' ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
198
+ return this.state.selectedKeys === "all" ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
162
199
  }
163
200
  /**
164
201
  * Whether the selection is empty.
165
202
  */ get isEmpty() {
166
- return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;
203
+ return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
167
204
  }
168
205
  /**
169
206
  * Whether all items in the collection are selected.
170
207
  */ get isSelectAll() {
171
208
  if (this.isEmpty) return false;
172
- if (this.state.selectedKeys === 'all') return true;
209
+ if (this.state.selectedKeys === "all") return true;
173
210
  if (this._isSelectAll != null) return this._isSelectAll;
174
211
  let allKeys = this.getSelectAllKeys();
175
212
  let selectedKeys = this.state.selectedKeys;
176
- this._isSelectAll = allKeys.every((k)=>selectedKeys.has(k)
177
- );
213
+ this._isSelectAll = allKeys.every((k)=>selectedKeys.has(k));
178
214
  return this._isSelectAll;
179
215
  }
180
216
  get firstSelectedKey() {
@@ -202,21 +238,21 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
202
238
  /**
203
239
  * Extends the selection to the given key.
204
240
  */ extendSelection(toKey) {
205
- if (this.selectionMode === 'none') return;
206
- if (this.selectionMode === 'single') {
241
+ if (this.selectionMode === "none") return;
242
+ if (this.selectionMode === "single") {
207
243
  this.replaceSelection(toKey);
208
244
  return;
209
245
  }
210
246
  toKey = this.getKey(toKey);
211
247
  let selection;
212
248
  // Only select the one key if coming from a select all.
213
- if (this.state.selectedKeys === 'all') selection = new $e40ea825a81a3709$export$52baac22726c72bf([
249
+ if (this.state.selectedKeys === "all") selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
214
250
  toKey
215
251
  ], toKey, toKey);
216
252
  else {
217
253
  let selectedKeys = this.state.selectedKeys;
218
254
  let anchorKey = selectedKeys.anchorKey || toKey;
219
- selection = new $e40ea825a81a3709$export$52baac22726c72bf(selectedKeys, anchorKey, toKey);
255
+ selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selectedKeys, anchorKey, toKey);
220
256
  for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey))selection.delete(key);
221
257
  for (let key1 of this.getKeyRange(toKey, anchorKey))if (this.canSelectItem(key1)) selection.add(key1);
222
258
  }
@@ -236,7 +272,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
236
272
  let key = from;
237
273
  while(key){
238
274
  let item = this.collection.getItem(key);
239
- if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
275
+ if (item && item.type === "item" || item.type === "cell" && this.allowsCellSelection) keys.push(key);
240
276
  if (key === to) return keys;
241
277
  key = this.collection.getKeyAfter(key);
242
278
  }
@@ -247,23 +283,23 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
247
283
  if (!item) // ¯\_(ツ)_/¯
248
284
  return key;
249
285
  // If cell selection is allowed, just return the key.
250
- if (item.type === 'cell' && this.allowsCellSelection) return key;
286
+ if (item.type === "cell" && this.allowsCellSelection) return key;
251
287
  // Find a parent item to select
252
- while(item.type !== 'item' && item.parentKey != null)item = this.collection.getItem(item.parentKey);
253
- if (!item || item.type !== 'item') return null;
288
+ while(item.type !== "item" && item.parentKey != null)item = this.collection.getItem(item.parentKey);
289
+ if (!item || item.type !== "item") return null;
254
290
  return item.key;
255
291
  }
256
292
  /**
257
293
  * Toggles whether the given key is selected.
258
294
  */ toggleSelection(key) {
259
- if (this.selectionMode === 'none') return;
260
- if (this.selectionMode === 'single' && !this.isSelected(key)) {
295
+ if (this.selectionMode === "none") return;
296
+ if (this.selectionMode === "single" && !this.isSelected(key)) {
261
297
  this.replaceSelection(key);
262
298
  return;
263
299
  }
264
300
  key = this.getKey(key);
265
301
  if (key == null) return;
266
- let keys = new $e40ea825a81a3709$export$52baac22726c72bf(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
302
+ let keys = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
267
303
  if (keys.has(key)) keys.delete(key);
268
304
  else if (this.canSelectItem(key)) {
269
305
  keys.add(key);
@@ -276,24 +312,24 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
276
312
  /**
277
313
  * Replaces the selection with only the given key.
278
314
  */ replaceSelection(key) {
279
- if (this.selectionMode === 'none') return;
315
+ if (this.selectionMode === "none") return;
280
316
  key = this.getKey(key);
281
317
  if (key == null) return;
282
- let selection = this.canSelectItem(key) ? new $e40ea825a81a3709$export$52baac22726c72bf([
318
+ let selection = this.canSelectItem(key) ? new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
283
319
  key
284
- ], key, key) : new $e40ea825a81a3709$export$52baac22726c72bf();
320
+ ], key, key) : new (0, $e40ea825a81a3709$export$52baac22726c72bf)();
285
321
  this.state.setSelectedKeys(selection);
286
322
  }
287
323
  /**
288
324
  * Replaces the selection with the given keys.
289
325
  */ setSelectedKeys(keys) {
290
- if (this.selectionMode === 'none') return;
291
- let selection = new $e40ea825a81a3709$export$52baac22726c72bf();
326
+ if (this.selectionMode === "none") return;
327
+ let selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)();
292
328
  for (let key of keys){
293
329
  key = this.getKey(key);
294
330
  if (key != null) {
295
331
  selection.add(key);
296
- if (this.selectionMode === 'single') break;
332
+ if (this.selectionMode === "single") break;
297
333
  }
298
334
  }
299
335
  this.state.setSelectedKeys(selection);
@@ -304,9 +340,9 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
304
340
  while(key){
305
341
  if (this.canSelectItem(key)) {
306
342
  let item = this.collection.getItem(key);
307
- if (item.type === 'item') keys.push(key);
343
+ if (item.type === "item") keys.push(key);
308
344
  // Add child keys. If cell selection is allowed, then include item children too.
309
- if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) addKeys([
345
+ if (item.hasChildNodes && (this.allowsCellSelection || item.type !== "item")) addKeys([
310
346
  ...item.childNodes
311
347
  ][0].key);
312
348
  }
@@ -319,12 +355,12 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
319
355
  /**
320
356
  * Selects all items in the collection.
321
357
  */ selectAll() {
322
- if (this.selectionMode === 'multiple') this.state.setSelectedKeys('all');
358
+ if (this.selectionMode === "multiple") this.state.setSelectedKeys("all");
323
359
  }
324
360
  /**
325
361
  * Removes all keys from the selection.
326
362
  */ clearSelection() {
327
- if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new $e40ea825a81a3709$export$52baac22726c72bf());
363
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $e40ea825a81a3709$export$52baac22726c72bf)());
328
364
  }
329
365
  /**
330
366
  * Toggles between select all and an empty selection.
@@ -333,11 +369,11 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
333
369
  else this.selectAll();
334
370
  }
335
371
  select(key, e) {
336
- if (this.selectionMode === 'none') return;
337
- if (this.selectionMode === 'single') {
372
+ if (this.selectionMode === "none") return;
373
+ if (this.selectionMode === "single") {
338
374
  if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
339
375
  else this.replaceSelection(key);
340
- } else if (this.selectionBehavior === 'toggle' || e && (e.pointerType === 'touch' || e.pointerType === 'virtual')) // 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
376
+ } else if (this.selectionBehavior === "toggle" || e && (e.pointerType === "touch" || e.pointerType === "virtual")) // 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
341
377
  this.toggleSelection(key);
342
378
  else this.replaceSelection(key);
343
379
  }
@@ -351,25 +387,25 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
351
387
  for (let key of selection){
352
388
  if (!selectedKeys.has(key)) return false;
353
389
  }
354
- for (let key2 of selectedKeys){
355
- if (!selection.has(key2)) return false;
390
+ for (let key1 of selectedKeys){
391
+ if (!selection.has(key1)) return false;
356
392
  }
357
393
  return true;
358
394
  }
359
395
  canSelectItem(key) {
360
- if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) return false;
396
+ if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key)) return false;
361
397
  let item = this.collection.getItem(key);
362
- if (!item || item.type === 'cell' && !this.allowsCellSelection) return false;
398
+ if (!item || item.type === "cell" && !this.allowsCellSelection) return false;
363
399
  return true;
364
400
  }
365
401
  isDisabled(key) {
366
- return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';
402
+ return this.state.disabledKeys.has(key) && this.state.disabledBehavior === "all";
367
403
  }
368
404
  constructor(collection, state, options){
369
405
  this.collection = collection;
370
406
  this.state = state;
371
- var ref;
372
- this.allowsCellSelection = (ref = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && ref !== void 0 ? ref : false;
407
+ var _options_allowsCellSelection;
408
+ this.allowsCellSelection = (_options_allowsCellSelection = options === null || options === void 0 ? void 0 : options.allowsCellSelection) !== null && _options_allowsCellSelection !== void 0 ? _options_allowsCellSelection : false;
373
409
  this._isSelectAll = null;
374
410
  }
375
411
  }
@@ -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,CAAC,GAAG,CAAC,IAAI,GAChB,MAAM,CAAC,KAAK;IAEhB,CAAC;IAED,MAAM,CAAC,IAAI;AACb,CAAC;SAce,yCAAyB,CAAC,KAAkC,EAA0B,CAAC;IACrG,GAAG,CAAC,CAAC,gBACH,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,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"],"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 type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\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 /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\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 selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\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(selectionBehaviorProp);\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 (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\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 disabledBehavior\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 DisabledBehavior,\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 if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\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.canSelectItem(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 get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\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.canSelectItem(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 if (this.canSelectItem(key)) {\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 let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\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.canSelectItem(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 isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACZA;;;;;;;;;;C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,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,KAAK,GAAG;YACc;QAA3B,IAAI,CAAC,mBAAmB,GAAG,CAAA,+BAAA,oBAAA,qBAAA,KAAA,IAAA,QAAS,mBAAmB,cAA5B,0CAAA,+BAAgC,KAAK;QAChE,IAAI,CAAC,YAAY,GAAG,IAAI;IAC1B;AA+bF;","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"],"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 type {MultipleSelectionStateProps} from './useMultipleSelectionState';\nexport type {FocusState, SingleSelectionState, MultipleSelectionState, MultipleSelectionManager} from './types';\nexport {useMultipleSelectionState} from './useMultipleSelectionState';\nexport {SelectionManager} from './SelectionManager';\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 {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared';\nimport {Key, useEffect, useMemo, useRef, useState} from 'react';\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 /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\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 selectionBehavior: selectionBehaviorProp = 'toggle',\n disabledBehavior = 'all'\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(selectionBehaviorProp);\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 (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) {\n setSelectionBehavior('replace');\n }\n\n // If the selectionBehavior prop changes, update the state as well.\n let lastSelectionBehavior = useRef(selectionBehaviorProp);\n useEffect(() => {\n if (selectionBehaviorProp !== lastSelectionBehavior.current) {\n setSelectionBehavior(selectionBehaviorProp);\n lastSelectionBehavior.current = selectionBehaviorProp;\n }\n }, [selectionBehaviorProp]);\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 disabledBehavior\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 DisabledBehavior,\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 if (key == null || this.collection.getItem(key)) {\n this.state.setFocusedKey(key, childFocusStrategy);\n }\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.canSelectItem(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 get disabledKeys(): Set<Key> {\n return this.state.disabledKeys;\n }\n\n get disabledBehavior(): DisabledBehavior {\n return this.state.disabledBehavior;\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.canSelectItem(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 if (this.canSelectItem(key)) {\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 let selection = this.canSelectItem(key)\n ? new Selection([key], key, key)\n : new Selection();\n\n this.state.setSelectedKeys(selection);\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.canSelectItem(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 isDisabled(key: Key) {\n return this.state.disabledKeys.has(key) && this.state.disabledBehavior === 'all';\n }\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/selection",
3
- "version": "3.11.1",
3
+ "version": "3.11.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -17,10 +17,10 @@
17
17
  "url": "https://github.com/adobe/react-spectrum"
18
18
  },
19
19
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-stately/collections": "^3.5.0",
22
- "@react-stately/utils": "^3.5.1",
23
- "@react-types/shared": "^3.16.0"
20
+ "@react-stately/collections": "^3.5.1",
21
+ "@react-stately/utils": "^3.5.2",
22
+ "@react-types/shared": "^3.16.0",
23
+ "@swc/helpers": "^0.4.14"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
31
+ "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
32
32
  }