@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.
Files changed (215) hide show
  1. package/README.md +4 -0
  2. package/dist/index.cjs.js +1413 -2314
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +6 -4
  5. package/dist/index.esm.js +1413 -2315
  6. package/dist/index.esm.js.map +1 -1
  7. package/package.json +25 -13
  8. package/src/components/atoms/.DS_Store +0 -0
  9. package/src/components/atoms/alert/Alert.mdx +19 -0
  10. package/src/components/atoms/alert/Alert.stories.js +148 -26
  11. package/src/components/atoms/badge/Badge.js +2 -2
  12. package/src/components/atoms/badge/Badge.mdx +27 -0
  13. package/src/components/atoms/badge/Badge.stories.js +143 -29
  14. package/src/components/atoms/breadcrumb/Breadcrumb.mdx +21 -0
  15. package/src/components/atoms/breadcrumb/Breadcrumb.stories.js +38 -29
  16. package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +108 -55
  17. package/src/components/atoms/button-with-link/ButtonWithLink.mdx +21 -0
  18. package/src/components/atoms/button-with-link/ButtonWithLink.stories.js +160 -31
  19. package/src/components/atoms/card/Card.js +13 -1
  20. package/src/components/atoms/card/Card.mdx +41 -0
  21. package/src/components/atoms/card/Card.stories.js +360 -0
  22. package/src/components/atoms/card/Card.theme.js +2 -0
  23. package/src/components/atoms/card/index.d.ts +1 -0
  24. package/src/components/atoms/checkbox/Checkbox.mdx +15 -0
  25. package/src/components/atoms/checkbox/Checkbox.oldstories.js +30 -0
  26. package/src/components/atoms/checkbox/Checkbox.stories.js +148 -29
  27. package/src/components/atoms/country-dropdown/CountryDropdown.mdx +36 -0
  28. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +61 -27
  29. package/src/components/atoms/detail/Detail.js +0 -26
  30. package/src/components/atoms/detail/Detail.mdx +32 -0
  31. package/src/components/atoms/detail/Detail.stories.js +156 -0
  32. package/src/components/atoms/display-box/DisplayBox.mdx +11 -0
  33. package/src/components/atoms/display-box/DisplayBox.stories.js +65 -21
  34. package/src/components/atoms/display-card/DisplayCard.mdx +13 -0
  35. package/src/components/atoms/display-card/DisplayCard.stories.js +163 -22
  36. package/src/components/atoms/dropdown/Dropdown.mdx +65 -0
  37. package/src/components/atoms/dropdown/Dropdown.stories.js +91 -10
  38. package/src/components/atoms/form-layouts/FormInput.mdx +38 -0
  39. package/src/components/atoms/form-layouts/FormInput.stories.js +212 -26
  40. package/src/components/atoms/form-select/FormSelect.mdx +42 -0
  41. package/src/components/atoms/form-select/FormSelect.stories.js +55 -29
  42. package/src/components/atoms/formatted-address/FormattedAddress.mdx +13 -0
  43. package/src/components/atoms/formatted-address/FormattedAddress.stories.js +133 -27
  44. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.mdx +17 -0
  45. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.stories.js +57 -0
  46. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.mdx +40 -0
  47. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.stories.js +74 -0
  48. package/src/components/atoms/icons/Icons.mdx +40 -0
  49. package/src/components/atoms/icons/Icons.stories.js +325 -0
  50. package/src/components/atoms/labeled-amount/LabeledAmount.mdx +23 -0
  51. package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +110 -34
  52. package/src/components/atoms/line-item/LineItem.mdx +28 -0
  53. package/src/components/atoms/line-item/LineItem.stories.js +89 -22
  54. package/src/components/atoms/link/Link.mdx +19 -0
  55. package/src/components/atoms/link/Link.stories.js +155 -49
  56. package/src/components/atoms/loading/Loading.mdx +13 -0
  57. package/src/components/atoms/loading/Loading.stories.js +22 -0
  58. package/src/components/atoms/loading-line/LoadingLine.js +14 -10
  59. package/src/components/atoms/loading-line/LoadingLine.mdx +15 -0
  60. package/src/components/atoms/loading-line/LoadingLine.stories.js +132 -28
  61. package/src/components/atoms/nav-footer/NavFooter.mdx +15 -0
  62. package/src/components/atoms/nav-footer/NavFooter.stories.js +235 -22
  63. package/src/components/atoms/nav-header/NavHeader.mdx +13 -0
  64. package/src/components/atoms/nav-header/NavHeader.stories.js +122 -21
  65. package/src/components/atoms/nav-tabs/NavTabs.mdx +30 -0
  66. package/src/components/atoms/nav-tabs/NavTabs.stories.js +49 -0
  67. package/src/components/atoms/password-requirements/PasswordRequirements.mdx +39 -0
  68. package/src/components/atoms/password-requirements/PasswordRequirements.stories.js +108 -44
  69. package/src/components/atoms/placeholder/Placeholder.mdx +19 -0
  70. package/src/components/atoms/placeholder/Placeholder.stories.js +164 -36
  71. package/src/components/atoms/searchable-select/SearchableSelect.mdx +44 -0
  72. package/src/components/atoms/searchable-select/SearchableSelect.stories.js +103 -28
  73. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.mdx +36 -0
  74. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +65 -40
  75. package/src/components/atoms/table/Table.mdx +71 -0
  76. package/src/components/atoms/table/Table.oldstories.js +84 -0
  77. package/src/components/atoms/table/Table.stories.js +59 -75
  78. package/src/components/atoms/table/TableRow.js +1 -0
  79. package/src/components/atoms/title/Title.js +0 -23
  80. package/src/components/atoms/title/Title.mdx +26 -0
  81. package/src/components/atoms/title/Title.stories.js +144 -0
  82. package/src/components/atoms/toggle-switch/ToggleSwitch.mdx +17 -0
  83. package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +103 -20
  84. package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +8 -5
  85. package/src/components/atoms/typeahead-input/TypeaheadInput.mdx +13 -0
  86. package/src/components/atoms/typeahead-input/TypeaheadInput.stories.js +63 -0
  87. package/src/components/molecules/address-form/AddressForm.mdx +18 -0
  88. package/src/components/molecules/address-form/AddressForm.stories.js +223 -20
  89. package/src/components/molecules/banner/Banner.mdx +23 -0
  90. package/src/components/molecules/banner/Banner.stories.js +122 -26
  91. package/src/components/molecules/change-password-form/ChangePasswordForm.mdx +15 -0
  92. package/src/components/molecules/change-password-form/ChangePasswordForm.stories.js +203 -19
  93. package/src/components/molecules/collapsible-section/CollapsibleSection.mdx +15 -0
  94. package/src/components/molecules/collapsible-section/CollapsibleSection.stories.js +210 -61
  95. package/src/components/molecules/edit-name-form/EditNameForm.mdx +13 -0
  96. package/src/components/molecules/edit-name-form/EditNameForm.stories.js +117 -0
  97. package/src/components/molecules/idle-modal/IdleModal.js +101 -0
  98. package/src/components/molecules/idle-modal/IdleModal.mdx +17 -0
  99. package/src/components/molecules/idle-modal/IdleModal.stories.js +180 -0
  100. package/src/components/molecules/idle-modal/index.d.ts +16 -0
  101. package/src/components/molecules/idle-modal/index.js +3 -0
  102. package/src/components/molecules/index.js +1 -0
  103. package/src/components/molecules/link-card/LinkCard.mdx +17 -0
  104. package/src/components/molecules/link-card/LinkCard.stories.js +287 -72
  105. package/src/components/molecules/login-form/LoginForm.mdx +16 -0
  106. package/src/components/molecules/login-form/LoginForm.stories.js +117 -21
  107. package/src/components/molecules/modal/Modal.mdx +17 -0
  108. package/src/components/molecules/modal/Modal.stories.js +342 -128
  109. package/src/components/molecules/module/Module.mdx +17 -0
  110. package/src/components/molecules/module/Module.stories.js +267 -25
  111. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.js +295 -61
  112. package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.stories.js → MultipleSelectFilter.oldstories.js} +1 -1
  113. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.styled.js +4 -4
  114. package/src/components/molecules/obligation/Obligation.mdx +23 -0
  115. package/src/components/molecules/obligation/Obligation.stories.js +460 -0
  116. package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +1 -1
  117. package/src/components/molecules/pagination/Pagination.mdx +15 -0
  118. package/src/components/molecules/pagination/Pagination.stories.js +177 -28
  119. package/src/components/molecules/popover/Popover.mdx +15 -0
  120. package/src/components/molecules/popover/Popover.stories.js +220 -0
  121. package/src/components/molecules/tabs/Tabs.mdx +17 -0
  122. package/src/components/molecules/tabs/Tabs.stories.js +135 -227
  123. package/src/components/molecules/toast-notification/Toast.mdx +15 -0
  124. package/src/components/molecules/toast-notification/Toast.stories.js +183 -0
  125. package/src/hooks/use-outside-click/index.js +5 -4
  126. package/src/stories/Button.stories.ts +53 -0
  127. package/src/stories/Button.tsx +48 -0
  128. package/src/stories/Configure.mdx +364 -0
  129. package/src/stories/Header.stories.ts +33 -0
  130. package/src/stories/Header.tsx +56 -0
  131. package/src/stories/Page.stories.ts +32 -0
  132. package/src/stories/Page.tsx +73 -0
  133. package/src/stories/assets/accessibility.png +0 -0
  134. package/src/stories/assets/accessibility.svg +5 -0
  135. package/src/stories/assets/addon-library.png +0 -0
  136. package/src/stories/assets/assets.png +0 -0
  137. package/src/stories/assets/avif-test-image.avif +0 -0
  138. package/src/stories/assets/context.png +0 -0
  139. package/src/stories/assets/discord.svg +15 -0
  140. package/src/stories/assets/docs.png +0 -0
  141. package/src/stories/assets/figma-plugin.png +0 -0
  142. package/src/stories/assets/github.svg +3 -0
  143. package/src/stories/assets/share.png +0 -0
  144. package/src/stories/assets/styling.png +0 -0
  145. package/src/stories/assets/testing.png +0 -0
  146. package/src/stories/assets/theming.png +0 -0
  147. package/src/stories/assets/tutorials.svg +12 -0
  148. package/src/stories/assets/youtube.svg +4 -0
  149. package/src/stories/button.css +30 -0
  150. package/src/stories/header.css +32 -0
  151. package/src/stories/page.css +69 -0
  152. package/src/util/idleTimerUtils.js +36 -0
  153. package/src/util/index.js +3 -1
  154. package/src/components/atoms/icons/icons.stories.js +0 -116
  155. package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +0 -24
  156. package/src/components/molecules/multiple-select-filter/__private__/ActionLinkButton.js +0 -24
  157. package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +0 -85
  158. package/src/components/molecules/multiple-select-filter/__private__/FilterDropdown.js +0 -23
  159. package/src/components/molecules/multiple-select-filter/__private__/FilterableList.js +0 -144
  160. package/src/components/molecules/multiple-select-filter/__private__/FilterableListItem.js +0 -67
  161. package/src/components/molecules/multiple-select-filter/__private__/SearchBox.js +0 -38
  162. package/src/components/molecules/multiple-select-filter/__private__/useKeyboardNavigation.js +0 -84
  163. package/src/components/molecules/multiple-select-filter/__private__/util.js +0 -31
  164. package/src/components/molecules/toast-notification/ToastNotification.stories.js +0 -105
  165. /package/src/components/atoms/add-obligation/{AddObligation.stories.js → AddObligation.oldstories.js} +0 -0
  166. /package/src/components/atoms/amount-callout/{AmountCallout.stories.js → AmountCallout.oldstories.js} +0 -0
  167. /package/src/components/atoms/checkbox-list/{CheckboxList.stories.js → CheckboxList.oldstories.js} +0 -0
  168. /package/src/components/atoms/form-layouts/{FormLayouts.stories.js → FormLayouts.oldstories.js} +0 -0
  169. /package/src/components/atoms/hamburger-button/{HamburgerButton.stories.js → HamburgerButton.oldstories.js} +0 -0
  170. /package/src/components/atoms/heading/{Heading.stories.js → Heading.oldstories.js} +0 -0
  171. /package/src/components/atoms/layouts/examples/box-example/{BoxExample.stories.js → BoxExample.oldstories.js} +0 -0
  172. /package/src/components/atoms/layouts/examples/center-example/{CenterExample.stories.js → CenterExample.oldstories.js} +0 -0
  173. /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.stories.js → ClusterExample.oldstories.js} +0 -0
  174. /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.stories.js → CoverExample.oldstories.js} +0 -0
  175. /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.stories.js → FrameExample.oldstories.js} +0 -0
  176. /package/src/components/atoms/layouts/examples/grid-example/{GridExample.stories.js → GridExample.oldstories.js} +0 -0
  177. /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.stories.js → ImposterExample.oldstories.js} +0 -0
  178. /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.stories.js → MotionExample.oldstories.js} +0 -0
  179. /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.stories.js → ReelExample.oldstories.js} +0 -0
  180. /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.stories.js → SidebarExample.oldstories.js} +0 -0
  181. /package/src/components/atoms/layouts/examples/stack-example/{StackExample.stories.js → StackExample.oldstories.js} +0 -0
  182. /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.stories.js → SwitcherExample.oldstories.js} +0 -0
  183. /package/src/components/atoms/paragraph/{Paragraph.stories.js → Paragraph.oldstories.js} +0 -0
  184. /package/src/components/atoms/processing-fee/{ProcessingFee.stories.js → ProcessingFee.oldstories.js} +0 -0
  185. /package/src/components/atoms/search/{Search.stories.js → Search.oldstories.js} +0 -0
  186. /package/src/components/atoms/solid-divider/{SolidDivider.stories.js → SolidDivider.oldstories.js} +0 -0
  187. /package/src/components/atoms/sortable-table-heading/{SortableTableHeading.stories.js → SortableTableHeading.oldstories.js} +0 -0
  188. /package/src/components/atoms/spinner/{Spinner.stories.js → Spinner.oldstories.js} +0 -0
  189. /package/src/components/atoms/tab/{Tab.stories.js → Tab.oldstories.js} +0 -0
  190. /package/src/components/atoms/text/{Text.stories.js → Text.oldstories.js} +0 -0
  191. /package/src/components/atoms/typeahead-input/{TypeaheadIinput.stories.js → TypeaheadIinput.oldstories.js} +0 -0
  192. /package/src/components/atoms/wallet-name/{WalletName.stories.js → WalletName.oldstories.js} +0 -0
  193. /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.stories.js → AccountAndRoutingModal.oldstories.js} +0 -0
  194. /package/src/components/molecules/editable-list/{EditableList.stories.js → EditableList.oldstories.js} +0 -0
  195. /package/src/components/molecules/email-form/{EmailForm.stories.js → EmailForm.oldstories.js} +0 -0
  196. /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.stories.js → ForgotPasswordForm.oldstories.js} +0 -0
  197. /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.stories.js → HighlightTabRow.oldstories.js} +0 -0
  198. /package/src/components/molecules/obligation/modules/{AmountModule.stories.js → AmountModule.oldstories.js} +0 -0
  199. /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.stories.js → PaymentButtonBar.oldstories.js} +0 -0
  200. /package/src/components/molecules/payment-details/{PaymentDetails.stories.js → PaymentDetails.oldstories.js} +0 -0
  201. /package/src/components/molecules/payment-form-ach/{PaymentFormACH.stories.js → PaymentFormACH.oldstories.js} +0 -0
  202. /package/src/components/molecules/payment-form-card/{PaymentFormCard.stories.js → PaymentFormCard.oldstories.js} +0 -0
  203. /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.stories.js → PeriscopeDashBoardIframe.oldstories.js} +0 -0
  204. /package/src/components/molecules/phone-form/{PhoneForm.stories.js → PhoneForm.oldstories.js} +0 -0
  205. /package/src/components/molecules/popup-menu/{PopupMenu.stories.js → PopupMenu.oldstories.js} +0 -0
  206. /package/src/components/molecules/radio-group/{RadioGroup.stories.js → RadioGroup.oldstories.js} +0 -0
  207. /package/src/components/molecules/radio-section/{RadioSection.stories.js → RadioSection.oldstories.js} +0 -0
  208. /package/src/components/molecules/registration-form/{RegistrationForm.stories.js → RegistrationForm.oldstories.js} +0 -0
  209. /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.stories.js → ResetConfirmationForm.oldstories.js} +0 -0
  210. /package/src/components/molecules/reset-password-form/{ResetPasswordForm.stories.js → ResetPasswordForm.oldstories.js} +0 -0
  211. /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.stories.js → ResetPasswordSuccess.oldstories.js} +0 -0
  212. /package/src/components/molecules/tab-sidebar/{TabSidebar.stories.js → TabSidebar.oldstories.js} +0 -0
  213. /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.stories.js → TermsAndConditions.oldstories.js} +0 -0
  214. /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.stories.js → TermsAndConditionsModal.oldstories.js} +0 -0
  215. /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;
@@ -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;