@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,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Stack from "../layouts/Stack";
|
|
3
|
+
import Box from "../layouts/Box";
|
|
4
|
+
import Text from "../text";
|
|
5
|
+
import Paragraph from "../paragraph";
|
|
6
|
+
import Cluster from "../layouts/Cluster";
|
|
7
|
+
import ButtonWithAction from "../button-with-action";
|
|
8
|
+
import ButtonWithLink from "../button-with-link";
|
|
9
|
+
import { WHITE, CHARADE_GREY } from "../../../constants/colors";
|
|
10
|
+
|
|
11
|
+
const DisplayCard = ({
|
|
12
|
+
title,
|
|
13
|
+
item,
|
|
14
|
+
buttonText,
|
|
15
|
+
buttonAction,
|
|
16
|
+
url,
|
|
17
|
+
link = false
|
|
18
|
+
}) => (
|
|
19
|
+
<Box padding="0 0 16px">
|
|
20
|
+
<Stack childGap="0rem">
|
|
21
|
+
<Box padding="0 0 8px 0">
|
|
22
|
+
<Paragraph
|
|
23
|
+
variant="pL"
|
|
24
|
+
color={CHARADE_GREY}
|
|
25
|
+
extraStyles={`letter-spacing: 0.29px`}
|
|
26
|
+
>
|
|
27
|
+
{title}
|
|
28
|
+
</Paragraph>
|
|
29
|
+
</Box>
|
|
30
|
+
<Box padding="0">
|
|
31
|
+
<Box
|
|
32
|
+
padding="24px"
|
|
33
|
+
borderSize="1px"
|
|
34
|
+
borderRadius="4px"
|
|
35
|
+
background={WHITE}
|
|
36
|
+
boxShadow="0px 2px 14px 0px rgb(246, 246, 249),
|
|
37
|
+
0px 3px 8px 0px rgb(202, 206, 216)"
|
|
38
|
+
>
|
|
39
|
+
<Cluster justify="space-between" align="center">
|
|
40
|
+
<Text variant="p" color={CHARADE_GREY}>
|
|
41
|
+
{item}
|
|
42
|
+
</Text>
|
|
43
|
+
{link ? (
|
|
44
|
+
<ButtonWithLink
|
|
45
|
+
text={buttonText}
|
|
46
|
+
url={url}
|
|
47
|
+
variant="smallGhost"
|
|
48
|
+
dataQa={buttonText}
|
|
49
|
+
/>
|
|
50
|
+
) : (
|
|
51
|
+
<ButtonWithAction
|
|
52
|
+
text={buttonText}
|
|
53
|
+
action={buttonAction}
|
|
54
|
+
variant="smallGhost"
|
|
55
|
+
dataQa={buttonText}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
</Cluster>
|
|
59
|
+
</Box>
|
|
60
|
+
</Box>
|
|
61
|
+
</Stack>
|
|
62
|
+
</Box>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export default DisplayCard;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import React, { useEffect, Fragment, useState, useRef, createRef } from "react";
|
|
2
|
+
import { pipe, find, map, prop, fromMaybe } from "sanctuary";
|
|
3
|
+
import { Box, Stack } from "../layouts";
|
|
4
|
+
import Text from "../text";
|
|
5
|
+
import { noop } from "../../../util/general";
|
|
6
|
+
import DropdownIcon from "./DropdownIcon";
|
|
7
|
+
import styled from "styled-components";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
WHITE,
|
|
11
|
+
GREY_CHATEAU,
|
|
12
|
+
MINESHAFT_GREY,
|
|
13
|
+
ERROR_COLOR
|
|
14
|
+
} from "../../../constants/colors";
|
|
15
|
+
import { fallbackValues } from "./Dropdown.theme";
|
|
16
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
17
|
+
|
|
18
|
+
const IconWrapper = styled.div`
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
transition: transform 0.3s ease;
|
|
23
|
+
${({ open }) => (open ? "transform: rotate(-180deg)" : "")}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const DropdownContentWrapper = styled.div`
|
|
27
|
+
transform-origin: 0 0;
|
|
28
|
+
border: 1px solid ${GREY_CHATEAU};
|
|
29
|
+
border-radius: 2px;
|
|
30
|
+
background-color: ${WHITE};
|
|
31
|
+
padding: 8px 0 8px;
|
|
32
|
+
position: absolute;
|
|
33
|
+
width: 100%;
|
|
34
|
+
max-height: 400px;
|
|
35
|
+
overflow-y: scroll;
|
|
36
|
+
z-index: 1;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
&:focus {
|
|
39
|
+
outline: none;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
const DropdownItemWrapper = styled.div`
|
|
44
|
+
background-color: ${({ selected, themeValues }) =>
|
|
45
|
+
selected ? themeValues.selectedColor : WHITE};
|
|
46
|
+
text-align: start;
|
|
47
|
+
border-size: 0px;
|
|
48
|
+
border-color: transparent;
|
|
49
|
+
box-shadow: none;
|
|
50
|
+
padding: 1rem;
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
width: 100%;
|
|
53
|
+
|
|
54
|
+
&:hover {
|
|
55
|
+
background-color: ${({ selected, disabled, themeValues }) =>
|
|
56
|
+
selected
|
|
57
|
+
? themeValues.selectedColor
|
|
58
|
+
: disabled
|
|
59
|
+
? WHITE
|
|
60
|
+
: themeValues.hoverColor};
|
|
61
|
+
}
|
|
62
|
+
&:focus {
|
|
63
|
+
background-color: ${({ selected, disabled, themeValues }) =>
|
|
64
|
+
selected
|
|
65
|
+
? themeValues.selectedColor
|
|
66
|
+
: disabled
|
|
67
|
+
? WHITE
|
|
68
|
+
: themeValues.hoverColor};
|
|
69
|
+
outline: none;
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const SearchInput = styled.input`
|
|
74
|
+
border: none;
|
|
75
|
+
background-color: ${({ themeValues }) =>
|
|
76
|
+
themeValues.hoverColor && themeValues.hoverColor};
|
|
77
|
+
font-size: 16px;
|
|
78
|
+
height: 24px;
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
const Dropdown = ({
|
|
82
|
+
placeholder,
|
|
83
|
+
options,
|
|
84
|
+
value,
|
|
85
|
+
isOpen,
|
|
86
|
+
isError,
|
|
87
|
+
onSelect,
|
|
88
|
+
disabledValues = [],
|
|
89
|
+
onClick = noop,
|
|
90
|
+
themeValues
|
|
91
|
+
}) => {
|
|
92
|
+
const [inputValue, setInputValue] = useState("");
|
|
93
|
+
const [optionsState, setOptionsState] = useState([]);
|
|
94
|
+
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
95
|
+
const [optionsChanged, setOptionsChanged] = useState(true);
|
|
96
|
+
|
|
97
|
+
if (optionsState !== options) {
|
|
98
|
+
setOptionsState(options);
|
|
99
|
+
setOptionsChanged(true);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (optionsChanged) {
|
|
103
|
+
setFilteredOptions(options);
|
|
104
|
+
setOptionsChanged(false);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const [timer, setTimer] = useState(null);
|
|
108
|
+
const optionRefs = useRef([...Array(options.length)].map(() => createRef()));
|
|
109
|
+
const dropdownRef = useRef(null);
|
|
110
|
+
|
|
111
|
+
const onKeyDown = e => {
|
|
112
|
+
const { key, keyCode } = e;
|
|
113
|
+
const focus = document.activeElement;
|
|
114
|
+
const optionEl = optionRefs.current.find(ref => ref.current === focus);
|
|
115
|
+
switch (key) {
|
|
116
|
+
case "ArrowDown":
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
if (optionEl) {
|
|
119
|
+
if (optionEl.current.nextElementSibling) {
|
|
120
|
+
optionEl.current.nextElementSibling.focus();
|
|
121
|
+
} else {
|
|
122
|
+
// If at the end of the options list, don't do anything
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
onClick();
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
case "ArrowUp":
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
if (optionEl) {
|
|
132
|
+
if (optionEl.current.previousElementSibling) {
|
|
133
|
+
optionEl.current.previousElementSibling.focus();
|
|
134
|
+
} else {
|
|
135
|
+
// If at the start of the options list, don't do anything
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
onClick();
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
case "Tab":
|
|
143
|
+
if (isOpen) {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case "Backspace" || "Delete":
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
setInputValue(inputValue.slice(0, -1));
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if ((keyCode > 64 && keyCode < 91) || keyCode == 32) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
setInputValue(inputValue + key);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (isOpen && optionRefs.current[0].current) {
|
|
160
|
+
optionRefs.current[0].current.focus();
|
|
161
|
+
}
|
|
162
|
+
clearTimeout(timer);
|
|
163
|
+
setInputValue("");
|
|
164
|
+
}, [isOpen]);
|
|
165
|
+
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
clearTimeout(timer);
|
|
168
|
+
setTimer(setTimeout(() => setInputValue(""), 2000));
|
|
169
|
+
|
|
170
|
+
setFilteredOptions(
|
|
171
|
+
options.filter(
|
|
172
|
+
option =>
|
|
173
|
+
option.value.toLowerCase().startsWith(inputValue.toLowerCase()) ||
|
|
174
|
+
option.text.toLowerCase().startsWith(inputValue.toLowerCase())
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
}, [inputValue]);
|
|
178
|
+
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (
|
|
181
|
+
!isOpen &&
|
|
182
|
+
filteredOptions[0] &&
|
|
183
|
+
!disabledValues.includes(filteredOptions[0].value) &&
|
|
184
|
+
filteredOptions[0].text != placeholder
|
|
185
|
+
) {
|
|
186
|
+
onSelect(filteredOptions[0].value);
|
|
187
|
+
}
|
|
188
|
+
if (optionRefs.current[0].current) {
|
|
189
|
+
optionRefs.current[0].current.focus();
|
|
190
|
+
} else if (isOpen) {
|
|
191
|
+
dropdownRef.current.focus();
|
|
192
|
+
}
|
|
193
|
+
}, [filteredOptions]);
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<Box
|
|
197
|
+
onKeyDown={onKeyDown}
|
|
198
|
+
onClick={onClick}
|
|
199
|
+
tabIndex={0}
|
|
200
|
+
padding="0"
|
|
201
|
+
width="100%"
|
|
202
|
+
focusStyles={`background-color: ${themeValues.hoverColor};`}
|
|
203
|
+
aria-expanded={isOpen}
|
|
204
|
+
>
|
|
205
|
+
<Box
|
|
206
|
+
as="button"
|
|
207
|
+
background={isOpen ? themeValues.hoverColor : WHITE}
|
|
208
|
+
minHeight="52px"
|
|
209
|
+
width="100%"
|
|
210
|
+
padding="16px"
|
|
211
|
+
hoverStyles={`background-color: ${themeValues.hoverColor};`}
|
|
212
|
+
focusStyles={`background-color: ${themeValues.hoverColor};`}
|
|
213
|
+
borderSize="1px"
|
|
214
|
+
borderColor={
|
|
215
|
+
isError
|
|
216
|
+
? ERROR_COLOR
|
|
217
|
+
: isOpen
|
|
218
|
+
? themeValues.selectedColor
|
|
219
|
+
: GREY_CHATEAU
|
|
220
|
+
}
|
|
221
|
+
borderRadius="2px"
|
|
222
|
+
extraStyles={`tabindex: 0;`}
|
|
223
|
+
dataQa={placeholder}
|
|
224
|
+
>
|
|
225
|
+
<Stack direction="row" bottomItem={2}>
|
|
226
|
+
{isOpen ? (
|
|
227
|
+
<SearchInput
|
|
228
|
+
value={inputValue}
|
|
229
|
+
onChange={noop}
|
|
230
|
+
themeValues={themeValues}
|
|
231
|
+
/>
|
|
232
|
+
) : (
|
|
233
|
+
<Text variant="p">
|
|
234
|
+
{value
|
|
235
|
+
? pipe([
|
|
236
|
+
find(option => option.value === value),
|
|
237
|
+
map(prop("text")),
|
|
238
|
+
fromMaybe(placeholder)
|
|
239
|
+
])(options)
|
|
240
|
+
: placeholder}
|
|
241
|
+
</Text>
|
|
242
|
+
)}
|
|
243
|
+
<IconWrapper open={isOpen}>
|
|
244
|
+
<DropdownIcon />
|
|
245
|
+
</IconWrapper>
|
|
246
|
+
</Stack>
|
|
247
|
+
</Box>
|
|
248
|
+
{isOpen ? (
|
|
249
|
+
<DropdownContentWrapper open={isOpen} ref={dropdownRef} tabIndex={-1}>
|
|
250
|
+
<Stack childGap="0">
|
|
251
|
+
{filteredOptions.map((choice, i) => (
|
|
252
|
+
<DropdownItemWrapper
|
|
253
|
+
key={choice.value}
|
|
254
|
+
ref={optionRefs.current[i]}
|
|
255
|
+
as="button"
|
|
256
|
+
tabIndex={-1}
|
|
257
|
+
onClick={
|
|
258
|
+
disabledValues.includes(choice.value)
|
|
259
|
+
? evt => evt.preventDefault()
|
|
260
|
+
: () => onSelect(choice.value)
|
|
261
|
+
}
|
|
262
|
+
selected={choice.value === value}
|
|
263
|
+
disabled={disabledValues.includes(choice.value)}
|
|
264
|
+
data-qa={choice.text}
|
|
265
|
+
themeValues={themeValues}
|
|
266
|
+
>
|
|
267
|
+
<Text
|
|
268
|
+
variant="p"
|
|
269
|
+
color={
|
|
270
|
+
choice.value === value
|
|
271
|
+
? WHITE
|
|
272
|
+
: disabledValues.includes(choice.value)
|
|
273
|
+
? STORM_GREY
|
|
274
|
+
: MINESHAFT_GREY
|
|
275
|
+
}
|
|
276
|
+
extraStyles={`padding-left: 16px;
|
|
277
|
+
cursor: ${
|
|
278
|
+
disabledValues.includes(choice.value)
|
|
279
|
+
? "default"
|
|
280
|
+
: "pointer"
|
|
281
|
+
};
|
|
282
|
+
white-space: nowrap;
|
|
283
|
+
overflow: hidden;
|
|
284
|
+
text-overflow: ellipsis;`}
|
|
285
|
+
>
|
|
286
|
+
{choice.text}
|
|
287
|
+
</Text>
|
|
288
|
+
</DropdownItemWrapper>
|
|
289
|
+
))}
|
|
290
|
+
</Stack>
|
|
291
|
+
</DropdownContentWrapper>
|
|
292
|
+
) : (
|
|
293
|
+
<Fragment />
|
|
294
|
+
)}
|
|
295
|
+
</Box>
|
|
296
|
+
);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
export default themeComponent(Dropdown, "Dropdown", fallbackValues);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const DropdownIcon = () => (
|
|
4
|
+
<svg
|
|
5
|
+
version="1.2"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
overflow="visible"
|
|
8
|
+
preserveAspectRatio="none"
|
|
9
|
+
viewBox="0 0 14 10"
|
|
10
|
+
height="8"
|
|
11
|
+
width="12"
|
|
12
|
+
>
|
|
13
|
+
<g transform="translate(1 1)">
|
|
14
|
+
<g fillRule="evenodd" fill="none" id="Symbols_1548197283918">
|
|
15
|
+
<g
|
|
16
|
+
fill="#333"
|
|
17
|
+
transform="translate(-155 -22)"
|
|
18
|
+
id="Dropdown/Closed_1548197283918"
|
|
19
|
+
>
|
|
20
|
+
<polygon
|
|
21
|
+
points="165.59 22.59 161 27.17 156.41 22.59 155 24 161 30 167 24"
|
|
22
|
+
id="Path_1548197283918"
|
|
23
|
+
vectorEffect="non-scaling-stroke"
|
|
24
|
+
/>
|
|
25
|
+
</g>
|
|
26
|
+
</g>
|
|
27
|
+
</g>
|
|
28
|
+
</svg>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export default DropdownIcon;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 } from "../layouts";
|
|
6
|
+
import withWindowSize from "../../withWindowSize";
|
|
7
|
+
|
|
8
|
+
const FormContainer = ({ themeValues, children, ...rest }) => {
|
|
9
|
+
const { isMobile } = useContext(ThemeContext);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Box
|
|
13
|
+
padding={isMobile ? "1rem" : "1.5rem"}
|
|
14
|
+
background={themeValues.formBackgroundColor}
|
|
15
|
+
borderRadius="4px"
|
|
16
|
+
{...rest}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</Box>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default themeComponent(
|
|
24
|
+
withWindowSize(FormContainer),
|
|
25
|
+
"FormContainer",
|
|
26
|
+
fallbackValues,
|
|
27
|
+
"default"
|
|
28
|
+
);
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React, { useState, useContext } from "react";
|
|
2
|
+
import styled, { ThemeContext } from "styled-components";
|
|
3
|
+
import { FormattedInput } from "formatted-input";
|
|
4
|
+
import { fallbackValues } from "./FormLayouts.theme.js";
|
|
5
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
6
|
+
import Text from "../text";
|
|
7
|
+
import { Box, Cluster, Stack } from "../layouts";
|
|
8
|
+
import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
|
|
9
|
+
import { MATISSE_BLUE, ERROR_COLOR } from "../../../constants/colors";
|
|
10
|
+
|
|
11
|
+
const InputField = styled.input`
|
|
12
|
+
border: 1px solid
|
|
13
|
+
${({ field, showErrors, themeValues }) =>
|
|
14
|
+
(field.dirty && field.hasErrors) || (field.hasErrors && showErrors)
|
|
15
|
+
? ERROR_COLOR
|
|
16
|
+
: themeValues.borderColor};
|
|
17
|
+
border-radius: 2px;
|
|
18
|
+
height: 48px;
|
|
19
|
+
width: 100%;
|
|
20
|
+
padding: 1rem;
|
|
21
|
+
min-width: 100px;
|
|
22
|
+
margin: 0;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
position: relative;
|
|
25
|
+
font-size: 1.1rem;
|
|
26
|
+
font-family: Public Sans;
|
|
27
|
+
line-height: 2rem;
|
|
28
|
+
font-weight: ${FONT_WEIGHT_REGULAR};
|
|
29
|
+
background-color: ${({ themeValues }) =>
|
|
30
|
+
themeValues.inputBackgroundColor && themeValues.inputBackgroundColor};
|
|
31
|
+
color: ${({ themeValues }) => themeValues.color && themeValues.color};
|
|
32
|
+
box-shadow: none;
|
|
33
|
+
${({ background, themeValues }) =>
|
|
34
|
+
background &&
|
|
35
|
+
`background: ${themeValues.inputBackgroundColor} url(${background}) no-repeat right 0.5rem center;`}
|
|
36
|
+
transition: background 0.3s ease;
|
|
37
|
+
|
|
38
|
+
&:focus {
|
|
39
|
+
border: 1px solid ${MATISSE_BLUE};
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line no-unused-vars
|
|
44
|
+
const FormattedInputField = styled(({ showErrors, ...props }) => (
|
|
45
|
+
<FormattedInput {...props} />
|
|
46
|
+
))`
|
|
47
|
+
border: 1px solid
|
|
48
|
+
${({ field, showErrors, themeValues }) =>
|
|
49
|
+
(field.dirty && field.hasErrors) || (field.hasErrors && showErrors)
|
|
50
|
+
? ERROR_COLOR
|
|
51
|
+
: themeValues.borderColor};
|
|
52
|
+
border-radius: 2px;
|
|
53
|
+
height: 48px;
|
|
54
|
+
width: 100%;
|
|
55
|
+
padding: 1rem;
|
|
56
|
+
min-width: 100px;
|
|
57
|
+
margin: 0;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
position: relative;
|
|
60
|
+
font-size: 1.1rem;
|
|
61
|
+
line-height: 2rem;
|
|
62
|
+
font-weight: ${FONT_WEIGHT_REGULAR};
|
|
63
|
+
background-color: ${({ themeValues }) =>
|
|
64
|
+
themeValues.inputBackgroundColor && themeValues.inputBackgroundColor};
|
|
65
|
+
color: ${({ themeValues }) => themeValues.color && themeValues.color};
|
|
66
|
+
box-shadow: none;
|
|
67
|
+
|
|
68
|
+
&:focus {
|
|
69
|
+
border: 1px solid ${MATISSE_BLUE};
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const FormInput = ({
|
|
74
|
+
type = "text",
|
|
75
|
+
labelTextWhenNoError,
|
|
76
|
+
errorMessages,
|
|
77
|
+
isNum = false,
|
|
78
|
+
helperModal = false,
|
|
79
|
+
field,
|
|
80
|
+
fieldActions,
|
|
81
|
+
showErrors,
|
|
82
|
+
formatter = null,
|
|
83
|
+
decorator,
|
|
84
|
+
themeValues,
|
|
85
|
+
background,
|
|
86
|
+
...props
|
|
87
|
+
}) => {
|
|
88
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
89
|
+
const { isMobile } = useContext(ThemeContext);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Stack childGap="0.25rem">
|
|
93
|
+
<Box padding="0">
|
|
94
|
+
{helperModal ? (
|
|
95
|
+
<Cluster justify="space-between" align="center">
|
|
96
|
+
<Text
|
|
97
|
+
color={themeValues.labelColor}
|
|
98
|
+
variant="pS"
|
|
99
|
+
weight={themeValues.fontWeight}
|
|
100
|
+
extraStyles={`word-break: break-word;
|
|
101
|
+
font-family: Public Sans;
|
|
102
|
+
&::first-letter {
|
|
103
|
+
text-transform: uppercase;
|
|
104
|
+
}`}
|
|
105
|
+
>
|
|
106
|
+
{labelTextWhenNoError}
|
|
107
|
+
</Text>
|
|
108
|
+
<Text
|
|
109
|
+
color={themeValues.linkColor}
|
|
110
|
+
variant="pS"
|
|
111
|
+
weight={themeValues.fontWeight}
|
|
112
|
+
>
|
|
113
|
+
{helperModal()}
|
|
114
|
+
</Text>
|
|
115
|
+
</Cluster>
|
|
116
|
+
) : (
|
|
117
|
+
<Box padding="0" minWidth="100%">
|
|
118
|
+
<Cluster justify="space-between" align="center">
|
|
119
|
+
<Text
|
|
120
|
+
color={themeValues.labelColor}
|
|
121
|
+
variant="pS"
|
|
122
|
+
fontWeight={themeValues.fontWeight}
|
|
123
|
+
extraStyles={`word-break: break-word;
|
|
124
|
+
font-family: Public Sans;
|
|
125
|
+
&::first-letter {
|
|
126
|
+
text-transform: uppercase;
|
|
127
|
+
}`}
|
|
128
|
+
id={labelTextWhenNoError}
|
|
129
|
+
>
|
|
130
|
+
{labelTextWhenNoError}
|
|
131
|
+
</Text>
|
|
132
|
+
{type === "password" && (
|
|
133
|
+
<Text
|
|
134
|
+
variant="pS"
|
|
135
|
+
color={themeValues.linkColor}
|
|
136
|
+
weight={themeValues.fontWeight}
|
|
137
|
+
hoverStyles={themeValues.hoverFocusStyles}
|
|
138
|
+
focusStyles={themeValues.hoverFocusStyles}
|
|
139
|
+
extraStyles={`cursor: pointer;`}
|
|
140
|
+
onClick={() => setShowPassword(!showPassword)}
|
|
141
|
+
aria-label="Show password"
|
|
142
|
+
tabIndex="0"
|
|
143
|
+
onKeyPress={e =>
|
|
144
|
+
e.key === "Enter" && setShowPassword(!showPassword)
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
{showPassword ? "Hide" : "Show"}
|
|
148
|
+
</Text>
|
|
149
|
+
)}
|
|
150
|
+
{isMobile && decorator && (
|
|
151
|
+
<Box padding="0 0 0 auto">{decorator}</Box>
|
|
152
|
+
)}
|
|
153
|
+
</Cluster>
|
|
154
|
+
</Box>
|
|
155
|
+
)}
|
|
156
|
+
</Box>
|
|
157
|
+
<Box padding="0">
|
|
158
|
+
{formatter ? (
|
|
159
|
+
<FormattedInputField
|
|
160
|
+
aria-labelledby={labelTextWhenNoError}
|
|
161
|
+
onChange={e => fieldActions.set(e)}
|
|
162
|
+
type={type}
|
|
163
|
+
value={field.rawValue}
|
|
164
|
+
pattern={isNum ? "[0-9]*" : ""}
|
|
165
|
+
inputMode={isNum ? "numeric" : ""}
|
|
166
|
+
field={field}
|
|
167
|
+
formatter={formatter}
|
|
168
|
+
showErrors={showErrors}
|
|
169
|
+
data-qa={labelTextWhenNoError}
|
|
170
|
+
themeValues={themeValues}
|
|
171
|
+
{...props}
|
|
172
|
+
/>
|
|
173
|
+
) : (
|
|
174
|
+
<InputField
|
|
175
|
+
aria-labelledby={labelTextWhenNoError}
|
|
176
|
+
onChange={e => fieldActions.set(e.target.value)}
|
|
177
|
+
type={type === "password" && showPassword ? "text" : type}
|
|
178
|
+
value={field.rawValue}
|
|
179
|
+
pattern={isNum ? "[0-9]*" : ""}
|
|
180
|
+
inputMode={isNum ? "numeric" : ""}
|
|
181
|
+
field={field}
|
|
182
|
+
showErrors={showErrors}
|
|
183
|
+
data-qa={labelTextWhenNoError}
|
|
184
|
+
themeValues={themeValues}
|
|
185
|
+
background={background}
|
|
186
|
+
{...props}
|
|
187
|
+
/>
|
|
188
|
+
)}
|
|
189
|
+
</Box>
|
|
190
|
+
<Stack direction="row" justify="space-between">
|
|
191
|
+
{(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
|
|
192
|
+
<Text
|
|
193
|
+
color={ERROR_COLOR}
|
|
194
|
+
variant="pXS"
|
|
195
|
+
weight={themeValues.fontWeight}
|
|
196
|
+
extraStyles={`word-break: break-word;
|
|
197
|
+
font-family: Public Sans;
|
|
198
|
+
&::first-letter {
|
|
199
|
+
text-transform: uppercase;
|
|
200
|
+
}`}
|
|
201
|
+
>
|
|
202
|
+
{errorMessages[field.errors[0]]}
|
|
203
|
+
</Text>
|
|
204
|
+
) : (
|
|
205
|
+
<Text extraStyles={`height: ${themeValues.lineHeight};`} />
|
|
206
|
+
)}
|
|
207
|
+
{!isMobile && decorator && <Box padding="0 0 0 auto">{decorator}</Box>}
|
|
208
|
+
</Stack>
|
|
209
|
+
</Stack>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export default themeComponent(
|
|
214
|
+
FormInput,
|
|
215
|
+
"FormInput",
|
|
216
|
+
fallbackValues,
|
|
217
|
+
"default"
|
|
218
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Stack } from "../layouts";
|
|
3
|
+
|
|
4
|
+
const FormInputColumn = ({
|
|
5
|
+
childGap = "0.5rem",
|
|
6
|
+
bottomItem,
|
|
7
|
+
children,
|
|
8
|
+
...rest
|
|
9
|
+
}) => (
|
|
10
|
+
<Stack childGap={childGap} bottomItem={bottomItem} {...rest}>
|
|
11
|
+
{children}
|
|
12
|
+
</Stack>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export default FormInputColumn;
|