@thecb/components 10.12.1 → 10.12.3-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 +4 -0
- package/dist/index.cjs.js +1413 -2314
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.esm.js +1413 -2315
- package/dist/index.esm.js.map +1 -1
- package/package.json +25 -13
- 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.js +13 -1
- package/src/components/atoms/card/Card.mdx +41 -0
- package/src/components/atoms/card/Card.stories.js +360 -0
- package/src/components/atoms/card/Card.theme.js +2 -0
- package/src/components/atoms/card/index.d.ts +1 -0
- package/src/components/atoms/checkbox/Checkbox.mdx +15 -0
- package/src/components/atoms/checkbox/Checkbox.oldstories.js +30 -0
- package/src/components/atoms/checkbox/Checkbox.stories.js +148 -29
- 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/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/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/multiple-select-filter/MultipleSelectFilter.js +295 -61
- package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.stories.js → MultipleSelectFilter.oldstories.js} +1 -1
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.styled.js +4 -4
- 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/hooks/use-outside-click/index.js +5 -4
- package/src/stories/Button.stories.ts +53 -0
- package/src/stories/Button.tsx +48 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/Header.stories.ts +33 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Page.stories.ts +32 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +5 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +15 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +3 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +12 -0
- package/src/stories/assets/youtube.svg +4 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/src/util/idleTimerUtils.js +36 -0
- package/src/util/index.js +3 -1
- package/src/components/atoms/icons/icons.stories.js +0 -116
- package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +0 -24
- package/src/components/molecules/multiple-select-filter/__private__/ActionLinkButton.js +0 -24
- package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +0 -85
- package/src/components/molecules/multiple-select-filter/__private__/FilterDropdown.js +0 -23
- package/src/components/molecules/multiple-select-filter/__private__/FilterableList.js +0 -144
- package/src/components/molecules/multiple-select-filter/__private__/FilterableListItem.js +0 -67
- package/src/components/molecules/multiple-select-filter/__private__/SearchBox.js +0 -38
- package/src/components/molecules/multiple-select-filter/__private__/useKeyboardNavigation.js +0 -84
- package/src/components/molecules/multiple-select-filter/__private__/util.js +0 -31
- 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/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/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,6 +1,82 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
2
|
import Dropdown from "./Dropdown";
|
|
3
|
-
import
|
|
3
|
+
import { fn } from "@storybook/test";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Atoms/Dropdown",
|
|
8
|
+
component: Dropdown,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
controls: { expanded: true }
|
|
12
|
+
},
|
|
13
|
+
tags: ["!autodocs"],
|
|
14
|
+
args: {
|
|
15
|
+
placeholder: "Placeholder",
|
|
16
|
+
options: [],
|
|
17
|
+
value: "",
|
|
18
|
+
isOpen: false,
|
|
19
|
+
isError: false,
|
|
20
|
+
onSelect: fn(),
|
|
21
|
+
disabledValues: [],
|
|
22
|
+
onClick: fn(),
|
|
23
|
+
themeValues: {},
|
|
24
|
+
maxHeight: "400px",
|
|
25
|
+
widthFitOptions: false,
|
|
26
|
+
disabled: false,
|
|
27
|
+
hasTitles: false,
|
|
28
|
+
autoEraseTypeAhead: true,
|
|
29
|
+
ariaLabelledby: "label-id",
|
|
30
|
+
ariaDescribedby: "desc-id",
|
|
31
|
+
autocompleteValue: "",
|
|
32
|
+
smoothScroll: true,
|
|
33
|
+
ariaInvalid: false,
|
|
34
|
+
isRequired: false
|
|
35
|
+
},
|
|
36
|
+
argTypes: {
|
|
37
|
+
autoEraseTypeAhead: {
|
|
38
|
+
description: "Clears type ahead inputs after 20s",
|
|
39
|
+
table: {
|
|
40
|
+
type: { summary: "boolean" },
|
|
41
|
+
defaultValue: { summary: true }
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
autocompleteValue: {
|
|
45
|
+
description:
|
|
46
|
+
"Sets the autoComplete attribute and name attribute on the underlying input element",
|
|
47
|
+
table: {
|
|
48
|
+
type: { summary: "string" },
|
|
49
|
+
defaultValue: { summary: undefined }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
hasTitles: {
|
|
53
|
+
description:
|
|
54
|
+
"Adds the selected value and option values as HTML `title` attributes to their respective elements",
|
|
55
|
+
table: {
|
|
56
|
+
type: { summary: "boolean" },
|
|
57
|
+
defaultValue: { summary: false }
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
smoothScroll: {
|
|
61
|
+
description:
|
|
62
|
+
"Smoothly animate to the selected option when the menu is opened by a mouse click",
|
|
63
|
+
table: {
|
|
64
|
+
type: { summary: "boolean" },
|
|
65
|
+
defaultValue: { summary: true }
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
widthFitOptions: {
|
|
69
|
+
description:
|
|
70
|
+
"Sets the width of the wrapping element to fit-content instead of 100%",
|
|
71
|
+
table: {
|
|
72
|
+
type: { summary: "boolean" },
|
|
73
|
+
defaultValue: { summary: false }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default meta;
|
|
4
80
|
|
|
5
81
|
const options = [
|
|
6
82
|
{ text: "Please select an option", value: "" },
|
|
@@ -11,7 +87,7 @@ const options = [
|
|
|
11
87
|
|
|
12
88
|
const disabledValues = ["DISABLED_OPTION"];
|
|
13
89
|
|
|
14
|
-
|
|
90
|
+
const DropdownWithHooks = props => {
|
|
15
91
|
const [isOpen, setOpen] = useState(false);
|
|
16
92
|
const [value, setValue] = useState(null);
|
|
17
93
|
const [isError, setError] = useState(false);
|
|
@@ -26,6 +102,7 @@ export const dropdown = () => {
|
|
|
26
102
|
|
|
27
103
|
return (
|
|
28
104
|
<Dropdown
|
|
105
|
+
{...props}
|
|
29
106
|
placeholder={options[0].text}
|
|
30
107
|
options={options}
|
|
31
108
|
disabledValues={disabledValues}
|
|
@@ -33,15 +110,19 @@ export const dropdown = () => {
|
|
|
33
110
|
isOpen={isOpen}
|
|
34
111
|
isError={isError}
|
|
35
112
|
onSelect={setValue}
|
|
36
|
-
onClick={() => setOpen(!isOpen)}
|
|
113
|
+
onClick={() => !props.disabled && setOpen(!isOpen)}
|
|
114
|
+
disabled={props.disabled}
|
|
37
115
|
/>
|
|
38
116
|
);
|
|
39
117
|
};
|
|
40
118
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
height: "500px"
|
|
45
|
-
});
|
|
119
|
+
export const Basic = {
|
|
120
|
+
render: args => <DropdownWithHooks {...args} />
|
|
121
|
+
};
|
|
46
122
|
|
|
47
|
-
export
|
|
123
|
+
export const Disabled = {
|
|
124
|
+
args: {
|
|
125
|
+
disabled: true
|
|
126
|
+
},
|
|
127
|
+
render: args => <DropdownWithHooks {...args} />
|
|
128
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as FormInputStories from './FormInput.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={FormInputStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
FormInput is a wrapper for `<input/>` elements that adds extra functionality. It is meant to be used in forms. The underlying component is an `input` element, unless the formatter prop is set, then it will be a [formatted-input](https://www.npmjs.com/package/formatted-input) component. Additional props are passed down to the underlying element.
|
|
10
|
+
|
|
11
|
+
## Form Integration
|
|
12
|
+
|
|
13
|
+
FormInput requires a `field` and `fieldActions` prop. Both are objects that _can_ be generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform). Below are example values for each prop with the minimum properties needed for a FormInput component.
|
|
14
|
+
|
|
15
|
+
### field
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
{
|
|
19
|
+
"dirty": false,
|
|
20
|
+
"rawValue": "",
|
|
21
|
+
"errors": [
|
|
22
|
+
"error/REQUIRED"
|
|
23
|
+
],
|
|
24
|
+
"hasErrors": true
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### fieldActions
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
{
|
|
32
|
+
set: (value) => {...}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`fieldActions.set()` is called when an option is selected in the underlying Dropdown component, unless a function is defined for the `onChange` prop.
|
|
37
|
+
|
|
38
|
+
<Controls />
|
|
@@ -1,33 +1,219 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { text } from "@storybook/addon-knobs";
|
|
1
|
+
import React, { useState } from "react";
|
|
3
2
|
import FormInput from "./FormInput";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { connect, Provider } from "react-redux";
|
|
4
|
+
import { createStore } from "redux";
|
|
5
|
+
import { createFormState, required } from "redux-freeform";
|
|
6
|
+
import Modal from "../../molecules/modal";
|
|
7
|
+
import { moneyFormat } from "../../../util/formats";
|
|
8
|
+
|
|
9
|
+
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
|
|
10
|
+
example: {
|
|
11
|
+
validators: [required()]
|
|
9
12
|
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const store = createStore(
|
|
16
|
+
reducer,
|
|
17
|
+
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const errorMessages = {
|
|
21
|
+
[required.error]: "This is required!"
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const FormWrapper = props => (
|
|
25
|
+
<FormInput
|
|
26
|
+
{...props}
|
|
27
|
+
field={props.fields.example}
|
|
28
|
+
fieldActions={props.actions.fields.example}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const ConnectedFormInput = connect(
|
|
33
|
+
mapStateToProps,
|
|
34
|
+
mapDispatchToProps
|
|
35
|
+
)(FormWrapper);
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
title: "Atoms/form-layouts/FormInput",
|
|
39
|
+
component: ConnectedFormInput,
|
|
40
|
+
tags: ["!autodocs"],
|
|
41
|
+
parameters: {
|
|
42
|
+
layout: "centered",
|
|
43
|
+
controls: { expanded: true }
|
|
44
|
+
},
|
|
45
|
+
args: {
|
|
46
|
+
type: "text",
|
|
47
|
+
labelTextWhenNoError: "",
|
|
48
|
+
errorMessages: errorMessages,
|
|
49
|
+
isNum: false,
|
|
50
|
+
isEmail: false,
|
|
51
|
+
helperModal: undefined,
|
|
52
|
+
showErrors: undefined,
|
|
53
|
+
formatter: null,
|
|
54
|
+
decorator: undefined,
|
|
55
|
+
themeValues: {},
|
|
56
|
+
background: undefined,
|
|
57
|
+
customHeight: undefined,
|
|
58
|
+
autocompleteValue: "",
|
|
59
|
+
extraStyles: undefined,
|
|
60
|
+
removeFromValue: undefined,
|
|
61
|
+
dataQa: "form-input-qa",
|
|
62
|
+
isRequired: false
|
|
63
|
+
},
|
|
64
|
+
argTypes: {
|
|
65
|
+
extraStyles: { type: "string" },
|
|
66
|
+
fieldActions: { type: "object" },
|
|
67
|
+
field: { type: "object" },
|
|
68
|
+
background: {
|
|
69
|
+
description:
|
|
70
|
+
"sets the value for `background: url(${background})` _only_ if the `formatter` prop is _not_ set",
|
|
71
|
+
table: {
|
|
72
|
+
type: { summary: "string" },
|
|
73
|
+
defaultValue: { summary: undefined }
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
isNum: {
|
|
77
|
+
description: "sets the input's inputMode attribute to `numeric`",
|
|
78
|
+
table: {
|
|
79
|
+
type: { summary: "boolean" },
|
|
80
|
+
defaultValue: { summary: false }
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
isEmail: {
|
|
84
|
+
description: "sets the input's inputMode attribute to `email`",
|
|
85
|
+
table: {
|
|
86
|
+
type: { summary: "boolean" },
|
|
87
|
+
defaultValue: { summary: false }
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
isRequired: {
|
|
91
|
+
description: "adds the `required` attribute to the input element",
|
|
92
|
+
table: {
|
|
93
|
+
type: { summary: "boolean" },
|
|
94
|
+
defaultValue: { summary: false }
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
customHeight: {
|
|
98
|
+
description: "sets a height to the input",
|
|
99
|
+
table: {
|
|
100
|
+
type: { summary: "string" },
|
|
101
|
+
defaultValue: { summary: "48px" }
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
helperModal: {
|
|
105
|
+
description: "a function that returns a modal",
|
|
106
|
+
table: {
|
|
107
|
+
type: { summary: "object" },
|
|
108
|
+
defaultValue: { summary: undefined }
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
removeFromValue: {
|
|
112
|
+
description:
|
|
113
|
+
"regex pattern for characters to in the user inputted value before passing it to `fieldActions.set()`",
|
|
114
|
+
table: {
|
|
115
|
+
type: { summary: "string" },
|
|
116
|
+
defaultValue: { summary: undefined }
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
extraStyles: {
|
|
120
|
+
description: "styles applied to the underlying input element",
|
|
121
|
+
table: {
|
|
122
|
+
type: { summary: "string" },
|
|
123
|
+
defaultValue: { summary: undefined }
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
decorators: [
|
|
128
|
+
Story => (
|
|
129
|
+
<Provider store={store}>
|
|
130
|
+
<Story />
|
|
131
|
+
</Provider>
|
|
132
|
+
)
|
|
133
|
+
]
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const Basic = args => <ConnectedFormInput {...args} />;
|
|
137
|
+
|
|
138
|
+
export const WithDecorator = {
|
|
139
|
+
args: {
|
|
140
|
+
decorator: "Decorator!"
|
|
141
|
+
},
|
|
142
|
+
render: args => <ConnectedFormInput {...args} />
|
|
10
143
|
};
|
|
11
|
-
|
|
144
|
+
|
|
145
|
+
export const IsEmail = {
|
|
146
|
+
args: {
|
|
147
|
+
isEmail: true
|
|
148
|
+
},
|
|
149
|
+
render: args => <ConnectedFormInput {...args} />
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const IsNum = {
|
|
153
|
+
args: {
|
|
154
|
+
isNum: true
|
|
155
|
+
},
|
|
156
|
+
render: args => <ConnectedFormInput {...args} />
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const WithLabel = {
|
|
160
|
+
args: {
|
|
161
|
+
labelTextWhenNoError: "Label"
|
|
162
|
+
},
|
|
163
|
+
render: args => <ConnectedFormInput {...args} />
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const WithCustomHeight = {
|
|
167
|
+
args: {
|
|
168
|
+
customHeight: "100px"
|
|
169
|
+
},
|
|
170
|
+
render: args => <ConnectedFormInput {...args} />
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const Required = {
|
|
174
|
+
args: {
|
|
175
|
+
isRequired: true
|
|
176
|
+
},
|
|
177
|
+
render: args => <ConnectedFormInput {...args} />
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const WithFormatter = {
|
|
181
|
+
args: {
|
|
182
|
+
labelTextWhenNoError: "Price",
|
|
183
|
+
formatter: moneyFormat
|
|
184
|
+
},
|
|
185
|
+
render: args => <ConnectedFormInput {...args} />
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const InputWithModal = props => {
|
|
189
|
+
const [isOpen, toggleOpen] = useState(false);
|
|
190
|
+
|
|
12
191
|
return (
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
192
|
+
<ConnectedFormInput
|
|
193
|
+
{...props}
|
|
194
|
+
helperModal={() => (
|
|
195
|
+
<Modal
|
|
196
|
+
modalOpen={isOpen}
|
|
197
|
+
hideModal={() => toggleOpen(false)}
|
|
198
|
+
showModal={() => toggleOpen(true)}
|
|
199
|
+
modalHeaderText="Modal title!"
|
|
200
|
+
modalBodyText="Modal text!"
|
|
201
|
+
defaultWrapper={false}
|
|
202
|
+
onlyCloseButton={true}
|
|
203
|
+
initialFocusSelector=""
|
|
204
|
+
>
|
|
205
|
+
<div onClick={() => toggleOpen(true)} role="button">
|
|
206
|
+
Help!
|
|
207
|
+
</div>
|
|
208
|
+
</Modal>
|
|
209
|
+
)}
|
|
210
|
+
/>
|
|
26
211
|
);
|
|
27
212
|
};
|
|
28
213
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
214
|
+
export const WithHelperModal = {
|
|
215
|
+
argTypes: {
|
|
216
|
+
helperModal: { type: "function" }
|
|
217
|
+
},
|
|
218
|
+
render: args => <InputWithModal {...args} />
|
|
219
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as FormSelectStories from './FormSelect.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={FormSelectStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
FormSelect is a wrapper for the [Dropdown component](?path=/docs/atoms-dropdown--docs) meant to be used in forms.
|
|
10
|
+
|
|
11
|
+
It controls the open state of the menu (including closing on mouse clicks outside of the component). It also renders an accesible label and error messages.
|
|
12
|
+
|
|
13
|
+
FormSelect can be used with [redux-freeform](https://github.com/CityBaseInc/redux-freeform) to connect the form to Redux state.
|
|
14
|
+
|
|
15
|
+
<Story />
|
|
16
|
+
|
|
17
|
+
## Form Integration
|
|
18
|
+
|
|
19
|
+
FormSelect requires a `field` and `fieldActions` prop. Both are objects that _can_ be generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform). Below are example values for each prop with the minimum properties needed for a FormSelect component.
|
|
20
|
+
|
|
21
|
+
### field
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
{
|
|
25
|
+
"dirty": false,
|
|
26
|
+
"rawValue": "",
|
|
27
|
+
"errors": [
|
|
28
|
+
"error/REQUIRED"
|
|
29
|
+
],
|
|
30
|
+
"hasErrors": true
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### fieldActions
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
{
|
|
38
|
+
set: (value) => {...}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`fieldActions.set()` is called when an option is selected in the underlying Dropdown component, unless a function is defined for the `onChange` prop.
|
|
@@ -1,50 +1,76 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { connect } from "react-redux";
|
|
3
|
-
import { text } from "@storybook/addon-knobs";
|
|
4
|
-
import { createFormState, required } from "redux-freeform";
|
|
5
|
-
|
|
6
2
|
import FormSelect from "./FormSelect";
|
|
7
|
-
import
|
|
3
|
+
import { connect, Provider } from "react-redux";
|
|
4
|
+
import { createStore } from "redux";
|
|
5
|
+
import { createFormState, required } from "redux-freeform";
|
|
8
6
|
|
|
9
7
|
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
|
|
10
|
-
|
|
8
|
+
example: {
|
|
11
9
|
validators: [required()]
|
|
12
10
|
}
|
|
13
11
|
});
|
|
12
|
+
|
|
13
|
+
const store = createStore(
|
|
14
|
+
reducer,
|
|
15
|
+
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
16
|
+
);
|
|
17
|
+
|
|
14
18
|
const errorMessages = {
|
|
15
|
-
[required.error]: "
|
|
19
|
+
[required.error]: "You must choose an option!"
|
|
16
20
|
};
|
|
21
|
+
|
|
17
22
|
const options = [
|
|
18
|
-
{ value: "", text: "
|
|
23
|
+
{ value: "", text: "Choose an option" },
|
|
19
24
|
{ value: "foo", text: "foo" },
|
|
20
25
|
{ value: "bar", text: "bar" },
|
|
21
26
|
{ value: "baz", text: "baz" },
|
|
22
27
|
{ value: "disabled", text: "disabled" }
|
|
23
28
|
];
|
|
24
29
|
|
|
25
|
-
const story = page({
|
|
26
|
-
title: "Components|Atoms/FormSelect",
|
|
27
|
-
Component: FormSelect,
|
|
28
|
-
reducer,
|
|
29
|
-
mapStateToProps,
|
|
30
|
-
mapDispatchToProps,
|
|
31
|
-
height: "500px"
|
|
32
|
-
});
|
|
33
|
-
|
|
34
30
|
const FormWrapper = props => (
|
|
35
31
|
<FormSelect
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
options={options}
|
|
40
|
-
field={props.fields.thing}
|
|
41
|
-
fieldActions={props.actions.fields.thing}
|
|
42
|
-
disabledValues={["disabled"]}
|
|
32
|
+
{...props}
|
|
33
|
+
field={props.fields.example}
|
|
34
|
+
fieldActions={props.actions.fields.example}
|
|
43
35
|
/>
|
|
44
36
|
);
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
const ConnectedFormSelect = connect(
|
|
39
|
+
mapStateToProps,
|
|
40
|
+
mapDispatchToProps
|
|
41
|
+
)(FormWrapper);
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
title: "Atoms/FormSelect",
|
|
45
|
+
component: ConnectedFormSelect,
|
|
46
|
+
tags: ["!autodocs"],
|
|
47
|
+
args: {
|
|
48
|
+
labelTextWhenNoError: "Form Select Example",
|
|
49
|
+
errorMessages: errorMessages,
|
|
50
|
+
options: options,
|
|
51
|
+
showErrors: false,
|
|
52
|
+
onChange: null,
|
|
53
|
+
dropdownMaxHeight: "600px",
|
|
54
|
+
disabledValues: ["disabled"],
|
|
55
|
+
disabled: false,
|
|
56
|
+
hasTitles: false,
|
|
57
|
+
autocompleteValue: "",
|
|
58
|
+
smoothScroll: true,
|
|
59
|
+
dataQa: "form-select-qa",
|
|
60
|
+
widthFitOptions: false,
|
|
61
|
+
isRequired: false
|
|
62
|
+
},
|
|
63
|
+
argTypes: {
|
|
64
|
+
fieldActions: { type: "object" },
|
|
65
|
+
field: { type: "object" }
|
|
66
|
+
},
|
|
67
|
+
decorators: [
|
|
68
|
+
Story => (
|
|
69
|
+
<Provider store={store}>
|
|
70
|
+
<Story />
|
|
71
|
+
</Provider>
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const Basic = args => <ConnectedFormSelect {...args} />;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as FormattedAddressStories from './FormattedAddress.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={FormattedAddressStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
8
|
+
|
|
9
|
+
FormattedAddress is a composition of Box and Text components to help create consistent formatting of addresses. The outer padding and text color are themeable.
|
|
10
|
+
|
|
11
|
+
<Story />
|
|
12
|
+
|
|
13
|
+
<Controls />
|