@react-stately/selection 3.15.0 → 3.15.1

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.
@@ -23,4 +23,4 @@
23
23
 
24
24
 
25
25
  export {$e40ea825a81a3709$export$52baac22726c72bf as Selection};
26
- //# sourceMappingURL=Selection.mjs.map
26
+ //# sourceMappingURL=Selection.module.js.map
@@ -66,7 +66,7 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
66
66
  /**
67
67
  * The currently selected keys in the collection.
68
68
  */ get selectedKeys() {
69
- return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
69
+ return this.state.selectedKeys === 'all' ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
70
70
  }
71
71
  /**
72
72
  * The raw selection value for the collection.
@@ -77,20 +77,20 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
77
77
  /**
78
78
  * Returns whether a key is selected.
79
79
  */ isSelected(key) {
80
- if (this.state.selectionMode === "none") return false;
80
+ if (this.state.selectionMode === 'none') return false;
81
81
  key = this.getKey(key);
82
- return this.state.selectedKeys === "all" ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
82
+ return this.state.selectedKeys === 'all' ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
83
83
  }
84
84
  /**
85
85
  * Whether the selection is empty.
86
86
  */ get isEmpty() {
87
- return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
87
+ return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;
88
88
  }
89
89
  /**
90
90
  * Whether all items in the collection are selected.
91
91
  */ get isSelectAll() {
92
92
  if (this.isEmpty) return false;
93
- if (this.state.selectedKeys === "all") return true;
93
+ if (this.state.selectedKeys === 'all') return true;
94
94
  if (this._isSelectAll != null) return this._isSelectAll;
95
95
  let allKeys = this.getSelectAllKeys();
96
96
  let selectedKeys = this.state.selectedKeys;
@@ -122,15 +122,15 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
122
122
  /**
123
123
  * Extends the selection to the given key.
124
124
  */ extendSelection(toKey) {
125
- if (this.selectionMode === "none") return;
126
- if (this.selectionMode === "single") {
125
+ if (this.selectionMode === 'none') return;
126
+ if (this.selectionMode === 'single') {
127
127
  this.replaceSelection(toKey);
128
128
  return;
129
129
  }
130
130
  toKey = this.getKey(toKey);
131
131
  let selection;
132
132
  // Only select the one key if coming from a select all.
133
- if (this.state.selectedKeys === "all") selection = new (0, $21c847070f1f9569$exports.Selection)([
133
+ if (this.state.selectedKeys === 'all') selection = new (0, $21c847070f1f9569$exports.Selection)([
134
134
  toKey
135
135
  ], toKey, toKey);
136
136
  else {
@@ -156,7 +156,7 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
156
156
  let key = from;
157
157
  while(key){
158
158
  let item = this.collection.getItem(key);
159
- if (item && item.type === "item" || item.type === "cell" && this.allowsCellSelection) keys.push(key);
159
+ if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
160
160
  if (key === to) return keys;
161
161
  key = this.collection.getKeyAfter(key);
162
162
  }
@@ -167,23 +167,23 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
167
167
  if (!item) // ¯\_(ツ)_/¯
168
168
  return key;
169
169
  // If cell selection is allowed, just return the key.
170
- if (item.type === "cell" && this.allowsCellSelection) return key;
170
+ if (item.type === 'cell' && this.allowsCellSelection) return key;
171
171
  // Find a parent item to select
172
- while(item.type !== "item" && item.parentKey != null)item = this.collection.getItem(item.parentKey);
173
- if (!item || item.type !== "item") return null;
172
+ while(item.type !== 'item' && item.parentKey != null)item = this.collection.getItem(item.parentKey);
173
+ if (!item || item.type !== 'item') return null;
174
174
  return item.key;
175
175
  }
176
176
  /**
177
177
  * Toggles whether the given key is selected.
178
178
  */ toggleSelection(key) {
179
- if (this.selectionMode === "none") return;
180
- if (this.selectionMode === "single" && !this.isSelected(key)) {
179
+ if (this.selectionMode === 'none') return;
180
+ if (this.selectionMode === 'single' && !this.isSelected(key)) {
181
181
  this.replaceSelection(key);
182
182
  return;
183
183
  }
184
184
  key = this.getKey(key);
185
185
  if (key == null) return;
186
- let keys = new (0, $21c847070f1f9569$exports.Selection)(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
186
+ let keys = new (0, $21c847070f1f9569$exports.Selection)(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
187
187
  if (keys.has(key)) keys.delete(key);
188
188
  else if (this.canSelectItem(key)) {
189
189
  keys.add(key);
@@ -196,7 +196,7 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
196
196
  /**
197
197
  * Replaces the selection with only the given key.
198
198
  */ replaceSelection(key) {
199
- if (this.selectionMode === "none") return;
199
+ if (this.selectionMode === 'none') return;
200
200
  key = this.getKey(key);
201
201
  if (key == null) return;
202
202
  let selection = this.canSelectItem(key) ? new (0, $21c847070f1f9569$exports.Selection)([
@@ -207,13 +207,13 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
207
207
  /**
208
208
  * Replaces the selection with the given keys.
209
209
  */ setSelectedKeys(keys) {
210
- if (this.selectionMode === "none") return;
210
+ if (this.selectionMode === 'none') return;
211
211
  let selection = new (0, $21c847070f1f9569$exports.Selection)();
212
212
  for (let key of keys){
213
213
  key = this.getKey(key);
214
214
  if (key != null) {
215
215
  selection.add(key);
216
- if (this.selectionMode === "single") break;
216
+ if (this.selectionMode === 'single') break;
217
217
  }
218
218
  }
219
219
  this.state.setSelectedKeys(selection);
@@ -224,9 +224,9 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
224
224
  while(key){
225
225
  if (this.canSelectItem(key)) {
226
226
  let item = this.collection.getItem(key);
227
- if (item.type === "item") keys.push(key);
227
+ if (item.type === 'item') keys.push(key);
228
228
  // Add child keys. If cell selection is allowed, then include item children too.
229
- if (item.hasChildNodes && (this.allowsCellSelection || item.type !== "item")) addKeys((0, $ia6MY$reactstatelycollections.getFirstItem)((0, $ia6MY$reactstatelycollections.getChildNodes)(item, this.collection)).key);
229
+ if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) addKeys((0, $ia6MY$reactstatelycollections.getFirstItem)((0, $ia6MY$reactstatelycollections.getChildNodes)(item, this.collection)).key);
230
230
  }
231
231
  key = this.collection.getKeyAfter(key);
232
232
  }
@@ -237,12 +237,12 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
237
237
  /**
238
238
  * Selects all items in the collection.
239
239
  */ selectAll() {
240
- if (!this.isSelectAll && this.selectionMode === "multiple") this.state.setSelectedKeys("all");
240
+ if (!this.isSelectAll && this.selectionMode === 'multiple') this.state.setSelectedKeys('all');
241
241
  }
242
242
  /**
243
243
  * Removes all keys from the selection.
244
244
  */ clearSelection() {
245
- if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $21c847070f1f9569$exports.Selection)());
245
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $21c847070f1f9569$exports.Selection)());
246
246
  }
247
247
  /**
248
248
  * Toggles between select all and an empty selection.
@@ -251,11 +251,11 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
251
251
  else this.selectAll();
252
252
  }
253
253
  select(key, e) {
254
- if (this.selectionMode === "none") return;
255
- if (this.selectionMode === "single") {
254
+ if (this.selectionMode === 'none') return;
255
+ if (this.selectionMode === 'single') {
256
256
  if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
257
257
  else this.replaceSelection(key);
258
- } 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
258
+ } 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
259
259
  this.toggleSelection(key);
260
260
  else this.replaceSelection(key);
261
261
  }
@@ -276,14 +276,14 @@ class $8112da6fa5bbc322$export$6c8a5aaad13c9852 {
276
276
  }
277
277
  canSelectItem(key) {
278
278
  var _item_props;
279
- if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key)) return false;
279
+ if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) return false;
280
280
  let item = this.collection.getItem(key);
281
- if (!item || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || item.type === "cell" && !this.allowsCellSelection) return false;
281
+ if (!item || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || item.type === 'cell' && !this.allowsCellSelection) return false;
282
282
  return true;
283
283
  }
284
284
  isDisabled(key) {
285
285
  var _this_collection_getItem_props, _this_collection_getItem;
286
- return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled));
286
+ return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled));
287
287
  }
288
288
  isLink(key) {
289
289
  var _this_collection_getItem_props, _this_collection_getItem;
@@ -60,7 +60,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
60
60
  /**
61
61
  * The currently selected keys in the collection.
62
62
  */ get selectedKeys() {
63
- return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
63
+ return this.state.selectedKeys === 'all' ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
64
64
  }
65
65
  /**
66
66
  * The raw selection value for the collection.
@@ -71,20 +71,20 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
71
71
  /**
72
72
  * Returns whether a key is selected.
73
73
  */ isSelected(key) {
74
- if (this.state.selectionMode === "none") return false;
74
+ if (this.state.selectionMode === 'none') return false;
75
75
  key = this.getKey(key);
76
- return this.state.selectedKeys === "all" ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
76
+ return this.state.selectedKeys === 'all' ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
77
77
  }
78
78
  /**
79
79
  * Whether the selection is empty.
80
80
  */ get isEmpty() {
81
- return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
81
+ return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;
82
82
  }
83
83
  /**
84
84
  * Whether all items in the collection are selected.
85
85
  */ get isSelectAll() {
86
86
  if (this.isEmpty) return false;
87
- if (this.state.selectedKeys === "all") return true;
87
+ if (this.state.selectedKeys === 'all') return true;
88
88
  if (this._isSelectAll != null) return this._isSelectAll;
89
89
  let allKeys = this.getSelectAllKeys();
90
90
  let selectedKeys = this.state.selectedKeys;
@@ -116,15 +116,15 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
116
116
  /**
117
117
  * Extends the selection to the given key.
118
118
  */ extendSelection(toKey) {
119
- if (this.selectionMode === "none") return;
120
- if (this.selectionMode === "single") {
119
+ if (this.selectionMode === 'none') return;
120
+ if (this.selectionMode === 'single') {
121
121
  this.replaceSelection(toKey);
122
122
  return;
123
123
  }
124
124
  toKey = this.getKey(toKey);
125
125
  let selection;
126
126
  // Only select the one key if coming from a select all.
127
- if (this.state.selectedKeys === "all") selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
127
+ if (this.state.selectedKeys === 'all') selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
128
128
  toKey
129
129
  ], toKey, toKey);
130
130
  else {
@@ -150,7 +150,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
150
150
  let key = from;
151
151
  while(key){
152
152
  let item = this.collection.getItem(key);
153
- if (item && item.type === "item" || item.type === "cell" && this.allowsCellSelection) keys.push(key);
153
+ if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
154
154
  if (key === to) return keys;
155
155
  key = this.collection.getKeyAfter(key);
156
156
  }
@@ -161,23 +161,23 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
161
161
  if (!item) // ¯\_(ツ)_/¯
162
162
  return key;
163
163
  // If cell selection is allowed, just return the key.
164
- if (item.type === "cell" && this.allowsCellSelection) return key;
164
+ if (item.type === 'cell' && this.allowsCellSelection) return key;
165
165
  // Find a parent item to select
166
- while(item.type !== "item" && item.parentKey != null)item = this.collection.getItem(item.parentKey);
167
- if (!item || item.type !== "item") return null;
166
+ while(item.type !== 'item' && item.parentKey != null)item = this.collection.getItem(item.parentKey);
167
+ if (!item || item.type !== 'item') return null;
168
168
  return item.key;
169
169
  }
170
170
  /**
171
171
  * Toggles whether the given key is selected.
172
172
  */ toggleSelection(key) {
173
- if (this.selectionMode === "none") return;
174
- if (this.selectionMode === "single" && !this.isSelected(key)) {
173
+ if (this.selectionMode === 'none') return;
174
+ if (this.selectionMode === 'single' && !this.isSelected(key)) {
175
175
  this.replaceSelection(key);
176
176
  return;
177
177
  }
178
178
  key = this.getKey(key);
179
179
  if (key == null) return;
180
- let keys = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
180
+ let keys = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
181
181
  if (keys.has(key)) keys.delete(key);
182
182
  else if (this.canSelectItem(key)) {
183
183
  keys.add(key);
@@ -190,7 +190,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
190
190
  /**
191
191
  * Replaces the selection with only the given key.
192
192
  */ replaceSelection(key) {
193
- if (this.selectionMode === "none") return;
193
+ if (this.selectionMode === 'none') return;
194
194
  key = this.getKey(key);
195
195
  if (key == null) return;
196
196
  let selection = this.canSelectItem(key) ? new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
@@ -201,13 +201,13 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
201
201
  /**
202
202
  * Replaces the selection with the given keys.
203
203
  */ setSelectedKeys(keys) {
204
- if (this.selectionMode === "none") return;
204
+ if (this.selectionMode === 'none') return;
205
205
  let selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)();
206
206
  for (let key of keys){
207
207
  key = this.getKey(key);
208
208
  if (key != null) {
209
209
  selection.add(key);
210
- if (this.selectionMode === "single") break;
210
+ if (this.selectionMode === 'single') break;
211
211
  }
212
212
  }
213
213
  this.state.setSelectedKeys(selection);
@@ -218,9 +218,9 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
218
218
  while(key){
219
219
  if (this.canSelectItem(key)) {
220
220
  let item = this.collection.getItem(key);
221
- if (item.type === "item") keys.push(key);
221
+ if (item.type === 'item') keys.push(key);
222
222
  // Add child keys. If cell selection is allowed, then include item children too.
223
- if (item.hasChildNodes && (this.allowsCellSelection || item.type !== "item")) addKeys((0, $jkhUT$getFirstItem)((0, $jkhUT$getChildNodes)(item, this.collection)).key);
223
+ if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) addKeys((0, $jkhUT$getFirstItem)((0, $jkhUT$getChildNodes)(item, this.collection)).key);
224
224
  }
225
225
  key = this.collection.getKeyAfter(key);
226
226
  }
@@ -231,12 +231,12 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
231
231
  /**
232
232
  * Selects all items in the collection.
233
233
  */ selectAll() {
234
- if (!this.isSelectAll && this.selectionMode === "multiple") this.state.setSelectedKeys("all");
234
+ if (!this.isSelectAll && this.selectionMode === 'multiple') this.state.setSelectedKeys('all');
235
235
  }
236
236
  /**
237
237
  * Removes all keys from the selection.
238
238
  */ clearSelection() {
239
- if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $e40ea825a81a3709$export$52baac22726c72bf)());
239
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $e40ea825a81a3709$export$52baac22726c72bf)());
240
240
  }
241
241
  /**
242
242
  * Toggles between select all and an empty selection.
@@ -245,11 +245,11 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
245
245
  else this.selectAll();
246
246
  }
247
247
  select(key, e) {
248
- if (this.selectionMode === "none") return;
249
- if (this.selectionMode === "single") {
248
+ if (this.selectionMode === 'none') return;
249
+ if (this.selectionMode === 'single') {
250
250
  if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
251
251
  else this.replaceSelection(key);
252
- } 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
252
+ } 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
253
253
  this.toggleSelection(key);
254
254
  else this.replaceSelection(key);
255
255
  }
@@ -270,14 +270,14 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
270
270
  }
271
271
  canSelectItem(key) {
272
272
  var _item_props;
273
- if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key)) return false;
273
+ if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) return false;
274
274
  let item = this.collection.getItem(key);
275
- if (!item || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || item.type === "cell" && !this.allowsCellSelection) return false;
275
+ if (!item || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || item.type === 'cell' && !this.allowsCellSelection) return false;
276
276
  return true;
277
277
  }
278
278
  isDisabled(key) {
279
279
  var _this_collection_getItem_props, _this_collection_getItem;
280
- return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled));
280
+ return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled));
281
281
  }
282
282
  isLink(key) {
283
283
  var _this_collection_getItem_props, _this_collection_getItem;
@@ -298,4 +298,4 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
298
298
 
299
299
 
300
300
  export {$d496c0a20b6e58ec$export$6c8a5aaad13c9852 as SelectionManager};
301
- //# sourceMappingURL=SelectionManager.mjs.map
301
+ //# sourceMappingURL=SelectionManager.module.js.map
@@ -60,7 +60,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
60
60
  /**
61
61
  * The currently selected keys in the collection.
62
62
  */ get selectedKeys() {
63
- return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
63
+ return this.state.selectedKeys === 'all' ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
64
64
  }
65
65
  /**
66
66
  * The raw selection value for the collection.
@@ -71,20 +71,20 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
71
71
  /**
72
72
  * Returns whether a key is selected.
73
73
  */ isSelected(key) {
74
- if (this.state.selectionMode === "none") return false;
74
+ if (this.state.selectionMode === 'none') return false;
75
75
  key = this.getKey(key);
76
- return this.state.selectedKeys === "all" ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
76
+ return this.state.selectedKeys === 'all' ? this.canSelectItem(key) : this.state.selectedKeys.has(key);
77
77
  }
78
78
  /**
79
79
  * Whether the selection is empty.
80
80
  */ get isEmpty() {
81
- return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
81
+ return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;
82
82
  }
83
83
  /**
84
84
  * Whether all items in the collection are selected.
85
85
  */ get isSelectAll() {
86
86
  if (this.isEmpty) return false;
87
- if (this.state.selectedKeys === "all") return true;
87
+ if (this.state.selectedKeys === 'all') return true;
88
88
  if (this._isSelectAll != null) return this._isSelectAll;
89
89
  let allKeys = this.getSelectAllKeys();
90
90
  let selectedKeys = this.state.selectedKeys;
@@ -116,15 +116,15 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
116
116
  /**
117
117
  * Extends the selection to the given key.
118
118
  */ extendSelection(toKey) {
119
- if (this.selectionMode === "none") return;
120
- if (this.selectionMode === "single") {
119
+ if (this.selectionMode === 'none') return;
120
+ if (this.selectionMode === 'single') {
121
121
  this.replaceSelection(toKey);
122
122
  return;
123
123
  }
124
124
  toKey = this.getKey(toKey);
125
125
  let selection;
126
126
  // Only select the one key if coming from a select all.
127
- if (this.state.selectedKeys === "all") selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
127
+ if (this.state.selectedKeys === 'all') selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
128
128
  toKey
129
129
  ], toKey, toKey);
130
130
  else {
@@ -150,7 +150,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
150
150
  let key = from;
151
151
  while(key){
152
152
  let item = this.collection.getItem(key);
153
- if (item && item.type === "item" || item.type === "cell" && this.allowsCellSelection) keys.push(key);
153
+ if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key);
154
154
  if (key === to) return keys;
155
155
  key = this.collection.getKeyAfter(key);
156
156
  }
@@ -161,23 +161,23 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
161
161
  if (!item) // ¯\_(ツ)_/¯
162
162
  return key;
163
163
  // If cell selection is allowed, just return the key.
164
- if (item.type === "cell" && this.allowsCellSelection) return key;
164
+ if (item.type === 'cell' && this.allowsCellSelection) return key;
165
165
  // Find a parent item to select
166
- while(item.type !== "item" && item.parentKey != null)item = this.collection.getItem(item.parentKey);
167
- if (!item || item.type !== "item") return null;
166
+ while(item.type !== 'item' && item.parentKey != null)item = this.collection.getItem(item.parentKey);
167
+ if (!item || item.type !== 'item') return null;
168
168
  return item.key;
169
169
  }
170
170
  /**
171
171
  * Toggles whether the given key is selected.
172
172
  */ toggleSelection(key) {
173
- if (this.selectionMode === "none") return;
174
- if (this.selectionMode === "single" && !this.isSelected(key)) {
173
+ if (this.selectionMode === 'none') return;
174
+ if (this.selectionMode === 'single' && !this.isSelected(key)) {
175
175
  this.replaceSelection(key);
176
176
  return;
177
177
  }
178
178
  key = this.getKey(key);
179
179
  if (key == null) return;
180
- let keys = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
180
+ let keys = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
181
181
  if (keys.has(key)) keys.delete(key);
182
182
  else if (this.canSelectItem(key)) {
183
183
  keys.add(key);
@@ -190,7 +190,7 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
190
190
  /**
191
191
  * Replaces the selection with only the given key.
192
192
  */ replaceSelection(key) {
193
- if (this.selectionMode === "none") return;
193
+ if (this.selectionMode === 'none') return;
194
194
  key = this.getKey(key);
195
195
  if (key == null) return;
196
196
  let selection = this.canSelectItem(key) ? new (0, $e40ea825a81a3709$export$52baac22726c72bf)([
@@ -201,13 +201,13 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
201
201
  /**
202
202
  * Replaces the selection with the given keys.
203
203
  */ setSelectedKeys(keys) {
204
- if (this.selectionMode === "none") return;
204
+ if (this.selectionMode === 'none') return;
205
205
  let selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)();
206
206
  for (let key of keys){
207
207
  key = this.getKey(key);
208
208
  if (key != null) {
209
209
  selection.add(key);
210
- if (this.selectionMode === "single") break;
210
+ if (this.selectionMode === 'single') break;
211
211
  }
212
212
  }
213
213
  this.state.setSelectedKeys(selection);
@@ -218,9 +218,9 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
218
218
  while(key){
219
219
  if (this.canSelectItem(key)) {
220
220
  let item = this.collection.getItem(key);
221
- if (item.type === "item") keys.push(key);
221
+ if (item.type === 'item') keys.push(key);
222
222
  // Add child keys. If cell selection is allowed, then include item children too.
223
- if (item.hasChildNodes && (this.allowsCellSelection || item.type !== "item")) addKeys((0, $jkhUT$getFirstItem)((0, $jkhUT$getChildNodes)(item, this.collection)).key);
223
+ if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) addKeys((0, $jkhUT$getFirstItem)((0, $jkhUT$getChildNodes)(item, this.collection)).key);
224
224
  }
225
225
  key = this.collection.getKeyAfter(key);
226
226
  }
@@ -231,12 +231,12 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
231
231
  /**
232
232
  * Selects all items in the collection.
233
233
  */ selectAll() {
234
- if (!this.isSelectAll && this.selectionMode === "multiple") this.state.setSelectedKeys("all");
234
+ if (!this.isSelectAll && this.selectionMode === 'multiple') this.state.setSelectedKeys('all');
235
235
  }
236
236
  /**
237
237
  * Removes all keys from the selection.
238
238
  */ clearSelection() {
239
- if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $e40ea825a81a3709$export$52baac22726c72bf)());
239
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $e40ea825a81a3709$export$52baac22726c72bf)());
240
240
  }
241
241
  /**
242
242
  * Toggles between select all and an empty selection.
@@ -245,11 +245,11 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
245
245
  else this.selectAll();
246
246
  }
247
247
  select(key, e) {
248
- if (this.selectionMode === "none") return;
249
- if (this.selectionMode === "single") {
248
+ if (this.selectionMode === 'none') return;
249
+ if (this.selectionMode === 'single') {
250
250
  if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
251
251
  else this.replaceSelection(key);
252
- } 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
252
+ } 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
253
253
  this.toggleSelection(key);
254
254
  else this.replaceSelection(key);
255
255
  }
@@ -270,14 +270,14 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
270
270
  }
271
271
  canSelectItem(key) {
272
272
  var _item_props;
273
- if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key)) return false;
273
+ if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) return false;
274
274
  let item = this.collection.getItem(key);
275
- if (!item || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || item.type === "cell" && !this.allowsCellSelection) return false;
275
+ if (!item || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.isDisabled) || item.type === 'cell' && !this.allowsCellSelection) return false;
276
276
  return true;
277
277
  }
278
278
  isDisabled(key) {
279
279
  var _this_collection_getItem_props, _this_collection_getItem;
280
- return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled));
280
+ return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled));
281
281
  }
282
282
  isLink(key) {
283
283
  var _this_collection_getItem_props, _this_collection_getItem;
@@ -29,7 +29,7 @@ function $1adc19da2128bba9$var$equalSets(setA, setB) {
29
29
  return true;
30
30
  }
31
31
  function $1adc19da2128bba9$export$253fe78d46329472(props) {
32
- let { selectionMode: selectionMode = "none", disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior: disabledBehavior = "all" } = props;
32
+ let { selectionMode: selectionMode = 'none', disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = 'toggle', disabledBehavior: disabledBehavior = 'all' } = props;
33
33
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
34
34
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
35
35
  let isFocusedRef = (0, $byFPT$react.useRef)(false);
@@ -50,7 +50,7 @@ function $1adc19da2128bba9$export$253fe78d46329472(props) {
50
50
  let [selectionBehavior, setSelectionBehavior] = (0, $byFPT$react.useState)(selectionBehaviorProp);
51
51
  // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press
52
52
  // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.
53
- if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0) setSelectionBehavior("replace");
53
+ if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) setSelectionBehavior('replace');
54
54
  // If the selectionBehavior prop changes, update the state as well.
55
55
  let lastSelectionBehavior = (0, $byFPT$react.useRef)(selectionBehaviorProp);
56
56
  (0, $byFPT$react.useEffect)(()=>{
@@ -79,7 +79,7 @@ function $1adc19da2128bba9$export$253fe78d46329472(props) {
79
79
  get childFocusStrategy () {
80
80
  return childFocusStrategyRef.current;
81
81
  },
82
- setFocusedKey (k, childFocusStrategy = "first") {
82
+ setFocusedKey (k, childFocusStrategy = 'first') {
83
83
  focusedKeyRef.current = k;
84
84
  childFocusStrategyRef.current = childFocusStrategy;
85
85
  setFocusedKey(k);
@@ -94,7 +94,7 @@ function $1adc19da2128bba9$export$253fe78d46329472(props) {
94
94
  }
95
95
  function $1adc19da2128bba9$var$convertSelection(selection, defaultValue) {
96
96
  if (!selection) return defaultValue;
97
- return selection === "all" ? "all" : new (0, $21c847070f1f9569$exports.Selection)(selection);
97
+ return selection === 'all' ? 'all' : new (0, $21c847070f1f9569$exports.Selection)(selection);
98
98
  }
99
99
 
100
100
 
@@ -23,7 +23,7 @@ function $7af3f5b51489e0b5$var$equalSets(setA, setB) {
23
23
  return true;
24
24
  }
25
25
  function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
26
- let { selectionMode: selectionMode = "none", disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior: disabledBehavior = "all" } = props;
26
+ let { selectionMode: selectionMode = 'none', disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = 'toggle', disabledBehavior: disabledBehavior = 'all' } = props;
27
27
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
28
28
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
29
29
  let isFocusedRef = (0, $6tM1y$useRef)(false);
@@ -44,7 +44,7 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
44
44
  let [selectionBehavior, setSelectionBehavior] = (0, $6tM1y$useState)(selectionBehaviorProp);
45
45
  // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press
46
46
  // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.
47
- if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0) setSelectionBehavior("replace");
47
+ if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) setSelectionBehavior('replace');
48
48
  // If the selectionBehavior prop changes, update the state as well.
49
49
  let lastSelectionBehavior = (0, $6tM1y$useRef)(selectionBehaviorProp);
50
50
  (0, $6tM1y$useEffect)(()=>{
@@ -73,7 +73,7 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
73
73
  get childFocusStrategy () {
74
74
  return childFocusStrategyRef.current;
75
75
  },
76
- setFocusedKey (k, childFocusStrategy = "first") {
76
+ setFocusedKey (k, childFocusStrategy = 'first') {
77
77
  focusedKeyRef.current = k;
78
78
  childFocusStrategyRef.current = childFocusStrategy;
79
79
  setFocusedKey(k);
@@ -88,9 +88,9 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
88
88
  }
89
89
  function $7af3f5b51489e0b5$var$convertSelection(selection, defaultValue) {
90
90
  if (!selection) return defaultValue;
91
- return selection === "all" ? "all" : new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selection);
91
+ return selection === 'all' ? 'all' : new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selection);
92
92
  }
93
93
 
94
94
 
95
95
  export {$7af3f5b51489e0b5$export$253fe78d46329472 as useMultipleSelectionState};
96
- //# sourceMappingURL=useMultipleSelectionState.mjs.map
96
+ //# sourceMappingURL=useMultipleSelectionState.module.js.map
@@ -23,7 +23,7 @@ function $7af3f5b51489e0b5$var$equalSets(setA, setB) {
23
23
  return true;
24
24
  }
25
25
  function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
26
- let { selectionMode: selectionMode = "none", disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior: disabledBehavior = "all" } = props;
26
+ let { selectionMode: selectionMode = 'none', disallowEmptySelection: disallowEmptySelection, allowDuplicateSelectionEvents: allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = 'toggle', disabledBehavior: disabledBehavior = 'all' } = props;
27
27
  // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
28
28
  // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
29
29
  let isFocusedRef = (0, $6tM1y$useRef)(false);
@@ -44,7 +44,7 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
44
44
  let [selectionBehavior, setSelectionBehavior] = (0, $6tM1y$useState)(selectionBehaviorProp);
45
45
  // If the selectionBehavior prop is set to replace, but the current state is toggle (e.g. due to long press
46
46
  // to enter selection mode on touch), and the selection becomes empty, reset the selection behavior.
47
- if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0) setSelectionBehavior("replace");
47
+ if (selectionBehaviorProp === 'replace' && selectionBehavior === 'toggle' && typeof selectedKeys === 'object' && selectedKeys.size === 0) setSelectionBehavior('replace');
48
48
  // If the selectionBehavior prop changes, update the state as well.
49
49
  let lastSelectionBehavior = (0, $6tM1y$useRef)(selectionBehaviorProp);
50
50
  (0, $6tM1y$useEffect)(()=>{
@@ -73,7 +73,7 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
73
73
  get childFocusStrategy () {
74
74
  return childFocusStrategyRef.current;
75
75
  },
76
- setFocusedKey (k, childFocusStrategy = "first") {
76
+ setFocusedKey (k, childFocusStrategy = 'first') {
77
77
  focusedKeyRef.current = k;
78
78
  childFocusStrategyRef.current = childFocusStrategy;
79
79
  setFocusedKey(k);
@@ -88,7 +88,7 @@ function $7af3f5b51489e0b5$export$253fe78d46329472(props) {
88
88
  }
89
89
  function $7af3f5b51489e0b5$var$convertSelection(selection, defaultValue) {
90
90
  if (!selection) return defaultValue;
91
- return selection === "all" ? "all" : new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selection);
91
+ return selection === 'all' ? 'all' : new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selection);
92
92
  }
93
93
 
94
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/selection",
3
- "version": "3.15.0",
3
+ "version": "3.15.1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,9 +22,9 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/collections": "^3.10.6",
26
- "@react-stately/utils": "^3.10.0",
27
- "@react-types/shared": "^3.23.0",
25
+ "@react-stately/collections": "^3.10.7",
26
+ "@react-stately/utils": "^3.10.1",
27
+ "@react-types/shared": "^3.23.1",
28
28
  "@swc/helpers": "^0.5.0"
29
29
  },
30
30
  "peerDependencies": {
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
36
+ "gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
37
37
  }