UNPKG

@patternfly/react-core

Version:

This library provides a set of common React components for use with the PatternFly reference implementation.

22 lines 1.41 kB
import { __rest } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef, useRef } from 'react'; import { Button } from '../Button'; import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon'; import { KeyTypes } from '../../helpers/constants'; const FormGroupLabelHelpBase = (_a) => { var { 'aria-label': ariaLabel, className, innerRef } = _a, props = __rest(_a, ['aria-label', "className", "innerRef"]); const ref = useRef(null); const buttonRef = innerRef || ref; const isMutableRef = (ref) => typeof ref === 'object' && ref !== null && 'current' in ref && ref.current !== undefined; const handleKeyDown = (event) => { if ([KeyTypes.Space, KeyTypes.Enter].includes(event.key) && isMutableRef(buttonRef) && buttonRef.current) { event.preventDefault(); buttonRef.current.click(); } }; return (_jsx(Button, Object.assign({ component: "span", isInline: true, ref: buttonRef, onKeyDown: handleKeyDown, "aria-label": ariaLabel, className: className, variant: "plain", hasNoPadding: true }, props, { icon: _jsx(QuestionCircleIcon, {}) }))); }; export const FormGroupLabelHelp = forwardRef((props, ref) => (_jsx(FormGroupLabelHelpBase, Object.assign({ innerRef: ref }, props)))); FormGroupLabelHelp.displayName = 'FormGroupLabelHelp'; //# sourceMappingURL=FormGroupLabelHelp.js.map