@thecb/components 10.12.6-beta.0 → 11.0.0-beta.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/README.md +14 -6
- package/dist/index.cjs.js +1311 -1482
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1311 -1483
- package/dist/index.esm.js.map +1 -1
- package/package.json +25 -13
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/alert/Alert.mdx +19 -0
- package/src/components/atoms/alert/Alert.stories.js +148 -26
- package/src/components/atoms/badge/Badge.js +2 -2
- package/src/components/atoms/badge/Badge.mdx +27 -0
- package/src/components/atoms/badge/Badge.stories.js +143 -29
- package/src/components/atoms/breadcrumb/Breadcrumb.mdx +21 -0
- package/src/components/atoms/breadcrumb/Breadcrumb.stories.js +38 -29
- package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +108 -55
- package/src/components/atoms/button-with-link/ButtonWithLink.mdx +21 -0
- package/src/components/atoms/button-with-link/ButtonWithLink.stories.js +160 -31
- package/src/components/atoms/card/Card.mdx +41 -0
- package/src/components/atoms/card/Card.stories.js +351 -0
- package/src/components/atoms/card/CardText.js +6 -1
- package/src/components/atoms/checkbox/Checkbox.mdx +15 -0
- package/src/components/atoms/checkbox/Checkbox.oldstories.js +34 -0
- package/src/components/atoms/checkbox/Checkbox.stories.js +140 -25
- package/src/components/atoms/country-dropdown/CountryDropdown.mdx +36 -0
- package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +61 -27
- package/src/components/atoms/detail/Detail.js +0 -26
- package/src/components/atoms/detail/Detail.mdx +32 -0
- package/src/components/atoms/detail/Detail.stories.js +156 -0
- package/src/components/atoms/display-box/DisplayBox.mdx +11 -0
- package/src/components/atoms/display-box/DisplayBox.stories.js +65 -21
- package/src/components/atoms/display-card/DisplayCard.mdx +13 -0
- package/src/components/atoms/display-card/DisplayCard.stories.js +163 -22
- package/src/components/atoms/dropdown/Dropdown.mdx +65 -0
- package/src/components/atoms/dropdown/Dropdown.stories.js +91 -10
- package/src/components/atoms/form-layouts/FormInput.mdx +38 -0
- package/src/components/atoms/form-layouts/FormInput.stories.js +212 -26
- package/src/components/atoms/form-select/FormSelect.mdx +42 -0
- package/src/components/atoms/form-select/FormSelect.stories.js +55 -29
- package/src/components/atoms/formatted-address/FormattedAddress.mdx +13 -0
- package/src/components/atoms/formatted-address/FormattedAddress.stories.js +133 -27
- package/src/components/atoms/formatted-bank-account/FormattedBankAccount.mdx +17 -0
- package/src/components/atoms/formatted-bank-account/FormattedBankAccount.stories.js +57 -0
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.mdx +40 -0
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.stories.js +74 -0
- package/src/components/atoms/icons/Icons.mdx +40 -0
- package/src/components/atoms/icons/Icons.stories.js +325 -0
- package/src/components/atoms/labeled-amount/LabeledAmount.mdx +23 -0
- package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +110 -34
- package/src/components/atoms/line-item/LineItem.mdx +28 -0
- package/src/components/atoms/line-item/LineItem.stories.js +89 -22
- package/src/components/atoms/link/Link.mdx +19 -0
- package/src/components/atoms/link/Link.stories.js +155 -49
- package/src/components/atoms/loading/Loading.mdx +13 -0
- package/src/components/atoms/loading/Loading.stories.js +22 -0
- package/src/components/atoms/loading-line/LoadingLine.js +14 -10
- package/src/components/atoms/loading-line/LoadingLine.mdx +15 -0
- package/src/components/atoms/loading-line/LoadingLine.stories.js +132 -28
- package/src/components/atoms/nav-footer/.DS_Store +0 -0
- package/src/components/atoms/nav-footer/NavFooter.mdx +15 -0
- package/src/components/atoms/nav-footer/NavFooter.stories.js +235 -22
- package/src/components/atoms/nav-header/NavHeader.mdx +13 -0
- package/src/components/atoms/nav-header/NavHeader.stories.js +122 -21
- package/src/components/atoms/nav-tabs/NavTabs.mdx +30 -0
- package/src/components/atoms/nav-tabs/NavTabs.stories.js +49 -0
- package/src/components/atoms/password-requirements/PasswordRequirements.mdx +39 -0
- package/src/components/atoms/password-requirements/PasswordRequirements.stories.js +108 -44
- package/src/components/atoms/placeholder/Placeholder.mdx +19 -0
- package/src/components/atoms/placeholder/Placeholder.stories.js +164 -36
- package/src/components/atoms/searchable-select/SearchableSelect.mdx +44 -0
- package/src/components/atoms/searchable-select/SearchableSelect.stories.js +103 -28
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.mdx +36 -0
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +65 -40
- package/src/components/atoms/table/Table.mdx +71 -0
- package/src/components/atoms/table/Table.oldstories.js +84 -0
- package/src/components/atoms/table/Table.stories.js +59 -75
- package/src/components/atoms/table/TableRow.js +1 -0
- package/src/components/atoms/title/Title.js +0 -23
- package/src/components/atoms/title/Title.mdx +26 -0
- package/src/components/atoms/title/Title.stories.js +144 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.mdx +17 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +103 -20
- package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +8 -5
- package/src/components/atoms/typeahead-input/TypeaheadInput.mdx +13 -0
- package/src/components/atoms/typeahead-input/TypeaheadInput.stories.js +63 -0
- package/src/components/molecules/.DS_Store +0 -0
- package/src/components/molecules/address-form/AddressForm.mdx +18 -0
- package/src/components/molecules/address-form/AddressForm.stories.js +223 -20
- package/src/components/molecules/banner/Banner.mdx +23 -0
- package/src/components/molecules/banner/Banner.stories.js +122 -26
- package/src/components/molecules/change-password-form/ChangePasswordForm.mdx +15 -0
- package/src/components/molecules/change-password-form/ChangePasswordForm.stories.js +203 -19
- package/src/components/molecules/collapsible-section/CollapsibleSection.mdx +15 -0
- package/src/components/molecules/collapsible-section/CollapsibleSection.stories.js +210 -61
- package/src/components/molecules/edit-name-form/EditNameForm.mdx +13 -0
- package/src/components/molecules/edit-name-form/EditNameForm.stories.js +117 -0
- package/src/components/molecules/idle-modal/IdleModal.js +101 -0
- package/src/components/molecules/idle-modal/IdleModal.mdx +17 -0
- package/src/components/molecules/idle-modal/IdleModal.stories.js +180 -0
- package/src/components/molecules/idle-modal/index.d.ts +16 -0
- package/src/components/molecules/idle-modal/index.js +3 -0
- package/src/components/molecules/index.js +1 -0
- package/src/components/molecules/link-card/LinkCard.mdx +17 -0
- package/src/components/molecules/link-card/LinkCard.stories.js +287 -72
- package/src/components/molecules/login-form/LoginForm.mdx +16 -0
- package/src/components/molecules/login-form/LoginForm.stories.js +117 -21
- package/src/components/molecules/modal/Modal.mdx +17 -0
- package/src/components/molecules/modal/Modal.stories.js +342 -128
- package/src/components/molecules/module/Module.mdx +17 -0
- package/src/components/molecules/module/Module.stories.js +267 -25
- package/src/components/molecules/obligation/.DS_Store +0 -0
- package/src/components/molecules/obligation/Obligation.mdx +23 -0
- package/src/components/molecules/obligation/Obligation.stories.js +460 -0
- package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +1 -1
- package/src/components/molecules/pagination/Pagination.mdx +15 -0
- package/src/components/molecules/pagination/Pagination.stories.js +177 -28
- package/src/components/molecules/popover/Popover.mdx +15 -0
- package/src/components/molecules/popover/Popover.stories.js +220 -0
- package/src/components/molecules/tabs/Tabs.mdx +17 -0
- package/src/components/molecules/tabs/Tabs.stories.js +135 -227
- package/src/components/molecules/toast-notification/Toast.mdx +15 -0
- package/src/components/molecules/toast-notification/Toast.stories.js +183 -0
- package/src/util/idleTimerUtils.js +36 -0
- package/src/util/index.js +3 -1
- package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +0 -24
- package/src/components/molecules/toast-notification/ToastNotification.stories.js +0 -105
- /package/src/components/atoms/add-obligation/{AddObligation.stories.js → AddObligation.oldstories.js} +0 -0
- /package/src/components/atoms/amount-callout/{AmountCallout.stories.js → AmountCallout.oldstories.js} +0 -0
- /package/src/components/atoms/checkbox-list/{CheckboxList.stories.js → CheckboxList.oldstories.js} +0 -0
- /package/src/components/atoms/form-layouts/{FormLayouts.stories.js → FormLayouts.oldstories.js} +0 -0
- /package/src/components/atoms/hamburger-button/{HamburgerButton.stories.js → HamburgerButton.oldstories.js} +0 -0
- /package/src/components/atoms/heading/{Heading.stories.js → Heading.oldstories.js} +0 -0
- /package/src/components/atoms/icons/{icons.stories.js → icons.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/box-example/{BoxExample.stories.js → BoxExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/center-example/{CenterExample.stories.js → CenterExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.stories.js → ClusterExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.stories.js → CoverExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.stories.js → FrameExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/grid-example/{GridExample.stories.js → GridExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.stories.js → ImposterExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.stories.js → MotionExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.stories.js → ReelExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.stories.js → SidebarExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/stack-example/{StackExample.stories.js → StackExample.oldstories.js} +0 -0
- /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.stories.js → SwitcherExample.oldstories.js} +0 -0
- /package/src/components/atoms/paragraph/{Paragraph.stories.js → Paragraph.oldstories.js} +0 -0
- /package/src/components/atoms/processing-fee/{ProcessingFee.stories.js → ProcessingFee.oldstories.js} +0 -0
- /package/src/components/atoms/search/{Search.stories.js → Search.oldstories.js} +0 -0
- /package/src/components/atoms/solid-divider/{SolidDivider.stories.js → SolidDivider.oldstories.js} +0 -0
- /package/src/components/atoms/sortable-table-heading/{SortableTableHeading.stories.js → SortableTableHeading.oldstories.js} +0 -0
- /package/src/components/atoms/spinner/{Spinner.stories.js → Spinner.oldstories.js} +0 -0
- /package/src/components/atoms/tab/{Tab.stories.js → Tab.oldstories.js} +0 -0
- /package/src/components/atoms/text/{Text.stories.js → Text.oldstories.js} +0 -0
- /package/src/components/atoms/typeahead-input/{TypeaheadIinput.stories.js → TypeaheadIinput.oldstories.js} +0 -0
- /package/src/components/atoms/wallet-name/{WalletName.stories.js → WalletName.oldstories.js} +0 -0
- /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.stories.js → AccountAndRoutingModal.oldstories.js} +0 -0
- /package/src/components/molecules/editable-list/{EditableList.stories.js → EditableList.oldstories.js} +0 -0
- /package/src/components/molecules/email-form/{EmailForm.stories.js → EmailForm.oldstories.js} +0 -0
- /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.stories.js → ForgotPasswordForm.oldstories.js} +0 -0
- /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.stories.js → HighlightTabRow.oldstories.js} +0 -0
- /package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.stories.js → MultipleSelectFilter.oldstories.js} +0 -0
- /package/src/components/molecules/obligation/modules/{AmountModule.stories.js → AmountModule.oldstories.js} +0 -0
- /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.stories.js → PaymentButtonBar.oldstories.js} +0 -0
- /package/src/components/molecules/payment-details/{PaymentDetails.stories.js → PaymentDetails.oldstories.js} +0 -0
- /package/src/components/molecules/payment-form-ach/{PaymentFormACH.stories.js → PaymentFormACH.oldstories.js} +0 -0
- /package/src/components/molecules/payment-form-card/{PaymentFormCard.stories.js → PaymentFormCard.oldstories.js} +0 -0
- /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.stories.js → PeriscopeDashBoardIframe.oldstories.js} +0 -0
- /package/src/components/molecules/phone-form/{PhoneForm.stories.js → PhoneForm.oldstories.js} +0 -0
- /package/src/components/molecules/popup-menu/{PopupMenu.stories.js → PopupMenu.oldstories.js} +0 -0
- /package/src/components/molecules/radio-group/{RadioGroup.stories.js → RadioGroup.oldstories.js} +0 -0
- /package/src/components/molecules/radio-section/{RadioSection.stories.js → RadioSection.oldstories.js} +0 -0
- /package/src/components/molecules/registration-form/{RegistrationForm.stories.js → RegistrationForm.oldstories.js} +0 -0
- /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.stories.js → ResetConfirmationForm.oldstories.js} +0 -0
- /package/src/components/molecules/reset-password-form/{ResetPasswordForm.stories.js → ResetPasswordForm.oldstories.js} +0 -0
- /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.stories.js → ResetPasswordSuccess.oldstories.js} +0 -0
- /package/src/components/molecules/tab-sidebar/{TabSidebar.stories.js → TabSidebar.oldstories.js} +0 -0
- /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.stories.js → TermsAndConditions.oldstories.js} +0 -0
- /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.stories.js → TermsAndConditionsModal.oldstories.js} +0 -0
- /package/src/components/molecules/workflow-tile/{WorkflowTile.stories.js → WorkflowTile.oldstories.js} +0 -0
|
@@ -1,28 +1,111 @@
|
|
|
1
|
-
import React, { useState
|
|
2
|
-
import { boolean, text } from "@storybook/addon-knobs";
|
|
1
|
+
import React, { useState } from "react";
|
|
3
2
|
import ToggleSwitch from "./ToggleSwitch";
|
|
4
|
-
import
|
|
3
|
+
import { noop } from "../../../util/general";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "Atoms/ToggleSwitch",
|
|
7
|
+
component: ToggleSwitch,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered"
|
|
10
|
+
},
|
|
11
|
+
tags: ["!autodocs"],
|
|
12
|
+
args: {
|
|
13
|
+
isOn: false,
|
|
14
|
+
onToggle: noop,
|
|
15
|
+
disabled: false,
|
|
16
|
+
name: "switch",
|
|
17
|
+
label: "Autopay Enabled",
|
|
18
|
+
labelLeft: false,
|
|
19
|
+
dataQa: undefined
|
|
20
|
+
},
|
|
21
|
+
argTypes: {
|
|
22
|
+
isOn: {
|
|
23
|
+
description: "Whether the ToggleSwitch is in an on state",
|
|
24
|
+
table: {
|
|
25
|
+
type: { summary: "boolean" },
|
|
26
|
+
defaultValue: { summary: false }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
onToggle: {
|
|
30
|
+
description: "Function to execute when user interacts with switch",
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: "function" },
|
|
33
|
+
defaultValue: { summary: undefined }
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
disabled: {
|
|
37
|
+
description: "Whether the ToggleSwitch is disabled",
|
|
38
|
+
table: {
|
|
39
|
+
type: { summary: "boolean" },
|
|
40
|
+
defaultValue: { summary: false }
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
name: {
|
|
44
|
+
description: "Accessible name for ToggleSwitch element",
|
|
45
|
+
table: {
|
|
46
|
+
type: { summary: "string" },
|
|
47
|
+
defaultValue: { summary: "" }
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
label: {
|
|
51
|
+
description: "Text to display next to ToggleSwitch",
|
|
52
|
+
table: {
|
|
53
|
+
type: { summary: "string" },
|
|
54
|
+
defaultValue: { summary: null }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
labelLeft: {
|
|
58
|
+
description: "Show the label on the left of the ToggleSwitch",
|
|
59
|
+
table: {
|
|
60
|
+
type: { summary: "boolean" },
|
|
61
|
+
defaultValue: { summary: false }
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
dataQa: {
|
|
65
|
+
description: "data-qa value to use for E2E testing libraries",
|
|
66
|
+
table: {
|
|
67
|
+
type: { summary: "string" },
|
|
68
|
+
defaultValue: { summary: undefined }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default meta;
|
|
75
|
+
|
|
76
|
+
const StatefulToggle = ({ useDynamicLabel, ...args }) => {
|
|
77
|
+
const [toggleOn, setToggleOn] = useState(false);
|
|
78
|
+
const dynamicLabel = toggleOn ? "Autopay Enabled" : "Autopay Disabled";
|
|
79
|
+
const label = useDynamicLabel ? dynamicLabel : args.label;
|
|
8
80
|
|
|
9
|
-
const disabled = boolean("disabled", false, "props");
|
|
10
81
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
disabled={disabled}
|
|
18
|
-
/>
|
|
19
|
-
</Fragment>
|
|
82
|
+
<ToggleSwitch
|
|
83
|
+
{...args}
|
|
84
|
+
isOn={toggleOn}
|
|
85
|
+
onToggle={() => setToggleOn(!toggleOn)}
|
|
86
|
+
label={label}
|
|
87
|
+
/>
|
|
20
88
|
);
|
|
21
89
|
};
|
|
22
90
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
91
|
+
export const BasicToggleSwitch = {};
|
|
92
|
+
|
|
93
|
+
export const StatefulToggleSwitch = {
|
|
94
|
+
render: args => <StatefulToggle {...args} useDynamicLabel />
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const LeftLabelToggleSwitch = {
|
|
98
|
+
args: {
|
|
99
|
+
labelLeft: true,
|
|
100
|
+
label: "Set as Default"
|
|
101
|
+
},
|
|
102
|
+
render: args => <StatefulToggle {...args} />
|
|
103
|
+
};
|
|
27
104
|
|
|
28
|
-
export
|
|
105
|
+
export const DisabledToggleSwitch = {
|
|
106
|
+
args: {
|
|
107
|
+
label: "Receive SMS Alerts",
|
|
108
|
+
disabled: true
|
|
109
|
+
},
|
|
110
|
+
render: args => <StatefulToggle {...args} />
|
|
111
|
+
};
|
|
@@ -17,13 +17,15 @@ const labelStyles = `
|
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
19
|
const rightLabelStyles = `
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
> div {
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
}
|
|
22
23
|
`;
|
|
23
24
|
|
|
24
25
|
const leftLabelStyles = `
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
> div {
|
|
27
|
+
flex-direction: row-reverse;
|
|
28
|
+
}
|
|
27
29
|
`;
|
|
28
30
|
|
|
29
31
|
export const fallbackValues = {
|
|
@@ -32,5 +34,6 @@ export const fallbackValues = {
|
|
|
32
34
|
disabledBackgroundLight,
|
|
33
35
|
white,
|
|
34
36
|
rightLabelStyles,
|
|
35
|
-
leftLabelStyles
|
|
37
|
+
leftLabelStyles,
|
|
38
|
+
labelStyles
|
|
36
39
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as TypeaheadInputStories from './TypeaheadInput.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={TypeaheadInputStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
TypeaheadInput is a wrapper for an uncontrolled input element that includes a visually hidden label and search icon.
|
|
10
|
+
|
|
11
|
+
<Story />
|
|
12
|
+
|
|
13
|
+
<Controls />
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import TypeaheadInput from "./TypeaheadInput";
|
|
2
|
+
import { fn } from "@storybook/test";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Atoms/TypeaheadInput",
|
|
6
|
+
component: TypeaheadInput,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
controls: { expanded: true }
|
|
10
|
+
},
|
|
11
|
+
tags: ["!autodocs"],
|
|
12
|
+
args: {
|
|
13
|
+
handleChange: undefined,
|
|
14
|
+
placeholder: undefined,
|
|
15
|
+
id: undefined,
|
|
16
|
+
labelText: undefined
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
id: {
|
|
20
|
+
description: "Used to link `labelText` to the input element",
|
|
21
|
+
control: { type: "text" },
|
|
22
|
+
table: {
|
|
23
|
+
type: { summary: "string" },
|
|
24
|
+
defaultValue: { summary: undefined }
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
placeholder: {
|
|
28
|
+
description: "Placeholder text for the input element",
|
|
29
|
+
control: { type: "text" },
|
|
30
|
+
table: {
|
|
31
|
+
type: { summary: "string" },
|
|
32
|
+
defaultValue: { summary: undefined }
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
labelText: {
|
|
36
|
+
description: "Visually hidden label for the input",
|
|
37
|
+
control: { type: "text" },
|
|
38
|
+
table: {
|
|
39
|
+
type: { summary: "string" },
|
|
40
|
+
defaultValue: { summary: undefined }
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
handleChange: {
|
|
44
|
+
description: "Callback function called when input value changes",
|
|
45
|
+
control: { type: "object" },
|
|
46
|
+
table: {
|
|
47
|
+
type: { summary: "function" },
|
|
48
|
+
defaultValue: { summary: undefined }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default meta;
|
|
55
|
+
|
|
56
|
+
export const Basic = {
|
|
57
|
+
args: {
|
|
58
|
+
handleChange: fn(),
|
|
59
|
+
placeholder: "Name…",
|
|
60
|
+
id: "search-input",
|
|
61
|
+
labelText: "Search"
|
|
62
|
+
}
|
|
63
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as AddressFormStories from './AddressForm.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={AddressFormStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
Renders all the fields needed to collect a full address.
|
|
10
|
+
|
|
11
|
+
- Uses the [StateProvinceDropdown](?path=/docs/atoms-stateprovincedropdown--docs) component connected with the value from [CountryDropdown](?path=/docs/atoms-countrydropdown--docs) to filter states/provinces.
|
|
12
|
+
- Zip codes automatically formatted via [FormInput](?path=/docs/atoms-form-layouts-forminput--docs) `formatter` prop.
|
|
13
|
+
- Optional "Save address to wallet" [Checkbox](?path=/docs/atoms-checkbox--docs) via the `showWalletCheckbox` prop.
|
|
14
|
+
- Expands to fit the width of it's containing element
|
|
15
|
+
|
|
16
|
+
<Story />
|
|
17
|
+
|
|
18
|
+
<Controls />
|
|
@@ -1,21 +1,224 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { connect } from "react-redux";
|
|
3
|
-
|
|
1
|
+
import React, { useState } from "react";
|
|
4
2
|
import AddressForm from "./AddressForm";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
import { connect, Provider } from "react-redux";
|
|
4
|
+
import { createStore } from "redux";
|
|
5
|
+
import {
|
|
6
|
+
createFormState,
|
|
7
|
+
required,
|
|
8
|
+
onlyIntegers,
|
|
9
|
+
hasLength,
|
|
10
|
+
validateWhen,
|
|
11
|
+
matchesRegex
|
|
12
|
+
} from "redux-freeform";
|
|
13
|
+
import { noop } from "../../../util/general";
|
|
14
|
+
import { fn } from "@storybook/test";
|
|
15
|
+
|
|
16
|
+
const formConfig = {
|
|
17
|
+
street1: {
|
|
18
|
+
validators: [required()]
|
|
19
|
+
},
|
|
20
|
+
street2: {
|
|
21
|
+
validators: []
|
|
22
|
+
},
|
|
23
|
+
city: {
|
|
24
|
+
validators: [required()]
|
|
25
|
+
},
|
|
26
|
+
stateProvince: {
|
|
27
|
+
validators: [required()]
|
|
28
|
+
},
|
|
29
|
+
country: {
|
|
30
|
+
defaultValue: "US",
|
|
31
|
+
validators: [required()]
|
|
32
|
+
},
|
|
33
|
+
zip: {
|
|
34
|
+
validators: [
|
|
35
|
+
required(),
|
|
36
|
+
validateWhen(
|
|
37
|
+
validateWhen(hasLength(5, 5), hasLength(0, 5)),
|
|
38
|
+
matchesRegex("US"),
|
|
39
|
+
"country"
|
|
40
|
+
),
|
|
41
|
+
validateWhen(
|
|
42
|
+
validateWhen(hasLength(9, 9), hasLength(6, 9)),
|
|
43
|
+
matchesRegex("US"),
|
|
44
|
+
"country"
|
|
45
|
+
)
|
|
46
|
+
],
|
|
47
|
+
constraints: [
|
|
48
|
+
validateWhen(onlyIntegers(), matchesRegex("US"), "country"),
|
|
49
|
+
validateWhen(hasLength(0, 9), matchesRegex("US"), "country")
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState(
|
|
55
|
+
formConfig
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const store = createStore(
|
|
59
|
+
reducer,
|
|
60
|
+
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const FormWrapper = props => <AddressForm {...props} />;
|
|
64
|
+
|
|
65
|
+
const ConnectedAddressForm = connect(
|
|
66
|
+
mapStateToProps,
|
|
67
|
+
mapDispatchToProps
|
|
68
|
+
)(FormWrapper);
|
|
69
|
+
|
|
70
|
+
export default {
|
|
71
|
+
title: "Molecules/AddressForm",
|
|
72
|
+
component: ConnectedAddressForm,
|
|
73
|
+
tags: ["!autodocs"],
|
|
74
|
+
parameters: {
|
|
75
|
+
layout: "centered",
|
|
76
|
+
controls: { expanded: true }
|
|
77
|
+
},
|
|
78
|
+
args: {
|
|
79
|
+
variant: "default",
|
|
80
|
+
fields: undefined,
|
|
81
|
+
actions: undefined,
|
|
82
|
+
clearOnDismount: undefined,
|
|
83
|
+
showErrors: undefined,
|
|
84
|
+
handleSubmit: noop,
|
|
85
|
+
showWalletCheckbox: undefined,
|
|
86
|
+
saveToWallet: undefined,
|
|
87
|
+
walletCheckboxMarked: undefined,
|
|
88
|
+
dataQa: null
|
|
89
|
+
},
|
|
90
|
+
argTypes: {
|
|
91
|
+
actions: {
|
|
92
|
+
description:
|
|
93
|
+
"Field actions, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
94
|
+
control: { type: "object" },
|
|
95
|
+
table: {
|
|
96
|
+
type: { summary: "object" },
|
|
97
|
+
defaultValue: { summary: undefined }
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
fields: {
|
|
101
|
+
description:
|
|
102
|
+
"Field data, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
103
|
+
control: { type: "object" },
|
|
104
|
+
table: {
|
|
105
|
+
type: { summary: "object" },
|
|
106
|
+
defaultValue: { summary: undefined }
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
showErrors: {
|
|
110
|
+
description:
|
|
111
|
+
"Show form field errors. Passed to the [FormInput](?path=/docs/atoms-form-layouts-forminput--docs), [CountryDropdown](?path=/docs/atoms-countrydropdown--docs), and [StateProvinceDropdown](?path=/docs/atoms-stateprovincedropdown--docs) fields.",
|
|
112
|
+
control: { type: "boolean" },
|
|
113
|
+
table: {
|
|
114
|
+
type: { summary: "boolean" },
|
|
115
|
+
defaultValue: { summary: undefined }
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
clearOnDismount: {
|
|
119
|
+
description:
|
|
120
|
+
"If `true`, `actions.form.clear()` will be called when the component unmounts.",
|
|
121
|
+
control: { type: "boolean" },
|
|
122
|
+
table: {
|
|
123
|
+
type: { summary: "boolean" },
|
|
124
|
+
defaultValue: { summary: undefined }
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
variant: {
|
|
128
|
+
description:
|
|
129
|
+
"Passed down to the `Box` component that wraps this component via the `FormContainer` component.",
|
|
130
|
+
control: { type: "text" },
|
|
131
|
+
table: {
|
|
132
|
+
type: { summary: "string" },
|
|
133
|
+
defaultValue: { summary: "default" }
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
handleSubmit: {
|
|
137
|
+
description:
|
|
138
|
+
"Function called when the `Enter` key is pressed on any of the text inputs (`onKeyDown`), and the `StateProvinceDropdown` field. The React event form the will be passed as a parameter.",
|
|
139
|
+
control: { type: "object" },
|
|
140
|
+
table: {
|
|
141
|
+
type: { summary: "function" },
|
|
142
|
+
defaultValue: { summary: undefined }
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
showWalletCheckbox: {
|
|
146
|
+
description: "Shows the `Save address to wallet` checkbox if `true`.",
|
|
147
|
+
control: { type: "boolean" },
|
|
148
|
+
table: {
|
|
149
|
+
type: { summary: "boolean" },
|
|
150
|
+
defaultValue: { summary: undefined }
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
saveToWallet: {
|
|
154
|
+
description:
|
|
155
|
+
"Callback function for the `onChange` event of the `Save address to wallet` checkbox.",
|
|
156
|
+
control: { type: "object" },
|
|
157
|
+
table: {
|
|
158
|
+
type: { summary: "function" },
|
|
159
|
+
defaultValue: { summary: undefined }
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
walletCheckboxMarked: {
|
|
163
|
+
description:
|
|
164
|
+
"Sets the `Save address to wallet` checkbox to `checked` when true.",
|
|
165
|
+
control: { type: "boolean" },
|
|
166
|
+
table: {
|
|
167
|
+
type: { summary: "boolean" },
|
|
168
|
+
defaultValue: { summary: undefined }
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
dataQa: {
|
|
172
|
+
description:
|
|
173
|
+
"Value for the `data-qa` attribute on the `FormContainer` wrapping element.",
|
|
174
|
+
control: { type: "text" },
|
|
175
|
+
table: {
|
|
176
|
+
type: { summary: "string" },
|
|
177
|
+
defaultValue: { summary: null }
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
decorators: [
|
|
182
|
+
Story => (
|
|
183
|
+
<Provider store={store}>
|
|
184
|
+
<Story />
|
|
185
|
+
</Provider>
|
|
186
|
+
)
|
|
187
|
+
]
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const Basic = args => <ConnectedAddressForm {...args} />;
|
|
191
|
+
|
|
192
|
+
export const ShowErrors = {
|
|
193
|
+
args: {
|
|
194
|
+
showErrors: true
|
|
195
|
+
},
|
|
196
|
+
render: args => <ConnectedAddressForm {...args} />
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const HandleSubmit = {
|
|
200
|
+
args: {
|
|
201
|
+
handleSubmit: fn()
|
|
202
|
+
},
|
|
203
|
+
render: args => <ConnectedAddressForm {...args} />
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const AddressFormWithWalletState = props => {
|
|
207
|
+
const [checked, setChecked] = useState(true);
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<ConnectedAddressForm
|
|
211
|
+
{...props}
|
|
212
|
+
showWalletCheckbox={props.showWalletCheckbox}
|
|
213
|
+
walletCheckboxMarked={checked}
|
|
214
|
+
saveToWallet={() => setChecked(!checked)}
|
|
215
|
+
/>
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const WalletCheckbox = {
|
|
220
|
+
args: {
|
|
221
|
+
showWalletCheckbox: true
|
|
222
|
+
},
|
|
223
|
+
render: args => <AddressFormWithWalletState {...args} />
|
|
224
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as BannerStories from './Banner.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={BannerStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
Banner is a themeable component that renders a heading and sub-heading alongside an image. It supports custom padding and content spacing for both mobile and desktop, as well as minimum width and height values.
|
|
10
|
+
|
|
11
|
+
## The `Image` Prop
|
|
12
|
+
|
|
13
|
+
The `image` prop is required, and must be valid a React component, typically a component that renders an SVG.
|
|
14
|
+
|
|
15
|
+
The Banner component forces a width of `176px` for SVG elements on mobile screens.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<div style={{ margin: "2em 0"}}>
|
|
20
|
+
<Story />
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<Controls />
|
|
@@ -1,29 +1,125 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { text, boolean } from "@storybook/addon-knobs";
|
|
3
1
|
import Banner from "./Banner";
|
|
4
2
|
import { WalletBannerIcon } from "../../atoms/icons";
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Molecules/Banner",
|
|
6
|
+
component: Banner,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered"
|
|
9
|
+
},
|
|
10
|
+
tags: ["!autodocs"],
|
|
11
|
+
args: {
|
|
12
|
+
heading: "This is a banner heading!",
|
|
13
|
+
subHeading: "Sub heading!",
|
|
14
|
+
image: WalletBannerIcon,
|
|
15
|
+
padding: "0.5rem 1.5rem",
|
|
16
|
+
mobilePadding: "0.5rem 1rem",
|
|
17
|
+
minWidth: "100%",
|
|
18
|
+
minHeight: "auto",
|
|
19
|
+
contentSpacing: "3rem",
|
|
20
|
+
mobileContentSpacing: "0.5rem"
|
|
21
|
+
},
|
|
22
|
+
argTypes: {
|
|
23
|
+
heading: {
|
|
24
|
+
description: "Banner heading",
|
|
25
|
+
table: {
|
|
26
|
+
type: { summary: "string" },
|
|
27
|
+
defaultValue: { summary: undefined }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
subHeading: {
|
|
31
|
+
description: "Banner sub-heading",
|
|
32
|
+
table: {
|
|
33
|
+
type: { summary: "string" },
|
|
34
|
+
defaultValue: { summary: undefined }
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
image: {
|
|
38
|
+
description: "Image displayed on the right side of the banner",
|
|
39
|
+
table: {
|
|
40
|
+
type: { summary: "React Component" },
|
|
41
|
+
defaultValue: { summary: undefined }
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
padding: {
|
|
45
|
+
description: "Padding around the banner content (desktop)",
|
|
46
|
+
table: {
|
|
47
|
+
type: { summary: "string" },
|
|
48
|
+
defaultValue: { summary: "0.5rem 1.5rem" }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
mobilePadding: {
|
|
52
|
+
description: "Padding around the banner content (mobile)",
|
|
53
|
+
table: {
|
|
54
|
+
type: { summary: "string" },
|
|
55
|
+
defaultValue: { summary: "0.5rem 1rem" }
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
minWidth: {
|
|
59
|
+
description:
|
|
60
|
+
"Minimum width of the banner, must be a valid value for the `min-width` property.",
|
|
61
|
+
table: {
|
|
62
|
+
type: { summary: "string" },
|
|
63
|
+
defaultValue: { summary: "100%" }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
minHeight: {
|
|
67
|
+
description:
|
|
68
|
+
"Minimum height of the banner, must be a valid value for the `min-height` property.",
|
|
69
|
+
table: {
|
|
70
|
+
type: { summary: "string" },
|
|
71
|
+
defaultValue: { summary: "auto" }
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
contentSpacing: {
|
|
75
|
+
description:
|
|
76
|
+
"Space between the headers and image, must be a valid CSS measurement value with a unit",
|
|
77
|
+
table: {
|
|
78
|
+
type: { summary: "string" },
|
|
79
|
+
defaultValue: { summary: "3rem" }
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
mobileContentSpacing: {
|
|
83
|
+
description:
|
|
84
|
+
"Space between the headers and image (mobile), must be a valid CSS measurement value with a unit",
|
|
85
|
+
table: {
|
|
86
|
+
type: { summary: "string" },
|
|
87
|
+
defaultValue: { summary: "0.5rem" }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default meta;
|
|
94
|
+
|
|
95
|
+
export const Basic = {};
|
|
96
|
+
|
|
97
|
+
export const CustomPadding = {
|
|
98
|
+
args: {
|
|
99
|
+
padding: "2rem 4rem"
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const CustomSpacing = {
|
|
104
|
+
args: {
|
|
105
|
+
contentSpacing: "8rem"
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const MinWidth = {
|
|
110
|
+
args: {
|
|
111
|
+
minWidth: "1000px"
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const MinHeight = {
|
|
116
|
+
args: {
|
|
117
|
+
minHeight: "500px"
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const CustomImageComponent = {
|
|
122
|
+
args: {
|
|
123
|
+
image: () => "🎉"
|
|
124
|
+
}
|
|
125
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as ChangePasswordFormStories from './ChangePasswordForm.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={ChangePasswordFormStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
Renders a form for users to update their password. Built with [FormInput](?path=/docs/atoms-form-layouts-forminput--docs), and [PasswordRequirements](?path=/docs/atoms-passwordrequirements--docs).
|
|
10
|
+
|
|
11
|
+
When the [`revenueManagement`](?path=/story/molecules-changepasswordform--revenue-management) prop is set to `true`, the form will include a user block with their full name & initials, and "Save" & "Cancel" buttons.
|
|
12
|
+
|
|
13
|
+
<Story />
|
|
14
|
+
|
|
15
|
+
<Controls />
|