@react-aria/selection 3.13.1 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/import.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {useRef as $eCAIO$useRef, useEffect as $eCAIO$useEffect, useMemo as $eCAIO$useMemo} from "react";
2
2
  import {getFocusableTreeWalker as $eCAIO$getFocusableTreeWalker, focusSafely as $eCAIO$focusSafely} from "@react-aria/focus";
3
- import {focusWithoutScrolling as $eCAIO$focusWithoutScrolling, useEvent as $eCAIO$useEvent, scrollIntoView as $eCAIO$scrollIntoView, scrollIntoViewport as $eCAIO$scrollIntoViewport, mergeProps as $eCAIO$mergeProps, isAppleDevice as $eCAIO$isAppleDevice, isMac as $eCAIO$isMac} from "@react-aria/utils";
3
+ import {focusWithoutScrolling as $eCAIO$focusWithoutScrolling, useEvent as $eCAIO$useEvent, scrollIntoView as $eCAIO$scrollIntoView, scrollIntoViewport as $eCAIO$scrollIntoViewport, mergeProps as $eCAIO$mergeProps, isAppleDevice as $eCAIO$isAppleDevice, isMac as $eCAIO$isMac, isScrollable as $eCAIO$isScrollable} from "@react-aria/utils";
4
4
  import {getInteractionModality as $eCAIO$getInteractionModality, usePress as $eCAIO$usePress, useLongPress as $eCAIO$useLongPress} from "@react-aria/interactions";
5
5
  import {useLocale as $eCAIO$useLocale, useCollator as $eCAIO$useCollator} from "@react-aria/i18n";
6
6
 
@@ -74,7 +74,7 @@ function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
74
74
  }).current;
75
75
  let onKeyDown = (e)=>{
76
76
  let character = $fb3050f43d946246$var$getStringForKey(e.key);
77
- if (!character || e.ctrlKey || e.metaKey) return;
77
+ if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target)) return;
78
78
  // Do not propagate the Spacebar event if it's meant to be part of the search.
79
79
  // When we time out, the search term becomes empty, hence the check on length.
80
80
  // Trimming is to account for the case of pressing the Spacebar more than once,
@@ -154,15 +154,19 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
154
154
  break;
155
155
  case "ArrowLeft":
156
156
  if (delegate.getKeyLeftOf) {
157
+ var _delegate_getFirstKey2, _delegate_getLastKey2;
157
158
  e.preventDefault();
158
159
  let nextKey2 = delegate.getKeyLeftOf(manager.focusedKey);
160
+ if (nextKey2 == null && shouldFocusWrap) nextKey2 = direction === "rtl" ? (_delegate_getFirstKey2 = delegate.getFirstKey) === null || _delegate_getFirstKey2 === void 0 ? void 0 : _delegate_getFirstKey2.call(delegate, manager.focusedKey) : (_delegate_getLastKey2 = delegate.getLastKey) === null || _delegate_getLastKey2 === void 0 ? void 0 : _delegate_getLastKey2.call(delegate, manager.focusedKey);
159
161
  navigateToKey(nextKey2, direction === "rtl" ? "first" : "last");
160
162
  }
161
163
  break;
162
164
  case "ArrowRight":
163
165
  if (delegate.getKeyRightOf) {
166
+ var _delegate_getLastKey3, _delegate_getFirstKey3;
164
167
  e.preventDefault();
165
168
  let nextKey3 = delegate.getKeyRightOf(manager.focusedKey);
169
+ if (nextKey3 == null && shouldFocusWrap) nextKey3 = direction === "rtl" ? (_delegate_getLastKey3 = delegate.getLastKey) === null || _delegate_getLastKey3 === void 0 ? void 0 : _delegate_getLastKey3.call(delegate, manager.focusedKey) : (_delegate_getFirstKey3 = delegate.getFirstKey) === null || _delegate_getFirstKey3 === void 0 ? void 0 : _delegate_getFirstKey3.call(delegate, manager.focusedKey);
166
170
  navigateToKey(nextKey3, direction === "rtl" ? "last" : "first");
167
171
  }
