{"version":3,"sources":["../../../components/form/hook-time-input.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { Controller, FieldValues, RegisterOptions, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTimeInput } from './time-input';\nimport type { FormTimeInputProps } from './time-input';\n\ntype HookFormTimeInputProps<T extends FieldValues> = Omit<FormTimeInputProps, 'name' | 'inputProps'> & {\n  name: Path<T>;\n  rules?: RegisterOptions<T, Path<T>>;\n  error?: string;\n};\n\nexport function HookFormTimeInput<T extends FieldValues>({\n  id,\n  name,\n  rules,\n  label,\n  error,\n  classNames,\n  disabled,\n  ...rest\n}: HookFormTimeInputProps<T>) {\n  const methods = useFormContext<T>();\n  if (!methods) return null;\n\n  const {\n    control,\n    formState: { errors },\n  } = methods;\n\n  const fieldError = _get(errors, name);\n  const errorMessage = error ?? (fieldError?.message as string);\n  const showError = !!fieldError && !disabled;\n\n  return (\n    <div className={cn('$hook-form-time-input', classNames?.wrapper)}>\n      <Controller\n        name={name}\n        control={control}\n        rules={rules}\n        render={({ field: { onChange, onBlur, value } }) => (\n          <FormTimeInput\n            {...rest}\n            name={name}\n            label={label}\n            value={value}\n            onChange={onChange}\n            onBlur={onBlur}\n            disabled={disabled}\n            classNames={{\n              label: cn(classNames?.label, {\n                'text-danger': showError,\n              }),\n              input: cn(classNames?.input, {\n                'ring-danger text-danger': showError,\n              }),\n            }}\n          />\n        )}\n      />\n      {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n    </div>\n  );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAAS,YAAgD,sBAAsB;AAYxE,SAAS,kBAAyC,IAS3B;AAT2B,eACvD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAtBF,IAeyD,IAQpD,iBARoD,IAQpD;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,UAAU,eAAkB;AAClC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,OAAO;AAAA,EACtB,IAAI;AAEJ,QAAM,aAAa,KAAK,QAAQ,IAAI;AACpC,QAAM,eAAe,wBAAU,yCAAY;AAC3C,QAAM,YAAY,CAAC,CAAC,cAAc,CAAC;AAEnC,SACE,oCAAC,SAAI,WAAW,GAAG,yBAAyB,yCAAY,OAAO,KAC7D;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,CAAC,EAAE,OAAO,EAAE,UAAU,QAAQ,MAAM,EAAE,MAC5C;AAAA,QAAC;AAAA,yCACK,OADL;AAAA,UAEC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,YAAY;AAAA,YACV,OAAO,GAAG,yCAAY,OAAO;AAAA,cAC3B,eAAe;AAAA,YACjB,CAAC;AAAA,YACD,OAAO,GAAG,yCAAY,OAAO;AAAA,cAC3B,2BAA2B;AAAA,YAC7B,CAAC;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EAEJ,GACC,aAAa,oCAAC,aAAU,OAAO,MAAM,WAAU,QAAO,SAAS,cAAc,CAChF;AAEJ;","names":[]}