@spscommerce/ds-react 4.8.1 → 4.9.0-ie

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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useRef, useEffect, createContext, useContext, useMemo, useReducer, useCallback, useState, useLayoutEffect as useLayoutEffect$1 } from 'react';
2
+ import { useRef, useEffect, createContext, useContext, useMemo, useReducer, useCallback, useState } from 'react';
3
3
  import { noI18nI18n, ButtonKind, ButtonType, SpsIcon as SpsIcon$1, Position, ZStratum, SpsOptionListOption, DropdownKind, SPS_ACTION_DEFAULTS, TagKind, ClickableTagKind, MultiSelectTagKind, SpsIconSize, SelectMode, TooltipKind, TooltipShowTrigger, TOOLTIP_HIDE_DELAY_MS_DEFAULT, FeedbackBlockKind, FeedbackBlockIcons, GrowlerKind, GrowlerIcon, GROWLER_VISIBLE_DURATION_MS, GROWLER_FADEOUT_DURATION_MS, SpsInsightTileKind, SpsInsightTileIcons, SortDirection, ModalKind, ModalSize, DEFAULT_PAGE_SIZE_OPTIONS, SpinnerSize, StdButtonKind, SpsTaskStatus, TASK_QUEUE_NOTIFICATION_DURATION_MS, SpsTaskStatusIcons, RingSize, WizardSubstepConditions } from '@spscommerce/ds-shared';
4
4
  import clsx from 'clsx';
5
5
  import { values, code, debounce, flatten, deepFreeze, setPath, diff, DiffChange, getPath, crumblePath, traversePath, forEachNestedObject, lockToAnimationFrames, constrain } from '@spscommerce/utils';
@@ -15,7 +15,6 @@ import * as moment$6 from 'moment-timezone';
15
15
  import moment__default from 'moment-timezone';
16
16
  import isPlainObject from 'lodash.isplainobject';
17
17
  import { colors } from '@spscommerce/ds-colors';
18
- import { useCollection } from '@react-stately/collections';
19
18
 
20
19
  /*! *****************************************************************************
21
20
  Copyright (c) Microsoft Corporation.
@@ -1747,7 +1746,7 @@ Object.assign(SpsCardTabbedPane, {
1747
1746
  * @param activeTab
1748
1747
  * @param isTabbedCard
1749
1748
  */
