@thecb/components 2.2.0
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/.eslintrc.json +29 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
- package/.github/stale.yml +17 -0
- package/.prettierignore +3 -0
- package/.tool-versions +1 -0
- package/README.md +149 -0
- package/dist/cb-components.cjs.js +77 -0
- package/package.json +96 -0
- package/rollup.config.js +35 -0
- package/src/components/atoms/alert/Alert.js +67 -0
- package/src/components/atoms/alert/Alert.theme.js +71 -0
- package/src/components/atoms/alert/index.js +3 -0
- package/src/components/atoms/amount-callout/AmountCallout.js +27 -0
- package/src/components/atoms/amount-callout/AmountCallout.theme.js +19 -0
- package/src/components/atoms/amount-callout/index.js +3 -0
- package/src/components/atoms/breadcrumb/Breadcrumb.js +50 -0
- package/src/components/atoms/breadcrumb/Breadcrumb.theme.js +25 -0
- package/src/components/atoms/breadcrumb/index.js +3 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.js +128 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +125 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +360 -0
- package/src/components/atoms/button-with-action/index.js +3 -0
- package/src/components/atoms/button-with-link/ButtonWithLink.js +40 -0
- package/src/components/atoms/button-with-link/index.js +3 -0
- package/src/components/atoms/checkbox/Checkbox.js +143 -0
- package/src/components/atoms/checkbox/Checkbox.theme.js +54 -0
- package/src/components/atoms/checkbox/index.js +3 -0
- package/src/components/atoms/checkbox-list/CheckboxList.js +129 -0
- package/src/components/atoms/checkbox-list/CheckboxList.theme.js +42 -0
- package/src/components/atoms/checkbox-list/index.js +3 -0
- package/src/components/atoms/country-dropdown/CountryDropdown.js +24 -0
- package/src/components/atoms/country-dropdown/index.js +1 -0
- package/src/components/atoms/country-dropdown/options.js +249 -0
- package/src/components/atoms/display-box/DisplayBox.js +22 -0
- package/src/components/atoms/display-box/DisplayBox.theme.js +9 -0
- package/src/components/atoms/display-box/index.js +3 -0
- package/src/components/atoms/display-card/DisplayCard.js +65 -0
- package/src/components/atoms/display-card/index.js +3 -0
- package/src/components/atoms/dropdown/Dropdown.js +299 -0
- package/src/components/atoms/dropdown/Dropdown.theme.js +9 -0
- package/src/components/atoms/dropdown/DropdownIcon.js +31 -0
- package/src/components/atoms/dropdown/index.js +3 -0
- package/src/components/atoms/form-layouts/FormContainer.js +28 -0
- package/src/components/atoms/form-layouts/FormInput.js +218 -0
- package/src/components/atoms/form-layouts/FormInputColumn.js +15 -0
- package/src/components/atoms/form-layouts/FormInputRow.js +26 -0
- package/src/components/atoms/form-layouts/FormLayouts.theme.js +52 -0
- package/src/components/atoms/form-layouts/index.js +6 -0
- package/src/components/atoms/form-select/FormSelect.js +62 -0
- package/src/components/atoms/form-select/FormSelect.styled.js +65 -0
- package/src/components/atoms/form-select/index.js +3 -0
- package/src/components/atoms/formatted-address/FormattedAddress.js +53 -0
- package/src/components/atoms/formatted-address/FormattedAddress.theme.js +11 -0
- package/src/components/atoms/formatted-address/index.js +3 -0
- package/src/components/atoms/hamburger-button/HamburgerButton.js +113 -0
- package/src/components/atoms/hamburger-button/index.js +3 -0
- package/src/components/atoms/heading/Heading.js +37 -0
- package/src/components/atoms/heading/Heading.styled.js +14 -0
- package/src/components/atoms/heading/Heading.theme.js +18 -0
- package/src/components/atoms/heading/index.js +3 -0
- package/src/components/atoms/icons/AccountsAddIcon.js +42 -0
- package/src/components/atoms/icons/AccountsIcon.js +37 -0
- package/src/components/atoms/icons/AccountsIconSmall.js +63 -0
- package/src/components/atoms/icons/ChevronIcon.js +51 -0
- package/src/components/atoms/icons/ForgotPasswordIcon.js +46 -0
- package/src/components/atoms/icons/GoToEmailIcon.js +31 -0
- package/src/components/atoms/icons/Icons.theme.js +38 -0
- package/src/components/atoms/icons/PaymentMethodIcon.js +42 -0
- package/src/components/atoms/icons/PaymentsIconSmall.js +63 -0
- package/src/components/atoms/icons/ProfileIconSmall.js +44 -0
- package/src/components/atoms/icons/PropertiesAddIcon.js +70 -0
- package/src/components/atoms/icons/PropertiesIconSmall.js +32 -0
- package/src/components/atoms/icons/SettingsIconSmall.js +63 -0
- package/src/components/atoms/icons/VerifiedEmailIcon.js +53 -0
- package/src/components/atoms/icons/index.js +28 -0
- package/src/components/atoms/index.js +33 -0
- package/src/components/atoms/labeled-amount/LabeledAmount.js +35 -0
- package/src/components/atoms/labeled-amount/LabeledAmount.theme.js +10 -0
- package/src/components/atoms/labeled-amount/index.js +3 -0
- package/src/components/atoms/layouts/Box.js +83 -0
- package/src/components/atoms/layouts/Box.styled.js +131 -0
- package/src/components/atoms/layouts/Center.js +28 -0
- package/src/components/atoms/layouts/Center.styled.js +18 -0
- package/src/components/atoms/layouts/Cluster.js +37 -0
- package/src/components/atoms/layouts/Cluster.styled.js +21 -0
- package/src/components/atoms/layouts/Cover.js +49 -0
- package/src/components/atoms/layouts/Cover.styled.js +29 -0
- package/src/components/atoms/layouts/Frame.js +28 -0
- package/src/components/atoms/layouts/Frame.styled.js +27 -0
- package/src/components/atoms/layouts/Grid.js +38 -0
- package/src/components/atoms/layouts/Grid.styled.js +22 -0
- package/src/components/atoms/layouts/Imposter.js +52 -0
- package/src/components/atoms/layouts/Imposter.styled.js +19 -0
- package/src/components/atoms/layouts/Motion.js +51 -0
- package/src/components/atoms/layouts/Motion.styled.js +41 -0
- package/src/components/atoms/layouts/Reel.js +28 -0
- package/src/components/atoms/layouts/Reel.styled.js +17 -0
- package/src/components/atoms/layouts/Sidebar.js +42 -0
- package/src/components/atoms/layouts/Sidebar.styled.js +38 -0
- package/src/components/atoms/layouts/Stack.js +36 -0
- package/src/components/atoms/layouts/Stack.styled.js +30 -0
- package/src/components/atoms/layouts/Switcher.js +64 -0
- package/src/components/atoms/layouts/Switcher.styled.js +44 -0
- package/src/components/atoms/layouts/examples/FixedSizeContainer.js +22 -0
- package/src/components/atoms/layouts/examples/FixedSizeContainer.styled.js +20 -0
- package/src/components/atoms/layouts/examples/LayoutContentBlock.js +27 -0
- package/src/components/atoms/layouts/examples/LayoutContentBlock.styled.js +15 -0
- package/src/components/atoms/layouts/examples/ResizingContainer.js +49 -0
- package/src/components/atoms/layouts/examples/ResizingContainer.styled.js +39 -0
- package/src/components/atoms/layouts/examples/cluster-example/ClusterExample.js +10 -0
- package/src/components/atoms/layouts/examples/cluster-example/ClusterExample.stories.js +97 -0
- package/src/components/atoms/layouts/examples/grid-example/GridExample.js +49 -0
- package/src/components/atoms/layouts/examples/grid-example/GridExample.stories.js +44 -0
- package/src/components/atoms/layouts/examples/sidebar-example/SidebarExample.js +11 -0
- package/src/components/atoms/layouts/examples/sidebar-example/SidebarExample.stories.js +87 -0
- package/src/components/atoms/layouts/examples/stack-example/StackExample.js +27 -0
- package/src/components/atoms/layouts/examples/stack-example/StackExample.stories.js +69 -0
- package/src/components/atoms/layouts/examples/switcher-example/SwitcherExample.js +38 -0
- package/src/components/atoms/layouts/examples/switcher-example/SwitcherExample.stories.js +65 -0
- package/src/components/atoms/layouts/index.js +27 -0
- package/src/components/atoms/line-item/LineItem.js +30 -0
- package/src/components/atoms/line-item/LineItem.theme.js +7 -0
- package/src/components/atoms/line-item/index.js +3 -0
- package/src/components/atoms/link/ExternalLink.js +50 -0
- package/src/components/atoms/link/ExternalLink.styled.js +26 -0
- package/src/components/atoms/link/InternalLink.js +51 -0
- package/src/components/atoms/link/InternalLink.styled.js +39 -0
- package/src/components/atoms/link/Link.theme.js +8 -0
- package/src/components/atoms/link/index.js +4 -0
- package/src/components/atoms/nav-footer/NavFooter.js +57 -0
- package/src/components/atoms/nav-footer/index.js +3 -0
- package/src/components/atoms/nav-header/NavHeader.js +36 -0
- package/src/components/atoms/nav-header/index.js +3 -0
- package/src/components/atoms/paragraph/Paragraph.js +31 -0
- package/src/components/atoms/paragraph/Paragraph.styled.js +13 -0
- package/src/components/atoms/paragraph/Paragraph.theme.js +18 -0
- package/src/components/atoms/paragraph/index.js +3 -0
- package/src/components/atoms/password-requirements/PasswordRequirements.js +116 -0
- package/src/components/atoms/password-requirements/index.js +3 -0
- package/src/components/atoms/placeholder/Placeholder.js +122 -0
- package/src/components/atoms/placeholder/Placeholder.theme.js +9 -0
- package/src/components/atoms/placeholder/index.js +3 -0
- package/src/components/atoms/processing-fee/ProcessingFee.js +43 -0
- package/src/components/atoms/processing-fee/ProcessingFee.theme.js +7 -0
- package/src/components/atoms/processing-fee/index.js +3 -0
- package/src/components/atoms/radio-button/RadioButton.js +101 -0
- package/src/components/atoms/radio-button/RadioButton.theme.js +9 -0
- package/src/components/atoms/radio-button/index.js +3 -0
- package/src/components/atoms/solid-divider/SolidDivider.js +22 -0
- package/src/components/atoms/solid-divider/SolidDivider.theme.js +8 -0
- package/src/components/atoms/solid-divider/index.js +3 -0
- package/src/components/atoms/spinner/Spinner.js +61 -0
- package/src/components/atoms/spinner/Spinner.theme.js +5 -0
- package/src/components/atoms/spinner/index.js +3 -0
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +28 -0
- package/src/components/atoms/state-province-dropdown/index.js +3 -0
- package/src/components/atoms/state-province-dropdown/options.js +3837 -0
- package/src/components/atoms/text/Text.js +37 -0
- package/src/components/atoms/text/Text.styled.js +32 -0
- package/src/components/atoms/text/Text.theme.js +22 -0
- package/src/components/atoms/text/index.js +3 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.js +212 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +36 -0
- package/src/components/atoms/toggle-switch/index.js +3 -0
- package/src/components/index.js +3 -0
- package/src/components/molecules/address-form/AddressForm.js +110 -0
- package/src/components/molecules/address-form/AddressForm.state.js +52 -0
- package/src/components/molecules/address-form/index.js +11 -0
- package/src/components/molecules/change-password-form/ChangePasswordForm.js +92 -0
- package/src/components/molecules/change-password-form/ChangePasswordForm.state.js +33 -0
- package/src/components/molecules/change-password-form/index.js +11 -0
- package/src/components/molecules/collapsible-section/CollapsibleSection.js +126 -0
- package/src/components/molecules/collapsible-section/CollapsibleSection.theme.js +11 -0
- package/src/components/molecules/collapsible-section/index.js +3 -0
- package/src/components/molecules/edit-name-form/EditNameForm.js +51 -0
- package/src/components/molecules/edit-name-form/EditNameForm.state.js +14 -0
- package/src/components/molecules/edit-name-form/index.js +11 -0
- package/src/components/molecules/email-form/EmailForm.js +55 -0
- package/src/components/molecules/email-form/EmailForm.state.js +19 -0
- package/src/components/molecules/email-form/index.js +11 -0
- package/src/components/molecules/forgot-password-form/ForgotPasswordForm.js +32 -0
- package/src/components/molecules/forgot-password-form/ForgotPasswordForm.state.js +11 -0
- package/src/components/molecules/forgot-password-form/index.js +11 -0
- package/src/components/molecules/highlight-tab-row/HighlightTabRow.js +62 -0
- package/src/components/molecules/highlight-tab-row/HighlightTabRow.theme.js +7 -0
- package/src/components/molecules/highlight-tab-row/index.js +8 -0
- package/src/components/molecules/index.js +24 -0
- package/src/components/molecules/login-form/LoginForm.js +46 -0
- package/src/components/molecules/login-form/LoginForm.state.js +14 -0
- package/src/components/molecules/login-form/index.js +11 -0
- package/src/components/molecules/modal/Modal.js +138 -0
- package/src/components/molecules/modal/index.js +3 -0
- package/src/components/molecules/module/Module.js +42 -0
- package/src/components/molecules/module/Module.theme.js +30 -0
- package/src/components/molecules/module/index.js +8 -0
- package/src/components/molecules/nav-menu/NavMenu.theme.js +5 -0
- package/src/components/molecules/nav-menu/NavMenuDesktop.js +39 -0
- package/src/components/molecules/nav-menu/NavMenuMobile.js +63 -0
- package/src/components/molecules/nav-menu/index.js +4 -0
- package/src/components/molecules/obligation/Obligation.js +69 -0
- package/src/components/molecules/obligation/icons/AccountBillIcon.js +89 -0
- package/src/components/molecules/obligation/icons/AccountConstructionIcon.js +99 -0
- package/src/components/molecules/obligation/icons/AccountDentalIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountElectricIcon.js +99 -0
- package/src/components/molecules/obligation/icons/AccountGarbageIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountGasIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountGenericIcon.js +89 -0
- package/src/components/molecules/obligation/icons/AccountMedicalIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountWaterIcon.js +94 -0
- package/src/components/molecules/obligation/icons/PropertyApartmentIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyBusinessIcon.js +94 -0
- package/src/components/molecules/obligation/icons/PropertyCarIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyCommercialVehicleIcon.js +100 -0
- package/src/components/molecules/obligation/icons/PropertyGarageIcon.js +96 -0
- package/src/components/molecules/obligation/icons/PropertyLandIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyMotorcycleIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +94 -0
- package/src/components/molecules/obligation/icons/PropertyStorefrontIcon.js +100 -0
- package/src/components/molecules/obligation/icons/index.js +60 -0
- package/src/components/molecules/obligation/index.js +3 -0
- package/src/components/molecules/obligation/modules/AmountModule.js +36 -0
- package/src/components/molecules/obligation/modules/IconModule.js +29 -0
- package/src/components/molecules/obligation/modules/PaymentDetailsActions.js +67 -0
- package/src/components/molecules/obligation/modules/TitleModule.js +25 -0
- package/src/components/molecules/obligation/modules/index.js +6 -0
- package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +80 -0
- package/src/components/molecules/payment-button-bar/index.js +3 -0
- package/src/components/molecules/payment-details/PaymentDetails.js +158 -0
- package/src/components/molecules/payment-details/PaymentDetails.theme.js +11 -0
- package/src/components/molecules/payment-details/index.js +1 -0
- package/src/components/molecules/phone-form/PhoneForm.js +44 -0
- package/src/components/molecules/phone-form/PhoneForm.state.js +17 -0
- package/src/components/molecules/phone-form/index.js +11 -0
- package/src/components/molecules/radio-section/RadioSection.js +205 -0
- package/src/components/molecules/radio-section/RadioSection.theme.js +15 -0
- package/src/components/molecules/radio-section/index.js +3 -0
- package/src/components/molecules/registration-form/RegistrationForm.js +104 -0
- package/src/components/molecules/registration-form/RegistrationForm.state.js +40 -0
- package/src/components/molecules/registration-form/index.js +11 -0
- package/src/components/molecules/reset-confirmation-form/ResetConfirmationForm.js +56 -0
- package/src/components/molecules/reset-confirmation-form/index.js +3 -0
- package/src/components/molecules/reset-password-form/ResetPasswordForm.js +67 -0
- package/src/components/molecules/reset-password-form/ResetPasswordForm.state.js +30 -0
- package/src/components/molecules/reset-password-form/index.js +11 -0
- package/src/components/molecules/reset-password-success/ResetPasswordSuccess.js +55 -0
- package/src/components/molecules/reset-password-success/index.js +3 -0
- package/src/components/molecules/tab-sidebar/TabSidebar.js +92 -0
- package/src/components/molecules/tab-sidebar/TabSidebar.theme.js +9 -0
- package/src/components/molecules/tab-sidebar/index.js +3 -0
- package/src/components/molecules/terms-and-conditions/TermsAndConditions.js +73 -0
- package/src/components/molecules/terms-and-conditions/index.js +3 -0
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +64 -0
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.theme.js +28 -0
- package/src/components/molecules/terms-and-conditions-modal/index.js +3 -0
- package/src/components/molecules/workflow-tile/WorkflowTile.js +58 -0
- package/src/components/molecules/workflow-tile/index.js +3 -0
- package/src/components/templates/center-single/CenterSingle.js +61 -0
- package/src/components/templates/center-single/index.js +3 -0
- package/src/components/templates/center-stack/CenterStack.js +49 -0
- package/src/components/templates/center-stack/index.js +3 -0
- package/src/components/templates/default-page-template/DefaultPageTemplate.js +49 -0
- package/src/components/templates/default-page-template/index.js +3 -0
- package/src/components/templates/index.js +5 -0
- package/src/components/templates/sidebar-single-content/SidebarSingleContent.js +60 -0
- package/src/components/templates/sidebar-single-content/index.js +3 -0
- package/src/components/templates/sidebar-stack-content/SidebarStackContent.js +81 -0
- package/src/components/templates/sidebar-stack-content/index.js +3 -0
- package/src/components/templates/templates.theme.js +5 -0
- package/src/components/withWindowSize.js +50 -0
- package/src/constants/colors.js +178 -0
- package/src/constants/regex_constants.js +1 -0
- package/src/constants/style_constants.js +21 -0
- package/src/deprecated/colors.js +154 -0
- package/src/deprecated/components/radio-button/index.js +3 -0
- package/src/deprecated/components/radio-button/radio-button.js +44 -0
- package/src/deprecated/icons/AlertErrorIcon.js +42 -0
- package/src/deprecated/icons/AlertInfoIcon.js +42 -0
- package/src/deprecated/icons/AlertSuccessIcon.js +42 -0
- package/src/deprecated/icons/AlertWarningIcon.js +36 -0
- package/src/deprecated/icons/BankIcon.js +82 -0
- package/src/deprecated/icons/GenericCard.js +39 -0
- package/src/deprecated/icons/IconAdd.js +44 -0
- package/src/deprecated/icons/IconCheck.js +23 -0
- package/src/deprecated/icons/IconCheckEmail.js +46 -0
- package/src/deprecated/icons/IconChevron.js +35 -0
- package/src/deprecated/icons/IconEmailVerified.js +62 -0
- package/src/deprecated/icons/IconEye.js +32 -0
- package/src/deprecated/icons/IconEyeSlash.js +48 -0
- package/src/deprecated/icons/IconInvalid.js +69 -0
- package/src/deprecated/icons/IconNeutral.js +27 -0
- package/src/deprecated/icons/IconQuit.js +32 -0
- package/src/deprecated/icons/IconValid.js +72 -0
- package/src/deprecated/icons/IconWarn.js +28 -0
- package/src/deprecated/icons/index.js +40 -0
- package/src/deprecated/index.js +1 -0
- package/src/deprecated/spinner/Spinner.js +68 -0
- package/src/deprecated/spinner/index.js +1 -0
- package/src/deprecated/utility/__tests__/safeConcat.spec.js +59 -0
- package/src/deprecated/utility/__tests__/validateKeyType.spec.js +116 -0
- package/src/deprecated/utility/index.js +2 -0
- package/src/deprecated/utility/safeConcat.js +10 -0
- package/src/deprecated/utility/validateKeyType.js +19 -0
- package/src/index.js +2 -0
- package/src/util/formats.js +30 -0
- package/src/util/general.js +15 -0
- package/src/util/inputValidationUtils.js +257 -0
- package/src/util/router-utils.js +23 -0
- package/src/util/themeUtils.js +144 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { fallbackValues } from "./Text.theme";
|
|
3
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
4
|
+
import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
|
|
5
|
+
import { FIREFLY_GREY } from "../../../constants/colors";
|
|
6
|
+
import { TextSpan } from "./Text.styled";
|
|
7
|
+
import { safeChildren } from "../../../util/general";
|
|
8
|
+
|
|
9
|
+
const Text = ({
|
|
10
|
+
themeValues,
|
|
11
|
+
weight = FONT_WEIGHT_REGULAR,
|
|
12
|
+
color = FIREFLY_GREY,
|
|
13
|
+
extraStyles = ``,
|
|
14
|
+
hoverStyles,
|
|
15
|
+
focusStyles,
|
|
16
|
+
onClick,
|
|
17
|
+
dataQa,
|
|
18
|
+
children,
|
|
19
|
+
...rest
|
|
20
|
+
}) => (
|
|
21
|
+
<TextSpan
|
|
22
|
+
fontSize={themeValues.fontSize}
|
|
23
|
+
weight={weight}
|
|
24
|
+
color={color}
|
|
25
|
+
fontFamily={themeValues.fontFamily}
|
|
26
|
+
extraStyles={extraStyles}
|
|
27
|
+
hoverStyles={hoverStyles}
|
|
28
|
+
focusStyles={focusStyles}
|
|
29
|
+
onClick={onClick}
|
|
30
|
+
data-qa={dataQa}
|
|
31
|
+
{...rest}
|
|
32
|
+
>
|
|
33
|
+
{safeChildren(children, <span />)}
|
|
34
|
+
</TextSpan>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export default themeComponent(Text, "Text", fallbackValues, "p");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const TextSpan = styled.span`
|
|
4
|
+
--font-size: ${({ fontSize }) => fontSize};
|
|
5
|
+
font-size: var(--font-size);
|
|
6
|
+
line-height: calc(1.5 * var(--font-size));
|
|
7
|
+
font-weight: ${({ weight }) => weight};
|
|
8
|
+
font-family: ${({ fontFamily }) => fontFamily};
|
|
9
|
+
color: ${({ color }) => color};
|
|
10
|
+
|
|
11
|
+
&:hover {
|
|
12
|
+
${({ hoverStyles }) =>
|
|
13
|
+
css`
|
|
14
|
+
${hoverStyles}
|
|
15
|
+
`}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:focus {
|
|
19
|
+
${({ focusStyles }) =>
|
|
20
|
+
css`
|
|
21
|
+
${focusStyles}
|
|
22
|
+
`}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${({ disabled, disabledStyles }) =>
|
|
26
|
+
disabled &&
|
|
27
|
+
css`
|
|
28
|
+
${disabledStyles}
|
|
29
|
+
`}
|
|
30
|
+
|
|
31
|
+
${({ extraStyles }) => extraStyles}
|
|
32
|
+
`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const fontFamily = {
|
|
2
|
+
primary: "Public Sans",
|
|
3
|
+
secondary: "Open Sans"
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// Text uses the same variants as paragraph
|
|
7
|
+
// Use a Paragraph if you want a block level element
|
|
8
|
+
// Use a Text if you want an inline element
|
|
9
|
+
|
|
10
|
+
const fontSize = {
|
|
11
|
+
p: "1rem",
|
|
12
|
+
pL: "1.125rem",
|
|
13
|
+
pS: "0.875rem",
|
|
14
|
+
pXS: "0.75rem",
|
|
15
|
+
pXXS: "0.65rem",
|
|
16
|
+
pXL: "1.5rem"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const fallbackValues = {
|
|
20
|
+
fontFamily,
|
|
21
|
+
fontSize
|
|
22
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import posed from "react-pose";
|
|
4
|
+
import { fallbackValues } from "./ToggleSwitch.theme";
|
|
5
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
6
|
+
import Heading from "../heading";
|
|
7
|
+
import { Box, Center, Cover, Cluster } from "../layouts";
|
|
8
|
+
import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
|
|
9
|
+
import { CHARADE_GREY } from "../../../constants/colors";
|
|
10
|
+
|
|
11
|
+
const HiddenToggleSwitchBox = styled.input`
|
|
12
|
+
opacity: 0;
|
|
13
|
+
position: absolute;
|
|
14
|
+
cursor: ${({ disabled }) => (disabled ? "auto" : "pointer")};
|
|
15
|
+
height: 24px;
|
|
16
|
+
width: 50px;
|
|
17
|
+
${({ isMobile }) => (isMobile ? `transform: scale(0.75)` : ``)}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const VisibleSwitchComponent = styled.label`
|
|
21
|
+
width: 48px;
|
|
22
|
+
height: 24px;
|
|
23
|
+
border-radius: 48px;
|
|
24
|
+
border: none;
|
|
25
|
+
position: relative;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
cursor: ${({ disabled }) => (disabled ? "auto" : "pointer")};
|
|
28
|
+
display: inline-block;
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
box-shadow: ${({ disabled }) =>
|
|
32
|
+
disabled ? "none" : "0px 2px 5px 0px rgba(0, 0, 0, 0.5) !important"};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:focus {
|
|
36
|
+
box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.5);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
${({ isMobile }) => (isMobile ? `transform: scale(0.75)` : ``)}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const ToggleSwitchMiddleRingComponent = styled.div`
|
|
43
|
+
position: absolute;
|
|
44
|
+
width: 20px;
|
|
45
|
+
height: 20px;
|
|
46
|
+
border: none;
|
|
47
|
+
border-radius: 50%;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const ToggleSwitchInnerRingComponent = styled.div`
|
|
52
|
+
position: absolute;
|
|
53
|
+
width: 14px;
|
|
54
|
+
height: 14px;
|
|
55
|
+
top: 3px;
|
|
56
|
+
left: 3px;
|
|
57
|
+
right: 3px;
|
|
58
|
+
bottom: 3px;
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const ToggleSwitch = ({
|
|
64
|
+
isOn = false,
|
|
65
|
+
onToggle = noop,
|
|
66
|
+
disabled = false,
|
|
67
|
+
name = "",
|
|
68
|
+
label = null,
|
|
69
|
+
labelLeft = false,
|
|
70
|
+
themeValues,
|
|
71
|
+
isMobile,
|
|
72
|
+
dataQa
|
|
73
|
+
}) => {
|
|
74
|
+
const ToggleSwitchInnerRing = posed(ToggleSwitchInnerRingComponent)({
|
|
75
|
+
off: {
|
|
76
|
+
backgroundColor: themeValues.offBackground,
|
|
77
|
+
transition: {
|
|
78
|
+
ease: "easeOut"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
on: {
|
|
82
|
+
backgroundColor: themeValues.onBackground,
|
|
83
|
+
transition: {
|
|
84
|
+
ease: "easeIn"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
disabled: {
|
|
88
|
+
backgroundColor: themeValues.disabledBackground
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const ToggleSwitchMiddleRing = posed(ToggleSwitchMiddleRingComponent)({
|
|
93
|
+
off: {
|
|
94
|
+
backgroundColor: themeValues.white,
|
|
95
|
+
left: "2px",
|
|
96
|
+
top: "2px",
|
|
97
|
+
bottom: "2px",
|
|
98
|
+
right: "24px",
|
|
99
|
+
transition: {
|
|
100
|
+
ease: "backIn"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
on: {
|
|
104
|
+
backgroundColor: themeValues.white,
|
|
105
|
+
right: "2px",
|
|
106
|
+
top: "2px",
|
|
107
|
+
bottom: "2px",
|
|
108
|
+
left: "24px",
|
|
109
|
+
transition: {
|
|
110
|
+
ease: "backIn"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
disabled: {
|
|
114
|
+
backgroundColor: themeValues.white,
|
|
115
|
+
left: "2px",
|
|
116
|
+
top: "2px",
|
|
117
|
+
bottom: "2px",
|
|
118
|
+
right: "24px"
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const VisibleSwitch = posed(VisibleSwitchComponent)({
|
|
123
|
+
focusable: true,
|
|
124
|
+
hoverable: true,
|
|
125
|
+
pressable: true,
|
|
126
|
+
focus: {
|
|
127
|
+
outline: "0px ridge rgba(170, 50, 220, 0)",
|
|
128
|
+
boxShadow: "0px 2px 5px 0px rgba(0,0,0,0.5)"
|
|
129
|
+
},
|
|
130
|
+
hover: {
|
|
131
|
+
boxShadow: "0px 2px 5px 0px rgba(0,0,0,0.5)"
|
|
132
|
+
},
|
|
133
|
+
off: {
|
|
134
|
+
backgroundColor: themeValues.offBackground,
|
|
135
|
+
transition: {
|
|
136
|
+
ease: "easeOut"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
on: {
|
|
140
|
+
backgroundColor: themeValues.onBackground,
|
|
141
|
+
transition: {
|
|
142
|
+
ease: "easeIn"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
disabled: {
|
|
146
|
+
backgroundColor: themeValues.disabledBackground
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const handleKeyDown = e => {
|
|
151
|
+
if (e.keyCode === 13) {
|
|
152
|
+
onToggle();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<Box
|
|
158
|
+
padding="0"
|
|
159
|
+
extraStyles={
|
|
160
|
+
labelLeft ? themeValues.leftLabelStyles : themeValues.rightLabelStyles
|
|
161
|
+
}
|
|
162
|
+
focusStyles={`outline: ${themeValues.onBackground} auto 5px`}
|
|
163
|
+
>
|
|
164
|
+
<Center>
|
|
165
|
+
<Cluster justify="stretch" align="center">
|
|
166
|
+
<Cover minHeight="100%" singleChild>
|
|
167
|
+
<Box
|
|
168
|
+
minWidth="100%"
|
|
169
|
+
padding="0"
|
|
170
|
+
extraStyles={`display: flex; align-items: center;`}
|
|
171
|
+
dataQa={dataQa}
|
|
172
|
+
>
|
|
173
|
+
<HiddenToggleSwitchBox
|
|
174
|
+
checked={isOn}
|
|
175
|
+
onChange={disabled ? noop : onToggle}
|
|
176
|
+
disabled={disabled}
|
|
177
|
+
id={`#toggle-${name}`}
|
|
178
|
+
isMobile={isMobile}
|
|
179
|
+
/>
|
|
180
|
+
<VisibleSwitch
|
|
181
|
+
name={name}
|
|
182
|
+
htmlFor={`#toggle-${name}`}
|
|
183
|
+
onClick={disabled ? noop : onToggle}
|
|
184
|
+
onKeyDown={disabled ? noop : handleKeyDown}
|
|
185
|
+
pose={disabled ? "disabled" : isOn ? "on" : "off"}
|
|
186
|
+
tabIndex={disabled ? -1 : 0}
|
|
187
|
+
disabled={disabled}
|
|
188
|
+
isMobile={isMobile}
|
|
189
|
+
>
|
|
190
|
+
<ToggleSwitchMiddleRing>
|
|
191
|
+
<ToggleSwitchInnerRing />
|
|
192
|
+
</ToggleSwitchMiddleRing>
|
|
193
|
+
</VisibleSwitch>
|
|
194
|
+
</Box>
|
|
195
|
+
</Cover>
|
|
196
|
+
{label && (
|
|
197
|
+
<Heading
|
|
198
|
+
variant={"h4"}
|
|
199
|
+
weight={FONT_WEIGHT_SEMIBOLD}
|
|
200
|
+
extraStyles={`margin: 0 0.5rem; position: relative; bottom: 1px; display: inline-block;`}
|
|
201
|
+
color={CHARADE_GREY}
|
|
202
|
+
>
|
|
203
|
+
{label}
|
|
204
|
+
</Heading>
|
|
205
|
+
)}
|
|
206
|
+
</Cluster>
|
|
207
|
+
</Center>
|
|
208
|
+
</Box>
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export default themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WHITE,
|
|
3
|
+
REGENT_GREY,
|
|
4
|
+
IRON_GREY,
|
|
5
|
+
MATISSE_BLUE
|
|
6
|
+
} from "../../../constants/colors";
|
|
7
|
+
|
|
8
|
+
const onBackground = `${MATISSE_BLUE}`;
|
|
9
|
+
const disabledBackground = `${IRON_GREY}`;
|
|
10
|
+
const white = `${WHITE}`;
|
|
11
|
+
const offBackground = `${REGENT_GREY}`;
|
|
12
|
+
|
|
13
|
+
const labelStyles = `
|
|
14
|
+
display: flex;
|
|
15
|
+
justify-content: flex-start;
|
|
16
|
+
align-items: center;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const rightLabelStyles = `
|
|
20
|
+
${labelStyles}
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
const leftLabelStyles = `
|
|
25
|
+
${labelStyles}
|
|
26
|
+
flex-direction: row-reverse;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const fallbackValues = {
|
|
30
|
+
onBackground,
|
|
31
|
+
disabledBackground,
|
|
32
|
+
white,
|
|
33
|
+
offBackground,
|
|
34
|
+
rightLabelStyles,
|
|
35
|
+
leftLabelStyles
|
|
36
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { required, hasLength } from "redux-freeform";
|
|
3
|
+
import StateProvinceDropdown from "../../atoms/state-province-dropdown";
|
|
4
|
+
// import CountryDropdown from "../../atoms/country-dropdown";
|
|
5
|
+
import { zipFormat } from "../../../util/formats";
|
|
6
|
+
import {
|
|
7
|
+
FormInput,
|
|
8
|
+
FormContainer,
|
|
9
|
+
FormInputColumn
|
|
10
|
+
} from "../../atoms/form-layouts";
|
|
11
|
+
|
|
12
|
+
const AddressForm = ({
|
|
13
|
+
variant = "default",
|
|
14
|
+
fields,
|
|
15
|
+
actions,
|
|
16
|
+
clearOnDismount,
|
|
17
|
+
showErrors,
|
|
18
|
+
handleSubmit
|
|
19
|
+
}) => {
|
|
20
|
+
if (clearOnDismount) {
|
|
21
|
+
useEffect(() => () => actions.form.clear(), []);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const street1ErrorMessages = {
|
|
25
|
+
[required.error]: "Street is required"
|
|
26
|
+
};
|
|
27
|
+
const cityErrorMessages = {
|
|
28
|
+
[required.error]: "City is required"
|
|
29
|
+
};
|
|
30
|
+
const zipErrorMessages = {
|
|
31
|
+
[required.error]: "Zip code is required",
|
|
32
|
+
[hasLength.error]: "Zip code must be 5 or 9 digits"
|
|
33
|
+
};
|
|
34
|
+
const stateProvinceErrorMessages = {
|
|
35
|
+
[required.error]: "State or Province is required"
|
|
36
|
+
};
|
|
37
|
+
// const countryErrorMessages = {
|
|
38
|
+
// [required.error]: "Country is required"
|
|
39
|
+
// };
|
|
40
|
+
|
|
41
|
+
const isUS = fields.country.rawValue === "US";
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<FormContainer variant={variant} role="form" aria-label="Address">
|
|
45
|
+
<FormInputColumn>
|
|
46
|
+
{/* <CountryDropdown
|
|
47
|
+
labelTextWhenNoError="Country"
|
|
48
|
+
errorMessages={countryErrorMessages}
|
|
49
|
+
field={fields.country}
|
|
50
|
+
onChange={value => {
|
|
51
|
+
actions.fields.country.set(value);
|
|
52
|
+
// temporary measure to not dirty fields until
|
|
53
|
+
// we can write a reset function for fields
|
|
54
|
+
if (fields.stateProvince.rawValue) {
|
|
55
|
+
actions.fields.stateProvince.set("");
|
|
56
|
+
}
|
|
57
|
+
if (fields.zip.rawValue) {
|
|
58
|
+
actions.fields.zip.set("");
|
|
59
|
+
}
|
|
60
|
+
}}
|
|
61
|
+
showErrors={showErrors}
|
|
62
|
+
/> */}
|
|
63
|
+
<FormInput
|
|
64
|
+
labelTextWhenNoError="Address"
|
|
65
|
+
errorMessages={street1ErrorMessages}
|
|
66
|
+
field={fields.street1}
|
|
67
|
+
fieldActions={actions.fields.street1}
|
|
68
|
+
showErrors={showErrors}
|
|
69
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
70
|
+
/>
|
|
71
|
+
<FormInput
|
|
72
|
+
labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
|
|
73
|
+
field={fields.street2}
|
|
74
|
+
fieldActions={actions.fields.street2}
|
|
75
|
+
showErrors={showErrors}
|
|
76
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
77
|
+
/>
|
|
78
|
+
<FormInput
|
|
79
|
+
labelTextWhenNoError="City"
|
|
80
|
+
errorMessages={cityErrorMessages}
|
|
81
|
+
field={fields.city}
|
|
82
|
+
fieldActions={actions.fields.city}
|
|
83
|
+
showErrors={showErrors}
|
|
84
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
85
|
+
/>
|
|
86
|
+
<StateProvinceDropdown
|
|
87
|
+
labelTextWhenNoError={isUS ? "State" : "State or Province"}
|
|
88
|
+
errorMessages={stateProvinceErrorMessages}
|
|
89
|
+
countryCode={fields.country.rawValue}
|
|
90
|
+
field={fields.stateProvince}
|
|
91
|
+
fieldActions={actions.fields.stateProvince}
|
|
92
|
+
showErrors={showErrors}
|
|
93
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
94
|
+
/>
|
|
95
|
+
<FormInput
|
|
96
|
+
isNum={isUS}
|
|
97
|
+
formatter={isUS ? zipFormat : null}
|
|
98
|
+
labelTextWhenNoError="Zip code"
|
|
99
|
+
errorMessages={zipErrorMessages}
|
|
100
|
+
field={fields.zip}
|
|
101
|
+
fieldActions={actions.fields.zip}
|
|
102
|
+
showErrors={showErrors}
|
|
103
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
104
|
+
/>
|
|
105
|
+
</FormInputColumn>
|
|
106
|
+
</FormContainer>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default AddressForm;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createFormState,
|
|
3
|
+
required,
|
|
4
|
+
onlyIntegers,
|
|
5
|
+
hasLength,
|
|
6
|
+
validateWhen,
|
|
7
|
+
matchesRegex
|
|
8
|
+
} from "redux-freeform";
|
|
9
|
+
|
|
10
|
+
//TODO: Will make zip code able to have more than 5 digits once we add in the FormattedInput because it will have issues with format of 60606-1111.
|
|
11
|
+
|
|
12
|
+
const formConfig = {
|
|
13
|
+
street1: {
|
|
14
|
+
validators: [required()]
|
|
15
|
+
},
|
|
16
|
+
street2: {
|
|
17
|
+
validators: []
|
|
18
|
+
},
|
|
19
|
+
city: {
|
|
20
|
+
validators: [required()]
|
|
21
|
+
},
|
|
22
|
+
stateProvince: {
|
|
23
|
+
validators: [required()]
|
|
24
|
+
},
|
|
25
|
+
country: {
|
|
26
|
+
defaultValue: "US",
|
|
27
|
+
validators: [required()]
|
|
28
|
+
},
|
|
29
|
+
zip: {
|
|
30
|
+
validators: [
|
|
31
|
+
required(),
|
|
32
|
+
validateWhen(
|
|
33
|
+
validateWhen(hasLength(5, 5), hasLength(0, 5)),
|
|
34
|
+
matchesRegex("US"),
|
|
35
|
+
"country"
|
|
36
|
+
),
|
|
37
|
+
validateWhen(
|
|
38
|
+
validateWhen(hasLength(9, 9), hasLength(6, 9)),
|
|
39
|
+
matchesRegex("US"),
|
|
40
|
+
"country"
|
|
41
|
+
)
|
|
42
|
+
],
|
|
43
|
+
constraints: [
|
|
44
|
+
validateWhen(onlyIntegers(), matchesRegex("US"), "country"),
|
|
45
|
+
validateWhen(hasLength(0, 9), matchesRegex("US"), "country")
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const { reducer, mapStateToProps, mapDispatchToProps } = createFormState(
|
|
51
|
+
formConfig
|
|
52
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import AddressFrom from "./AddressForm";
|
|
2
|
+
import {
|
|
3
|
+
reducer,
|
|
4
|
+
mapStateToProps,
|
|
5
|
+
mapDispatchToProps,
|
|
6
|
+
} from "./AddressForm.state";
|
|
7
|
+
|
|
8
|
+
AddressFrom.reducer = reducer;
|
|
9
|
+
AddressFrom.mapStateToProps = mapStateToProps;
|
|
10
|
+
AddressFrom.mapDispatchToProps = mapDispatchToProps;
|
|
11
|
+
export default AddressFrom;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import {
|
|
3
|
+
required,
|
|
4
|
+
hasLength,
|
|
5
|
+
matchesField,
|
|
6
|
+
hasNumber,
|
|
7
|
+
hasLowercaseLetter,
|
|
8
|
+
hasUppercaseLetter,
|
|
9
|
+
hasSpecialCharacter
|
|
10
|
+
} from "redux-freeform";
|
|
11
|
+
import {
|
|
12
|
+
FormInput,
|
|
13
|
+
FormContainer,
|
|
14
|
+
FormInputColumn
|
|
15
|
+
} from "../../atoms/form-layouts";
|
|
16
|
+
import { Box, Cluster } from "../../atoms/layouts";
|
|
17
|
+
import PasswordRequirements from "../../atoms/password-requirements";
|
|
18
|
+
|
|
19
|
+
const ChangePasswordForm = ({
|
|
20
|
+
clearOnDismount,
|
|
21
|
+
fields,
|
|
22
|
+
actions,
|
|
23
|
+
handleSubmit,
|
|
24
|
+
showErrors,
|
|
25
|
+
isMobile
|
|
26
|
+
}) => {
|
|
27
|
+
if (clearOnDismount) {
|
|
28
|
+
useEffect(() => () => actions.form.clear(), []);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const currentPasswordErrorMessages = {
|
|
32
|
+
[required.error]: "Current Password is required"
|
|
33
|
+
};
|
|
34
|
+
const newPasswordErrorMessages = {
|
|
35
|
+
[required.error]: "New Password field is required.",
|
|
36
|
+
[hasLength.error]: "Your new password must have at least 8 characters",
|
|
37
|
+
[hasNumber.error]: "Your new password must contain at least one number",
|
|
38
|
+
[hasLowercaseLetter.error]:
|
|
39
|
+
"Your new password must contain at least one lowercase letter",
|
|
40
|
+
[hasUppercaseLetter.error]:
|
|
41
|
+
"Your new password must contain at least one uppercase letter",
|
|
42
|
+
[hasSpecialCharacter.error]:
|
|
43
|
+
"Your new password must contain at least one special character (!@#$%^&*.?)"
|
|
44
|
+
};
|
|
45
|
+
const confirmNewPasswordErrorMessages = {
|
|
46
|
+
[matchesField.error]: "Confirm password must match your new password"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<FormContainer role="form" aria-label="Change password">
|
|
51
|
+
<FormInputColumn>
|
|
52
|
+
<FormInput
|
|
53
|
+
labelTextWhenNoError="Current password"
|
|
54
|
+
errorMessages={currentPasswordErrorMessages}
|
|
55
|
+
field={fields.currentPassword}
|
|
56
|
+
fieldActions={actions.fields.currentPassword}
|
|
57
|
+
showErrors={showErrors}
|
|
58
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
59
|
+
type="password"
|
|
60
|
+
/>
|
|
61
|
+
<FormInput
|
|
62
|
+
labelTextWhenNoError="New password"
|
|
63
|
+
errorMessages={newPasswordErrorMessages}
|
|
64
|
+
field={fields.newPassword}
|
|
65
|
+
fieldActions={actions.fields.newPassword}
|
|
66
|
+
showErrors={showErrors}
|
|
67
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
68
|
+
type="password"
|
|
69
|
+
/>
|
|
70
|
+
<FormInput
|
|
71
|
+
labelTextWhenNoError="Confirm password"
|
|
72
|
+
errorMessages={confirmNewPasswordErrorMessages}
|
|
73
|
+
field={fields.confirmNewPassword}
|
|
74
|
+
fieldActions={actions.fields.confirmNewPassword}
|
|
75
|
+
showErrors={showErrors}
|
|
76
|
+
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
77
|
+
type="password"
|
|
78
|
+
/>
|
|
79
|
+
</FormInputColumn>
|
|
80
|
+
<Box padding={isMobile ? "1rem 0 0" : "1.5rem 0 0"}>
|
|
81
|
+
<Cluster justify="center" align="center">
|
|
82
|
+
<PasswordRequirements
|
|
83
|
+
password={fields.newPassword}
|
|
84
|
+
isMobile={isMobile}
|
|
85
|
+
/>
|
|
86
|
+
</Cluster>
|
|
87
|
+
</Box>
|
|
88
|
+
</FormContainer>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default ChangePasswordForm;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createFormState,
|
|
3
|
+
required,
|
|
4
|
+
matchesField,
|
|
5
|
+
hasLength,
|
|
6
|
+
hasNumber,
|
|
7
|
+
hasLowercaseLetter,
|
|
8
|
+
hasUppercaseLetter,
|
|
9
|
+
hasSpecialCharacter
|
|
10
|
+
} from "redux-freeform";
|
|
11
|
+
|
|
12
|
+
const formConfig = {
|
|
13
|
+
currentPassword: {
|
|
14
|
+
validators: [required()]
|
|
15
|
+
},
|
|
16
|
+
newPassword: {
|
|
17
|
+
validators: [
|
|
18
|
+
required(),
|
|
19
|
+
hasLength(8, 100),
|
|
20
|
+
hasNumber(),
|
|
21
|
+
hasLowercaseLetter(),
|
|
22
|
+
hasUppercaseLetter(),
|
|
23
|
+
hasSpecialCharacter()
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
confirmNewPassword: {
|
|
27
|
+
validators: [required(), matchesField("newPassword")]
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const { reducer, mapStateToProps, mapDispatchToProps } = createFormState(
|
|
32
|
+
formConfig
|
|
33
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ChangePasswordForm from "./ChangePasswordForm";
|
|
2
|
+
import {
|
|
3
|
+
reducer,
|
|
4
|
+
mapStateToProps,
|
|
5
|
+
mapDispatchToProps,
|
|
6
|
+
} from "./ChangePasswordForm.state";
|
|
7
|
+
|
|
8
|
+
ChangePasswordForm.reducer = reducer;
|
|
9
|
+
ChangePasswordForm.mapStateToProps = mapStateToProps;
|
|
10
|
+
ChangePasswordForm.mapDispatchToProps = mapDispatchToProps;
|
|
11
|
+
export default ChangePasswordForm;
|