homeflowjs 1.1.3 → 1.1.4
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.
package/package.json
CHANGED
|
@@ -72,6 +72,7 @@ const RentYieldCalculator = ({
|
|
|
72
72
|
currency,
|
|
73
73
|
grossYieldTitle,
|
|
74
74
|
netYieldTitle,
|
|
75
|
+
showThousandSeparator,
|
|
75
76
|
}) => {
|
|
76
77
|
const customFieldsConfigsList = useMemo(() => initialFieldsConfigsList
|
|
77
78
|
.map((fieldConfig) => {
|
|
@@ -134,6 +135,7 @@ const RentYieldCalculator = ({
|
|
|
134
135
|
rangeStylesConfigs={rangeStylesConfigs}
|
|
135
136
|
inputPrefixString={currency}
|
|
136
137
|
onRangeInputUpdate={onFormDataUpdate}
|
|
138
|
+
showThousandSeparator={showThousandSeparator}
|
|
137
139
|
/>
|
|
138
140
|
</div>
|
|
139
141
|
))}
|
|
@@ -163,6 +165,7 @@ RentYieldCalculator.defaultProps = {
|
|
|
163
165
|
currency: '£',
|
|
164
166
|
grossYieldTitle: 'Gross Yield',
|
|
165
167
|
netYieldTitle: 'Net Yield',
|
|
168
|
+
showThousandSeparator: true,
|
|
166
169
|
};
|
|
167
170
|
|
|
168
171
|
const FieldConfigType = PropTypes.shape({
|
|
@@ -182,6 +185,7 @@ RentYieldCalculator.propTypes = {
|
|
|
182
185
|
currency: PropTypes.string,
|
|
183
186
|
grossYieldTitle: PropTypes.string,
|
|
184
187
|
netYieldTitle: PropTypes.string,
|
|
188
|
+
showThousandSeparator: PropTypes.bool,
|
|
185
189
|
};
|
|
186
190
|
|
|
187
191
|
export default memo(RentYieldCalculator);
|
|
@@ -18,9 +18,21 @@ const RangeInput = ({
|
|
|
18
18
|
rangeStylesConfigs,
|
|
19
19
|
inputPrefixString,
|
|
20
20
|
onRangeInputUpdate,
|
|
21
|
+
showThousandSeparator,
|
|
21
22
|
}) => {
|
|
23
|
+
|
|
24
|
+
const withThousandSeparator = (number) => {
|
|
25
|
+
if (!showThousandSeparator) {
|
|
26
|
+
return inputPrefixString ? `${inputPrefixString} ${number}` : `${number}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const separatedNumber = new Intl.NumberFormat().format(number);
|
|
30
|
+
|
|
31
|
+
return inputPrefixString ? `${inputPrefixString} ${separatedNumber}` : `${separatedNumber}`;
|
|
32
|
+
};
|
|
33
|
+
|
|
22
34
|
const [valueConfig, setValueConfig] = useState({
|
|
23
|
-
inputValue:
|
|
35
|
+
inputValue: withThousandSeparator(0),
|
|
24
36
|
rangeValue: 0,
|
|
25
37
|
});
|
|
26
38
|
|
|
@@ -35,9 +47,7 @@ const RangeInput = ({
|
|
|
35
47
|
useEffect(() => {
|
|
36
48
|
const validatedValue = onValidateValue(Number(inititalValue));
|
|
37
49
|
setValueConfig({
|
|
38
|
-
inputValue:
|
|
39
|
-
? `${inputPrefixString} ${validatedValue}`
|
|
40
|
-
: `${validatedValue}`,
|
|
50
|
+
inputValue: withThousandSeparator(validatedValue),
|
|
41
51
|
rangeValue: validatedValue,
|
|
42
52
|
});
|
|
43
53
|
}, []);
|
|
@@ -47,15 +57,12 @@ const RangeInput = ({
|
|
|
47
57
|
const currentValue = isRangeValue ? value[0] : value;
|
|
48
58
|
const digitValue = isRangeValue
|
|
49
59
|
? currentValue
|
|
50
|
-
: currentValue.
|
|
60
|
+
: currentValue.replace(`${inputPrefixString} `, '').replaceAll(',', '');
|
|
61
|
+
|
|
62
|
+
if (isNaN(digitValue)) return;
|
|
51
63
|
|
|
52
|
-
if (isNaN(digitValue)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
64
|
const validatedValue = onValidateValue(Number(digitValue));
|
|
56
|
-
const inputValue =
|
|
57
|
-
? `${inputPrefixString} ${validatedValue}`
|
|
58
|
-
: `${validatedValue}`;
|
|
65
|
+
const inputValue = withThousandSeparator(validatedValue);
|
|
59
66
|
const rangeValue = Number(validatedValue);
|
|
60
67
|
|
|
61
68
|
setValueConfig((prevState) => ({
|
|
@@ -116,6 +123,7 @@ RangeInput.propTypes = {
|
|
|
116
123
|
inititalValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
117
124
|
inputPrefixString: PropTypes.string,
|
|
118
125
|
onRangeInputUpdate: PropTypes.func,
|
|
126
|
+
showThousandSeparator: PropTypes.bool.isRequired,
|
|
119
127
|
...RANGE_CONTROLLER_PROP_TYPES,
|
|
120
128
|
};
|
|
121
129
|
|