1750
- function useTab$1(children, activeTab, isTabbedCard) {
1749
+ function useTab(children, activeTab, isTabbedCard) {
1751
1750
  // STATE: Currently active tab state
1752
1751
  var _a = __read(React.useState({
1753
1752
  index: 0,
@@ -1831,7 +1830,7 @@ function SpsCard(props) {
1831
1830
  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"]);
1832
1831
  // This used to be a prop but now we derive it
1833
1832
  var isTabbedCard = React.Children.toArray(children).some(function (child) { return React.isValidElement(child) && child.type === SpsCardTabbedPane; });
1834
- var _a = __read(useTab$1(children, activeTab, isTabbedCard), 2), currentlyActiveTab = _a[0], setCurrentlyActiveTab = _a[1];
1833
+ var _a = __read(useTab(children, activeTab, isTabbedCard), 2), currentlyActiveTab = _a[0], setCurrentlyActiveTab = _a[1];
1835
1834
  var classes = clsx(unsafelyReplaceClassName || 'sps-card', className);
1836
1835
  return (React.createElement("div", __assign({}, rest, { className: classes, "data-testid": testId + "__card" }),
1837
1836
  (headerTitle || headerContent) && (React.createElement(SpsCardHeader, { title: headerTitle, content: contentOf(headerContent), icon: headerIcon, "data-testid": testId + "__header" })),
@@ -7686,6 +7685,22 @@ function SpsModalV2(_a) {
7686
7685
  if (event && event.key === 'Escape' && onClose) {
7687
7686
  onClose();
7688
7687
  }
7688
+ if (event && event.key === 'Tab') {
7689
+ var focusableElements = rootElement.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
7690
+ var firstFocusableElement = focusableElements[0];
7691
+ var lastFocusableElement = focusableElements[focusableElements.length - 1];
7692
+ if (focusableElements.length === 0) {
7693
+ event.preventDefault();
7694
+ }
7695
+ else if (event.shiftKey && event.target === firstFocusableElement) {
7696
+ event.preventDefault();
7697
+ lastFocusableElement.focus();
7698
+ }
7699
+ else if (!event.shiftKey && event.target === lastFocusableElement) {
7700
+ event.preventDefault();
7701
+ firstFocusableElement.focus();
7702
+ }
7703
+ }
7689
7704
  }, [onClose]);
7690
7705
  var _e = __read(selectChildren(children, [{ type: SpsModalV2Footer }]), 2), _f = __read(_e[0], 1), footer = _f[0], bodyContent = _e[1];
7691
7706
  return bodyIsReady
@@ -10888,3232 +10903,6 @@ var MANIFEST = {
10888
10903
  },
10889
10904
  };
10890
10905
 
10891
- function useControlledState(value, defaultValue, onChange) {
10892
- let [stateValue, setStateValue] = useState(value || defaultValue);
10893
- let ref = useRef(value !== undefined);
10894
- let wasControlled = ref.current;
10895
- let isControlled = value !== undefined; // Internal state reference for useCallback
10896
-
10897
- let stateRef = useRef(stateValue);
10898
-
10899
- if (wasControlled !== isControlled) {
10900
- console.warn("WARN: A component changed from " + (wasControlled ? 'controlled' : 'uncontrolled') + " to " + (isControlled ? 'controlled' : 'uncontrolled') + ".");
10901
- }
10902
-
10903
- ref.current = isControlled;
10904
- let setValue = useCallback(function (value) {
10905
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
10906
- args[_key - 1] = arguments[_key];
10907
- }
10908
-
10909
- let onChangeCaller = function onChangeCaller(value) {
10910
- if (onChange) {
10911
- if (!Object.is(stateRef.current, value)) {
10912
- for (var _len2 = arguments.length, onChangeArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
10913
- onChangeArgs[_key2 - 1] = arguments[_key2];
10914
- }
10915
-
10916
- onChange(value, ...onChangeArgs);
10917
- }
10918
- }
10919
-
10920
- if (!isControlled) {
10921
- stateRef.current = value;
10922
- }
10923
- };
10924
-
10925
- if (typeof value === 'function') {
10926
- // this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates
10927
- // when someone using useControlledState calls setControlledState(myFunc)
10928
- // this will call our useState setState with a function as well which invokes myFunc and calls onChange with the value from myFunc
10929
- // 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
10930
- // 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
10931
- let updateFunction = function updateFunction(oldValue) {
10932
- for (var _len3 = arguments.length, functionArgs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
10933
- functionArgs[_key3 - 1] = arguments[_key3];
10934
- }
10935
-
10936
- let interceptedValue = value(isControlled ? stateRef.current : oldValue, ...functionArgs);
10937
- onChangeCaller(interceptedValue, ...args);
10938
-
10939
- if (!isControlled) {
10940
- return interceptedValue;
10941
- }
10942
-
10943
- return oldValue;
10944
- };
10945
-
10946
- setStateValue(updateFunction);
10947
- } else {
10948
- if (!isControlled) {
10949
- setStateValue(value);
10950
- }
10951
-
10952
- onChangeCaller(value, ...args);
10953
- }
10954
- }, [isControlled, onChange]); // If a controlled component's value prop changes, we need to update stateRef
10955
-
10956
- if (isControlled) {
10957
- stateRef.current = value;
10958
- } else {
10959
- value = stateValue;
10960
- }
10961
-
10962
- return [value, setValue];
10963
- }
10964
-
10965
- function _extends$3() {
10966
- _extends$3 = Object.assign || function (target) {
10967
- for (var i = 1; i < arguments.length; i++) {
10968
- var source = arguments[i];
10969
-
10970
- for (var key in source) {
10971
- if (Object.prototype.hasOwnProperty.call(source, key)) {
10972
- target[key] = source[key];
10973
- }
10974
- }
10975
- }
10976
-
10977
- return target;
10978
- };
10979
-
10980
- return _extends$3.apply(this, arguments);
10981
- }
10982
-
10983
- /*
10984
- * Copyright 2020 Adobe. All rights reserved.
10985
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10986
- * you may not use this file except in compliance with the License. You may obtain a copy
10987
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10988
- *
10989
- * Unless required by applicable law or agreed to in writing, software distributed under
10990
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10991
- * OF ANY KIND, either express or implied. See the License for the specific language
10992
- * governing permissions and limitations under the License.
10993
- */
10994
-
10995
- /**
10996
- * A Selection is a special Set containing Keys, which also has an anchor
10997
- * and current selected key for use when range selecting.
10998
- */
10999
- class $c91e86e24f2dc9a2182dcc2674c58c$export$Selection extends Set {
11000
- constructor(keys, anchorKey, currentKey) {
11001
- super(keys);
11002
- this.anchorKey = void 0;
11003
- this.currentKey = void 0;
11004
-
11005
- if (keys instanceof $c91e86e24f2dc9a2182dcc2674c58c$export$Selection) {
11006
- this.anchorKey = anchorKey || keys.anchorKey;
11007
- this.currentKey = currentKey || keys.currentKey;
11008
- } else {
11009
- this.anchorKey = anchorKey;
11010
- this.currentKey = currentKey;
11011
- }
11012
- }
11013
-
11014
- }
11015
-
11016
- /**
11017
- * Manages state for multiple selection and focus in a collection.
11018
- */
11019
- function useMultipleSelectionState(props) {
11020
- let {
11021
- selectionMode = 'none',
11022
- disallowEmptySelection
11023
- } = props; // We want synchronous updates to `isFocused` and `focusedKey` after their setters are called.
11024
- // But we also need to trigger a react re-render. So, we have both a ref (sync) and state (async).
11025
-
11026
- let isFocusedRef = useRef(false);
11027
- let [, setFocused] = useState(false);
11028
- let focusedKeyRef = useRef(null);
11029
- let childFocusStrategyRef = useRef(null);
11030
- let [, setFocusedKey] = useState(null);
11031
- let selectedKeysProp = useMemo(() => $c86d35e876e048ac11515eee40c7$var$convertSelection(props.selectedKeys), [props.selectedKeys]);
11032
- let defaultSelectedKeys = useMemo(() => $c86d35e876e048ac11515eee40c7$var$convertSelection(props.defaultSelectedKeys, new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection()), [props.defaultSelectedKeys]);
11033
- let [selectedKeys, setSelectedKeys] = useControlledState(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
11034
- let disabledKeysProp = useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [props.disabledKeys]);
11035
- return {
11036
- selectionMode,
11037
- disallowEmptySelection,
11038
-
11039
- get isFocused() {
11040
- return isFocusedRef.current;
11041
- },
11042
-
11043
- setFocused(f) {
11044
- isFocusedRef.current = f;
11045
- setFocused(f);
11046
- },
11047
-
11048
- get focusedKey() {
11049
- return focusedKeyRef.current;
11050
- },
11051
-
11052
- get childFocusStrategy() {
11053
- return childFocusStrategyRef.current;
11054
- },
11055
-
11056
- setFocusedKey(k, childFocusStrategy) {
11057
- if (childFocusStrategy === void 0) {
11058
- childFocusStrategy = 'first';
11059
- }
11060
-
11061
- focusedKeyRef.current = k;
11062
- childFocusStrategyRef.current = childFocusStrategy;
11063
- setFocusedKey(k);
11064
- },
11065
-
11066
- selectedKeys,
11067
- setSelectedKeys,
11068
- disabledKeys: disabledKeysProp
11069
- };
11070
- }
11071
-
11072
- function $c86d35e876e048ac11515eee40c7$var$convertSelection(selection, defaultValue) {
11073
- if (!selection) {
11074
- return defaultValue;
11075
- }
11076
-
11077
- return selection === 'all' ? 'all' : new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection(selection);
11078
- }
11079
-
11080
- /**
11081
- * An interface for reading and updating multiple selection state.
11082
- */
11083
- class SelectionManager {
11084
- constructor(collection, state, options) {
11085
- var _options$allowsCellSe;
11086
-
11087
- this.collection = void 0;
11088
- this.state = void 0;
11089
- this.allowsCellSelection = void 0;
11090
- this._isSelectAll = void 0;
11091
- this.collection = collection;
11092
- this.state = state;
11093
- this.allowsCellSelection = (_options$allowsCellSe = options == null ? void 0 : options.allowsCellSelection) != null ? _options$allowsCellSe : false;
11094
- this._isSelectAll = null;
11095
- }
11096
- /**
11097
- * The type of selection that is allowed in the collection.
11098
- */
11099
-
11100
-
11101
- get selectionMode() {
11102
- return this.state.selectionMode;
11103
- }
11104
- /**
11105
- * Whether the collection allows empty selection.
11106
- */
11107
-
11108
-
11109
- get disallowEmptySelection() {
11110
- return this.state.disallowEmptySelection;
11111
- }
11112
- /**
11113
- * Whether the collection is currently focused.
11114
- */
11115
-
11116
-
11117
- get isFocused() {
11118
- return this.state.isFocused;
11119
- }
11120
- /**
11121
- * Sets whether the collection is focused.
11122
- */
11123
-
11124
-
11125
- setFocused(isFocused) {
11126
- this.state.setFocused(isFocused);
11127
- }
11128
- /**
11129
- * The current focused key in the collection.
11130
- */
11131
-
11132
-
11133
- get focusedKey() {
11134
- return this.state.focusedKey;
11135
- }
11136
- /** Whether the first or last child of the focused key should receive focus. */
11137
-
11138
-
11139
- get childFocusStrategy() {
11140
- return this.state.childFocusStrategy;
11141
- }
11142
- /**
11143
- * Sets the focused key.
11144
- */
11145
-
11146
-
11147
- setFocusedKey(key, childFocusStrategy) {
11148
- this.state.setFocusedKey(key, childFocusStrategy);
11149
- }
11150
- /**
11151
- * The currently selected keys in the collection.
11152
- */
11153
-
11154
-
11155
- get selectedKeys() {
11156
- return this.state.selectedKeys === 'all' ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
11157
- }
11158
- /**
11159
- * The raw selection value for the collection.
11160
- * Either 'all' for select all, or a set of keys.
11161
- */
11162
-
11163
-
11164
- get rawSelection() {
11165
- return this.state.selectedKeys;
11166
- }
11167
- /**
11168
- * Returns whether a key is selected.
11169
- */
11170
-
11171
-
11172
- isSelected(key) {
11173
- if (this.state.selectionMode === 'none') {
11174
- return false;
11175
- }
11176
-
11177
- key = this.getKey(key);
11178
- return this.state.selectedKeys === 'all' ? !this.state.disabledKeys.has(key) : this.state.selectedKeys.has(key);
11179
- }
11180
- /**
11181
- * Whether the selection is empty.
11182
- */
11183
-
11184
-
11185
- get isEmpty() {
11186
- return this.state.selectedKeys !== 'all' && this.state.selectedKeys.size === 0;
11187
- }
11188
- /**
11189
- * Whether all items in the collection are selected.
11190
- */
11191
-
11192
-
11193
- get isSelectAll() {
11194
- if (this.isEmpty) {
11195
- return false;
11196
- }
11197
-
11198
- if (this.state.selectedKeys === 'all') {
11199
- return true;
11200
- }
11201
-
11202
- if (this._isSelectAll != null) {
11203
- return this._isSelectAll;
11204
- }
11205
-
11206
- let allKeys = this.getSelectAllKeys();
11207
- let selectedKeys = this.state.selectedKeys;
11208
- this._isSelectAll = allKeys.every(k => selectedKeys.has(k));
11209
- return this._isSelectAll;
11210
- }
11211
-
11212
- get firstSelectedKey() {
11213
- var _first;
11214
-
11215
- let first = null;
11216
-
11217
- for (let key of this.state.selectedKeys) {
11218
- let item = this.collection.getItem(key);
11219
-
11220
- if (!first || (item == null ? void 0 : item.index) < first.index) {
11221
- first = item;
11222
- }
11223
- }
11224
-
11225
- return (_first = first) == null ? void 0 : _first.key;
11226
- }
11227
-
11228
- get lastSelectedKey() {
11229
- var _last;
11230
-
11231
- let last = null;
11232
-
11233
- for (let key of this.state.selectedKeys) {
11234
- let item = this.collection.getItem(key);
11235
-
11236
- if (!last || (item == null ? void 0 : item.index) > last.index) {
11237
- last = item;
11238
- }
11239
- }
11240
-
11241
- return (_last = last) == null ? void 0 : _last.key;
11242
- }
11243
- /**
11244
- * Extends the selection to the given key.
11245
- */
11246
-
11247
-
11248
- extendSelection(toKey) {
11249
- toKey = this.getKey(toKey);
11250
- let selection; // Only select the one key if coming from a select all.
11251
-
11252
- if (this.state.selectedKeys === 'all') {
11253
- selection = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection([toKey], toKey, toKey);
11254
- } else {
11255
- let selectedKeys = this.state.selectedKeys;
11256
- let anchorKey = selectedKeys.anchorKey || toKey;
11257
- selection = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection(selectedKeys, anchorKey, toKey);
11258
-
11259
- for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) {
11260
- selection.delete(key);
11261
- }
11262
-
11263
- for (let key of this.getKeyRange(toKey, anchorKey)) {
11264
- if (!this.state.disabledKeys.has(key)) {
11265
- selection.add(key);
11266
- }
11267
- }
11268
- }
11269
-
11270
- this.state.setSelectedKeys(selection);
11271
- }
11272
-
11273
- getKeyRange(from, to) {
11274
- let fromItem = this.collection.getItem(from);
11275
- let toItem = this.collection.getItem(to);
11276
-
11277
- if (fromItem && toItem) {
11278
- if (fromItem.index <= toItem.index) {
11279
- return this.getKeyRangeInternal(from, to);
11280
- }
11281
-
11282
- return this.getKeyRangeInternal(to, from);
11283
- }
11284
-
11285
- return [];
11286
- }
11287
-
11288
- getKeyRangeInternal(from, to) {
11289
- let keys = [];
11290
- let key = from;
11291
-
11292
- while (key) {
11293
- let item = this.collection.getItem(key);
11294
-
11295
- if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) {
11296
- keys.push(key);
11297
- }
11298
-
11299
- if (key === to) {
11300
- return keys;
11301
- }
11302
-
11303
- key = this.collection.getKeyAfter(key);
11304
- }
11305
-
11306
- return [];
11307
- }
11308
-
11309
- getKey(key) {
11310
- let item = this.collection.getItem(key);
11311
-
11312
- if (!item) {
11313
- // ¯\_(ツ)_/¯
11314
- return key;
11315
- } // If cell selection is allowed, just return the key.
11316
-
11317
-
11318
- if (item.type === 'cell' && this.allowsCellSelection) {
11319
- return key;
11320
- } // Find a parent item to select
11321
-
11322
-
11323
- while (item.type !== 'item' && item.parentKey) {
11324
- item = this.collection.getItem(item.parentKey);
11325
- }
11326
-
11327
- if (!item || item.type !== 'item') {
11328
- return null;
11329
- }
11330
-
11331
- return item.key;
11332
- }
11333
- /**
11334
- * Toggles whether the given key is selected.
11335
- */
11336
-
11337
-
11338
- toggleSelection(key) {
11339
- key = this.getKey(key);
11340
-
11341
- if (key == null) {
11342
- return;
11343
- }
11344
-
11345
- let keys = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection(this.state.selectedKeys === 'all' ? this.getSelectAllKeys() : this.state.selectedKeys);
11346
-
11347
- if (keys.has(key)) {
11348
- keys.delete(key); // TODO: move anchor to last selected key...
11349
- // Does `current` need to move here too?
11350
- } else {
11351
- keys.add(key);
11352
- keys.anchorKey = key;
11353
- keys.currentKey = key;
11354
- }
11355
-
11356
- if (this.disallowEmptySelection && keys.size === 0) {
11357
- return;
11358
- }
11359
-
11360
- this.state.setSelectedKeys(keys);
11361
- }
11362
- /**
11363
- * Replaces the selection with only the given key.
11364
- */
11365
-
11366
-
11367
- replaceSelection(key) {
11368
- key = this.getKey(key);
11369
-
11370
- if (key == null) {
11371
- return;
11372
- }
11373
-
11374
- this.state.setSelectedKeys(new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection([key], key, key));
11375
- }
11376
- /**
11377
- * Replaces the selection with the given keys.
11378
- */
11379
-
11380
-
11381
- setSelectedKeys(keys) {
11382
- if (this.selectionMode === 'none') {
11383
- return;
11384
- }
11385
-
11386
- let selection = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection();
11387
-
11388
- for (let key of keys) {
11389
- key = this.getKey(key);
11390
-
11391
- if (key != null) {
11392
- selection.add(key);
11393
-
11394
- if (this.selectionMode === 'single') {
11395
- break;
11396
- }
11397
- }
11398
- }
11399
-
11400
- this.state.setSelectedKeys(selection);
11401
- }
11402
-
11403
- getSelectAllKeys() {
11404
- let keys = [];
11405
-
11406
- let addKeys = key => {
11407
- while (key) {
11408
- if (!this.state.disabledKeys.has(key)) {
11409
- let item = this.collection.getItem(key);
11410
-
11411
- if (item.type === 'item') {
11412
- keys.push(key);
11413
- } // Add child keys. If cell selection is allowed, then include item children too.
11414
-
11415
-
11416
- if (item.hasChildNodes && (this.allowsCellSelection || item.type !== 'item')) {
11417
- addKeys([...item.childNodes][0].key);
11418
- }
11419
- }
11420
-
11421
- key = this.collection.getKeyAfter(key);
11422
- }
11423
- };
11424
-
11425
- addKeys(this.collection.getFirstKey());
11426
- return keys;
11427
- }
11428
- /**
11429
- * Selects all items in the collection.
11430
- */
11431
-
11432
-
11433
- selectAll() {
11434
- if (this.selectionMode === 'multiple') {
11435
- this.state.setSelectedKeys('all');
11436
- }
11437
- }
11438
- /**
11439
- * Removes all keys from the selection.
11440
- */
11441
-
11442
-
11443
- clearSelection() {
11444
- if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) {
11445
- this.state.setSelectedKeys(new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection());
11446
- }
11447
- }
11448
- /**
11449
- * Toggles between select all and an empty selection.
11450
- */
11451
-
11452
-
11453
- toggleSelectAll() {
11454
- if (this.isSelectAll) {
11455
- this.clearSelection();
11456
- } else {
11457
- this.selectAll();
11458
- }
11459
- }
11460
-
11461
- select(key, e) {
11462
- if (this.selectionMode === 'none') {
11463
- return;
11464
- }
11465
-
11466
- if (this.selectionMode === 'single') {
11467
- if (this.isSelected(key) && !this.disallowEmptySelection) {
11468
- this.toggleSelection(key);
11469
- } else {
11470
- this.replaceSelection(key);
11471
- }
11472
- } else if (e && e.shiftKey) {
11473
- this.extendSelection(key);
11474
- } else {
11475
- this.toggleSelection(key);
11476
- }
11477
- }
11478
- /**
11479
- * Returns whether the current selection is equal to the given selection.
11480
- */
11481
-
11482
-
11483
- isSelectionEqual(selection) {
11484
- if (selection === this.state.selectedKeys) {
11485
- return true;
11486
- } // Check if the set of keys match.
11487
-
11488
-
11489
- let selectedKeys = this.selectedKeys;
11490
-
11491
- if (selection.size !== selectedKeys.size) {
11492
- return false;
11493
- }
11494
-
11495
- for (let key of selection) {
11496
- if (!selectedKeys.has(key)) {
11497
- return false;
11498
- }
11499
- }
11500
-
11501
- for (let key of selectedKeys) {
11502
- if (!selection.has(key)) {
11503
- return false;
11504
- }
11505
- }
11506
-
11507
- return true;
11508
- }
11509
-
11510
- }
11511
-
11512
- let $ed5d55e571caf578a4f08babbaa26be$var$_Symbol$iterator;
11513
- $ed5d55e571caf578a4f08babbaa26be$var$_Symbol$iterator = Symbol.iterator;
11514
-
11515
- /*
11516
- * Copyright 2020 Adobe. All rights reserved.
11517
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11518
- * you may not use this file except in compliance with the License. You may obtain a copy
11519
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
11520
- *
11521
- * Unless required by applicable law or agreed to in writing, software distributed under
11522
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11523
- * OF ANY KIND, either express or implied. See the License for the specific language
11524
- * governing permissions and limitations under the License.
11525
- */
11526
- class ListCollection {
11527
- constructor(nodes) {
11528
- var _last;
11529
-
11530
- this.keyMap = new Map();
11531
- this.iterable = void 0;
11532
- this.firstKey = void 0;
11533
- this.lastKey = void 0;
11534
- this.iterable = nodes;
11535
-
11536
- let visit = node => {
11537
- this.keyMap.set(node.key, node);
11538
-
11539
- if (node.childNodes && node.type === 'section') {
11540
- for (let child of node.childNodes) {
11541
- visit(child);
11542
- }
11543
- }
11544
- };
11545
-
11546
- for (let node of nodes) {
11547
- visit(node);
11548
- }
11549
-
11550
- let last;
11551
- let index = 0;
11552
-
11553
- for (let [key, node] of this.keyMap) {
11554
- if (last) {
11555
- last.nextKey = key;
11556
- node.prevKey = last.key;
11557
- } else {
11558
- this.firstKey = key;
11559
- node.prevKey = undefined;
11560
- }
11561
-
11562
- if (node.type === 'item') {
11563
- node.index = index++;
11564
- }
11565
-
11566
- last = node; // Set nextKey as undefined since this might be the last node
11567
- // If it isn't the last node, last.nextKey will properly set at start of new loop
11568
-
11569
- last.nextKey = undefined;
11570
- }
11571
-
11572
- this.lastKey = (_last = last) == null ? void 0 : _last.key;
11573
- }
11574
-
11575
- *[$ed5d55e571caf578a4f08babbaa26be$var$_Symbol$iterator]() {
11576
- yield* this.iterable;
11577
- }
11578
-
11579
- get size() {
11580
- return this.keyMap.size;
11581
- }
11582
-
11583
- getKeys() {
11584
- return this.keyMap.keys();
11585
- }
11586
-
11587
- getKeyBefore(key) {
11588
- let node = this.keyMap.get(key);
11589
- return node ? node.prevKey : null;
11590
- }
11591
-
11592
- getKeyAfter(key) {
11593
- let node = this.keyMap.get(key);
11594
- return node ? node.nextKey : null;
11595
- }
11596
-
11597
- getFirstKey() {
11598
- return this.firstKey;
11599
- }
11600
-
11601
- getLastKey() {
11602
- return this.lastKey;
11603
- }
11604
-
11605
- getItem(key) {
11606
- return this.keyMap.get(key);
11607
- }
11608
-
11609
- at(idx) {
11610
- const keys = [...this.getKeys()];
11611
- return this.getItem(keys[idx]);
11612
- }
11613
-
11614
- }
11615
-
11616
- /**
11617
- * Provides state management for list-like components. Handles building a collection
11618
- * of items from props, and manages multiple selection state.
11619
- */
11620
- function useListState(props) {
11621
- let {
11622
- filter
11623
- } = props;
11624
- let selectionState = useMultipleSelectionState(props);
11625
- let disabledKeys = useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [props.disabledKeys]);
11626
-
11627
- let factory = nodes => filter ? new ListCollection(filter(nodes)) : new ListCollection(nodes);
11628
-
11629
- let context = useMemo(() => ({
11630
- suppressTextValueWarning: props.suppressTextValueWarning
11631
- }), [props.suppressTextValueWarning]);
11632
- let collection = useCollection(props, factory, context, [filter]); // Reset focused key if that item is deleted from the collection.
11633
-
11634
- useEffect(() => {
11635
- if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
11636
- selectionState.setFocusedKey(null);
11637
- }
11638
- }, [collection, selectionState.focusedKey]);
11639
- return {
11640
- collection,
11641
- disabledKeys,
11642
- selectionManager: new SelectionManager(collection, selectionState)
11643
- };
11644
- }
11645
-
11646
- /**
11647
- * Provides state management for list-like components with single selection.
11648
- * Handles building a collection of items from props, and manages selection state.
11649
- */
11650
- function useSingleSelectListState(props) {
11651
- var _props$defaultSelecte;
11652
-
11653
- let [selectedKey, setSelectedKey] = useControlledState(props.selectedKey, (_props$defaultSelecte = props.defaultSelectedKey) != null ? _props$defaultSelecte : null, props.onSelectionChange);
11654
- let selectedKeys = useMemo(() => selectedKey != null ? [selectedKey] : [], [selectedKey]);
11655
- let {
11656
- collection,
11657
- disabledKeys,
11658
- selectionManager
11659
- } = useListState(_extends$3({}, props, {
11660
- selectionMode: 'single',
11661
- disallowEmptySelection: true,
11662
- selectedKeys,
11663
- onSelectionChange: keys => {
11664
- let key = keys.values().next().value; // Always fire onSelectionChange, even if the key is the same
11665
- // as the current key (useControlledState does not).
11666
-
11667
- if (key === selectedKey && props.onSelectionChange) {
11668
- props.onSelectionChange(key);
11669
- }
11670
-
11671
- setSelectedKey(key);
11672
- }
11673
- }));
11674
- let selectedItem = selectedKey != null ? collection.getItem(selectedKey) : null;
11675
- return {
11676
- collection,
11677
- disabledKeys,
11678
- selectionManager,
11679
- selectedKey,
11680
- setSelectedKey,
11681
- selectedItem
11682
- };
11683
- }
11684
-
11685
- function _extends$2() {
11686
- _extends$2 = Object.assign || function (target) {
11687
- for (var i = 1; i < arguments.length; i++) {
11688
- var source = arguments[i];
11689
-
11690
- for (var key in source) {
11691
- if (Object.prototype.hasOwnProperty.call(source, key)) {
11692
- target[key] = source[key];
11693
- }
11694
- }
11695
- }
11696
-
11697
- return target;
11698
- };
11699
-
11700
- return _extends$2.apply(this, arguments);
11701
- }
11702
-
11703
- /**
11704
- * Provides state management for a Tabs component. Tabs include a TabList which tracks
11705
- * which tab is currently selected and displays the content associated with that Tab in a TabPanel.
11706
- */
11707
- function useTabListState(props) {
11708
- let state = useSingleSelectListState(_extends$2({}, props, {
11709
- suppressTextValueWarning: true
11710
- }));
11711
- useEffect(() => {
11712
- // Ensure a tab is always selected (in case no selected key was specified or if selected item was deleted from collection)
11713
- let selectedKey = state.selectedKey;
11714
-
11715
- if (state.selectionManager.isEmpty || !state.collection.getItem(selectedKey)) {
11716
- selectedKey = state.collection.getFirstKey();
11717
- state.selectionManager.replaceSelection(selectedKey);
11718
- }
11719
-
11720
- if (state.selectionManager.focusedKey == null) {
11721
- state.selectionManager.setFocusedKey(selectedKey);
11722
- }
11723
- }, [state.selectionManager, state.selectedKey, state.collection]);
11724
- return state;
11725
- }
11726
-
11727
- // Default context value to use in case there is no SSRProvider. This is fine for
11728
- // client-only apps. In order to support multiple copies of React Aria potentially
11729
- // being on the page at once, the prefix is set to a random number. SSRProvider
11730
- // will reset this to zero for consistency between server and client, so in the
11731
- // SSR case multiple copies of React Aria is not supported.
11732
- const $f01a183cc7bdff77849e49ad26eb904$var$defaultContext = {
11733
- prefix: Math.round(Math.random() * 10000000000),
11734
- current: 0
11735
- };
11736
-
11737
- const $f01a183cc7bdff77849e49ad26eb904$var$SSRContext = /*#__PURE__*/React__default.createContext($f01a183cc7bdff77849e49ad26eb904$var$defaultContext);
11738
- let $f01a183cc7bdff77849e49ad26eb904$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
11739
- /** @private */
11740
-
11741
- function useSSRSafeId(defaultId) {
11742
- let ctx = useContext($f01a183cc7bdff77849e49ad26eb904$var$SSRContext); // If we are rendering in a non-DOM environment, and there's no SSRProvider,
11743
- // provide a warning to hint to the developer to add one.
11744
-
11745
- if (ctx === $f01a183cc7bdff77849e49ad26eb904$var$defaultContext && !$f01a183cc7bdff77849e49ad26eb904$var$canUseDOM) {
11746
- console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
11747
- }
11748
-
11749
- return useMemo(() => defaultId || "react-aria-" + ctx.prefix + "-" + ++ctx.current, [defaultId]);
11750
- }
11751
- /**
11752
- * Returns whether the component is currently being server side rendered or
11753
- * hydrated on the client. Can be used to delay browser-specific rendering
11754
- * until after hydration.
11755
- */
11756
-
11757
- function useIsSSR() {
11758
- let cur = useContext($f01a183cc7bdff77849e49ad26eb904$var$SSRContext);
11759
- let isInSSRContext = cur !== $f01a183cc7bdff77849e49ad26eb904$var$defaultContext;
11760
- let [isSSR, setIsSSR] = useState(isInSSRContext); // If on the client, and the component was initially server rendered,
11761
- // then schedule a layout effect to update the component after hydration.
11762
-
11763
- if (typeof window !== 'undefined' && isInSSRContext) {
11764
- // This if statement technically breaks the rules of hooks, but is safe
11765
- // because the condition never changes after mounting.
11766
- // eslint-disable-next-line react-hooks/rules-of-hooks
11767
- useLayoutEffect$1(() => {
11768
- setIsSSR(false);
11769
- }, []);
11770
- }
11771
-
11772
- return isSSR;
11773
- }
11774
-
11775
- /*
11776
- * Copyright 2020 Adobe. All rights reserved.
11777
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11778
- * you may not use this file except in compliance with the License. You may obtain a copy
11779
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
11780
- *
11781
- * Unless required by applicable law or agreed to in writing, software distributed under
11782
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11783
- * OF ANY KIND, either express or implied. See the License for the specific language
11784
- * governing permissions and limitations under the License.
11785
- */
11786
- // https://en.wikipedia.org/wiki/Right-to-left
11787
- const $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);
11788
- 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']);
11789
- /**
11790
- * 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}.
11791
- */
11792
-
11793
- function $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) {
11794
- // If the Intl.Locale API is available, use it to get the script for the locale.
11795
- // This is more accurate than guessing by language, since languages can be written in multiple scripts.
11796
- // @ts-ignore
11797
- if (Intl.Locale) {
11798
- // @ts-ignore
11799
- let script = new Intl.Locale(locale).maximize().script;
11800
- return $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS.has(script);
11801
- } // If not, just guess by the language (first part of the locale)
11802
-
11803
-
11804
- let lang = locale.split('-')[0];
11805
- return $d26e725ad56fbcb2c25f52b7de27$var$RTL_LANGS.has(lang);
11806
- }
11807
-
11808
- /**
11809
- * Gets the locale setting of the browser.
11810
- */
11811
- function $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale() {
11812
- // @ts-ignore
11813
- let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
11814
- return {
11815
- locale,
11816
- direction: $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) ? 'rtl' : 'ltr'
11817
- };
11818
- }
11819
-
11820
- let $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();
11821
- let $e851d0b81d46abd5f971c8e95c27f1$var$listeners = new Set();
11822
-
11823
- function $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale() {
11824
- $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();
11825
-
11826
- for (let listener of $e851d0b81d46abd5f971c8e95c27f1$var$listeners) {
11827
- listener($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale);
11828
- }
11829
- }
11830
- /**
11831
- * Returns the current browser/system language, and updates when it changes.
11832
- */
11833
-
11834
-
11835
- function $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale() {
11836
- let isSSR = useIsSSR();
11837
- let [defaultLocale, setDefaultLocale] = useState($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale);
11838
- useEffect(() => {
11839
- if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {
11840
- window.addEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);
11841
- }
11842
-
11843
- $e851d0b81d46abd5f971c8e95c27f1$var$listeners.add(setDefaultLocale);
11844
- return () => {
11845
- $e851d0b81d46abd5f971c8e95c27f1$var$listeners.delete(setDefaultLocale);
11846
-
11847
- if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {
11848
- window.removeEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);
11849
- }
11850
- };
11851
- }, []); // We cannot determine the browser's language on the server, so default to
11852
- // en-US. This will be updated after hydration on the client to the correct value.
11853
-
11854
- if (isSSR) {
11855
- return {
11856
- locale: 'en-US',
11857
- direction: 'ltr'
11858
- };
11859
- }
11860
-
11861
- return defaultLocale;
11862
- }
11863
-
11864
- const $cff8541df3b5c83067b2ab3ee0d20$var$I18nContext = /*#__PURE__*/React__default.createContext(null);
11865
- /**
11866
- * Returns the current locale and layout direction.
11867
- */
11868
-
11869
- function useLocale() {
11870
- let defaultLocale = $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale();
11871
- let context = useContext($cff8541df3b5c83067b2ab3ee0d20$var$I18nContext);
11872
- return context || defaultLocale;
11873
- }
11874
-
11875
- // During SSR, React emits a warning when calling useLayoutEffect.
11876
- // Since neither useLayoutEffect nor useEffect run on the server,
11877
- // we can suppress this by replace it with a noop on the server.
11878
- const useLayoutEffect = typeof window !== 'undefined' ? React__default.useLayoutEffect : () => {};
11879
- let $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap = new Map();
11880
- /**
11881
- * If a default is not provided, generate an id.
11882
- * @param defaultId - Default component id.
11883
- */
11884
-
11885
- function useId(defaultId) {
11886
- let isRendering = useRef(true);
11887
- isRendering.current = true;
11888
- let [value, setValue] = useState(defaultId);
11889
- let nextId = useRef(null);
11890
- let res = useSSRSafeId(value); // don't memo this, we want it new each render so that the Effects always run
11891
-
11892
- let updateValue = val => {
11893
- if (!isRendering.current) {
11894
- setValue(val);
11895
- } else {
11896
- nextId.current = val;
11897
- }
11898
- };
11899
-
11900
- $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.set(res, updateValue);
11901
- useLayoutEffect(() => {
11902
- isRendering.current = false;
11903
- }, [updateValue]);
11904
- useLayoutEffect(() => {
11905
- let r = res;
11906
- return () => {
11907
- $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.delete(r);
11908
- };
11909
- }, [res]);
11910
- useEffect(() => {
11911
- let newId = nextId.current;
11912
-
11913
- if (newId) {
11914
- setValue(newId);
11915
- nextId.current = null;
11916
- }
11917
- }, [setValue, updateValue]);
11918
- return res;
11919
- }
11920
- /**
11921
- * Merges two ids.
11922
- * Different ids will trigger a side-effect and re-render components hooked up with `useId`.
11923
- */
11924
-
11925
- function mergeIds(idA, idB) {
11926
- if (idA === idB) {
11927
- return idA;
11928
- }
11929
-
11930
- let setIdA = $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.get(idA);
11931
-
11932
- if (setIdA) {
11933
- setIdA(idB);
11934
- return idB;
11935
- }
11936
-
11937
- let setIdB = $f8b5fdd96fb429d7102983f777c41307$var$idsUpdaterMap.get(idB);
11938
-
11939
- if (setIdB) {
11940
- setIdB(idA);
11941
- return idA;
11942
- }
11943
-
11944
- return idB;
11945
- }
11946
-
11947
- /*
11948
- * Copyright 2020 Adobe. All rights reserved.
11949
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11950
- * you may not use this file except in compliance with the License. You may obtain a copy
11951
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
11952
- *
11953
- * Unless required by applicable law or agreed to in writing, software distributed under
11954
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11955
- * OF ANY KIND, either express or implied. See the License for the specific language
11956
- * governing permissions and limitations under the License.
11957
- */
11958
-
11959
- /**
11960
- * Calls all functions in the order they were chained with the same arguments.
11961
- */
11962
- function chain() {
11963
- for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
11964
- callbacks[_key] = arguments[_key];
11965
- }
11966
-
11967
- return function () {
11968
- for (let callback of callbacks) {
11969
- if (typeof callback === 'function') {
11970
- callback(...arguments);
11971
- }
11972
- }
11973
- };
11974
- }
11975
-
11976
- /**
11977
- * Merges multiple props objects together. Event handlers are chained,
11978
- * classNames are combined, and ids are deduplicated - different ids
11979
- * will trigger a side-effect and re-render components hooked up with `useId`.
11980
- * For all other props, the last prop object overrides all previous ones.
11981
- * @param args - Multiple sets of props to merge together.
11982
- */
11983
- function mergeProps() {
11984
- let result = {};
11985
-
11986
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
11987
- args[_key] = arguments[_key];
11988
- }
11989
-
11990
- for (let props of args) {
11991
- for (let key in result) {
11992
- // Chain events
11993
- if (/^on[A-Z]/.test(key) && typeof result[key] === 'function' && typeof props[key] === 'function') {
11994
- 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
11995
- } else if (key === 'className' && typeof result.className === 'string' && typeof props.className === 'string') {
11996
- result[key] = clsx(result.className, props.className);
11997
- } else if (key === 'UNSAFE_className' && typeof result.UNSAFE_className === 'string' && typeof props.UNSAFE_className === 'string') {
11998
- result[key] = clsx(result.UNSAFE_className, props.UNSAFE_className);
11999
- } else if (key === 'id' && result.id && props.id) {
12000
- result.id = mergeIds(result.id, props.id); // Override others
12001
- } else {
12002
- result[key] = props[key] !== undefined ? props[key] : result[key];
12003
- }
12004
- } // Add props from b that are not in a
12005
-
12006
-
12007
- for (let key in props) {
12008
- if (result[key] === undefined) {
12009
- result[key] = props[key];
12010
- }
12011
- }
12012
- }
12013
-
12014
- return result;
12015
- }
12016
- // Currently necessary for Safari and old Edge:
12017
- // https://caniuse.com/#feat=mdn-api_htmlelement_focus_preventscroll_option
12018
- // See https://bugs.webkit.org/show_bug.cgi?id=178583
12019
- //
12020
- // Original licensing for the following methods can be found in the
12021
- // NOTICE file in the root directory of this source tree.
12022
- // See https://github.com/calvellido/focus-options-polyfill
12023
- function focusWithoutScrolling(element) {
12024
- if ($bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScroll()) {
12025
- element.focus({
12026
- preventScroll: true
12027
- });
12028
- } else {
12029
- let scrollableElements = $bc7c9c3af78f5218ff72cecce15730$var$getScrollableElements(element);
12030
- element.focus();
12031
- $bc7c9c3af78f5218ff72cecce15730$var$restoreScrollPosition(scrollableElements);
12032
- }
12033
- }
12034
- let $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached = null;
12035
-
12036
- function $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScroll() {
12037
- if ($bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached == null) {
12038
- $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached = false;
12039
-
12040
- try {
12041
- var focusElem = document.createElement('div');
12042
- focusElem.focus({
12043
- get preventScroll() {
12044
- $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached = true;
12045
- return true;
12046
- }
12047
-
12048
- });
12049
- } catch (e) {// Ignore
12050
- }
12051
- }
12052
-
12053
- return $bc7c9c3af78f5218ff72cecce15730$var$supportsPreventScrollCached;
12054
- }
12055
-
12056
- function $bc7c9c3af78f5218ff72cecce15730$var$getScrollableElements(element) {
12057
- var parent = element.parentNode;
12058
- var scrollableElements = [];
12059
- var rootScrollingElement = document.scrollingElement || document.documentElement;
12060
-
12061
- while (parent instanceof HTMLElement && parent !== rootScrollingElement) {
12062
- if (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) {
12063
- scrollableElements.push({
12064
- element: parent,
12065
- scrollTop: parent.scrollTop,
12066
- scrollLeft: parent.scrollLeft
12067
- });
12068
- }
12069
-
12070
- parent = parent.parentNode;
12071
- }
12072
-
12073
- if (rootScrollingElement instanceof HTMLElement) {
12074
- scrollableElements.push({
12075
- element: rootScrollingElement,
12076
- scrollTop: rootScrollingElement.scrollTop,
12077
- scrollLeft: rootScrollingElement.scrollLeft
12078
- });
12079
- }
12080
-
12081
- return scrollableElements;
12082
- }
12083
-
12084
- function $bc7c9c3af78f5218ff72cecce15730$var$restoreScrollPosition(scrollableElements) {
12085
- for (let {
12086
- element,
12087
- scrollTop,
12088
- scrollLeft
12089
- } of scrollableElements) {
12090
- element.scrollTop = scrollTop;
12091
- element.scrollLeft = scrollLeft;
12092
- }
12093
- }
12094
- // mapped to a set of CSS properties that are transitioning for that element.
12095
- // This is necessary rather than a simple count of transitions because of browser
12096
- // bugs, e.g. Chrome sometimes fires both transitionend and transitioncancel rather
12097
- // than one or the other. So we need to track what's actually transitioning so that
12098
- // we can ignore these duplicate events.
12099
- let $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement = new Map(); // A list of callbacks to call once there are no transitioning elements.
12100
-
12101
- let $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks = new Set();
12102
-
12103
- function $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$setupGlobalEvents() {
12104
- if (typeof window === 'undefined') {
12105
- return;
12106
- }
12107
-
12108
- let onTransitionStart = e => {
12109
- // Add the transitioning property to the list for this element.
12110
- let transitions = $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.get(e.target);
12111
-
12112
- if (!transitions) {
12113
- transitions = new Set();
12114
- $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.set(e.target, transitions); // The transitioncancel event must be registered on the element itself, rather than as a global
12115
- // event. This enables us to handle when the node is deleted from the document while it is transitioning.
12116
- // In that case, the cancel event would have nowhere to bubble to so we need to handle it directly.
12117
-
12118
- e.target.addEventListener('transitioncancel', onTransitionEnd);
12119
- }
12120
-
12121
- transitions.add(e.propertyName);
12122
- };
12123
-
12124
- let onTransitionEnd = e => {
12125
- // Remove property from list of transitioning properties.
12126
- let properties = $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.get(e.target);
12127
-
12128
- if (!properties) {
12129
- return;
12130
- }
12131
-
12132
- properties.delete(e.propertyName); // If empty, remove transitioncancel event, and remove the element from the list of transitioning elements.
12133
-
12134
- if (properties.size === 0) {
12135
- e.target.removeEventListener('transitioncancel', onTransitionEnd);
12136
- $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.delete(e.target);
12137
- } // If no transitioning elements, call all of the queued callbacks.
12138
-
12139
-
12140
- if ($b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.size === 0) {
12141
- for (let cb of $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks) {
12142
- cb();
12143
- }
12144
-
12145
- $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks.clear();
12146
- }
12147
- };
12148
-
12149
- document.body.addEventListener('transitionrun', onTransitionStart);
12150
- document.body.addEventListener('transitionend', onTransitionEnd);
12151
- }
12152
-
12153
- if (typeof document !== 'undefined') {
12154
- if (document.readyState !== 'loading') {
12155
- $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$setupGlobalEvents();
12156
- } else {
12157
- document.addEventListener('DOMContentLoaded', $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$setupGlobalEvents);
12158
- }
12159
- }
12160
-
12161
- function runAfterTransition(fn) {
12162
- // Wait one frame to see if an animation starts, e.g. a transition on mount.
12163
- requestAnimationFrame(() => {
12164
- // If no transitions are running, call the function immediately.
12165
- // Otherwise, add it to a list of callbacks to run at the end of the animation.
12166
- if ($b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionsByElement.size === 0) {
12167
- fn();
12168
- } else {
12169
- $b3e8d5c5f32fa26afa6df1b81f09b6b8$var$transitionCallbacks.add(fn);
12170
- }
12171
- });
12172
- }
12173
- function useGlobalListeners() {
12174
- let globalListeners = useRef(new Map());
12175
- let addGlobalListener = useCallback((eventTarget, type, listener, options) => {
12176
- globalListeners.current.set(listener, {
12177
- type,
12178
- eventTarget,
12179
- options
12180
- });
12181
- eventTarget.addEventListener(type, listener, options);
12182
- }, []);
12183
- let removeGlobalListener = useCallback((eventTarget, type, listener, options) => {
12184
- eventTarget.removeEventListener(type, listener, options);
12185
- globalListeners.current.delete(listener);
12186
- }, []);
12187
- let removeAllGlobalListeners = useCallback(() => {
12188
- globalListeners.current.forEach((value, key) => {
12189
- removeGlobalListener(value.eventTarget, value.type, key, value.options);
12190
- });
12191
- }, [removeGlobalListener]); // eslint-disable-next-line arrow-body-style
12192
-
12193
- useEffect(() => {
12194
- return removeAllGlobalListeners;
12195
- }, [removeAllGlobalListeners]);
12196
- return {
12197
- addGlobalListener,
12198
- removeGlobalListener,
12199
- removeAllGlobalListeners
12200
- };
12201
- }
12202
-
12203
- /**
12204
- * Merges aria-label and aria-labelledby into aria-labelledby when both exist.
12205
- * @param props - Aria label props.
12206
- * @param defaultLabel - Default value for aria-label when not present.
12207
- */
12208
- function useLabels(props, defaultLabel) {
12209
- let {
12210
- id,
12211
- 'aria-label': label,
12212
- 'aria-labelledby': labelledBy
12213
- } = props; // If there is both an aria-label and aria-labelledby,
12214
- // combine them by pointing to the element itself.
12215
-
12216
- id = useId(id);
12217
-
12218
- if (labelledBy && label) {
12219
- let ids = new Set([...labelledBy.trim().split(/\s+/), id]);
12220
- labelledBy = [...ids].join(' ');
12221
- } else if (labelledBy) {
12222
- labelledBy = labelledBy.trim().split(/\s+/).join(' ');
12223
- } // If no labels are provided, use the default
12224
-
12225
-
12226
- if (!label && !labelledBy && defaultLabel) {
12227
- label = defaultLabel;
12228
- }
12229
-
12230
- return {
12231
- id,
12232
- 'aria-label': label,
12233
- 'aria-labelledby': labelledBy
12234
- };
12235
- }
12236
- // Syncs ref from context with ref passed to hook
12237
- function useSyncRef(context, ref) {
12238
- useLayoutEffect(() => {
12239
- if (context && context.ref && ref) {
12240
- context.ref.current = ref.current;
12241
- return () => {
12242
- context.ref.current = null;
12243
- };
12244
- }
12245
- }, [context, ref]);
12246
- }
12247
-
12248
- function $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(re) {
12249
- return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : false;
12250
- }
12251
-
12252
- function isMac() {
12253
- return $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(/^Mac/);
12254
- }
12255
-
12256
- function _objectWithoutPropertiesLoose(source, excluded) {
12257
- if (source == null) return {};
12258
- var target = {};
12259
- var sourceKeys = Object.keys(source);
12260
- var key, i;
12261
-
12262
- for (i = 0; i < sourceKeys.length; i++) {
12263
- key = sourceKeys[i];
12264
- if (excluded.indexOf(key) >= 0) continue;
12265
- target[key] = source[key];
12266
- }
12267
-
12268
- return target;
12269
- }
12270
-
12271
- let $e17c9db826984f8ab8e5d837bf0b8$var$state = 'default';
12272
- let $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect = '';
12273
-
12274
- function $e17c9db826984f8ab8e5d837bf0b8$export$disableTextSelection() {
12275
- if ($e17c9db826984f8ab8e5d837bf0b8$var$state === 'default') {
12276
- $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect = document.documentElement.style.webkitUserSelect;
12277
- document.documentElement.style.webkitUserSelect = 'none';
12278
- }
12279
-
12280
- $e17c9db826984f8ab8e5d837bf0b8$var$state = 'disabled';
12281
- }
12282
-
12283
- function $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection() {
12284
- // If the state is already default, there's nothing to do.
12285
- // If it is restoring, then there's no need to queue a second restore.
12286
- if ($e17c9db826984f8ab8e5d837bf0b8$var$state !== 'disabled') {
12287
- return;
12288
- }
12289
-
12290
- $e17c9db826984f8ab8e5d837bf0b8$var$state = 'restoring'; // There appears to be a delay on iOS where selection still might occur
12291
- // after pointer up, so wait a bit before removing user-select.
12292
-
12293
- setTimeout(() => {
12294
- // Wait for any CSS transitions to complete so we don't recompute style
12295
- // for the whole page in the middle of the animation and cause jank.
12296
- runAfterTransition(() => {
12297
- // Avoid race conditions
12298
- if ($e17c9db826984f8ab8e5d837bf0b8$var$state === 'restoring') {
12299
- if (document.documentElement.style.webkitUserSelect === 'none') {
12300
- document.documentElement.style.webkitUserSelect = $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect || '';
12301
- }
12302
-
12303
- $e17c9db826984f8ab8e5d837bf0b8$var$savedUserSelect = '';
12304
- $e17c9db826984f8ab8e5d837bf0b8$var$state = 'default';
12305
- }
12306
- });
12307
- }, 300);
12308
- }
12309
-
12310
- /*
12311
- * Copyright 2020 Adobe. All rights reserved.
12312
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12313
- * you may not use this file except in compliance with the License. You may obtain a copy
12314
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12315
- *
12316
- * Unless required by applicable law or agreed to in writing, software distributed under
12317
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12318
- * OF ANY KIND, either express or implied. See the License for the specific language
12319
- * governing permissions and limitations under the License.
12320
- */
12321
- // Original licensing for the following method can be found in the
12322
- // NOTICE file in the root directory of this source tree.
12323
- // See https://github.com/facebook/react/blob/3c713d513195a53788b3f8bb4b70279d68b15bcc/packages/react-interactions/events/src/dom/shared/index.js#L74-L87
12324
- // Keyboards, Assistive Technologies, and element.click() all produce a "virtual"
12325
- // click event. This is a method of inferring such clicks. Every browser except
12326
- // IE 11 only sets a zero value of "detail" for click events that are "virtual".
12327
- // However, IE 11 uses a zero value for all click events. For IE 11 we rely on
12328
- // the quirk that it produces click events that are of type PointerEvent, and
12329
- // where only the "virtual" click lacks a pointerType field.
12330
- function $f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(event) {
12331
- // JAWS/NVDA with Firefox.
12332
- if (event.mozInputSource === 0 && event.isTrusted) {
12333
- return true;
12334
- }
12335
-
12336
- return event.detail === 0 && !event.pointerType;
12337
- }
12338
-
12339
- const $a3ff51240de6f955c79cf17a88e349$export$PressResponderContext = /*#__PURE__*/React__default.createContext(null);
12340
-
12341
- $a3ff51240de6f955c79cf17a88e349$export$PressResponderContext.displayName = 'PressResponderContext';
12342
-
12343
- function $ffc54430b1dbeee65879852feaaff07d$var$usePressResponderContext(props) {
12344
- // Consume context from <PressResponder> and merge with props.
12345
- let context = useContext($a3ff51240de6f955c79cf17a88e349$export$PressResponderContext);
12346
-
12347
- if (context) {
12348
- let {
12349
- register
12350
- } = context,
12351
- contextProps = _objectWithoutPropertiesLoose(context, ["register"]);
12352
-
12353
- props = mergeProps(contextProps, props);
12354
- register();
12355
- }
12356
-
12357
- useSyncRef(context, props.ref);
12358
- return props;
12359
- }
12360
- /**
12361
- * Handles press interactions across mouse, touch, keyboard, and screen readers.
12362
- * It normalizes behavior across browsers and platforms, and handles many nuances
12363
- * of dealing with pointer and keyboard events.
12364
- */
12365
-
12366
-
12367
- function usePress(props) {
12368
- let _usePressResponderCon = $ffc54430b1dbeee65879852feaaff07d$var$usePressResponderContext(props),
12369
- {
12370
- onPress,
12371
- onPressChange,
12372
- onPressStart,
12373
- onPressEnd,
12374
- onPressUp,
12375
- isDisabled,
12376
- isPressed: isPressedProp,
12377
- preventFocusOnPress
12378
- } = _usePressResponderCon,
12379
- domProps = _objectWithoutPropertiesLoose(_usePressResponderCon, ["onPress", "onPressChange", "onPressStart", "onPressEnd", "onPressUp", "isDisabled", "isPressed", "preventFocusOnPress", "ref"]);
12380
-
12381
- let propsRef = useRef(null);
12382
- propsRef.current = {
12383
- onPress,
12384
- onPressChange,
12385
- onPressStart,
12386
- onPressEnd,
12387
- onPressUp,
12388
- isDisabled
12389
- };
12390
- let [isPressed, setPressed] = useState(false);
12391
- let ref = useRef({
12392
- isPressed: false,
12393
- ignoreEmulatedMouseEvents: false,
12394
- ignoreClickAfterPress: false,
12395
- didFirePressStart: false,
12396
- activePointerId: null,
12397
- target: null,
12398
- isOverTarget: false,
12399
- pointerType: null
12400
- });
12401
- let {
12402
- addGlobalListener,
12403
- removeAllGlobalListeners
12404
- } = useGlobalListeners();
12405
- let pressProps = useMemo(() => {
12406
- let state = ref.current;
12407
-
12408
- let triggerPressStart = (originalEvent, pointerType) => {
12409
- let {
12410
- onPressStart,
12411
- onPressChange,
12412
- isDisabled
12413
- } = propsRef.current;
12414
-
12415
- if (isDisabled || state.didFirePressStart) {
12416
- return;
12417
- }
12418
-
12419
- if (onPressStart) {
12420
- onPressStart({
12421
- type: 'pressstart',
12422
- pointerType,
12423
- target: originalEvent.currentTarget,
12424
- shiftKey: originalEvent.shiftKey,
12425
- metaKey: originalEvent.metaKey,
12426
- ctrlKey: originalEvent.ctrlKey
12427
- });
12428
- }
12429
-
12430
- if (onPressChange) {
12431
- onPressChange(true);
12432
- }
12433
-
12434
- state.didFirePressStart = true;
12435
- setPressed(true);
12436
- };
12437
-
12438
- let triggerPressEnd = function triggerPressEnd(originalEvent, pointerType, wasPressed) {
12439
- if (wasPressed === void 0) {
12440
- wasPressed = true;
12441
- }
12442
-
12443
- let {
12444
- onPressEnd,
12445
- onPressChange,
12446
- onPress,
12447
- isDisabled
12448
- } = propsRef.current;
12449
-
12450
- if (!state.didFirePressStart) {
12451
- return;
12452
- }
12453
-
12454
- state.ignoreClickAfterPress = true;
12455
- state.didFirePressStart = false;
12456
-
12457
- if (onPressEnd) {
12458
- onPressEnd({
12459
- type: 'pressend',
12460
- pointerType,
12461
- target: originalEvent.currentTarget,
12462
- shiftKey: originalEvent.shiftKey,
12463
- metaKey: originalEvent.metaKey,
12464
- ctrlKey: originalEvent.ctrlKey
12465
- });
12466
- }
12467
-
12468
- if (onPressChange) {
12469
- onPressChange(false);
12470
- }
12471
-
12472
- setPressed(false);
12473
-
12474
- if (onPress && wasPressed && !isDisabled) {
12475
- onPress({
12476
- type: 'press',
12477
- pointerType,
12478
- target: originalEvent.currentTarget,
12479
- shiftKey: originalEvent.shiftKey,
12480
- metaKey: originalEvent.metaKey,
12481
- ctrlKey: originalEvent.ctrlKey
12482
- });
12483
- }
12484
- };
12485
-
12486
- let triggerPressUp = (originalEvent, pointerType) => {
12487
- let {
12488
- onPressUp,
12489
- isDisabled
12490
- } = propsRef.current;
12491
-
12492
- if (isDisabled) {
12493
- return;
12494
- }
12495
-
12496
- if (onPressUp) {
12497
- onPressUp({
12498
- type: 'pressup',
12499
- pointerType,
12500
- target: originalEvent.currentTarget,
12501
- shiftKey: originalEvent.shiftKey,
12502
- metaKey: originalEvent.metaKey,
12503
- ctrlKey: originalEvent.ctrlKey
12504
- });
12505
- }
12506
- };
12507
-
12508
- let cancel = e => {
12509
- if (state.isPressed) {
12510
- if (state.isOverTarget) {
12511
- triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12512
- }
12513
-
12514
- state.isPressed = false;
12515
- state.isOverTarget = false;
12516
- state.activePointerId = null;
12517
- state.pointerType = null;
12518
- removeAllGlobalListeners();
12519
- $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12520
- }
12521
- };
12522
-
12523
- let pressProps = {
12524
- onKeyDown(e) {
12525
- if ($ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(e.nativeEvent) && e.currentTarget.contains(e.target)) {
12526
- e.preventDefault();
12527
- e.stopPropagation(); // If the event is repeating, it may have started on a different element
12528
- // after which focus moved to the current element. Ignore these events and
12529
- // only handle the first key down event.
12530
-
12531
- if (!state.isPressed && !e.repeat) {
12532
- state.target = e.currentTarget;
12533
- state.isPressed = true;
12534
- triggerPressStart(e, 'keyboard'); // Focus may move before the key up event, so register the event on the document
12535
- // instead of the same element where the key down event occurred.
12536
-
12537
- addGlobalListener(document, 'keyup', onKeyUp, false);
12538
- }
12539
- }
12540
- },
12541
-
12542
- onKeyUp(e) {
12543
- if ($ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(e.nativeEvent) && !e.repeat && e.currentTarget.contains(e.target)) {
12544
- triggerPressUp($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), 'keyboard');
12545
- }
12546
- },
12547
-
12548
- onClick(e) {
12549
- if (e && !e.currentTarget.contains(e.target)) {
12550
- return;
12551
- }
12552
-
12553
- if (e && e.button === 0) {
12554
- e.stopPropagation();
12555
-
12556
- if (isDisabled) {
12557
- e.preventDefault();
12558
- } // If triggered from a screen reader or by using element.click(),
12559
- // trigger as if it were a keyboard click.
12560
-
12561
-
12562
- if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && $f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(e.nativeEvent)) {
12563
- // Ensure the element receives focus (VoiceOver on iOS does not do this)
12564
- if (!isDisabled && !preventFocusOnPress) {
12565
- focusWithoutScrolling(e.currentTarget);
12566
- }
12567
-
12568
- triggerPressStart(e, 'virtual');
12569
- triggerPressUp(e, 'virtual');
12570
- triggerPressEnd(e, 'virtual');
12571
- }
12572
-
12573
- state.ignoreEmulatedMouseEvents = false;
12574
- state.ignoreClickAfterPress = false;
12575
- }
12576
- }
12577
-
12578
- };
12579
-
12580
- let onKeyUp = e => {
12581
- if (state.isPressed && $ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(e)) {
12582
- e.preventDefault();
12583
- e.stopPropagation();
12584
- state.isPressed = false;
12585
- triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), 'keyboard', e.target === state.target);
12586
- removeAllGlobalListeners(); // If the target is a link, trigger the click method to open the URL,
12587
- // but defer triggering pressEnd until onClick event handler.
12588
-
12589
- if (e.target === state.target && $ffc54430b1dbeee65879852feaaff07d$var$isHTMLAnchorLink(state.target) || state.target.getAttribute('role') === 'link') {
12590
- state.target.click();
12591
- }
12592
- }
12593
- };
12594
-
12595
- if (typeof PointerEvent !== 'undefined') {
12596
- pressProps.onPointerDown = e => {
12597
- // Only handle left clicks, and ignore events that bubbled through portals.
12598
- if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
12599
- return;
12600
- } // Due to browser inconsistencies, especially on mobile browsers, we prevent
12601
- // default on pointer down and handle focusing the pressable element ourselves.
12602
-
12603
-
12604
- if ($ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(e.target)) {
12605
- e.preventDefault();
12606
- } // iOS safari fires pointer events from VoiceOver (but only when outside an iframe...)
12607
- // https://bugs.webkit.org/show_bug.cgi?id=222627
12608
-
12609
-
12610
- state.pointerType = $ffc54430b1dbeee65879852feaaff07d$var$isVirtualPointerEvent(e.nativeEvent) ? 'virtual' : e.pointerType;
12611
- e.stopPropagation();
12612
-
12613
- if (!state.isPressed) {
12614
- state.isPressed = true;
12615
- state.isOverTarget = true;
12616
- state.activePointerId = e.pointerId;
12617
- state.target = e.currentTarget;
12618
-
12619
- if (!isDisabled && !preventFocusOnPress) {
12620
- focusWithoutScrolling(e.currentTarget);
12621
- }
12622
-
12623
- $e17c9db826984f8ab8e5d837bf0b8$export$disableTextSelection();
12624
- triggerPressStart(e, state.pointerType);
12625
- addGlobalListener(document, 'pointermove', onPointerMove, false);
12626
- addGlobalListener(document, 'pointerup', onPointerUp, false);
12627
- addGlobalListener(document, 'pointercancel', onPointerCancel, false);
12628
- }
12629
- };
12630
-
12631
- pressProps.onMouseDown = e => {
12632
- if (!e.currentTarget.contains(e.target)) {
12633
- return;
12634
- }
12635
-
12636
- if (e.button === 0) {
12637
- // Chrome and Firefox on touch Windows devices require mouse down events
12638
- // to be canceled in addition to pointer events, or an extra asynchronous
12639
- // focus event will be fired.
12640
- if ($ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(e.target)) {
12641
- e.preventDefault();
12642
- }
12643
-
12644
- e.stopPropagation();
12645
- }
12646
- };
12647
-
12648
- pressProps.onPointerUp = e => {
12649
- if (!e.currentTarget.contains(e.target)) {
12650
- return;
12651
- } // Only handle left clicks
12652
- // Safari on iOS sometimes fires pointerup events, even
12653
- // when the touch isn't over the target, so double check.
12654
-
12655
-
12656
- if (e.button === 0 && $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, e.currentTarget)) {
12657
- triggerPressUp(e, state.pointerType);
12658
- }
12659
- }; // Safari on iOS < 13.2 does not implement pointerenter/pointerleave events correctly.
12660
- // Use pointer move events instead to implement our own hit testing.
12661
- // See https://bugs.webkit.org/show_bug.cgi?id=199803
12662
-
12663
-
12664
- let onPointerMove = e => {
12665
- if (e.pointerId !== state.activePointerId) {
12666
- return;
12667
- }
12668
-
12669
- if ($ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, state.target)) {
12670
- if (!state.isOverTarget) {
12671
- state.isOverTarget = true;
12672
- triggerPressStart($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType);
12673
- }
12674
- } else if (state.isOverTarget) {
12675
- state.isOverTarget = false;
12676
- triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12677
- }
12678
- };
12679
-
12680
- let onPointerUp = e => {
12681
- if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0) {
12682
- if ($ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, state.target)) {
12683
- triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType);
12684
- } else if (state.isOverTarget) {
12685
- triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12686
- }
12687
-
12688
- state.isPressed = false;
12689
- state.isOverTarget = false;
12690
- state.activePointerId = null;
12691
- state.pointerType = null;
12692
- removeAllGlobalListeners();
12693
- $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12694
- }
12695
- };
12696
-
12697
- let onPointerCancel = e => {
12698
- cancel(e);
12699
- };
12700
-
12701
- pressProps.onDragStart = e => {
12702
- if (!e.currentTarget.contains(e.target)) {
12703
- return;
12704
- } // Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.
12705
-
12706
-
12707
- cancel(e);
12708
- };
12709
- } else {
12710
- pressProps.onMouseDown = e => {
12711
- // Only handle left clicks
12712
- if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
12713
- return;
12714
- } // Due to browser inconsistencies, especially on mobile browsers, we prevent
12715
- // default on mouse down and handle focusing the pressable element ourselves.
12716
-
12717
-
12718
- if ($ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(e.target)) {
12719
- e.preventDefault();
12720
- }
12721
-
12722
- e.stopPropagation();
12723
-
12724
- if (state.ignoreEmulatedMouseEvents) {
12725
- return;
12726
- }
12727
-
12728
- state.isPressed = true;
12729
- state.isOverTarget = true;
12730
- state.target = e.currentTarget;
12731
- state.pointerType = $f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(e.nativeEvent) ? 'virtual' : 'mouse';
12732
-
12733
- if (!isDisabled && !preventFocusOnPress) {
12734
- focusWithoutScrolling(e.currentTarget);
12735
- }
12736
-
12737
- triggerPressStart(e, state.pointerType);
12738
- addGlobalListener(document, 'mouseup', onMouseUp, false);
12739
- };
12740
-
12741
- pressProps.onMouseEnter = e => {
12742
- if (!e.currentTarget.contains(e.target)) {
12743
- return;
12744
- }
12745
-
12746
- e.stopPropagation();
12747
-
12748
- if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
12749
- state.isOverTarget = true;
12750
- triggerPressStart(e, state.pointerType);
12751
- }
12752
- };
12753
-
12754
- pressProps.onMouseLeave = e => {
12755
- if (!e.currentTarget.contains(e.target)) {
12756
- return;
12757
- }
12758
-
12759
- e.stopPropagation();
12760
-
12761
- if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
12762
- state.isOverTarget = false;
12763
- triggerPressEnd(e, state.pointerType, false);
12764
- }
12765
- };
12766
-
12767
- pressProps.onMouseUp = e => {
12768
- if (!e.currentTarget.contains(e.target)) {
12769
- return;
12770
- }
12771
-
12772
- if (!state.ignoreEmulatedMouseEvents && e.button === 0) {
12773
- triggerPressUp(e, state.pointerType);
12774
- }
12775
- };
12776
-
12777
- let onMouseUp = e => {
12778
- // Only handle left clicks
12779
- if (e.button !== 0) {
12780
- return;
12781
- }
12782
-
12783
- state.isPressed = false;
12784
- removeAllGlobalListeners();
12785
-
12786
- if (state.ignoreEmulatedMouseEvents) {
12787
- state.ignoreEmulatedMouseEvents = false;
12788
- return;
12789
- }
12790
-
12791
- if ($ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(e, state.target)) {
12792
- triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType);
12793
- } else if (state.isOverTarget) {
12794
- triggerPressEnd($ffc54430b1dbeee65879852feaaff07d$var$createEvent(state.target, e), state.pointerType, false);
12795
- }
12796
-
12797
- state.isOverTarget = false;
12798
- };
12799
-
12800
- pressProps.onTouchStart = e => {
12801
- if (!e.currentTarget.contains(e.target)) {
12802
- return;
12803
- }
12804
-
12805
- e.stopPropagation();
12806
- let touch = $ffc54430b1dbeee65879852feaaff07d$var$getTouchFromEvent(e.nativeEvent);
12807
-
12808
- if (!touch) {
12809
- return;
12810
- }
12811
-
12812
- state.activePointerId = touch.identifier;
12813
- state.ignoreEmulatedMouseEvents = true;
12814
- state.isOverTarget = true;
12815
- state.isPressed = true;
12816
- state.target = e.currentTarget;
12817
- state.pointerType = 'touch'; // Due to browser inconsistencies, especially on mobile browsers, we prevent default
12818
- // on the emulated mouse event and handle focusing the pressable element ourselves.
12819
-
12820
- if (!isDisabled && !preventFocusOnPress) {
12821
- focusWithoutScrolling(e.currentTarget);
12822
- }
12823
-
12824
- $e17c9db826984f8ab8e5d837bf0b8$export$disableTextSelection();
12825
- triggerPressStart(e, state.pointerType);
12826
- addGlobalListener(window, 'scroll', onScroll, true);
12827
- };
12828
-
12829
- pressProps.onTouchMove = e => {
12830
- if (!e.currentTarget.contains(e.target)) {
12831
- return;
12832
- }
12833
-
12834
- e.stopPropagation();
12835
-
12836
- if (!state.isPressed) {
12837
- return;
12838
- }
12839
-
12840
- let touch = $ffc54430b1dbeee65879852feaaff07d$var$getTouchById(e.nativeEvent, state.activePointerId);
12841
-
12842
- if (touch && $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(touch, e.currentTarget)) {
12843
- if (!state.isOverTarget) {
12844
- state.isOverTarget = true;
12845
- triggerPressStart(e, state.pointerType);
12846
- }
12847
- } else if (state.isOverTarget) {
12848
- state.isOverTarget = false;
12849
- triggerPressEnd(e, state.pointerType, false);
12850
- }
12851
- };
12852
-
12853
- pressProps.onTouchEnd = e => {
12854
- if (!e.currentTarget.contains(e.target)) {
12855
- return;
12856
- }
12857
-
12858
- e.stopPropagation();
12859
-
12860
- if (!state.isPressed) {
12861
- return;
12862
- }
12863
-
12864
- let touch = $ffc54430b1dbeee65879852feaaff07d$var$getTouchById(e.nativeEvent, state.activePointerId);
12865
-
12866
- if (touch && $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(touch, e.currentTarget)) {
12867
- triggerPressUp(e, state.pointerType);
12868
- triggerPressEnd(e, state.pointerType);
12869
- } else if (state.isOverTarget) {
12870
- triggerPressEnd(e, state.pointerType, false);
12871
- }
12872
-
12873
- state.isPressed = false;
12874
- state.activePointerId = null;
12875
- state.isOverTarget = false;
12876
- state.ignoreEmulatedMouseEvents = true;
12877
- $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12878
- removeAllGlobalListeners();
12879
- };
12880
-
12881
- pressProps.onTouchCancel = e => {
12882
- if (!e.currentTarget.contains(e.target)) {
12883
- return;
12884
- }
12885
-
12886
- e.stopPropagation();
12887
-
12888
- if (state.isPressed) {
12889
- cancel(e);
12890
- }
12891
- };
12892
-
12893
- let onScroll = e => {
12894
- if (state.isPressed && e.target.contains(state.target)) {
12895
- cancel({
12896
- currentTarget: state.target,
12897
- shiftKey: false,
12898
- ctrlKey: false,
12899
- metaKey: false
12900
- });
12901
- }
12902
- };
12903
-
12904
- pressProps.onDragStart = e => {
12905
- if (!e.currentTarget.contains(e.target)) {
12906
- return;
12907
- }
12908
-
12909
- cancel(e);
12910
- };
12911
- }
12912
-
12913
- return pressProps;
12914
- }, [addGlobalListener, isDisabled, preventFocusOnPress, removeAllGlobalListeners]); // Remove user-select: none in case component unmounts immediately after pressStart
12915
- // eslint-disable-next-line arrow-body-style
12916
-
12917
- useEffect(() => {
12918
- return () => $e17c9db826984f8ab8e5d837bf0b8$export$restoreTextSelection();
12919
- }, []);
12920
- return {
12921
- isPressed: isPressedProp || isPressed,
12922
- pressProps: mergeProps(domProps, pressProps)
12923
- };
12924
- }
12925
-
12926
- function $ffc54430b1dbeee65879852feaaff07d$var$isHTMLAnchorLink(target) {
12927
- return target.tagName === 'A' && target.hasAttribute('href');
12928
- }
12929
-
12930
- function $ffc54430b1dbeee65879852feaaff07d$var$isValidKeyboardEvent(event) {
12931
- const {
12932
- key,
12933
- target
12934
- } = event;
12935
- const element = target;
12936
- const {
12937
- tagName,
12938
- isContentEditable
12939
- } = element;
12940
- const role = element.getAttribute('role'); // Accessibility for keyboards. Space and Enter only.
12941
- // "Spacebar" is for IE 11
12942
-
12943
- return (key === 'Enter' || key === ' ' || key === 'Spacebar') && tagName !== 'INPUT' && tagName !== 'TEXTAREA' && isContentEditable !== true && ( // A link with a valid href should be handled natively,
12944
- // unless it also has role='button' and was triggered using Space.
12945
- !$ffc54430b1dbeee65879852feaaff07d$var$isHTMLAnchorLink(element) || role === 'button' && key !== 'Enter') && // An element with role='link' should only trigger with Enter key
12946
- !(role === 'link' && key !== 'Enter');
12947
- }
12948
-
12949
- function $ffc54430b1dbeee65879852feaaff07d$var$getTouchFromEvent(event) {
12950
- const {
12951
- targetTouches
12952
- } = event;
12953
-
12954
- if (targetTouches.length > 0) {
12955
- return targetTouches[0];
12956
- }
12957
-
12958
- return null;
12959
- }
12960
-
12961
- function $ffc54430b1dbeee65879852feaaff07d$var$getTouchById(event, pointerId) {
12962
- const changedTouches = event.changedTouches;
12963
-
12964
- for (let i = 0; i < changedTouches.length; i++) {
12965
- const touch = changedTouches[i];
12966
-
12967
- if (touch.identifier === pointerId) {
12968
- return touch;
12969
- }
12970
- }
12971
-
12972
- return null;
12973
- }
12974
-
12975
- function $ffc54430b1dbeee65879852feaaff07d$var$createEvent(target, e) {
12976
- return {
12977
- currentTarget: target,
12978
- shiftKey: e.shiftKey,
12979
- ctrlKey: e.ctrlKey,
12980
- metaKey: e.metaKey
12981
- };
12982
- }
12983
-
12984
- function $ffc54430b1dbeee65879852feaaff07d$var$getPointClientRect(point) {
12985
- let offsetX = point.width / 2 || point.radiusX || 0;
12986
- let offsetY = point.height / 2 || point.radiusY || 0;
12987
- return {
12988
- top: point.clientY - offsetY,
12989
- right: point.clientX + offsetX,
12990
- bottom: point.clientY + offsetY,
12991
- left: point.clientX - offsetX
12992
- };
12993
- }
12994
-
12995
- function $ffc54430b1dbeee65879852feaaff07d$var$areRectanglesOverlapping(a, b) {
12996
- // check if they cannot overlap on x axis
12997
- if (a.left > b.right || b.left > a.right) {
12998
- return false;
12999
- } // check if they cannot overlap on y axis
13000
-
13001
-
13002
- if (a.top > b.bottom || b.top > a.bottom) {
13003
- return false;
13004
- }
13005
-
13006
- return true;
13007
- }
13008
-
13009
- function $ffc54430b1dbeee65879852feaaff07d$var$isOverTarget(point, target) {
13010
- let rect = target.getBoundingClientRect();
13011
- let pointRect = $ffc54430b1dbeee65879852feaaff07d$var$getPointClientRect(point);
13012
- return $ffc54430b1dbeee65879852feaaff07d$var$areRectanglesOverlapping(rect, pointRect);
13013
- }
13014
-
13015
- function $ffc54430b1dbeee65879852feaaff07d$var$shouldPreventDefault(target) {
13016
- // We cannot prevent default if the target is inside a draggable element.
13017
- return !target.closest('[draggable="true"]');
13018
- }
13019
-
13020
- function $ffc54430b1dbeee65879852feaaff07d$var$isVirtualPointerEvent(event) {
13021
- // If the pointer size is zero, then we assume it's from a screen reader.
13022
- return event.width === 0 && event.height === 0;
13023
- }
13024
- let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = null;
13025
- let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$changeHandlers = new Set();
13026
- let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasSetupGlobalListeners = false;
13027
- let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = false;
13028
- let $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently = false; // Only Tab or Esc keys will make focus visible on text input elements
13029
-
13030
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers(modality, e) {
13031
- for (let handler of $d01f69bb2ab5f70dfd0005370a2a2cbc$var$changeHandlers) {
13032
- handler(modality, e);
13033
- }
13034
- }
13035
- /**
13036
- * Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
13037
- */
13038
-
13039
-
13040
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$isValidKey(e) {
13041
- // Control and Shift keys trigger when navigating back to the tab with keyboard.
13042
- return !(e.metaKey || !isMac() && e.altKey || e.ctrlKey || e.type === 'keyup' && (e.key === 'Control' || e.key === 'Shift'));
13043
- }
13044
-
13045
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleKeyboardEvent(e) {
13046
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
13047
-
13048
- if ($d01f69bb2ab5f70dfd0005370a2a2cbc$var$isValidKey(e)) {
13049
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'keyboard';
13050
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers('keyboard', e);
13051
- }
13052
- }
13053
-
13054
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent(e) {
13055
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'pointer';
13056
-
13057
- if (e.type === 'mousedown' || e.type === 'pointerdown') {
13058
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
13059
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers('pointer', e);
13060
- }
13061
- }
13062
-
13063
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleClickEvent(e) {
13064
- if ($f67ef9f1b8ed09b4b00fd0840cd8b94b$export$isVirtualClick(e)) {
13065
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
13066
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'virtual';
13067
- }
13068
- }
13069
-
13070
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleFocusEvent(e) {
13071
- // Firefox fires two extra focus events when the user first clicks into an iframe:
13072
- // first on the window, then on the document. We ignore these events so they don't
13073
- // cause keyboard focus rings to appear.
13074
- if (e.target === window || e.target === document) {
13075
- return;
13076
- } // If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
13077
- // This occurs, for example, when navigating a form with the next/previous buttons on iOS.
13078
-
13079
-
13080
- if (!$d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus && !$d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently) {
13081
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality = 'virtual';
13082
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$triggerChangeHandlers('virtual', e);
13083
- }
13084
-
13085
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = false;
13086
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently = false;
13087
- }
13088
-
13089
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleWindowBlur() {
13090
- // When the window is blurred, reset state. This is necessary when tabbing out of the window,
13091
- // for example, since a subsequent focus event won't be fired.
13092
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = false;
13093
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasBlurredWindowRecently = true;
13094
- }
13095
- /**
13096
- * Setup global event listeners to control when keyboard focus style should be visible.
13097
- */
13098
-
13099
-
13100
- function $d01f69bb2ab5f70dfd0005370a2a2cbc$var$setupGlobalFocusEvents() {
13101
- if (typeof window === 'undefined' || $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasSetupGlobalListeners) {
13102
- return;
13103
- } // Programmatic focus() calls shouldn't affect the current input modality.
13104
- // However, we need to detect other cases when a focus event occurs without
13105
- // a preceding user event (e.g. screen reader focus). Overriding the focus
13106
- // method on HTMLElement.prototype is a bit hacky, but works.
13107
-
13108
-
13109
- let focus = HTMLElement.prototype.focus;
13110
-
13111
- HTMLElement.prototype.focus = function () {
13112
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
13113
- focus.apply(this, arguments);
13114
- };
13115
-
13116
- document.addEventListener('keydown', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleKeyboardEvent, true);
13117
- document.addEventListener('keyup', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleKeyboardEvent, true);
13118
- document.addEventListener('click', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleClickEvent, true); // Register focus events on the window so they are sure to happen
13119
- // before React's event listeners (registered on the document).
13120
-
13121
- window.addEventListener('focus', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleFocusEvent, true);
13122
- window.addEventListener('blur', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handleWindowBlur, false);
13123
-
13124
- if (typeof PointerEvent !== 'undefined') {
13125
- document.addEventListener('pointerdown', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
13126
- document.addEventListener('pointermove', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
13127
- document.addEventListener('pointerup', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
13128
- } else {
13129
- document.addEventListener('mousedown', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
13130
- document.addEventListener('mousemove', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
13131
- document.addEventListener('mouseup', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$handlePointerEvent, true);
13132
- }
13133
-
13134
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasSetupGlobalListeners = true;
13135
- }
13136
-
13137
- if (typeof document !== 'undefined') {
13138
- if (document.readyState !== 'loading') {
13139
- $d01f69bb2ab5f70dfd0005370a2a2cbc$var$setupGlobalFocusEvents();
13140
- } else {
13141
- document.addEventListener('DOMContentLoaded', $d01f69bb2ab5f70dfd0005370a2a2cbc$var$setupGlobalFocusEvents);
13142
- }
13143
- }
13144
- function getInteractionModality() {
13145
- return $d01f69bb2ab5f70dfd0005370a2a2cbc$var$currentModality;
13146
- }
13147
-
13148
- /**
13149
- * A utility function that focuses an element while avoiding undesired side effects such
13150
- * as page scrolling and screen reader issues with CSS transitions.
13151
- */
13152
- function focusSafely(element) {
13153
- // If the user is interacting with a virtual cursor, e.g. screen reader, then
13154
- // wait until after any animated transitions that are currently occurring on
13155
- // the page before shifting focus. This avoids issues with VoiceOver on iOS
13156
- // causing the page to scroll when moving focus if the element is transitioning
13157
- // from off the screen.
13158
- if (getInteractionModality() === 'virtual') {
13159
- let lastFocusedElement = document.activeElement;
13160
- runAfterTransition(() => {
13161
- // If focus did not move and the element is still in the document, focus it.
13162
- if (document.activeElement === lastFocusedElement && document.contains(element)) {
13163
- focusWithoutScrolling(element);
13164
- }
13165
- });
13166
- } else {
13167
- focusWithoutScrolling(element);
13168
- }
13169
- }
13170
-
13171
- /*
13172
- * Copyright 2021 Adobe. All rights reserved.
13173
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13174
- * you may not use this file except in compliance with the License. You may obtain a copy
13175
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13176
- *
13177
- * Unless required by applicable law or agreed to in writing, software distributed under
13178
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13179
- * OF ANY KIND, either express or implied. See the License for the specific language
13180
- * governing permissions and limitations under the License.
13181
- */
13182
- function $ee5e90cbb4a22466973155c14222fa1$var$isStyleVisible(element) {
13183
- if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) {
13184
- return false;
13185
- }
13186
-
13187
- let {
13188
- display,
13189
- visibility
13190
- } = element.style;
13191
- let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
13192
-
13193
- if (isVisible) {
13194
- const {
13195
- getComputedStyle
13196
- } = element.ownerDocument.defaultView;
13197
- let {
13198
- display: computedDisplay,
13199
- visibility: computedVisibility
13200
- } = getComputedStyle(element);
13201
- isVisible = computedDisplay !== 'none' && computedVisibility !== 'hidden' && computedVisibility !== 'collapse';
13202
- }
13203
-
13204
- return isVisible;
13205
- }
13206
-
13207
- function $ee5e90cbb4a22466973155c14222fa1$var$isAttributeVisible(element, childElement) {
13208
- return !element.hasAttribute('hidden') && (element.nodeName === 'DETAILS' && childElement && childElement.nodeName !== 'SUMMARY' ? element.hasAttribute('open') : true);
13209
- }
13210
- /**
13211
- * Adapted from https://github.com/testing-library/jest-dom and
13212
- * https://github.com/vuejs/vue-test-utils-next/.
13213
- * Licensed under the MIT License.
13214
- * @param element - Element to evaluate for display or visibility.
13215
- */
13216
-
13217
-
13218
- function $ee5e90cbb4a22466973155c14222fa1$export$isElementVisible(element, childElement) {
13219
- return element.nodeName !== '#comment' && $ee5e90cbb4a22466973155c14222fa1$var$isStyleVisible(element) && $ee5e90cbb4a22466973155c14222fa1$var$isAttributeVisible(element, childElement) && (!element.parentElement || $ee5e90cbb4a22466973155c14222fa1$export$isElementVisible(element.parentElement, element));
13220
- }
13221
-
13222
- 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]'];
13223
- const $c9e8f80f5bb1841844f54e4ad30b$var$FOCUSABLE_ELEMENT_SELECTOR = $c9e8f80f5bb1841844f54e4ad30b$var$focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';
13224
- $c9e8f80f5bb1841844f54e4ad30b$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
13225
- const $c9e8f80f5bb1841844f54e4ad30b$var$TABBABLE_ELEMENT_SELECTOR = $c9e8f80f5bb1841844f54e4ad30b$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
13226
-
13227
- const $c9e8f80f5bb1841844f54e4ad30b$var$focusScopeDataAttrNames = ['data-focus-scope-start', 'data-focus-scope-end'];
13228
-
13229
- function $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeDirectChild(scope) {
13230
- return $c9e8f80f5bb1841844f54e4ad30b$var$focusScopeDataAttrNames.some(name => scope.getAttribute(name) !== null);
13231
- }
13232
-
13233
- function $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeNestedChild(scope) {
13234
- return $c9e8f80f5bb1841844f54e4ad30b$var$focusScopeDataAttrNames.some(name => scope.querySelector("[" + name + "]"));
13235
- }
13236
-
13237
- function $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeInScope(scopes) {
13238
- return scopes.some(scope => $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeDirectChild(scope) || $c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeNestedChild(scope));
13239
- }
13240
-
13241
- function $c9e8f80f5bb1841844f54e4ad30b$var$isElementInScope(element, scope) {
13242
- return !$c9e8f80f5bb1841844f54e4ad30b$var$isFocusScopeInScope(scope) && scope.some(node => node.contains(element));
13243
- }
13244
- /**
13245
- * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}
13246
- * that matches all focusable/tabbable elements.
13247
- */
13248
-
13249
-
13250
- function getFocusableTreeWalker(root, opts, scope) {
13251
- let selector = opts != null && opts.tabbable ? $c9e8f80f5bb1841844f54e4ad30b$var$TABBABLE_ELEMENT_SELECTOR : $c9e8f80f5bb1841844f54e4ad30b$var$FOCUSABLE_ELEMENT_SELECTOR;
13252
- let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
13253
- acceptNode(node) {
13254
- var _opts$from;
13255
-
13256
- // Skip nodes inside the starting node.
13257
- if (opts != null && (_opts$from = opts.from) != null && _opts$from.contains(node)) {
13258
- return NodeFilter.FILTER_REJECT;
13259
- }
13260
-
13261
- if (node.matches(selector) && $ee5e90cbb4a22466973155c14222fa1$export$isElementVisible(node) && (!scope || $c9e8f80f5bb1841844f54e4ad30b$var$isElementInScope(node, scope))) {
13262
- return NodeFilter.FILTER_ACCEPT;
13263
- }
13264
-
13265
- return NodeFilter.FILTER_SKIP;
13266
- }
13267
-
13268
- });
13269
-
13270
- if (opts != null && opts.from) {
13271
- walker.currentNode = opts.from;
13272
- }
13273
-
13274
- return walker;
13275
- }
13276
-
13277
- function _extends$1() {
13278
- _extends$1 = Object.assign || function (target) {
13279
- for (var i = 1; i < arguments.length; i++) {
13280
- var source = arguments[i];
13281
-
13282
- for (var key in source) {
13283
- if (Object.prototype.hasOwnProperty.call(source, key)) {
13284
- target[key] = source[key];
13285
- }
13286
- }
13287
- }
13288
-
13289
- return target;
13290
- };
13291
-
13292
- return _extends$1.apply(this, arguments);
13293
- }
13294
-
13295
- /**
13296
- * Handles typeahead interactions with collections.
13297
- */
13298
- function useTypeSelect(options) {
13299
- let {
13300
- keyboardDelegate,
13301
- selectionManager,
13302
- onTypeSelect
13303
- } = options;
13304
- let state = useRef({
13305
- search: '',
13306
- timeout: null
13307
- }).current;
13308
-
13309
- let onKeyDown = e => {
13310
- let character = $c78d7fa5f7d5832f9b4f97b33a679865$var$getStringForKey(e.key);
13311
-
13312
- if (!character || e.ctrlKey || e.metaKey) {
13313
- return;
13314
- } // Do not propagate the Spacebar event if it's meant to be part of the search.
13315
- // When we time out, the search term becomes empty, hence the check on length.
13316
- // Trimming is to account for the case of pressing the Spacebar more than once,
13317
- // which should cycle through the selection/deselection of the focused item.
13318
-
13319
-
13320
- if (character === ' ' && state.search.trim().length > 0) {
13321
- e.preventDefault();
13322
-
13323
- if (!('continuePropagation' in e)) {
13324
- e.stopPropagation();
13325
- }
13326
- }
13327
-
13328
- state.search += character; // Use the delegate to find a key to focus.
13329
- // Prioritize items after the currently focused item, falling back to searching the whole list.
13330
-
13331
- let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey); // If no key found, search from the top.
13332
-
13333
- if (key == null) {
13334
- key = keyboardDelegate.getKeyForSearch(state.search);
13335
- }
13336
-
13337
- if (key != null) {
13338
- selectionManager.setFocusedKey(key);
13339
-
13340
- if (onTypeSelect) {
13341
- onTypeSelect(key);
13342
- }
13343
- }
13344
-
13345
- clearTimeout(state.timeout);
13346
- state.timeout = setTimeout(() => {
13347
- state.search = '';
13348
- }, 500);
13349
- };
13350
-
13351
- return {
13352
- typeSelectProps: {
13353
- // Using a capturing listener to catch the keydown event before
13354
- // other hooks in order to handle the Spacebar event.
13355
- onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
13356
- }
13357
- };
13358
- }
13359
-
13360
- function $c78d7fa5f7d5832f9b4f97b33a679865$var$getStringForKey(key) {
13361
- // If the key is of length 1, it is an ASCII value.
13362
- // Otherwise, if there are no ASCII characters in the key name,
13363
- // it is a Unicode character.
13364
- // See https://www.w3.org/TR/uievents-key/
13365
- if (key.length === 1 || !/^[A-Z]/i.test(key)) {
13366
- return key;
13367
- }
13368
-
13369
- return '';
13370
- }
13371
-
13372
- function $a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) {
13373
- if (isMac()) {
13374
- return e.metaKey;
13375
- }
13376
-
13377
- return e.ctrlKey;
13378
- }
13379
-
13380
- /**
13381
- * Handles interactions with selectable collections.
13382
- */
13383
- function useSelectableCollection(options) {
13384
- let {
13385
- selectionManager: manager,
13386
- keyboardDelegate: delegate,
13387
- ref,
13388
- autoFocus = false,
13389
- shouldFocusWrap = false,
13390
- disallowEmptySelection = false,
13391
- disallowSelectAll = false,
13392
- selectOnFocus = false,
13393
- disallowTypeAhead = false,
13394
- shouldUseVirtualFocus,
13395
- allowsTabNavigation = false
13396
- } = options;
13397
- let {
13398
- direction
13399
- } = useLocale();
13400
-
13401
- let onKeyDown = e => {
13402
- // Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
13403
- if (e.altKey && e.key === 'Tab') {
13404
- e.preventDefault();
13405
- } // Let child element (e.g. menu button) handle the event if the Alt key is pressed.
13406
- // Keyboard events bubble through portals. Don't handle keyboard events
13407
- // for elements outside the collection (e.g. menus).
13408
-
13409
-
13410
- if (e.altKey || !ref.current.contains(e.target)) {
13411
- return;
13412
- }
13413
-
13414
- const navigateToKey = (key, childFocus) => {
13415
- if (key != null) {
13416
- manager.setFocusedKey(key, childFocus);
13417
-
13418
- if (e.shiftKey && manager.selectionMode === 'multiple') {
13419
- manager.extendSelection(key);
13420
- } else if (selectOnFocus) {
13421
- manager.replaceSelection(key);
13422
- }
13423
- }
13424
- };
13425
-
13426
- switch (e.key) {
13427
- case 'ArrowDown':
13428
- {
13429
- if (delegate.getKeyBelow) {
13430
- e.preventDefault();
13431
- let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : delegate.getFirstKey == null ? void 0 : delegate.getFirstKey();
13432
-
13433
- if (nextKey == null && shouldFocusWrap) {
13434
- nextKey = delegate.getFirstKey == null ? void 0 : delegate.getFirstKey(manager.focusedKey);
13435
- }
13436
-
13437
- navigateToKey(nextKey);
13438
- }
13439
-
13440
- break;
13441
- }
13442
-
13443
- case 'ArrowUp':
13444
- {
13445
- if (delegate.getKeyAbove) {
13446
- e.preventDefault();
13447
- let nextKey = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : delegate.getLastKey == null ? void 0 : delegate.getLastKey();
13448
-
13449
- if (nextKey == null && shouldFocusWrap) {
13450
- nextKey = delegate.getLastKey == null ? void 0 : delegate.getLastKey(manager.focusedKey);
13451
- }
13452
-
13453
- navigateToKey(nextKey);
13454
- }
13455
-
13456
- break;
13457
- }
13458
-
13459
- case 'ArrowLeft':
13460
- {
13461
- if (delegate.getKeyLeftOf) {
13462
- e.preventDefault();
13463
- let nextKey = delegate.getKeyLeftOf(manager.focusedKey);
13464
- navigateToKey(nextKey, direction === 'rtl' ? 'first' : 'last');
13465
- }
13466
-
13467
- break;
13468
- }
13469
-
13470
- case 'ArrowRight':
13471
- {
13472
- if (delegate.getKeyRightOf) {
13473
- e.preventDefault();
13474
- let nextKey = delegate.getKeyRightOf(manager.focusedKey);
13475
- navigateToKey(nextKey, direction === 'rtl' ? 'last' : 'first');
13476
- }
13477
-
13478
- break;
13479
- }
13480
-
13481
- case 'Home':
13482
- if (delegate.getFirstKey) {
13483
- e.preventDefault();
13484
- let firstKey = delegate.getFirstKey(manager.focusedKey, $a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e));
13485
- manager.setFocusedKey(firstKey);
13486
-
13487
- if ($a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) && e.shiftKey && manager.selectionMode === 'multiple') {
13488
- manager.extendSelection(firstKey);
13489
- } else if (selectOnFocus) {
13490
- manager.replaceSelection(firstKey);
13491
- }
13492
- }
13493
-
13494
- break;
13495
-
13496
- case 'End':
13497
- if (delegate.getLastKey) {
13498
- e.preventDefault();
13499
- let lastKey = delegate.getLastKey(manager.focusedKey, $a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e));
13500
- manager.setFocusedKey(lastKey);
13501
-
13502
- if ($a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) && e.shiftKey && manager.selectionMode === 'multiple') {
13503
- manager.extendSelection(lastKey);
13504
- } else if (selectOnFocus) {
13505
- manager.replaceSelection(lastKey);
13506
- }
13507
- }
13508
-
13509
- break;
13510
-
13511
- case 'PageDown':
13512
- if (delegate.getKeyPageBelow) {
13513
- e.preventDefault();
13514
- let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
13515
- navigateToKey(nextKey);
13516
- }
13517
-
13518
- break;
13519
-
13520
- case 'PageUp':
13521
- if (delegate.getKeyPageAbove) {
13522
- e.preventDefault();
13523
- let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
13524
- navigateToKey(nextKey);
13525
- }
13526
-
13527
- break;
13528
-
13529
- case 'a':
13530
- if ($a9b9aa71af07c56ab1d89ca45381f4b$var$isCtrlKeyPressed(e) && manager.selectionMode === 'multiple' && disallowSelectAll !== true) {
13531
- e.preventDefault();
13532
- manager.selectAll();
13533
- }
13534
-
13535
- break;
13536
-
13537
- case 'Escape':
13538
- e.preventDefault();
13539
-
13540
- if (!disallowEmptySelection) {
13541
- manager.clearSelection();
13542
- }
13543
-
13544
- break;
13545
-
13546
- case 'Tab':
13547
- {
13548
- if (!allowsTabNavigation) {
13549
- // There may be elements that are "tabbable" inside a collection (e.g. in a grid cell).
13550
- // However, collections should be treated as a single tab stop, with arrow key navigation internally.
13551
- // We don't control the rendering of these, so we can't override the tabIndex to prevent tabbing.
13552
- // Instead, we handle the Tab key, and move focus manually to the first/last tabbable element
13553
- // in the collection, so that the browser default behavior will apply starting from that element
13554
- // rather than the currently focused one.
13555
- if (e.shiftKey) {
13556
- ref.current.focus();
13557
- } else {
13558
- let walker = getFocusableTreeWalker(ref.current, {
13559
- tabbable: true
13560
- });
13561
- let next;
13562
- let last;
13563
-
13564
- do {
13565
- last = walker.lastChild();
13566
-
13567
- if (last) {
13568
- next = last;
13569
- }
13570
- } while (last);
13571
-
13572
- if (next && !next.contains(document.activeElement)) {
13573
- focusWithoutScrolling(next);
13574
- }
13575
- }
13576
-
13577
- break;
13578
- }
13579
- }
13580
- }
13581
- };
13582
-
13583
- let onFocus = e => {
13584
- if (manager.isFocused) {
13585
- // If a focus event bubbled through a portal, reset focus state.
13586
- if (!e.currentTarget.contains(e.target)) {
13587
- manager.setFocused(false);
13588
- }
13589
-
13590
- return;
13591
- } // Focus events can bubble through portals. Ignore these events.
13592
-
13593
-
13594
- if (!e.currentTarget.contains(e.target)) {
13595
- return;
13596
- }
13597
-
13598
- manager.setFocused(true);
13599
-
13600
- if (manager.focusedKey == null) {
13601
- // If the user hasn't yet interacted with the collection, there will be no focusedKey set.
13602
- // Attempt to detect whether the user is tabbing forward or backward into the collection
13603
- // and either focus the first or last item accordingly.
13604
- let relatedTarget = e.relatedTarget;
13605
-
13606
- if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) {
13607
- var _manager$lastSelected;
13608
-
13609
- manager.setFocusedKey((_manager$lastSelected = manager.lastSelectedKey) != null ? _manager$lastSelected : delegate.getLastKey());
13610
- } else {
13611
- var _manager$firstSelecte;
13612
-
13613
- manager.setFocusedKey((_manager$firstSelecte = manager.firstSelectedKey) != null ? _manager$firstSelecte : delegate.getFirstKey());
13614
- }
13615
- }
13616
- };
13617
-
13618
- let onBlur = e => {
13619
- // Don't set blurred and then focused again if moving focus within the collection.
13620
- if (!e.currentTarget.contains(e.relatedTarget)) {
13621
- manager.setFocused(false);
13622
- }
13623
- };
13624
-
13625
- const autoFocusRef = useRef(autoFocus);
13626
- useEffect(() => {
13627
- if (autoFocusRef.current) {
13628
- let focusedKey = null; // Check focus strategy to determine which item to focus
13629
-
13630
- if (autoFocus === 'first') {
13631
- focusedKey = delegate.getFirstKey();
13632
- }
13633
-
13634
- if (autoFocus === 'last') {
13635
- focusedKey = delegate.getLastKey();
13636
- } // If there are any selected keys, make the first one the new focus target
13637
-
13638
-
13639
- let selectedKeys = manager.selectedKeys;
13640
-
13641
- if (selectedKeys.size) {
13642
- focusedKey = selectedKeys.values().next().value;
13643
- }
13644
-
13645
- manager.setFocused(true);
13646
- manager.setFocusedKey(focusedKey); // If no default focus key is selected, focus the collection itself.
13647
-
13648
- if (focusedKey == null && !shouldUseVirtualFocus) {
13649
- focusSafely(ref.current);
13650
- }
13651
- }
13652
-
13653
- autoFocusRef.current = false; // eslint-disable-next-line react-hooks/exhaustive-deps
13654
- }, []);
13655
- let handlers = {
13656
- onKeyDown,
13657
- onFocus,
13658
- onBlur,
13659
-
13660
- onMouseDown(e) {
13661
- // Ignore events that bubbled through portals.
13662
- if (e.currentTarget.contains(e.target)) {
13663
- // Prevent focus going to the collection when clicking on the scrollbar.
13664
- e.preventDefault();
13665
- }
13666
- }
13667
-
13668
- };
13669
- let {
13670
- typeSelectProps
13671
- } = useTypeSelect({
13672
- keyboardDelegate: delegate,
13673
- selectionManager: manager
13674
- });
13675
-
13676
- if (!disallowTypeAhead) {
13677
- handlers = mergeProps(typeSelectProps, handlers);
13678
- } // If nothing is focused within the collection, make the collection itself tabbable.
13679
- // This will be marshalled to either the first or last item depending on where focus came from.
13680
- // If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
13681
- // to move real DOM focus to the element anyway.
13682
-
13683
-
13684
- let tabIndex;
13685
-
13686
- if (!shouldUseVirtualFocus) {
13687
- tabIndex = manager.focusedKey == null ? 0 : -1;
13688
- }
13689
-
13690
- return {
13691
- collectionProps: _extends$1({}, handlers, {
13692
- tabIndex
13693
- })
13694
- };
13695
- }
13696
-
13697
- /**
13698
- * Handles interactions with an item in a selectable collection.
13699
- */
13700
- function useSelectableItem(options) {
13701
- let {
13702
- selectionManager: manager,
13703
- key,
13704
- ref,
13705
- shouldSelectOnPressUp,
13706
- isVirtualized,
13707
- shouldUseVirtualFocus,
13708
- focus
13709
- } = options;
13710
-
13711
- let onSelect = e => manager.select(key, e); // Focus the associated DOM node when this item becomes the focusedKey
13712
-
13713
-
13714
- let isFocused = key === manager.focusedKey;
13715
- useEffect(() => {
13716
- if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
13717
- if (focus) {
13718
- focus();
13719
- } else {
13720
- focusSafely(ref.current);
13721
- }
13722
- }
13723
- }, [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
13724
- // item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver
13725
- // on iOS 14 doesn't try to move real DOM focus to the item anyway.
13726
-
13727
- let itemProps = {};
13728
-
13729
- if (!shouldUseVirtualFocus) {
13730
- itemProps = {
13731
- tabIndex: isFocused ? 0 : -1,
13732
-
13733
- onFocus(e) {
13734
- if (e.target === ref.current) {
13735
- manager.setFocusedKey(key);
13736
- }
13737
- }
13738
-
13739
- };
13740
- } // By default, selection occurs on pointer down. This can be strange if selecting an
13741
- // item causes the UI to disappear immediately (e.g. menus).
13742
- // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
13743
- // onPress requires a pointer down event on the same element as pointer up. For menus,
13744
- // we want to be able to have the pointer down on the trigger that opens the menu and
13745
- // the pointer up on the menu item rather than requiring a separate press.
13746
- // For keyboard events, selection still occurs on key down.
13747
-
13748
-
13749
- if (shouldSelectOnPressUp) {
13750
- itemProps.onPressStart = e => {
13751
- if (e.pointerType === 'keyboard') {
13752
- onSelect(e);
13753
- }
13754
- };
13755
-
13756
- itemProps.onPressUp = e => {
13757
- if (e.pointerType !== 'keyboard') {
13758
- onSelect(e);
13759
- }
13760
- };
13761
- } else {
13762
- // On touch, it feels strange to select on touch down, so we special case this.
13763
- itemProps.onPressStart = e => {
13764
- if (e.pointerType !== 'touch') {
13765
- onSelect(e);
13766
- }
13767
- };
13768
-
13769
- itemProps.onPress = e => {
13770
- if (e.pointerType === 'touch') {
13771
- onSelect(e);
13772
- }
13773
- };
13774
- }
13775
-
13776
- if (!isVirtualized) {
13777
- itemProps['data-key'] = key;
13778
- }
13779
-
13780
- return {
13781
- itemProps
13782
- };
13783
- }
13784
-
13785
- function _extends() {
13786
- _extends = Object.assign || function (target) {
13787
- for (var i = 1; i < arguments.length; i++) {
13788
- var source = arguments[i];
13789
-
13790
- for (var key in source) {
13791
- if (Object.prototype.hasOwnProperty.call(source, key)) {
13792
- target[key] = source[key];
13793
- }
13794
- }
13795
- }
13796
-
13797
- return target;
13798
- };
13799
-
13800
- return _extends.apply(this, arguments);
13801
- }
13802
-
13803
- /*
13804
- * Copyright 2020 Adobe. All rights reserved.
13805
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13806
- * you may not use this file except in compliance with the License. You may obtain a copy
13807
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13808
- *
13809
- * Unless required by applicable law or agreed to in writing, software distributed under
13810
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13811
- * OF ANY KIND, either express or implied. See the License for the specific language
13812
- * governing permissions and limitations under the License.
13813
- */
13814
- const $c5c378b07d37fb3729fd37493414d657$export$tabsIds = new WeakMap();
13815
-
13816
- function $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, role) {
13817
- if (typeof key === 'string') {
13818
- key = key.replace(/\s+/g, '');
13819
- }
13820
-
13821
- let baseId = $c5c378b07d37fb3729fd37493414d657$export$tabsIds.get(state);
13822
- return baseId + "-" + role + "-" + key;
13823
- }
13824
-
13825
- /**
13826
- * Provides the behavior and accessibility implementation for a tab.
13827
- * When selected, the associated tab panel is shown.
13828
- */
13829
- function useTab(props, state, ref) {
13830
- let {
13831
- key,
13832
- isDisabled: propsDisabled
13833
- } = props;
13834
- let {
13835
- selectionManager: manager,
13836
- selectedKey
13837
- } = state;
13838
- let isSelected = key === selectedKey;
13839
- let {
13840
- itemProps
13841
- } = useSelectableItem({
13842
- selectionManager: manager,
13843
- key,
13844
- ref
13845
- });
13846
- let isDisabled = propsDisabled || state.disabledKeys.has(key);
13847
- let {
13848
- pressProps
13849
- } = usePress(_extends({}, itemProps, {
13850
- isDisabled
13851
- }));
13852
- let tabId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tab');
13853
- let tabPanelId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tabpanel');
13854
- let {
13855
- tabIndex
13856
- } = pressProps;
13857
- return {
13858
- tabProps: _extends({}, pressProps, {
13859
- id: tabId,
13860
- 'aria-selected': isSelected,
13861
- 'aria-disabled': isDisabled || undefined,
13862
- 'aria-controls': isSelected ? tabPanelId : undefined,
13863
- tabIndex: isDisabled ? undefined : tabIndex,
13864
- role: 'tab'
13865
- })
13866
- };
13867
- }
13868
-
13869
- /**
13870
- * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for
13871
- * the contents of a tab, and is shown when the tab is selected.
13872
- */
13873
- function useTabPanel(props, state, ref) {
13874
- let [tabIndex, setTabIndex] = useState(0); // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
13875
- // Otherwise, tabbing from the focused tab should go directly to the first tabbable element
13876
- // within the tabpanel.
13877
-
13878
- useLayoutEffect$1(() => {
13879
- if (ref != null && ref.current) {
13880
- let update = () => {
13881
- // Detect if there are any tabbable elements and update the tabIndex accordingly.
13882
- let walker = getFocusableTreeWalker(ref.current, {
13883
- tabbable: true
13884
- });
13885
- setTabIndex(walker.nextNode() ? undefined : 0);
13886
- };
13887
-
13888
- update(); // Update when new elements are inserted, or the tabIndex/disabled attribute updates.
13889
-
13890
- let observer = new MutationObserver(update);
13891
- observer.observe(ref.current, {
13892
- subtree: true,
13893
- childList: true,
13894
- attributes: true,
13895
- attributeFilter: ['tabIndex', 'disabled']
13896
- });
13897
- return () => {
13898
- observer.disconnect();
13899
- };
13900
- }
13901
- }, [ref]);
13902
- const id = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, state == null ? void 0 : state.selectedKey, 'tabpanel');
13903
- const tabPanelProps = useLabels(_extends({}, props, {
13904
- id,
13905
- 'aria-labelledby': $c5c378b07d37fb3729fd37493414d657$export$generateId(state, state == null ? void 0 : state.selectedKey, 'tab')
13906
- }));
13907
- return {
13908
- tabPanelProps: mergeProps(tabPanelProps, {
13909
- tabIndex,
13910
- role: 'tabpanel',
13911
- 'aria-describedby': props['aria-describedby'],
13912
- 'aria-details': props['aria-details']
13913
- })
13914
- };
13915
- }
13916
-
13917
- class $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate {
13918
- constructor(collection, direction, orientation, disabledKeys) {
13919
- if (disabledKeys === void 0) {
13920
- disabledKeys = new Set();
13921
- }
13922
-
13923
- this.collection = void 0;
13924
- this.flipDirection = void 0;
13925
- this.disabledKeys = void 0;
13926
- this.orientation = void 0;
13927
- this.collection = collection;
13928
- this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
13929
- this.orientation = orientation;
13930
- this.disabledKeys = disabledKeys;
13931
- }
13932
-
13933
- getKeyLeftOf(key) {
13934
- if (this.flipDirection) {
13935
- return this.getNextKey(key);
13936
- } else {
13937
- if (this.orientation === 'horizontal') {
13938
- return this.getPreviousKey(key);
13939
- }
13940
-
13941
- return null;
13942
- }
13943
- }
13944
-
13945
- getKeyRightOf(key) {
13946
- if (this.flipDirection) {
13947
- return this.getPreviousKey(key);
13948
- } else {
13949
- if (this.orientation === 'horizontal') {
13950
- return this.getNextKey(key);
13951
- }
13952
-
13953
- return null;
13954
- }
13955
- }
13956
-
13957
- getKeyAbove(key) {
13958
- if (this.orientation === 'vertical') {
13959
- return this.getPreviousKey(key);
13960
- }
13961
-
13962
- return null;
13963
- }
13964
-
13965
- getKeyBelow(key) {
13966
- if (this.orientation === 'vertical') {
13967
- return this.getNextKey(key);
13968
- }
13969
-
13970
- return null;
13971
- }
13972
-
13973
- getFirstKey() {
13974
- let key = this.collection.getFirstKey();
13975
-
13976
- if (this.disabledKeys.has(key)) {
13977
- key = this.getNextKey(key);
13978
- }
13979
-
13980
- return key;
13981
- }
13982
-
13983
- getLastKey() {
13984
- let key = this.collection.getLastKey();
13985
-
13986
- if (this.disabledKeys.has(key)) {
13987
- key = this.getPreviousKey(key);
13988
- }
13989
-
13990
- return key;
13991
- }
13992
-
13993
- getNextKey(key) {
13994
- do {
13995
- key = this.collection.getKeyAfter(key);
13996
-
13997
- if (key == null) {
13998
- key = this.collection.getFirstKey();
13999
- }
14000
- } while (this.disabledKeys.has(key));
14001
-
14002
- return key;
14003
- }
14004
-
14005
- getPreviousKey(key) {
14006
- do {
14007
- key = this.collection.getKeyBefore(key);
14008
-
14009
- if (key == null) {
14010
- key = this.collection.getLastKey();
14011
- }
14012
- } while (this.disabledKeys.has(key));
14013
-
14014
- return key;
14015
- }
14016
-
14017
- }
14018
-
14019
- /**
14020
- * Provides the behavior and accessibility implementation for a tab list.
14021
- * Tabs organize content into multiple sections and allow users to navigate between them.
14022
- */
14023
- function useTabList(props, state, ref) {
14024
- let {
14025
- orientation = 'horizontal',
14026
- keyboardActivation = 'automatic'
14027
- } = props;
14028
- let {
14029
- collection,
14030
- selectionManager: manager,
14031
- disabledKeys
14032
- } = state;
14033
- let {
14034
- direction
14035
- } = useLocale();
14036
- let delegate = useMemo(() => new $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate(collection, direction, orientation, disabledKeys), [collection, disabledKeys, orientation, direction]);
14037
- let {
14038
- collectionProps
14039
- } = useSelectableCollection({
14040
- ref,
14041
- selectionManager: manager,
14042
- keyboardDelegate: delegate,
14043
- selectOnFocus: keyboardActivation === 'automatic',
14044
- disallowEmptySelection: true
14045
- }); // Compute base id for all tabs
14046
-
14047
- let tabsId = useId();
14048
- $c5c378b07d37fb3729fd37493414d657$export$tabsIds.set(state, tabsId);
14049
- let tabListLabelProps = useLabels(_extends({}, props, {
14050
- id: tabsId
14051
- }));
14052
- return {
14053
- tabListProps: _extends({}, mergeProps(collectionProps, tabListLabelProps), {
14054
- role: 'tablist',
14055
- 'aria-orientation': orientation,
14056
- tabIndex: undefined
14057
- })
14058
- };
14059
- }
14060
-
14061
- function SpsTab(_a) {
14062
- var item = _a.item, state = _a.state;
14063
- var key = item.key;
14064
- var ref = React.useRef();
14065
- var tabProps = useTab({ key: key }, state, ref).tabProps;
14066
- var isSelected = state.selectedKey === key;
14067
- var isDisabled = state.disabledKeys.has(key);
14068
- return (React.createElement("div", __assign({}, tabProps, { ref: ref, className: clsx('sps-nav__item', 'sps-nav__link', isSelected && 'active', isDisabled && 'sps-nav__item--disabled') }), item.rendered));
14069
- }
14070
-
14071
- function SpsTabPanel(_a) {
14072
- var state = _a.state, props = __rest(_a, ["state"]);
14073
- var ref = React.useRef();
14074
- var tabPanelProps = useTabPanel(props, state, ref).tabPanelProps;
14075
- return (React.createElement("div", __assign({}, tabPanelProps, { ref: ref, className: "sps-card__body" }), state.selectedItem ? state.selectedItem.props.children : null));
14076
- }
14077
-
14078
- function SpsTabsV2(props) {
14079
- var state = useTabListState(props);
14080
- var ref = React.useRef();
14081
- var tabListProps = useTabList(props, state, ref).tabListProps;
14082
- return (React.createElement(React.Fragment, null,
14083
- React.createElement("div", __assign({}, tabListProps, { ref: ref, className: "sps-nav sps-nav--tabs sps-tabs-v2" }), __spreadArray([], __read(state.collection)).map(function (item) { return (React.createElement(SpsTab, { key: item.key, item: item, state: state })); })),
14084
- React.createElement(SpsTabPanel, { key: state.selectedItem ? state.selectedItem.key : null, state: state })));
14085
- }
14086
-
14087
- function SpsCardV2Footer(_a) {
14088
- var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
14089
- return (React.createElement("div", __assign({ className: clsx('sps-card__footer', className) }, rest), children));
14090
- }
14091
-
14092
- function SpsCardV2Header(_a) {
14093
- var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
14094
- return (React.createElement("div", __assign({ className: clsx('sps-card__header', className) }, rest), children));
14095
- }
14096
-
14097
- function SpsCardV2(_a) {
14098
- var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
14099
- var _b = __read(selectChildren(children, [
14100
- { type: SpsCardV2Header },
14101
- { type: SpsTabsV2 },
14102
- { type: SpsCardV2Footer },
14103
- ]), 4), header = _b[0], tabs = _b[1], footer = _b[2], bodyContent = _b[3];
14104
- return (React.createElement("div", __assign({ className: clsx('sps-card', className) }, rest),
14105
- header,
14106
- tabs.length > 0
14107
- ? tabs
14108
- : (React.createElement("div", { className: "sps-card__body" }, bodyContent)),
14109
- footer));
14110
- }
14111
-
14112
- function SpsCardV2Title(_a) {
14113
- var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
14114
- return (React.createElement("div", __assign({ className: clsx('sps-card__title', className) }, rest), children));
14115
- }
14116
-
14117
10906
  var moment$2 = moment$6.default || moment$6;
