import React from 'react' import { ComponentProps } from '../types' /** * @deprecated This type is deprecated. Use `PolymorphicRef` from './ui.tsx' instead. * The UI component provides better type safety and accessibility features. */ type PolymorphicRef = React.Ref< React.ElementRef > /** * @deprecated This type is deprecated. Use `AsProp` from './ui.tsx' instead. * The UI component provides better type safety and accessibility features. */ type AsProp = { as?: C } /** * @deprecated This type is deprecated. Use `PropsToOmit` from './ui.tsx' instead. * The UI component provides better type safety and accessibility features. */ type PropsToOmit = keyof (AsProp & P) /** * @deprecated This type is deprecated. Use `PolymorphicComponentProp` from './ui.tsx' instead. * The UI component provides better type safety and accessibility features. */ type PolymorphicComponentProp< C extends React.ElementType, // eslint-disable-next-line @typescript-eslint/no-empty-object-type Props = {}, > = React.PropsWithChildren> & Omit, PropsToOmit> /** * @deprecated This type is deprecated. Use `PolymorphicComponentPropWithRef` from './ui.tsx' instead. * The UI component provides better type safety and accessibility features. */ type PolymorphicComponentPropWithRef< C extends React.ElementType, // eslint-disable-next-line @typescript-eslint/no-empty-object-type Props = {}, > = PolymorphicComponentProp & { ref?: PolymorphicRef | React.ForwardedRef> } /** * @deprecated This type is deprecated. Use `UIProps` from './ui.tsx' instead. * The UI component provides better type safety and accessibility features. */ type FPProps = PolymorphicComponentPropWithRef< C, { renderStyles?: boolean styles?: React.CSSProperties classes?: string } > /** * FPComponent type definition * * @deprecated This type is deprecated. Use the `UI` component from './ui.tsx' instead. * The UI component provides enhanced accessibility documentation, better type safety, * and comprehensive WCAG 2.1 AA compliance guidance. * * @typeParam C - The HTML element type to render * @param props - The component props * @returns React component * * @example * ```typescript * // Migration from FP to UI * // Before: * import FP from '@fpkit/acss/components/fp'; * Click me * * // After: * import UI from '@fpkit/acss/components/ui'; * Click me * ``` */ type FPComponent = { ( props: FPProps, ): React.ReactElement | null displayName?: string } /** * @deprecated **DEPRECATED:** This component is deprecated and will be removed in a future version. * Please use the `UI` component from `./ui.tsx` instead. * * The UI component is a drop-in replacement with the same API but provides: * - Enhanced accessibility documentation and WCAG 2.1 AA compliance guidance * - Better TypeScript type safety with detailed JSDoc comments * - Comprehensive examples for accessible component patterns * - More robust style merging with defaultStyles support * * @example * ```typescript * // Migration Guide * // Before: * import FP from '@fpkit/acss/components/fp'; * * Click me * * * // After: * import UI from '@fpkit/acss/components/ui'; * * Click me * * ``` * * @param {Object} props - Component props * @param {React.ElementType} props.as - The HTML element to render. Defaults to 'div'. * @param {boolean} props.renderStyles - Whether to render styles or not. Defaults to true. * @param {Object} props.styles - The styles to apply to the component. * @param {Object} props.defaultStyles - The default styles to apply to the component. * @param {React.ReactNode} props.children - The children to render inside the component. * @returns {React.ReactElement} - A React component that renders an HTML element with optional styles. */ const FP = React.forwardRef( ( { as, styles, classes, children, defaultStyles, ...props }: FPProps, ref?: PolymorphicRef, ) => { const Component = as || 'div' const styleObj = { ...defaultStyles, ...styles } as React.CSSProperties return ( {children} ) }, ) as FPComponent FP.displayName = 'FP' /** * @deprecated This interface is deprecated. Use the `UI` component from './ui.tsx' instead. * The UI component provides better type safety and accessibility features. */ export interface BoxProps extends ComponentProps { renderStyles: true } export default FP