import React from 'react';
import type { ReactNode } from 'react';
import type {
  TextProps as NativeTextProps,
  StyleProp,
  TextStyle,
} from 'react-native';
import { StyledText } from './StyledText';
import { useDeprecation } from '../../../utils/hooks';

export interface TextProps extends NativeTextProps {
  /**
   * Text content.
   */
  children: ReactNode;
  /**
   * Size of the text.
   */
  fontSize?:
    | 'xsmall'
    | 'small'
    | 'medium'
    | 'large'
    | 'xlarge'
    | 'xxxlarge'
    | 'xxxxlarge'
    | 'xxxxxlarge'
    | '6xlarge'
    | '7xlarge';
  /**
   * Font weight of the text.
   */
  fontWeight?: 'light' | 'regular' | 'semi-bold';
  /**
   * Visual intent color to apply to the text.
   */
  intent?:
    | 'body'
    | 'subdued'
    | 'primary'
    | 'secondary'
    | 'success'
    | 'info'
    | 'warning'
    | 'danger'
    | 'inverted'
    | 'archived'
    | 'disabled';
  /**
   * Additional style.
   */
  style?: StyleProp<TextStyle>;
  /**
   * Testing id of the component.
   */
  testID?: string;
  /**
   * The typeface to render the text in:
   * - `neutral`: The default typeface for the platform.
   * - `playful`: To visualise a playful content.
   */
  typeface?: 'neutral' | 'playful';
}

/**
 * @deprecated Typography.Text is deprecated and will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.
 */
const Text = ({
  children,
  fontSize = 'medium',
  fontWeight = 'regular',
  intent = 'body',
  typeface = 'neutral',
  allowFontScaling = false,
  ...nativeProps
}: TextProps) => {
  useDeprecation(
    'Typography.Text is deprecated and will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.'
  );

  return (
    <StyledText
      {...nativeProps}
      themeFontSize={fontSize}
      themeFontWeight={fontWeight}
      themeIntent={intent}
      themeTypeface={typeface}
      allowFontScaling={allowFontScaling}
    >
      {children}
    </StyledText>
  );
};

export default Text;
