Skip to content

Commit

Permalink
feat: valueAsNumber for number type inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTK committed Jul 12, 2023
1 parent 78721df commit ccadf02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/short-days-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"protobuf-auto-form": patch
---

feat: valueAsNumber for number type inputs
4 changes: 3 additions & 1 deletion packages/core/src/protobuf/input/primitive/Basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const BasicInput: React.FC<Props> = ({
error,
}) => {
const { register } = useFormContext();
const inputType = getInputType(type as BasicType);

return (
<input
Expand All @@ -61,8 +62,9 @@ const BasicInput: React.FC<Props> = ({
: options?.rules?.validate),
...(validate && { autoformValidation: validate }),
},
valueAsNumber: inputType === 'number',
})}
type={getInputType(type as BasicType)}
type={inputType}
placeholder={type}
step="any"
readOnly={options?.readOnly}
Expand Down

0 comments on commit ccadf02

Please sign in to comment.