168
172
  break;
@@ -271,10 +275,12 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
271
275
  // Restore the scroll position to what it was before.
272
276
  scrollRef.current.scrollTop = scrollPos.current.top;
273
277
  scrollRef.current.scrollLeft = scrollPos.current.left;
278
+ }
279
+ if (!isVirtualized && manager.focusedKey != null) {
274
280
  // Refocus and scroll the focused item into view if it exists within the scrollable region.
275
281
  let element = scrollRef.current.querySelector(`[data-key="${manager.focusedKey}"]`);
276
282
  if (element) {
277
- // This prevents a flash of focus on the first/last element in the collection
283
+ // This prevents a flash of focus on the first/last element in the collection, or the collection itself.
278
284
  (0, $eCAIO$focusWithoutScrolling)(element);
279
285
  (0, $eCAIO$scrollIntoView)(scrollRef.current, element);
280
286
  }
@@ -385,9 +391,9 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
385
391
  // Focus the associated DOM node when this item becomes the focusedKey
386
392
  (0, $eCAIO$useEffect)(()=>{
387
393
  let isFocused = key === manager.focusedKey;
388
- if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
394
+ if (isFocused && manager.isFocused && !shouldUseVirtualFocus) {
389
395
  if (focus) focus();
390
- else (0, $eCAIO$focusSafely)(ref.current);
396
+ else if (document.activeElement !== ref.current) (0, $eCAIO$focusSafely)(ref.current);
391
397
  }
392
398
  // eslint-disable-next-line react-hooks/exhaustive-deps
393
399
  }, [
@@ -511,6 +517,7 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
511
517
  }),
512
518
  isPressed: isPressed,
513
519
  isSelected: manager.isSelected(key),
520
+ isFocused: manager.isFocused && manager.focusedKey === key,
514
521
  isDisabled: isDisabled,
515
522
  allowsSelection: allowsSelection,
516
523
  hasAction: hasAction
@@ -547,7 +554,8 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
547
554
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
548
555
  * OF ANY KIND, either express or implied. See the License for the specific language
549
556
  * governing permissions and limitations under the License.
550
- */ class $2a25aae57d74318e$export$a05409b8bb224a5a {
557
+ */
558
+ class $2a25aae57d74318e$export$a05409b8bb224a5a {
551
559
  getKeyBelow(key) {
552
560
  key = this.collection.getKeyAfter(key);
553
561
  while(key != null){
@@ -555,6 +563,7 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
555
563
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
556
564
  key = this.collection.getKeyAfter(key);
557
565
  }
566
+ return null;
558
567
  }
559
568
  getKeyAbove(key) {
560
569
  key = this.collection.getKeyBefore(key);
@@ -563,6 +572,15 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
563
572
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
564
573
  key = this.collection.getKeyBefore(key);
565
574
  }
575
+ return null;
576
+ }
577
+ getKeyRightOf(key) {
578
+ if (this.orientation === "horizontal") return this.direction === "rtl" ? this.getKeyAbove(key) : this.getKeyBelow(key);
579
+ return null;
580
+ }
581
+ getKeyLeftOf(key) {
582
+ if (this.orientation === "horizontal") return this.direction === "rtl" ? this.getKeyBelow(key) : this.getKeyAbove(key);
583
+ return null;
566
584
  }
567
585
  getFirstKey() {
568
586
  let key = this.collection.getFirstKey();
@@ -571,6 +589,7 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
571
589
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
572
590
  key = this.collection.getKeyAfter(key);
573
591
  }
592
+ return null;
574
593
  }
575
594
  getLastKey() {
576
595
  let key = this.collection.getLastKey();
@@ -579,6 +598,7 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
579
598
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
580
599
  key = this.collection.getKeyBefore(key);
581
600
  }
601
+ return null;
582
602
  }
