@thecb/components 10.12.3-beta.0 → 10.12.3-beta.1
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 +0 -4
- package/dist/index.cjs.js +2526 -1617
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.esm.js +2527 -1617
- package/dist/index.esm.js.map +1 -1
- package/package.json +13 -25
- package/src/components/atoms/alert/Alert.stories.js +26 -148
- package/src/components/atoms/badge/Badge.js +2 -2
- package/src/components/atoms/badge/Badge.stories.js +29 -143
- package/src/components/atoms/breadcrumb/Breadcrumb.stories.js +29 -38
- package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +55 -108
- package/src/components/atoms/button-with-link/ButtonWithLink.stories.js +31 -160
- package/src/components/atoms/checkbox/Checkbox.stories.js +29 -148
- package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +27 -61
- package/src/components/atoms/detail/Detail.js +26 -0
- package/src/components/atoms/display-box/DisplayBox.stories.js +21 -65
- package/src/components/atoms/display-card/DisplayCard.stories.js +22 -163
- package/src/components/atoms/dropdown/Dropdown.stories.js +10 -91
- package/src/components/atoms/form-layouts/FormInput.stories.js +26 -212
- package/src/components/atoms/form-select/FormSelect.stories.js +29 -55
- package/src/components/atoms/formatted-address/FormattedAddress.stories.js +27 -133
- package/src/components/atoms/icons/icons.stories.js +116 -0
- package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +34 -110
- package/src/components/atoms/line-item/LineItem.stories.js +22 -89
- package/src/components/atoms/link/Link.stories.js +49 -155
- package/src/components/atoms/loading-line/LoadingLine.js +10 -14
- package/src/components/atoms/loading-line/LoadingLine.stories.js +28 -132
- package/src/components/atoms/nav-footer/NavFooter.stories.js +22 -235
- package/src/components/atoms/nav-header/NavHeader.stories.js +21 -122
- package/src/components/atoms/password-requirements/PasswordRequirements.stories.js +44 -108
- package/src/components/atoms/placeholder/Placeholder.stories.js +36 -164
- package/src/components/atoms/searchable-select/SearchableSelect.stories.js +28 -103
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +40 -65
- package/src/components/atoms/table/Table.stories.js +75 -59
- package/src/components/atoms/table/TableRow.js +0 -1
- package/src/components/atoms/title/Title.js +23 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +20 -103
- package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +5 -8
- package/src/components/molecules/address-form/AddressForm.stories.js +20 -223
- package/src/components/molecules/banner/Banner.stories.js +26 -122
- package/src/components/molecules/change-password-form/ChangePasswordForm.stories.js +19 -203
- package/src/components/molecules/collapsible-section/CollapsibleSection.stories.js +61 -210
- package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +24 -0
- package/src/components/molecules/index.js +0 -1
- package/src/components/molecules/link-card/LinkCard.stories.js +72 -287
- package/src/components/molecules/login-form/LoginForm.stories.js +21 -117
- package/src/components/molecules/modal/Modal.stories.js +128 -342
- package/src/components/molecules/module/Module.stories.js +25 -267
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.js +61 -295
- package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.oldstories.js → MultipleSelectFilter.stories.js} +1 -1
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.styled.js +4 -4
- package/src/components/molecules/multiple-select-filter/__private__/ActionLinkButton.js +24 -0
- package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +85 -0
- package/src/components/molecules/multiple-select-filter/__private__/FilterDropdown.js +23 -0
- package/src/components/molecules/multiple-select-filter/__private__/FilterableList.js +144 -0
- package/src/components/molecules/multiple-select-filter/__private__/FilterableListItem.js +67 -0
- package/src/components/molecules/multiple-select-filter/__private__/SearchBox.js +38 -0
- package/src/components/molecules/multiple-select-filter/__private__/useKeyboardNavigation.js +84 -0
- package/src/components/molecules/multiple-select-filter/__private__/util.js +31 -0
- package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +1 -1
- package/src/components/molecules/pagination/Pagination.stories.js +28 -177
- package/src/components/molecules/tabs/Tabs.stories.js +227 -135
- package/src/components/molecules/toast-notification/ToastNotification.stories.js +105 -0
- package/src/hooks/use-outside-click/index.js +4 -5
- package/src/util/index.js +1 -3
- package/src/components/atoms/alert/Alert.mdx +0 -19
- package/src/components/atoms/badge/Badge.mdx +0 -27
- package/src/components/atoms/breadcrumb/Breadcrumb.mdx +0 -21
- package/src/components/atoms/button-with-link/ButtonWithLink.mdx +0 -21
- package/src/components/atoms/card/Card.mdx +0 -41
- package/src/components/atoms/card/Card.stories.js +0 -360
- package/src/components/atoms/checkbox/Checkbox.mdx +0 -15
- package/src/components/atoms/checkbox/Checkbox.oldstories.js +0 -30
- package/src/components/atoms/country-dropdown/CountryDropdown.mdx +0 -36
- package/src/components/atoms/detail/Detail.mdx +0 -32
- package/src/components/atoms/detail/Detail.stories.js +0 -156
- package/src/components/atoms/display-box/DisplayBox.mdx +0 -11
- package/src/components/atoms/display-card/DisplayCard.mdx +0 -13
- package/src/components/atoms/dropdown/Dropdown.mdx +0 -65
- package/src/components/atoms/form-layouts/FormInput.mdx +0 -38
- package/src/components/atoms/form-select/FormSelect.mdx +0 -42
- package/src/components/atoms/formatted-address/FormattedAddress.mdx +0 -13
- package/src/components/atoms/formatted-bank-account/FormattedBankAccount.mdx +0 -17
- package/src/components/atoms/formatted-bank-account/FormattedBankAccount.stories.js +0 -57
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.mdx +0 -40
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.stories.js +0 -74
- package/src/components/atoms/icons/Icons.mdx +0 -40
- package/src/components/atoms/icons/Icons.stories.js +0 -325
- package/src/components/atoms/labeled-amount/LabeledAmount.mdx +0 -23
- package/src/components/atoms/line-item/LineItem.mdx +0 -28
- package/src/components/atoms/link/Link.mdx +0 -19
- package/src/components/atoms/loading/Loading.mdx +0 -13
- package/src/components/atoms/loading/Loading.stories.js +0 -22
- package/src/components/atoms/loading-line/LoadingLine.mdx +0 -15
- package/src/components/atoms/nav-footer/NavFooter.mdx +0 -15
- package/src/components/atoms/nav-header/NavHeader.mdx +0 -13
- package/src/components/atoms/nav-tabs/NavTabs.mdx +0 -30
- package/src/components/atoms/nav-tabs/NavTabs.stories.js +0 -49
- package/src/components/atoms/password-requirements/PasswordRequirements.mdx +0 -39
- package/src/components/atoms/placeholder/Placeholder.mdx +0 -19
- package/src/components/atoms/searchable-select/SearchableSelect.mdx +0 -44
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.mdx +0 -36
- package/src/components/atoms/table/Table.mdx +0 -71
- package/src/components/atoms/table/Table.oldstories.js +0 -84
- package/src/components/atoms/title/Title.mdx +0 -26
- package/src/components/atoms/title/Title.stories.js +0 -144
- package/src/components/atoms/toggle-switch/ToggleSwitch.mdx +0 -17
- package/src/components/atoms/typeahead-input/TypeaheadInput.mdx +0 -13
- package/src/components/atoms/typeahead-input/TypeaheadInput.stories.js +0 -63
- package/src/components/molecules/address-form/AddressForm.mdx +0 -18
- package/src/components/molecules/banner/Banner.mdx +0 -23
- package/src/components/molecules/change-password-form/ChangePasswordForm.mdx +0 -15
- package/src/components/molecules/collapsible-section/CollapsibleSection.mdx +0 -15
- package/src/components/molecules/edit-name-form/EditNameForm.mdx +0 -13
- package/src/components/molecules/edit-name-form/EditNameForm.stories.js +0 -117
- package/src/components/molecules/idle-modal/IdleModal.js +0 -101
- package/src/components/molecules/idle-modal/IdleModal.mdx +0 -17
- package/src/components/molecules/idle-modal/IdleModal.stories.js +0 -180
- package/src/components/molecules/idle-modal/index.d.ts +0 -16
- package/src/components/molecules/idle-modal/index.js +0 -3
- package/src/components/molecules/link-card/LinkCard.mdx +0 -17
- package/src/components/molecules/login-form/LoginForm.mdx +0 -16
- package/src/components/molecules/modal/Modal.mdx +0 -17
- package/src/components/molecules/module/Module.mdx +0 -17
- package/src/components/molecules/obligation/Obligation.mdx +0 -23
- package/src/components/molecules/obligation/Obligation.stories.js +0 -460
- package/src/components/molecules/pagination/Pagination.mdx +0 -15
- package/src/components/molecules/popover/Popover.mdx +0 -15
- package/src/components/molecules/popover/Popover.stories.js +0 -220
- package/src/components/molecules/tabs/Tabs.mdx +0 -17
- package/src/components/molecules/toast-notification/Toast.mdx +0 -15
- package/src/components/molecules/toast-notification/Toast.stories.js +0 -183
- package/src/stories/Button.stories.ts +0 -53
- package/src/stories/Button.tsx +0 -48
- package/src/stories/Configure.mdx +0 -364
- package/src/stories/Header.stories.ts +0 -33
- package/src/stories/Header.tsx +0 -56
- package/src/stories/Page.stories.ts +0 -32
- package/src/stories/Page.tsx +0 -73
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -5
- 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 +0 -15
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -3
- 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 +0 -12
- package/src/stories/assets/youtube.svg +0 -4
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/src/stories/page.css +0 -69
- package/src/util/idleTimerUtils.js +0 -36
- /package/src/components/atoms/add-obligation/{AddObligation.oldstories.js → AddObligation.stories.js} +0 -0
- /package/src/components/atoms/amount-callout/{AmountCallout.oldstories.js → AmountCallout.stories.js} +0 -0
- /package/src/components/atoms/checkbox-list/{CheckboxList.oldstories.js → CheckboxList.stories.js} +0 -0
- /package/src/components/atoms/form-layouts/{FormLayouts.oldstories.js → FormLayouts.stories.js} +0 -0
- /package/src/components/atoms/hamburger-button/{HamburgerButton.oldstories.js → HamburgerButton.stories.js} +0 -0
- /package/src/components/atoms/heading/{Heading.oldstories.js → Heading.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/box-example/{BoxExample.oldstories.js → BoxExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/center-example/{CenterExample.oldstories.js → CenterExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.oldstories.js → ClusterExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.oldstories.js → CoverExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.oldstories.js → FrameExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/grid-example/{GridExample.oldstories.js → GridExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.oldstories.js → ImposterExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.oldstories.js → MotionExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.oldstories.js → ReelExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.oldstories.js → SidebarExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/stack-example/{StackExample.oldstories.js → StackExample.stories.js} +0 -0
- /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.oldstories.js → SwitcherExample.stories.js} +0 -0
- /package/src/components/atoms/paragraph/{Paragraph.oldstories.js → Paragraph.stories.js} +0 -0
- /package/src/components/atoms/processing-fee/{ProcessingFee.oldstories.js → ProcessingFee.stories.js} +0 -0
- /package/src/components/atoms/search/{Search.oldstories.js → Search.stories.js} +0 -0
- /package/src/components/atoms/solid-divider/{SolidDivider.oldstories.js → SolidDivider.stories.js} +0 -0
- /package/src/components/atoms/sortable-table-heading/{SortableTableHeading.oldstories.js → SortableTableHeading.stories.js} +0 -0
- /package/src/components/atoms/spinner/{Spinner.oldstories.js → Spinner.stories.js} +0 -0
- /package/src/components/atoms/tab/{Tab.oldstories.js → Tab.stories.js} +0 -0
- /package/src/components/atoms/text/{Text.oldstories.js → Text.stories.js} +0 -0
- /package/src/components/atoms/typeahead-input/{TypeaheadIinput.oldstories.js → TypeaheadIinput.stories.js} +0 -0
- /package/src/components/atoms/wallet-name/{WalletName.oldstories.js → WalletName.stories.js} +0 -0
- /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.oldstories.js → AccountAndRoutingModal.stories.js} +0 -0
- /package/src/components/molecules/editable-list/{EditableList.oldstories.js → EditableList.stories.js} +0 -0
- /package/src/components/molecules/email-form/{EmailForm.oldstories.js → EmailForm.stories.js} +0 -0
- /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.oldstories.js → ForgotPasswordForm.stories.js} +0 -0
- /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.oldstories.js → HighlightTabRow.stories.js} +0 -0
- /package/src/components/molecules/obligation/modules/{AmountModule.oldstories.js → AmountModule.stories.js} +0 -0
- /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.oldstories.js → PaymentButtonBar.stories.js} +0 -0
- /package/src/components/molecules/payment-details/{PaymentDetails.oldstories.js → PaymentDetails.stories.js} +0 -0
- /package/src/components/molecules/payment-form-ach/{PaymentFormACH.oldstories.js → PaymentFormACH.stories.js} +0 -0
- /package/src/components/molecules/payment-form-card/{PaymentFormCard.oldstories.js → PaymentFormCard.stories.js} +0 -0
- /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.oldstories.js → PeriscopeDashBoardIframe.stories.js} +0 -0
- /package/src/components/molecules/phone-form/{PhoneForm.oldstories.js → PhoneForm.stories.js} +0 -0
- /package/src/components/molecules/popup-menu/{PopupMenu.oldstories.js → PopupMenu.stories.js} +0 -0
- /package/src/components/molecules/radio-group/{RadioGroup.oldstories.js → RadioGroup.stories.js} +0 -0
- /package/src/components/molecules/radio-section/{RadioSection.oldstories.js → RadioSection.stories.js} +0 -0
- /package/src/components/molecules/registration-form/{RegistrationForm.oldstories.js → RegistrationForm.stories.js} +0 -0
- /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.oldstories.js → ResetConfirmationForm.stories.js} +0 -0
- /package/src/components/molecules/reset-password-form/{ResetPasswordForm.oldstories.js → ResetPasswordForm.stories.js} +0 -0
- /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.oldstories.js → ResetPasswordSuccess.stories.js} +0 -0
- /package/src/components/molecules/tab-sidebar/{TabSidebar.oldstories.js → TabSidebar.stories.js} +0 -0
- /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.oldstories.js → TermsAndConditions.stories.js} +0 -0
- /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.oldstories.js → TermsAndConditionsModal.stories.js} +0 -0
- /package/src/components/molecules/workflow-tile/{WorkflowTile.oldstories.js → WorkflowTile.stories.js} +0 -0
|
@@ -1,137 +1,62 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { connect, Provider } from "react-redux";
|
|
5
|
-
import { createStore } from "redux";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
import { text } from "@storybook/addon-knobs";
|
|
6
4
|
import { createFormState } from "redux-freeform";
|
|
7
5
|
|
|
6
|
+
import SearchableSelect, { SELECT_ALL } from "./SearchableSelect";
|
|
7
|
+
import page from "../../../../.storybook/page";
|
|
8
|
+
|
|
8
9
|
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
|
|
9
10
|
searchTerm: {
|
|
10
11
|
validators: []
|
|
11
12
|
}
|
|
12
13
|
});
|
|
13
14
|
|
|
14
|
-
const store = createStore(
|
|
15
|
-
reducer,
|
|
16
|
-
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const selectAllItem = { name: SELECT_ALL, value: SELECT_ALL };
|
|
20
|
-
|
|
21
15
|
const items = [
|
|
22
16
|
{ name: "Foo", value: "foo-value" },
|
|
23
17
|
{ name: "Baz", value: "baz-value" },
|
|
24
|
-
|
|
18
|
+
{ name: SELECT_ALL, value: SELECT_ALL },
|
|
25
19
|
{ name: "Bar", value: "bar-value" }
|
|
26
20
|
];
|
|
27
21
|
|
|
28
22
|
const FormWrapper = props => {
|
|
29
23
|
const [selectedItems, setSelectedItems] = useState(props.selectedItems || []);
|
|
24
|
+
const selectValues = items => items.map(item => item.value);
|
|
30
25
|
|
|
31
|
-
const selectItem =
|
|
32
|
-
if (selectedItems.
|
|
33
|
-
const
|
|
34
|
-
|
|
26
|
+
const selectItem = selectedItem => {
|
|
27
|
+
if (selectValues(selectedItems).includes(selectedItem.value)) {
|
|
28
|
+
const fewerItems = selectedItems.filter(
|
|
29
|
+
item => item.value !== selectedItem.value
|
|
35
30
|
);
|
|
36
|
-
setSelectedItems(
|
|
37
|
-
} else {
|
|
38
|
-
if (selectedItems.length + 1 === items.length - 1) {
|
|
39
|
-
setSelectedItems([...selectedItems, selection, selectAllItem]);
|
|
40
|
-
} else {
|
|
41
|
-
setSelectedItems([...selectedItems, selection]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const toggleSelectAllItems = selectAll => {
|
|
47
|
-
if (selectAll) {
|
|
48
|
-
setSelectedItems(items);
|
|
31
|
+
setSelectedItems(fewerItems);
|
|
49
32
|
} else {
|
|
50
|
-
|
|
33
|
+
const moreItems = selectedItems.concat(selectedItem);
|
|
34
|
+
setSelectedItems(moreItems);
|
|
51
35
|
}
|
|
52
36
|
};
|
|
53
37
|
|
|
54
|
-
const allSelected = selectedItems.length === items.length ?? false;
|
|
55
|
-
|
|
56
38
|
return (
|
|
57
39
|
<SearchableSelect
|
|
58
|
-
{...props}
|
|
59
40
|
autocompleteValue={props.autocompleteValue}
|
|
60
|
-
items={
|
|
61
|
-
selectedItems={selectedItems}
|
|
62
|
-
selectItem={selectItem}
|
|
41
|
+
items={items}
|
|
63
42
|
fields={props.fields}
|
|
64
43
|
actions={props.actions}
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
selectedItems={selectedItems}
|
|
45
|
+
selectItem={item => selectItem(item)}
|
|
67
46
|
/>
|
|
68
47
|
);
|
|
69
48
|
};
|
|
70
49
|
|
|
71
|
-
const
|
|
50
|
+
const story = page({
|
|
51
|
+
title: "Components|Atoms/SearchableSelect",
|
|
52
|
+
Component: SearchableSelect,
|
|
53
|
+
reducer,
|
|
72
54
|
mapStateToProps,
|
|
73
55
|
mapDispatchToProps
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
export default {
|
|
77
|
-
title: "Atoms/SearchableSelect",
|
|
78
|
-
component: ConnectedSearchableSelect,
|
|
79
|
-
tags: ["!autodocs"],
|
|
80
|
-
parameters: {
|
|
81
|
-
controls: { expanded: true }
|
|
82
|
-
},
|
|
83
|
-
args: {
|
|
84
|
-
autocompleteValue: undefined,
|
|
85
|
-
items: items,
|
|
86
|
-
disabled: false,
|
|
87
|
-
themeValues: {},
|
|
88
|
-
placeholder: "Search agencies"
|
|
89
|
-
},
|
|
90
|
-
argTypes: {
|
|
91
|
-
fieldActions: { type: "object" },
|
|
92
|
-
field: { type: "object" },
|
|
93
|
-
selectedItems: {
|
|
94
|
-
description: "Array of objects representing the selected items.",
|
|
95
|
-
table: {
|
|
96
|
-
type: { summary: "array" }
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
selectItem: {
|
|
100
|
-
description:
|
|
101
|
-
"Function that will be called when a non-`SELECT_ALL` checkbox is changed.",
|
|
102
|
-
table: {
|
|
103
|
-
type: { summary: "array" }
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
allSelected: {
|
|
107
|
-
description:
|
|
108
|
-
"Whether all all items are selected or not. This affects what parameter `toggleSelectAllItems` is called with",
|
|
109
|
-
table: {
|
|
110
|
-
type: { summary: "boolean" }
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
toggleSelectAllItems: {
|
|
114
|
-
description:
|
|
115
|
-
"Function called when a checkbox with the name `SELECT_ALL` is changed.",
|
|
116
|
-
table: {
|
|
117
|
-
type: { summary: "function" }
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
decorators: [
|
|
122
|
-
Story => (
|
|
123
|
-
<Provider store={store}>
|
|
124
|
-
<Story />
|
|
125
|
-
</Provider>
|
|
126
|
-
)
|
|
127
|
-
]
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const Basic = args => <ConnectedSearchableSelect {...args} />;
|
|
56
|
+
});
|
|
131
57
|
|
|
132
|
-
export
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
};
|
|
58
|
+
export default story;
|
|
59
|
+
const ConnectedForm = connect(mapStateToProps, mapDispatchToProps)(FormWrapper);
|
|
60
|
+
export const searchableSelect = () => (
|
|
61
|
+
<ConnectedForm autocompleteValue={text("autocompleteValue", null, "props")} />
|
|
62
|
+
);
|
|
@@ -1,78 +1,53 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { createStore } from "redux";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
import { text, boolean } from "@storybook/addon-knobs";
|
|
5
4
|
import { createFormState, required } from "redux-freeform";
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
import StateProvinceDropDown from ".";
|
|
7
|
+
import page from "../../../../.storybook/page";
|
|
7
8
|
|
|
8
9
|
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
|
|
9
|
-
|
|
10
|
+
state: {
|
|
10
11
|
validators: [required()]
|
|
11
12
|
}
|
|
12
13
|
});
|
|
13
|
-
|
|
14
|
-
const store = createStore(
|
|
15
|
-
reducer,
|
|
16
|
-
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
17
|
-
);
|
|
18
|
-
|
|
19
14
|
const errorMessages = {
|
|
20
|
-
[required.error]: "
|
|
15
|
+
[required.error]: "State is required"
|
|
21
16
|
};
|
|
22
17
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
fieldActions={props.actions.fields.country}
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const ConnectedStateProvinceDropdown = connect(
|
|
18
|
+
const story = page({
|
|
19
|
+
title: "Components|Atoms/StateProvinceDropDown",
|
|
20
|
+
Component: StateProvinceDropDown,
|
|
21
|
+
reducer,
|
|
32
22
|
mapStateToProps,
|
|
33
|
-
mapDispatchToProps
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export default {
|
|
37
|
-
title: "Atoms/StateProvinceDropdown",
|
|
38
|
-
component: ConnectedStateProvinceDropdown,
|
|
39
|
-
tags: ["!autodocs"],
|
|
40
|
-
parameters: {
|
|
41
|
-
controls: { expanded: true }
|
|
42
|
-
},
|
|
43
|
-
args: {
|
|
44
|
-
errorMessages: errorMessages,
|
|
45
|
-
showErrors: false,
|
|
46
|
-
onChange: action("onChange"),
|
|
47
|
-
labelTextWhenNoError: "State",
|
|
48
|
-
isRequired: false,
|
|
49
|
-
countryCode: "US"
|
|
50
|
-
},
|
|
51
|
-
argTypes: {
|
|
52
|
-
fieldActions: { type: "object" },
|
|
53
|
-
field: { type: "object" },
|
|
54
|
-
showErrors: {
|
|
55
|
-
table: {
|
|
56
|
-
type: { summary: "boolean" },
|
|
57
|
-
defaultValue: { summary: undefined }
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
decorators: [
|
|
62
|
-
Story => (
|
|
63
|
-
<Provider store={store}>
|
|
64
|
-
<Story />
|
|
65
|
-
</Provider>
|
|
66
|
-
)
|
|
67
|
-
]
|
|
68
|
-
};
|
|
23
|
+
mapDispatchToProps,
|
|
24
|
+
height: "500px"
|
|
25
|
+
});
|
|
69
26
|
|
|
70
|
-
|
|
27
|
+
const FormWrapper = ({
|
|
28
|
+
autocompleteValue,
|
|
29
|
+
fields,
|
|
30
|
+
actions,
|
|
31
|
+
countryCode,
|
|
32
|
+
labelTextWhenNoError,
|
|
33
|
+
showErrors
|
|
34
|
+
}) => (
|
|
35
|
+
<StateProvinceDropDown
|
|
36
|
+
errorMessages={errorMessages}
|
|
37
|
+
field={fields.state}
|
|
38
|
+
fieldActions={actions.fields.state}
|
|
39
|
+
countryCode={countryCode}
|
|
40
|
+
labelTextWhenNoError={labelTextWhenNoError}
|
|
41
|
+
showErrors={showErrors}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
71
44
|
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
45
|
+
export default story;
|
|
46
|
+
const ConnectedForm = connect(mapStateToProps, mapDispatchToProps)(FormWrapper);
|
|
47
|
+
export const stateProvinceDropDown = () => (
|
|
48
|
+
<ConnectedForm
|
|
49
|
+
labelTextWhenNoError={text("State/Province", "", "props")}
|
|
50
|
+
countryCode={text("countryCode", "US", "props")}
|
|
51
|
+
showErrors={boolean("showErrors", false, "props")}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
@@ -1,65 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TableHead,
|
|
6
|
-
TableHeading,
|
|
7
|
-
TableRow
|
|
8
|
-
} from "./index.js";
|
|
9
|
-
import { fn } from "@storybook/test";
|
|
10
|
-
import { noop } from "../../../util/general";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Table, TableHead, TableBody, TableRow, TableCell } from "./";
|
|
3
|
+
import page from "../../../../.storybook/page";
|
|
4
|
+
import SortableTableHeading from "../sortable-table-heading";
|
|
11
5
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
layout: "centered",
|
|
18
|
-
controls: { expanded: true }
|
|
19
|
-
},
|
|
20
|
-
args: {
|
|
21
|
-
extraStyles: undefined
|
|
22
|
-
},
|
|
23
|
-
argTypes: {
|
|
24
|
-
extraStyles: {
|
|
25
|
-
description: "Styles for the table element.",
|
|
26
|
-
control: { type: "text" },
|
|
27
|
-
table: {
|
|
28
|
-
type: { summary: "string" },
|
|
29
|
-
defaultValue: { summary: undefined }
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
6
|
+
const data = [
|
|
7
|
+
{ name: "Alice", occupation: "Engineer", location: "New York" },
|
|
8
|
+
{ name: "Bob", occupation: "Designer", location: "Los Angeles" },
|
|
9
|
+
{ name: "Charlie", occupation: "Doctor", location: "Chicago" }
|
|
10
|
+
];
|
|
34
11
|
|
|
35
|
-
|
|
12
|
+
const headings = [
|
|
13
|
+
{ displayName: "Name", sortKey: "name" },
|
|
14
|
+
{ displayName: "Occupation", sortKey: "occupation" },
|
|
15
|
+
{ displayName: "Location", sortKey: "location" }
|
|
16
|
+
];
|
|
36
17
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<TableCell>Cell 2</TableCell>
|
|
48
|
-
<TableCell>Cell 3</TableCell>
|
|
49
|
-
</TableRow>
|
|
50
|
-
<TableRow hoverCursor={hoverCursor} onClick={onClick}>
|
|
51
|
-
<TableCell>Cell 4</TableCell>
|
|
52
|
-
<TableCell>Cell 5</TableCell>
|
|
53
|
-
<TableCell>Cell 6</TableCell>
|
|
54
|
-
</TableRow>
|
|
55
|
-
</TableBody>
|
|
56
|
-
</Table>
|
|
57
|
-
);
|
|
18
|
+
const ComposedSortableTable = () => {
|
|
19
|
+
const [sortState, setSortState] = useState({
|
|
20
|
+
column: "name",
|
|
21
|
+
order: "asc"
|
|
22
|
+
});
|
|
23
|
+
const [sortedData, setSortedData] = useState(data);
|
|
24
|
+
const handleSortChange = column => {
|
|
25
|
+
// Determine the new sort order for SortableTableHeading components
|
|
26
|
+
const newOrder =
|
|
27
|
+
sortState.column === column && sortState.order === "asc" ? "desc" : "asc";
|
|
58
28
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
29
|
+
setSortState({
|
|
30
|
+
column,
|
|
31
|
+
order: newOrder
|
|
32
|
+
});
|
|
62
33
|
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
// Perform sort and update sortedData state
|
|
35
|
+
const sorted = [...data].sort((a, b) => {
|
|
36
|
+
const valueA = a[column];
|
|
37
|
+
const valueB = b[column];
|
|
38
|
+
if (newOrder === "asc") {
|
|
39
|
+
return valueA > valueB ? 1 : -1;
|
|
40
|
+
} else {
|
|
41
|
+
return valueA < valueB ? 1 : -1;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
setSortedData(sorted);
|
|
46
|
+
};
|
|
47
|
+
return (
|
|
48
|
+
<Table id="users-table">
|
|
49
|
+
<TableHead>
|
|
50
|
+
{headings.map(heading => (
|
|
51
|
+
<SortableTableHeading
|
|
52
|
+
ariaControlsId="users-table"
|
|
53
|
+
displayName={heading.displayName}
|
|
54
|
+
key={heading.sortKey}
|
|
55
|
+
onSortChange={() => handleSortChange(heading.sortKey)}
|
|
56
|
+
sortOrder={
|
|
57
|
+
sortState.column === heading.sortKey ? sortState.order : null
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
))}
|
|
61
|
+
</TableHead>
|
|
62
|
+
<TableBody>
|
|
63
|
+
{sortedData.map((item, idx) => (
|
|
64
|
+
<TableRow key={idx}>
|
|
65
|
+
<TableCell>{item.name}</TableCell>
|
|
66
|
+
<TableCell>{item.occupation}</TableCell>
|
|
67
|
+
<TableCell>{item.location}</TableCell>
|
|
68
|
+
</TableRow>
|
|
69
|
+
))}
|
|
70
|
+
</TableBody>
|
|
71
|
+
</Table>
|
|
72
|
+
);
|
|
65
73
|
};
|
|
74
|
+
|
|
75
|
+
export const table = () => <ComposedSortableTable />;
|
|
76
|
+
const story = page({
|
|
77
|
+
title: "Components|Atoms/Table",
|
|
78
|
+
Component: Table
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export default story;
|
|
@@ -10,6 +10,29 @@ import {
|
|
|
10
10
|
} from "./Title.theme";
|
|
11
11
|
import { themeComponent } from "../../../util/themeUtils";
|
|
12
12
|
|
|
13
|
+
/*
|
|
14
|
+
New responsive text component for Title elements
|
|
15
|
+
Size is decoupled from tag
|
|
16
|
+
Comes with two variants - "large" and "small"
|
|
17
|
+
Large variant results in text that is 1.5rem (24px desktop, 21px mobile)
|
|
18
|
+
Small variant results in text that is 1.25rem/1.2142rem (20px desktop, 17px mobile)
|
|
19
|
+
|
|
20
|
+
If you need a smaller text size, use the <Detail /> atom, which has smaller variants
|
|
21
|
+
|
|
22
|
+
Use the "as" prop to specify element type, can use any of: h1/h2/h3/h4/h5/h6/p
|
|
23
|
+
If you need an inline text element (span), use the <Text /> atom
|
|
24
|
+
The "as" value should be dictated by the structure of your page, not what font-size you want
|
|
25
|
+
|
|
26
|
+
Title / Detail both use slightly different desktop/mobile scales
|
|
27
|
+
(Mobile scale is different to allow for design-friendly px values)
|
|
28
|
+
Both atoms detect the presence of a mobile device on their own
|
|
29
|
+
and apply the corresponding scale
|
|
30
|
+
|
|
31
|
+
Mobile breakpoint value is specified in Title.theme.js
|
|
32
|
+
|
|
33
|
+
If you want to disable mobile text scales (use the same rem scale for desktop/mobile), then use a theme in FCS to set both the "large" and "small" variants to use the same rem sizes. FCS themes override fallbacks defined in the .theme file
|
|
34
|
+
*/
|
|
35
|
+
|
|
13
36
|
const isBelowBreakpoint = window.innerWidth < MOBILE_BREAKPOINT;
|
|
14
37
|
const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 1;
|
|
15
38
|
const mobileDeviceDetected = isBelowBreakpoint && isTouchDevice;
|
|
@@ -1,111 +1,28 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useState, Fragment } from "react";
|
|
2
|
+
import { boolean, text } from "@storybook/addon-knobs";
|
|
2
3
|
import ToggleSwitch from "./ToggleSwitch";
|
|
3
|
-
import
|
|
4
|
+
import page from "../../../../.storybook/page";
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
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;
|
|
6
|
+
export const toggleSwitchDefault = () => {
|
|
7
|
+
const [isOn, onToggle] = useState(false);
|
|
80
8
|
|
|
9
|
+
const disabled = boolean("disabled", false, "props");
|
|
81
10
|
return (
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
11
|
+
<Fragment>
|
|
12
|
+
<ToggleSwitch
|
|
13
|
+
name="toggle-switch"
|
|
14
|
+
label={text("label", "Toggle Switch Label", "props")}
|
|
15
|
+
isOn={isOn}
|
|
16
|
+
onToggle={() => onToggle(!isOn)}
|
|
17
|
+
disabled={disabled}
|
|
18
|
+
/>
|
|
19
|
+
</Fragment>
|
|
88
20
|
);
|
|
89
21
|
};
|
|
90
22
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const LeftLabelToggleSwitch = {
|
|
98
|
-
args: {
|
|
99
|
-
labelLeft: true,
|
|
100
|
-
label: "Set as Default"
|
|
101
|
-
},
|
|
102
|
-
render: args => <StatefulToggle {...args} />
|
|
103
|
-
};
|
|
23
|
+
const story = page({
|
|
24
|
+
title: "Components|Atoms/ToggleSwitch",
|
|
25
|
+
Component: ToggleSwitch
|
|
26
|
+
});
|
|
104
27
|
|
|
105
|
-
export
|
|
106
|
-
args: {
|
|
107
|
-
label: "Receive SMS Alerts",
|
|
108
|
-
disabled: true
|
|
109
|
-
},
|
|
110
|
-
render: args => <StatefulToggle {...args} />
|
|
111
|
-
};
|
|
28
|
+
export default story;
|
|
@@ -17,15 +17,13 @@ const labelStyles = `
|
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
19
|
const rightLabelStyles = `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
20
|
+
${labelStyles}
|
|
21
|
+
flex-direction: row;
|
|
23
22
|
`;
|
|
24
23
|
|
|
25
24
|
const leftLabelStyles = `
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
25
|
+
${labelStyles}
|
|
26
|
+
flex-direction: row-reverse;
|
|
29
27
|
`;
|
|
30
28
|
|
|
31
29
|
export const fallbackValues = {
|
|
@@ -34,6 +32,5 @@ export const fallbackValues = {
|
|
|
34
32
|
disabledBackgroundLight,
|
|
35
33
|
white,
|
|
36
34
|
rightLabelStyles,
|
|
37
|
-
leftLabelStyles
|
|
38
|
-
labelStyles
|
|
35
|
+
leftLabelStyles
|
|
39
36
|
};
|