@thecb/components 10.12.6 → 11.0.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 +1309 -1481
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1309 -1482
- 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/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,22 +1,206 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { connect } from "react-redux";
|
|
3
|
-
import { boolean } from "@storybook/addon-knobs";
|
|
4
|
-
|
|
5
2
|
import ChangePasswordForm from "./ChangePasswordForm";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
+
hasLength,
|
|
9
|
+
hasNumber,
|
|
10
|
+
hasLowercaseLetter,
|
|
11
|
+
hasUppercaseLetter,
|
|
12
|
+
hasSpecialCharacter,
|
|
13
|
+
matchesField
|
|
14
|
+
} from "redux-freeform";
|
|
15
|
+
import { noop } from "../../../util/general";
|
|
16
|
+
import { fn } from "@storybook/test";
|
|
17
|
+
|
|
18
|
+
const formConfig = {
|
|
19
|
+
currentPassword: {
|
|
20
|
+
validators: [required()]
|
|
21
|
+
},
|
|
22
|
+
newPassword: {
|
|
23
|
+
validators: [
|
|
24
|
+
required(),
|
|
25
|
+
hasLength(8, 100),
|
|
26
|
+
hasNumber(),
|
|
27
|
+
hasLowercaseLetter(),
|
|
28
|
+
hasUppercaseLetter(),
|
|
29
|
+
hasSpecialCharacter()
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
confirmNewPassword: {
|
|
33
|
+
validators: [required(), matchesField("newPassword")]
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState(
|
|
38
|
+
formConfig
|
|
22
39
|
);
|
|
40
|
+
|
|
41
|
+
const store = createStore(
|
|
42
|
+
reducer,
|
|
43
|
+
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const FormWrapper = props => <ChangePasswordForm {...props} />;
|
|
47
|
+
|
|
48
|
+
const ConnectedChangePasswordForm = connect(
|
|
49
|
+
mapStateToProps,
|
|
50
|
+
mapDispatchToProps
|
|
51
|
+
)(FormWrapper);
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
title: "Molecules/ChangePasswordForm",
|
|
55
|
+
component: ConnectedChangePasswordForm,
|
|
56
|
+
tags: ["!autodocs"],
|
|
57
|
+
parameters: {
|
|
58
|
+
layout: "centered",
|
|
59
|
+
controls: { expanded: true }
|
|
60
|
+
},
|
|
61
|
+
args: {
|
|
62
|
+
clearOnDismount: undefined,
|
|
63
|
+
fields: undefined,
|
|
64
|
+
actions: undefined,
|
|
65
|
+
handleSubmit: noop,
|
|
66
|
+
showErrors: undefined,
|
|
67
|
+
isMobile: undefined,
|
|
68
|
+
revenueManagement: undefined,
|
|
69
|
+
closeForm: undefined,
|
|
70
|
+
firstName: undefined,
|
|
71
|
+
lastName: undefined
|
|
72
|
+
},
|
|
73
|
+
argTypes: {
|
|
74
|
+
actions: {
|
|
75
|
+
description:
|
|
76
|
+
"Field actions, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
77
|
+
control: { type: "object" },
|
|
78
|
+
table: {
|
|
79
|
+
type: { summary: "object" },
|
|
80
|
+
defaultValue: { summary: undefined }
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
fields: {
|
|
84
|
+
description:
|
|
85
|
+
"Field data, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
86
|
+
control: { type: "object" },
|
|
87
|
+
table: {
|
|
88
|
+
type: { summary: "object" },
|
|
89
|
+
defaultValue: { summary: undefined }
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
clearOnDismount: {
|
|
93
|
+
description:
|
|
94
|
+
"If `true`, `actions.form.clear()` will be called when the component unmounts.",
|
|
95
|
+
control: { type: "boolean" },
|
|
96
|
+
table: {
|
|
97
|
+
type: { summary: "boolean" },
|
|
98
|
+
defaultValue: { summary: undefined }
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
handleSubmit: {
|
|
102
|
+
description:
|
|
103
|
+
"Function called when the `Enter` key is pressed on any of the text inputs (`onKeyDown`). The React event form the will be passed as a parameter.",
|
|
104
|
+
control: { type: "object" },
|
|
105
|
+
table: {
|
|
106
|
+
type: { summary: "function" },
|
|
107
|
+
defaultValue: { summary: undefined }
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
isMobile: {
|
|
111
|
+
description:
|
|
112
|
+
"Reduces the padding of the `PasswordRequirements` component for mobile desvices (typically screen size <768px).",
|
|
113
|
+
control: { type: "boolean" },
|
|
114
|
+
table: {
|
|
115
|
+
type: { summary: "boolean" },
|
|
116
|
+
defaultValue: { summary: undefined }
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
showErrors: {
|
|
120
|
+
description:
|
|
121
|
+
"Passed to the [FormInput](?path=/docs/atoms-form-layouts-forminput--docs) fields.",
|
|
122
|
+
control: { type: "boolean" },
|
|
123
|
+
table: {
|
|
124
|
+
type: { summary: "boolean" },
|
|
125
|
+
defaultValue: { summary: undefined }
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
revenueManagement: {
|
|
129
|
+
description:
|
|
130
|
+
"Renders the user's name from the `firstName` and `lastName` props, and `Cancel` & `Save` buttons. The `Save` button uses the `handleSubmit` prop as it's action.",
|
|
131
|
+
control: { type: "boolean" },
|
|
132
|
+
table: {
|
|
133
|
+
type: { summary: "boolean" },
|
|
134
|
+
defaultValue: { summary: undefined }
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
closeForm: {
|
|
138
|
+
description:
|
|
139
|
+
"Action for the `Cancel` button for the `revenueManagement` version of the form",
|
|
140
|
+
control: { type: "boolean" },
|
|
141
|
+
table: {
|
|
142
|
+
type: { summary: "boolean" },
|
|
143
|
+
defaultValue: { summary: undefined }
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
firstName: {
|
|
147
|
+
description:
|
|
148
|
+
"First name of the user, used only with `revenueManagement` set to `true.`",
|
|
149
|
+
control: { type: "text" },
|
|
150
|
+
table: {
|
|
151
|
+
type: { summary: "string" },
|
|
152
|
+
defaultValue: { summary: undefined }
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
lastName: {
|
|
156
|
+
description:
|
|
157
|
+
"Last name of the user, used only with `revenueManagement` set to `true.`",
|
|
158
|
+
control: { type: "text" },
|
|
159
|
+
table: {
|
|
160
|
+
type: { summary: "string" },
|
|
161
|
+
defaultValue: { summary: undefined }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
decorators: [
|
|
166
|
+
Story => (
|
|
167
|
+
<Provider store={store}>
|
|
168
|
+
<Story />
|
|
169
|
+
</Provider>
|
|
170
|
+
)
|
|
171
|
+
]
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const Basic = args => <ConnectedChangePasswordForm {...args} />;
|
|
175
|
+
|
|
176
|
+
export const ShowErrors = {
|
|
177
|
+
args: {
|
|
178
|
+
showErrors: true
|
|
179
|
+
},
|
|
180
|
+
render: args => <ConnectedChangePasswordForm {...args} />
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const HandleSubmit = {
|
|
184
|
+
args: {
|
|
185
|
+
handleSubmit: fn()
|
|
186
|
+
},
|
|
187
|
+
render: args => <ConnectedChangePasswordForm {...args} />
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const IsMobile = {
|
|
191
|
+
args: {
|
|
192
|
+
isMobile: true
|
|
193
|
+
},
|
|
194
|
+
render: args => <ConnectedChangePasswordForm {...args} />
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export const RevenueManagement = {
|
|
198
|
+
args: {
|
|
199
|
+
revenueManagement: true,
|
|
200
|
+
firstName: "Cole",
|
|
201
|
+
lastName: "Slaw",
|
|
202
|
+
closeForm: fn(),
|
|
203
|
+
handleSubmit: fn()
|
|
204
|
+
},
|
|
205
|
+
render: args => <ConnectedChangePasswordForm {...args} />
|
|
206
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as CollapsibleSectionStories from './CollapsibleSection.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={CollapsibleSectionStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
The CollapsibleSection component behaves like a typical accordion, expanding and collapsing respectively when triggered by user interaction. It also includes [accessibility attributes for accordions](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/).
|
|
10
|
+
|
|
11
|
+
<Controls />
|
|
12
|
+
|
|
13
|
+
<div style={{ marginBottom: "2em"}}>
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
@@ -1,68 +1,217 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import DisplayCard from "../../atoms/display-card";
|
|
5
|
-
import { Stack, Motion } from "../../atoms/layouts";
|
|
6
|
-
import page from "../../../../.storybook/page";
|
|
2
|
+
import CollapsibleSection from "./CollapsibleSection.js";
|
|
3
|
+
import { fn } from "@storybook/test";
|
|
7
4
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "Molecules/CollapsibleSection",
|
|
7
|
+
component: CollapsibleSection,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered"
|
|
12
10
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
tags: ["!autodocs"],
|
|
12
|
+
args: {
|
|
13
|
+
isOpen: true,
|
|
14
|
+
toggleSection: fn(),
|
|
15
|
+
themeValues: {},
|
|
16
|
+
isMobile: undefined,
|
|
17
|
+
supportsTouch: undefined,
|
|
18
|
+
title: "Example Title",
|
|
19
|
+
customPadding: undefined,
|
|
20
|
+
initiallyOpen: true,
|
|
21
|
+
openHeight: "auto",
|
|
22
|
+
children: <p>The children prop will populate this content.</p>,
|
|
23
|
+
customTitle: false,
|
|
24
|
+
stackTitle: false,
|
|
25
|
+
stackTitleContent: "StackTitleContent Prop Value",
|
|
26
|
+
sectionGap: "0.5rem",
|
|
27
|
+
name: "",
|
|
28
|
+
index: 1,
|
|
29
|
+
extraStyles: ""
|
|
30
|
+
},
|
|
31
|
+
argTypes: {
|
|
32
|
+
isOpen: {
|
|
33
|
+
description:
|
|
34
|
+
"Boolean indicating whether the section is expanded (true) or collapsed (false).",
|
|
35
|
+
control: { type: "boolean" },
|
|
36
|
+
table: {
|
|
37
|
+
type: { summary: "boolean" },
|
|
38
|
+
defaultValue: { summary: `undefined` }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
toggleSection: {
|
|
42
|
+
description:
|
|
43
|
+
"Function that toggles the expanded versus collapsed state for a given 'CollapsibleSection'",
|
|
44
|
+
table: {
|
|
45
|
+
type: { summary: "object" },
|
|
46
|
+
defaultValue: { summary: `undefined` }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
isMobile: {
|
|
50
|
+
description:
|
|
51
|
+
"Whether user is on a mobile device (typically screen size smaller than 768px)",
|
|
52
|
+
table: {
|
|
53
|
+
type: { summary: "boolean" },
|
|
54
|
+
defaultValue: { summary: `undefined` }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
supportsTouch: {
|
|
58
|
+
description: "Whether a device supports touch events",
|
|
59
|
+
table: {
|
|
60
|
+
type: { summary: "boolean" },
|
|
61
|
+
defaultValue: { summary: `undefined` }
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
title: {
|
|
65
|
+
description:
|
|
66
|
+
"The title of the collapsible section, that, when clicked or tapped will toggle the component's expanded/collapsed state",
|
|
67
|
+
table: {
|
|
68
|
+
type: { summary: "string" },
|
|
69
|
+
defaultValue: { summary: `undefined` }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
customPadding: {
|
|
73
|
+
description:
|
|
74
|
+
"The amount of padding to apply to the title prop's containing `Box` element",
|
|
75
|
+
table: {
|
|
76
|
+
type: { summary: "string" },
|
|
77
|
+
defaultValue: { summary: `undefined` }
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
initiallyOpen: {
|
|
81
|
+
description: "Whether the component should render itself open by default",
|
|
82
|
+
table: {
|
|
83
|
+
type: { summary: "boolean" },
|
|
84
|
+
defaultValue: { summary: true }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
openHeight: {
|
|
88
|
+
description: "Sets the height of the component when it is expanded",
|
|
89
|
+
table: {
|
|
90
|
+
type: { summary: "string" },
|
|
91
|
+
defaultValue: { summary: "auto" }
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
children: {
|
|
95
|
+
description:
|
|
96
|
+
"Content that will show when the component is expanded and be hidden when the component is collapsed",
|
|
97
|
+
table: {
|
|
98
|
+
type: { summary: "object" },
|
|
99
|
+
defaultValue: { summary: `undefined` }
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
customTitle: {
|
|
103
|
+
description:
|
|
104
|
+
"Renders a differently styled title element when true, and is also used to help compute an appropriate label for the wrapper",
|
|
105
|
+
table: {
|
|
106
|
+
type: { summary: "boolean" },
|
|
107
|
+
defaultValue: { summary: false }
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
stackTitle: {
|
|
111
|
+
description:
|
|
112
|
+
"Whether or not to include an additional title (content provided by StackTitleContent prop) above the CollapsibleSection",
|
|
113
|
+
table: {
|
|
114
|
+
type: { summary: "boolean" },
|
|
115
|
+
defaultValue: { summary: false }
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
stackTitleContent: {
|
|
119
|
+
description:
|
|
120
|
+
"When stackTitle prop is true, this content is used for a header located _above_ the CollapsibleSection",
|
|
121
|
+
table: {
|
|
122
|
+
type: { summary: "string" },
|
|
123
|
+
defaultValue: { summary: `undefined` }
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
sectionGap: {
|
|
127
|
+
description:
|
|
128
|
+
"When the CollapsibleSection is open and not on a mobile screen, this prop determines the wrapping Stack component's 'childGap' prop value.",
|
|
129
|
+
table: {
|
|
130
|
+
type: { summary: "string" },
|
|
131
|
+
defaultValue: { summary: `undefined` }
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
name: {
|
|
135
|
+
description:
|
|
136
|
+
"When it's not empty, 'name' provides the label value for the Box instance with a role of 'heading.'",
|
|
137
|
+
table: {
|
|
138
|
+
type: { summary: "string" },
|
|
139
|
+
defaultValue: { summary: "" }
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
index: {
|
|
143
|
+
description:
|
|
144
|
+
"The index value of the current CollapsibleSection in a list of CollapsibleSections. It is used to create a unique ID string for each component.",
|
|
145
|
+
table: {
|
|
146
|
+
type: { summary: "number" },
|
|
147
|
+
defaultValue: { summary: 1 }
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
extraStyles: {
|
|
151
|
+
description:
|
|
152
|
+
"A string containing additional CSS to apply to the title's Box container (the one with role='button').",
|
|
153
|
+
table: {
|
|
154
|
+
type: { summary: "string" },
|
|
155
|
+
defaultValue: { summary: `undefined` }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
16
158
|
}
|
|
17
159
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
isOpen={open}
|
|
26
|
-
key="security-section"
|
|
27
|
-
>
|
|
28
|
-
<Stack childGap="16px">
|
|
29
|
-
<Motion
|
|
30
|
-
padding="0"
|
|
31
|
-
variants={content}
|
|
32
|
-
transition={{ duration: 0.3 }}
|
|
33
|
-
positionTransition
|
|
34
|
-
extraStyles={`transform-origin: 100% 0;`}
|
|
35
|
-
>
|
|
36
|
-
<DisplayCard
|
|
37
|
-
title="Password"
|
|
38
|
-
item="•••••••••••••"
|
|
39
|
-
buttonText="Change Password"
|
|
40
|
-
link
|
|
41
|
-
url=""
|
|
42
|
-
/>
|
|
43
|
-
</Motion>
|
|
44
|
-
<Motion
|
|
45
|
-
padding="0"
|
|
46
|
-
variants={content}
|
|
47
|
-
transition={{ duration: 0.3 }}
|
|
48
|
-
positionTransition
|
|
49
|
-
extraStyles={`transform-origin: 100% 0;`}
|
|
50
|
-
>
|
|
51
|
-
<DisplayCard
|
|
52
|
-
title="Name"
|
|
53
|
-
item="Hello Citybase"
|
|
54
|
-
buttonText="Edit Name"
|
|
55
|
-
link
|
|
56
|
-
url=""
|
|
57
|
-
/>
|
|
58
|
-
</Motion>
|
|
59
|
-
</Stack>
|
|
60
|
-
</CollapsibleSection>
|
|
61
|
-
);
|
|
160
|
+
|
|
161
|
+
export default meta;
|
|
162
|
+
|
|
163
|
+
export const Basic = {
|
|
164
|
+
args: {
|
|
165
|
+
title: "Basic Title"
|
|
166
|
+
}
|
|
62
167
|
};
|
|
63
|
-
const story = page({
|
|
64
|
-
title: "Components|Molecules/CollapsibleSection",
|
|
65
|
-
Component: CollapsibleSection
|
|
66
|
-
});
|
|
67
168
|
|
|
68
|
-
export
|
|
169
|
+
export const ToggleSection = {
|
|
170
|
+
render: args => {
|
|
171
|
+
const [isOpen, setIsOpen] = useState(true);
|
|
172
|
+
return (
|
|
173
|
+
<CollapsibleSection
|
|
174
|
+
{...args}
|
|
175
|
+
title="ToggleSection Title"
|
|
176
|
+
isOpen={isOpen}
|
|
177
|
+
toggleSection={() => setIsOpen(!isOpen)}
|
|
178
|
+
/>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const Mobile = {
|
|
184
|
+
args: {
|
|
185
|
+
title: "Mobile Title",
|
|
186
|
+
isMobile: true
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const CustomTitle = {
|
|
191
|
+
args: {
|
|
192
|
+
title: "Custom Title",
|
|
193
|
+
customTitle: true
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export const CustomPadding = {
|
|
198
|
+
args: {
|
|
199
|
+
title: "CustomPadding Title",
|
|
200
|
+
customPadding: "3rem"
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const StackTitleContentAndStackTitle = {
|
|
205
|
+
args: {
|
|
206
|
+
title: "StackTitleContentAndStackTitle Title",
|
|
207
|
+
stackTitle: true,
|
|
208
|
+
stackTitleContent: <h1>Stack Title Content</h1>
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export const SectionGap = {
|
|
213
|
+
args: {
|
|
214
|
+
title: "SectionGap Title",
|
|
215
|
+
sectionGap: "100px"
|
|
216
|
+
}
|
|
217
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as EditNameFormStories from './EditNameForm.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={EditNameFormStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
Renders input fields to collect a person's first name and last name.
|
|
10
|
+
|
|
11
|
+
<Story />
|
|
12
|
+
|
|
13
|
+
<Controls />
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EditNameForm from "./EditNameForm";
|
|
3
|
+
import { connect, Provider } from "react-redux";
|
|
4
|
+
import { createStore } from "redux";
|
|
5
|
+
import { createFormState, required } from "redux-freeform";
|
|
6
|
+
import { noop } from "../../../util/general";
|
|
7
|
+
import { fn } from "@storybook/test";
|
|
8
|
+
|
|
9
|
+
const formConfig = {
|
|
10
|
+
firstName: {
|
|
11
|
+
validators: [required()]
|
|
12
|
+
},
|
|
13
|
+
lastName: {
|
|
14
|
+
validators: [required()]
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState(
|
|
19
|
+
formConfig
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const store = createStore(
|
|
23
|
+
reducer,
|
|
24
|
+
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const FormWrapper = props => <EditNameForm {...props} />;
|
|
28
|
+
|
|
29
|
+
const ConnectedEditNameForm = connect(
|
|
30
|
+
mapStateToProps,
|
|
31
|
+
mapDispatchToProps
|
|
32
|
+
)(FormWrapper);
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
title: "Molecules/EditNameForm",
|
|
36
|
+
component: ConnectedEditNameForm,
|
|
37
|
+
tags: ["!autodocs"],
|
|
38
|
+
parameters: {
|
|
39
|
+
layout: "centered"
|
|
40
|
+
},
|
|
41
|
+
args: {
|
|
42
|
+
fields: undefined,
|
|
43
|
+
actions: undefined,
|
|
44
|
+
clearOnDismount: undefined,
|
|
45
|
+
showErrors: undefined,
|
|
46
|
+
handleSubmit: noop
|
|
47
|
+
},
|
|
48
|
+
argTypes: {
|
|
49
|
+
fields: {
|
|
50
|
+
description:
|
|
51
|
+
"Field data, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
52
|
+
control: { type: "object" },
|
|
53
|
+
table: {
|
|
54
|
+
type: { summary: "object" },
|
|
55
|
+
defaultValue: { summary: undefined }
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
actions: {
|
|
59
|
+
description:
|
|
60
|
+
"Field actions, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
61
|
+
control: { type: "object" },
|
|
62
|
+
table: {
|
|
63
|
+
type: { summary: "object" },
|
|
64
|
+
defaultValue: { summary: undefined }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
clearOnDismount: {
|
|
68
|
+
description:
|
|
69
|
+
"If `true`, `actions.form.clear()` will be called when the component unmounts.",
|
|
70
|
+
control: { type: "boolean" },
|
|
71
|
+
table: {
|
|
72
|
+
type: { summary: "boolean" },
|
|
73
|
+
defaultValue: { summary: undefined }
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
showErrors: {
|
|
77
|
+
description: "Show form field errors.",
|
|
78
|
+
control: { type: "boolean" },
|
|
79
|
+
table: {
|
|
80
|
+
type: { summary: "boolean" },
|
|
81
|
+
defaultValue: { summary: undefined }
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
handleSubmit: {
|
|
85
|
+
description:
|
|
86
|
+
"Function called when the `Enter` key is pressed on any of the text inputs (via `onKeyDown` prop passed to `FormInput` component).",
|
|
87
|
+
control: { type: "object" },
|
|
88
|
+
table: {
|
|
89
|
+
type: { summary: "function" },
|
|
90
|
+
defaultValue: { summary: noop }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
decorators: [
|
|
95
|
+
Story => (
|
|
96
|
+
<Provider store={store}>
|
|
97
|
+
<Story />
|
|
98
|
+
</Provider>
|
|
99
|
+
)
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const Basic = args => <ConnectedEditNameForm {...args} />;
|
|
104
|
+
|
|
105
|
+
export const ShowErrors = {
|
|
106
|
+
args: {
|
|
107
|
+
showErrors: true
|
|
108
|
+
},
|
|
109
|
+
render: args => <ConnectedEditNameForm {...args} />
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const HandleSubmit = {
|
|
113
|
+
args: {
|
|
114
|
+
handleSubmit: fn()
|
|
115
|
+
},
|
|
116
|
+
render: args => <ConnectedEditNameForm {...args} />
|
|
117
|
+
};
|