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