@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.5.2",
3
+ "version": "10.5.3",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
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
- <FormInput
72
- labelTextWhenNoError={li.description}
69
+ <PartialAmountField
73
70
  key={li.id}
71
+ lineItem={li}
74
72
  field={fields[li.id]}
75
- fieldActions={actions.fields[li.id]}
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) || section.disabled
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 && supportsTouch && !section.disabled
104
+ isMobile &&
105
+ supportsTouch &&
106
+ !section.disabled &&
107
+ section.id !== openSection
103
108
  ? () => toggleOpenSection(section.id)
104
109
  : noop
105
110
  }