@spscommerce/ds-react 3.16.1-ie → 3.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs.js CHANGED
@@ -15,6 +15,7 @@ var positioning = require('@spscommerce/positioning');
15
15
  var moment$6 = require('moment-timezone');
16
16
  var isPlainObject = require('lodash.isplainobject');
17
17
  var dsColors = require('@spscommerce/ds-colors');
18
+ var collections = require('@react-stately/collections');
18
19
 
19
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
21
 
@@ -39,6 +40,7 @@ function _interopNamespace(e) {
39
40
  }
40
41
 
41
42
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
43
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
42
44
  var clsx__default = /*#__PURE__*/_interopDefaultLegacy(clsx);
43
45
  var PropTypes__namespace = /*#__PURE__*/_interopNamespace(PropTypes);
44
46
  var nanoid__default = /*#__PURE__*/_interopDefaultLegacy(nanoid);
@@ -1778,7 +1780,7 @@ Object.assign(SpsCardTabbedPane, {
1778
1780
  * @param activeTab
1779
1781
  * @param isTabbedCard
1780
1782
  */
1781
- function useTab(children, activeTab, isTabbedCard) {
1783
+ function useTab$1(children, activeTab, isTabbedCard) {
1782
1784
  // STATE: Currently active tab state
1783
1785
  var _a = __read(React__namespace.useState({
1784
1786
  index: 0,
@@ -1862,7 +1864,7 @@ function SpsCard(props) {
1862
1864
  var activeTab = props.activeTab, children = props.children, className = props.className, footer = props.footer, headerContent = props.headerContent, headerIcon = props.headerIcon, headerTitle = props.headerTitle, testId = props["data-testid"], unsafelyReplaceClassName = props.unsafelyReplaceClassName, rest = __rest(props, ["activeTab", "children", "className", "footer", "headerContent", "headerIcon", "headerTitle", 'data-testid', "unsafelyReplaceClassName"]);
1863
1865
  // This used to be a prop but now we derive it
1864
1866
  var isTabbedCard = React__namespace.Children.toArray(children).some(function (child) { return React__namespace.isValidElement(child) && child.type === SpsCardTabbedPane; });
1865
- var _a = __read(useTab(children, activeTab, isTabbedCard), 2), currentlyActiveTab = _a[0], setCurrentlyActiveTab = _a[1];
1867
+ var _a = __read(useTab$1(children, activeTab, isTabbedCard), 2), currentlyActiveTab = _a[0], setCurrentlyActiveTab = _a[1];
1866
1868
  var classes = clsx__default['default'](unsafelyReplaceClassName || 'sps-card', className);
1867
1869
  return (React__namespace.createElement("div", __assign({}, rest, { className: classes, "data-testid": testId + "__card" }),
1868
1870
  (headerTitle || headerContent) && (React__namespace.createElement(SpsCardHeader, { title: headerTitle, content: contentOf(headerContent), icon: headerIcon, "data-testid": testId + "__header" })),
@@ -9170,6 +9172,20 @@ function SpsTaskQueue(_a) {
9170
9172
  var _g = __read(React__namespace.useState(hasTasks), 2), showNotification = _g[0], setShowNotification = _g[1];
9171
9173
  var toggleRef = React__namespace.useRef(null);
9172
9174
  var taskQueueDropdownRef = React__namespace.useRef(null);
9175
+ var resizeListener = React__namespace.useCallback(function () {
9176
+ setIsOpen(false);
9177
+ if (onClose) {
9178
+ onClose();
9179
+ }
9180
+ }, []);
9181
+ React__namespace.useEffect(function () {
9182
+ if (isOpen) {
9183
+ window.addEventListener('resize', resizeListener);
9184
+ }
9185
+ else {
9186
+ window.removeEventListener('resize', resizeListener);
9187
+ }
9188
+ }, [isOpen]);
9173
9189
  var portal = usePortal('sps-task-queue-portal');
9174
9190
  var portalContext = React__namespace.useContext(PortalContext);
9175
9191
  var _h = __read(isOpen
@@ -9184,13 +9200,6 @@ function SpsTaskQueue(_a) {
9184
9200
  // this gives us a stable reference to the freshest onClose handler
9185
9201
  var onCloseRef = React__namespace.useRef(onClose);
9186
9202
  onCloseRef.current = onClose;
9187
- // this gives us a stable getter for the freshest available positioning options
9188
- var getPositioningOptions = function () { return ({
9189
- relativeTo: toggleRef.current,
9190
- position: taskQueuePosition,
9191
- }); };
9192
- var getPositioningOptionsRef = React__namespace.useRef(getPositioningOptions);
9193
- getPositioningOptionsRef.current = getPositioningOptions;
9194
9203
  var handleToggle = function () {
9195
9204
  if (hasTasks && !isOpen) {
9196
9205
  setIsOpen(true);
@@ -9378,7 +9387,6 @@ var SpsTextInput = React__namespace.forwardRef(function (_a, ref) {
9378
9387
  setAndPropagateValue('');
9379
9388
  }
9380
9389
  function handleChange(event) {
9381
- console.log('handleChange', event.target.value);
9382
9390
  setAndPropagateValue(event.target.value, event);
9383
9391
  }
9384
9392
  var classes = clsx__default['default'](unsafelyReplaceClassName || 'sps-text-input', className);
@@ -10388,6 +10396,3232 @@ var MANIFEST = {
10388
10396
  },
10389
10397
  };
10390
10398
 
10399
+ function useControlledState(value, defaultValue, onChange) {
10400
+ let [stateValue, setStateValue] = React.useState(value || defaultValue);
10401
+ let ref = React.useRef(value !== undefined);
10402
+ let wasControlled = ref.current;
10403
+ let isControlled = value !== undefined; // Internal state reference for useCallback
10404
+
10405
+ let stateRef = React.useRef(stateValue);
10406
+
10407
+ if (wasControlled !== isControlled) {
10408
+ console.warn("WARN: A component changed from " + (wasControlled ? 'controlled' : 'uncontrolled') + " to " + (isControlled ? 'controlled' : 'uncontrolled') + ".");
10409
+ }
10410
+
10411
+ ref.current = isControlled;
10412
+ let setValue = React.useCallback(function (value) {
10413
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
10414
+ args[_key - 1] = arguments[_key];
10415
+ }
10416
+
10417
+ let onChangeCaller = function onChangeCaller(value) {
10418
+ if (onChange) {
10419
+ if (!Object.is(stateRef.current, value)) {
10420
+ for (var _len2 = arguments.length, onChangeArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
10421
+ onChangeArgs[_key2 - 1] = arguments[_key2];
10422
+ }
10423
+
10424
+ onChange(value, ...onChangeArgs);
10425
+ }
10426
+ }
10427
+
10428
+ if (!isControlled) {
10429
+ stateRef.current = value;
10430
+ }
10431
+ };
10432
+
10433
+ if (typeof value === 'function') {
10434
+ // this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates
10435
+ // when someone using useControlledState calls setControlledState(myFunc)
10436
+ // this will call our useState setState with a function as well which invokes myFunc and calls onChange with the value from myFunc
10437
+ // if we're in an uncontrolled state, then we also return the value of myFunc which to setState looks as though it was just called with myFunc from the beginning
10438
+ // otherwise we just return the controlled value, which won't cause a rerender because React knows to bail out when the value is the same
10439
+ let updateFunction = function updateFunction(oldValue) {
10440
+ for (var _len3 = arguments.length, functionArgs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
10441
+ functionArgs[_key3 - 1] = arguments[_key3];
10442
+ }
10443
+
10444
+ let interceptedValue = value(isControlled ? stateRef.current : oldValue, ...functionArgs);
10445
+ onChangeCaller(interceptedValue, ...args);
10446
+
10447
+ if (!isControlled) {
10448
+ return interceptedValue;
10449
+ }
10450
+
10451
+ return oldValue;
10452
+ };
10453
+
10454
+ setStateValue(updateFunction);
10455
+ } else {
10456
+ if (!isControlled) {
10457
+ setStateValue(value);
10458
+ }
10459
+
10460
+ onChangeCaller(value, ...args);
10461
+ }
10462
+ }, [isControlled, onChange]); // If a controlled component's value prop changes, we need to update stateRef
10463
+
10464
+ if (isControlled) {
10465
+ stateRef.current = value;
10466
+ } else {
10467
+ value = stateValue;
10468
+ }
10469
+
10470
+ return [value, setValue];
10471
+ }
10472
+
10473
+ function _extends$3() {
10474
+ _extends$3 = Object.assign || function (target) {
10475
+ for (var i = 1; i < arguments.length; i++) {
10476
+ var source = arguments[i];
10477
+
10478
+ for (var key in source) {
10479
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
10480
+ target[key] = source[key];
10481
+ }
10482
+ }
10483
+ }
10484
+
10485
+ return target;
10486
+ };
10487
+
10488
+ return _extends$3.apply(this, arguments);
10489
+ }
10490
+
10491
+ /*
10492
+ * Copyright 2020 Adobe. All rights reserved.
10493
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10494
+ * you may not use this file except in compliance with the License. You may obtain a copy
10495
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10496
+ *
10497
+ * Unless required by applicable law or agreed to in writing, software distributed under
10498
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10499
+ * OF ANY KIND, either express or implied. See the License for the specific language
10500
+ * governing permissions and limitations under the License.
10501
+ */
10502
+
10503
+ /**
10504
+ * A Selection is a special Set containing Keys, which also has an anchor
10505
+ * and current selected key for use when range selecting.
10506
+ */
10507
+ class $c91e86e24f2dc9a2182dcc2674c58c$export$Selection extends Set {
10508
+ constructor(keys, anchorKey, currentKey) {
10509
+ super(keys);
10510
+ this.anchorKey = void 0;
10511
+ this.currentKey = void 0;
10512
+
10513
+ if (keys instanceof $c91e86e24f2dc9a2182dcc2674c58c$export$Selection) {
10514
+ this.anchorKey = anchorKey || keys.anchorKey;
10515
+ this.currentKey = currentKey || keys.currentKey;
10516
+ } else {
10517
+ this.anchorKey = anchorKey;
10518
+ this.currentKey = currentKey;
10519
+ }
10520
+ }
10521
+
10522
+ }
10523
+
10524
+ /**
10525
+ * Manages state for multiple selection and focus in a collection.
10526
+ */
10527
+ function useMultipleSelectionState(props) {
10528
+ let {
10529
+ selectionMode = 'none',
10530
+ disallowEmptySelection
10531
+ } = props; // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
10532
+ // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
10533
+
10534
+ let isFocusedRef = React.useRef(false);
10535
+ let [, setFocused] = React.useState(false);
10536
+ let focusedKeyRef = React.useRef(null);
10537
+ let childFocusStrategyRef = React.useRef(null);
10538
+ let [, setFocusedKey] = React.useState(null);
10539
+ let selectedKeysProp = React.useMemo(() => $c86d35e876e048ac11515eee40c7$var$convertSelection(props.selectedKeys), [props.selectedKeys]);
10540
+ let defaultSelectedKeys = React.useMemo(() => $c86d35e876e048ac11515eee40c7$var$convertSelection(props.defaultSelectedKeys, new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection()), [props.defaultSelectedKeys]);
10541
+ let [selectedKeys, setSelectedKeys] = useControlledState(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
10542
+ let disabledKeysProp = React.useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [props.disabledKeys]);
10543
+ return {
10544
+ selectionMode,
10545
+ disallowEmptySelection,
10546
+
10547
+ get isFocused() {
10548
+ return isFocusedRef.current;
10549
+ },
10550
+
10551
+ setFocused(f) {
10552
+ isFocusedRef.current = f;
10553
+ setFocused(f);
10554
+ },
10555
+
10556
+ get focusedKey() {
10557
+ return focusedKeyRef.current;
10558
+ },
10559
+
10560
+ get childFocusStrategy() {
10561
+ return childFocusStrategyRef.current;
10562
+ },
10563
+
10564
+ setFocusedKey(k, childFocusStrategy) {
10565
+ if (childFocusStrategy === void 0) {
10566
+ childFocusStrategy = 'first';
10567
+ }
10568
+
10569
+ focusedKeyRef.current = k;
10570
+ childFocusStrategyRef.current = childFocusStrategy;
10571
+ setFocusedKey(k);
10572
+ },
10573
+
10574
+ selectedKeys,
10575
+ setSelectedKeys,
10576
+ disabledKeys: disabledKeysProp
10577
+ };
10578
+ }
10579
+
10580
+ function $c86d35e876e048ac11515eee40c7$var$convertSelection(selection, defaultValue) {
10581
+ if (!selection) {
10582
+ return defaultValue;
10583
+ }
10584
+
10585
+ return selection === 'all' ? 'all' : new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection(selection);
10586
+ }
10587
+
10588
+ /**
10589
+ * An interface for reading and updating multiple selection state.
10590
+ */
10591
+ class SelectionManager {
10592
+ constructor(collection, state, options) {
10593
+ var _options$allowsCellSe;
10594
+
10595
+ this.collection = void 0;
10596
+ this.state = void 0;
10597
+ this.allowsCellSelection = void 0;
10598
+ this._isSelectAll = void 0;
10599
+ this.collection = collection;
10600
+ this.state = state;
10601
+ this.allowsCellSelection = (_options$allowsCellSe = options == null ? void 0 : options.allowsCellSelection) != null ? _options$allowsCellSe : false;
10602
+ this._isSelectAll = null;
10603
+ }
10604
+ /**
10605
+ * The type of selection that is allowed in the collection.
10606
+ */
10607
+
10608
+
10609
+ get selectionMode() {
10610
+ return this.state.selectionMode;
10611
+ }
10612
+ /**
10613
+ * Whether the collection allows empty selection.
10614
+ */
10615
+
10616
+
10617
+ get disallowEmptySelection() {
10618
+ return this.state.disallowEmptySelection;
10619
+ }
10620
+ /**
10621
+ * Whether the collection is currently focused.
10622
+ */
10623
+
10624
+
10625
+ get isFocused() {
10626
+ return this.state.isFocused;
10627
+ }
10628
+ /**
10629
+ * Sets whether the collection is focused.
10630
+ */
10631
+
10632
+
10633
+ setFocused(isFocused) {
10634
+ this.state.setFocused(isFocused);
10635
+ }
10636
+ /**
10637
+ * The current focused key in the collection.
10638
+ */
10639
+
10640
+
10641
+ get focusedKey() {
10642
+ return this.state.focusedKey;
10643
+ }
10644
+ /** Whether the first or last child of the focused key should receive focus. */
10645
+
10646
+
10647
+ get childFocusStrategy() {
10648
+ return this.state.childFocusStrategy;
10649
+ }
10650
+ /**
10651
+ * Sets the focused key.
10652
+ */
10653
+
10654
+
10655
+ setFocusedKey(key, childFocusStrategy) {
10656
+ this.state.setFocusedKey(key, childFocusStrategy);
10657
+ }
10658
+ /**
10659
+ * The currently selected keys in the collection.
10660
+ */
10661
+
10662
+
10663
+ get selectedKeys() {
10664
+ return this.state.selectedKeys === 'all' ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
10665
+ }
10666
+ /**
10667
+ * The raw selection value for the collection.
10668
+ * Either 'all' for select all, or a set of keys.
10669
+ */
10670
+
10671
+
10672
+ get rawSelection() {
10673
+ return this.state.selectedKeys;
10674
+ }
10675
+ /**
10676
+ * Returns whether a key is selected.
10677
+ */
10678
+
10679
+
10680
+ isSelected(key) {
10681
+ if (this.state.selectionMode === 'none') {
10682
+ return false;
10683
+ }
10684
+
10685
+ key = this.getKey(key);
10686
+ return this.state.selectedKeys === 'all' ? !this.state.disabledKeys.has(key) : this.state.selectedKeys.has(key);
10687
+ }
10688
+ /**
10689
+ * Whether the selection is empty.
10690
+ */
10691
+
10692
+
10693
+ get isEmpty() {
10694
+ return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;
10695
+ }
10696
+ /**
10697
+ * Whether all items in the collection are selected.
10698
+ */
10699
+
10700
+
10701
+ get isSelectAll() {
10702
+ if (this.isEmpty) {
10703
+ return false;
10704
+ }
10705
+
10706
+ if (this.state.selectedKeys === 'all') {
10707
+ return true;
10708
+ }
10709
+
10710
+ if (this._isSelectAll != null) {
10711
+ return this._isSelectAll;
10712
+ }
10713
+
10714
+ let allKeys = this.getSelectAllKeys();
10715
+ let selectedKeys = this.state.selectedKeys;
10716
+ this._isSelectAll = allKeys.every(k => selectedKeys.has(k));
10717
+ return this._isSelectAll;
10718
+ }
10719
+
10720
+ get firstSelectedKey() {
10721
+ var _first;
10722
+
10723
+ let first = null;
10724
+
10725
+ for (let key of this.state.selectedKeys) {
10726
+ let item = this.collection.getItem(key);
10727
+
10728
+ if (!first || (item == null ? void 0 : item.index) < first.index) {
10729
+ first = item;
10730
+ }
10731
+ }
10732
+
10733
+ return (_first = first) == null ? void 0 : _first.key;
10734
+ }
10735
+
10736
+ get lastSelectedKey() {
10737
+ var _last;
10738
+
10739
+ let last = null;
10740
+
10741
+ for (let key of this.state.selectedKeys) {
10742
+ let item = this.collection.getItem(key);
10743
+
10744
+ if (!last || (item == null ? void 0 : item.index) > last.index) {
10745
+ last = item;
10746
+ }
10747
+ }
10748
+
10749
+ return (_last = last) == null ? void 0 : _last.key;
10750
+ }
10751
+ /**
10752
+ * Extends the selection to the given key.
10753
+ */
10754
+
10755
+
10756
+ extendSelection(toKey) {
10757
+ toKey = this.getKey(toKey);
10758
+ let selection; // Only select the one key if coming from a select all.
10759
+
10760
+ if (this.state.selectedKeys === 'all') {
10761
+ selection = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection([toKey], toKey, toKey);
10762
+ } else {
10763
+ let selectedKeys = this.state.selectedKeys;
10764
+ let anchorKey = selectedKeys.anchorKey || toKey;
10765
+ selection = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection(selectedKeys, anchorKey, toKey);
10766
+
10767
+ for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {
10768
+ selection.delete(key);
10769
+ }
10770
+
10771
+ for (let key of this.getKeyRange(toKey, anchorKey)) {
10772
+ if (!this.state.disabledKeys.has(key)) {
10773
+ selection.add(key);
10774
+ }
10775
+ }
10776
+ }
10777
+
10778
+ this.state.setSelectedKeys(selection);
10779
+ }
10780
+
10781
+ getKeyRange(from, to) {
10782
+ let fromItem = this.collection.getItem(from);
10783
+ let toItem = this.collection.getItem(to);
10784
+
10785
+ if (fromItem && toItem) {
10786
+ if (fromItem.index <= toItem.index) {
10787
+ return this.getKeyRangeInternal(from, to);
10788
+ }
10789
+
10790
+ return this.getKeyRangeInternal(to, from);
10791
+ }
10792
+
10793
+ return [];
10794
+ }
10795
+
10796
+ getKeyRangeInternal(from, to) {
10797
+ let keys = [];
10798
+ let key = from;
10799
+
10800
+ while (key) {
10801
+ let item = this.collection.getItem(key);
10802
+
10803
+ if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) {
10804
+ keys.push(key);
10805
+ }
10806
+
10807
+ if (key === to) {
10808
+ return keys;
10809
+ }
10810
+
10811
+ key = this.collection.getKeyAfter(key);
10812
+ }
10813
+
10814
+ return [];
10815
+ }
10816
+
10817
+ getKey(key) {
10818
+ let item = this.collection.getItem(key);
10819
+
10820
+ if (!item) {
10821
+ // ¯\_(ツ)_/¯
10822
+ return key;
10823
+ } // If cell selection is allowed, just return the key.
10824
+
10825
+
10826
+ if (item.type === 'cell' && this.allowsCellSelection) {
10827
+ return key;
10828
+ } // Find a parent item to select
10829
+
10830
+
10831
+ while (item.type !== 'item' && item.parentKey) {
10832
+ item = this.collection.getItem(item.parentKey);
10833
+ }
10834
+
10835
+ if (!item || item.type !== 'item') {
10836
+ return null;
10837
+ }
10838
+
10839
+ return item.key;
10840
+ }
10841
+ /**
10842
+ * Toggles whether the given key is selected.
10843
+ */
10844
+
10845
+
10846
+ toggleSelection(key) {
10847
+ key = this.getKey(key);
10848
+
10849
+ if (key == null) {
10850
+ return;
10851
+ }
10852
+
10853
+ let keys = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
10854
+
10855
+ if (keys.has(key)) {
10856
+ keys.delete(key); // TODO: move anchor to last selected key...
10857
+ // Does `current` need to move here too?
10858
+ } else {
10859
+ keys.add(key);
10860
+ keys.anchorKey = key;
10861
+ keys.currentKey = key;
10862
+ }
10863
+
10864
+ if (this.disallowEmptySelection && keys.size === 0) {
10865
+ return;
10866
+ }
10867
+
10868
+ this.state.setSelectedKeys(keys);
10869
+ }
10870
+ /**
10871
+ * Replaces the selection with only the given key.
10872
+ */
10873
+
10874
+
10875
+ replaceSelection(key) {
10876
+ key = this.getKey(key);
10877
+
10878
+ if (key == null) {
10879
+ return;
10880
+ }
10881
+
10882
+ this.state.setSelectedKeys(new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection([key], key, key));
10883
+ }
10884
+ /**
10885
+ * Replaces the selection with the given keys.
10886
+ */
10887
+
10888
+
10889
+ setSelectedKeys(keys) {
10890
+ if (this.selectionMode === 'none') {
10891
+ return;
10892
+ }
10893
+
10894
+ let selection = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection();
10895
+
10896
+ for (let key of keys) {
10897
+ key = this.getKey(key);
10898
+
10899
+ if (key != null) {
10900
+ selection.add(key);
10901
+
10902
+ if (this.selectionMode === 'single') {
10903
+ break;
10904
+ }
10905
+ }
10906
+ }
10907
+
10908
+ this.state.setSelectedKeys(selection);
10909
+ }
10910
+
10911
+ getSelectAllKeys() {
10912
+ let keys = [];
10913
+
10914
+ let addKeys = key => {
10915
+ while (key) {
10916
+ if (!this.state.disabledKeys.has(key)) {
10917
+ let item = this.collection.getItem(key);
10918
+
10919
+ if (item.type === 'item') {
10920
+ keys.push(key);
10921
+ } // Add child keys. If cell selection is allowed, then include item children too.
10922
+
10923
+
10924
+ if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {
10925
+ addKeys([...item.childNodes][0].key);
10926
+ }
10927
+ }
10928
+
10929
+ key = this.collection.getKeyAfter(key);
10930
+ }
10931
+ };
10932
+
10933
+ addKeys(this.collection.getFirstKey());
10934
+ return keys;
10935
+ }
10936
+ /**
10937
+ * Selects all items in the collection.
10938
+ */
10939
+
10940
+
10941
+ selectAll() {
10942
+ if (this.selectionMode === 'multiple') {
10943
+ this.state.setSelectedKeys('all');
10944
+ }
10945
+ }
10946
+ /**
10947
+ * Removes all keys from the selection.
10948
+ */
10949
+
10950
+
10951
+ clearSelection() {
10952
+ if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {
10953
+ this.state.setSelectedKeys(new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection());
10954
+ }
10955
+ }
10956
+ /**
10957
+ * Toggles between select all and an empty selection.
10958
+ */
10959
+
10960
+
10961
+ toggleSelectAll() {
10962
+ if (this.isSelectAll) {
10963
+ this.clearSelection();
10964
+ } else {
10965
+ this.selectAll();
10966
+ }
10967
+ }
10968
+
10969
+ select(key, e) {
10970
+ if (this.selectionMode === 'none') {
10971
+ return;
10972
+ }
10973
+
10974
+ if (this.selectionMode === 'single') {
10975
+ if (this.isSelected(key) && !this.disallowEmptySelection) {
10976
+ this.toggleSelection(key);
10977
+ } else {
10978
+ this.replaceSelection(key);
10979
+ }
10980
+ } else if (e && e.shiftKey) {
10981
+ this.extendSelection(key);
10982
+ } else {
10983
+ this.toggleSelection(key);
10984
+ }
10985
+ }
10986
+ /**
10987
+ * Returns whether the current selection is equal to the given selection.
10988
+ */
10989
+
10990
+
10991
+ isSelectionEqual(selection) {
10992
+ if (selection === this.state.selectedKeys) {
10993
+ return true;
10994
+ } // Check if the set of keys match.
10995
+
10996
+
10997
+ let selectedKeys = this.selectedKeys;
10998
+
10999
+ if (selection.size !== selectedKeys.size) {
11000
+ return false;
11001
+ }
11002
+
11003
+ for (let key of selection) {
11004
+ if (!selectedKeys.has(key)) {
11005
+ return false;
11006
+ }
11007
+ }
11008
+
11009
+ for (let key of selectedKeys) {
11010
+ if (!selection.has(key)) {
11011
+ return false;
11012
+ }
11013
+ }
11014
+
11015
+ return true;
11016
+ }
11017
+
11018
+ }
11019
+
11020
+ let $ed5d55e571caf578a4f08babbaa26be$var$_Symbol$iterator;
11021
+ $ed5d55e571caf578a4f08babbaa26be$var$_Symbol$iterator = Symbol.iterator;
11022
+
11023
+ /*
11024
+ * Copyright 2020 Adobe. All rights reserved.
11025
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11026
+ * you may not use this file except in compliance with the License. You may obtain a copy
11027
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11028
+ *
11029
+ * Unless required by applicable law or agreed to in writing, software distributed under
11030
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11031
+ * OF ANY KIND, either express or implied. See the License for the specific language
11032
+ * governing permissions and limitations under the License.
11033
+ */
11034
+ class ListCollection {
11035
+ constructor(nodes) {
11036
+ var _last;
11037
+
11038
+ this.keyMap = new Map();
11039
+ this.iterable = void 0;
11040
+ this.firstKey = void 0;
11041
+ this.lastKey = void 0;
11042
+ this.iterable = nodes;
11043
+
11044
+ let visit = node => {
11045
+ this.keyMap.set(node.key, node);
11046
+
11047
+ if (node.childNodes && node.type === 'section') {
11048
+ for (let child of node.childNodes) {
11049
+ visit(child);
11050
+ }
11051
+ }
11052
+ };
11053
+
11054
+ for (let node of nodes) {
11055
+ visit(node);
11056
+ }
11057
+
11058
+ let last;
11059
+ let index = 0;
11060
+
11061
+ for (let [key, node] of this.keyMap) {
11062
+ if (last) {
11063
+ last.nextKey = key;
11064
+ node.prevKey = last.key;
11065
+ } else {
11066
+ this.firstKey = key;
11067
+ node.prevKey = undefined;
11068
+ }
11069
+
11070
+ if (node.type === 'item') {
11071
+ node.index = index++;
11072
+ }
11073
+
11074
+ last = node; // Set nextKey as undefined since this might be the last node
11075
+ // If it isn't the last node, last.nextKey will properly set at start of new loop
11076
+
11077
+ last.nextKey = undefined;
11078
+ }
11079
+
11080
+ this.lastKey = (_last = last) == null ? void 0 : _last.key;
11081
+ }
11082
+
11083
+ *[$ed5d55e571caf578a4f08babbaa26be$var$_Symbol$iterator]() {
11084
+ yield* this.iterable;
11085
+ }
11086
+
11087
+ get size() {
11088
+ return this.keyMap.size;
11089
+ }
11090
+
11091
+ getKeys() {
11092
+ return this.keyMap.keys();
11093
+ }
11094
+
11095
+ getKeyBefore(key) {
11096
+ let node = this.keyMap.get(key);
11097
+ return node ? node.prevKey : null;
11098
+ }
11099
+
11100
+ getKeyAfter(key) {
11101
+ let node = this.keyMap.get(key);
11102
+ return node ? node.nextKey : null;
11103
+ }
11104
+
11105
+ getFirstKey() {
11106
+ return this.firstKey;
11107
+ }
11108
+
11109
+ getLastKey() {
11110
+ return this.lastKey;
11111
+ }
11112
+
11113
+ getItem(key) {
11114
+ return this.keyMap.get(key);
11115
+ }
11116
+
11117
+ at(idx) {
11118
+ const keys = [...this.getKeys()];
11119
+ return this.getItem(keys[idx]);
11120
+ }
11121
+
11122
+ }
11123
+
11124
+ /**
11125
+ * Provides state management for list-like components. Handles building a collection
11126
+ * of items from props, and manages multiple selection state.
11127
+ */
11128
+ function useListState(props) {
11129
+ let {
11130
+ filter
11131
+ } = props;
11132
+ let selectionState = useMultipleSelectionState(props);
11133
+ let disabledKeys = React.useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [props.disabledKeys]);
11134
+
11135
+ let factory = nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes);
11136
+
11137
+ let context = React.useMemo(() => ({
11138
+ suppressTextValueWarning: props.suppressTextValueWarning
11139
+ }), [props.suppressTextValueWarning]);
11140
+ let collection = collections.useCollection(props, factory, context, [filter]); // Reset focused key if that item is deleted from the collection.
11141
+
11142
+ React.useEffect(() => {
11143
+ if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
11144
+ selectionState.setFocusedKey(null);
11145
+ }
11146
+ }, [collection, selectionState.focusedKey]);
11147
+ return {
11148
+ collection,
11149
+ disabledKeys,
11150
+ selectionManager: new SelectionManager(collection, selectionState)
11151
+ };
11152
+ }
11153
+
11154
+ /**
11155
+ * Provides state management for list-like components with single selection.
11156
+ * Handles building a collection of items from props, and manages selection state.
11157
+ */
11158
+ function useSingleSelectListState(props) {
11159
+ var _props$defaultSelecte;
11160
+
11161
+ let [selectedKey, setSelectedKey] = useControlledState(props.selectedKey, (_props$defaultSelecte = props.defaultSelectedKey) != null ? _props$defaultSelecte : null, props.onSelectionChange);
11162
+ let selectedKeys = React.useMemo(() => selectedKey != null ? [selectedKey] : [], [selectedKey]);
11163
+ let {
11164
+ collection,
11165
+ disabledKeys,
11166
+ selectionManager
11167
+ } = useListState(_extends$3({}, props, {
11168
+ selectionMode: 'single',
11169
+ disallowEmptySelection: true,
11170
+ selectedKeys,
11171
+ onSelectionChange: keys => {
11172
+ let key = keys.values().next().value; // Always fire onSelectionChange, even if the key is the same
11173
+ // as the current key (useControlledState does not).
11174
+
11175
+ if (key === selectedKey && props.onSelectionChange) {
11176
+ props.onSelectionChange(key);
11177
+ }
11178
+
11179
+ setSelectedKey(key);
11180
+ }
11181
+ }));
11182
+ let selectedItem = selectedKey != null ? collection.getItem(selectedKey) : null;
11183
+ return {
11184
+ collection,
11185
+ disabledKeys,
11186
+ selectionManager,
11187
+ selectedKey,
11188
+ setSelectedKey,
11189
+ selectedItem
11190
+ };
11191
+ }
11192
+
11193
+ function _extends$2() {
11194
+ _extends$2 = Object.assign || function (target) {
11195
+ for (var i = 1; i < arguments.length; i++) {
11196
+ var source = arguments[i];
11197
+
11198
+ for (var key in source) {
11199
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
11200
+ target[key] = source[key];
11201
+ }
11202
+ }
11203
+ }
11204
+
11205
+ return target;
11206
+ };
11207
+
11208
+ return _extends$2.apply(this, arguments);
11209
+ }
11210
+
11211
+ /**
11212
+ * Provides state management for a Tabs component. Tabs include a TabList which tracks
11213
+ * which tab is currently selected and displays the content associated with that Tab in a TabPanel.
11214
+ */
11215
+ function useTabListState(props) {
11216
+ let state = useSingleSelectListState(_extends$2({}, props, {
11217
+ suppressTextValueWarning: true
11218
+ }));
11219
+ React.useEffect(() => {
11220
+ // Ensure a tab is always selected (in case no selected key was specified or if selected item was deleted from collection)
11221
+ let selectedKey = state.selectedKey;
11222
+
11223
+ if (state.selectionManager.isEmpty || !state.collection.getItem(selectedKey)) {
11224
+ selectedKey = state.collection.getFirstKey();
11225
+ state.selectionManager.replaceSelection(selectedKey);
11226
+ }
11227
+
11228
+ if (state.selectionManager.focusedKey == null) {
11229
+ state.selectionManager.setFocusedKey(selectedKey);
11230
+ }
11231
+ }, [state.selectionManager, state.selectedKey, state.collection]);
11232
+ return state;
11233
+ }
11234
+
11235
+ // Default context value to use in case there is no SSRProvider. This is fine for
11236
+ // client-only apps. In order to support multiple copies of React Aria potentially
11237
+ // being on the page at once, the prefix is set to a random number. SSRProvider
11238
+ // will reset this to zero for consistency between server and client, so in the
11239
+ // SSR case multiple copies of React Aria is not supported.
11240
+ const $f01a183cc7bdff77849e49ad26eb904$var$defaultContext = {
11241
+ prefix: Math.round(Math.random() * 10000000000),
11242
+ current: 0
11243
+ };
11244
+
11245
+ const $f01a183cc7bdff77849e49ad26eb904$var$SSRContext = /*#__PURE__*/React__default['default'].createContext($f01a183cc7bdff77849e49ad26eb904$var$defaultContext);
11246
+ let $f01a183cc7bdff77849e49ad26eb904$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
11247
+ /** @private */
11248
+
11249
+ function useSSRSafeId(defaultId) {
11250
+ let ctx = React.useContext($f01a183cc7bdff77849e49ad26eb904$var$SSRContext); // If we are rendering in a non-DOM environment, and there's no SSRProvider,
11251
+ // provide a warning to hint to the developer to add one.
11252
+
11253
+ if (ctx === $f01a183cc7bdff77849e49ad26eb904$var$defaultContext && !$f01a183cc7bdff77849e49ad26eb904$var$canUseDOM) {
11254
+ console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
11255
+ }
11256
+
11257
+ return React.useMemo(() => defaultId || "react-aria-" + ctx.prefix + "-" + ++ctx.current, [defaultId]);
11258
+ }
11259
+ /**
11260
+ * Returns whether the component is currently being server side rendered or
11261
+ * hydrated on the client. Can be used to delay browser-specific rendering
11262
+ * until after hydration.
11263
+ */
11264
+
11265
+ function useIsSSR() {
11266
+ let cur = React.useContext($f01a183cc7bdff77849e49ad26eb904$var$SSRContext);
11267
+ let isInSSRContext = cur !== $f01a183cc7bdff77849e49ad26eb904$var$defaultContext;
11268
+ let [isSSR, setIsSSR] = React.useState(isInSSRContext); // If on the client, and the component was initially server rendered,
11269
+ // then schedule a layout effect to update the component after hydration.
11270
+
11271
+ if (typeof window !== 'undefined' && isInSSRContext) {
11272
+ // This if statement technically breaks the rules of hooks, but is safe
11273
+ // because the condition never changes after mounting.
11274
+ // eslint-disable-next-line react-hooks/rules-of-hooks
11275
+ React.useLayoutEffect(() => {
11276
+ setIsSSR(false);
11277
+ }, []);
11278
+ }
11279
+
11280
+ return isSSR;
11281
+ }
11282
+
11283
+ /*
11284
+ * Copyright 2020 Adobe. All rights reserved.
11285
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11286
+ * you may not use this file except in compliance with the License. You may obtain a copy
11287
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11288
+ *
11289
+ * Unless required by applicable law or agreed to in writing, software distributed under
11290
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11291
+ * OF ANY KIND, either express or implied. See the License for the specific language
11292
+ * governing permissions and limitations under the License.
11293
+ */
11294
+ // https://en.wikipedia.org/wiki/Right-to-left
11295
+ const $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);
11296
+ const $d26e725ad56fbcb2c25f52b7de27$var$RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);
11297
+ /**
11298
+ * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.
11299
+ */
11300
+
11301
+ function $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) {
11302
+ // If the Intl.Locale API is available, use it to get the script for the locale.
11303
+ // This is more accurate than guessing by language, since languages can be written in multiple scripts.
11304
+ // @ts-ignore
11305
+ if (Intl.Locale) {
11306
+ // @ts-ignore
11307
+ let script = new Intl.Locale(locale).maximize().script;
11308
+ return $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS.has(script);
11309
+ } // If not, just guess by the language (first part of the locale)
11310
+
11311
+
11312
+ let lang = locale.split('-')[0];
11313
+ return $d26e725ad56fbcb2c25f52b7de27$var$RTL_LANGS.has(lang);
11314
+ }
11315
+
11316
+ /**
11317
+ * Gets the locale setting of the browser.
11318
+ */
11319
+ function $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale() {
11320
+ // @ts-ignore
11321
+ let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
11322
+ return {
11323
+ locale,
11324
+ direction: $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) ? 'rtl' : 'ltr'
11325
+ };
11326
+ }
11327
+
11328
+ let $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();
11329
+ let $e851d0b81d46abd5f971c8e95c27f1$var$listeners = new Set();
11330
+
11331
+ function $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale() {
11332
+ $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();
11333
+
11334
+ for (let listener of $e851d0b81d46abd5f971c8e95c27f1$var$listeners) {
11335
+ listener($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale);
11336
+ }
11337
+ }
11338
+ /**
11339
+ * Returns the current browser/system language, and updates when it changes.
11340
+ */
11341
+
11342
+
11343
+ function $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale() {
11344
+ let isSSR = useIsSSR();
11345
+ let [defaultLocale, setDefaultLocale] = React.useState($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale);
11346
+ React.useEffect(() => {
11347
+ if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {
11348
+ window.addEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);
11349
+ }
11350
+
11351
+ $e851d0b81d46abd5f971c8e95c27f1$var$listeners.add(setDefaultLocale);
11352
+ return () => {
11353
+ $e851d0b81d46abd5f971c8e95c27f1$var$listeners.delete(setDefaultLocale);
11354
+
11355
+ if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {
11356
+ window.removeEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);
11357
+ }
11358
+ };
11359
+ }, []); // We cannot determine the browser's language on the server, so default to
11360
+ // en-US. This will be updated after hydration on the client to the correct value.
11361
+
11362
+ if (isSSR) {
11363
+ return {
11364
+ locale: 'en-US',
11365
+ direction: 'ltr'
11366
+ };
11367
+ }
11368
+
11369
+ return defaultLocale;
11370
+ }
11371
+
11372
+ const $cff8541df3b5c83067b2ab3ee0d20$var$I18nContext = /*#__PURE__*/React__default['default'].createContext(null);
11373
+ /**
11374
+ * Returns the current locale and layout direction.
11375
+ */
11376
+
11377
+ function useLocale() {
11378
+ let defaultLocale = $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale();
11379
+ let context = React.useContext($cff8541df3b5c83067b2ab3ee0d20$var$I18nContext);
11380
+ return context || defaultLocale;
11381
+ }
11382
+
11383
+ // During SSR, React emits a warning when calling useLayoutEffect.
11384
+ // Since neither useLayoutEffect nor useEffect run on the server,
11385
+ // we can suppress this by replace it with a noop on the server.
11386
+ const useLayoutEffect = typeof window !== 'undefined' ? React__default['default'].useLayoutEffect : () => {};
11387
+ let $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap = new Map();
11388
+ /**
11389
+ * If a default is not provided, generate an id.
11390
+ * @param defaultId - Default component id.
11391
+ */
11392
+
11393
+ function useId(defaultId) {
11394
+ let isRendering = React.useRef(true);
11395
+ isRendering.current = true;
11396
+ let [value, setValue] = React.useState(defaultId);
11397
+ let nextId = React.useRef(null);
11398
+ let res = useSSRSafeId(value); // don't memo this, we want it new each render so that the Effects always run
11399
+
11400
+ let updateValue = val => {
11401
+ if (!isRendering.current) {
11402
+ setValue(val);
11403
+ } else {
11404
+ nextId.current = val;
11405
+ }
11406
+ };
11407
+
11408
+ $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.set(res, updateValue);
11409
+ useLayoutEffect(() => {
11410
+ isRendering.current = false;
11411
+ }, [updateValue]);
11412
+ useLayoutEffect(() => {
11413
+ let r = res;
11414
+ return () => {
11415
+ $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.delete(r);
11416
+ };
11417
+ }, [res]);
11418
+ React.useEffect(() => {
11419
+ let newId = nextId.current;
11420
+
11421
+ if (newId) {
11422
+ setValue(newId);
11423
+ nextId.current = null;
11424
+ }
11425
+ }, [setValue, updateValue]);
11426
+ return res;
11427
+ }
11428
+ /**
11429
+ * Merges two ids.
11430
+ * Different ids will trigger a side-effect and re-render components hooked up with `useId`.
11431
+ */
11432
+
11433
+ function mergeIds(idA, idB) {
11434
+ if (idA === idB) {
11435
+ return idA;
11436
+ }
11437
+
11438
+ let setIdA = $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.get(idA);
11439
+
11440
+ if (setIdA) {
11441
+ setIdA(idB);
11442
+ return idB;
11443
+ }
11444
+
11445
+ let setIdB = $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.get(idB);
11446
+
11447
+ if (setIdB) {
11448
+ setIdB(idA);
11449
+ return idA;
11450
+ }
11451
+
11452
+ return idB;
11453
+ }
11454
+
11455
+ /*
11456
+ * Copyright 2020 Adobe. All rights reserved.
11457
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11458
+ * you may not use this file except in compliance with the License. You may obtain a copy
11459
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11460
+ *
11461
+ * Unless required by applicable law or agreed to in writing, software distributed under
11462
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11463
+ * OF ANY KIND, either express or implied. See the License for the specific language
11464
+ * governing permissions and limitations under the License.
11465
+ */
11466
+
11467
+ /**
11468
+ * Calls all functions in the order they were chained with the same arguments.
11469
+ */
11470
+ function chain() {
11471
+ for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
11472
+ callbacks[_key] = arguments[_key];
11473
+ }
11474
+
11475
+ return function () {
11476
+ for (let callback of callbacks) {
11477
+ if (typeof callback === 'function') {
11478
+ callback(...arguments);
11479
+ }
11480
+ }
11481
+ };
11482
+ }
11483
+
11484
+ /**
11485
+ * Merges multiple props objects together. Event handlers are chained,
11486
+ * classNames are combined, and ids are deduplicated - different ids
11487
+ * will trigger a side-effect and re-render components hooked up with `useId`.
11488
+ * For all other props, the last prop object overrides all previous ones.
11489
+ * @param args - Multiple sets of props to merge together.
11490
+ */
11491
+ function mergeProps() {
11492
+ let result = {};
11493
+
11494
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
11495
+ args[_key] = arguments[_key];
11496
+ }
11497
+
11498
+ for (let props of args) {
11499
+ for (let key in result) {
11500
+ // Chain events
11501
+ if (/^on[A-Z]/.test(key) && typeof result[key] === 'function' && typeof props[key] === 'function') {
11502
+ result[key] = chain(result[key], props[key]); // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check
11503
+ } else if (key === 'className' && typeof result.className === 'string' && typeof props.className === 'string') {
11504
+ result[key] = clsx__default['default'](result.className, props.className);
11505
+ } else if (key === 'UNSAFE_className' && typeof result.UNSAFE_className === 'string' && typeof props.UNSAFE_className === 'string') {
11506
+ result[key] = clsx__default['default'](result.UNSAFE_className, props.UNSAFE_className);
11507
+ } else if (key === 'id' && result.id && props.id) {
11508
+ result.id = mergeIds(result.id, props.id); // Override others
11509
+ } else {
11510
+ result[key] = props[key] !== undefined ? props[key] : result[key];
11511
+ }
11512
+ } // Add props from b that are not in a
11513
+
11514
+
11515
+ for (let key in props) {
11516
+ if (result[key] === undefined) {
11517
+ result[key] = props[key];
11518
+ }
11519
+ }
11520
+ }
11521
+
11522
+ return result;
11523
+ }
11524
+ // Currently necessary for Safari and old Edge:
11525
+ // https://caniuse.com/#feat=mdn-api_htmlelement_focus_preventscroll_option
11526
+ // See https://bugs.webkit.org/show_bug.cgi?id=178583
11527
+ //
11528
+ // Original licensing for the following methods can be found in the
11529
+ // NOTICE file in the root directory of this source tree.
11530
+ // See https://github.com/calvellido/focus-options-polyfill
11531
+ function focusWithoutScrolling(element) {
11532
+ if ($bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScroll()) {
11533
+ element.focus({
11534
+ preventScroll: true
11535
+ });
11536
+ } else {
11537
+ let scrollableElements = $bc7c9c3af78f5218ff72cecce15730$var$getScrollableElements(element);
11538
+ element.focus();
11539
+ $bc7c9c3af78f5218ff72cecce15730$var$restoreScrollPosition(scrollableElements);
11540
+ }
11541
+ }
11542
+ let $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached = null;
11543
+
11544
+ function $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScroll() {
11545
+ if ($bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached == null) {
11546
+ $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached = false;
11547
+
11548
+ try {
11549
+ var focusElem = document.createElement('div');
11550
+ focusElem.focus({
11551
+ get preventScroll() {
11552
+ $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached = true;
11553
+ return true;
11554
+ }
11555
+
11556
+ });
11557
+ } catch (e) {// Ignore
11558
+ }
11559
+ }
11560
+
11561
+ return $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached;
11562
+ }
11563
+
11564
+ function $bc7c9c3af78f5218ff72cecce15730$var$getScrollableElements(element) {
11565
+ var parent = element.parentNode;
11566
+ var scrollableElements = [];
11567
+ var rootScrollingElement = document.scrollingElement || document.documentElement;
11568
+
11569
+ while (parent instanceof HTMLElement && parent !== rootScrollingElement) {
11570
+ if (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) {
11571
+ scrollableElements.push({
11572
+ element: parent,
11573
+ scrollTop: parent.scrollTop,
11574
+ scrollLeft: parent.scrollLeft
11575
+ });
11576
+ }
11577
+
11578
+ parent = parent.parentNode;
11579
+ }
11580
+
11581
+ if (rootScrollingElement instanceof HTMLElement) {
11582
+ scrollableElements.push({
11583
+ element: rootScrollingElement,
11584
+ scrollTop: rootScrollingElement.scrollTop,
11585
+ scrollLeft: rootScrollingElement.scrollLeft
11586
+ });
11587
+ }
11588
+
11589
+ return scrollableElements;
11590
+ }
11591
+
11592
+ function $bc7c9c3af78f5218ff72cecce15730$var$restoreScrollPosition(scrollableElements) {
11593
+ for (let {
11594
+ element,
11595
+ scrollTop,
11596
+ scrollLeft
11597
+ } of scrollableElements) {
11598
+ element.scrollTop = scrollTop;
11599
+ element.scrollLeft = scrollLeft;
11600
+ }
11601
+ }
11602
+ // mapped to a set of CSS properties that are transitioning for that element.
11603
+ // This is necessary rather than a simple count of transitions because of browser
11604
+ // bugs, e.g. Chrome sometimes fires both transitionend and transitioncancel rather
11605
+ // than one or the other. So we need to track what's actually transitioning so that
11606
+ // we can ignore these duplicate events.
11607
+ let $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement = new Map(); // A list of callbacks to call once there are no transitioning elements.
11608
+
11609
+ let $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks = new Set();
11610
+
11611
+ function $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$setupGlobalEvents() {
11612
+ if (typeof window === 'undefined') {
11613
+ return;
11614
+ }
11615
+
11616
+ let onTransitionStart = e => {
11617
+ // Add the transitioning property to the list for this element.
11618
+ let transitions = $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.get(e.target);
11619
+
11620
+ if (!transitions) {
11621
+ transitions = new Set();
11622
+ $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.set(e.target, transitions); // The transitioncancel event must be registered on the element itself, rather than as a global
11623
+ // event. This enables us to handle when the node is deleted from the document while it is transitioning.
11624
+ // In that case, the cancel event would have nowhere to bubble to so we need to handle it directly.
11625
+
11626
+ e.target.addEventListener('transitioncancel', onTransitionEnd);
11627
+ }
11628
+
11629
+ transitions.add(e.propertyName);
11630
+ };
11631
+
11632
+ let onTransitionEnd = e => {
11633
+ // Remove property from list of transitioning properties.
11634
+ let properties = $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.get(e.target);
11635
+
11636
+ if (!properties) {
11637
+ return;
11638
+ }
11639
+
11640
+ properties.delete(e.propertyName); // If empty, remove transitioncancel event, and remove the element from the list of transitioning elements.
11641
+
11642
+ if (properties.size === 0) {
11643
+ e.target.removeEventListener('transitioncancel', onTransitionEnd);
11644
+ $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.delete(e.target);
11645
+ } // If no transitioning elements, call all of the queued callbacks.
11646
+
11647
+
11648
+ if ($b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.size === 0) {
11649
+ for (let cb of $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks) {
11650
+ cb();
11651
+ }
11652
+
11653
+ $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks.clear();
11654
+ }
11655
+ };
11656
+
11657
+ document.body.addEventListener('transitionrun', onTransitionStart);
11658
+ document.body.addEventListener('transitionend', onTransitionEnd);
11659
+ }
11660
+
11661
+ if (typeof document !== 'undefined') {
11662
+ if (document.readyState !== 'loading') {
11663
+ $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$setupGlobalEvents();
11664
+ } else {
11665
+ document.addEventListener('DOMContentLoaded', $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$setupGlobalEvents);
11666
+ }
11667
+ }
11668
+
11669
+ function runAfterTransition(fn) {
11670
+ // Wait one frame to see if an animation starts, e.g. a transition on mount.
11671
+ requestAnimationFrame(() => {
11672
+ // If no transitions are running, call the function immediately.
11673
+ // Otherwise, add it to a list of callbacks to run at the end of the animation.
11674
+ if ($b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.size === 0) {
11675
+ fn();
11676
+ } else {
11677
+ $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks.add(fn);
11678
+ }
11679
+ });
11680
+ }
11681
+ function useGlobalListeners() {
11682
+ let globalListeners = React.useRef(new Map());
11683
+ let addGlobalListener = React.useCallback((eventTarget, type, listener, options) => {
11684
+ globalListeners.current.set(listener, {
11685
+ type,
11686
+ eventTarget,
11687
+ options
11688
+ });
11689
+ eventTarget.addEventListener(type, listener, options);
11690
+ }, []);
11691
+ let removeGlobalListener = React.useCallback((eventTarget, type, listener, options) => {
11692
+ eventTarget.removeEventListener(type, listener, options);
11693
+ globalListeners.current.delete(listener);
11694
+ }, []);
11695
+ let removeAllGlobalListeners = React.useCallback(() => {
11696
+ globalListeners.current.forEach((value, key) => {
11697
+ removeGlobalListener(value.eventTarget, value.type, key, value.options);
11698
+ });
11699
+ }, [removeGlobalListener]); // eslint-disable-next-line arrow-body-style
11700
+
11701
+ React.useEffect(() => {
11702
+ return removeAllGlobalListeners;
11703
+ }, [removeAllGlobalListeners]);
11704
+ return {
11705
+ addGlobalListener,
11706
+ removeGlobalListener,
11707
+ removeAllGlobalListeners
11708
+ };
11709
+ }
11710
+
11711
+ /**
11712
+ * Merges aria-label and aria-labelledby into aria-labelledby when both exist.
11713
+ * @param props - Aria label props.
11714
+ * @param defaultLabel - Default value for aria-label when not present.
11715
+ */
11716
+ function useLabels(props, defaultLabel) {
11717
+ let {
11718
+ id,
11719
+ 'aria-label': label,
11720
+ 'aria-labelledby': labelledBy
11721
+ } = props; // If there is both an aria-label and aria-labelledby,
11722
+ // combine them by pointing to the element itself.
11723
+
11724
+ id = useId(id);
11725
+
11726
+ if (labelledBy && label) {
11727
+ let ids = new Set([...labelledBy.trim().split(/\s+/), id]);
11728
+ labelledBy = [...ids].join(' ');
11729
+ } else if (labelledBy) {
11730
+ labelledBy = labelledBy.trim().split(/\s+/).join(' ');
11731
+ } // If no labels are provided, use the default
11732
+
11733
+
11734
+ if (!label && !labelledBy && defaultLabel) {
11735
+ label = defaultLabel;
11736
+ }
11737
+
11738
+ return {
11739
+ id,
11740
+ 'aria-label': label,
11741
+ 'aria-labelledby': labelledBy
11742
+ };
11743
+ }
11744
+ // Syncs ref from context with ref passed to hook
11745
+ function useSyncRef(context, ref) {
11746
+ useLayoutEffect(() => {
11747
+ if (context && context.ref && ref) {
11748
+ context.ref.current = ref.current;
11749
+ return () => {
11750
+ context.ref.current = null;
11751
+ };
11752
+ }
11753
+ }, [context, ref]);
11754
+ }
11755
+
11756
+ function $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(re) {
11757
+ return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : false;
11758
+ }
11759
+
11760
+ function isMac() {
11761
+ return $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(/^Mac/);
11762
+ }
11763
+
11764
+ function _objectWithoutPropertiesLoose(source, excluded) {
11765
+ if (source == null) return {};
11766
+ var target = {};
11767
+ var sourceKeys = Object.keys(source);
11768
+ var key, i;
11769
+
11770
+ for (i = 0; i < sourceKeys.length; i++) {
11771
+ key = sourceKeys[i];
11772
+ if (excluded.indexOf(key) >= 0) continue;
11773
+ target[key] = source[key];
11774
+ }
11775
+
11776
+ return target;
11777
+ }
11778
+
11779
+ let $e17c9db826984f8ab8e5d837bf0b8$var$state = 'default';
11780
+ let $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect = '';
11781
+
11782
+ function $e17c9db826984f8ab8e5d837bf0b8$export$disableTextSelection() {
11783
+ if ($e17c9db826984f8ab8e5d837bf0b8$var$state === 'default') {
11784
+ $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect = document.documentElement.style.webkitUserSelect;
11785
+ document.documentElement.style.webkitUserSelect = 'none';
11786
+ }
11787
+
11788
+ $e17c9db826984f8ab8e5d837bf0b8$var$state = 'disabled';
11789
+ }
11790
+
11791
+ function $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection() {
11792
+ // If the state is already default, there's nothing to do.
11793
+ // If it is restoring, then there's no need to queue a second restore.
11794
+ if ($e17c9db826984f8ab8e5d837bf0b8$var$state !== 'disabled') {
11795
+ return;
11796
+ }
11797
+
11798
+ $e17c9db826984f8ab8e5d837bf0b8$var$state = 'restoring'; // There appears to be a delay on iOS where selection still might occur
11799
+ // after pointer up, so wait a bit before removing user-select.
11800
+
11801
+ setTimeout(() => {
11802
+ // Wait for any CSS transitions to complete so we don't recompute style
11803
+ // for the whole page in the middle of the animation and cause jank.
11804
+ runAfterTransition(() => {
11805
+ // Avoid race conditions
11806
+ if ($e17c9db826984f8ab8e5d837bf0b8$var$state === 'restoring') {
11807
+ if (document.documentElement.style.webkitUserSelect === 'none') {
11808
+ document.documentElement.style.webkitUserSelect = $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect || '';
11809
+ }
11810
+
11811
+ $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect = '';
11812
+ $e17c9db826984f8ab8e5d837bf0b8$var$state = 'default';
11813
+ }
11814
+ });
11815
+ }, 300);
11816
+ }
11817
+
11818
+ /*
11819
+ * Copyright 2020 Adobe. All rights reserved.
11820
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11821
+ * you may not use this file except in compliance with the License. You may obtain a copy
11822
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11823
+ *
11824
+ * Unless required by applicable law or agreed to in writing, software distributed under
11825
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11826
+ * OF ANY KIND, either express or implied. See the License for the specific language
11827
+ * governing permissions and limitations under the License.
11828
+ */
11829
+ // Original licensing for the following method can be found in the
11830
+ // NOTICE file in the root directory of this source tree.
11831
+ // See https://github.com/facebook/react/blob/3c713d513195a53788b3f8bb4b70279d68b15bcc/packages/react-interactions/events/src/dom/shared/index.js#L74-L87
11832
+ // Keyboards, Assistive Technologies, and element.click() all produce a "virtual"
11833
+ // click event. This is a method of inferring such clicks. Every browser except
11834
+ // IE 11 only sets a zero value of "detail" for click events that are "virtual".
11835
+ // However, IE 11 uses a zero value for all click events. For IE 11 we rely on
11836
+ // the quirk that it produces click events that are of type PointerEvent, and
11837
+ // where only the "virtual" click lacks a pointerType field.
11838
+ function $f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(event) {
11839
+ // JAWS/NVDA with Firefox.
11840
+ if (event.mozInputSource === 0 && event.isTrusted) {
11841
+ return true;
11842
+ }
11843
+
11844
+ return event.detail === 0 && !event.pointerType;
11845
+ }
11846
+
11847
+ const $a3ff51240de6f955c79cf17a88e349$export$PressResponderContext = /*#__PURE__*/React__default['default'].createContext(null);
11848
+
11849
+ $a3ff51240de6f955c79cf17a88e349$export$PressResponderContext.displayName = 'PressResponderContext';
11850
+
11851
+ function $ffc54430b1dbeee65879852feaaff07d$var$usePressResponderContext(props) {
11852
+ // Consume context from <PressResponder> and merge with props.
11853
+ let context = React.useContext($a3ff51240de6f955c79cf17a88e349$export$PressResponderContext);
11854
+
11855
+ if (context) {
11856
+ let {
11857
+ register
11858
+ } = context,
11859
+ contextProps = _objectWithoutPropertiesLoose(context, ["register"]);
11860
+
11861
+ props = mergeProps(contextProps, props);
11862
+ register();
11863
+ }
11864
+
11865
+ useSyncRef(context, props.ref);
11866
+ return props;
11867
+ }
11868
+ /**
11869
+ * Handles press interactions across mouse, touch, keyboard, and screen readers.
11870
+ * It normalizes behavior across browsers and platforms, and handles many nuances
11871
+ * of dealing with pointer and keyboard events.
11872
+ */
11873
+
11874
+
11875
+ function usePress(props) {
11876
+ let _usePressResponderCon = $ffc54430b1dbeee65879852feaaff07d$var$usePressResponderContext(props),
11877
+ {
11878
+ onPress,
11879
+ onPressChange,
11880
+ onPressStart,
11881
+ onPressEnd,
11882
+ onPressUp,
11883
+ isDisabled,
11884
+ isPressed: isPressedProp,
11885
+ preventFocusOnPress
11886
+ } = _usePressResponderCon,
11887
+ domProps = _objectWithoutPropertiesLoose(_usePressResponderCon, ["onPress", "onPressChange", "onPressStart", "onPressEnd", "onPressUp", "isDisabled", "isPressed", "preventFocusOnPress", "ref"]);
11888
+
11889
+ let propsRef = React.useRef(null);
11890
+ propsRef.current = {
11891
+ onPress,
11892
+ onPressChange,
11893
+ onPressStart,
11894
+ onPressEnd,
11895
+ onPressUp,
11896
+ isDisabled
11897
+ };
11898
+ let [isPressed, setPressed] = React.useState(false);
11899
+ let ref = React.useRef({
11900
+ isPressed: false,
11901
+ ignoreEmulatedMouseEvents: false,
11902
+ ignoreClickAfterPress: false,
11903
+ didFirePressStart: false,
11904
+ activePointerId: null,
11905
+ target: null,
11906
+ isOverTarget: false,
11907
+ pointerType: null
11908
+ });
11909
+ let {
11910
+ addGlobalListener,
11911
+ removeAllGlobalListeners
11912
+ } = useGlobalListeners();
11913
+ let pressProps = React.useMemo(() => {
11914
+ let state = ref.current;
11915
+
11916
+ let triggerPressStart = (originalEvent, pointerType) => {
11917
+ let {
11918
+ onPressStart,
11919
+ onPressChange,
11920
+ isDisabled
11921
+ } = propsRef.current;
11922
+
11923
+ if (isDisabled || state.didFirePressStart) {
11924
+ return;
11925
+ }
11926
+
11927
+ if (onPressStart) {
11928
+ onPressStart({
11929
+ type: 'pressstart',
11930
+ pointerType,
11931
+ target: originalEvent.currentTarget,
11932
+ shiftKey: originalEvent.shiftKey,
11933
+ metaKey: originalEvent.metaKey,
11934
+ ctrlKey: originalEvent.ctrlKey
11935
+ });
11936
+ }
11937
+
11938
+ if (onPressChange) {
11939
+ onPressChange(true);
11940
+ }
11941
+
11942
+ state.didFirePressStart = true;
11943
+ setPressed(true);
11944
+ };
11945
+
11946
+ let triggerPressEnd = function triggerPressEnd(originalEvent, pointerType, wasPressed) {
11947
+ if (wasPressed === void 0) {
11948
+ wasPressed = true;
11949
+ }
11950
+
11951
+ let {
11952
+ onPressEnd,
11953
+ onPressChange,
11954
+ onPress,
11955
+ isDisabled
11956
+ } = propsRef.current;
11957
+
11958
+ if (!state.didFirePressStart) {
11959
+ return;
11960
+ }
11961
+
11962
+ state.ignoreClickAfterPress = true;
11963
+ state.didFirePressStart = false;
11964
+
11965
+ if (onPressEnd) {
11966
+ onPressEnd({
11967
+ type: 'pressend',
11968
+ pointerType,
11969
+ target: originalEvent.currentTarget,
11970
+ shiftKey: originalEvent.shiftKey,
11971
+ metaKey: originalEvent.metaKey,
11972
+ ctrlKey: originalEvent.ctrlKey
11973
+ });
11974
+ }
11975
+
11976
+ if (onPressChange) {
11977
+ onPressChange(false);
11978
+ }
11979
+
11980
+ setPressed(false);
11981
+
11982
+ if (onPress && wasPressed && !isDisabled) {
11983
+ onPress({
11984
+ type: 'press',
11985
+ pointerType,
11986
+ target: originalEvent.currentTarget,
11987
+ shiftKey: originalEvent.shiftKey,
11988
+ metaKey: originalEvent.metaKey,
11989
+ ctrlKey: originalEvent.ctrlKey
11990
+ });
11991
+ }
11992
+ };
11993
+
11994
+ let triggerPressUp = (originalEvent, pointerType) => {
11995
+ let {
11996
+ onPressUp,
11997
+ isDisabled
11998
+ } = propsRef.current;
11999
+
12000
+ if (isDisabled) {
12001
+ return;
12002
+ }
12003
+
12004
+ if (onPressUp) {
12005
+ onPressUp({
12006
+ type: 'pressup',
12007
+ pointerType,
12008
+ target: originalEvent.currentTarget,
12009
+ shiftKey: originalEvent.shiftKey,
12010
+ metaKey: originalEvent.metaKey,
12011
+ ctrlKey: originalEvent.ctrlKey
12012
+ });
12013
+ }
12014
+ };
12015
+
12016
+ let cancel = e => {
12017
+ if (state.isPressed) {
12018
+ if (state.isOverTarget) {
12019
+ triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12020
+ }
12021
+
12022
+ state.isPressed = false;
12023
+ state.isOverTarget = false;
12024
+ state.activePointerId = null;
12025
+ state.pointerType = null;
12026
+ removeAllGlobalListeners();
12027
+ $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12028
+ }
12029
+ };
12030
+
12031
+ let pressProps = {
12032
+ onKeyDown(e) {
12033
+ if ($ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(e.nativeEvent) && e.currentTarget.contains(e.target)) {
12034
+ e.preventDefault();
12035
+ e.stopPropagation(); // If the event is repeating, it may have started on a different element
12036
+ // after which focus moved to the current element. Ignore these events and
12037
+ // only handle the first key down event.
12038
+
12039
+ if (!state.isPressed && !e.repeat) {
12040
+ state.target = e.currentTarget;
12041
+ state.isPressed = true;
12042
+ triggerPressStart(e, 'keyboard'); // Focus may move before the key up event, so register the event on the document
12043
+ // instead of the same element where the key down event occurred.
12044
+
12045
+ addGlobalListener(document, 'keyup', onKeyUp, false);
12046
+ }
12047
+ }
12048
+ },
12049
+
12050
+ onKeyUp(e) {
12051
+ if ($ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(e.nativeEvent) && !e.repeat && e.currentTarget.contains(e.target)) {
12052
+ triggerPressUp($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), 'keyboard');
12053
+ }
12054
+ },
12055
+
12056
+ onClick(e) {
12057
+ if (e && !e.currentTarget.contains(e.target)) {
12058
+ return;
12059
+ }
12060
+
12061
+ if (e && e.button === 0) {
12062
+ e.stopPropagation();
12063
+
12064
+ if (isDisabled) {
12065
+ e.preventDefault();
12066
+ } // If triggered from a screen reader or by using element.click(),
12067
+ // trigger as if it were a keyboard click.
12068
+
12069
+
12070
+ if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && $f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(e.nativeEvent)) {
12071
+ // Ensure the element receives focus (VoiceOver on iOS does not do this)
12072
+ if (!isDisabled && !preventFocusOnPress) {
12073
+ focusWithoutScrolling(e.currentTarget);
12074
+ }
12075
+
12076
+ triggerPressStart(e, 'virtual');
12077
+ triggerPressUp(e, 'virtual');
12078
+ triggerPressEnd(e, 'virtual');
12079
+ }
12080
+
12081
+ state.ignoreEmulatedMouseEvents = false;
12082
+ state.ignoreClickAfterPress = false;
12083
+ }
12084
+ }
12085
+
12086
+ };
12087
+
12088
+ let onKeyUp = e => {
12089
+ if (state.isPressed && $ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(e)) {
12090
+ e.preventDefault();
12091
+ e.stopPropagation();
12092
+ state.isPressed = false;
12093
+ triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), 'keyboard', e.target === state.target);
12094
+ removeAllGlobalListeners(); // If the target is a link, trigger the click method to open the URL,
12095
+ // but defer triggering pressEnd until onClick event handler.
12096
+
12097
+ if (e.target === state.target && $ffc54430b1dbeee65879852feaaff07d$var$isHTMLAnchorLink(state.target) || state.target.getAttribute('role') === 'link') {
12098
+ state.target.click();
12099
+ }
12100
+ }
12101
+ };
12102
+
12103
+ if (typeof PointerEvent !== 'undefined') {
12104
+ pressProps.onPointerDown = e => {
12105
+ // Only handle left clicks, and ignore events that bubbled through portals.
12106
+ if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
12107
+ return;
12108
+ } // Due to browser inconsistencies, especially on mobile browsers, we prevent
12109
+ // default on pointer down and handle focusing the pressable element ourselves.
12110
+
12111
+
12112
+ if ($ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(e.target)) {
12113
+ e.preventDefault();
12114
+ } // iOS safari fires pointer events from VoiceOver (but only when outside an iframe...)
12115
+ // https://bugs.webkit.org/show_bug.cgi?id=222627
12116
+
12117
+
12118
+ state.pointerType = $ffc54430b1dbeee65879852feaaff07d$var$isVirtualPointerEvent(e.nativeEvent) ? 'virtual' : e.pointerType;
12119
+ e.stopPropagation();
12120
+
12121
+ if (!state.isPressed) {
12122
+ state.isPressed = true;
12123
+ state.isOverTarget = true;
12124
+ state.activePointerId = e.pointerId;
12125
+ state.target = e.currentTarget;
12126
+
12127
+ if (!isDisabled && !preventFocusOnPress) {
12128
+ focusWithoutScrolling(e.currentTarget);
12129
+ }
12130
+
12131
+ $e17c9db826984f8ab8e5d837bf0b8$export$disableTextSelection();
12132
+ triggerPressStart(e, state.pointerType);
12133
+ addGlobalListener(document, 'pointermove', onPointerMove, false);
12134
+ addGlobalListener(document, 'pointerup', onPointerUp, false);
12135
+ addGlobalListener(document, 'pointercancel', onPointerCancel, false);
12136
+ }
12137
+ };
12138
+
12139
+ pressProps.onMouseDown = e => {
12140
+ if (!e.currentTarget.contains(e.target)) {
12141
+ return;
12142
+ }
12143
+
12144
+ if (e.button === 0) {
12145
+ // Chrome and Firefox on touch Windows devices require mouse down events
12146
+ // to be canceled in addition to pointer events, or an extra asynchronous
12147
+ // focus event will be fired.
12148
+ if ($ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(e.target)) {
12149
+ e.preventDefault();
12150
+ }
12151
+
12152
+ e.stopPropagation();
12153
+ }
12154
+ };
12155
+
12156
+ pressProps.onPointerUp = e => {
12157
+ if (!e.currentTarget.contains(e.target)) {
12158
+ return;
12159
+ } // Only handle left clicks
12160
+ // Safari on iOS sometimes fires pointerup events, even
12161
+ // when the touch isn't over the target, so double check.
12162
+
12163
+
12164
+ if (e.button === 0 && $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, e.currentTarget)) {
12165
+ triggerPressUp(e, state.pointerType);
12166
+ }
12167
+ }; // Safari on iOS < 13.2 does not implement pointerenter/pointerleave events correctly.
12168
+ // Use pointer move events instead to implement our own hit testing.
12169
+ // See https://bugs.webkit.org/show_bug.cgi?id=199803
12170
+
12171
+
12172
+ let onPointerMove = e => {
12173
+ if (e.pointerId !== state.activePointerId) {
12174
+ return;
12175
+ }
12176
+
12177
+ if ($ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, state.target)) {
12178
+ if (!state.isOverTarget) {
12179
+ state.isOverTarget = true;
12180
+ triggerPressStart($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType);
12181
+ }
12182
+ } else if (state.isOverTarget) {
12183
+ state.isOverTarget = false;
12184
+ triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12185
+ }
12186
+ };
12187
+
12188
+ let onPointerUp = e => {
12189
+ if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0) {
12190
+ if ($ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, state.target)) {
12191
+ triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType);
12192
+ } else if (state.isOverTarget) {
12193
+ triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12194
+ }
12195
+
12196
+ state.isPressed = false;
12197
+ state.isOverTarget = false;
12198
+ state.activePointerId = null;
12199
+ state.pointerType = null;
12200
+ removeAllGlobalListeners();
12201
+ $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12202
+ }
12203
+ };
12204
+
12205
+ let onPointerCancel = e => {
12206
+ cancel(e);
12207
+ };
12208
+
12209
+ pressProps.onDragStart = e => {
12210
+ if (!e.currentTarget.contains(e.target)) {
12211
+ return;
12212
+ } // Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.
12213
+
12214
+
12215
+ cancel(e);
12216
+ };
12217
+ } else {
12218
+ pressProps.onMouseDown = e => {
12219
+ // Only handle left clicks
12220
+ if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
12221
+ return;
12222
+ } // Due to browser inconsistencies, especially on mobile browsers, we prevent
12223
+ // default on mouse down and handle focusing the pressable element ourselves.
12224
+
12225
+
12226
+ if ($ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(e.target)) {
12227
+ e.preventDefault();
12228
+ }
12229
+
12230
+ e.stopPropagation();
12231
+
12232
+ if (state.ignoreEmulatedMouseEvents) {
12233
+ return;
12234
+ }
12235
+
12236
+ state.isPressed = true;
12237
+ state.isOverTarget = true;
12238
+ state.target = e.currentTarget;
12239
+ state.pointerType = $f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(e.nativeEvent) ? 'virtual' : 'mouse';
12240
+
12241
+ if (!isDisabled && !preventFocusOnPress) {
12242
+ focusWithoutScrolling(e.currentTarget);
12243
+ }
12244
+
12245
+ triggerPressStart(e, state.pointerType);
12246
+ addGlobalListener(document, 'mouseup', onMouseUp, false);
12247
+ };
12248
+
12249
+ pressProps.onMouseEnter = e => {
12250
+ if (!e.currentTarget.contains(e.target)) {
12251
+ return;
12252
+ }
12253
+
12254
+ e.stopPropagation();
12255
+
12256
+ if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
12257
+ state.isOverTarget = true;
12258
+ triggerPressStart(e, state.pointerType);
12259
+ }
12260
+ };
12261
+
12262
+ pressProps.onMouseLeave = e => {
12263
+ if (!e.currentTarget.contains(e.target)) {
12264
+ return;
12265
+ }
12266
+
12267
+ e.stopPropagation();
12268
+
12269
+ if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
12270
+ state.isOverTarget = false;
12271
+ triggerPressEnd(e, state.pointerType, false);
12272
+ }
12273
+ };
12274
+
12275
+ pressProps.onMouseUp = e => {
12276
+ if (!e.currentTarget.contains(e.target)) {
12277
+ return;
12278
+ }
12279
+
12280
+ if (!state.ignoreEmulatedMouseEvents && e.button === 0) {
12281
+ triggerPressUp(e, state.pointerType);
12282
+ }
12283
+ };
12284
+
12285
+ let onMouseUp = e => {
12286
+ // Only handle left clicks
12287
+ if (e.button !== 0) {
12288
+ return;
12289
+ }
12290
+
12291
+ state.isPressed = false;
12292
+ removeAllGlobalListeners();
12293
+
12294
+ if (state.ignoreEmulatedMouseEvents) {
12295
+ state.ignoreEmulatedMouseEvents = false;
12296
+ return;
12297
+ }
12298
+
12299
+ if ($ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, state.target)) {
12300
+ triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType);
12301
+ } else if (state.isOverTarget) {
12302
+ triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12303
+ }
12304
+
12305
+ state.isOverTarget = false;
12306
+ };
12307
+
12308
+ pressProps.onTouchStart = e => {
12309
+ if (!e.currentTarget.contains(e.target)) {
12310
+ return;
12311
+ }
12312
+
12313
+ e.stopPropagation();
12314
+ let touch = $ffc54430b1dbeee65879852feaaff07d$var$getTouchFromEvent(e.nativeEvent);
12315
+
12316
+ if (!touch) {
12317
+ return;
12318
+ }
12319
+
12320
+ state.activePointerId = touch.identifier;
12321
+ state.ignoreEmulatedMouseEvents = true;
12322
+ state.isOverTarget = true;
12323
+ state.isPressed = true;
12324
+ state.target = e.currentTarget;
12325
+ state.pointerType = 'touch'; // Due to browser inconsistencies, especially on mobile browsers, we prevent default
12326
+ // on the emulated mouse event and handle focusing the pressable element ourselves.
12327
+
12328
+ if (!isDisabled && !preventFocusOnPress) {
12329
+ focusWithoutScrolling(e.currentTarget);
12330
+ }
12331
+
12332
+ $e17c9db826984f8ab8e5d837bf0b8$export$disableTextSelection();
12333
+ triggerPressStart(e, state.pointerType);
12334
+ addGlobalListener(window, 'scroll', onScroll, true);
12335
+ };
12336
+
12337
+ pressProps.onTouchMove = e => {
12338
+ if (!e.currentTarget.contains(e.target)) {
12339
+ return;
12340
+ }
12341
+
12342
+ e.stopPropagation();
12343
+
12344
+ if (!state.isPressed) {
12345
+ return;
12346
+ }
12347
+
12348
+ let touch = $ffc54430b1dbeee65879852feaaff07d$var$getTouchById(e.nativeEvent, state.activePointerId);
12349
+
12350
+ if (touch && $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(touch, e.currentTarget)) {
12351
+ if (!state.isOverTarget) {
12352
+ state.isOverTarget = true;
12353
+ triggerPressStart(e, state.pointerType);
12354
+ }
12355
+ } else if (state.isOverTarget) {
12356
+ state.isOverTarget = false;
12357
+ triggerPressEnd(e, state.pointerType, false);
12358
+ }
12359
+ };
12360
+
12361
+ pressProps.onTouchEnd = e => {
12362
+ if (!e.currentTarget.contains(e.target)) {
12363
+ return;
12364
+ }
12365
+
12366
+ e.stopPropagation();
12367
+
12368
+ if (!state.isPressed) {
12369
+ return;
12370
+ }
12371
+
12372
+ let touch = $ffc54430b1dbeee65879852feaaff07d$var$getTouchById(e.nativeEvent, state.activePointerId);
12373
+
12374
+ if (touch && $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(touch, e.currentTarget)) {
12375
+ triggerPressUp(e, state.pointerType);
12376
+ triggerPressEnd(e, state.pointerType);
12377
+ } else if (state.isOverTarget) {
12378
+ triggerPressEnd(e, state.pointerType, false);
12379
+ }
12380
+
12381
+ state.isPressed = false;
12382
+ state.activePointerId = null;
12383
+ state.isOverTarget = false;
12384
+ state.ignoreEmulatedMouseEvents = true;
12385
+ $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12386
+ removeAllGlobalListeners();
12387
+ };
12388
+
12389
+ pressProps.onTouchCancel = e => {
12390
+ if (!e.currentTarget.contains(e.target)) {
12391
+ return;
12392
+ }
12393
+
12394
+ e.stopPropagation();
12395
+
12396
+ if (state.isPressed) {
12397
+ cancel(e);
12398
+ }
12399
+ };
12400
+
12401
+ let onScroll = e => {
12402
+ if (state.isPressed && e.target.contains(state.target)) {
12403
+ cancel({
12404
+ currentTarget: state.target,
12405
+ shiftKey: false,
12406
+ ctrlKey: false,
12407
+ metaKey: false
12408
+ });
12409
+ }
12410
+ };
12411
+
12412
+ pressProps.onDragStart = e => {
12413
+ if (!e.currentTarget.contains(e.target)) {
12414
+ return;
12415
+ }
12416
+
12417
+ cancel(e);
12418
+ };
12419
+ }
12420
+
12421
+ return pressProps;
12422
+ }, [addGlobalListener, isDisabled, preventFocusOnPress, removeAllGlobalListeners]); // Remove user-select: none in case component unmounts immediately after pressStart
12423
+ // eslint-disable-next-line arrow-body-style
12424
+
12425
+ React.useEffect(() => {
12426
+ return () => $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12427
+ }, []);
12428
+ return {
12429
+ isPressed: isPressedProp || isPressed,
12430
+ pressProps: mergeProps(domProps, pressProps)
12431
+ };
12432
+ }
12433
+
12434
+ function $ffc54430b1dbeee65879852feaaff07d$var$isHTMLAnchorLink(target) {
12435
+ return target.tagName === 'A' && target.hasAttribute('href');
12436
+ }
12437
+
12438
+ function $ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(event) {
12439
+ const {
12440
+ key,
12441
+ target
12442
+ } = event;
12443
+ const element = target;
12444
+ const {
12445
+ tagName,
12446
+ isContentEditable
12447
+ } = element;
12448
+ const role = element.getAttribute('role'); // Accessibility for keyboards. Space and Enter only.
12449
+ // "Spacebar" is for IE 11
12450
+
12451
+ return (key === 'Enter' || key === ' ' || key === 'Spacebar') && tagName !== 'INPUT' && tagName !== 'TEXTAREA' && isContentEditable !== true && ( // A link with a valid href should be handled natively,
12452
+ // unless it also has role='button' and was triggered using Space.
12453
+ !$ffc54430b1dbeee65879852feaaff07d$var$isHTMLAnchorLink(element) || role === 'button' && key !== 'Enter') && // An element with role='link' should only trigger with Enter key
12454
+ !(role === 'link' && key !== 'Enter');
12455
+ }
12456
+
12457
+ function $ffc54430b1dbeee65879852feaaff07d$var$getTouchFromEvent(event) {
12458
+ const {
12459
+ targetTouches
12460
+ } = event;
12461
+
12462
+ if (targetTouches.length > 0) {
12463
+ return targetTouches[0];
12464
+ }
12465
+
12466
+ return null;
12467
+ }
12468
+
12469
+ function $ffc54430b1dbeee65879852feaaff07d$var$getTouchById(event, pointerId) {
12470
+ const changedTouches = event.changedTouches;
12471
+
12472
+ for (let i = 0; i < changedTouches.length; i++) {
12473
+ const touch = changedTouches[i];
12474
+
12475
+ if (touch.identifier === pointerId) {
12476
+ return touch;
12477
+ }
12478
+ }
12479
+
12480
+ return null;
12481
+ }
12482
+
12483
+ function $ffc54430b1dbeee65879852feaaff07d$var$createEvent(target, e) {
12484
+ return {
12485
+ currentTarget: target,
12486
+ shiftKey: e.shiftKey,
12487
+ ctrlKey: e.ctrlKey,
12488
+ metaKey: e.metaKey
12489
+ };
12490
+ }
12491
+
12492
+ function $ffc54430b1dbeee65879852feaaff07d$var$getPointClientRect(point) {
12493
+ let offsetX = point.width / 2 || point.radiusX || 0;
12494
+ let offsetY = point.height / 2 || point.radiusY || 0;
12495
+ return {
12496
+ top: point.clientY - offsetY,
12497
+ right: point.clientX + offsetX,
12498
+ bottom: point.clientY + offsetY,
12499
+ left: point.clientX - offsetX
12500
+ };
12501
+ }
12502
+
12503
+ function $ffc54430b1dbeee65879852feaaff07d$var$areRectanglesOverlapping(a, b) {
12504
+ // check if they cannot overlap on x axis
12505
+ if (a.left > b.right || b.left > a.right) {
12506
+ return false;
12507
+ } // check if they cannot overlap on y axis
12508
+
12509
+
12510
+ if (a.top > b.bottom || b.top > a.bottom) {
12511
+ return false;
12512
+ }
12513
+
12514
+ return true;
12515
+ }
12516
+
12517
+ function $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(point, target) {
12518
+ let rect = target.getBoundingClientRect();
12519
+ let pointRect = $ffc54430b1dbeee65879852feaaff07d$var$getPointClientRect(point);
12520
+ return $ffc54430b1dbeee65879852feaaff07d$var$areRectanglesOverlapping(rect, pointRect);
12521
+ }
12522
+
12523
+ function $ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(target) {
12524
+ // We cannot prevent default if the target is inside a draggable element.
12525
+ return !target.closest('[draggable="true"]');
12526
+ }
12527
+
12528
+ function $ffc54430b1dbeee65879852feaaff07d$var$isVirtualPointerEvent(event) {
12529
+ // If the pointer size is zero, then we assume it's from a screen reader.
12530
+ return event.width === 0 && event.height === 0;
12531
+ }
12532
+ let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = null;
12533
+ let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$changeHandlers = new Set();
12534
+ let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasSetupGlobalListeners = false;
12535
+ let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = false;
12536
+ let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently = false; // Only Tab or Esc keys will make focus visible on text input elements
12537
+
12538
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers(modality, e) {
12539
+ for (let handler of $d01f69bb2ab5f70dfd0005370a2a2cbc$var$changeHandlers) {
12540
+ handler(modality, e);
12541
+ }
12542
+ }
12543
+ /**
12544
+ * Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
12545
+ */
12546
+
12547
+
12548
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$isValidKey(e) {
12549
+ // Control and Shift keys trigger when navigating back to the tab with keyboard.
12550
+ return !(e.metaKey || !isMac() && e.altKey || e.ctrlKey || e.type === 'keyup' && (e.key === 'Control' || e.key === 'Shift'));
12551
+ }
12552
+
12553
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleKeyboardEvent(e) {
12554
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
12555
+
12556
+ if ($d01f69bb2ab5f70dfd0005370a2a2cbc$var$isValidKey(e)) {
12557
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'keyboard';
12558
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers('keyboard', e);
12559
+ }
12560
+ }
12561
+
12562
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent(e) {
12563
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'pointer';
12564
+
12565
+ if (e.type === 'mousedown' || e.type === 'pointerdown') {
12566
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
12567
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers('pointer', e);
12568
+ }
12569
+ }
12570
+
12571
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleClickEvent(e) {
12572
+ if ($f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(e)) {
12573
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
12574
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'virtual';
12575
+ }
12576
+ }
12577
+
12578
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleFocusEvent(e) {
12579
+ // Firefox fires two extra focus events when the user first clicks into an iframe:
12580
+ // first on the window, then on the document. We ignore these events so they don't
12581
+ // cause keyboard focus rings to appear.
12582
+ if (e.target === window || e.target === document) {
12583
+ return;
12584
+ } // If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
12585
+ // This occurs, for example, when navigating a form with the next/previous buttons on iOS.
12586
+
12587
+
12588
+ if (!$d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus && !$d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently) {
12589
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'virtual';
12590
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers('virtual', e);
12591
+ }
12592
+
12593
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = false;
12594
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently = false;
12595
+ }
12596
+
12597
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleWindowBlur() {
12598
+ // When the window is blurred, reset state. This is necessary when tabbing out of the window,
12599
+ // for example, since a subsequent focus event won't be fired.
12600
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = false;
12601
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently = true;
12602
+ }
12603
+ /**
12604
+ * Setup global event listeners to control when keyboard focus style should be visible.
12605
+ */
12606
+
12607
+
12608
+ function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$setupGlobalFocusEvents() {
12609
+ if (typeof window === 'undefined' || $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasSetupGlobalListeners) {
12610
+ return;
12611
+ } // Programmatic focus() calls shouldn't affect the current input modality.
12612
+ // However, we need to detect other cases when a focus event occurs without
12613
+ // a preceding user event (e.g. screen reader focus). Overriding the focus
12614
+ // method on HTMLElement.prototype is a bit hacky, but works.
12615
+
12616
+
12617
+ let focus = HTMLElement.prototype.focus;
12618
+
12619
+ HTMLElement.prototype.focus = function () {
12620
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
12621
+ focus.apply(this, arguments);
12622
+ };
12623
+
12624
+ document.addEventListener('keydown', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleKeyboardEvent, true);
12625
+ document.addEventListener('keyup', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleKeyboardEvent, true);
12626
+ document.addEventListener('click', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleClickEvent, true); // Register focus events on the window so they are sure to happen
12627
+ // before React's event listeners (registered on the document).
12628
+
12629
+ window.addEventListener('focus', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleFocusEvent, true);
12630
+ window.addEventListener('blur', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleWindowBlur, false);
12631
+
12632
+ if (typeof PointerEvent !== 'undefined') {
12633
+ document.addEventListener('pointerdown', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
12634
+ document.addEventListener('pointermove', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
12635
+ document.addEventListener('pointerup', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
12636
+ } else {
12637
+ document.addEventListener('mousedown', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
12638
+ document.addEventListener('mousemove', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
12639
+ document.addEventListener('mouseup', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
12640
+ }
12641
+
12642
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasSetupGlobalListeners = true;
12643
+ }
12644
+
12645
+ if (typeof document !== 'undefined') {
12646
+ if (document.readyState !== 'loading') {
12647
+ $d01f69bb2ab5f70dfd0005370a2a2cbc$var$setupGlobalFocusEvents();
12648
+ } else {
12649
+ document.addEventListener('DOMContentLoaded', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$setupGlobalFocusEvents);
12650
+ }
12651
+ }
12652
+ function getInteractionModality() {
12653
+ return $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality;
12654
+ }
12655
+
12656
+ /**
12657
+ * A utility function that focuses an element while avoiding undesired side effects such
12658
+ * as page scrolling and screen reader issues with CSS transitions.
12659
+ */
12660
+ function focusSafely(element) {
12661
+ // If the user is interacting with a virtual cursor, e.g. screen reader, then
12662
+ // wait until after any animated transitions that are currently occurring on
12663
+ // the page before shifting focus. This avoids issues with VoiceOver on iOS
12664
+ // causing the page to scroll when moving focus if the element is transitioning
12665
+ // from off the screen.
12666
+ if (getInteractionModality() === 'virtual') {
12667
+ let lastFocusedElement = document.activeElement;
12668
+ runAfterTransition(() => {
12669
+ // If focus did not move and the element is still in the document, focus it.
12670
+ if (document.activeElement === lastFocusedElement && document.contains(element)) {
12671
+ focusWithoutScrolling(element);
12672
+ }
12673
+ });
12674
+ } else {
12675
+ focusWithoutScrolling(element);
12676
+ }
12677
+ }
12678
+
12679
+ /*
12680
+ * Copyright 2021 Adobe. All rights reserved.
12681
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12682
+ * you may not use this file except in compliance with the License. You may obtain a copy
12683
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12684
+ *
12685
+ * Unless required by applicable law or agreed to in writing, software distributed under
12686
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12687
+ * OF ANY KIND, either express or implied. See the License for the specific language
12688
+ * governing permissions and limitations under the License.
12689
+ */
12690
+ function $ee5e90cbb4a22466973155c14222fa1$var$isStyleVisible(element) {
12691
+ if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) {
12692
+ return false;
12693
+ }
12694
+
12695
+ let {
12696
+ display,
12697
+ visibility
12698
+ } = element.style;
12699
+ let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
12700
+
12701
+ if (isVisible) {
12702
+ const {
12703
+ getComputedStyle
12704
+ } = element.ownerDocument.defaultView;
12705
+ let {
12706
+ display: computedDisplay,
12707
+ visibility: computedVisibility
12708
+ } = getComputedStyle(element);
12709
+ isVisible = computedDisplay !== 'none' && computedVisibility !== 'hidden' && computedVisibility !== 'collapse';
12710
+ }
12711
+
12712
+ return isVisible;
12713
+ }
12714
+
12715
+ function $ee5e90cbb4a22466973155c14222fa1$var$isAttributeVisible(element, childElement) {
12716
+ return !element.hasAttribute('hidden') && (element.nodeName === 'DETAILS' && childElement && childElement.nodeName !== 'SUMMARY' ? element.hasAttribute('open') : true);
12717
+ }
12718
+ /**
12719
+ * Adapted from https://github.com/testing-library/jest-dom and
12720
+ * https://github.com/vuejs/vue-test-utils-next/.
12721
+ * Licensed under the MIT License.
12722
+ * @param element - Element to evaluate for display or visibility.
12723
+ */
12724
+
12725
+
12726
+ function $ee5e90cbb4a22466973155c14222fa1$export$isElementVisible(element, childElement) {
12727
+ return element.nodeName !== '#comment' && $ee5e90cbb4a22466973155c14222fa1$var$isStyleVisible(element) && $ee5e90cbb4a22466973155c14222fa1$var$isAttributeVisible(element, childElement) && (!element.parentElement || $ee5e90cbb4a22466973155c14222fa1$export$isElementVisible(element.parentElement, element));
12728
+ }
12729
+
12730
+ const $c9e8f80f5bb1841844f54e4ad30b$var$focusableElements = ['input:not([disabled]):not([type=hidden])', 'select:not([disabled])', 'textarea:not([disabled])', 'button:not([disabled])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]'];
12731
+ const $c9e8f80f5bb1841844f54e4ad30b$var$FOCUSABLE_ELEMENT_SELECTOR = $c9e8f80f5bb1841844f54e4ad30b$var$focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';
12732
+ $c9e8f80f5bb1841844f54e4ad30b$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
12733
+ const $c9e8f80f5bb1841844f54e4ad30b$var$TABBABLE_ELEMENT_SELECTOR = $c9e8f80f5bb1841844f54e4ad30b$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
12734
+
12735
+ const $c9e8f80f5bb1841844f54e4ad30b$var$focusScopeDataAttrNames = ['data-focus-scope-start', 'data-focus-scope-end'];
12736
+
12737
+ function $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeDirectChild(scope) {
12738
+ return $c9e8f80f5bb1841844f54e4ad30b$var$focusScopeDataAttrNames.some(name => scope.getAttribute(name) !== null);
12739
+ }
12740
+
12741
+ function $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeNestedChild(scope) {
12742
+ return $c9e8f80f5bb1841844f54e4ad30b$var$focusScopeDataAttrNames.some(name => scope.querySelector("[" + name + "]"));
12743
+ }
12744
+
12745
+ function $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeInScope(scopes) {
12746
+ return scopes.some(scope => $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeDirectChild(scope) || $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeNestedChild(scope));
12747
+ }
12748
+
12749
+ function $c9e8f80f5bb1841844f54e4ad30b$var$isElementInScope(element, scope) {
12750
+ return !$c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeInScope(scope) && scope.some(node => node.contains(element));
12751
+ }
12752
+ /**
12753
+ * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}
12754
+ * that matches all focusable/tabbable elements.
12755
+ */
12756
+
12757
+
12758
+ function getFocusableTreeWalker(root, opts, scope) {
12759
+ let selector = opts != null && opts.tabbable ? $c9e8f80f5bb1841844f54e4ad30b$var$TABBABLE_ELEMENT_SELECTOR : $c9e8f80f5bb1841844f54e4ad30b$var$FOCUSABLE_ELEMENT_SELECTOR;
12760
+ let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
12761
+ acceptNode(node) {
12762
+ var _opts$from;
12763
+
12764
+ // Skip nodes inside the starting node.
12765
+ if (opts != null && (_opts$from = opts.from) != null && _opts$from.contains(node)) {
12766
+ return NodeFilter.FILTER_REJECT;
12767
+ }
12768
+
12769
+ if (node.matches(selector) && $ee5e90cbb4a22466973155c14222fa1$export$isElementVisible(node) && (!scope || $c9e8f80f5bb1841844f54e4ad30b$var$isElementInScope(node, scope))) {
12770
+ return NodeFilter.FILTER_ACCEPT;
12771
+ }
12772
+
12773
+ return NodeFilter.FILTER_SKIP;
12774
+ }
12775
+
12776
+ });
12777
+
12778
+ if (opts != null && opts.from) {
12779
+ walker.currentNode = opts.from;
12780
+ }
12781
+
12782
+ return walker;
12783
+ }
12784
+
12785
+ function _extends$1() {
12786
+ _extends$1 = Object.assign || function (target) {
12787
+ for (var i = 1; i < arguments.length; i++) {
12788
+ var source = arguments[i];
12789
+
12790
+ for (var key in source) {
12791
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
12792
+ target[key] = source[key];
12793
+ }
12794
+ }
12795
+ }
12796
+
12797
+ return target;
12798
+ };
12799
+
12800
+ return _extends$1.apply(this, arguments);
12801
+ }
12802
+
12803
+ /**
12804
+ * Handles typeahead interactions with collections.
12805
+ */
12806
+ function useTypeSelect(options) {
12807
+ let {
12808
+ keyboardDelegate,
12809
+ selectionManager,
12810
+ onTypeSelect
12811
+ } = options;
12812
+ let state = React.useRef({
12813
+ search: '',
12814
+ timeout: null
12815
+ }).current;
12816
+
12817
+ let onKeyDown = e => {
12818
+ let character = $c78d7fa5f7d5832f9b4f97b33a679865$var$getStringForKey(e.key);
12819
+
12820
+ if (!character || e.ctrlKey || e.metaKey) {
12821
+ return;
12822
+ } // Do not propagate the Spacebar event if it's meant to be part of the search.
12823
+ // When we time out, the search term becomes empty, hence the check on length.
12824
+ // Trimming is to account for the case of pressing the Spacebar more than once,
12825
+ // which should cycle through the selection/deselection of the focused item.
12826
+
12827
+
12828
+ if (character === ' ' && state.search.trim().length > 0) {
12829
+ e.preventDefault();
12830
+
12831
+ if (!('continuePropagation' in e)) {
12832
+ e.stopPropagation();
12833
+ }
12834
+ }
12835
+
12836
+ state.search += character; // Use the delegate to find a key to focus.
12837
+ // Prioritize items after the currently focused item, falling back to searching the whole list.
12838
+
12839
+ let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey); // If no key found, search from the top.
12840
+
12841
+ if (key == null) {
12842
+ key = keyboardDelegate.getKeyForSearch(state.search);
12843
+ }
12844
+
12845
+ if (key != null) {
12846
+ selectionManager.setFocusedKey(key);
12847
+
12848
+ if (onTypeSelect) {
12849
+ onTypeSelect(key);
12850
+ }
12851
+ }
12852
+
12853
+ clearTimeout(state.timeout);
12854
+ state.timeout = setTimeout(() => {
12855
+ state.search = '';
12856
+ }, 500);
12857
+ };
12858
+
12859
+ return {
12860
+ typeSelectProps: {
12861
+ // Using a capturing listener to catch the keydown event before
12862
+ // other hooks in order to handle the Spacebar event.
12863
+ onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
12864
+ }
12865
+ };
12866
+ }
12867
+
12868
+ function $c78d7fa5f7d5832f9b4f97b33a679865$var$getStringForKey(key) {
12869
+ // If the key is of length 1, it is an ASCII value.
12870
+ // Otherwise, if there are no ASCII characters in the key name,
12871
+ // it is a Unicode character.
12872
+ // See https://www.w3.org/TR/uievents-key/
12873
+ if (key.length === 1 || !/^[A-Z]/i.test(key)) {
12874
+ return key;
12875
+ }
12876
+
12877
+ return '';
12878
+ }
12879
+
12880
+ function $a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) {
12881
+ if (isMac()) {
12882
+ return e.metaKey;
12883
+ }
12884
+
12885
+ return e.ctrlKey;
12886
+ }
12887
+
12888
+ /**
12889
+ * Handles interactions with selectable collections.
12890
+ */
12891
+ function useSelectableCollection(options) {
12892
+ let {
12893
+ selectionManager: manager,
12894
+ keyboardDelegate: delegate,
12895
+ ref,
12896
+ autoFocus = false,
12897
+ shouldFocusWrap = false,
12898
+ disallowEmptySelection = false,
12899
+ disallowSelectAll = false,
12900
+ selectOnFocus = false,
12901
+ disallowTypeAhead = false,
12902
+ shouldUseVirtualFocus,
12903
+ allowsTabNavigation = false
12904
+ } = options;
12905
+ let {
12906
+ direction
12907
+ } = useLocale();
12908
+
12909
+ let onKeyDown = e => {
12910
+ // Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
12911
+ if (e.altKey && e.key === 'Tab') {
12912
+ e.preventDefault();
12913
+ } // Let child element (e.g. menu button) handle the event if the Alt key is pressed.
12914
+ // Keyboard events bubble through portals. Don't handle keyboard events
12915
+ // for elements outside the collection (e.g. menus).
12916
+
12917
+
12918
+ if (e.altKey || !ref.current.contains(e.target)) {
12919
+ return;
12920
+ }
12921
+
12922
+ const navigateToKey = (key, childFocus) => {
12923
+ if (key != null) {
12924
+ manager.setFocusedKey(key, childFocus);
12925
+
12926
+ if (e.shiftKey && manager.selectionMode === 'multiple') {
12927
+ manager.extendSelection(key);
12928
+ } else if (selectOnFocus) {
12929
+ manager.replaceSelection(key);
12930
+ }
12931
+ }
12932
+ };
12933
+
12934
+ switch (e.key) {
12935
+ case 'ArrowDown':
12936
+ {
12937
+ if (delegate.getKeyBelow) {
12938
+ e.preventDefault();
12939
+ let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : delegate.getFirstKey == null ? void 0 : delegate.getFirstKey();
12940
+
12941
+ if (nextKey == null && shouldFocusWrap) {
12942
+ nextKey = delegate.getFirstKey == null ? void 0 : delegate.getFirstKey(manager.focusedKey);
12943
+ }
12944
+
12945
+ navigateToKey(nextKey);
12946
+ }
12947
+
12948
+ break;
12949
+ }
12950
+
12951
+ case 'ArrowUp':
12952
+ {
12953
+ if (delegate.getKeyAbove) {
12954
+ e.preventDefault();
12955
+ let nextKey = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : delegate.getLastKey == null ? void 0 : delegate.getLastKey();
12956
+
12957
+ if (nextKey == null && shouldFocusWrap) {
12958
+ nextKey = delegate.getLastKey == null ? void 0 : delegate.getLastKey(manager.focusedKey);
12959
+ }
12960
+
12961
+ navigateToKey(nextKey);
12962
+ }
12963
+
12964
+ break;
12965
+ }
12966
+
12967
+ case 'ArrowLeft':
12968
+ {
12969
+ if (delegate.getKeyLeftOf) {
12970
+ e.preventDefault();
12971
+ let nextKey = delegate.getKeyLeftOf(manager.focusedKey);
12972
+ navigateToKey(nextKey, direction === 'rtl' ? 'first' : 'last');
12973
+ }
12974
+
12975
+ break;
12976
+ }
12977
+
12978
+ case 'ArrowRight':
12979
+ {
12980
+ if (delegate.getKeyRightOf) {
12981
+ e.preventDefault();
12982
+ let nextKey = delegate.getKeyRightOf(manager.focusedKey);
12983
+ navigateToKey(nextKey, direction === 'rtl' ? 'last' : 'first');
12984
+ }
12985
+
12986
+ break;
12987
+ }
12988
+
12989
+ case 'Home':
12990
+ if (delegate.getFirstKey) {
12991
+ e.preventDefault();
12992
+ let firstKey = delegate.getFirstKey(manager.focusedKey, $a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e));
12993
+ manager.setFocusedKey(firstKey);
12994
+
12995
+ if ($a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) && e.shiftKey && manager.selectionMode === 'multiple') {
12996
+ manager.extendSelection(firstKey);
12997
+ } else if (selectOnFocus) {
12998
+ manager.replaceSelection(firstKey);
12999
+ }
13000
+ }
13001
+
13002
+ break;
13003
+
13004
+ case 'End':
13005
+ if (delegate.getLastKey) {
13006
+ e.preventDefault();
13007
+ let lastKey = delegate.getLastKey(manager.focusedKey, $a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e));
13008
+ manager.setFocusedKey(lastKey);
13009
+
13010
+ if ($a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) && e.shiftKey && manager.selectionMode === 'multiple') {
13011
+ manager.extendSelection(lastKey);
13012
+ } else if (selectOnFocus) {
13013
+ manager.replaceSelection(lastKey);
13014
+ }
13015
+ }
13016
+
13017
+ break;
13018
+
13019
+ case 'PageDown':
13020
+ if (delegate.getKeyPageBelow) {
13021
+ e.preventDefault();
13022
+ let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
13023
+ navigateToKey(nextKey);
13024
+ }
13025
+
13026
+ break;
13027
+
13028
+ case 'PageUp':
13029
+ if (delegate.getKeyPageAbove) {
13030
+ e.preventDefault();
13031
+ let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
13032
+ navigateToKey(nextKey);
13033
+ }
13034
+
13035
+ break;
13036
+
13037
+ case 'a':
13038
+ if ($a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) && manager.selectionMode === 'multiple' && disallowSelectAll !== true) {
13039
+ e.preventDefault();
13040
+ manager.selectAll();
13041
+ }
13042
+
13043
+ break;
13044
+
13045
+ case 'Escape':
13046
+ e.preventDefault();
13047
+
13048
+ if (!disallowEmptySelection) {
13049
+ manager.clearSelection();
13050
+ }
13051
+
13052
+ break;
13053
+
13054
+ case 'Tab':
13055
+ {
13056
+ if (!allowsTabNavigation) {
13057
+ // There may be elements that are "tabbable" inside a collection (e.g. in a grid cell).
13058
+ // However, collections should be treated as a single tab stop, with arrow key navigation internally.
13059
+ // We don't control the rendering of these, so we can't override the tabIndex to prevent tabbing.
13060
+ // Instead, we handle the Tab key, and move focus manually to the first/last tabbable element
13061
+ // in the collection, so that the browser default behavior will apply starting from that element
13062
+ // rather than the currently focused one.
13063
+ if (e.shiftKey) {
13064
+ ref.current.focus();
13065
+ } else {
13066
+ let walker = getFocusableTreeWalker(ref.current, {
13067
+ tabbable: true
13068
+ });
13069
+ let next;
13070
+ let last;
13071
+
13072
+ do {
13073
+ last = walker.lastChild();
13074
+
13075
+ if (last) {
13076
+ next = last;
13077
+ }
13078
+ } while (last);
13079
+
13080
+ if (next && !next.contains(document.activeElement)) {
13081
+ focusWithoutScrolling(next);
13082
+ }
13083
+ }
13084
+
13085
+ break;
13086
+ }
13087
+ }
13088
+ }
13089
+ };
13090
+
13091
+ let onFocus = e => {
13092
+ if (manager.isFocused) {
13093
+ // If a focus event bubbled through a portal, reset focus state.
13094
+ if (!e.currentTarget.contains(e.target)) {
13095
+ manager.setFocused(false);
13096
+ }
13097
+
13098
+ return;
13099
+ } // Focus events can bubble through portals. Ignore these events.
13100
+
13101
+
13102
+ if (!e.currentTarget.contains(e.target)) {
13103
+ return;
13104
+ }
13105
+
13106
+ manager.setFocused(true);
13107
+
13108
+ if (manager.focusedKey == null) {
13109
+ // If the user hasn't yet interacted with the collection, there will be no focusedKey set.
13110
+ // Attempt to detect whether the user is tabbing forward or backward into the collection
13111
+ // and either focus the first or last item accordingly.
13112
+ let relatedTarget = e.relatedTarget;
13113
+
13114
+ if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) {
13115
+ var _manager$lastSelected;
13116
+
13117
+ manager.setFocusedKey((_manager$lastSelected = manager.lastSelectedKey) != null ? _manager$lastSelected : delegate.getLastKey());
13118
+ } else {
13119
+ var _manager$firstSelecte;
13120
+
13121
+ manager.setFocusedKey((_manager$firstSelecte = manager.firstSelectedKey) != null ? _manager$firstSelecte : delegate.getFirstKey());
13122
+ }
13123
+ }
13124
+ };
13125
+
13126
+ let onBlur = e => {
13127
+ // Don't set blurred and then focused again if moving focus within the collection.
13128
+ if (!e.currentTarget.contains(e.relatedTarget)) {
13129
+ manager.setFocused(false);
13130
+ }
13131
+ };
13132
+
13133
+ const autoFocusRef = React.useRef(autoFocus);
13134
+ React.useEffect(() => {
13135
+ if (autoFocusRef.current) {
13136
+ let focusedKey = null; // Check focus strategy to determine which item to focus
13137
+
13138
+ if (autoFocus === 'first') {
13139
+ focusedKey = delegate.getFirstKey();
13140
+ }
13141
+
13142
+ if (autoFocus === 'last') {
13143
+ focusedKey = delegate.getLastKey();
13144
+ } // If there are any selected keys, make the first one the new focus target
13145
+
13146
+
13147
+ let selectedKeys = manager.selectedKeys;
13148
+
13149
+ if (selectedKeys.size) {
13150
+ focusedKey = selectedKeys.values().next().value;
13151
+ }
13152
+
13153
+ manager.setFocused(true);
13154
+ manager.setFocusedKey(focusedKey); // If no default focus key is selected, focus the collection itself.
13155
+
13156
+ if (focusedKey == null && !shouldUseVirtualFocus) {
13157
+ focusSafely(ref.current);
13158
+ }
13159
+ }
13160
+
13161
+ autoFocusRef.current = false; // eslint-disable-next-line react-hooks/exhaustive-deps
13162
+ }, []);
13163
+ let handlers = {
13164
+ onKeyDown,
13165
+ onFocus,
13166
+ onBlur,
13167
+
13168
+ onMouseDown(e) {
13169
+ // Ignore events that bubbled through portals.
13170
+ if (e.currentTarget.contains(e.target)) {
13171
+ // Prevent focus going to the collection when clicking on the scrollbar.
13172
+ e.preventDefault();
13173
+ }
13174
+ }
13175
+
13176
+ };
13177
+ let {
13178
+ typeSelectProps
13179
+ } = useTypeSelect({
13180
+ keyboardDelegate: delegate,
13181
+ selectionManager: manager
13182
+ });
13183
+
13184
+ if (!disallowTypeAhead) {
13185
+ handlers = mergeProps(typeSelectProps, handlers);
13186
+ } // If nothing is focused within the collection, make the collection itself tabbable.
13187
+ // This will be marshalled to either the first or last item depending on where focus came from.
13188
+ // If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
13189
+ // to move real DOM focus to the element anyway.
13190
+
13191
+
13192
+ let tabIndex;
13193
+
13194
+ if (!shouldUseVirtualFocus) {
13195
+ tabIndex = manager.focusedKey == null ? 0 : -1;
13196
+ }
13197
+
13198
+ return {
13199
+ collectionProps: _extends$1({}, handlers, {
13200
+ tabIndex
13201
+ })
13202
+ };
13203
+ }
13204
+
13205
+ /**
13206
+ * Handles interactions with an item in a selectable collection.
13207
+ */
13208
+ function useSelectableItem(options) {
13209
+ let {
13210
+ selectionManager: manager,
13211
+ key,
13212
+ ref,
13213
+ shouldSelectOnPressUp,
13214
+ isVirtualized,
13215
+ shouldUseVirtualFocus,
13216
+ focus
13217
+ } = options;
13218
+
13219
+ let onSelect = e => manager.select(key, e); // Focus the associated DOM node when this item becomes the focusedKey
13220
+
13221
+
13222
+ let isFocused = key === manager.focusedKey;
13223
+ React.useEffect(() => {
13224
+ if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
13225
+ if (focus) {
13226
+ focus();
13227
+ } else {
13228
+ focusSafely(ref.current);
13229
+ }
13230
+ }
13231
+ }, [ref, isFocused, manager.focusedKey, manager.childFocusStrategy, manager.isFocused, shouldUseVirtualFocus]); // Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused
13232
+ // item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver
13233
+ // on iOS 14 doesn't try to move real DOM focus to the item anyway.
13234
+
13235
+ let itemProps = {};
13236
+
13237
+ if (!shouldUseVirtualFocus) {
13238
+ itemProps = {
13239
+ tabIndex: isFocused ? 0 : -1,
13240
+
13241
+ onFocus(e) {
13242
+ if (e.target === ref.current) {
13243
+ manager.setFocusedKey(key);
13244
+ }
13245
+ }
13246
+
13247
+ };
13248
+ } // By default, selection occurs on pointer down. This can be strange if selecting an
13249
+ // item causes the UI to disappear immediately (e.g. menus).
13250
+ // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
13251
+ // onPress requires a pointer down event on the same element as pointer up. For menus,
13252
+ // we want to be able to have the pointer down on the trigger that opens the menu and
13253
+ // the pointer up on the menu item rather than requiring a separate press.
13254
+ // For keyboard events, selection still occurs on key down.
13255
+
13256
+
13257
+ if (shouldSelectOnPressUp) {
13258
+ itemProps.onPressStart = e => {
13259
+ if (e.pointerType === 'keyboard') {
13260
+ onSelect(e);
13261
+ }
13262
+ };
13263
+
13264
+ itemProps.onPressUp = e => {
13265
+ if (e.pointerType !== 'keyboard') {
13266
+ onSelect(e);
13267
+ }
13268
+ };
13269
+ } else {
13270
+ // On touch, it feels strange to select on touch down, so we special case this.
13271
+ itemProps.onPressStart = e => {
13272
+ if (e.pointerType !== 'touch') {
13273
+ onSelect(e);
13274
+ }
13275
+ };
13276
+
13277
+ itemProps.onPress = e => {
13278
+ if (e.pointerType === 'touch') {
13279
+ onSelect(e);
13280
+ }
13281
+ };
13282
+ }
13283
+
13284
+ if (!isVirtualized) {
13285
+ itemProps['data-key'] = key;
13286
+ }
13287
+
13288
+ return {
13289
+ itemProps
13290
+ };
13291
+ }
13292
+
13293
+ function _extends() {
13294
+ _extends = Object.assign || function (target) {
13295
+ for (var i = 1; i < arguments.length; i++) {
13296
+ var source = arguments[i];
13297
+
13298
+ for (var key in source) {
13299
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
13300
+ target[key] = source[key];
13301
+ }
13302
+ }
13303
+ }
13304
+
13305
+ return target;
13306
+ };
13307
+
13308
+ return _extends.apply(this, arguments);
13309
+ }
13310
+
13311
+ /*
13312
+ * Copyright 2020 Adobe. All rights reserved.
13313
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13314
+ * you may not use this file except in compliance with the License. You may obtain a copy
13315
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13316
+ *
13317
+ * Unless required by applicable law or agreed to in writing, software distributed under
13318
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13319
+ * OF ANY KIND, either express or implied. See the License for the specific language
13320
+ * governing permissions and limitations under the License.
13321
+ */
13322
+ const $c5c378b07d37fb3729fd37493414d657$export$tabsIds = new WeakMap();
13323
+
13324
+ function $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, role) {
13325
+ if (typeof key === 'string') {
13326
+ key = key.replace(/\s+/g, '');
13327
+ }
13328
+
13329
+ let baseId = $c5c378b07d37fb3729fd37493414d657$export$tabsIds.get(state);
13330
+ return baseId + "-" + role + "-" + key;
13331
+ }
13332
+
13333
+ /**
13334
+ * Provides the behavior and accessibility implementation for a tab.
13335
+ * When selected, the associated tab panel is shown.
13336
+ */
13337
+ function useTab(props, state, ref) {
13338
+ let {
13339
+ key,
13340
+ isDisabled: propsDisabled
13341
+ } = props;
13342
+ let {
13343
+ selectionManager: manager,
13344
+ selectedKey
13345
+ } = state;
13346
+ let isSelected = key === selectedKey;
13347
+ let {
13348
+ itemProps
13349
+ } = useSelectableItem({
13350
+ selectionManager: manager,
13351
+ key,
13352
+ ref
13353
+ });
13354
+ let isDisabled = propsDisabled || state.disabledKeys.has(key);
13355
+ let {
13356
+ pressProps
13357
+ } = usePress(_extends({}, itemProps, {
13358
+ isDisabled
13359
+ }));
13360
+ let tabId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tab');
13361
+ let tabPanelId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tabpanel');
13362
+ let {
13363
+ tabIndex
13364
+ } = pressProps;
13365
+ return {
13366
+ tabProps: _extends({}, pressProps, {
13367
+ id: tabId,
13368
+ 'aria-selected': isSelected,
13369
+ 'aria-disabled': isDisabled || undefined,
13370
+ 'aria-controls': isSelected ? tabPanelId : undefined,
13371
+ tabIndex: isDisabled ? undefined : tabIndex,
13372
+ role: 'tab'
13373
+ })
13374
+ };
13375
+ }
13376
+
13377
+ /**
13378
+ * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for
13379
+ * the contents of a tab, and is shown when the tab is selected.
13380
+ */
13381
+ function useTabPanel(props, state, ref) {
13382
+ let [tabIndex, setTabIndex] = React.useState(0); // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
13383
+ // Otherwise, tabbing from the focused tab should go directly to the first tabbable element
13384
+ // within the tabpanel.
13385
+
13386
+ React.useLayoutEffect(() => {
13387
+ if (ref != null && ref.current) {
13388
+ let update = () => {
13389
+ // Detect if there are any tabbable elements and update the tabIndex accordingly.
13390
+ let walker = getFocusableTreeWalker(ref.current, {
13391
+ tabbable: true
13392
+ });
13393
+ setTabIndex(walker.nextNode() ? undefined : 0);
13394
+ };
13395
+
13396
+ update(); // Update when new elements are inserted, or the tabIndex/disabled attribute updates.
13397
+
13398
+ let observer = new MutationObserver(update);
13399
+ observer.observe(ref.current, {
13400
+ subtree: true,
13401
+ childList: true,
13402
+ attributes: true,
13403
+ attributeFilter: ['tabIndex', 'disabled']
13404
+ });
13405
+ return () => {
13406
+ observer.disconnect();
13407
+ };
13408
+ }
13409
+ }, [ref]);
13410
+ const id = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, state == null ? void 0 : state.selectedKey, 'tabpanel');
13411
+ const tabPanelProps = useLabels(_extends({}, props, {
13412
+ id,
13413
+ 'aria-labelledby': $c5c378b07d37fb3729fd37493414d657$export$generateId(state, state == null ? void 0 : state.selectedKey, 'tab')
13414
+ }));
13415
+ return {
13416
+ tabPanelProps: mergeProps(tabPanelProps, {
13417
+ tabIndex,
13418
+ role: 'tabpanel',
13419
+ 'aria-describedby': props['aria-describedby'],
13420
+ 'aria-details': props['aria-details']
13421
+ })
13422
+ };
13423
+ }
13424
+
13425
+ class $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate {
13426
+ constructor(collection, direction, orientation, disabledKeys) {
13427
+ if (disabledKeys === void 0) {
13428
+ disabledKeys = new Set();
13429
+ }
13430
+
13431
+ this.collection = void 0;
13432
+ this.flipDirection = void 0;
13433
+ this.disabledKeys = void 0;
13434
+ this.orientation = void 0;
13435
+ this.collection = collection;
13436
+ this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
13437
+ this.orientation = orientation;
13438
+ this.disabledKeys = disabledKeys;
13439
+ }
13440
+
13441
+ getKeyLeftOf(key) {
13442
+ if (this.flipDirection) {
13443
+ return this.getNextKey(key);
13444
+ } else {
13445
+ if (this.orientation === 'horizontal') {
13446
+ return this.getPreviousKey(key);
13447
+ }
13448
+
13449
+ return null;
13450
+ }
13451
+ }
13452
+
13453
+ getKeyRightOf(key) {
13454
+ if (this.flipDirection) {
13455
+ return this.getPreviousKey(key);
13456
+ } else {
13457
+ if (this.orientation === 'horizontal') {
13458
+ return this.getNextKey(key);
13459
+ }
13460
+
13461
+ return null;
13462
+ }
13463
+ }
13464
+
13465
+ getKeyAbove(key) {
13466
+ if (this.orientation === 'vertical') {
13467
+ return this.getPreviousKey(key);
13468
+ }
13469
+
13470
+ return null;
13471
+ }
13472
+
13473
+ getKeyBelow(key) {
13474
+ if (this.orientation === 'vertical') {
13475
+ return this.getNextKey(key);
13476
+ }
13477
+
13478
+ return null;
13479
+ }
13480
+
13481
+ getFirstKey() {
13482
+ let key = this.collection.getFirstKey();
13483
+
13484
+ if (this.disabledKeys.has(key)) {
13485
+ key = this.getNextKey(key);
13486
+ }
13487
+
13488
+ return key;
13489
+ }
13490
+
13491
+ getLastKey() {
13492
+ let key = this.collection.getLastKey();
13493
+
13494
+ if (this.disabledKeys.has(key)) {
13495
+ key = this.getPreviousKey(key);
13496
+ }
13497
+
13498
+ return key;
13499
+ }
13500
+
13501
+ getNextKey(key) {
13502
+ do {
13503
+ key = this.collection.getKeyAfter(key);
13504
+
13505
+ if (key == null) {
13506
+ key = this.collection.getFirstKey();
13507
+ }
13508
+ } while (this.disabledKeys.has(key));
13509
+
13510
+ return key;
13511
+ }
13512
+
13513
+ getPreviousKey(key) {
13514
+ do {
13515
+ key = this.collection.getKeyBefore(key);
13516
+
13517
+ if (key == null) {
13518
+ key = this.collection.getLastKey();
13519
+ }
13520
+ } while (this.disabledKeys.has(key));
13521
+
13522
+ return key;
13523
+ }
13524
+
13525
+ }
13526
+
13527
+ /**
13528
+ * Provides the behavior and accessibility implementation for a tab list.
13529
+ * Tabs organize content into multiple sections and allow users to navigate between them.
13530
+ */
13531
+ function useTabList(props, state, ref) {
13532
+ let {
13533
+ orientation = 'horizontal',
13534
+ keyboardActivation = 'automatic'
13535
+ } = props;
13536
+ let {
13537
+ collection,
13538
+ selectionManager: manager,
13539
+ disabledKeys
13540
+ } = state;
13541
+ let {
13542
+ direction
13543
+ } = useLocale();
13544
+ let delegate = React.useMemo(() => new $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate(collection, direction, orientation, disabledKeys), [collection, disabledKeys, orientation, direction]);
13545
+ let {
13546
+ collectionProps
13547
+ } = useSelectableCollection({
13548
+ ref,
13549
+ selectionManager: manager,
13550
+ keyboardDelegate: delegate,
13551
+ selectOnFocus: keyboardActivation === 'automatic',
13552
+ disallowEmptySelection: true
13553
+ }); // Compute base id for all tabs
13554
+
13555
+ let tabsId = useId();
13556
+ $c5c378b07d37fb3729fd37493414d657$export$tabsIds.set(state, tabsId);
13557
+ let tabListLabelProps = useLabels(_extends({}, props, {
13558
+ id: tabsId
13559
+ }));
13560
+ return {
13561
+ tabListProps: _extends({}, mergeProps(collectionProps, tabListLabelProps), {
13562
+ role: 'tablist',
13563
+ 'aria-orientation': orientation,
13564
+ tabIndex: undefined
13565
+ })
13566
+ };
13567
+ }
13568
+
13569
+ function SpsTab(_a) {
13570
+ var item = _a.item, state = _a.state;
13571
+ var key = item.key;
13572
+ var ref = React__namespace.useRef();
13573
+ var tabProps = useTab({ key: key }, state, ref).tabProps;
13574
+ var isSelected = state.selectedKey === key;
13575
+ var isDisabled = state.disabledKeys.has(key);
13576
+ return (React__namespace.createElement("div", __assign({}, tabProps, { ref: ref, className: clsx__default['default']('sps-nav__item', 'sps-nav__link', isSelected && 'active', isDisabled && 'sps-nav__item--disabled') }), item.rendered));
13577
+ }
13578
+
13579
+ function SpsTabPanel(_a) {
13580
+ var state = _a.state, props = __rest(_a, ["state"]);
13581
+ var ref = React__namespace.useRef();
13582
+ var tabPanelProps = useTabPanel(props, state, ref).tabPanelProps;
13583
+ return (React__namespace.createElement("div", __assign({}, tabPanelProps, { ref: ref, className: "sps-card__body" }), state.selectedItem ? state.selectedItem.props.children : null));
13584
+ }
13585
+
13586
+ function SpsTabsV2(props) {
13587
+ var state = useTabListState(props);
13588
+ var ref = React__namespace.useRef();
13589
+ var tabListProps = useTabList(props, state, ref).tabListProps;
13590
+ return (React__namespace.createElement(React__namespace.Fragment, null,
13591
+ React__namespace.createElement("div", __assign({}, tabListProps, { ref: ref, className: "sps-nav sps-nav--tabs sps-tabs-v2" }), __spreadArray([], __read(state.collection)).map(function (item) { return (React__namespace.createElement(SpsTab, { key: item.key, item: item, state: state })); })),
13592
+ React__namespace.createElement(SpsTabPanel, { key: state.selectedItem ? state.selectedItem.key : null, state: state })));
13593
+ }
13594
+
13595
+ function SpsCardV2Footer(_a) {
13596
+ var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
13597
+ return (React__namespace.createElement("div", __assign({ className: clsx__default['default']('sps-card__footer', className) }, rest), children));
13598
+ }
13599
+
13600
+ function SpsCardV2Header(_a) {
13601
+ var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
13602
+ return (React__namespace.createElement("div", __assign({ className: clsx__default['default']('sps-card__header', className) }, rest), children));
13603
+ }
13604
+
13605
+ function SpsCardV2(_a) {
13606
+ var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
13607
+ var _b = __read(selectChildren(children, [
13608
+ { type: SpsCardV2Header },
13609
+ { type: SpsTabsV2 },
13610
+ { type: SpsCardV2Footer },
13611
+ ]), 4), header = _b[0], tabs = _b[1], footer = _b[2], bodyContent = _b[3];
13612
+ return (React__namespace.createElement("div", __assign({ className: clsx__default['default']('sps-card', className) }, rest),
13613
+ header,
13614
+ tabs.length > 0
13615
+ ? tabs
13616
+ : (React__namespace.createElement("div", { className: "sps-card__body" }, bodyContent)),
13617
+ footer));
13618
+ }
13619
+
13620
+ function SpsCardV2Title(_a) {
13621
+ var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
13622
+ return (React__namespace.createElement("div", __assign({ className: clsx__default['default']('sps-card__title', className) }, rest), children));
13623
+ }
13624
+
10391
13625
  var moment$2 = moment__namespace.default || moment__namespace;
