@homefile/components-v2 2.24.12 → 2.24.14

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
  };
@@ -10,6 +10,6 @@ export const ReceiptItems = ({ isSelectDisabled = true, leftOptions = [], onItem
10
10
  });
11
11
  return (_jsxs(Box, { mb: "10rem", children: [_jsxs(Stack, { bg: "lightBlue.2", px: "4", pb: "base", pt: "2", children: [_jsx(Text, { textTransform: "uppercase", variant: "home", children: title }), _jsxs(Flex, { gap: "base", align: "center", children: [_jsx(Checkbox, { onChange: handleSelectAll }), _jsx(DoubleSelects, { isSelectDisabled: isSelectDisabled, leftOptions: leftOptions, rightOptions: rightOptions, onLeftSelectChange: onLeftSelectChange, onRightSelectChange: onRightSelectChange })] })] }), receipts.map((receipt) => {
12
12
  const hasRoomType = !!(receipt === null || receipt === void 0 ? void 0 : receipt.roomType);
13
- return (_jsxs(Box, { children: [!hasRoomType && (_jsx(ReceiptItem, Object.assign({ onChange: () => handleItemSelect(receipt._id), isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, onEditClick: () => onEditReceipt === null || onEditReceipt === void 0 ? void 0 : onEditReceipt(receipt.sku), selectItems: receiptOptions, variant: variant }, receipt))), hasRoomType && (_jsx(ReceiptItemAssigned, Object.assign({ onChange: () => handleItemSelect(receipt._id), onRoomClick: onRoomClick, isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, initialSelectValue: receiptOptions === null || receiptOptions === void 0 ? void 0 : receiptOptions[1], selectItems: receiptOptions, variant: variant }, receipt)))] }, receipt._id));
13
+ return (_jsxs(Box, { children: [!hasRoomType && (_jsx(ReceiptItem, Object.assign({ onChange: () => handleItemSelect(receipt._id), isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, onEditClick: () => onEditReceipt === null || onEditReceipt === void 0 ? void 0 : onEditReceipt(receipt._id), selectItems: receiptOptions, variant: variant }, receipt))), hasRoomType && (_jsx(ReceiptItemAssigned, Object.assign({ onChange: () => handleItemSelect(receipt._id), onRoomClick: onRoomClick, isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, initialSelectValue: receiptOptions === null || receiptOptions === void 0 ? void 0 : receiptOptions[1], selectItems: receiptOptions, variant: variant }, receipt)))] }, receipt._id));
14
14
  })] }));
15
15
  };
@@ -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: '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.24.12",
3
+ "version": "2.24.14",
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
  )
@@ -51,7 +51,7 @@ export const ReceiptItems = ({
51
51
  onChange={() => handleItemSelect(receipt._id)}
52
52
  isChecked={isItemSelected(receipt._id)}
53
53
  onSelectedChange={onReceiptSelectedChange}
54
- onEditClick={() => onEditReceipt?.(receipt.sku)}
54
+ onEditClick={() => onEditReceipt?.(receipt._id)}
55
55
  selectItems={receiptOptions}
56
56
  variant={variant}
57
57
  {...receipt}
@@ -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: '',