import type { ComponentMap } from './types/form';

/**
 * @description: 生成placeholder
 */
export function createPlaceholderMessage(component: keyof ComponentMap, label: string) {
  if (component === 'NInput') return `请输入${label}`;
  if (
    [
      'NPicker',
      'NSelect',
      'NCheckbox',
      'NRadio',
      'NSwitch',
      'NDatePicker',
      'NTimePicker',
      'NCheckboxGroup',
      'ApiSelect',
      'ApiTreeSelect'
    ].includes(component)
  )
    return `请选择${label}`;
  return '';
}

const DATE_TYPE = ['NDatePicker', 'NMonthPicker', 'NWeekPicker', 'NTimePicker'];

function genType() {
  return [...DATE_TYPE, 'NRangePicker'];
}

/**
 * 时间字段
 */
export const dateItemType = genType();

export function defaultType(component: keyof ComponentMap) {
  if (component === 'NInput') return '';
  if (component === 'NInputNumber') return null;
  return [
    'NPicker',
    'NSelect',
    'NCheckbox',
    'NRadio',
    'NSwitch',
    'NDatePicker',
    'NTimePicker',
    'NCheckboxGroup'
  ].includes(component)
    ? ''
    : undefined;
}
