400 lines
18 KiB
JavaScript
400 lines
18 KiB
JavaScript
import $02cb4c75c506befe$exports from "./ar-AE.module.js";
|
|
import $568b8163f1e56faf$exports from "./bg-BG.module.js";
|
|
import $87581c0202d106b8$exports from "./cs-CZ.module.js";
|
|
import $a10a0369f5433ed1$exports from "./da-DK.module.js";
|
|
import $bfd288727d5cb166$exports from "./de-DE.module.js";
|
|
import $ca177778f9a74e3c$exports from "./el-GR.module.js";
|
|
import $9b5aa79ef84beb6c$exports from "./en-US.module.js";
|
|
import $57968e8209de2557$exports from "./es-ES.module.js";
|
|
import $60690790bf4c1c6a$exports from "./et-EE.module.js";
|
|
import $1101246e8c7d9357$exports from "./fi-FI.module.js";
|
|
import $6404b5cb5b241730$exports from "./fr-FR.module.js";
|
|
import $dfeafa702e92e31f$exports from "./he-IL.module.js";
|
|
import $2d125e0b34676352$exports from "./hr-HR.module.js";
|
|
import $ea029611d7634059$exports from "./hu-HU.module.js";
|
|
import $77f075bb86ad7091$exports from "./it-IT.module.js";
|
|
import $6e87462e84907983$exports from "./ja-JP.module.js";
|
|
import $9246f2c6edc6b232$exports from "./ko-KR.module.js";
|
|
import $e587accc6c0a434c$exports from "./lt-LT.module.js";
|
|
import $03a1900e7400b5ab$exports from "./lv-LV.module.js";
|
|
import $1387676441be6cf6$exports from "./nb-NO.module.js";
|
|
import $17e82ebf0f8ab91f$exports from "./nl-NL.module.js";
|
|
import $2f5377d3471630e5$exports from "./pl-PL.module.js";
|
|
import $dee9868b6fa95ffe$exports from "./pt-BR.module.js";
|
|
import $f8b2e63637cbb5a6$exports from "./pt-PT.module.js";
|
|
import $46a885db3b44ea95$exports from "./ro-RO.module.js";
|
|
import $50d8a8f0afa9dee5$exports from "./ru-RU.module.js";
|
|
import $2867ee6173245507$exports from "./sk-SK.module.js";
|
|
import $0631b65beeb09b50$exports from "./sl-SI.module.js";
|
|
import $65fc749265dcd686$exports from "./sr-SP.module.js";
|
|
import $69ba655c7853c08e$exports from "./sv-SE.module.js";
|
|
import $a79794784d61577c$exports from "./tr-TR.module.js";
|
|
import $c2845791417ebaf4$exports from "./uk-UA.module.js";
|
|
import $29b642d0025cc7a4$exports from "./zh-CN.module.js";
|
|
import $cd36dd33f9d46936$exports from "./zh-TW.module.js";
|
|
import {announce as $3yVy0$announce} from "@react-aria/live-announcer";
|
|
import {ariaHideOutside as $3yVy0$ariaHideOutside} from "@react-aria/overlays";
|
|
import {listData as $3yVy0$listData, getItemId as $3yVy0$getItemId} from "@react-aria/listbox";
|
|
import {useRouter as $3yVy0$useRouter, chain as $3yVy0$chain, useLabels as $3yVy0$useLabels, isAppleDevice as $3yVy0$isAppleDevice, mergeProps as $3yVy0$mergeProps} from "@react-aria/utils";
|
|
import {useMemo as $3yVy0$useMemo, useRef as $3yVy0$useRef, useEffect as $3yVy0$useEffect} from "react";
|
|
import {getChildNodes as $3yVy0$getChildNodes, getItemCount as $3yVy0$getItemCount} from "@react-stately/collections";
|
|
import {ListKeyboardDelegate as $3yVy0$ListKeyboardDelegate, useSelectableCollection as $3yVy0$useSelectableCollection} from "@react-aria/selection";
|
|
import {privateValidationStateProp as $3yVy0$privateValidationStateProp} from "@react-stately/form";
|
|
import {useLocalizedStringFormatter as $3yVy0$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
import {useMenuTrigger as $3yVy0$useMenuTrigger} from "@react-aria/menu";
|
|
import {useTextField as $3yVy0$useTextField} from "@react-aria/textfield";
|
|
|
|
|
|
function $parcel$interopDefault(a) {
|
|
return a && a.__esModule ? a.default : a;
|
|
}
|
|
/*
|
|
* Copyright 2020 Adobe. All rights reserved.
|
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
* governing permissions and limitations under the License.
|
|
*/ /*
|
|
* Copyright 2020 Adobe. All rights reserved.
|
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
* governing permissions and limitations under the License.
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
var $de5926a92e8ebc5b$exports = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$de5926a92e8ebc5b$exports = {
|
|
"ar-AE": $02cb4c75c506befe$exports,
|
|
"bg-BG": $568b8163f1e56faf$exports,
|
|
"cs-CZ": $87581c0202d106b8$exports,
|
|
"da-DK": $a10a0369f5433ed1$exports,
|
|
"de-DE": $bfd288727d5cb166$exports,
|
|
"el-GR": $ca177778f9a74e3c$exports,
|
|
"en-US": $9b5aa79ef84beb6c$exports,
|
|
"es-ES": $57968e8209de2557$exports,
|
|
"et-EE": $60690790bf4c1c6a$exports,
|
|
"fi-FI": $1101246e8c7d9357$exports,
|
|
"fr-FR": $6404b5cb5b241730$exports,
|
|
"he-IL": $dfeafa702e92e31f$exports,
|
|
"hr-HR": $2d125e0b34676352$exports,
|
|
"hu-HU": $ea029611d7634059$exports,
|
|
"it-IT": $77f075bb86ad7091$exports,
|
|
"ja-JP": $6e87462e84907983$exports,
|
|
"ko-KR": $9246f2c6edc6b232$exports,
|
|
"lt-LT": $e587accc6c0a434c$exports,
|
|
"lv-LV": $03a1900e7400b5ab$exports,
|
|
"nb-NO": $1387676441be6cf6$exports,
|
|
"nl-NL": $17e82ebf0f8ab91f$exports,
|
|
"pl-PL": $2f5377d3471630e5$exports,
|
|
"pt-BR": $dee9868b6fa95ffe$exports,
|
|
"pt-PT": $f8b2e63637cbb5a6$exports,
|
|
"ro-RO": $46a885db3b44ea95$exports,
|
|
"ru-RU": $50d8a8f0afa9dee5$exports,
|
|
"sk-SK": $2867ee6173245507$exports,
|
|
"sl-SI": $0631b65beeb09b50$exports,
|
|
"sr-SP": $65fc749265dcd686$exports,
|
|
"sv-SE": $69ba655c7853c08e$exports,
|
|
"tr-TR": $a79794784d61577c$exports,
|
|
"uk-UA": $c2845791417ebaf4$exports,
|
|
"zh-CN": $29b642d0025cc7a4$exports,
|
|
"zh-TW": $cd36dd33f9d46936$exports
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function $c350ade66beef0af$export$8c18d1b4f7232bbf(props, state) {
|
|
let { buttonRef: buttonRef, popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, shouldFocusWrap: // completionMode = 'suggest',
|
|
shouldFocusWrap, isReadOnly: isReadOnly, isDisabled: isDisabled } = props;
|
|
let stringFormatter = (0, $3yVy0$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($de5926a92e8ebc5b$exports))), "@react-aria/combobox");
|
|
let { menuTriggerProps: menuTriggerProps, menuProps: menuProps } = (0, $3yVy0$useMenuTrigger)({
|
|
type: "listbox",
|
|
isDisabled: isDisabled || isReadOnly
|
|
}, state, buttonRef);
|
|
// Set listbox id so it can be used when calling getItemId later
|
|
(0, $3yVy0$listData).set(state, {
|
|
id: menuProps.id
|
|
});
|
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
let delegate = (0, $3yVy0$useMemo)(()=>keyboardDelegate || new (0, $3yVy0$ListKeyboardDelegate)(state.collection, state.disabledKeys, listBoxRef), [
|
|
keyboardDelegate,
|
|
state.collection,
|
|
state.disabledKeys,
|
|
listBoxRef
|
|
]);
|
|
// Use useSelectableCollection to get the keyboard handlers to apply to the textfield
|
|
let { collectionProps: collectionProps } = (0, $3yVy0$useSelectableCollection)({
|
|
selectionManager: state.selectionManager,
|
|
keyboardDelegate: delegate,
|
|
disallowTypeAhead: true,
|
|
disallowEmptySelection: true,
|
|
shouldFocusWrap: shouldFocusWrap,
|
|
ref: inputRef,
|
|
// Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component
|
|
isVirtualized: true
|
|
});
|
|
let router = (0, $3yVy0$useRouter)();
|
|
// For textfield specific keydown operations
|
|
let onKeyDown = (e)=>{
|
|
switch(e.key){
|
|
case "Enter":
|
|
case "Tab":
|
|
// Prevent form submission if menu is open since we may be selecting a option
|
|
if (state.isOpen && e.key === "Enter") e.preventDefault();
|
|
// If the focused item is a link, trigger opening it. Items that are links are not selectable.
|
|
if (state.isOpen && state.selectionManager.focusedKey != null && state.selectionManager.isLink(state.selectionManager.focusedKey)) {
|
|
if (e.key === "Enter") {
|
|
let item = listBoxRef.current.querySelector(`[data-key="${CSS.escape(state.selectionManager.focusedKey.toString())}"]`);
|
|
if (item instanceof HTMLAnchorElement) router.open(item, e);
|
|
}
|
|
state.close();
|
|
} else state.commit();
|
|
break;
|
|
case "Escape":
|
|
if (state.selectedKey !== null || state.inputValue === "" || props.allowsCustomValue) e.continuePropagation();
|
|
state.revert();
|
|
break;
|
|
case "ArrowDown":
|
|
state.open("first", "manual");
|
|
break;
|
|
case "ArrowUp":
|
|
state.open("last", "manual");
|
|
break;
|
|
case "ArrowLeft":
|
|
case "ArrowRight":
|
|
state.selectionManager.setFocusedKey(null);
|
|
break;
|
|
}
|
|
};
|
|
let onBlur = (e)=>{
|
|
var _popoverRef_current;
|
|
// Ignore blur if focused moved to the button or into the popover.
|
|
if (e.relatedTarget === (buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) || ((_popoverRef_current = popoverRef.current) === null || _popoverRef_current === void 0 ? void 0 : _popoverRef_current.contains(e.relatedTarget))) return;
|
|
if (props.onBlur) props.onBlur(e);
|
|
state.setFocused(false);
|
|
};
|
|
let onFocus = (e)=>{
|
|
if (state.isFocused) return;
|
|
if (props.onFocus) props.onFocus(e);
|
|
state.setFocused(true);
|
|
};
|
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
let { labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $3yVy0$useTextField)({
|
|
...props,
|
|
onChange: state.setInputValue,
|
|
onKeyDown: !isReadOnly ? (0, $3yVy0$chain)(state.isOpen && collectionProps.onKeyDown, onKeyDown, props.onKeyDown) : props.onKeyDown,
|
|
onBlur: onBlur,
|
|
value: state.inputValue,
|
|
onFocus: onFocus,
|
|
autoComplete: "off",
|
|
validate: undefined,
|
|
[(0, $3yVy0$privateValidationStateProp)]: state
|
|
}, inputRef);
|
|
// Press handlers for the ComboBox button
|
|
let onPress = (e)=>{
|
|
if (e.pointerType === "touch") {
|
|
// Focus the input field in case it isn't focused yet
|
|
inputRef.current.focus();
|
|
state.toggle(null, "manual");
|
|
}
|
|
};
|
|
let onPressStart = (e)=>{
|
|
if (e.pointerType !== "touch") {
|
|
inputRef.current.focus();
|
|
state.toggle(e.pointerType === "keyboard" || e.pointerType === "virtual" ? "first" : null, "manual");
|
|
}
|
|
};
|
|
let triggerLabelProps = (0, $3yVy0$useLabels)({
|
|
id: menuTriggerProps.id,
|
|
"aria-label": stringFormatter.format("buttonLabel"),
|
|
"aria-labelledby": props["aria-labelledby"] || labelProps.id
|
|
});
|
|
let listBoxProps = (0, $3yVy0$useLabels)({
|
|
id: menuProps.id,
|
|
"aria-label": stringFormatter.format("listboxLabel"),
|
|
"aria-labelledby": props["aria-labelledby"] || labelProps.id
|
|
});
|
|
// If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu
|
|
let lastEventTime = (0, $3yVy0$useRef)(0);
|
|
let onTouchEnd = (e)=>{
|
|
if (isDisabled || isReadOnly) return;
|
|
// Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.
|
|
if (e.timeStamp - lastEventTime.current < 500) {
|
|
e.preventDefault();
|
|
inputRef.current.focus();
|
|
return;
|
|
}
|
|
let rect = e.target.getBoundingClientRect();
|
|
let touch = e.changedTouches[0];
|
|
let centerX = Math.ceil(rect.left + .5 * rect.width);
|
|
let centerY = Math.ceil(rect.top + .5 * rect.height);
|
|
if (touch.clientX === centerX && touch.clientY === centerY) {
|
|
e.preventDefault();
|
|
inputRef.current.focus();
|
|
state.toggle(null, "manual");
|
|
lastEventTime.current = e.timeStamp;
|
|
}
|
|
};
|
|
// VoiceOver has issues with announcing aria-activedescendant properly on change
|
|
// (especially on iOS). We use a live region announcer to announce focus changes
|
|
// manually. In addition, section titles are announced when navigating into a new section.
|
|
let focusedItem = state.selectionManager.focusedKey != null && state.isOpen ? state.collection.getItem(state.selectionManager.focusedKey) : undefined;
|
|
var _focusedItem_parentKey;
|
|
let sectionKey = (_focusedItem_parentKey = focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) !== null && _focusedItem_parentKey !== void 0 ? _focusedItem_parentKey : null;
|
|
var _state_selectionManager_focusedKey;
|
|
let itemKey = (_state_selectionManager_focusedKey = state.selectionManager.focusedKey) !== null && _state_selectionManager_focusedKey !== void 0 ? _state_selectionManager_focusedKey : null;
|
|
let lastSection = (0, $3yVy0$useRef)(sectionKey);
|
|
let lastItem = (0, $3yVy0$useRef)(itemKey);
|
|
(0, $3yVy0$useEffect)(()=>{
|
|
if ((0, $3yVy0$isAppleDevice)() && focusedItem != null && itemKey !== lastItem.current) {
|
|
let isSelected = state.selectionManager.isSelected(itemKey);
|
|
let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;
|
|
let sectionTitle = (section === null || section === void 0 ? void 0 : section["aria-label"]) || (typeof (section === null || section === void 0 ? void 0 : section.rendered) === "string" ? section.rendered : "") || "";
|
|
let announcement = stringFormatter.format("focusAnnouncement", {
|
|
isGroupChange: section && sectionKey !== lastSection.current,
|
|
groupTitle: sectionTitle,
|
|
groupCount: section ? [
|
|
...(0, $3yVy0$getChildNodes)(section, state.collection)
|
|
].length : 0,
|
|
optionText: focusedItem["aria-label"] || focusedItem.textValue || "",
|
|
isSelected: isSelected
|
|
});
|
|
(0, $3yVy0$announce)(announcement);
|
|
}
|
|
lastSection.current = sectionKey;
|
|
lastItem.current = itemKey;
|
|
});
|
|
// Announce the number of available suggestions when it changes
|
|
let optionCount = (0, $3yVy0$getItemCount)(state.collection);
|
|
let lastSize = (0, $3yVy0$useRef)(optionCount);
|
|
let lastOpen = (0, $3yVy0$useRef)(state.isOpen);
|
|
(0, $3yVy0$useEffect)(()=>{
|
|
// Only announce the number of options available when the menu opens if there is no
|
|
// focused item, otherwise screen readers will typically read e.g. "1 of 6".
|
|
// The exception is VoiceOver since this isn't included in the message above.
|
|
let didOpenWithoutFocusedItem = state.isOpen !== lastOpen.current && (state.selectionManager.focusedKey == null || (0, $3yVy0$isAppleDevice)());
|
|
if (state.isOpen && (didOpenWithoutFocusedItem || optionCount !== lastSize.current)) {
|
|
let announcement = stringFormatter.format("countAnnouncement", {
|
|
optionCount: optionCount
|
|
});
|
|
(0, $3yVy0$announce)(announcement);
|
|
}
|
|
lastSize.current = optionCount;
|
|
lastOpen.current = state.isOpen;
|
|
});
|
|
// Announce when a selection occurs for VoiceOver. Other screen readers typically do this automatically.
|
|
let lastSelectedKey = (0, $3yVy0$useRef)(state.selectedKey);
|
|
(0, $3yVy0$useEffect)(()=>{
|
|
if ((0, $3yVy0$isAppleDevice)() && state.isFocused && state.selectedItem && state.selectedKey !== lastSelectedKey.current) {
|
|
let optionText = state.selectedItem["aria-label"] || state.selectedItem.textValue || "";
|
|
let announcement = stringFormatter.format("selectedAnnouncement", {
|
|
optionText: optionText
|
|
});
|
|
(0, $3yVy0$announce)(announcement);
|
|
}
|
|
lastSelectedKey.current = state.selectedKey;
|
|
});
|
|
(0, $3yVy0$useEffect)(()=>{
|
|
if (state.isOpen) return (0, $3yVy0$ariaHideOutside)([
|
|
inputRef.current,
|
|
popoverRef.current
|
|
]);
|
|
}, [
|
|
state.isOpen,
|
|
inputRef,
|
|
popoverRef
|
|
]);
|
|
return {
|
|
labelProps: labelProps,
|
|
buttonProps: {
|
|
...menuTriggerProps,
|
|
...triggerLabelProps,
|
|
excludeFromTabOrder: true,
|
|
onPress: onPress,
|
|
onPressStart: onPressStart,
|
|
isDisabled: isDisabled || isReadOnly
|
|
},
|
|
inputProps: (0, $3yVy0$mergeProps)(inputProps, {
|
|
role: "combobox",
|
|
"aria-expanded": menuTriggerProps["aria-expanded"],
|
|
"aria-controls": state.isOpen ? menuProps.id : undefined,
|
|
// TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)
|
|
"aria-autocomplete": "list",
|
|
"aria-activedescendant": focusedItem ? (0, $3yVy0$getItemId)(state, focusedItem.key) : undefined,
|
|
onTouchEnd: onTouchEnd,
|
|
// This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.
|
|
autoCorrect: "off",
|
|
// This disable's the macOS Safari spell check auto corrections.
|
|
spellCheck: "false"
|
|
}),
|
|
listBoxProps: (0, $3yVy0$mergeProps)(menuProps, listBoxProps, {
|
|
autoFocus: state.focusStrategy,
|
|
shouldUseVirtualFocus: true,
|
|
shouldSelectOnPressUp: true,
|
|
shouldFocusOnHover: true,
|
|
linkBehavior: "selection"
|
|
}),
|
|
descriptionProps: descriptionProps,
|
|
errorMessageProps: errorMessageProps,
|
|
isInvalid: isInvalid,
|
|
validationErrors: validationErrors,
|
|
validationDetails: validationDetails
|
|
};
|
|
}
|
|
|
|
|
|
|
|
|
|
export {$c350ade66beef0af$export$8c18d1b4f7232bbf as useComboBox};
|
|
//# sourceMappingURL=module.js.map
|