583
603
  getItem(key) {
584
604
  return this.ref.current.querySelector(`[data-key="${key}"]`);
@@ -587,23 +607,53 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
587
607
  let menu = this.ref.current;
588
608
  let item = this.getItem(key);
589
609
  if (!item) return null;
590
- let pageY = Math.max(0, item.offsetTop + item.offsetHeight - menu.offsetHeight);
591
- while(item && item.offsetTop > pageY){
592
- key = this.getKeyAbove(key);
593
- item = this.getItem(key);
610
+ if (!(0, $eCAIO$isScrollable)(menu)) return this.getFirstKey();
611
+ let containerRect = menu.getBoundingClientRect();
612
+ let itemRect = item.getBoundingClientRect();
613
+ if (this.orientation === "horizontal") {
614
+ let containerX = containerRect.x - menu.scrollLeft;
615
+ let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
616
+ while(item && itemRect.x - containerX > pageX){
617
+ key = this.getKeyAbove(key);
618
+ item = key == null ? null : this.getItem(key);
619
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
620
+ }
621
+ } else {
622
+ let containerY = containerRect.y - menu.scrollTop;
623
+ let pageY = Math.max(0, itemRect.y - containerY + itemRect.height - containerRect.height);
624
+ while(item && itemRect.y - containerY > pageY){
625
+ key = this.getKeyAbove(key);
626
+ item = key == null ? null : this.getItem(key);
627
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
628
+ }
594
629
  }
595
- return key;
630
+ return key !== null && key !== void 0 ? key : this.getFirstKey();
596
631
  }
597
632
  getKeyPageBelow(key) {
598
633
  let menu = this.ref.current;
599
634
  let item = this.getItem(key);
600
635
  if (!item) return null;
601
- let pageY = Math.min(menu.scrollHeight, item.offsetTop - item.offsetHeight + menu.offsetHeight);
602
- while(item && item.offsetTop < pageY){
603
- key = this.getKeyBelow(key);
604
- item = this.getItem(key);
636
+ if (!(0, $eCAIO$isScrollable)(menu)) return this.getLastKey();
637
+ let containerRect = menu.getBoundingClientRect();
638
+ let itemRect = item.getBoundingClientRect();
639
+ if (this.orientation === "horizontal") {
640
+ let containerX = containerRect.x - menu.scrollLeft;
641
+ let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
642
+ while(item && itemRect.x - containerX < pageX){
643
+ key = this.getKeyBelow(key);
644
+ item = key == null ? null : this.getItem(key);
645
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
646
+ }
647
+ } else {
648
+ let containerY = containerRect.y - menu.scrollTop;
649
+ let pageY = Math.min(menu.scrollHeight, itemRect.y - containerY - itemRect.height + containerRect.height);
650
+ while(item && itemRect.y - containerY < pageY){
651
+ key = this.getKeyBelow(key);
652
+ item = key == null ? null : this.getItem(key);
653
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
654
+ }
605
655
  }
606
- return key;
656
+ return key !== null && key !== void 0 ? key : this.getLastKey();
607
657
  }
608
658
  getKeyForSearch(search, fromKey) {
609
659
  if (!this.collator) return null;
@@ -617,11 +667,20 @@ function $880e95eb8b93ba9a$var$isSelectionKey() {
617
667
  }
618
668
  return null;
619
669
  }
620
- constructor(collection, disabledKeys, ref, collator){
621
- this.collection = collection;
622
- this.disabledKeys = disabledKeys;
623
- this.ref = ref;
624
- this.collator = collator;
670
+ constructor(...args){
671
+ if (args.length === 1) {
672
+ let opts = args[0];
673
+ this.collection = opts.collection;
674
+ this.ref = opts.ref;
675
+ this.disabledKeys = opts.disabledKeys || new Set();
676
+ this.orientation = opts.orientation;
677
+ this.direction = opts.direction;
678
+ } else {
679
+ this.collection = args[0];
680
+ this.disabledKeys = args[1];
681
+ this.ref = args[2];
682
+ this.collator = args[3];
683
+ }
625
684
  }
626
685
  }
627
686
 
package/dist/main.js CHANGED
@@ -83,7 +83,7 @@ function $a1189052f36475e8$export$e32c88dfddc6e1d8(options) {
83
83
  }).current;
84
84
  let onKeyDown = (e)=>{
85
85
  let character = $a1189052f36475e8$var$getStringForKey(e.key);
86
- if (!character || e.ctrlKey || e.metaKey) return;
86
+ if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target)) return;
87
87
  // Do not propagate the Spacebar event if it's meant to be part of the search.