10392
13626
  function newWeekArray() {
10393
13627
  return (new Array(7)).fill(null);
@@ -11223,6 +14457,10 @@ exports.SpsButtonGroup = SpsButtonGroup;
11223
14457
  exports.SpsCard = SpsCard;
11224
14458
  exports.SpsCardExamples = SpsCardExamples;
11225
14459
  exports.SpsCardTabbedPane = SpsCardTabbedPane;
14460
+ exports.SpsCardV2 = SpsCardV2;
14461
+ exports.SpsCardV2Footer = SpsCardV2Footer;
14462
+ exports.SpsCardV2Header = SpsCardV2Header;
14463
+ exports.SpsCardV2Title = SpsCardV2Title;
11226
14464
  exports.SpsCheckbox = SpsCheckbox;
11227
14465
  exports.SpsCheckboxDropdown = SpsCheckboxDropdown;
11228
14466
  exports.SpsCheckboxExamples = SpsCheckboxExamples;
@@ -11339,6 +14577,8 @@ exports.SpsSummaryListColumn = SpsSummaryListColumn;
11339
14577
  exports.SpsSummaryListExamples = SpsSummaryListExamples;
11340
14578
  exports.SpsSummaryListExpansion = SpsSummaryListExpansion;
11341
14579
  exports.SpsSummaryListRow = SpsSummaryListRow;
14580
+ exports.SpsTab = SpsTab;
14581
+ exports.SpsTabPanel = SpsTabPanel;
11342
14582
  exports.SpsTable = SpsTable;
11343
14583
  exports.SpsTableBody = SpsTableBody;
11344
14584
  exports.SpsTableCell = SpsTableCell;
@@ -11346,6 +14586,7 @@ exports.SpsTableExamples = SpsTableExamples;
11346
14586
  exports.SpsTableHead = SpsTableHead;
11347
14587
  exports.SpsTableHeader = SpsTableHeader;
11348
14588
  exports.SpsTableRow = SpsTableRow;
14589
+ exports.SpsTabsV2 = SpsTabsV2;
11349
14590
  exports.SpsTag = SpsTag;
11350
14591
  exports.SpsTagExamples = SpsTagExamples;
11351
14592
  exports.SpsTaskQueue = SpsTaskQueue;