@thecb/components 4.1.25 → 4.1.28
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 +36 -5
- package/package.json +1 -1
- package/src/components/atoms/form-layouts/FormFooterPanel.js +29 -0
- package/src/components/atoms/form-layouts/FormLayouts.theme.js +7 -2
- package/src/components/atoms/form-layouts/index.js +8 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +2 -2
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +2 -2
- package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +3 -2
package/dist/index.cjs.js
CHANGED
|
@@ -20484,6 +20484,9 @@ var hoverFocusStyles$1 = {
|
|
|
20484
20484
|
"default": "color: #0E506D; outline: none; text-decoration: underline; ",
|
|
20485
20485
|
disabled: "color: #6E727E;"
|
|
20486
20486
|
};
|
|
20487
|
+
var formFooterPanel = {
|
|
20488
|
+
"default": "".concat(INFO_BLUE)
|
|
20489
|
+
};
|
|
20487
20490
|
var fallbackValues$h = {
|
|
20488
20491
|
linkColor: linkColor$2,
|
|
20489
20492
|
formBackgroundColor: formBackgroundColor$1,
|
|
@@ -20495,7 +20498,8 @@ var fallbackValues$h = {
|
|
|
20495
20498
|
fontSize: fontSize$6,
|
|
20496
20499
|
errorFontSize: errorFontSize$1,
|
|
20497
20500
|
fontWeight: fontWeight$3,
|
|
20498
|
-
hoverFocusStyles: hoverFocusStyles$1
|
|
20501
|
+
hoverFocusStyles: hoverFocusStyles$1,
|
|
20502
|
+
formFooterPanel: formFooterPanel
|
|
20499
20503
|
};
|
|
20500
20504
|
|
|
20501
20505
|
function _templateObject4$3() {
|
|
@@ -20765,6 +20769,30 @@ var FormContainer = function FormContainer(_ref) {
|
|
|
20765
20769
|
|
|
20766
20770
|
var FormContainer$1 = themeComponent(withWindowSize(FormContainer), "FormContainer", fallbackValues$h, "default");
|
|
20767
20771
|
|
|
20772
|
+
var FormFooterPanel = function FormFooterPanel(_ref) {
|
|
20773
|
+
var themeValues = _ref.themeValues,
|
|
20774
|
+
link = _ref.link,
|
|
20775
|
+
linkText = _ref.linkText;
|
|
20776
|
+
|
|
20777
|
+
var _useContext = React.useContext(styled.ThemeContext),
|
|
20778
|
+
isMobile = _useContext.isMobile;
|
|
20779
|
+
|
|
20780
|
+
return /*#__PURE__*/React__default.createElement(Box, {
|
|
20781
|
+
background: themeValues.formFooterPanel,
|
|
20782
|
+
minWidth: "100%",
|
|
20783
|
+
padding: isMobile ? "1.5rem" : "2rem"
|
|
20784
|
+
}, /*#__PURE__*/React__default.createElement(Cluster, {
|
|
20785
|
+
justify: "center",
|
|
20786
|
+
align: "center"
|
|
20787
|
+
}, /*#__PURE__*/React__default.createElement(ButtonWithLink, {
|
|
20788
|
+
url: link,
|
|
20789
|
+
variant: "smallGhost",
|
|
20790
|
+
text: linkText
|
|
20791
|
+
})));
|
|
20792
|
+
};
|
|
20793
|
+
|
|
20794
|
+
var FormFooterPanel$1 = themeComponent(withWindowSize(FormFooterPanel), "FormFooterPanel", fallbackValues$h, "default");
|
|
20795
|
+
|
|
20768
20796
|
var fontSize$7 = {
|
|
20769
20797
|
"default": "1rem",
|
|
20770
20798
|
radio: "1.0625rem"
|
|
@@ -38538,7 +38566,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
38538
38566
|
}, []);
|
|
38539
38567
|
}
|
|
38540
38568
|
|
|
38541
|
-
var amountErrors = (_amountErrors = {}, _defineProperty(_amountErrors, required.error, "Amount is required"), _defineProperty(_amountErrors,
|
|
38569
|
+
var amountErrors = (_amountErrors = {}, _defineProperty(_amountErrors, required.error, "Amount is required"), _defineProperty(_amountErrors, numberGreaterThanOrEqualTo.error, "Your total payment must be greater than or equal to ".concat(displayCurrency(minimum))), _defineProperty(_amountErrors, numberLessThanOrEqualTo.error, "Your total payment must be less than ".concat(displayCurrency(maximum))), _amountErrors);
|
|
38542
38570
|
var lineItemsNew = Array.isArray(lineItems) ? lineItems : [];
|
|
38543
38571
|
return /*#__PURE__*/React__default.createElement(FormContainer$1, {
|
|
38544
38572
|
variant: variant,
|
|
@@ -38577,7 +38605,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
38577
38605
|
var createPartialAmountFormState = function createPartialAmountFormState(lineItems, maximum) {
|
|
38578
38606
|
var minimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
38579
38607
|
var formConfig = lineItems.reduce(function (acc, item) {
|
|
38580
|
-
var validators = [required(), validateSum(
|
|
38608
|
+
var validators = [required(), validateSum(numberGreaterThanOrEqualTo(minimum), lineItems.filter(function (lineItem) {
|
|
38581
38609
|
return lineItem != item;
|
|
38582
38610
|
}).reduce(function (acc, curr) {
|
|
38583
38611
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
@@ -38752,7 +38780,9 @@ var PaymentButtonBar = function PaymentButtonBar(_ref) {
|
|
|
38752
38780
|
redirectURL = _ref.redirectURL,
|
|
38753
38781
|
_ref$redirectText = _ref.redirectText,
|
|
38754
38782
|
redirectText = _ref$redirectText === void 0 ? "Return" : _ref$redirectText,
|
|
38755
|
-
buttonFlexOverride = _ref.buttonFlexOverride
|
|
38783
|
+
buttonFlexOverride = _ref.buttonFlexOverride,
|
|
38784
|
+
_ref$hideForwardButto = _ref.hideForwardButton,
|
|
38785
|
+
hideForwardButton = _ref$hideForwardButto === void 0 ? false : _ref$hideForwardButto;
|
|
38756
38786
|
|
|
38757
38787
|
var _useContext = React.useContext(styled.ThemeContext),
|
|
38758
38788
|
isMobile = _useContext.isMobile;
|
|
@@ -38792,7 +38822,7 @@ var PaymentButtonBar = function PaymentButtonBar(_ref) {
|
|
|
38792
38822
|
justify: buttonFlexOverride ? buttonFlexOverride : !!backButton ? "space-between" : "flex-end",
|
|
38793
38823
|
align: "center",
|
|
38794
38824
|
childGap: "0.75rem"
|
|
38795
|
-
}, backButton, forwardButton)));
|
|
38825
|
+
}, backButton, !hideForwardButton && /*#__PURE__*/React__default.createElement(React.Fragment, null, forwardButton))));
|
|
38796
38826
|
};
|
|
38797
38827
|
|
|
38798
38828
|
var backgroundColor$8 = {
|
|
@@ -40598,6 +40628,7 @@ exports.FailedIcon = FailedIcon;
|
|
|
40598
40628
|
exports.ForgotPasswordForm = ForgotPasswordForm;
|
|
40599
40629
|
exports.ForgotPasswordIcon = ForgotPasswordIcon$1;
|
|
40600
40630
|
exports.FormContainer = FormContainer$1;
|
|
40631
|
+
exports.FormFooterPanel = FormFooterPanel$1;
|
|
40601
40632
|
exports.FormInput = FormInput$1;
|
|
40602
40633
|
exports.FormInputColumn = FormInputColumn;
|
|
40603
40634
|
exports.FormInputRow = FormInputRow;
|
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { ThemeContext } from "styled-components";
|
|
3
|
+
import { fallbackValues } from "./FormLayouts.theme.js";
|
|
4
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
5
|
+
import { Box, Cluster } from "../layouts";
|
|
6
|
+
import ButtonWithLink from "../button-with-link";
|
|
7
|
+
import withWindowSize from "../../withWindowSize";
|
|
8
|
+
|
|
9
|
+
const FormFooterPanel = ({ themeValues, link, linkText }) => {
|
|
10
|
+
const { isMobile } = useContext(ThemeContext);
|
|
11
|
+
return (
|
|
12
|
+
<Box
|
|
13
|
+
background={themeValues.formFooterPanel}
|
|
14
|
+
minWidth="100%"
|
|
15
|
+
padding={isMobile ? "1.5rem" : "2rem"}
|
|
16
|
+
>
|
|
17
|
+
<Cluster justify="center" align="center">
|
|
18
|
+
<ButtonWithLink url={link} variant="smallGhost" text={linkText} />
|
|
19
|
+
</Cluster>
|
|
20
|
+
</Box>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default themeComponent(
|
|
25
|
+
withWindowSize(FormFooterPanel),
|
|
26
|
+
"FormFooterPanel",
|
|
27
|
+
fallbackValues,
|
|
28
|
+
"default"
|
|
29
|
+
);
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
MINESHAFT_GREY,
|
|
7
7
|
DUSTY_GREY,
|
|
8
8
|
GREY_CHATEAU,
|
|
9
|
-
ATHENS_GREY
|
|
9
|
+
ATHENS_GREY,
|
|
10
|
+
INFO_BLUE
|
|
10
11
|
} from "../../../constants/colors";
|
|
11
12
|
import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
|
|
12
13
|
|
|
@@ -36,6 +37,9 @@ const hoverFocusStyles = {
|
|
|
36
37
|
default: `color: #0E506D; outline: none; text-decoration: underline; `,
|
|
37
38
|
disabled: `color: #6E727E;`
|
|
38
39
|
};
|
|
40
|
+
const formFooterPanel = {
|
|
41
|
+
default: `${INFO_BLUE}`
|
|
42
|
+
};
|
|
39
43
|
|
|
40
44
|
export const fallbackValues = {
|
|
41
45
|
linkColor,
|
|
@@ -48,5 +52,6 @@ export const fallbackValues = {
|
|
|
48
52
|
fontSize,
|
|
49
53
|
errorFontSize,
|
|
50
54
|
fontWeight,
|
|
51
|
-
hoverFocusStyles
|
|
55
|
+
hoverFocusStyles,
|
|
56
|
+
formFooterPanel
|
|
52
57
|
};
|
|
@@ -2,5 +2,12 @@ import FormInput from "./FormInput";
|
|
|
2
2
|
import FormInputRow from "./FormInputRow";
|
|
3
3
|
import FormInputColumn from "./FormInputColumn";
|
|
4
4
|
import FormContainer from "./FormContainer";
|
|
5
|
+
import FormFooterPanel from "./FormFooterPanel";
|
|
5
6
|
|
|
6
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
FormInput,
|
|
9
|
+
FormInputRow,
|
|
10
|
+
FormInputColumn,
|
|
11
|
+
FormContainer,
|
|
12
|
+
FormFooterPanel
|
|
13
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
3
|
required,
|
|
4
|
-
|
|
4
|
+
numberGreaterThanOrEqualTo,
|
|
5
5
|
numberLessThanOrEqualTo
|
|
6
6
|
} from "redux-freeform";
|
|
7
7
|
import { displayCurrency } from "../../../util/general";
|
|
@@ -29,7 +29,7 @@ const PartialAmountForm = ({
|
|
|
29
29
|
|
|
30
30
|
const amountErrors = {
|
|
31
31
|
[required.error]: "Amount is required",
|
|
32
|
-
[
|
|
32
|
+
[numberGreaterThanOrEqualTo.error]: `Your total payment must be greater than or equal to ${displayCurrency(
|
|
33
33
|
minimum
|
|
34
34
|
)}`,
|
|
35
35
|
[numberLessThanOrEqualTo.error]: `Your total payment must be less than ${displayCurrency(
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
required,
|
|
4
4
|
onlyNaturals,
|
|
5
5
|
validateSum,
|
|
6
|
-
|
|
6
|
+
numberGreaterThanOrEqualTo,
|
|
7
7
|
numberLessThanOrEqualTo
|
|
8
8
|
} from "redux-freeform";
|
|
9
9
|
|
|
@@ -16,7 +16,7 @@ export const createPartialAmountFormState = (
|
|
|
16
16
|
const validators = [
|
|
17
17
|
required(),
|
|
18
18
|
validateSum(
|
|
19
|
-
|
|
19
|
+
numberGreaterThanOrEqualTo(minimum),
|
|
20
20
|
lineItems
|
|
21
21
|
.filter(lineItem => lineItem != item)
|
|
22
22
|
.reduce((acc, curr) => [...acc, curr.id], [])
|
|
@@ -17,7 +17,8 @@ const PaymentButtonBar = ({
|
|
|
17
17
|
cancelText = "Cancel",
|
|
18
18
|
redirectURL,
|
|
19
19
|
redirectText = "Return",
|
|
20
|
-
buttonFlexOverride
|
|
20
|
+
buttonFlexOverride,
|
|
21
|
+
hideForwardButton = false
|
|
21
22
|
}) => {
|
|
22
23
|
const { isMobile } = useContext(ThemeContext);
|
|
23
24
|
|
|
@@ -80,7 +81,7 @@ const PaymentButtonBar = ({
|
|
|
80
81
|
childGap="0.75rem"
|
|
81
82
|
>
|
|
82
83
|
{backButton}
|
|
83
|
-
{forwardButton}
|
|
84
|
+
{!hideForwardButton && <Fragment>{forwardButton}</Fragment>}
|
|
84
85
|
</Cluster>
|
|
85
86
|
</Box>
|
|
86
87
|
</Fragment>
|