Files
NapCatQQ/.pnpm-store/v3/files/a3/9c0fd4e7e4e60521d02f63b8decb5a2a96add268277396638d1c4a6728eb768e9e95a0f59c57539d325a905f55c9e73e7b2b86c6b9936dd0f8bd76607c201a
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

53 lines
1.7 KiB
Plaintext

/*
* 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.
*/
import {AriaLabelingProps, DOMProps} from '@react-types/shared';
// @ts-ignore
import intlMessages from '../intl/*.json';
import React from 'react';
import {useLabels} from '@react-aria/utils';
import {useLocalizedStringFormatter} from '@react-aria/i18n';
import {VisuallyHidden} from '@react-aria/visually-hidden';
export interface DismissButtonProps extends AriaLabelingProps, DOMProps {
/** Called when the dismiss button is activated. */
onDismiss?: () => void
}
/**
* A visually hidden button that can be used to allow screen reader
* users to dismiss a modal or popup when there is no visual
* affordance to do so.
*/
export function DismissButton(props: DismissButtonProps) {
let {onDismiss, ...otherProps} = props;
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/overlays');
let labels = useLabels(otherProps, stringFormatter.format('dismiss'));
let onClick = () => {
if (onDismiss) {
onDismiss();
}
};
return (
<VisuallyHidden>
<button
{...labels}
tabIndex={-1}
onClick={onClick}
style={{width: 1, height: 1}} />
</VisuallyHidden>
);
}