14118
10907
  function newWeekArray() {
14119
10908
  return (new Array(7)).fill(null);
@@ -14931,4 +11720,4 @@ Object.assign(SpsVr, {
14931
11720
  displayName: 'SpsDescriptionListTerm / SpsDt',
14932
11721
  });
14933
11722
 
14934
- export { ContentOrderExample, FauxChangeEvent, I18nContext, MANIFEST, OnBlurErrorKeys, PortalContext, SimpleDateUtils, SpsAddRemoveFormRowExamples, SpsAdvancedSearch, SpsAdvancedSearchExamples, SpsAutocomplete, SpsAutocompleteExamples, SpsButton, SpsButtonExamples, SpsButtonGroup, SpsCard, SpsCardExamples, SpsCardTabbedPane, SpsCardV2, SpsCardV2Footer, SpsCardV2Header, SpsCardV2Title, SpsCheckbox, SpsCheckboxDropdown, SpsCheckboxExamples, SpsClickableTag, SpsClickableTagExamples, SpsColumnChooser, SpsColumnChooserColumn, SpsColumnChooserExamples, SpsContentRow, SpsContentRowCol, SpsContentRowExamples, SpsContentRowExpansion, SpsCurrencyInput, SpsCurrencyInputExamples, SpsDateRangePicker, SpsDateRangePickerExamples, SpsDateRangePickerV2, SpsDateTime, SpsDatepicker, SpsDatepickerExamples, SpsDatepickerV2, SpsDatetimeExamples, SpsDd, SpsDescriptionList, SpsDescriptionListDefinition, SpsDescriptionListExamples, SpsDescriptionListTerm, SpsDl, SpsDropdown, SpsDropdownExamples, SpsDt, SpsFeedbackBlock, SpsFeedbackBlockExamples, SpsFieldset, SpsFieldsetExamples, SpsFilterPanel, SpsFilterPanelCap, SpsFilterPanelExamples, SpsFilterPanelFilterBox, SpsFilterPanelSection, SpsFocusedTask, SpsFocusedTaskActions, SpsFocusedTaskExamples, SpsForm, SpsFormArrayMeta, SpsFormComponentWrapper, SpsFormExamples, SpsFormFieldMeta, SpsFormGroupMeta, SpsFormMetaBase, SpsFormSetMeta, SpsGrowler, SpsGrowlerExamples, SpsI, SpsIcon, SpsIconButtonPanel, SpsIncrementor, SpsIncrementorExamples, SpsInputGroup, SpsInsightTile, SpsInsights, SpsKeyValueList, SpsKeyValueListExamples, SpsKeyValueListItem, SpsKeyValueTag, SpsKeyValueTagExamples, SpsLabel, SpsLabelExamples, SpsListActionBar, SpsListActionBarExamples, SpsListToolbar, SpsListToolbarExamples, SpsListToolbarSearch, SpsMicroBlock, SpsMicroBlockExamples, SpsMicroZeroState, SpsModal, SpsModalAction, SpsModalBody, SpsModalExamples, SpsModalFooter, SpsModalHeader, SpsModalOverlay, SpsModalV2, SpsModalV2Footer, SpsMultiSelect, SpsMultiSelectExamples, SpsMultiSelectTag, SpsPageSelector, SpsPageSubtitle, SpsPageTitle, SpsPageTitleExamples, SpsPagination, SpsPaginationExamples, SpsProductBar, SpsProductBarExamples, SpsProductBarTab, SpsProgressBar, SpsProgressBarExamples, SpsProgressRing, SpsRadioButton, SpsRadioButtonExamples, SpsScrollableContainer, SpsScrollableContainerExamples, SpsSearchResultsBar, SpsSearchResultsBarExamples, SpsSelect, SpsSelectExamples, SpsSideNav, SpsSideNavExamples, SpsSlackLink, SpsSlackLinkExamples, SpsSortingHeader, SpsSortingHeaderCell, SpsSortingHeaderExamples, SpsSpinner, SpsSpinnerExamples, SpsSplitButton, SpsSplitButtonExamples, SpsSteppedProgressBar, SpsSteppedProgressBarExamples, SpsSummaryListColumn, SpsSummaryListExamples, SpsSummaryListExpansion, SpsSummaryListRow, SpsTab, SpsTabPanel, SpsTable, SpsTableBody, SpsTableCell, SpsTableExamples, SpsTableHead, SpsTableHeader, SpsTableRow, SpsTabsV2, SpsTag, SpsTagExamples, SpsTaskQueue, SpsTaskQueueExamples, SpsTbody, SpsTd, SpsTextInput, SpsTextInputExamples, SpsTextarea, SpsTextareaExamples, SpsTh, SpsThead, SpsTile, SpsTileList, SpsTileListExamples, SpsToggle, SpsToggleExamples, SpsTooltip, SpsTooltipExamples, SpsTr, SpsValidators, SpsVerticalRule, SpsVr, SpsWf, SpsWfDoc, SpsWfDs, SpsWfStep, SpsWizardExamples, SpsWizardSidebar, SpsWizardSubstep, SpsWorkflow, SpsWorkflowDocument, SpsWorkflowDocumentStatus, SpsWorkflowExamples, SpsWorkflowStep, SpsZeroState, SpsZeroStateExamples, TooltipVisibility, contentOf, date, dateConstraint, dateRange, findParentBranches, flipPosition, formArray, formControl, formGroup, getMember, getPosition, selectChildren, toggleTooltipState, useCheckDeprecatedProps, useDidUpdateEffect, useDocumentEventListener, useElementId, useForm, useGrowlers, useInputPopup, usePatchReducer, usePortal, useServerSideValidation, useSpsAction, useSpsForm, validate, weekOfMonth };
11723
+ export { ContentOrderExample, FauxChangeEvent, I18nContext, MANIFEST, OnBlurErrorKeys, PortalContext, SimpleDateUtils, SpsAddRemoveFormRowExamples, SpsAdvancedSearch, SpsAdvancedSearchExamples, SpsAutocomplete, SpsAutocompleteExamples, SpsButton, SpsButtonExamples, SpsButtonGroup, SpsCard, SpsCardExamples, SpsCardTabbedPane, SpsCheckbox, SpsCheckboxDropdown, SpsCheckboxExamples, SpsClickableTag, SpsClickableTagExamples, SpsColumnChooser, SpsColumnChooserColumn, SpsColumnChooserExamples, SpsContentRow, SpsContentRowCol, SpsContentRowExamples, SpsContentRowExpansion, SpsCurrencyInput, SpsCurrencyInputExamples, SpsDateRangePicker, SpsDateRangePickerExamples, SpsDateRangePickerV2, SpsDateTime, SpsDatepicker, SpsDatepickerExamples, SpsDatepickerV2, SpsDatetimeExamples, SpsDd, SpsDescriptionList, SpsDescriptionListDefinition, SpsDescriptionListExamples, SpsDescriptionListTerm, SpsDl, SpsDropdown, SpsDropdownExamples, SpsDt, SpsFeedbackBlock, SpsFeedbackBlockExamples, SpsFieldset, SpsFieldsetExamples, SpsFilterPanel, SpsFilterPanelCap, SpsFilterPanelExamples, SpsFilterPanelFilterBox, SpsFilterPanelSection, SpsFocusedTask, SpsFocusedTaskActions, SpsFocusedTaskExamples, SpsForm, SpsFormArrayMeta, SpsFormComponentWrapper, SpsFormExamples, SpsFormFieldMeta, SpsFormGroupMeta, SpsFormMetaBase, SpsFormSetMeta, SpsGrowler, SpsGrowlerExamples, SpsI, SpsIcon, SpsIconButtonPanel, SpsIncrementor, SpsIncrementorExamples, SpsInputGroup, SpsInsightTile, SpsInsights, SpsKeyValueList, SpsKeyValueListExamples, SpsKeyValueListItem, SpsKeyValueTag, SpsKeyValueTagExamples, SpsLabel, SpsLabelExamples, SpsListActionBar, SpsListActionBarExamples, SpsListToolbar, SpsListToolbarExamples, SpsListToolbarSearch, SpsMicroBlock, SpsMicroBlockExamples, SpsMicroZeroState, SpsModal, SpsModalAction, SpsModalBody, SpsModalExamples, SpsModalFooter, SpsModalHeader, SpsModalOverlay, SpsModalV2, SpsModalV2Footer, SpsMultiSelect, SpsMultiSelectExamples, SpsMultiSelectTag, SpsPageSelector, SpsPageSubtitle, SpsPageTitle, SpsPageTitleExamples, SpsPagination, SpsPaginationExamples, SpsProductBar, SpsProductBarExamples, SpsProductBarTab, SpsProgressBar, SpsProgressBarExamples, SpsProgressRing, SpsRadioButton, SpsRadioButtonExamples, SpsScrollableContainer, SpsScrollableContainerExamples, SpsSearchResultsBar, SpsSearchResultsBarExamples, SpsSelect, SpsSelectExamples, SpsSideNav, SpsSideNavExamples, SpsSlackLink, SpsSlackLinkExamples, SpsSortingHeader, SpsSortingHeaderCell, SpsSortingHeaderExamples, SpsSpinner, SpsSpinnerExamples, SpsSplitButton, SpsSplitButtonExamples, SpsSteppedProgressBar, SpsSteppedProgressBarExamples, SpsSummaryListColumn, SpsSummaryListExamples, SpsSummaryListExpansion, SpsSummaryListRow, SpsTable, SpsTableBody, SpsTableCell, SpsTableExamples, SpsTableHead, SpsTableHeader, SpsTableRow, SpsTag, SpsTagExamples, SpsTaskQueue, SpsTaskQueueExamples, SpsTbody, SpsTd, SpsTextInput, SpsTextInputExamples, SpsTextarea, SpsTextareaExamples, SpsTh, SpsThead, SpsTile, SpsTileList, SpsTileListExamples, SpsToggle, SpsToggleExamples, SpsTooltip, SpsTooltipExamples, SpsTr, SpsValidators, SpsVerticalRule, SpsVr, SpsWf, SpsWfDoc, SpsWfDs, SpsWfStep, SpsWizardExamples, SpsWizardSidebar, SpsWizardSubstep, SpsWorkflow, SpsWorkflowDocument, SpsWorkflowDocumentStatus, SpsWorkflowExamples, SpsWorkflowStep, SpsZeroState, SpsZeroStateExamples, TooltipVisibility, contentOf, date, dateConstraint, dateRange, findParentBranches, flipPosition, formArray, formControl, formGroup, getMember, getPosition, selectChildren, toggleTooltipState, useCheckDeprecatedProps, useDidUpdateEffect, useDocumentEventListener, useElementId, useForm, useGrowlers, useInputPopup, usePatchReducer, usePortal, useServerSideValidation, useSpsAction, useSpsForm, validate, weekOfMonth };