UNPKG

react-aria

Version:
86 lines (76 loc) 4.09 kB
import {filterDOMProps as $6a28a4717b9a4e1c$export$457c3d6518dd4c6f} from "../utils/filterDOMProps.js"; import {listData as $519a33be2aaefa45$export$3585ede4d035bf14} from "./utils.js"; import {mergeProps as $64c36edd757dfa16$export$9d1611c77c2fe928} from "../utils/mergeProps.js"; import {useFocusWithin as $b842b95ed9b5d4d5$export$420e68273165f4ec} from "../interactions/useFocusWithin.js"; import {useId as $0292efe68908de6b$export$f680877a34711e37} from "../utils/useId.js"; import {useLabel as $6dc0ccf02415c0af$export$8467354a121f1b9f} from "../label/useLabel.js"; import {useSelectableList as $1bd41fe243048d1b$export$b95089534ab7c1fd} from "../selection/useSelectableList.js"; /* * 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. */ function $430e267aae88e2b6$export$50eacbbf140a3141(props, state, ref) { let domProps = (0, $6a28a4717b9a4e1c$export$457c3d6518dd4c6f)(props, { labelable: true }); // Use props instead of state here. We don't want this to change due to long press. let selectionBehavior = props.selectionBehavior || 'toggle'; let orientation = props.orientation || 'vertical'; let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override'); if (selectionBehavior === 'toggle' && linkBehavior === 'action') // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be // selectable in this configuration. linkBehavior = 'override'; let { listProps: listProps } = (0, $1bd41fe243048d1b$export$b95089534ab7c1fd)({ ...props, ref: ref, selectionManager: state.selectionManager, collection: state.collection, disabledKeys: state.disabledKeys, linkBehavior: linkBehavior }); let { focusWithinProps: focusWithinProps } = (0, $b842b95ed9b5d4d5$export$420e68273165f4ec)({ onFocusWithin: props.onFocus, onBlurWithin: props.onBlur, onFocusWithinChange: props.onFocusChange }); // Share list id and some props with child options. let id = (0, $0292efe68908de6b$export$f680877a34711e37)(props.id); (0, $519a33be2aaefa45$export$3585ede4d035bf14).set(state, { id: id, shouldUseVirtualFocus: props.shouldUseVirtualFocus, shouldSelectOnPressUp: props.shouldSelectOnPressUp, shouldFocusOnHover: props.shouldFocusOnHover, isVirtualized: props.isVirtualized, onAction: props.onAction, linkBehavior: linkBehavior, // @ts-ignore UNSTABLE_itemBehavior: props['UNSTABLE_itemBehavior'] }); let { labelProps: labelProps, fieldProps: fieldProps } = (0, $6dc0ccf02415c0af$export$8467354a121f1b9f)({ ...props, id: id, // listbox is not an HTML input element so it // shouldn't be labeled by a <label> element. labelElementType: 'span' }); return { labelProps: labelProps, listBoxProps: (0, $64c36edd757dfa16$export$9d1611c77c2fe928)(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? { 'aria-multiselectable': 'true' } : {}, { role: 'listbox', 'aria-orientation': orientation, ...(0, $64c36edd757dfa16$export$9d1611c77c2fe928)(fieldProps, listProps) }) }; } export {$430e267aae88e2b6$export$50eacbbf140a3141 as useListBox}; //# sourceMappingURL=useListBox.js.map