import type { IInputField, IFieldProps } from "../config/types"; /** * Анализирует свойства поля формы и возвращает флаги для всех специальных типов полей * @param {IInputField} input - Объект с параметрами поля формы * @param {string} [input.type] - Тип поля (textarea, file, password и т.д.) * @param {boolean} [input.isRequired] - Обязательность заполнения поля * @returns {IFieldProps} Объект с флагами свойств поля: */ export const getFieldProps = (input: IInputField = {}): IFieldProps => { const { type, isRequired } = input; const isRadio = type === "radio"; const isCheckbox = type === "checkbox"; return { isTextArea: type === "textarea", isFile: type === "file", isPassword: type === "password", isHidden: type === "hidden", isCaptcha: type === "captcha", isSelect: type === "select", isCanChecked: isRadio || isCheckbox, isRequired, isRadio, isCheckbox, }; };