import type { ILabelProps, IGetLabelPropsParams } from "../config/types"; /** * Получает свойства для компонента `Label` * @param {IGetLabelPropsParams} params - Параметры для получения свойств `label` * @returns {ILabelProps} Объект со свойствами для `Label`: */ export const getLabelProps = ({ label, comp, input, }: IGetLabelPropsParams = {}): ILabelProps => { const getHtmlFor = (): string => { if (label && typeof label === "object" && label.htmlFor) { return label.htmlFor; } if (comp) { return ""; } if (input) { return input.id || input.name || ""; } return ""; }; return { label: typeof label === "string" ? label : (label?.label ?? ""), htmlFor: getHtmlFor(), }; };