@uxf/form 10.0.0-beta.23 → 10.0.0-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,14 +2,12 @@ import { TextInputProps as UITextInputProps } from "@uxf/ui/text-input";
2
2
  import { FieldValues, UseControllerProps } from "react-hook-form";
3
3
  import React from "react";
4
4
  import { FormControlProps } from "@uxf/ui/types";
5
- type OnChangeHandler = FormControlProps<string>["onChange"];
6
5
  export type NumberInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UITextInputProps, "inputMode" | "isInvalid" | "maxLength" | "minLength" | "name" | "onChange" | "value" | "type"> & {
7
6
  decimalPlaces?: number;
8
- onChange?: OnChangeHandler;
7
+ onChange?: FormControlProps<number>["onChange"];
9
8
  requiredMessage?: string;
10
9
  };
11
10
  export declare function NumberInput<FormData extends FieldValues>(props: NumberInputProps<FormData>): React.JSX.Element;
12
11
  export declare namespace NumberInput {
13
12
  var displayName: string;
14
13
  }
15
- export {};
@@ -59,8 +59,9 @@ function NumberInput(props) {
59
59
  };
60
60
  const onChange = (value, event) => {
61
61
  var _a;
62
- field.onChange(value);
63
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
62
+ const parsedValue = props.decimalPlaces ? parseFloat(value) : parseInt(value, 10);
63
+ field.onChange(parsedValue);
64
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, parsedValue, event);
64
65
  };
65
66
  return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: id, inputMode: props.decimalPlaces ? "decimal" : "numeric", isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: onKeyDown, pattern: props.pattern, placeholder: props.placeholder, step: props.decimalPlaces ? Number(0).toFixed(props.decimalPlaces - 1) + "1" : props.step, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, type: "number", value: (_e = field.value) !== null && _e !== void 0 ? _e : "", variant: props.variant }));
66
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/form",
3
- "version": "10.0.0-beta.23",
3
+ "version": "10.0.0-beta.25",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,7 +12,7 @@
12
12
  "author": "UX Fans s.r.o",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@uxf/ui": "10.0.0-beta.22",
15
+ "@uxf/ui": "10.0.0-beta.25",
16
16
  "react-hook-form": "7.44.3",
17
17
  "coordinate-parser": "1.0.7"
18
18
  }