88
88
  // When we time out, the search term becomes empty, hence the check on length.
89
89
  // Trimming is to account for the case of pressing the Spacebar more than once,
@@ -163,15 +163,19 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
163
163
  break;
164
164
  case "ArrowLeft":
165
165
  if (delegate.getKeyLeftOf) {
166
+ var _delegate_getFirstKey2, _delegate_getLastKey2;
166
167
  e.preventDefault();
167
168
  let nextKey2 = delegate.getKeyLeftOf(manager.focusedKey);
169
+ if (nextKey2 == null && shouldFocusWrap) nextKey2 = direction === "rtl" ? (_delegate_getFirstKey2 = delegate.getFirstKey) === null || _delegate_getFirstKey2 === void 0 ? void 0 : _delegate_getFirstKey2.call(delegate, manager.focusedKey) : (_delegate_getLastKey2 = delegate.getLastKey) === null || _delegate_getLastKey2 === void 0 ? void 0 : _delegate_getLastKey2.call(delegate, manager.focusedKey);
168
170
  navigateToKey(nextKey2, direction === "rtl" ? "first" : "last");
169
171
  }
170
172
  break;
171
173
  case "ArrowRight":
172
174
  if (delegate.getKeyRightOf) {
175
+ var _delegate_getLastKey3, _delegate_getFirstKey3;
173
176
  e.preventDefault();
174
177
  let nextKey3 = delegate.getKeyRightOf(manager.focusedKey);
178
+ if (nextKey3 == null && shouldFocusWrap) nextKey3 = direction === "rtl" ? (_delegate_getLastKey3 = delegate.getLastKey) === null || _delegate_getLastKey3 === void 0 ? void 0 : _delegate_getLastKey3.call(delegate, manager.focusedKey) : (_delegate_getFirstKey3 = delegate.getFirstKey) === null || _delegate_getFirstKey3 === void 0 ? void 0 : _delegate_getFirstKey3.call(delegate, manager.focusedKey);
175
179
  navigateToKey(nextKey3, direction === "rtl" ? "last" : "first");
176
180
  }
177
181
  break;
