import { ComponentWithAs, getElementType, getUnhandledProps, useStyles, useFluentContext, useTelemetry, } from '@fluentui/react-bindings'; import { SvgIconProps, svgIconClassName, svgIconDisplayName, svgIconHandledProps, SvgIconChildrenFn, } from '@fluentui/react-icons-northstar'; import { callable } from '@fluentui/styles'; import * as React from 'react'; export type SvgIconStylesProps = Required< Pick >; /** * An SvgIcon displays a pictogram with semantic meaning. */ export const SvgIcon: ComponentWithAs<'span', SvgIconProps & { children: SvgIconChildrenFn }> & { handledProps: (keyof (SvgIconProps & { children: SvgIconChildrenFn }))[]; } = props => { const context = useFluentContext(); const { setStart, setEnd } = useTelemetry(SvgIcon.displayName, context.telemetry); setStart(); const { alt, 'aria-label': ariaLabel, bordered, circular, className, design, disabled, children, outline, rotate, size, styles, variables, xSpacing, } = props; const { classes } = useStyles(SvgIcon.displayName, { className: svgIconClassName, mapPropsToStyles: () => ({ bordered, circular, disabled, outline, rotate, size, xSpacing, }), mapPropsToInlineStyles: () => ({ className, design, styles, variables }), rtl: context.rtl, }); const ElementType = getElementType(props); const unhandledProps = getUnhandledProps(SvgIcon.handledProps, props); const element = ( {callable(children)({ classes, rtl: context.rtl, props })} ); setEnd(); return element; }; SvgIcon.displayName = svgIconDisplayName; SvgIcon.handledProps = [...svgIconHandledProps, 'children']; SvgIcon.defaultProps = { as: 'span', size: 'medium', rotate: 0, };