import { RichText } from '@hubspot/cms-components';
import styles from './index.module.scss';
import ContentFields from './ContentFields.js';
import cx from '../utils/classname.js';
import { TextProps } from './types.js';

const TextComponent = ({
  fieldPath,
  className = '',
  style = {},
}: TextProps) => {
  const defaultClasses = styles.text;
  const combinedClasses = cx(defaultClasses, className);

  return (
    <RichText fieldPath={fieldPath} className={combinedClasses} style={style} />
  );
};

type TextComponentType = typeof TextComponent & {
  ContentFields: typeof ContentFields;
};

const Text = TextComponent as TextComponentType;
Text.ContentFields = ContentFields;

export default Text;
