@comicrelief/component-library 7.24.0 → 7.24.2
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/.github/workflows/main.yml +22 -24
- package/dist/components/Atoms/Button/Button.js +21 -15
- package/dist/components/Atoms/Button/Button.test.js +3 -3
- package/dist/components/Atoms/ButtonWithStates/ButtonWithStates.js +19 -22
- package/dist/components/Atoms/Checkbox/Checkbox.js +42 -26
- package/dist/components/Atoms/Checkbox/Checkbox.test.js +3 -3
- package/dist/components/Atoms/Confetti/Confetti.js +20 -23
- package/dist/components/Atoms/Confetti/_TriggerConfetti.js +4 -11
- package/dist/components/Atoms/ErrorText/ErrorText.js +15 -11
- package/dist/components/Atoms/ErrorText/ErrorText.test.js +3 -3
- package/dist/components/Atoms/Icons/Arrow.js +16 -15
- package/dist/components/Atoms/Icons/AtSign.js +9 -9
- package/dist/components/Atoms/Icons/Chevron.js +16 -15
- package/dist/components/Atoms/Icons/Curve.js +16 -18
- package/dist/components/Atoms/Icons/Download.js +8 -8
- package/dist/components/Atoms/Icons/External.js +8 -8
- package/dist/components/Atoms/Icons/Favourite.js +8 -8
- package/dist/components/Atoms/Icons/Internal.js +8 -8
- package/dist/components/Atoms/Icons/index.js +8 -8
- package/dist/components/Atoms/Input/Input.js +38 -33
- package/dist/components/Atoms/Input/input.test.js +3 -3
- package/dist/components/Atoms/Label/Label.js +28 -23
- package/dist/components/Atoms/Link/Link.js +24 -29
- package/dist/components/Atoms/Link/Link.style.js +51 -40
- package/dist/components/Atoms/Link/Link.test.js +9 -9
- package/dist/components/Atoms/Logo/Logo.js +16 -18
- package/dist/components/Atoms/Logo/Logo.test.js +3 -3
- package/dist/components/Atoms/Pagination/Item/Item.js +7 -7
- package/dist/components/Atoms/Pagination/Item/Item.style.js +35 -28
- package/dist/components/Atoms/Pagination/List/List.js +21 -19
- package/dist/components/Atoms/Pagination/Pagination.js +41 -49
- package/dist/components/Atoms/Pagination/Pagination.test.js +54 -108
- package/dist/components/Atoms/Pagination/Utils/PaginationCalculator.js +15 -15
- package/dist/components/Atoms/Picture/Picture.js +34 -44
- package/dist/components/Atoms/Picture/Picture.test.js +5 -5
- package/dist/components/Atoms/RadioButton/RadioButton.js +35 -23
- package/dist/components/Atoms/RadioButton/RadioButton.test.js +3 -3
- package/dist/components/Atoms/RichText/RichText.js +9 -11
- package/dist/components/Atoms/RichText/RichText.test.js +4 -4
- package/dist/components/Atoms/Select/Select.js +56 -49
- package/dist/components/Atoms/Select/Select.test.js +3 -3
- package/dist/components/Atoms/SocialIcons/Icon/Icon.js +13 -13
- package/dist/components/Atoms/SocialIcons/SocialIcons.js +25 -23
- package/dist/components/Atoms/SocialIcons/SocialIcons.test.js +7 -7
- package/dist/components/Atoms/SocialIcons/Utils/Icons.js +3 -3
- package/dist/components/Atoms/SocialIcons/Utils/Links.js +19 -20
- package/dist/components/Atoms/SocialIcons/assets/X-white-Subtract.svg +3 -0
- package/dist/components/Atoms/Text/Text.js +62 -41
- package/dist/components/Atoms/Text/Text.test.js +11 -11
- package/dist/components/Atoms/TextArea/TextArea.js +18 -17
- package/dist/components/Atoms/TextArea/TextArea.test.js +3 -3
- package/dist/components/Atoms/TextInputWithDropdown/TextInputWithDropdown.js +69 -86
- package/dist/components/Atoms/TextInputWithDropdown/TextInputWithDropdown.style.js +23 -15
- package/dist/components/Atoms/TextInputWithDropdown/TextInputWithDropdown.test.js +15 -19
- package/dist/components/Molecules/Accordion/Accordion.js +35 -32
- package/dist/components/Molecules/Accordion/Accordion.test.js +3 -3
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.js +81 -52
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +5 -5
- package/dist/components/Molecules/Banner/Banner.js +21 -13
- package/dist/components/Molecules/Banner/Banner.test.js +3 -3
- package/dist/components/Molecules/Box/Box.js +33 -27
- package/dist/components/Molecules/Box/Box.test.js +5 -5
- package/dist/components/Molecules/Card/Card.js +22 -22
- package/dist/components/Molecules/Card/Card.test.js +5 -5
- package/dist/components/Molecules/CardDs/CardDs.js +80 -55
- package/dist/components/Molecules/CardDs/CardDs.test.js +3 -3
- package/dist/components/Molecules/Chip/Chip.js +8 -6
- package/dist/components/Molecules/Chip/Chip.style.js +48 -28
- package/dist/components/Molecules/Chip/Chip.test.js +4 -6
- package/dist/components/Molecules/Countdown/Countdown.js +28 -36
- package/dist/components/Molecules/Countdown/Countdown.style.js +3 -3
- package/dist/components/Molecules/Descriptor/Descriptor.js +32 -26
- package/dist/components/Molecules/Descriptor/Descriptor.test.js +5 -5
- package/dist/components/Molecules/DoubleCopy/DoubleCopy.js +6 -4
- package/dist/components/Molecules/DoubleCopy/DoubleCopy.style.js +7 -5
- package/dist/components/Molecules/DoubleCopy/DoubleCopy.test.js +4 -4
- package/dist/components/Molecules/HeroBanner/HeroBanner.js +13 -17
- package/dist/components/Molecules/InfoBanner/InfoBanner.js +22 -18
- package/dist/components/Molecules/InfoBanner/InfoBanner.test.js +10 -10
- package/dist/components/Molecules/Logos/Logos.js +26 -14
- package/dist/components/Molecules/Logos/Logos.md +5 -0
- package/dist/components/Molecules/Lookup/Lookup.js +49 -84
- package/dist/components/Molecules/PartnerLink/PartnerLink.js +10 -11
- package/dist/components/Molecules/PartnerLink/PartnerLink.style.js +15 -9
- package/dist/components/Molecules/PartnerLink/PartnerLink.test.js +3 -3
- package/dist/components/Molecules/Promo/Promo.js +30 -36
- package/dist/components/Molecules/Promo/Promo.style.js +44 -31
- package/dist/components/Molecules/Promo/Promo.test.js +6 -6
- package/dist/components/Molecules/Promo/_ProgressRing.js +13 -19
- package/dist/components/Molecules/Promo/_PromoVideo.js +25 -34
- package/dist/components/Molecules/Promo/_PromoVideoButton.js +7 -7
- package/dist/components/Molecules/Promo/_PromoVideoButton.style.js +68 -41
- package/dist/components/Molecules/SchoolLookup/SchoolLookup.js +29 -52
- package/dist/components/Molecules/SchoolLookup/SchoolLookup.test.js +4 -4
- package/dist/components/Molecules/SearchInput/SearchInput.js +8 -8
- package/dist/components/Molecules/SearchInput/SearchInput.style.js +22 -14
- package/dist/components/Molecules/SearchInput/SearchInput.test.js +4 -4
- package/dist/components/Molecules/SearchResult/SearchResult.js +43 -29
- package/dist/components/Molecules/SearchResult/SearchResult.test.js +9 -9
- package/dist/components/Molecules/ShareButton/ShareButton.js +22 -26
- package/dist/components/Molecules/ShareButton/ShareButton.style.js +5 -5
- package/dist/components/Molecules/ShareButton/ShareButton.test.js +3 -3
- package/dist/components/Molecules/ShareButton/assets/ShareIcons.js +2 -2
- package/dist/components/Molecules/SimpleSchoolLookup/SimpleSchoolLookup.js +28 -55
- package/dist/components/Molecules/SingleMessage/SingleMessage.js +99 -123
- package/dist/components/Molecules/SingleMessage/SingleMessage.style.js +132 -81
- package/dist/components/Molecules/SingleMessage/SingleMessage.test.js +13 -13
- package/dist/components/Molecules/SingleMessageDS/SingleMessageDs.js +31 -40
- package/dist/components/Molecules/SingleMessageDS/SingleMessageDs.style.js +85 -49
- package/dist/components/Molecules/SingleMessageDS/SingleMessageDs.test.js +3 -3
- package/dist/components/Molecules/Typeahead/Typeahead.js +47 -84
- package/dist/components/Molecules/Typeahead/Typeahead.test.js +12 -35
- package/dist/components/Molecules/VideoBanner/VideoBanner.js +20 -25
- package/dist/components/Molecules/VideoBanner/VideoBanner.test.js +4 -4
- package/dist/components/Organisms/CookieBanner/CookieBanner.js +7 -5
- package/dist/components/Organisms/CookieBanner/CookieBanner.style.js +21 -13
- package/dist/components/Organisms/CookieBanner/CookieBanner.test.js +5 -5
- package/dist/components/Organisms/Donate/Donate.js +34 -37
- package/dist/components/Organisms/Donate/Donate.style.js +85 -53
- package/dist/components/Organisms/Donate/Donate.test.js +10 -10
- package/dist/components/Organisms/Donate/Form/Form.js +53 -78
- package/dist/components/Organisms/Donate/Form/PopUpComponent.js +25 -30
- package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.js +11 -13
- package/dist/components/Organisms/Donate/GivingSelector/GivingSelector.style.js +38 -22
- package/dist/components/Organisms/Donate/MoneyBuy/MoneyBuy.js +47 -30
- package/dist/components/Organisms/EmailSignUp/EmailSignUp.style.js +63 -37
- package/dist/components/Organisms/EmailSignUp/EmailSignUp.test.js +12 -12
- package/dist/components/Organisms/EmailSignUp/EmailSignUpForm.js +23 -43
- package/dist/components/Organisms/EmailSignUp/_EmailSignUp.js +25 -21
- package/dist/components/Organisms/EmailSignUp/_EmailSignUpConfig.js +10 -9
- package/dist/components/Organisms/EmailSignUp/_TextInput.js +20 -18
- package/dist/components/Organisms/Footer/Footer.js +10 -10
- package/dist/components/Organisms/Footer/Footer.style.js +27 -21
- package/dist/components/Organisms/Footer/Footer.test.js +3 -3
- package/dist/components/Organisms/Footer/Nav/Nav.js +59 -70
- package/dist/components/Organisms/Footer/Nav/Nav.style.js +77 -43
- package/dist/components/Organisms/Header/Burger/BurgerMenu.js +6 -4
- package/dist/components/Organisms/Header/Burger/BurgerMenu.style.js +37 -21
- package/dist/components/Organisms/Header/Header.js +8 -8
- package/dist/components/Organisms/Header/Header.style.js +27 -19
- package/dist/components/Organisms/Header/Nav/Nav.js +39 -50
- package/dist/components/Organisms/Header/Nav/Nav.style.js +103 -57
- package/dist/components/Organisms/Header/header.test.js +1 -1
- package/dist/components/Organisms/ImpactSlider/ImpactMoneybuys.style.js +32 -29
- package/dist/components/Organisms/ImpactSlider/ImpactSlider.js +19 -22
- package/dist/components/Organisms/ImpactSlider/ImpactSlider.style.js +38 -24
- package/dist/components/Organisms/ImpactSlider/Slider.style.js +8 -14
- package/dist/components/Organisms/ImpactSlider/_ImpactMoneybuys.js +11 -11
- package/dist/components/Organisms/ImpactSlider/_Slider.js +9 -7
- package/dist/components/Organisms/ImpactSlider/_utils.js +11 -11
- package/dist/components/Organisms/MarketingPreferencesDS/MarketingPreferencesDS.style.js +61 -38
- package/dist/components/Organisms/MarketingPreferencesDS/MarketingPreferencesDSForm.js +24 -16
- package/dist/components/Organisms/MarketingPreferencesDS/_AssociatedFields.js +1 -1
- package/dist/components/Organisms/MarketingPreferencesDS/_CheckAnswer.js +20 -16
- package/dist/components/Organisms/MarketingPreferencesDS/_DefaultCopy.js +3 -3
- package/dist/components/Organisms/MarketingPreferencesDS/_MarketingPreferencesDS.js +46 -36
- package/dist/components/Organisms/MarketingPreferencesDS/_MarketingPrefsConfig.js +21 -34
- package/dist/components/Organisms/MarketingPreferencesDS/_TextInput.js +20 -18
- package/dist/components/Organisms/Membership/Form/Form.js +48 -81
- package/dist/components/Organisms/Membership/Membership.js +17 -15
- package/dist/components/Organisms/Membership/Membership.style.js +81 -51
- package/dist/components/Organisms/Membership/Membership.test.js +4 -4
- package/dist/components/Organisms/Membership/MoneyBox/MoneyBox.js +37 -26
- package/dist/hoc/shallowWithTheme.js +1 -1
- package/dist/index.js +67 -67
- package/dist/styleguide/CRLogo.js +2 -2
- package/dist/styleguide/StyleGuideRenderer.js +9 -7
- package/dist/styleguide/ThemeWrapper.js +5 -3
- package/dist/styleguide/data/data.js +3 -3
- package/dist/theme/crTheme/buttonColors.js +6 -5
- package/dist/theme/crTheme/colors.js +4 -3
- package/dist/theme/crTheme/fontSizes.js +4 -3
- package/dist/theme/crTheme/linkStyles.js +6 -5
- package/dist/theme/crTheme/theme.js +1 -1
- package/dist/theme/shared/breakpoint.js +4 -3
- package/dist/theme/shared/fontFamilies.js +5 -4
- package/dist/theme/shared/hideVisually.js +1 -1
- package/dist/theme/shared/size.js +4 -3
- package/dist/theme/shared/spacing.js +2 -2
- package/dist/theme/shared/zIndex.js +3 -3
- package/dist/theme/srTheme/buttonColors.js +6 -5
- package/dist/theme/srTheme/colors.js +4 -3
- package/dist/theme/srTheme/fontSizes.js +4 -3
- package/dist/theme/srTheme/linkStyles.js +6 -5
- package/dist/theme/srTheme/theme.js +1 -1
- package/dist/utils/Membership.js +30 -27
- package/dist/utils/ShareButton/sharePopUpHelper.js +8 -8
- package/dist/utils/ShareButton/shareTracking.js +1 -1
- package/dist/utils/ShareButton/shareUrlHelper.js +3 -3
- package/dist/utils/allowListed.js +3 -5
- package/dist/utils/allowListed.test.js +3 -3
- package/dist/utils/internalLinkHelper.js +8 -10
- package/dist/utils/navHelper.js +2 -2
- package/package.json +12 -9
- package/playwright/components/atoms/checkbox.spec.js +64 -0
- package/playwright/components/atoms/input.spec.js +158 -0
- package/playwright/components/atoms/label.spec.js +29 -0
- package/playwright/components/atoms/link.spec.js +48 -0
- package/playwright/components/atoms/radioButton.spec.js +30 -0
- package/playwright/components/atoms/select.spec.js +36 -0
- package/playwright/components/atoms/textArea.spec.js +39 -0
- package/playwright/components/atoms/textInputWithDropdown.spec.js +23 -0
- package/playwright/components/molecules/accordian.spec.js +20 -0
- package/playwright/components/molecules/schoolLookup.spec.js +26 -0
- package/playwright/components/molecules/searchInput.spec.js +24 -0
- package/playwright/components/molecules/shareButton.spec.js +32 -0
- package/playwright/components/molecules/simpleSchoolLookUp.spec.js +35 -0
- package/playwright/components/molecules/typeahead.spec.js +27 -0
- package/playwright/components/organisms/donate.spec.js +293 -0
- package/playwright/components/organisms/emailSignUpForm.spec.js +109 -0
- package/playwright/components/organisms/footer.spec.js +67 -0
- package/playwright/components/organisms/header.spec.js +82 -0
- package/playwright/components/organisms/impactSlider.spec.js +292 -0
- package/playwright/components/organisms/marketingPreferences.spec.js +220 -0
- package/playwright/components/organisms/membership.spec.js +47 -0
- package/playwright.config.js +49 -0
- package/src/components/Atoms/SocialIcons/Utils/Icons.js +1 -1
- package/src/components/Atoms/SocialIcons/assets/X-white-Subtract.svg +3 -0
- package/src/components/Molecules/Logos/Logos.js +18 -6
- package/src/components/Molecules/Logos/Logos.md +5 -0
- package/src/components/Organisms/ImpactSlider/_ImpactMoneybuys.js +3 -4
- package/src/components/Organisms/Membership/Membership.test.js +1 -1
- package/cypress/e2e/components/atoms/button.cy.js +0 -102
- package/cypress/e2e/components/atoms/buttonWithStates.cy.js +0 -47
- package/cypress/e2e/components/atoms/checkbox.cy.js +0 -70
- package/cypress/e2e/components/atoms/confetti.cy.js +0 -46
- package/cypress/e2e/components/atoms/errorText.cy.js +0 -45
- package/cypress/e2e/components/atoms/input.cy.js +0 -157
- package/cypress/e2e/components/atoms/label.cy.js +0 -93
- package/cypress/e2e/components/atoms/link.cy.js +0 -190
- package/cypress/e2e/components/atoms/logo.cy.js +0 -132
- package/cypress/e2e/components/atoms/pagination.cy.js +0 -191
- package/cypress/e2e/components/atoms/picture.cy.js +0 -130
- package/cypress/e2e/components/atoms/radioButton.cy.js +0 -76
- package/cypress/e2e/components/atoms/richText.cy.js +0 -70
- package/cypress/e2e/components/atoms/select.cy.js +0 -84
- package/cypress/e2e/components/atoms/socialIcons.cy.js +0 -162
- package/cypress/e2e/components/atoms/text.cy.js +0 -169
- package/cypress/e2e/components/atoms/textArea.cy.js +0 -89
- package/cypress/e2e/components/atoms/textInputWithDrop.cy.js +0 -76
- package/cypress/e2e/components/molecules/accordion.cy.js +0 -67
- package/cypress/e2e/components/molecules/articleTeaser.cy.js +0 -105
- package/cypress/e2e/components/molecules/banner.cy.js +0 -67
- package/cypress/e2e/components/molecules/box.cy.js +0 -104
- package/cypress/e2e/components/molecules/card.cy.js +0 -105
- package/cypress/e2e/components/molecules/cardDs.cy.js +0 -198
- package/cypress/e2e/components/molecules/chip.cy.js +0 -68
- package/cypress/e2e/components/molecules/countdown.cy.js +0 -71
- package/cypress/e2e/components/molecules/descriptor.cy.js +0 -142
- package/cypress/e2e/components/molecules/doubleCopy.cy.js +0 -79
- package/cypress/e2e/components/molecules/heroBanner.cy.js +0 -69
- package/cypress/e2e/components/molecules/infoBanner.cy.js +0 -69
- package/cypress/e2e/components/molecules/partnerLink.cy.js +0 -68
- package/cypress/e2e/components/molecules/promo.cy.js +0 -74
- package/cypress/e2e/components/molecules/schoolLookup.cy.js +0 -83
- package/cypress/e2e/components/molecules/searchInput.cy.js +0 -72
- package/cypress/e2e/components/molecules/searchResult.cy.js +0 -191
- package/cypress/e2e/components/molecules/shareButton.cy.js +0 -76
- package/cypress/e2e/components/molecules/simpleSchoolLookup.cy.js +0 -83
- package/cypress/e2e/components/molecules/singleMessage.cy.js +0 -502
- package/cypress/e2e/components/molecules/singleMessageDs.cy.js +0 -234
- package/cypress/e2e/components/molecules/typeahead.cy.js +0 -97
- package/cypress/e2e/components/molecules/videoBanner.cy.js +0 -132
- package/cypress/e2e/components/organisms/cookieBanner.cy.js +0 -80
- package/cypress/e2e/components/organisms/donate.cy.js +0 -284
- package/cypress/e2e/components/organisms/emailSignUp.cy.js +0 -54
- package/cypress/e2e/components/organisms/footer.cy.js +0 -168
- package/cypress/e2e/components/organisms/header.cy.js +0 -138
- package/cypress/e2e/components/organisms/impactSlider.cy.js +0 -72
- package/cypress/e2e/components/organisms/marketingPreferencesDSForm.cy.js +0 -589
- package/cypress/e2e/components/organisms/membership.cy.js +0 -122
- package/cypress/fixtures/example.json +0 -5
- package/cypress/plugins/index.js +0 -21
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -36
- package/cypress.config.js +0 -15
- package/dist/components/Atoms/SocialIcons/assets/x-logo.svg +0 -3
- package/src/components/Atoms/SocialIcons/assets/x-logo.svg +0 -3
|
@@ -4,22 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const getUrlParameter = name => {
|
|
8
|
+
const text = name.replace(/\[]/, '\\[').replace(/[\]]/, '\\]');
|
|
9
|
+
const regex = new RegExp("[\\?&]".concat(text, "=([^&#]*)"));
|
|
10
|
+
const results = regex.exec(window.location.search);
|
|
11
|
+
const param = results === null ? 'generic' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
|
12
12
|
return param;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const handleSubmission = (amount, donateLink, cartID, rowID) => {
|
|
15
|
+
let currentpageUrl = window.location.href;
|
|
16
|
+
const affiliateValue = getUrlParameter(currentpageUrl);
|
|
17
|
+
const reg = /[#?|[\]\\]/g;
|
|
18
18
|
if (currentpageUrl.match(reg) !== null) {
|
|
19
|
-
|
|
19
|
+
const thisMatch = currentpageUrl.match(reg)[0];
|
|
20
20
|
currentpageUrl = currentpageUrl.substring(0, currentpageUrl.indexOf(thisMatch));
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const forwardingUrl = "".concat(donateLink, "/?cartId=").concat(cartID, "&amount=").concat(amount, "&clientOverride=donate¤cy=GBP&givingType=single&affiliate=").concat(affiliateValue, "&siteurl=").concat(currentpageUrl, "&rowID=").concat(rowID);
|
|
23
23
|
window.location.href = forwardingUrl;
|
|
24
24
|
};
|
|
25
25
|
var _default = exports.default = handleSubmission;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
@@ -10,85 +11,107 @@ var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
|
|
|
10
11
|
var _size = require("../../../theme/shared/size");
|
|
11
12
|
var _CR_Tick_black = _interopRequireDefault(require("./assets/CR_Tick_black.svg"));
|
|
12
13
|
var _TextInput = _interopRequireDefault(require("./_TextInput"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) { if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
var OuterWrapper = exports.OuterWrapper = _styledComponents.default.div.withConfig({
|
|
14
|
+
const OuterWrapper = exports.OuterWrapper = _styledComponents.default.div.withConfig({
|
|
16
15
|
displayName: "MarketingPreferencesDSstyle__OuterWrapper",
|
|
17
16
|
componentId: "sc-68n85q-0"
|
|
18
17
|
})(["display:flex;flex-direction:column;", "{flex-direction:row;flex-wrap:wrap;}"], (0, _size.media)('small'));
|
|
19
|
-
|
|
18
|
+
const TopCopyWrapper = exports.TopCopyWrapper = _styledComponents.default.div.withConfig({
|
|
20
19
|
displayName: "MarketingPreferencesDSstyle__TopCopyWrapper",
|
|
21
20
|
componentId: "sc-68n85q-1"
|
|
22
|
-
})(["margin:", " 0;display:flex;width:100%;@media ", "{padding:10px;}"], (0, _spacing.default)('l'),
|
|
23
|
-
|
|
21
|
+
})(["margin:", " 0;display:flex;width:100%;@media ", "{padding:10px;}"], (0, _spacing.default)('l'), _ref => {
|
|
22
|
+
let {
|
|
23
|
+
theme
|
|
24
|
+
} = _ref;
|
|
24
25
|
return theme.breakpoint('small');
|
|
25
26
|
});
|
|
26
|
-
|
|
27
|
+
const BottomCopyWrapper = exports.BottomCopyWrapper = _styledComponents.default.div.withConfig({
|
|
27
28
|
displayName: "MarketingPreferencesDSstyle__BottomCopyWrapper",
|
|
28
29
|
componentId: "sc-68n85q-2"
|
|
29
30
|
})(["margin:", " 0;"], (0, _spacing.default)('md'));
|
|
30
|
-
|
|
31
|
+
const Head = exports.Head = _styledComponents.default.div.withConfig({
|
|
31
32
|
displayName: "MarketingPreferencesDSstyle__Head",
|
|
32
33
|
componentId: "sc-68n85q-3"
|
|
33
34
|
})(["display:flex;justify-content:space-between;flex-direction:column;"]);
|
|
34
|
-
|
|
35
|
+
const FormField = exports.FormField = _styledComponents.default.div.withConfig({
|
|
35
36
|
displayName: "MarketingPreferencesDSstyle__FormField",
|
|
36
37
|
componentId: "sc-68n85q-4"
|
|
37
|
-
})(["", ""],
|
|
38
|
-
|
|
38
|
+
})(["", ""], _ref2 => {
|
|
39
|
+
let {
|
|
40
|
+
theme
|
|
41
|
+
} = _ref2;
|
|
39
42
|
return (0, _styledComponents.css)(["position:relative;margin-bottom:", ";width:100%;display:flex;flex-direction:column;@media ", "{width:50%;padding:10px;}label{position:relative;margin-bottom:", ";width:100%;color:", ";}h3{position:relative;margin-bottom:", ";&:before{position:absolute;top:0;left:0;width:24px;height:24px;content:'';}}"], (0, _spacing.default)('md'), theme.breakpoint('small'), (0, _spacing.default)('md'), theme.color('grey_dark'), (0, _spacing.default)('md'));
|
|
40
43
|
});
|
|
41
|
-
|
|
44
|
+
const CheckContainer = exports.CheckContainer = _styledComponents.default.div.withConfig({
|
|
42
45
|
displayName: "MarketingPreferencesDSstyle__CheckContainer",
|
|
43
46
|
componentId: "sc-68n85q-5"
|
|
44
|
-
})(["", ""],
|
|
45
|
-
|
|
47
|
+
})(["", ""], _ref3 => {
|
|
48
|
+
let {
|
|
49
|
+
theme
|
|
50
|
+
} = _ref3;
|
|
46
51
|
return (0, _styledComponents.css)(["width:100%;display:flex;justify-content:space-between;font-size:", ";font-family:", ";"], theme.fontSize('md'), theme.fontFamilies(theme.font.regular));
|
|
47
52
|
});
|
|
48
|
-
|
|
53
|
+
const CheckLabel = exports.CheckLabel = _styledComponents.default.label.withConfig({
|
|
49
54
|
displayName: "MarketingPreferencesDSstyle__CheckLabel",
|
|
50
55
|
componentId: "sc-68n85q-6"
|
|
51
|
-
})(["", ""],
|
|
52
|
-
|
|
56
|
+
})(["", ""], _ref4 => {
|
|
57
|
+
let {
|
|
58
|
+
theme
|
|
59
|
+
} = _ref4;
|
|
53
60
|
return (0, _styledComponents.css)(["display:flex;align-items:center;font-size:", ";@media ", "{font-size:", ";}"], theme.fontSize('xs'), theme.breakpoint('small'), theme.fontSize('s'));
|
|
54
61
|
});
|
|
55
|
-
|
|
62
|
+
const CheckInput = exports.CheckInput = _styledComponents.default.input.withConfig({
|
|
56
63
|
displayName: "MarketingPreferencesDSstyle__CheckInput",
|
|
57
64
|
componentId: "sc-68n85q-7"
|
|
58
|
-
})(["font-size:", ";display:block;box-sizing:border-box;opacity:0;position:absolute;width:100%;height:100%;left:0;top:0;margin:0;border:1px solid ", ";+ span{margin-right:10px;width:30px;height:30px;background-color:", ";border:1px solid ", ";float:left;border-radius:8px;@media ", "{margin-right:15px;}}:checked + span{background:url(", ") no-repeat center;background-color:", ";background-size:contain;}"],
|
|
59
|
-
|
|
65
|
+
})(["font-size:", ";display:block;box-sizing:border-box;opacity:0;position:absolute;width:100%;height:100%;left:0;top:0;margin:0;border:1px solid ", ";+ span{margin-right:10px;width:30px;height:30px;background-color:", ";border:1px solid ", ";float:left;border-radius:8px;@media ", "{margin-right:15px;}}:checked + span{background:url(", ") no-repeat center;background-color:", ";background-size:contain;}"], _ref5 => {
|
|
66
|
+
let {
|
|
67
|
+
theme
|
|
68
|
+
} = _ref5;
|
|
60
69
|
return theme.fontSize('sm');
|
|
61
|
-
},
|
|
62
|
-
|
|
70
|
+
}, _ref6 => {
|
|
71
|
+
let {
|
|
72
|
+
theme
|
|
73
|
+
} = _ref6;
|
|
63
74
|
return theme.color('grey_for_forms');
|
|
64
|
-
},
|
|
65
|
-
|
|
75
|
+
}, _ref7 => {
|
|
76
|
+
let {
|
|
77
|
+
theme
|
|
78
|
+
} = _ref7;
|
|
66
79
|
return theme.color('grey_light');
|
|
67
|
-
},
|
|
68
|
-
|
|
80
|
+
}, _ref8 => {
|
|
81
|
+
let {
|
|
82
|
+
theme
|
|
83
|
+
} = _ref8;
|
|
69
84
|
return theme.color('black');
|
|
70
|
-
},
|
|
71
|
-
|
|
85
|
+
}, _ref9 => {
|
|
86
|
+
let {
|
|
87
|
+
theme
|
|
88
|
+
} = _ref9;
|
|
72
89
|
return theme.breakpoint('small');
|
|
73
|
-
}, _CR_Tick_black.default,
|
|
74
|
-
|
|
90
|
+
}, _CR_Tick_black.default, _ref10 => {
|
|
91
|
+
let {
|
|
92
|
+
theme
|
|
93
|
+
} = _ref10;
|
|
75
94
|
return theme.color('grey_light');
|
|
76
95
|
});
|
|
77
|
-
|
|
96
|
+
const ShowHideInputWrapper = exports.ShowHideInputWrapper = _styledComponents.default.div.withConfig({
|
|
78
97
|
displayName: "MarketingPreferencesDSstyle__ShowHideInputWrapper",
|
|
79
98
|
componentId: "sc-68n85q-8"
|
|
80
|
-
})(["display:", ";width:100%;label{width:100%;border:none;padding:0;}"],
|
|
81
|
-
|
|
99
|
+
})(["display:", ";width:100%;label{width:100%;border:none;padding:0;}"], _ref11 => {
|
|
100
|
+
let {
|
|
101
|
+
show
|
|
102
|
+
} = _ref11;
|
|
82
103
|
return show ? 'block' : 'none';
|
|
83
104
|
});
|
|
84
|
-
|
|
105
|
+
const ExtraInfo = exports.ExtraInfo = _styledComponents.default.span.withConfig({
|
|
85
106
|
displayName: "MarketingPreferencesDSstyle__ExtraInfo",
|
|
86
107
|
componentId: "sc-68n85q-9"
|
|
87
108
|
})(["display:block;width:100%;font-size:1rem;text-transform:inherit;font-weight:normal;line-height:normal;font-family:'Montserrat',Helvetica,Arial,sans-serif;margin-bottom:0.5rem;+ label{margin-top:20px;&[for=\"mp_email\"],&[for=\"mp_mobile\"],&[for=\"mp_phone\"]{> span:first-child{position:absolute;margin:-1px;padding:0;width:1px;height:1px;border:0;overflow:hidden;clip:rect(1px 1px 1px 1px);word-wrap:normal;}}"]);
|
|
88
|
-
|
|
109
|
+
const MPTextInput = exports.MPTextInput = (0, _styledComponents.default)(_TextInput.default).withConfig({
|
|
89
110
|
displayName: "MarketingPreferencesDSstyle__MPTextInput",
|
|
90
111
|
componentId: "sc-68n85q-10"
|
|
91
|
-
})(["input{border:1px solid ", ";;", "{max-width:none;}}"],
|
|
92
|
-
|
|
112
|
+
})(["input{border:1px solid ", ";;", "{max-width:none;}}"], _ref12 => {
|
|
113
|
+
let {
|
|
114
|
+
theme
|
|
115
|
+
} = _ref12;
|
|
93
116
|
return theme.color('black');
|
|
94
117
|
}, (0, _size.media)('small'));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
@@ -16,17 +16,19 @@ var _MarketingPreferencesDS = require("./_MarketingPreferencesDS");
|
|
|
16
16
|
*/
|
|
17
17
|
/* Create default validation and initial values by not passing any override
|
|
18
18
|
parameters into the functions: */
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const mpValidation = (0, _MarketingPreferencesDS.buildValidationSchema)();
|
|
20
|
+
const initialValues = (0, _MarketingPreferencesDS.setInitialValues)();
|
|
21
|
+
const {
|
|
22
|
+
mpValidationSchema,
|
|
23
|
+
mpValidationOptions
|
|
24
|
+
} = mpValidation;
|
|
23
25
|
|
|
24
26
|
// Or customise and override the config to suit the destination app's requirements:
|
|
25
|
-
|
|
27
|
+
const initalValueOverrides = {
|
|
26
28
|
mp_email: 'user@website.com' // Potentially provided earlier in the journey
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
const validationOverrides = {
|
|
30
32
|
mp_permissionEmail: {
|
|
31
33
|
hideInput: true
|
|
32
34
|
},
|
|
@@ -41,31 +43,37 @@ var validationOverrides = {
|
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
// Pass these override objects in as parameters
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const mpValidationCustom = (0, _MarketingPreferencesDS.buildValidationSchema)(validationOverrides);
|
|
47
|
+
const initialValuesCustom = (0, _MarketingPreferencesDS.setInitialValues)(initalValueOverrides);
|
|
48
|
+
const {
|
|
49
|
+
mpValidationSchema: mpValidationSchemaCustom,
|
|
50
|
+
mpValidationOptions: mpValidationOptionsCustom
|
|
51
|
+
} = mpValidationCustom;
|
|
52
|
+
const MarketingPreferencesDSForm = () => {
|
|
49
53
|
function customSubmitHandler(formData) {
|
|
50
54
|
// eslint-disable-next-line no-console
|
|
51
55
|
console.log('Successful submission', formData);
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
// For our default instance:
|
|
55
|
-
|
|
59
|
+
const formMethods = (0, _reactHookForm.useForm)({
|
|
56
60
|
mode: 'onBlur',
|
|
57
61
|
defaultValues: initialValues,
|
|
58
62
|
resolver: (0, _yup.yupResolver)(mpValidationSchema)
|
|
59
63
|
});
|
|
60
|
-
|
|
64
|
+
const {
|
|
65
|
+
handleSubmit
|
|
66
|
+
} = formMethods;
|
|
61
67
|
|
|
62
68
|
// For our customised-instance:
|
|
63
|
-
|
|
69
|
+
const formMethodsCustom = (0, _reactHookForm.useForm)({
|
|
64
70
|
mode: 'onBlur',
|
|
65
71
|
defaultValues: initialValuesCustom,
|
|
66
72
|
resolver: (0, _yup.yupResolver)(mpValidationSchemaCustom)
|
|
67
73
|
});
|
|
68
|
-
|
|
74
|
+
const {
|
|
75
|
+
handleSubmit: handleSubmitCustom
|
|
76
|
+
} = formMethodsCustom;
|
|
69
77
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
70
78
|
tag: "p",
|
|
71
79
|
weight: "bold"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
@@ -8,16 +8,20 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _AssociatedFields = _interopRequireDefault(require("./_AssociatedFields"));
|
|
10
10
|
var _MarketingPreferencesDS = require("./MarketingPreferencesDS.style");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const CheckAnswer = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
name,
|
|
14
|
+
mpValidationOptions,
|
|
15
|
+
userSelection,
|
|
16
|
+
formContext
|
|
17
|
+
} = _ref;
|
|
18
|
+
const {
|
|
19
|
+
setValue,
|
|
20
|
+
clearErrors,
|
|
21
|
+
register
|
|
22
|
+
} = formContext;
|
|
23
|
+
const onChange = e => {
|
|
24
|
+
let newVal;
|
|
21
25
|
if (e.target.checked) {
|
|
22
26
|
newVal = e.target.value;
|
|
23
27
|
} else {
|
|
@@ -26,8 +30,8 @@ var CheckAnswer = function CheckAnswer(_ref) {
|
|
|
26
30
|
// To ensure we're not letting invalid values get passed, reset any associated fields
|
|
27
31
|
// but only when it's not a hidden "passed values behind the scenes" field:
|
|
28
32
|
if (!mpValidationOptions[name].hideInput) {
|
|
29
|
-
|
|
30
|
-
theseFields.forEach(
|
|
33
|
+
const theseFields = _AssociatedFields.default[name].fieldNames;
|
|
34
|
+
theseFields.forEach(fieldName => {
|
|
31
35
|
setValue(fieldName, '');
|
|
32
36
|
});
|
|
33
37
|
}
|
|
@@ -38,10 +42,10 @@ var CheckAnswer = function CheckAnswer(_ref) {
|
|
|
38
42
|
|
|
39
43
|
/* If the click represents either a 'none selected' or a 'not required' option
|
|
40
44
|
(set in config), reset errors for all fields associated with this checkbox */
|
|
41
|
-
|
|
45
|
+
const reValidate = !mpValidationOptions[name][newVal];
|
|
42
46
|
if (reValidate) {
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
const theseFields = _AssociatedFields.default[name].fieldNames;
|
|
48
|
+
theseFields.forEach(fieldName => {
|
|
45
49
|
clearErrors(fieldName);
|
|
46
50
|
});
|
|
47
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
@@ -8,7 +8,7 @@ exports.defaultCopyTop = exports.defaultCopyBottom = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
|
|
10
10
|
var _Link = _interopRequireDefault(require("../../Atoms/Link/Link"));
|
|
11
|
-
|
|
11
|
+
const defaultCopyTop = exports.defaultCopyTop = /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
12
12
|
tag: "h3",
|
|
13
13
|
size: "xl",
|
|
14
14
|
family: "Anton",
|
|
@@ -24,7 +24,7 @@ var defaultCopyTop = exports.defaultCopyTop = /*#__PURE__*/_react.default.create
|
|
|
24
24
|
size: "md",
|
|
25
25
|
color: "grey_dark"
|
|
26
26
|
}, "Please tick the relevant boxes below if you would like to hear from us."));
|
|
27
|
-
|
|
27
|
+
const defaultCopyBottom = exports.defaultCopyBottom = /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
28
28
|
tag: "p",
|
|
29
29
|
color: "grey_dark"
|
|
30
30
|
}, "Update your preferences at any time by visiting our", ' ', /*#__PURE__*/_react.default.createElement(_Link.default, {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.MarketingPreferencesDS = void 0;
|
|
8
8
|
Object.defineProperty(exports, "buildValidationSchema", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function
|
|
10
|
+
get: function () {
|
|
11
11
|
return _MarketingPrefsConfig.buildValidationSchema;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "setInitialValues", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function
|
|
16
|
+
get: function () {
|
|
17
17
|
return _MarketingPrefsConfig.setInitialValues;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
@@ -25,49 +25,56 @@ var _CheckAnswer = _interopRequireDefault(require("./_CheckAnswer"));
|
|
|
25
25
|
var _DefaultCopy = require("./_DefaultCopy");
|
|
26
26
|
var _MarketingPreferencesDS = require("./MarketingPreferencesDS.style");
|
|
27
27
|
var _MarketingPrefsConfig = require("./_MarketingPrefsConfig");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const MarketingPreferencesDS = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
copyTop,
|
|
31
|
+
copyBottom,
|
|
32
|
+
mpValidationOptions,
|
|
33
|
+
id,
|
|
34
|
+
formContext
|
|
35
|
+
} = _ref;
|
|
36
|
+
const {
|
|
37
|
+
errors,
|
|
38
|
+
control
|
|
39
|
+
} = formContext;
|
|
36
40
|
|
|
37
41
|
// For brevity
|
|
38
|
-
|
|
39
|
-
control
|
|
42
|
+
const emailChoice = (0, _reactHookForm.useWatch)({
|
|
43
|
+
control,
|
|
40
44
|
name: 'mp_permissionEmail',
|
|
41
45
|
defaultValue: null
|
|
42
46
|
});
|
|
43
|
-
|
|
44
|
-
control
|
|
47
|
+
const postChoice = (0, _reactHookForm.useWatch)({
|
|
48
|
+
control,
|
|
45
49
|
name: 'mp_permissionPost',
|
|
46
50
|
defaultValue: null
|
|
47
51
|
});
|
|
48
|
-
|
|
49
|
-
control
|
|
52
|
+
const phoneChoice = (0, _reactHookForm.useWatch)({
|
|
53
|
+
control,
|
|
50
54
|
name: 'mp_permissionPhone',
|
|
51
55
|
defaultValue: null
|
|
52
56
|
});
|
|
53
|
-
|
|
54
|
-
control
|
|
57
|
+
const smsChoice = (0, _reactHookForm.useWatch)({
|
|
58
|
+
control,
|
|
55
59
|
name: 'mp_permissionSMS',
|
|
56
60
|
defaultValue: null
|
|
57
61
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
const {
|
|
63
|
+
// eslint-disable-next-line camelcase
|
|
64
|
+
mp_permissionEmail,
|
|
65
|
+
mp_permissionSMS,
|
|
66
|
+
mp_permissionPhone,
|
|
67
|
+
mp_permissionPost
|
|
68
|
+
} = mpValidationOptions;
|
|
62
69
|
|
|
63
70
|
// If the field is not required for each No/Yes choice, remove it from the DOM entirely
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
const disableEmailInput = mp_permissionEmail.yes === false && emailChoice.includes('yes');
|
|
72
|
+
const disableSMSInput = mp_permissionSMS.yes === false && smsChoice.includes('yes');
|
|
73
|
+
const disablePhoneInput = mp_permissionPhone.yes === false && phoneChoice.includes('yes');
|
|
74
|
+
const disablePostInput = mp_permissionPost.yes === false && postChoice.includes('yes');
|
|
68
75
|
|
|
69
76
|
// Required to track multiple errors to determine whether to show/hide the fieldset
|
|
70
|
-
|
|
77
|
+
const isAddressErroring = () => {
|
|
71
78
|
if (_lodash.default.isEmpty(errors)) {
|
|
72
79
|
return null;
|
|
73
80
|
}
|
|
@@ -75,11 +82,11 @@ var MarketingPreferencesDS = exports.MarketingPreferencesDS = function Marketing
|
|
|
75
82
|
};
|
|
76
83
|
/* Only show the field if config hasn't hidden it (to pass in parent values)
|
|
77
84
|
or if a choice has been made */
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
const showEmailField = !mp_permissionEmail.hideInput && (emailChoice || errors.mp_email);
|
|
86
|
+
const showSMSField = !mp_permissionSMS.hideInput && (smsChoice || errors.mp_mobile);
|
|
87
|
+
const showPhoneField = !mp_permissionPhone.hideInput && (phoneChoice || errors.mp_phone);
|
|
88
|
+
const showPostFields = !mp_permissionPost.hideInput && (postChoice || isAddressErroring());
|
|
89
|
+
const customId = id ? "marketing-preferences--".concat(id) : 'marketing-preferences';
|
|
83
90
|
return /*#__PURE__*/_react.default.createElement(_MarketingPreferencesDS.OuterWrapper, {
|
|
84
91
|
id: customId
|
|
85
92
|
}, copyTop && /*#__PURE__*/_react.default.createElement(_MarketingPreferencesDS.TopCopyWrapper, null, copyTop), !mp_permissionEmail.disableOption && /*#__PURE__*/_react.default.createElement(_MarketingPreferencesDS.FormField, {
|
|
@@ -200,9 +207,12 @@ var MarketingPreferencesDS = exports.MarketingPreferencesDS = function Marketing
|
|
|
200
207
|
};
|
|
201
208
|
|
|
202
209
|
// removes from DOM completely
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
exports.MarketingPreferencesDS = MarketingPreferencesDS;
|
|
211
|
+
const MaybeDisabled = _ref2 => {
|
|
212
|
+
let {
|
|
213
|
+
children,
|
|
214
|
+
disabled
|
|
215
|
+
} = _ref2;
|
|
206
216
|
if (disabled) return null;
|
|
207
217
|
return children;
|
|
208
218
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.setInitialValues = exports.buildValidationSchema = void 0;
|
|
7
8
|
var yup = _interopRequireWildcard(require("yup"));
|
|
8
9
|
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var setInitialValues = exports.setInitialValues = function setInitialValues(overrideValues) {
|
|
12
|
-
var defaultValues = {
|
|
10
|
+
const setInitialValues = overrideValues => {
|
|
11
|
+
const defaultValues = {
|
|
13
12
|
mp_email: '',
|
|
14
13
|
mp_mobile: '',
|
|
15
14
|
mp_phone: '',
|
|
@@ -26,11 +25,12 @@ var setInitialValues = exports.setInitialValues = function setInitialValues(over
|
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
// Override with any custom options supplied
|
|
29
|
-
|
|
28
|
+
const updatedValues = (0, _lodash.merge)(defaultValues, overrideValues);
|
|
30
29
|
return updatedValues;
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
exports.setInitialValues = setInitialValues;
|
|
32
|
+
const buildValidationSchema = overrideOptions => {
|
|
33
|
+
const defaultOptions = {
|
|
34
34
|
mp_permissionEmail: {
|
|
35
35
|
/**
|
|
36
36
|
* As per react-hook-form's validation requirements, sets the fields' required attribute
|
|
@@ -63,49 +63,35 @@ var buildValidationSchema = exports.buildValidationSchema = function buildValida
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
// Override with any custom options supplied
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const mpValidationOptions = (0, _lodash.merge)(defaultOptions, overrideOptions);
|
|
67
|
+
const phoneRegex = /^(((((\+44)|(0044))\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((((\+44)|(0044))\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((((\+44)|(0044))\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\\#(\d{4}|\d{3}))?$/;
|
|
68
|
+
const mpValidationSchema = yup.object({
|
|
69
69
|
mp_email: yup.string().when('mp_permissionEmail', {
|
|
70
|
-
is:
|
|
71
|
-
return !mpValidationOptions.mp_permissionEmail.disableOption && mpValidationOptions.mp_permissionEmail[val];
|
|
72
|
-
},
|
|
70
|
+
is: val => !mpValidationOptions.mp_permissionEmail.disableOption && mpValidationOptions.mp_permissionEmail[val],
|
|
73
71
|
then: yup.string().required('Please enter your email address').email('Please enter a valid email address')
|
|
74
72
|
}),
|
|
75
73
|
mp_mobile: yup.string().when('mp_permissionSMS', {
|
|
76
|
-
is:
|
|
77
|
-
return !mpValidationOptions.mp_permissionSMS.disableOption && mpValidationOptions.mp_permissionSMS[val];
|
|
78
|
-
},
|
|
74
|
+
is: val => !mpValidationOptions.mp_permissionSMS.disableOption && mpValidationOptions.mp_permissionSMS[val],
|
|
79
75
|
then: yup.string().required('Please enter your mobile number').matches(phoneRegex, 'Please enter a valid UK mobile number')
|
|
80
76
|
}),
|
|
81
77
|
mp_phone: yup.string().when('mp_permissionPhone', {
|
|
82
|
-
is:
|
|
83
|
-
return !mpValidationOptions.mp_permissionPhone.disableOption && mpValidationOptions.mp_permissionPhone[val];
|
|
84
|
-
},
|
|
78
|
+
is: val => !mpValidationOptions.mp_permissionPhone.disableOption && mpValidationOptions.mp_permissionPhone[val],
|
|
85
79
|
then: yup.string().required('Please enter your phone number').matches(phoneRegex, 'Please enter a valid UK phone number')
|
|
86
80
|
}),
|
|
87
81
|
mp_address1: yup.string().when('mp_permissionPost', {
|
|
88
|
-
is:
|
|
89
|
-
return !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val];
|
|
90
|
-
},
|
|
82
|
+
is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
|
|
91
83
|
then: yup.string().required('Please enter the first line of your address').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
|
|
92
84
|
}),
|
|
93
85
|
mp_town: yup.string().when('mp_permissionPost', {
|
|
94
|
-
is:
|
|
95
|
-
return !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val];
|
|
96
|
-
},
|
|
86
|
+
is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
|
|
97
87
|
then: yup.string().required('Please enter your town').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
|
|
98
88
|
}),
|
|
99
89
|
mp_postcode: yup.string().when('mp_permissionPost', {
|
|
100
|
-
is:
|
|
101
|
-
return !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val];
|
|
102
|
-
},
|
|
90
|
+
is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
|
|
103
91
|
then: yup.string().required('Please enter your postcode').matches(/^[a-zA-Z]{1,2}\d[a-zA-Z\d]?\s*\d[a-zA-Z]{2}$/, 'Please enter a valid postcode')
|
|
104
92
|
}),
|
|
105
93
|
mp_country: yup.string().when('mp_permissionPost', {
|
|
106
|
-
is:
|
|
107
|
-
return !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val];
|
|
108
|
-
},
|
|
94
|
+
is: val => !mpValidationOptions.mp_permissionPost.disableOption && mpValidationOptions.mp_permissionPost[val],
|
|
109
95
|
then: yup.string().required('Please enter your country').matches(/^[a-zA-Z0-9][a-zA-Z0-9'.,/()& -]*$/, 'This field only accepts alphanumeric characters and , . ( ) / & \' - and must start with an alphanumeric character').max(50, 'Please enter a maximum of 50 characters')
|
|
110
96
|
}),
|
|
111
97
|
/* Non-required fields */
|
|
@@ -113,7 +99,8 @@ var buildValidationSchema = exports.buildValidationSchema = function buildValida
|
|
|
113
99
|
mp_address3: yup.string().max(50, 'Please enter a maximum of 50 characters')
|
|
114
100
|
});
|
|
115
101
|
return {
|
|
116
|
-
mpValidationSchema
|
|
117
|
-
mpValidationOptions
|
|
102
|
+
mpValidationSchema,
|
|
103
|
+
mpValidationOptions
|
|
118
104
|
};
|
|
119
|
-
};
|
|
105
|
+
};
|
|
106
|
+
exports.buildValidationSchema = buildValidationSchema;
|