50 lines
2.1 KiB
Plaintext
50 lines
2.1 KiB
Plaintext
import {onCloseMap as $dd149f63282afbbf$export$f6211563215e3b37} from "./useCloseOnScroll.mjs";
|
|
import {useEffect as $gMvIk$useEffect} from "react";
|
|
import {useId as $gMvIk$useId} from "@react-aria/utils";
|
|
|
|
/*
|
|
* 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 $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
|
|
let { type: type } = props;
|
|
let { isOpen: isOpen } = state;
|
|
// Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
|
|
// without forcing users to pass onClose.
|
|
(0, $gMvIk$useEffect)(()=>{
|
|
if (ref && ref.current) (0, $dd149f63282afbbf$export$f6211563215e3b37).set(ref.current, state.close);
|
|
});
|
|
// Aria 1.1 supports multiple values for aria-haspopup other than just menus.
|
|
// https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
|
|
// However, we only add it for menus for now because screen readers often
|
|
// announce it as a menu even for other values.
|
|
let ariaHasPopup = undefined;
|
|
if (type === 'menu') ariaHasPopup = true;
|
|
else if (type === 'listbox') ariaHasPopup = 'listbox';
|
|
let overlayId = (0, $gMvIk$useId)();
|
|
return {
|
|
triggerProps: {
|
|
'aria-haspopup': ariaHasPopup,
|
|
'aria-expanded': isOpen,
|
|
'aria-controls': isOpen ? overlayId : undefined,
|
|
onPress: state.toggle
|
|
},
|
|
overlayProps: {
|
|
id: overlayId
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
export {$628037886ba31236$export$f9d5c8beee7d008d as useOverlayTrigger};
|
|
//# sourceMappingURL=useOverlayTrigger.module.js.map
|