@homefile/components-v2 2.14.9 → 2.14.10
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TextFieldI } from '../../../../interfaces';
|
|
2
|
-
export declare const NumberField: ({ id, label, placeholder, value }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const NumberField: ({ description, icon, id, label, placeholder, value, }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Controller, useFormContext } from 'react-hook-form';
|
|
3
3
|
import { Flex, Input } from '@chakra-ui/react';
|
|
4
|
-
import { LabeledField } from '../../..';
|
|
5
|
-
export const NumberField = ({ id, label, placeholder, value }) => {
|
|
4
|
+
import { FieldDescription, LabeledField } from '../../..';
|
|
5
|
+
export const NumberField = ({ description, icon, id, label, placeholder, value, }) => {
|
|
6
6
|
const { control } = useFormContext();
|
|
7
|
-
return (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
return (_jsxs(Flex, { align: "center", gap: "base", flex: "auto", children: [_jsx(FieldDescription, { description: description, icon: icon }), _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
|
|
8
|
+
return (_jsx(LabeledField, { label: label, children: _jsx(Input, { onChange: (e) => {
|
|
9
|
+
const value = e.target.valueAsNumber;
|
|
10
|
+
const isNumber = !isNaN(value);
|
|
11
|
+
if (!isNumber) {
|
|
12
|
+
onChange('');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
onChange(value);
|
|
16
|
+
}
|
|
17
|
+
}, placeholder: placeholder, type: "number", pattern: "[1-9]", value: value, textAlign: "right", _placeholder: { color: 'gray.2' } }) }));
|
|
18
|
+
} })] }));
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { Controller, useFormContext } from 'react-hook-form'
|
|
2
2
|
import { Flex, Input } from '@chakra-ui/react'
|
|
3
3
|
import { TextFieldI } from '@/interfaces'
|
|
4
|
-
import { LabeledField } from '@/components'
|
|
4
|
+
import { FieldDescription, LabeledField } from '@/components'
|
|
5
5
|
|
|
6
|
-
export const NumberField = ({
|
|
6
|
+
export const NumberField = ({
|
|
7
|
+
description,
|
|
8
|
+
icon,
|
|
9
|
+
id,
|
|
10
|
+
label,
|
|
11
|
+
placeholder,
|
|
12
|
+
value,
|
|
13
|
+
}: TextFieldI) => {
|
|
7
14
|
const { control } = useFormContext()
|
|
8
15
|
return (
|
|
9
16
|
<Flex align="center" gap="base" flex="auto">
|
|
17
|
+
<FieldDescription description={description} icon={icon} />
|
|
10
18
|
<Controller
|
|
11
19
|
control={control}
|
|
12
20
|
name={id}
|