import { AccessibilityActionHandlers, useFluentContext } from '@fluentui/react-bindings'; import * as React from 'react'; import * as _ from 'lodash'; import { renderComponent, RenderResultConfig } from './renderComponent'; import { createShorthandFactory, ShorthandFactory } from './factories'; import { ObjectOf } from '../types'; export interface CreateComponentConfig
{ displayName: string; className?: string; shorthandPropName?: string; defaultProps?: Partial
; handledProps?: string[]; propTypes?: React.WeakValidationMap
; actionHandlers?: AccessibilityActionHandlers; render: (config: RenderResultConfig
, props: P) => React.ReactNode; } export type CreateComponentReturnType
= React.FunctionComponent
& { deprecated_className: string; create: ShorthandFactory
; }; export const createComponentInternal =
= any>({ displayName = 'FluentUIComponent', className = 'fluent-ui-component', shorthandPropName = 'children', defaultProps = {}, handledProps = [], propTypes, actionHandlers, render, }: CreateComponentConfig
): CreateComponentReturnType
=> { const mergedDefaultProps = { as: 'div', ...(defaultProps as any), }; const FluentComponent: CreateComponentReturnType
= (props): React.ReactElement
=> {
// Stores debug information for component.
// Note that this ref should go as the first one, to be discoverable by debug utils.
const ref = React.useRef(null);
const context = useFluentContext();
const isFirstRenderRef = React.useRef