@thecb/components 10.12.2-beta.0 → 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 (223) hide show
  1. package/README.md +4 -0
  2. package/dist/index.cjs.js +1476 -2489
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +8 -6
  5. package/dist/index.esm.js +1476 -2488
  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.js +8 -14
  25. package/src/components/atoms/checkbox/Checkbox.mdx +15 -0
  26. package/src/components/atoms/checkbox/Checkbox.oldstories.js +30 -0
  27. package/src/components/atoms/checkbox/Checkbox.stories.js +148 -29
  28. package/src/components/atoms/country-dropdown/CountryDropdown.mdx +36 -0
  29. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +61 -27
  30. package/src/components/atoms/detail/Detail.js +0 -26
  31. package/src/components/atoms/detail/Detail.mdx +32 -0
  32. package/src/components/atoms/detail/Detail.stories.js +156 -0
  33. package/src/components/atoms/display-box/DisplayBox.mdx +11 -0
  34. package/src/components/atoms/display-box/DisplayBox.stories.js +65 -21
  35. package/src/components/atoms/display-card/DisplayCard.mdx +13 -0
  36. package/src/components/atoms/display-card/DisplayCard.stories.js +163 -22
  37. package/src/components/atoms/dropdown/Dropdown.mdx +65 -0
  38. package/src/components/atoms/dropdown/Dropdown.stories.js +91 -10
  39. package/src/components/atoms/form-layouts/FormInput.mdx +38 -0
  40. package/src/components/atoms/form-layouts/FormInput.stories.js +212 -26
  41. package/src/components/atoms/form-select/FormSelect.mdx +42 -0
  42. package/src/components/atoms/form-select/FormSelect.stories.js +55 -29
  43. package/src/components/atoms/formatted-address/FormattedAddress.mdx +13 -0
  44. package/src/components/atoms/formatted-address/FormattedAddress.stories.js +133 -27
  45. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.mdx +17 -0
  46. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.stories.js +57 -0
  47. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.mdx +40 -0
  48. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.stories.js +74 -0
  49. package/src/components/atoms/icons/Icons.mdx +40 -0
  50. package/src/components/atoms/icons/Icons.stories.js +325 -0
  51. package/src/components/atoms/icons/index.js +1 -5
  52. package/src/components/atoms/labeled-amount/LabeledAmount.mdx +23 -0
  53. package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +110 -34
  54. package/src/components/atoms/line-item/LineItem.mdx +28 -0
  55. package/src/components/atoms/line-item/LineItem.stories.js +89 -22
  56. package/src/components/atoms/link/Link.mdx +19 -0
  57. package/src/components/atoms/link/Link.stories.js +155 -49
  58. package/src/components/atoms/loading/Loading.mdx +13 -0
  59. package/src/components/atoms/loading/Loading.stories.js +22 -0
  60. package/src/components/atoms/loading-line/LoadingLine.js +14 -10
  61. package/src/components/atoms/loading-line/LoadingLine.mdx +15 -0
  62. package/src/components/atoms/loading-line/LoadingLine.stories.js +132 -28
  63. package/src/components/atoms/nav-footer/NavFooter.mdx +15 -0
  64. package/src/components/atoms/nav-footer/NavFooter.stories.js +235 -22
  65. package/src/components/atoms/nav-header/NavHeader.mdx +13 -0
  66. package/src/components/atoms/nav-header/NavHeader.stories.js +122 -21
  67. package/src/components/atoms/nav-tabs/NavTabs.mdx +30 -0
  68. package/src/components/atoms/nav-tabs/NavTabs.stories.js +49 -0
  69. package/src/components/atoms/password-requirements/PasswordRequirements.mdx +39 -0
  70. package/src/components/atoms/password-requirements/PasswordRequirements.stories.js +108 -44
  71. package/src/components/atoms/placeholder/Placeholder.mdx +19 -0
  72. package/src/components/atoms/placeholder/Placeholder.stories.js +164 -36
  73. package/src/components/atoms/searchable-select/SearchableSelect.mdx +44 -0
  74. package/src/components/atoms/searchable-select/SearchableSelect.stories.js +103 -28
  75. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.mdx +36 -0
  76. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +65 -40
  77. package/src/components/atoms/table/Table.mdx +71 -0
  78. package/src/components/atoms/table/Table.oldstories.js +84 -0
  79. package/src/components/atoms/table/Table.stories.js +59 -75
  80. package/src/components/atoms/table/TableRow.js +1 -0
  81. package/src/components/atoms/title/Title.js +0 -23
  82. package/src/components/atoms/title/Title.mdx +26 -0
  83. package/src/components/atoms/title/Title.stories.js +144 -0
  84. package/src/components/atoms/toggle-switch/ToggleSwitch.mdx +17 -0
  85. package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +103 -20
  86. package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +8 -5
  87. package/src/components/atoms/typeahead-input/TypeaheadInput.mdx +13 -0
  88. package/src/components/atoms/typeahead-input/TypeaheadInput.stories.js +63 -0
  89. package/src/components/molecules/address-form/AddressForm.mdx +18 -0
  90. package/src/components/molecules/address-form/AddressForm.stories.js +223 -20
  91. package/src/components/molecules/banner/Banner.mdx +23 -0
  92. package/src/components/molecules/banner/Banner.stories.js +122 -26
  93. package/src/components/molecules/change-password-form/ChangePasswordForm.mdx +15 -0
  94. package/src/components/molecules/change-password-form/ChangePasswordForm.stories.js +203 -19
  95. package/src/components/molecules/collapsible-section/CollapsibleSection.mdx +15 -0
  96. package/src/components/molecules/collapsible-section/CollapsibleSection.stories.js +210 -61
  97. package/src/components/molecules/edit-name-form/EditNameForm.mdx +13 -0
  98. package/src/components/molecules/edit-name-form/EditNameForm.stories.js +117 -0
  99. package/src/components/molecules/idle-modal/IdleModal.js +101 -0
  100. package/src/components/molecules/idle-modal/IdleModal.mdx +17 -0
  101. package/src/components/molecules/idle-modal/IdleModal.stories.js +180 -0
  102. package/src/components/molecules/idle-modal/index.d.ts +16 -0
  103. package/src/components/molecules/idle-modal/index.js +3 -0
  104. package/src/components/molecules/index.js +1 -0
  105. package/src/components/molecules/link-card/LinkCard.mdx +17 -0
  106. package/src/components/molecules/link-card/LinkCard.stories.js +287 -72
  107. package/src/components/molecules/login-form/LoginForm.mdx +16 -0
  108. package/src/components/molecules/login-form/LoginForm.stories.js +117 -21
  109. package/src/components/molecules/modal/Modal.mdx +17 -0
  110. package/src/components/molecules/modal/Modal.stories.js +342 -128
  111. package/src/components/molecules/module/Module.mdx +17 -0
  112. package/src/components/molecules/module/Module.stories.js +267 -25
  113. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.js +309 -77
  114. package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.stories.js → MultipleSelectFilter.oldstories.js} +4 -2
  115. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.styled.js +6 -6
  116. package/src/components/molecules/multiple-select-filter/index.d.ts +2 -2
  117. package/src/components/molecules/obligation/Obligation.mdx +23 -0
  118. package/src/components/molecules/obligation/Obligation.stories.js +460 -0
  119. package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +1 -1
  120. package/src/components/molecules/pagination/Pagination.mdx +15 -0
  121. package/src/components/molecules/pagination/Pagination.stories.js +177 -28
  122. package/src/components/molecules/popover/Popover.mdx +15 -0
  123. package/src/components/molecules/popover/Popover.stories.js +220 -0
  124. package/src/components/molecules/tabs/Tabs.mdx +17 -0
  125. package/src/components/molecules/tabs/Tabs.stories.js +135 -227
  126. package/src/components/molecules/toast-notification/Toast.mdx +15 -0
  127. package/src/components/molecules/toast-notification/Toast.stories.js +183 -0
  128. package/src/hooks/use-outside-click/index.js +5 -4
  129. package/src/stories/Button.stories.ts +53 -0
  130. package/src/stories/Button.tsx +48 -0
  131. package/src/stories/Configure.mdx +364 -0
  132. package/src/stories/Header.stories.ts +33 -0
  133. package/src/stories/Header.tsx +56 -0
  134. package/src/stories/Page.stories.ts +32 -0
  135. package/src/stories/Page.tsx +73 -0
  136. package/src/stories/assets/accessibility.png +0 -0
  137. package/src/stories/assets/accessibility.svg +5 -0
  138. package/src/stories/assets/addon-library.png +0 -0
  139. package/src/stories/assets/assets.png +0 -0
  140. package/src/stories/assets/avif-test-image.avif +0 -0
  141. package/src/stories/assets/context.png +0 -0
  142. package/src/stories/assets/discord.svg +15 -0
  143. package/src/stories/assets/docs.png +0 -0
  144. package/src/stories/assets/figma-plugin.png +0 -0
  145. package/src/stories/assets/github.svg +3 -0
  146. package/src/stories/assets/share.png +0 -0
  147. package/src/stories/assets/styling.png +0 -0
  148. package/src/stories/assets/testing.png +0 -0
  149. package/src/stories/assets/theming.png +0 -0
  150. package/src/stories/assets/tutorials.svg +12 -0
  151. package/src/stories/assets/youtube.svg +4 -0
  152. package/src/stories/button.css +30 -0
  153. package/src/stories/header.css +32 -0
  154. package/src/stories/page.css +69 -0
  155. package/src/util/idleTimerUtils.js +36 -0
  156. package/src/util/index.js +3 -1
  157. package/src/components/atoms/icons/CheckboxCheckmarkIcon.js +0 -45
  158. package/src/components/atoms/icons/PaymentStatusIcon.d.ts +0 -1
  159. package/src/components/atoms/icons/PaymentStatusIcon.js +0 -28
  160. package/src/components/atoms/icons/PersonIcon.d.ts +0 -1
  161. package/src/components/atoms/icons/PersonIcon.js +0 -28
  162. package/src/components/atoms/icons/icons.stories.js +0 -120
  163. package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +0 -24
  164. package/src/components/molecules/multiple-select-filter/__private__/ActionLinkButton.js +0 -27
  165. package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +0 -89
  166. package/src/components/molecules/multiple-select-filter/__private__/FilterDropdown.js +0 -27
  167. package/src/components/molecules/multiple-select-filter/__private__/FilterableList.js +0 -146
  168. package/src/components/molecules/multiple-select-filter/__private__/FilterableListItem.js +0 -79
  169. package/src/components/molecules/multiple-select-filter/__private__/SearchBox.js +0 -41
  170. package/src/components/molecules/multiple-select-filter/__private__/useKeyboardNavigation.js +0 -84
  171. package/src/components/molecules/multiple-select-filter/__private__/util.js +0 -31
  172. package/src/components/molecules/toast-notification/ToastNotification.stories.js +0 -105
  173. /package/src/components/atoms/add-obligation/{AddObligation.stories.js → AddObligation.oldstories.js} +0 -0
  174. /package/src/components/atoms/amount-callout/{AmountCallout.stories.js → AmountCallout.oldstories.js} +0 -0
  175. /package/src/components/atoms/checkbox-list/{CheckboxList.stories.js → CheckboxList.oldstories.js} +0 -0
  176. /package/src/components/atoms/form-layouts/{FormLayouts.stories.js → FormLayouts.oldstories.js} +0 -0
  177. /package/src/components/atoms/hamburger-button/{HamburgerButton.stories.js → HamburgerButton.oldstories.js} +0 -0
  178. /package/src/components/atoms/heading/{Heading.stories.js → Heading.oldstories.js} +0 -0
  179. /package/src/components/atoms/layouts/examples/box-example/{BoxExample.stories.js → BoxExample.oldstories.js} +0 -0
  180. /package/src/components/atoms/layouts/examples/center-example/{CenterExample.stories.js → CenterExample.oldstories.js} +0 -0
  181. /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.stories.js → ClusterExample.oldstories.js} +0 -0
  182. /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.stories.js → CoverExample.oldstories.js} +0 -0
  183. /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.stories.js → FrameExample.oldstories.js} +0 -0
  184. /package/src/components/atoms/layouts/examples/grid-example/{GridExample.stories.js → GridExample.oldstories.js} +0 -0
  185. /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.stories.js → ImposterExample.oldstories.js} +0 -0
  186. /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.stories.js → MotionExample.oldstories.js} +0 -0
  187. /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.stories.js → ReelExample.oldstories.js} +0 -0
  188. /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.stories.js → SidebarExample.oldstories.js} +0 -0
  189. /package/src/components/atoms/layouts/examples/stack-example/{StackExample.stories.js → StackExample.oldstories.js} +0 -0
  190. /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.stories.js → SwitcherExample.oldstories.js} +0 -0
  191. /package/src/components/atoms/paragraph/{Paragraph.stories.js → Paragraph.oldstories.js} +0 -0
  192. /package/src/components/atoms/processing-fee/{ProcessingFee.stories.js → ProcessingFee.oldstories.js} +0 -0
  193. /package/src/components/atoms/search/{Search.stories.js → Search.oldstories.js} +0 -0
  194. /package/src/components/atoms/solid-divider/{SolidDivider.stories.js → SolidDivider.oldstories.js} +0 -0
  195. /package/src/components/atoms/sortable-table-heading/{SortableTableHeading.stories.js → SortableTableHeading.oldstories.js} +0 -0
  196. /package/src/components/atoms/spinner/{Spinner.stories.js → Spinner.oldstories.js} +0 -0
  197. /package/src/components/atoms/tab/{Tab.stories.js → Tab.oldstories.js} +0 -0
  198. /package/src/components/atoms/text/{Text.stories.js → Text.oldstories.js} +0 -0
  199. /package/src/components/atoms/typeahead-input/{TypeaheadIinput.stories.js → TypeaheadIinput.oldstories.js} +0 -0
  200. /package/src/components/atoms/wallet-name/{WalletName.stories.js → WalletName.oldstories.js} +0 -0
  201. /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.stories.js → AccountAndRoutingModal.oldstories.js} +0 -0
  202. /package/src/components/molecules/editable-list/{EditableList.stories.js → EditableList.oldstories.js} +0 -0
  203. /package/src/components/molecules/email-form/{EmailForm.stories.js → EmailForm.oldstories.js} +0 -0
  204. /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.stories.js → ForgotPasswordForm.oldstories.js} +0 -0
  205. /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.stories.js → HighlightTabRow.oldstories.js} +0 -0
  206. /package/src/components/molecules/obligation/modules/{AmountModule.stories.js → AmountModule.oldstories.js} +0 -0
  207. /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.stories.js → PaymentButtonBar.oldstories.js} +0 -0
  208. /package/src/components/molecules/payment-details/{PaymentDetails.stories.js → PaymentDetails.oldstories.js} +0 -0
  209. /package/src/components/molecules/payment-form-ach/{PaymentFormACH.stories.js → PaymentFormACH.oldstories.js} +0 -0
  210. /package/src/components/molecules/payment-form-card/{PaymentFormCard.stories.js → PaymentFormCard.oldstories.js} +0 -0
  211. /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.stories.js → PeriscopeDashBoardIframe.oldstories.js} +0 -0
  212. /package/src/components/molecules/phone-form/{PhoneForm.stories.js → PhoneForm.oldstories.js} +0 -0
  213. /package/src/components/molecules/popup-menu/{PopupMenu.stories.js → PopupMenu.oldstories.js} +0 -0
  214. /package/src/components/molecules/radio-group/{RadioGroup.stories.js → RadioGroup.oldstories.js} +0 -0
  215. /package/src/components/molecules/radio-section/{RadioSection.stories.js → RadioSection.oldstories.js} +0 -0
  216. /package/src/components/molecules/registration-form/{RegistrationForm.stories.js → RegistrationForm.oldstories.js} +0 -0
  217. /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.stories.js → ResetConfirmationForm.oldstories.js} +0 -0
  218. /package/src/components/molecules/reset-password-form/{ResetPasswordForm.stories.js → ResetPasswordForm.oldstories.js} +0 -0
  219. /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.stories.js → ResetPasswordSuccess.oldstories.js} +0 -0
  220. /package/src/components/molecules/tab-sidebar/{TabSidebar.stories.js → TabSidebar.oldstories.js} +0 -0
  221. /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.stories.js → TermsAndConditions.oldstories.js} +0 -0
  222. /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.stories.js → TermsAndConditionsModal.oldstories.js} +0 -0
  223. /package/src/components/molecules/workflow-tile/{WorkflowTile.stories.js → WorkflowTile.oldstories.js} +0 -0
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- import { connect } from "react-redux";
3
- import { boolean } from "@storybook/addon-knobs";
4
-
5
- import EditNameForm from "./EditNameForm";
6
- import page from "../../../../.storybook/page";
7
- import * as EditNameFormState from "./EditNameForm.state";
8
-
9
- const story = page({
10
- title: "Components|Molecules/EditNameForm",
11
- Component: EditNameForm,
12
- reducer: EditNameFormState.reducer,
13
- mapStateToProps: EditNameFormState.mapStateToProps,
14
- mapDispatchToProps: EditNameFormState.mapDispatchToProps
15
- });
16
- export default story;
17
-
18
- const ConnectedForm = connect(
19
- EditNameFormState.mapStateToProps,
20
- EditNameFormState.mapDispatchToProps
21
- )(EditNameForm);
22
- export const editNameForm = () => (
23
- <ConnectedForm showErrors={boolean("showErrors", false, "props")} />
24
- );
@@ -1,27 +0,0 @@
1
- import React, { forwardRef } from "react";
2
- import { ButtonWithAction } from "../../../atoms";
3
- import { FONT_WEIGHT_REGULAR } from "../../../../constants/style_constants";
4
-
5
- const ActionLinkButton = forwardRef(
6
- ({ action, text, dataQa, ariaLabel }, ref) => {
7
- return (
8
- <ButtonWithAction
9
- ref={ref}
10
- action={action}
11
- variant="tertiary"
12
- extraStyles={`
13
- padding: 0.2rem;
14
- margin: 0.5rem;
15
- min-height: auto;
16
- min-width: auto;
17
- `}
18
- textExtraStyles={`font-weight: ${FONT_WEIGHT_REGULAR};`}
19
- text={text}
20
- dataQa={dataQa}
21
- aria-label={ariaLabel}
22
- ></ButtonWithAction>
23
- );
24
- }
25
- );
26
-
27
- export default ActionLinkButton;
@@ -1,89 +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
- extraStyles
23
- },
24
- ref
25
- ) => {
26
- const btnTextFilterDescription = selectedOptions?.length
27
- ? `${filterLabel ? `${filterLabel}: ` : ""}${selectedOptions[0].name}`
28
- : `${filterLabel ? filterLabel : ""}`;
29
- const btnTextItemsDescription =
30
- selectedOptions?.length && selectedOptions?.length > 1
31
- ? `, +${selectedOptions?.length - 1} More`
32
- : "";
33
- return (
34
- <StyledFilterButton
35
- ref={ref}
36
- variant="tertiary"
37
- action={action}
38
- aria-haspopup="listbox"
39
- aria-expanded={opened}
40
- aria-controls={filterDropdownID}
41
- backgroundColor={backgroundColor}
42
- dataQa={`${name}-filter-button`}
43
- extraStyles={extraStyles}
44
- aria-label={`${filterLabel} Filter: ${btnTextFilterDescription} ${btnTextItemsDescription}`}
45
- contentOverride
46
- >
47
- {btnContentOverride ? (
48
- btnContentOverride
49
- ) : (
50
- <Center
51
- as="span"
52
- style={{ display: "flex", flexDirection: "row" }}
53
- intrinsic
54
- >
55
- {hasIcon && <Icon color={contentColor} />}
56
- <Center
57
- as="span"
58
- style={{
59
- display: "flex",
60
- flexDirection: "row",
61
- padding: "0 0.5rem 0 0.25rem"
62
- }}
63
- intrinsic
64
- >
65
- <Text
66
- variant="pS"
67
- color={contentColor}
68
- extraStyles={`
69
- white-space: nowrap;
70
- overflow: hidden;
71
- text-overflow: ellipsis;
72
- ${truncateBtnTextWidth && `max-width:` + truncateBtnTextWidth}
73
- `}
74
- >
75
- {btnTextFilterDescription}
76
- </Text>
77
- <Text color={contentColor} variant="pS">
78
- {btnTextItemsDescription}
79
- </Text>
80
- </Center>
81
- <DropdownIconV2 color={contentColor} />
82
- </Center>
83
- )}
84
- </StyledFilterButton>
85
- );
86
- }
87
- );
88
-
89
- export default FilterButton;
@@ -1,27 +0,0 @@
1
- import React, { forwardRef } from "react";
2
- import { FilterDropdownContainer } from "../MultipleSelectFilter.styled";
3
-
4
- const FilterDropdown = forwardRef(
5
- ({ id, ariaOwns, ariaControls, opened, extraStyles, children }, ref) => {
6
- return (
7
- <>
8
- {opened && (
9
- <FilterDropdownContainer
10
- ref={ref}
11
- id={id}
12
- role="combobox"
13
- aria-expanded={opened}
14
- aria-haspopup="listbox"
15
- aria-owns={ariaOwns}
16
- aria-controls={ariaControls}
17
- extraStyles={extraStyles}
18
- >
19
- {children}
20
- </FilterDropdownContainer>
21
- )}
22
- </>
23
- );
24
- }
25
- );
26
-
27
- export default FilterDropdown;
@@ -1,146 +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
-
13
- const FilterableList = ({
14
- id,
15
- options,
16
- appliedOptions,
17
- selectedOptions,
18
- maxSelections,
19
- name,
20
- setSelectedOptions,
21
- searchTerm,
22
- themeValues
23
- }) => {
24
- const [filteredOptions, setFilteredOptions] = useState([]);
25
- const [filteredAppliedOptions, setFilteredAppliedOptions] = useState([]);
26
-
27
- useEffect(() => {
28
- setFilteredOptions(options);
29
- setFilteredAppliedOptions(appliedOptions);
30
- }, [options, appliedOptions]);
31
-
32
- useEffect(() => {
33
- const filteredOptionItems = filterItemsList(options, searchTerm?.rawValue);
34
- const filteredAppliedItems = filterItemsList(
35
- appliedOptions,
36
- searchTerm?.rawValue
37
- );
38
-
39
- setFilteredOptions(
40
- filteredOptionItems.length ? filteredOptionItems : filteredOptions
41
- );
42
- setFilteredAppliedOptions(filteredAppliedItems);
43
- }, [searchTerm.rawValue]);
44
-
45
- const handleSelectOption = option =>
46
- selectOption(option, selectedOptions, setSelectedOptions);
47
-
48
- const isAppliedOption = option =>
49
- filteredAppliedOptions?.some(
50
- appliedItem => appliedItem?.name === option?.name
51
- );
52
-
53
- const currentFilteredOptions = filteredOptions.filter(
54
- option => !isAppliedOption(option)
55
- );
56
-
57
- const sortedOptions = sortItemsList(currentFilteredOptions);
58
- const sortedAppliedOptions = sortItemsList(filteredAppliedOptions);
59
-
60
- const { itemRefs, focusedIndex, handleKeyDown } = useKeyboardNavigation({
61
- options: sortedOptions,
62
- appliedOptions: sortedAppliedOptions,
63
- selectedOptions,
64
- maxSelections
65
- });
66
-
67
- return (
68
- <Box
69
- id={id}
70
- padding="0"
71
- role="listbox"
72
- aria-label="Filter options container"
73
- onKeyDown={handleKeyDown}
74
- extraStyles={`
75
- overflow-y: auto;
76
- max-height: 250px;
77
- display: flex;
78
- flex-flow: column;
79
- padding-bottom: 0.5rem;
80
- `}
81
- >
82
- {sortedAppliedOptions?.length > 0 && (
83
- <>
84
- {sortedAppliedOptions.map((option, index) => {
85
- const checked = isChecked(option, selectedOptions);
86
- const tabIndex =
87
- index === focusedIndex || (index === 0 && focusedIndex === -1)
88
- ? "0"
89
- : "-1";
90
- return (
91
- <FilterableListItem
92
- key={index}
93
- ref={el => (itemRefs.current[index] = el)}
94
- index={index}
95
- option={option}
96
- checked={checked}
97
- selectOption={handleSelectOption}
98
- tabIndex={tabIndex}
99
- name={name}
100
- themeValues={themeValues}
101
- showDivider={
102
- sortedOptions.length > 0 &&
103
- index === sortedAppliedOptions.length - 1
104
- }
105
- ></FilterableListItem>
106
- );
107
- })}
108
- </>
109
- )}
110
- <>
111
- {sortedOptions.map((option, index) => {
112
- const checked = isChecked(option, selectedOptions);
113
- const isDisabled =
114
- isMaxSelectionReached(maxSelections, selectedOptions) && !checked;
115
- const indexOffset = sortedAppliedOptions?.length
116
- ? sortedAppliedOptions?.length
117
- : 0;
118
- const currentIndex = index === 0 ? indexOffset : index + indexOffset;
119
- const tabIndex =
120
- currentIndex === focusedIndex ||
121
- (indexOffset === 0 &&
122
- currentIndex === indexOffset &&
123
- focusedIndex === -1)
124
- ? "0"
125
- : "-1";
126
- return (
127
- <FilterableListItem
128
- key={currentIndex}
129
- ref={el => (itemRefs.current[currentIndex] = el)}
130
- index={currentIndex}
131
- option={option}
132
- checked={checked}
133
- selectOption={isDisabled ? noop : handleSelectOption}
134
- disabled={isDisabled}
135
- tabIndex={tabIndex}
136
- name={name}
137
- themeValues={themeValues}
138
- ></FilterableListItem>
139
- );
140
- })}
141
- </>
142
- </Box>
143
- );
144
- };
145
-
146
- export default React.memo(FilterableList);
@@ -1,79 +0,0 @@
1
- import React, { forwardRef } from "react";
2
- import Checkbox from "../../../atoms/checkbox";
3
- import { GHOST_GREY } from "../../../../constants/colors";
4
- import CheckboxCheckmarkIcon from "../../../atoms/icons/CheckboxCheckmarkIcon";
5
-
6
- const FilterableListItem = forwardRef(
7
- (
8
- {
9
- index,
10
- option,
11
- checked,
12
- selectOption,
13
- disabled,
14
- tabIndex,
15
- name,
16
- showDivider,
17
- extraStyles,
18
- themeValues
19
- },
20
- ref
21
- ) => {
22
- const dividerStyles = `
23
- ::after {
24
- content: '';
25
- position: absolute;
26
- width: 100%;
27
- display: block;
28
- height: 1px;
29
- background-color: ${GHOST_GREY};
30
- bottom: -0.5rem;
31
- left: 0;
32
- }`;
33
- return (
34
- <Checkbox
35
- key={index}
36
- ref={ref}
37
- title={option.name}
38
- name={option.name}
39
- role="option"
40
- aria-selected={checked}
41
- tabIndex={tabIndex}
42
- dataQa={`${name}-option-${index}`}
43
- checked={checked}
44
- onChange={() => selectOption(option)}
45
- textExtraStyles={`font-size: 0.875rem; margin: 0;`}
46
- disabled={disabled}
47
- extraStyles={`
48
- padding: 0.375rem 0.625rem;
49
- margin: 0;
50
- :hover,
51
- :active,
52
- :focus {
53
- background-color: ${themeValues.primaryColor};
54
- outline-offset: -3px;
55
- }
56
- ${showDivider && dividerStyles}
57
- ${extraStyles}
58
- `}
59
- checkboxMargin={showDivider ? "0 0 1rem" : "0"}
60
- hasIconOverride={true}
61
- icon={CheckboxCheckmarkIcon}
62
- checkboxExtraStyles={`
63
- display: flex;
64
- justify-content: center;
65
- align-items: center;
66
- height: 20px;
67
- width: 20px;
68
- ${
69
- checked && !disabled
70
- ? `background: ` + themeValues.secondaryColor + `;`
71
- : ""
72
- }
73
- `}
74
- />
75
- );
76
- }
77
- );
78
-
79
- export default FilterableListItem;
@@ -1,41 +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
- :focus {
32
- outline-offset: -3px;
33
- }
34
- `}
35
- />
36
- )}
37
- </Box>
38
- );
39
- };
40
-
41
- 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;