import React, { useEffect } from 'react';
import CSMaskedViewNativeComponent from '../../core/specs/CSMaskedViewNativeComponent';
import CSUnmaskedViewNativeComponent from '../../core/specs/CSUnmaskedViewNativeComponent';
import CSQMethodFilter from '../../csq/CSQMethodFilter';
import { CSMaskProps } from '../../types/types';

export const CSMask: React.FC<CSMaskProps> = ({
  isMasking = true,
  children,
  ...props
}) => {

  useEffect(() => {
      CSQMethodFilter.warnIfDisabled('default', 'CSMask');
  }, []);

  return isMasking ? (
    <CSMaskedViewNativeComponent {...props}>
      {children}
    </CSMaskedViewNativeComponent>
  ) : (
    <CSUnmaskedViewNativeComponent {...props}>
      {children}
    </CSUnmaskedViewNativeComponent>
  );
};
