![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/@react-aria/focus/src/ |
/*
* 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 clsx from 'clsx';
import {mergeProps} from '@react-aria/utils';
import React, {ReactElement} from 'react';
import {useFocusRing} from './useFocusRing';
export interface FocusRingProps {
/** Child element to apply CSS classes to. */
children: ReactElement,
/** CSS class to apply when the element is focused. */
focusClass?: string,
/** CSS class to apply when the element has keyboard focus. */
focusRingClass?: string,
/**
* Whether to show the focus ring when something
* inside the container element has focus (true), or
* only if the container itself has focus (false).
* @default false
*/
within?: boolean,
/** Whether the element is a text input. */
isTextInput?: boolean,
/** Whether the element will be auto focused. */
autoFocus?: boolean
}
/**
* A utility component that applies a CSS class when an element has keyboard focus.
* Focus rings are visible only when the user is interacting with a keyboard,
* not with a mouse, touch, or other input methods.
*/
export function FocusRing(props: FocusRingProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> {
let {children, focusClass, focusRingClass} = props;
let {isFocused, isFocusVisible, focusProps} = useFocusRing(props);
let child = React.Children.only(children);
return React.cloneElement(child, mergeProps(child.props as any, {
...focusProps,
className: clsx({
[focusClass || '']: isFocused,
[focusRingClass || '']: isFocusVisible
})
}));
}