@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,85 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import { Text, Center } from "../../../atoms";
|
|
3
|
-
import DropdownIconV2 from "../../../atoms/dropdown/DropdownIconV2";
|
|
4
|
-
import { StyledFilterButton } from "../MultipleSelectFilter.styled";
|
|
5
|
-
import { noop } from "../../../../util/general";
|
|
6
|
-
|
|
7
|
-
const FilterButton = forwardRef(
|
|
8
|
-
(
|
|
9
|
-
{
|
|
10
|
-
btnContentOverride,
|
|
11
|
-
action = noop,
|
|
12
|
-
opened,
|
|
13
|
-
backgroundColor,
|
|
14
|
-
contentColor,
|
|
15
|
-
name,
|
|
16
|
-
filterDropdownID,
|
|
17
|
-
hasIcon = false,
|
|
18
|
-
icon: Icon,
|
|
19
|
-
truncateBtnTextWidth,
|
|
20
|
-
filterLabel,
|
|
21
|
-
selectedOptions
|
|
22
|
-
},
|
|
23
|
-
ref
|
|
24
|
-
) => {
|
|
25
|
-
return (
|
|
26
|
-
<StyledFilterButton
|
|
27
|
-
ref={ref}
|
|
28
|
-
variant="tertiary"
|
|
29
|
-
action={action}
|
|
30
|
-
aria-haspopup="listbox"
|
|
31
|
-
aria-expanded={opened}
|
|
32
|
-
aria-controls={filterDropdownID}
|
|
33
|
-
backgroundColor={backgroundColor}
|
|
34
|
-
dataQa={`${name}-filter-button`}
|
|
35
|
-
contentOverride
|
|
36
|
-
>
|
|
37
|
-
{btnContentOverride ? (
|
|
38
|
-
btnContentOverride
|
|
39
|
-
) : (
|
|
40
|
-
<Center
|
|
41
|
-
as="span"
|
|
42
|
-
style={{ display: "flex", flexDirection: "row" }}
|
|
43
|
-
intrinsic
|
|
44
|
-
>
|
|
45
|
-
{hasIcon && <Icon color={contentColor} />}
|
|
46
|
-
<Center
|
|
47
|
-
as="span"
|
|
48
|
-
style={{
|
|
49
|
-
display: "flex",
|
|
50
|
-
flexDirection: "row",
|
|
51
|
-
padding: "0 0.5rem 0 0.25rem"
|
|
52
|
-
}}
|
|
53
|
-
intrinsic
|
|
54
|
-
>
|
|
55
|
-
<Text
|
|
56
|
-
variant="pS"
|
|
57
|
-
color={contentColor}
|
|
58
|
-
extraStyles={`
|
|
59
|
-
white-space: nowrap;
|
|
60
|
-
overflow: hidden;
|
|
61
|
-
text-overflow: ellipsis;
|
|
62
|
-
${truncateBtnTextWidth && `max-width:` + truncateBtnTextWidth}
|
|
63
|
-
`}
|
|
64
|
-
>
|
|
65
|
-
{selectedOptions?.length
|
|
66
|
-
? `${filterLabel ? filterLabel + ": " : ""}${
|
|
67
|
-
selectedOptions[0].name
|
|
68
|
-
}`
|
|
69
|
-
: `${filterLabel ? filterLabel : ""}`}
|
|
70
|
-
</Text>
|
|
71
|
-
<Text color={contentColor} variant="pS">
|
|
72
|
-
{selectedOptions?.length && selectedOptions?.length > 1
|
|
73
|
-
? `, +${selectedOptions?.length - 1} More`
|
|
74
|
-
: ""}
|
|
75
|
-
</Text>
|
|
76
|
-
</Center>
|
|
77
|
-
<DropdownIconV2 color={contentColor} />
|
|
78
|
-
</Center>
|
|
79
|
-
)}
|
|
80
|
-
</StyledFilterButton>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
export default FilterButton;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import { FilterDropdownContainer } from "../MultipleSelectFilter.styled";
|
|
3
|
-
|
|
4
|
-
const FilterDropdown = forwardRef(({ id, ariaOwns, opened, children }, ref) => {
|
|
5
|
-
return (
|
|
6
|
-
<>
|
|
7
|
-
{opened && (
|
|
8
|
-
<FilterDropdownContainer
|
|
9
|
-
ref={ref}
|
|
10
|
-
id={id}
|
|
11
|
-
role="combobox"
|
|
12
|
-
aria-expanded={opened}
|
|
13
|
-
aria-haspopup="listbox"
|
|
14
|
-
aria-owns={ariaOwns}
|
|
15
|
-
>
|
|
16
|
-
{children}
|
|
17
|
-
</FilterDropdownContainer>
|
|
18
|
-
)}
|
|
19
|
-
</>
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export default FilterDropdown;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import { Box } from "../../../atoms";
|
|
3
|
-
import FilterableListItem from "./FilterableListItem";
|
|
4
|
-
import useKeyboardNavigation from "./useKeyboardNavigation";
|
|
5
|
-
import {
|
|
6
|
-
sortItemsList,
|
|
7
|
-
filterItemsList,
|
|
8
|
-
selectOption,
|
|
9
|
-
isChecked,
|
|
10
|
-
isMaxSelectionReached
|
|
11
|
-
} from "./util";
|
|
12
|
-
import { GHOST_GREY } from "../../../../constants/colors";
|
|
13
|
-
|
|
14
|
-
const FilterableList = ({
|
|
15
|
-
id,
|
|
16
|
-
options,
|
|
17
|
-
appliedOptions,
|
|
18
|
-
selectedOptions,
|
|
19
|
-
maxSelections,
|
|
20
|
-
name,
|
|
21
|
-
setSelectedOptions,
|
|
22
|
-
searchTerm,
|
|
23
|
-
themeValues
|
|
24
|
-
}) => {
|
|
25
|
-
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
26
|
-
const [filteredAppliedOptions, setFilteredAppliedOptions] = useState([]);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setFilteredOptions(options);
|
|
30
|
-
setFilteredAppliedOptions(appliedOptions);
|
|
31
|
-
}, [options, appliedOptions]);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const filteredOptionItems = filterItemsList(options, searchTerm?.rawValue);
|
|
35
|
-
const filteredAppliedItems = filterItemsList(
|
|
36
|
-
appliedOptions,
|
|
37
|
-
searchTerm?.rawValue
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
setFilteredOptions(
|
|
41
|
-
filteredOptionItems.length ? filteredOptionItems : filteredOptions
|
|
42
|
-
);
|
|
43
|
-
setFilteredAppliedOptions(filteredAppliedItems);
|
|
44
|
-
}, [searchTerm.rawValue]);
|
|
45
|
-
|
|
46
|
-
const handleSelectOption = option =>
|
|
47
|
-
selectOption(option, selectedOptions, setSelectedOptions);
|
|
48
|
-
|
|
49
|
-
const isAppliedOption = option =>
|
|
50
|
-
filteredAppliedOptions?.some(
|
|
51
|
-
appliedItem => appliedItem?.name === option?.name
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const currentFilteredOptions = filteredOptions.filter(
|
|
55
|
-
option => !isAppliedOption(option)
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const sortedOptions = sortItemsList(currentFilteredOptions);
|
|
59
|
-
const sortedAppliedOptions = sortItemsList(filteredAppliedOptions);
|
|
60
|
-
|
|
61
|
-
const { itemRefs, focusedIndex, handleKeyDown } = useKeyboardNavigation({
|
|
62
|
-
options: sortedOptions,
|
|
63
|
-
appliedOptions: sortedAppliedOptions,
|
|
64
|
-
selectedOptions,
|
|
65
|
-
maxSelections
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Box
|
|
70
|
-
id={id}
|
|
71
|
-
role="listbox"
|
|
72
|
-
padding="0"
|
|
73
|
-
extraStyles={`
|
|
74
|
-
overflow-y: auto;
|
|
75
|
-
max-height: 250px;
|
|
76
|
-
display: flex;
|
|
77
|
-
flex-flow: column;
|
|
78
|
-
`}
|
|
79
|
-
onKeyDown={handleKeyDown}
|
|
80
|
-
>
|
|
81
|
-
{sortedAppliedOptions?.length > 0 && (
|
|
82
|
-
<Box
|
|
83
|
-
padding="0"
|
|
84
|
-
extraStyles={
|
|
85
|
-
sortedOptions.length > 0 && `border-bottom: 1px solid ${GHOST_GREY}`
|
|
86
|
-
}
|
|
87
|
-
>
|
|
88
|
-
{sortedAppliedOptions.map((option, index) => {
|
|
89
|
-
const checked = isChecked(option, selectedOptions);
|
|
90
|
-
const tabIndex =
|
|
91
|
-
index === focusedIndex || (index === 0 && focusedIndex === -1)
|
|
92
|
-
? "0"
|
|
93
|
-
: "-1";
|
|
94
|
-
return (
|
|
95
|
-
<FilterableListItem
|
|
96
|
-
key={index}
|
|
97
|
-
ref={el => (itemRefs.current[index] = el)}
|
|
98
|
-
index={index}
|
|
99
|
-
option={option}
|
|
100
|
-
checked={checked}
|
|
101
|
-
selectOption={handleSelectOption}
|
|
102
|
-
tabIndex={tabIndex}
|
|
103
|
-
name={name}
|
|
104
|
-
themeValues={themeValues}
|
|
105
|
-
></FilterableListItem>
|
|
106
|
-
);
|
|
107
|
-
})}
|
|
108
|
-
</Box>
|
|
109
|
-
)}
|
|
110
|
-
{sortedOptions.map((option, index) => {
|
|
111
|
-
const checked = isChecked(option, selectedOptions);
|
|
112
|
-
const isDisabled =
|
|
113
|
-
isMaxSelectionReached(maxSelections, selectedOptions) && !checked;
|
|
114
|
-
const indexOffset = sortedAppliedOptions?.length
|
|
115
|
-
? sortedAppliedOptions?.length
|
|
116
|
-
: 0;
|
|
117
|
-
const currentIndex = index === 0 ? indexOffset : index + indexOffset;
|
|
118
|
-
const tabIndex =
|
|
119
|
-
currentIndex === focusedIndex ||
|
|
120
|
-
(indexOffset === 0 &&
|
|
121
|
-
currentIndex === indexOffset &&
|
|
122
|
-
focusedIndex === -1)
|
|
123
|
-
? "0"
|
|
124
|
-
: "-1";
|
|
125
|
-
return (
|
|
126
|
-
<FilterableListItem
|
|
127
|
-
key={currentIndex}
|
|
128
|
-
ref={el => (itemRefs.current[currentIndex] = el)}
|
|
129
|
-
index={currentIndex}
|
|
130
|
-
option={option}
|
|
131
|
-
checked={checked}
|
|
132
|
-
selectOption={isDisabled ? noop : handleSelectOption}
|
|
133
|
-
disabled={isDisabled}
|
|
134
|
-
tabIndex={tabIndex}
|
|
135
|
-
name={name}
|
|
136
|
-
themeValues={themeValues}
|
|
137
|
-
></FilterableListItem>
|
|
138
|
-
);
|
|
139
|
-
})}
|
|
140
|
-
</Box>
|
|
141
|
-
);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export default React.memo(FilterableList);
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import Checkbox from "../../../atoms/checkbox";
|
|
3
|
-
import { Box } from "../../../atoms";
|
|
4
|
-
|
|
5
|
-
const FilterableListItem = forwardRef(
|
|
6
|
-
(
|
|
7
|
-
{
|
|
8
|
-
index,
|
|
9
|
-
option,
|
|
10
|
-
checked,
|
|
11
|
-
selectOption,
|
|
12
|
-
disabled,
|
|
13
|
-
tabIndex,
|
|
14
|
-
name,
|
|
15
|
-
themeValues
|
|
16
|
-
},
|
|
17
|
-
ref
|
|
18
|
-
) => {
|
|
19
|
-
return (
|
|
20
|
-
<Box
|
|
21
|
-
padding="0"
|
|
22
|
-
key={index}
|
|
23
|
-
extraStyles={`
|
|
24
|
-
:hover,
|
|
25
|
-
:active,
|
|
26
|
-
:focus {
|
|
27
|
-
background-color: ${themeValues.primaryColor};
|
|
28
|
-
}
|
|
29
|
-
`}
|
|
30
|
-
>
|
|
31
|
-
<Checkbox
|
|
32
|
-
ref={ref}
|
|
33
|
-
title={option.name}
|
|
34
|
-
name={option.name}
|
|
35
|
-
checked={checked}
|
|
36
|
-
onChange={() => selectOption(option)}
|
|
37
|
-
textExtraStyles={`font-size: 0.875rem; margin: 0;`}
|
|
38
|
-
disabled={disabled}
|
|
39
|
-
extraStyles={`
|
|
40
|
-
padding: 0.075rem 0.325rem;
|
|
41
|
-
margin: 0;
|
|
42
|
-
:hover,
|
|
43
|
-
:active,
|
|
44
|
-
:focus {
|
|
45
|
-
background-color: ${themeValues.primaryColor};
|
|
46
|
-
}
|
|
47
|
-
`}
|
|
48
|
-
checkboxMargin="0.3rem"
|
|
49
|
-
role="option"
|
|
50
|
-
checkboxExtraStyles={`
|
|
51
|
-
width: 1.375rem;
|
|
52
|
-
height: 1.375rem;
|
|
53
|
-
${
|
|
54
|
-
checked && !disabled
|
|
55
|
-
? `background: ` + themeValues.secondaryColor + `;`
|
|
56
|
-
: ""
|
|
57
|
-
}
|
|
58
|
-
`}
|
|
59
|
-
tabIndex={tabIndex}
|
|
60
|
-
dataQa={`${name}-option-${index}`}
|
|
61
|
-
/>
|
|
62
|
-
</Box>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
export default FilterableListItem;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Box, FormInput } from "../../../atoms";
|
|
3
|
-
import { GHOST_GREY } from "../../../../constants/colors";
|
|
4
|
-
|
|
5
|
-
const SearchBox = ({
|
|
6
|
-
autocompleteValue,
|
|
7
|
-
fields,
|
|
8
|
-
actions,
|
|
9
|
-
placeholder,
|
|
10
|
-
disabled,
|
|
11
|
-
showSearchBox
|
|
12
|
-
}) => {
|
|
13
|
-
return (
|
|
14
|
-
<Box padding="0 0 0.5rem">
|
|
15
|
-
{showSearchBox && (
|
|
16
|
-
<FormInput
|
|
17
|
-
autocompleteValue={autocompleteValue}
|
|
18
|
-
showFieldErrorRow={false}
|
|
19
|
-
errorMessages={{}}
|
|
20
|
-
field={fields.searchTerm}
|
|
21
|
-
fieldActions={actions.fields.searchTerm}
|
|
22
|
-
placeholder={placeholder}
|
|
23
|
-
disabled={disabled}
|
|
24
|
-
extraStyles={`
|
|
25
|
-
height: 2.875rem;
|
|
26
|
-
border: 0;
|
|
27
|
-
border-radius: 0;
|
|
28
|
-
padding: 0.45rem;
|
|
29
|
-
font-size: 0.875rem;
|
|
30
|
-
border-bottom: 1px solid ${GHOST_GREY};
|
|
31
|
-
`}
|
|
32
|
-
/>
|
|
33
|
-
)}
|
|
34
|
-
</Box>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default SearchBox;
|
package/src/components/molecules/multiple-select-filter/__private__/useKeyboardNavigation.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState, useEffect } from "react";
|
|
2
|
-
import { isMaxSelectionReached } from "./util";
|
|
3
|
-
|
|
4
|
-
const useKeyboardNavigation = ({
|
|
5
|
-
options,
|
|
6
|
-
appliedOptions,
|
|
7
|
-
selectedOptions,
|
|
8
|
-
maxSelections
|
|
9
|
-
}) => {
|
|
10
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
11
|
-
const itemRefs = useRef([]);
|
|
12
|
-
const totalItemsLength = options.length + appliedOptions.length;
|
|
13
|
-
|
|
14
|
-
const handleArrowUp = event => {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
setFocusedIndex(prevIndex =>
|
|
17
|
-
prevIndex > 0 ? prevIndex - 1 : totalItemsLength - 1
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const handleArrowDown = event => {
|
|
22
|
-
event.preventDefault();
|
|
23
|
-
setFocusedIndex(prevIndex =>
|
|
24
|
-
prevIndex < totalItemsLength - 1 ? prevIndex + 1 : 0
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const handleSpacebar = event => {
|
|
29
|
-
event.preventDefault();
|
|
30
|
-
const validFocusedIndex = focusedIndex < 0 ? 0 : focusedIndex;
|
|
31
|
-
// Select option on spacebar press if the maximum selection hasn't been reached.
|
|
32
|
-
if (
|
|
33
|
-
!isMaxSelectionReached(maxSelections, selectedOptions) &&
|
|
34
|
-
itemRefs.current &&
|
|
35
|
-
itemRefs.current[validFocusedIndex]
|
|
36
|
-
) {
|
|
37
|
-
const nestedInput = itemRefs.current[validFocusedIndex].querySelector(
|
|
38
|
-
"input"
|
|
39
|
-
);
|
|
40
|
-
if (nestedInput) {
|
|
41
|
-
nestedInput.click();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const handleTab = event => {
|
|
47
|
-
// Reset focus when tabbing out of the list.
|
|
48
|
-
setFocusedIndex(-1);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const keyActions = {
|
|
52
|
-
" ": event => handleSpacebar(event),
|
|
53
|
-
Space: event => handleSpacebar(event),
|
|
54
|
-
Tab: event => handleTab(event),
|
|
55
|
-
ArrowUp: event => handleArrowUp(event),
|
|
56
|
-
ArrowDown: event => handleArrowDown(event)
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const handleKeyDown = event => {
|
|
60
|
-
const eventKey = event.code || event.key;
|
|
61
|
-
const action = keyActions[eventKey];
|
|
62
|
-
if (action) {
|
|
63
|
-
action(event);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (
|
|
69
|
-
focusedIndex !== -1 &&
|
|
70
|
-
itemRefs.current &&
|
|
71
|
-
itemRefs.current[focusedIndex]
|
|
72
|
-
) {
|
|
73
|
-
itemRefs.current[focusedIndex].focus(); // move focus to the active option
|
|
74
|
-
}
|
|
75
|
-
}, [focusedIndex]);
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
itemRefs,
|
|
79
|
-
focusedIndex,
|
|
80
|
-
handleKeyDown
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default useKeyboardNavigation;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const filterItemsList = (list, searchTerm) =>
|
|
2
|
-
list.filter(item =>
|
|
3
|
-
item?.name?.toLowerCase().includes(searchTerm?.toLowerCase())
|
|
4
|
-
);
|
|
5
|
-
|
|
6
|
-
export const sortItemsList = list =>
|
|
7
|
-
list
|
|
8
|
-
.slice()
|
|
9
|
-
.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
|
10
|
-
|
|
11
|
-
export const isMaxSelectionReached = (maxSelection, selectedOptions) =>
|
|
12
|
-
maxSelection && maxSelection === selectedOptions?.length;
|
|
13
|
-
|
|
14
|
-
export const isChecked = (option, selectedOptions) =>
|
|
15
|
-
selectedOptions?.some(
|
|
16
|
-
selectedOption => selectedOption?.name === option?.name
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export const selectValues = items => items.map(item => item.value);
|
|
20
|
-
|
|
21
|
-
export const selectOption = (option, selectedOptions, setSelectedOptions) => {
|
|
22
|
-
if (selectValues(selectedOptions).includes(option.value)) {
|
|
23
|
-
const fewerOptions = selectedOptions.filter(
|
|
24
|
-
selectedOption => selectedOption.value !== option.value
|
|
25
|
-
);
|
|
26
|
-
setSelectedOptions(fewerOptions);
|
|
27
|
-
} else {
|
|
28
|
-
const moreOptions = selectedOptions.concat(option);
|
|
29
|
-
setSelectedOptions(moreOptions);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
import ToastNotification from "./ToastNotification";
|
|
3
|
-
import page from "../../../../.storybook/page";
|
|
4
|
-
import { useToastNotification } from "../../../hooks";
|
|
5
|
-
import { ToastVariants } from "../../../types/common";
|
|
6
|
-
import { text } from "@storybook/addon-knobs";
|
|
7
|
-
|
|
8
|
-
const groupId = "props";
|
|
9
|
-
|
|
10
|
-
export const toastNotificationSuccess = () => {
|
|
11
|
-
const {
|
|
12
|
-
isToastOpen,
|
|
13
|
-
toastVariant,
|
|
14
|
-
toastMessage,
|
|
15
|
-
showToast,
|
|
16
|
-
hideToast
|
|
17
|
-
} = useToastNotification();
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
showToast({
|
|
21
|
-
message: "Success!",
|
|
22
|
-
variant: ToastVariants.SUCCESS
|
|
23
|
-
});
|
|
24
|
-
}, []);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<ToastNotification
|
|
28
|
-
variant={toastVariant}
|
|
29
|
-
message={toastMessage}
|
|
30
|
-
toastOpen={isToastOpen}
|
|
31
|
-
closeToastNotification={() => hideToast()}
|
|
32
|
-
role={text("role", "alert", groupId)}
|
|
33
|
-
minWidth={text("minWidth", null, groupId)}
|
|
34
|
-
maxWidth={text("maxWidth", null, groupId)}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
toastNotificationSuccess.storyName = "Success Toast";
|
|
40
|
-
|
|
41
|
-
export const toastNotificationError = () => {
|
|
42
|
-
const {
|
|
43
|
-
isToastOpen,
|
|
44
|
-
toastVariant,
|
|
45
|
-
toastMessage,
|
|
46
|
-
showToast,
|
|
47
|
-
hideToast
|
|
48
|
-
} = useToastNotification();
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
showToast({
|
|
52
|
-
message: "An error occurred",
|
|
53
|
-
variant: ToastVariants.ERROR
|
|
54
|
-
});
|
|
55
|
-
}, []);
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<ToastNotification
|
|
59
|
-
variant={toastVariant}
|
|
60
|
-
message={toastMessage}
|
|
61
|
-
toastOpen={isToastOpen}
|
|
62
|
-
closeToastNotification={() => hideToast()}
|
|
63
|
-
role={text("role", "alert", groupId)}
|
|
64
|
-
minWidth={text("minWidth", null, groupId)}
|
|
65
|
-
maxWidth={text("maxWidth", null, groupId)}
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
toastNotificationError.storyName = "Error Toast";
|
|
70
|
-
|
|
71
|
-
export const toastNotificationNoAutoHide = () => {
|
|
72
|
-
const {
|
|
73
|
-
isToastOpen,
|
|
74
|
-
toastMessage,
|
|
75
|
-
showToast,
|
|
76
|
-
hideToast
|
|
77
|
-
} = useToastNotification({ timeout: 0 });
|
|
78
|
-
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
showToast({
|
|
81
|
-
message: "Success!",
|
|
82
|
-
variant: ToastVariants.SUCCESS
|
|
83
|
-
});
|
|
84
|
-
}, []);
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<ToastNotification
|
|
88
|
-
message={toastMessage}
|
|
89
|
-
toastOpen={isToastOpen}
|
|
90
|
-
closeToastNotification={() => hideToast()}
|
|
91
|
-
role={text("role", "alert", groupId)}
|
|
92
|
-
minWidth={text("minWidth", null, groupId)}
|
|
93
|
-
maxWidth={text("maxWidth", null, groupId)}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
toastNotificationNoAutoHide.storyName = "No auto-hide";
|
|
99
|
-
|
|
100
|
-
const story = page({
|
|
101
|
-
title: "Components|Molecules/ToastNotification",
|
|
102
|
-
Component: ToastNotification
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
export default story;
|
|
File without changes
|
|
File without changes
|
/package/src/components/atoms/checkbox-list/{CheckboxList.stories.js → CheckboxList.oldstories.js}
RENAMED
|
File without changes
|
/package/src/components/atoms/form-layouts/{FormLayouts.stories.js → FormLayouts.oldstories.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/components/atoms/solid-divider/{SolidDivider.stories.js → SolidDivider.oldstories.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/components/atoms/wallet-name/{WalletName.stories.js → WalletName.oldstories.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/components/molecules/email-form/{EmailForm.stories.js → EmailForm.oldstories.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|