@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
34 lines (33 loc) • 1.11 kB
JavaScript
"use client";
import withComponentMarkers from "../../shared/helpers/withComponentMarkers.js";
import React from 'react';
import clsx from 'clsx';
import Context from "../../shared/Context.js";
import { extendPropsWithContext } from "../../shared/component-helper.js";
import { jsx as _jsx } from "react/jsx-runtime";
const defaultProps = {
focusable: false,
element: 'span'
};
const VisuallyHidden = localProps => {
const context = React.useContext(Context);
const {
element,
children,
className,
focusable,
...props
} = extendPropsWithContext(localProps, defaultProps, context === null || context === void 0 ? void 0 : context.VisuallyHidden);
const visuallyHiddenClassNames = clsx('dnb-visually-hidden', focusable ? 'dnb-visually-hidden--focusable' : 'dnb-sr-only', className);
const Element = element || 'span';
return _jsx(Element, {
className: visuallyHiddenClassNames,
...props,
children: children
});
};
withComponentMarkers(VisuallyHidden, {
_supportsSpacingProps: false
});
export default VisuallyHidden;
//# sourceMappingURL=VisuallyHidden.js.map