@homefile/components-v2 2.24.11 → 2.24.13

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,17 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Controller, useFormContext } from 'react-hook-form';
3
+ import { NumericFormat } from 'react-number-format';
3
4
  import { Flex, Input } from '@chakra-ui/react';
4
5
  import { FormIcon, LabeledField } from '../../..';
5
- import { formatCurrency } from '../../../../utils';
6
6
  export const CurrencyField = ({ label, id, icon, placeholder, value, }) => {
7
7
  const { control } = useFormContext();
8
- return (_jsxs(Flex, { align: "center", gap: "base", flex: "auto", children: [_jsx(FormIcon, { icon: icon }), _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
9
- const handleChange = (e) => {
10
- const { value } = e.target;
11
- const number = Number(value.replace(/[^0-9]+/g, '')) / 100;
12
- const currency = formatCurrency({ value: number });
13
- onChange(currency);
14
- };
15
- return (_jsx(LabeledField, { label: label, children: _jsx(Input, { onChange: handleChange, placeholder: placeholder, textAlign: "right", value: value, _placeholder: { color: 'gray.2' } }) }));
8
+ return (_jsxs(Flex, { align: "center", gap: "base", flex: "auto", children: [_jsx(FormIcon, { icon: icon }), _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field }) => {
9
+ return (_jsx(LabeledField, { label: label, children: _jsx(NumericFormat, Object.assign({}, field, { customInput: Input, thousandSeparator: true, decimalScale: 2, fixedDecimalScale: true, prefix: "$", placeholder: placeholder, textAlign: "right", _placeholder: { color: 'gray.2' }, onValueChange: ({ floatValue }) => {
10
+ field.onChange(floatValue);
11
+ } })) }));
16
12
  } })] }));
17
13
  };
@@ -11,7 +11,7 @@ export default {
11
11
  amount: 0,
12
12
  maturityDate: '2025-04-17T00:00:00.000Z',
13
13
  documentDate: '2017-04-17T00:00:00.000Z',
14
- estimatedMortgageBalance: 0,
14
+ estimatedMortgageBalance: 295847.12,
15
15
  estimatedMortgagePayment: 0,
16
16
  interestRate: 0,
17
17
  interestRateType: '',
@@ -104,7 +104,7 @@ export const joinDayMonthYear = (value) => {
104
104
  });
105
105
  };
106
106
  export const formatISODate = (value) => {
107
- const displayValue = isValid(parseISO(value))
107
+ const displayValue = (isValid(parseISO(value)) || isValid(new Date(value)))
108
108
  ? format(value, 'MM/dd/yyyy')
109
109
  : '';
110
110
  return displayValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.24.11",
3
+ "version": "2.24.13",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -76,6 +76,7 @@
76
76
  "react-i18next": "^15.4.0",
77
77
  "react-icons": "^5.4.0",
78
78
  "react-modern-calendar-datepicker": "^3.1.6",
79
+ "react-number-format": "^5.4.4",
79
80
  "react-quill-new": "^3.3.3",
80
81
  "react-spinners": "^0.15.0",
81
82
  "recharts": "^2.15.0",
@@ -1,8 +1,8 @@
1
1
  import { Controller, useFormContext } from 'react-hook-form'
2
+ import {NumericFormat} from 'react-number-format'
2
3
  import { Flex, Input } from '@chakra-ui/react'
3
4
  import { TextFieldI } from '@/interfaces'
4
5
  import { FormIcon, LabeledField } from '@/components'
5
- import { formatCurrency } from '@/utils'
6
6
 
7
7
  export const CurrencyField = ({
8
8
  label,
@@ -20,21 +20,22 @@ export const CurrencyField = ({
20
20
  control={control}
21
21
  name={id}
22
22
  defaultValue={value}
23
- render={({ field: { value, onChange } }) => {
24
- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
25
- const { value } = e.target
26
- const number = Number(value.replace(/[^0-9]+/g, '')) / 100
27
- const currency = formatCurrency({ value: number })
28
- onChange(currency)
29
- }
23
+ render={({ field}) => {
30
24
  return (
31
25
  <LabeledField label={label}>
32
- <Input
33
- onChange={handleChange}
26
+ <NumericFormat
27
+ {...field}
28
+ customInput={Input}
29
+ thousandSeparator
30
+ decimalScale={2}
31
+ fixedDecimalScale
32
+ prefix="$"
34
33
  placeholder={placeholder}
35
34
  textAlign="right"
36
- value={value}
37
35
  _placeholder={{ color: 'gray.2' }}
36
+ onValueChange={({ floatValue }) => {
37
+ field.onChange(floatValue)
38
+ }}
38
39
  />
39
40
  </LabeledField>
40
41
  )
@@ -13,7 +13,7 @@ export default {
13
13
  amount: 0,
14
14
  maturityDate: '2025-04-17T00:00:00.000Z',
15
15
  documentDate: '2017-04-17T00:00:00.000Z',
16
- estimatedMortgageBalance: 0,
16
+ estimatedMortgageBalance: 295847.12,
17
17
  estimatedMortgagePayment: 0,
18
18
  interestRate: 0,
19
19
  interestRateType: '',
@@ -142,7 +142,7 @@ interface FormatCurrencyI {
142
142
  }
143
143
 
144
144
  export const formatISODate = (value: string) => {
145
- const displayValue = isValid(parseISO(value))
145
+ const displayValue = (isValid(parseISO(value)) || isValid(new Date(value)))
146
146
  ? format(value, 'MM/dd/yyyy')
147
147
  : ''
148
148