@@ -280,10 +284,12 @@ function $b6837c2f80a3c32f$export$d6daf82dcd84e87c(options) {
280
284
  // Restore the scroll position to what it was before.
281
285
  scrollRef.current.scrollTop = scrollPos.current.top;
282
286
  scrollRef.current.scrollLeft = scrollPos.current.left;
287
+ }
288
+ if (!isVirtualized && manager.focusedKey != null) {
283
289
  // Refocus and scroll the focused item into view if it exists within the scrollable region.
284
290
  let element = scrollRef.current.querySelector(`[data-key="${manager.focusedKey}"]`);
285
291
  if (element) {
286
- // This prevents a flash of focus on the first/last element in the collection
292
+ // This prevents a flash of focus on the first/last element in the collection, or the collection itself.
287
293
  (0, $glPPV$reactariautils.focusWithoutScrolling)(element);
288
294
  (0, $glPPV$reactariautils.scrollIntoView)(scrollRef.current, element);
289
295
  }
@@ -394,9 +400,9 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
394
400
  // Focus the associated DOM node when this item becomes the focusedKey
395
401
  (0, $glPPV$react.useEffect)(()=>{
396
402
  let isFocused = key === manager.focusedKey;
397
- if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
403
+ if (isFocused && manager.isFocused && !shouldUseVirtualFocus) {
398
404
  if (focus) focus();
399
- else (0, $glPPV$reactariafocus.focusSafely)(ref.current);
405
+ else if (document.activeElement !== ref.current) (0, $glPPV$reactariafocus.focusSafely)(ref.current);
400
406
  }
401
407
  // eslint-disable-next-line react-hooks/exhaustive-deps
402
408
  }, [
@@ -520,6 +526,7 @@ function $433b1145b0781e10$export$ecf600387e221c37(options) {
520
526
  }),
521
527
  isPressed: isPressed,
522
528
  isSelected: manager.isSelected(key),
529
+ isFocused: manager.isFocused && manager.focusedKey === key,
523
530
  isDisabled: isDisabled,
524
531
  allowsSelection: allowsSelection,
525
532
  hasAction: hasAction
@@ -556,7 +563,8 @@ function $433b1145b0781e10$var$isSelectionKey() {
556
563
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
557
564
  * OF ANY KIND, either express or implied. See the License for the specific language
558
565
  * governing permissions and limitations under the License.
559
- */ class $836f880b12dcae5c$export$a05409b8bb224a5a {
566
+ */
567
+ class $836f880b12dcae5c$export$a05409b8bb224a5a {
560
568
  getKeyBelow(key) {
561
569
  key = this.collection.getKeyAfter(key);
562
570
  while(key != null){
@@ -564,6 +572,7 @@ function $433b1145b0781e10$var$isSelectionKey() {
564
572
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
565
573
  key = this.collection.getKeyAfter(key);
566
574
  }
575
+ return null;
567
576
  }
568
577
  getKeyAbove(key) {
569
578
  key = this.collection.getKeyBefore(key);
@@ -572,6 +581,15 @@ function $433b1145b0781e10$var$isSelectionKey() {
572
581
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
573
582
  key = this.collection.getKeyBefore(key);
574
583
  }
584
+ return null;
585
+ }
586
+ getKeyRightOf(key) {
587
+ if (this.orientation === "horizontal") return this.direction === "rtl" ? this.getKeyAbove(key) : this.getKeyBelow(key);
588
+ return null;
589
+ }
590
+ getKeyLeftOf(key) {
591
+ if (this.orientation === "horizontal") return this.direction === "rtl" ? this.getKeyBelow(key) : this.getKeyAbove(key);
592
+ return null;
575
593
  }
576
594
  getFirstKey() {
577
595
  let key = this.collection.getFirstKey();
@@ -580,6 +598,7 @@ function $433b1145b0781e10$var$isSelectionKey() {
580
598
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
581
599
  key = this.collection.getKeyAfter(key);
582
600
  }
601
+ return null;
583
602
  }
584
603
  getLastKey() {
585
604
  let key = this.collection.getLastKey();
@@ -588,6 +607,7 @@ function $433b1145b0781e10$var$isSelectionKey() {
588
607
  if (item.type === "item" && !this.disabledKeys.has(key)) return key;
589
608
  key = this.collection.getKeyBefore(key);
590
609
  }
610
+ return null;
591
611
  }
592
612
  getItem(key) {
593
613
  return this.ref.current.querySelector(`[data-key="${key}"]`);
@@ -596,23 +616,53 @@ function $433b1145b0781e10$var$isSelectionKey() {
596
616
  let menu = this.ref.current;
597
617
  let item = this.getItem(key);
598
618
  if (!item) return null;
599
- let pageY = Math.max(0, item.offsetTop + item.offsetHeight - menu.offsetHeight);
600
- while(item && item.offsetTop > pageY){
601
- key = this.getKeyAbove(key);
602
- item = this.getItem(key);
619
+ if (!(0, $glPPV$reactariautils.isScrollable)(menu)) return this.getFirstKey();
620
+ let containerRect = menu.getBoundingClientRect();
621
+ let itemRect = item.getBoundingClientRect();
622
+ if (this.orientation === "horizontal") {
623
+ let containerX = containerRect.x - menu.scrollLeft;
624
+ let pageX = Math.max(0, itemRect.x - containerX + itemRect.width - containerRect.width);
625
+ while(item && itemRect.x - containerX > pageX){
626
+ key = this.getKeyAbove(key);
627
+ item = key == null ? null : this.getItem(key);
628
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
629
+ }
630
+ } else {
631
+ let containerY = containerRect.y - menu.scrollTop;
632
+ let pageY = Math.max(0, itemRect.y - containerY + itemRect.height - containerRect.height);
633
+ while(item && itemRect.y - containerY > pageY){
634
+ key = this.getKeyAbove(key);
635
+ item = key == null ? null : this.getItem(key);
636
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
637
+ }
603
638
  }
604
- return key;
639
+ return key !== null && key !== void 0 ? key : this.getFirstKey();
605
640
  }
606
641
  getKeyPageBelow(key) {
607
642
  let menu = this.ref.current;
608
643
  let item = this.getItem(key);
609
644
  if (!item) return null;
610
- let pageY = Math.min(menu.scrollHeight, item.offsetTop - item.offsetHeight + menu.offsetHeight);
611
- while(item && item.offsetTop < pageY){
612
- key = this.getKeyBelow(key);
613
- item = this.getItem(key);
645
+ if (!(0, $glPPV$reactariautils.isScrollable)(menu)) return this.getLastKey();
646
+ let containerRect = menu.getBoundingClientRect();
647
+ let itemRect = item.getBoundingClientRect();
648
+ if (this.orientation === "horizontal") {
649
+ let containerX = containerRect.x - menu.scrollLeft;
650
+ let pageX = Math.min(menu.scrollWidth, itemRect.x - containerX - itemRect.width + containerRect.width);
651
+ while(item && itemRect.x - containerX < pageX){
652
+ key = this.getKeyBelow(key);
653
+ item = key == null ? null : this.getItem(key);
654
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
655
+ }
656
+ } else {
657
+ let containerY = containerRect.y - menu.scrollTop;
658
+ let pageY = Math.min(menu.scrollHeight, itemRect.y - containerY - itemRect.height + containerRect.height);
659
+ while(item && itemRect.y - containerY < pageY){
660
+ key = this.getKeyBelow(key);
661
+ item = key == null ? null : this.getItem(key);
662
+ itemRect = item === null || item === void 0 ? void 0 : item.getBoundingClientRect();
663
+ }
614
664
  }
615
- return key;
665
+ return key !== null && key !== void 0 ? key : this.getLastKey();
616
666
  }
617
667
  getKeyForSearch(search, fromKey) {
618
668
  if (!this.collator) return null;
@@ -626,11 +676,20 @@ function $433b1145b0781e10$var$isSelectionKey() {
626
676
  }
627
677
  return null;
628
678
  }
629
- constructor(collection, disabledKeys, ref, collator){
630
- this.collection = collection;
631
- this.disabledKeys = disabledKeys;
632
- this.ref = ref;
633
- this.collator = collator;
679
+ constructor(...args){
680
+ if (args.length === 1) {
681
+ let opts = args[0];
682
+ this.collection = opts.collection;
683
+ this.ref = opts.ref;
684
+ this.disabledKeys = opts.disabledKeys || new Set();
685
+ this.orientation = opts.orientation;
686
+ this.direction = opts.direction;
687
+ } else {
688
+ this.collection = args[0];
689
+ this.disabledKeys = args[1];
690
+ this.ref = args[2];
691
+ this.collator = args[3];
692
+ }
634
693
  }
635
694
  }
636
695