@thecb/components 10.5.2 → 10.5.3
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/dist/index.cjs.js +41 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +41 -18
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/molecules/partial-amount-form/PartialAmountField.js +49 -0
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +8 -22
- package/src/components/molecules/radio-section/InnerRadioSection.js +7 -2
- package/src/components/atoms/icons/.DS_Store +0 -0
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { equals } from "ramda";
|
|
3
|
+
import { FormInput } from "../../atoms/form-layouts";
|
|
4
|
+
import { displayCurrency } from "../../../util/general";
|
|
5
|
+
import Text from "../../atoms/text";
|
|
6
|
+
|
|
7
|
+
const PartialAmountField = ({
|
|
8
|
+
lineItem,
|
|
9
|
+
field,
|
|
10
|
+
showErrors,
|
|
11
|
+
errorMessages,
|
|
12
|
+
moneyFormat,
|
|
13
|
+
fieldActions
|
|
14
|
+
}) => (
|
|
15
|
+
<FormInput
|
|
16
|
+
labelTextWhenNoError={lineItem.description}
|
|
17
|
+
key={lineItem.id}
|
|
18
|
+
field={field}
|
|
19
|
+
fieldActions={fieldActions}
|
|
20
|
+
showErrors={showErrors}
|
|
21
|
+
errorMessages={errorMessages}
|
|
22
|
+
style={{ textAlign: "right" }}
|
|
23
|
+
placeholder="$0.00"
|
|
24
|
+
formatter={moneyFormat}
|
|
25
|
+
isNum
|
|
26
|
+
decorator={
|
|
27
|
+
<Text variant="p">
|
|
28
|
+
Amount owed:{" "}
|
|
29
|
+
{
|
|
30
|
+
<Text variant="p" weight="600">
|
|
31
|
+
{displayCurrency(lineItem.amount)}
|
|
32
|
+
</Text>
|
|
33
|
+
}
|
|
34
|
+
</Text>
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
function arePropsEqual(prevProps, nextProps) {
|
|
40
|
+
return (
|
|
41
|
+
equals(prevProps.errorMessages, nextProps.errorMessages) &&
|
|
42
|
+
equals(prevProps.field, nextProps.field) &&
|
|
43
|
+
equals(prevProps.showErrors, nextProps.showErrors) &&
|
|
44
|
+
equals(prevProps.moneyFormat, nextProps.moneyFormat) &&
|
|
45
|
+
equals(prevProps.lineItem, nextProps.lineItem)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default React.memo(PartialAmountField, arePropsEqual);
|
|
@@ -4,13 +4,11 @@ import {
|
|
|
4
4
|
numberGreaterThanOrEqualTo,
|
|
5
5
|
numberLessThanOrEqualTo
|
|
6
6
|
} from "redux-freeform";
|
|
7
|
+
|
|
8
|
+
import PartialAmountField from "./PartialAmountField";
|
|
7
9
|
import { displayCurrency } from "../../../util/general";
|
|
8
10
|
import Text from "../../atoms/text";
|
|
9
|
-
import {
|
|
10
|
-
FormInput,
|
|
11
|
-
FormInputColumn,
|
|
12
|
-
FormContainer
|
|
13
|
-
} from "../../atoms/form-layouts";
|
|
11
|
+
import { FormInputColumn, FormContainer } from "../../atoms/form-layouts";
|
|
14
12
|
import { moneyFormat } from "../../../util/formats";
|
|
15
13
|
|
|
16
14
|
const PartialAmountForm = ({
|
|
@@ -68,27 +66,15 @@ const PartialAmountForm = ({
|
|
|
68
66
|
<div style={{ height: "16px" }}></div>
|
|
69
67
|
<FormInputColumn>
|
|
70
68
|
{lineItemsNew.map(li => (
|
|
71
|
-
<
|
|
72
|
-
labelTextWhenNoError={li.description}
|
|
69
|
+
<PartialAmountField
|
|
73
70
|
key={li.id}
|
|
71
|
+
lineItem={li}
|
|
74
72
|
field={fields[li.id]}
|
|
75
|
-
|
|
73
|
+
actions={actions}
|
|
76
74
|
showErrors={showErrors}
|
|
75
|
+
moneyFormat={moneyFormat}
|
|
76
|
+
fieldActions={actions.fields[li.id]}
|
|
77
77
|
errorMessages={getPartialAmountFormErrors(li.amount)}
|
|
78
|
-
style={{ textAlign: "right" }}
|
|
79
|
-
placeholder="$0.00"
|
|
80
|
-
formatter={moneyFormat}
|
|
81
|
-
isNum
|
|
82
|
-
decorator={
|
|
83
|
-
<Text variant="p">
|
|
84
|
-
Amount owed:{" "}
|
|
85
|
-
{
|
|
86
|
-
<Text variant="p" weight="600">
|
|
87
|
-
{displayCurrency(li.amount)}
|
|
88
|
-
</Text>
|
|
89
|
-
}
|
|
90
|
-
</Text>
|
|
91
|
-
}
|
|
92
78
|
/>
|
|
93
79
|
))}
|
|
94
80
|
</FormInputColumn>
|
|
@@ -94,12 +94,17 @@ const InnerRadioSection = ({
|
|
|
94
94
|
aria-labelledby={ariaLabelledBy}
|
|
95
95
|
aria-describedby={ariaDescribedBy}
|
|
96
96
|
onClick={
|
|
97
|
-
(isMobile && supportsTouch) ||
|
|
97
|
+
(isMobile && supportsTouch) ||
|
|
98
|
+
section.disabled ||
|
|
99
|
+
section.id === openSection
|
|
98
100
|
? noop
|
|
99
101
|
: () => toggleOpenSection(section.id)
|
|
100
102
|
}
|
|
101
103
|
onTouchEnd={
|
|
102
|
-
isMobile &&
|
|
104
|
+
isMobile &&
|
|
105
|
+
supportsTouch &&
|
|
106
|
+
!section.disabled &&
|
|
107
|
+
section.id !== openSection
|
|
103
108
|
? () => toggleOpenSection(section.id)
|
|
104
109
|
: noop
|
|
105
110
|
}
|
|
Binary file
|