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,EAAwC,GAI9C,OAHIJ,GAAYI,EAAWC,KAAKC,EAAAA,IAC5BL,GAAiBG,EAAWC,KAAKJ,GAE9BG,CACT,IAEA,OACEnB,EAAAA,EAAAA,KAACsB,EAAAA,GAAKpB,EAAAA,EAAA,CAAUe,SAAUA,EAAUM,KAAK,YAAe7C,GAAK,IAAAQ,SAC1D,SAACsC,GAA8B,OAAKxB,EAAAA,EAAAA,KAACyB,EAAAA,EAAiBvB,EAAAA,EAAA,GAAKsB,GAAgB9C,GAAS,IAG3F,C","sources":["webpack://agromarket/./src/components/ui/fields/CheckboxInput/CheckboxFieldView.tsx","webpack://agromarket/./src/components/ui/fields/CheckboxInput/CheckboxInput.tsx"],"sourcesContent":["import React from 'react'\nimport type { TOnCheckboxChange } from '@frontend/pole-ui/lib/components/Checkbox'\nimport { Checkbox } from '@frontend/pole-ui/lib/components/Checkbox'\nimport { injectMessages } from '@/logic/translation/utils'\nimport { useMount } from '@/utils/hooks'\nimport { useDeviceType } from '@/utils/hooks/useDeviceType'\nimport ErrorMessage from '../../ErrorMessage'\nimport InjectHtml from '../../InjectHtml'\nimport type { TCheckboxViewProps } from './interfaces'\nimport messages from './messages.json'\n\ninjectMessages(messages)\n\nconst CheckboxFieldView: React.FC<TCheckboxViewProps> = props => {\n const {\n input,\n label,\n labelId,\n onChange,\n shouldClearValueOnUnmount,\n meta,\n children,\n shouldChangeValue = true,\n errorClassName = 'space-holder-left40-from-sm space-holder-left24-sm space-holder-top8',\n ...otherProps\n } = props\n\n const { isMobile } = useDeviceType()\n\n useMount(undefined, () => {\n if (shouldClearValueOnUnmount) input.onChange(false)\n })\n\n const { touched, error } = meta\n\n const onCheckboxChange: TOnCheckboxChange = (_state, event) => {\n if (!shouldChangeValue) return\n\n onChange?.(event)\n input.onChange(event)\n }\n\n return (\n <Checkbox\n {...otherProps}\n onChange={onCheckboxChange}\n onFocus={otherProps.onFocus ?? input.onFocus}\n onBlur={input.onBlur}\n isMobile={isMobile}\n value={input.checked || input.value}\n error={touched && error && <ErrorMessage textId={`checkbox.error.${error}`} isVisible className={errorClassName} />}\n >\n {children || label || (labelId && <InjectHtml textId={labelId} />)}\n </Checkbox>\n )\n}\n\nexport default CheckboxFieldView\n","import React from 'react'\nimport { Field } from 'react-final-form'\nimport type { FieldValidator } from 'final-form'\nimport { getValidateFunction, isCheckboxRequired } from '@/utils/validators'\nimport CheckboxFieldView from './CheckboxFieldView'\nimport type { ICheckboxProps, TCheckboxViewProps } from './interfaces'\n\nconst CheckboxInput: React.FC<ICheckboxProps> = props => {\n const { isRequired, customValidator } = props\n\n const validate = getValidateFunction(() => {\n const validators: FieldValidator<boolean>[] = []\n if (isRequired) validators.push(isCheckboxRequired)\n if (customValidator) validators.push(customValidator)\n\n return validators\n }) as FieldValidator<boolean>\n\n return (\n <Field<boolean> validate={validate} type=\"checkbox\" {...props}>\n {(fieldProps: TCheckboxViewProps) => <CheckboxFieldView {...fieldProps} {...props} />}\n </Field>\n )\n}\n\nexport default CheckboxInput\n"],"names":["injectMessages","messages","props","_otherProps$onFocus","input","label","labelId","onChange","shouldClearValueOnUnmount","meta","children","_props$shouldChangeVa","shouldChangeValue","_props$errorClassName","errorClassName","otherProps","_objectWithoutProperties","_excluded","isMobile","useDeviceType","useMount","undefined","touched","error","_jsx","Checkbox","_objectSpread","_state","event","onFocus","onBlur","value","checked","ErrorMessage","textId","concat","isVisible","className","InjectHtml","isRequired","customValidator","validate","getValidateFunction","validators","push","isCheckboxRequired","Field","type","fieldProps","CheckboxFieldView"],"sourceRoot":""}