import { jsx as _jsx } from "react/jsx-runtime";
import { Controller } from "react-hook-form";
import { NumericalInput } from "../NumericalInput.native.js";
import { useFormContext } from "./context.native.js";
function FormNumericalInput(param) {
  var {
      id,
      helperText,
      error: defaultError,
      ...props
    } = param,
    _errors_id,
    {
      control,
      formState: {
        errors
      },
      disabled
    } = useFormContext(),
    error = !!errors[id] || defaultError,
    supportingText = (errors == null || (_errors_id = errors[id]) === null || _errors_id === void 0 ? void 0 : _errors_id.message) || helperText;
  return /* @__PURE__ */_jsx(Controller, {
    control,
    name: id,
    render: function (param2) {
      var {
          field
        } = param2,
        _field_value;
      return /* @__PURE__ */_jsx(NumericalInput, {
        ...props,
        fg: 1,
        disabled: disabled || props?.disabled,
        onChangeText: function (e) {
          var newValue = e?.replace(/[^0-9.]/g, "").replace(/(\..*)\./g, "$1");
          field?.onChange(newValue);
        },
        value: field == null || (_field_value = field.value) === null || _field_value === void 0 ? void 0 : _field_value.toString(),
        onValueChange: function (v) {
          return field?.onChange(v);
        },
        onBlur: field?.onBlur,
        id,
        error,
        supportingText
      });
    }
  });
}
export { FormNumericalInput };
//# sourceMappingURL=FormNumericalInput.native.js.map
