@nypl/design-system-react-components 0.25.8 → 0.25.9

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 (250) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +1 -1
  3. package/dist/components/Button/Button.d.ts +6 -6
  4. package/dist/components/Button/ButtonTypes.d.ts +0 -1
  5. package/dist/components/Card/Card.d.ts +6 -4
  6. package/dist/components/Checkbox/Checkbox.d.ts +3 -2
  7. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +3 -2
  8. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +8 -2
  9. package/dist/components/DatePicker/DatePicker.d.ts +3 -2
  10. package/dist/components/Form/Form.d.ts +2 -2
  11. package/dist/components/Heading/Heading.d.ts +7 -3
  12. package/dist/components/Heading/HeadingTypes.d.ts +6 -6
  13. package/dist/components/HelperErrorText/HelperErrorText.d.ts +5 -2
  14. package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -2
  15. package/dist/components/Icons/Icon.d.ts +4 -4
  16. package/dist/components/Icons/IconSvgs.d.ts +0 -21
  17. package/dist/components/Icons/IconTypes.d.ts +0 -23
  18. package/dist/components/Image/Image.d.ts +11 -3
  19. package/dist/components/Logo/Logo.d.ts +28 -0
  20. package/dist/components/Logo/LogoSvgs.d.ts +18 -0
  21. package/dist/components/Logo/LogoTypes.d.ts +30 -0
  22. package/dist/components/Modal/Modal.d.ts +0 -4
  23. package/dist/components/Notification/Notification.d.ts +2 -2
  24. package/dist/components/Placeholder/Placeholder.d.ts +3 -5
  25. package/dist/components/Radio/Radio.d.ts +6 -5
  26. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -2
  27. package/dist/components/SearchBar/SearchBar.d.ts +10 -2
  28. package/dist/components/Select/Select.d.ts +3 -2
  29. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +8 -4
  30. package/dist/components/Slider/Slider.d.ts +3 -2
  31. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -1
  32. package/dist/components/StructuredContent/StructuredContent.d.ts +41 -0
  33. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +5 -0
  34. package/dist/components/Table/Table.d.ts +23 -0
  35. package/dist/components/Template/Template.d.ts +8 -3
  36. package/dist/components/Text/Text.d.ts +2 -2
  37. package/dist/components/TextInput/TextInput.d.ts +4 -3
  38. package/dist/components/Toggle/Toggle.d.ts +3 -2
  39. package/dist/components/VideoPlayer/VideoPlayer.d.ts +14 -5
  40. package/dist/design-system-react-components.cjs.development.js +5630 -5692
  41. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  42. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  43. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  44. package/dist/design-system-react-components.esm.js +4304 -4362
  45. package/dist/design-system-react-components.esm.js.map +1 -1
  46. package/dist/index.d.ts +6 -4
  47. package/dist/styles.css +2 -2
  48. package/dist/theme/components/button.d.ts +0 -12
  49. package/dist/theme/components/card.d.ts +14 -2
  50. package/dist/theme/components/customTable.d.ts +47 -0
  51. package/dist/theme/components/fieldset.d.ts +2 -2
  52. package/dist/theme/components/global.d.ts +1 -1
  53. package/dist/theme/components/heading.d.ts +4 -0
  54. package/dist/theme/components/label.d.ts +1 -1
  55. package/dist/theme/components/link.d.ts +14 -1
  56. package/dist/theme/components/list.d.ts +0 -2
  57. package/dist/theme/components/logo.d.ts +4 -0
  58. package/dist/theme/components/searchBar.d.ts +7 -13
  59. package/dist/theme/components/select.d.ts +1 -0
  60. package/dist/theme/components/structuredContent.d.ts +33 -0
  61. package/dist/theme/components/template.d.ts +10 -10
  62. package/dist/theme/components/textInput.d.ts +2 -0
  63. package/dist/theme/components/toggle.d.ts +8 -5
  64. package/dist/utils/utils.d.ts +10 -0
  65. package/package.json +1 -2
  66. package/src/__tests__/utils/utils.test.ts +23 -1
  67. package/src/components/Accordion/Accordion.stories.mdx +14 -12
  68. package/src/components/Autosuggest/Autosuggest.stories.mdx +2 -1
  69. package/src/components/Autosuggest/Autosuggest.stories.tsx +24 -48
  70. package/src/components/Autosuggest/_Autosuggest.scss +2 -6
  71. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +30 -11
  72. package/src/components/Button/Button.stories.mdx +93 -48
  73. package/src/components/Button/Button.test.tsx +0 -12
  74. package/src/components/Button/Button.tsx +7 -7
  75. package/src/components/Button/ButtonTypes.tsx +0 -1
  76. package/src/components/Button/__snapshots__/Button.test.tsx.snap +0 -12
  77. package/src/components/Card/Card.stories.mdx +186 -71
  78. package/src/components/Card/Card.test.tsx +45 -22
  79. package/src/components/Card/Card.tsx +17 -5
  80. package/src/components/Card/__snapshots__/Card.test.tsx.snap +8 -2
  81. package/src/components/Chakra/Box.stories.mdx +3 -3
  82. package/src/components/Chakra/Center.stories.mdx +5 -5
  83. package/src/components/Chakra/Grid.stories.mdx +3 -3
  84. package/src/components/Chakra/Stack.stories.mdx +2 -2
  85. package/src/components/Checkbox/Checkbox.stories.mdx +37 -15
  86. package/src/components/Checkbox/Checkbox.tsx +13 -8
  87. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +48 -16
  88. package/src/components/CheckboxGroup/CheckboxGroup.tsx +14 -10
  89. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +6 -3
  90. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +151 -0
  91. package/src/components/ComponentWrapper/ComponentWrapper.tsx +36 -23
  92. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +85 -0
  93. package/src/components/DatePicker/DatePicker.stories.mdx +63 -18
  94. package/src/components/DatePicker/DatePicker.tsx +10 -6
  95. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +36 -18
  96. package/src/components/Fieldset/Fieldset.stories.mdx +19 -8
  97. package/src/components/Form/Form.stories.mdx +49 -41
  98. package/src/components/Form/Form.tsx +5 -4
  99. package/src/components/Grid/SimpleGrid.stories.mdx +26 -26
  100. package/src/components/Heading/Heading.stories.mdx +59 -23
  101. package/src/components/Heading/Heading.test.tsx +82 -18
  102. package/src/components/Heading/Heading.tsx +31 -31
  103. package/src/components/Heading/HeadingTypes.tsx +6 -6
  104. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +71 -0
  105. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +55 -27
  106. package/src/components/HelperErrorText/HelperErrorText.test.tsx +42 -15
  107. package/src/components/HelperErrorText/HelperErrorText.tsx +24 -24
  108. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +41 -4
  109. package/src/components/Hero/Hero.stories.mdx +72 -53
  110. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +9 -8
  111. package/src/components/HorizontalRule/HorizontalRule.tsx +2 -4
  112. package/src/components/Icons/Icon.stories.mdx +77 -76
  113. package/src/components/Icons/Icon.tsx +4 -5
  114. package/src/components/Icons/IconSvgs.tsx +0 -42
  115. package/src/components/Icons/IconTypes.tsx +0 -24
  116. package/src/components/Image/Image.stories.mdx +66 -18
  117. package/src/components/Image/Image.tsx +21 -10
  118. package/src/components/Label/Label.stories.mdx +20 -19
  119. package/src/components/Link/Link.stories.mdx +102 -51
  120. package/src/components/Link/Link.test.tsx +38 -8
  121. package/src/components/Link/Link.tsx +19 -12
  122. package/src/components/Link/__snapshots__/Link.test.tsx.snap +60 -0
  123. package/src/components/List/List.stories.mdx +36 -24
  124. package/src/components/Logo/Logo.stories.mdx +220 -0
  125. package/src/components/Logo/Logo.test.tsx +98 -0
  126. package/src/components/Logo/Logo.tsx +97 -0
  127. package/src/components/Logo/LogoSvgs.tsx +34 -0
  128. package/src/components/Logo/LogoTypes.tsx +32 -0
  129. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +71 -0
  130. package/src/components/Modal/Modal.stories.mdx +20 -5
  131. package/src/components/Modal/Modal.tsx +2 -8
  132. package/src/components/Notification/Notification.stories.mdx +61 -38
  133. package/src/components/Notification/Notification.tsx +9 -4
  134. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +4 -0
  135. package/src/components/Pagination/Pagination.stories.mdx +17 -6
  136. package/src/components/Pagination/Pagination.tsx +1 -1
  137. package/src/components/Placeholder/Placeholder.tsx +7 -14
  138. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +72 -43
  139. package/src/components/Radio/Radio.stories.mdx +39 -19
  140. package/src/components/Radio/Radio.tsx +13 -9
  141. package/src/components/RadioGroup/RadioGroup.stories.mdx +50 -16
  142. package/src/components/RadioGroup/RadioGroup.tsx +15 -11
  143. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +6 -3
  144. package/src/components/SearchBar/SearchBar.Test.tsx +58 -10
  145. package/src/components/SearchBar/SearchBar.stories.mdx +109 -30
  146. package/src/components/SearchBar/SearchBar.tsx +53 -32
  147. package/src/components/Select/Select.stories.mdx +48 -14
  148. package/src/components/Select/Select.tsx +16 -10
  149. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +50 -16
  150. package/src/components/SkeletonLoader/SkeletonLoader.tsx +8 -4
  151. package/src/components/Slider/Slider.stories.mdx +72 -22
  152. package/src/components/Slider/Slider.tsx +15 -10
  153. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +60 -30
  154. package/src/components/StatusBadge/StatusBadge.stories.mdx +33 -18
  155. package/src/components/StatusBadge/StatusBadge.tsx +2 -1
  156. package/src/components/StructuredContent/StructuredContent.stories.mdx +427 -0
  157. package/src/components/StructuredContent/StructuredContent.test.tsx +376 -0
  158. package/src/components/StructuredContent/StructuredContent.tsx +153 -0
  159. package/src/components/StructuredContent/StructuredContentTypes.tsx +5 -0
  160. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +283 -0
  161. package/src/components/StyleGuide/Bidirectionality.stories.mdx +32 -83
  162. package/src/components/StyleGuide/Breakpoints.stories.mdx +1 -11
  163. package/src/components/StyleGuide/Buttons.stories.mdx +3 -18
  164. package/src/components/StyleGuide/ColorCard.tsx +1 -2
  165. package/src/components/StyleGuide/Colors.stories.mdx +3 -11
  166. package/src/components/StyleGuide/DesignTokens.stories.mdx +3 -8
  167. package/src/components/StyleGuide/Forms.stories.mdx +2 -10
  168. package/src/components/StyleGuide/Iconography.stories.mdx +8 -34
  169. package/src/components/StyleGuide/Spacing.stories.mdx +3 -14
  170. package/src/components/StyleGuide/Typography.stories.mdx +64 -76
  171. package/src/components/Table/Table.stories.mdx +66 -0
  172. package/src/components/Table/Table.test.tsx +60 -0
  173. package/src/components/Table/Table.tsx +116 -0
  174. package/src/components/Tabs/Tabs.stories.mdx +19 -13
  175. package/src/components/Tabs/Tabs.test.tsx +1 -1
  176. package/src/components/Template/Template.stories.mdx +56 -47
  177. package/src/components/Template/Template.test.tsx +65 -5
  178. package/src/components/Template/Template.tsx +35 -5
  179. package/src/components/Template/__snapshots__/Template.test.tsx.snap +76 -0
  180. package/src/components/Text/Text.stories.mdx +33 -11
  181. package/src/components/Text/Text.tsx +2 -2
  182. package/src/components/TextInput/TextInput.stories.mdx +84 -17
  183. package/src/components/TextInput/TextInput.test.tsx +96 -0
  184. package/src/components/TextInput/TextInput.tsx +12 -8
  185. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +240 -0
  186. package/src/components/Toggle/Toggle.stories.mdx +33 -9
  187. package/src/components/Toggle/Toggle.tsx +14 -9
  188. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +64 -14
  189. package/src/components/VideoPlayer/VideoPlayer.tsx +17 -7
  190. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +12 -6
  191. package/src/docs/Chakra.stories.mdx +5 -8
  192. package/src/docs/Intro.stories.mdx +2 -2
  193. package/src/index.ts +5 -4
  194. package/src/styles/base/_03-base.scss +1 -1
  195. package/src/styles/base/_place-holder.scss +7 -7
  196. package/src/styles.scss +1 -5
  197. package/src/theme/components/breadcrumb.ts +3 -3
  198. package/src/theme/components/button.ts +5 -12
  199. package/src/theme/components/card.ts +5 -2
  200. package/src/theme/components/checkbox.ts +1 -1
  201. package/src/theme/components/customTable.ts +50 -0
  202. package/src/theme/components/datePicker.ts +1 -1
  203. package/src/theme/components/global.ts +6 -6
  204. package/src/theme/components/heading.ts +13 -11
  205. package/src/theme/components/helperErrorText.ts +1 -1
  206. package/src/theme/components/image.ts +1 -1
  207. package/src/theme/components/link.ts +17 -5
  208. package/src/theme/components/list.ts +1 -3
  209. package/src/theme/components/logo.ts +54 -0
  210. package/src/theme/components/notification.ts +1 -1
  211. package/src/theme/components/searchBar.ts +7 -13
  212. package/src/theme/components/select.ts +1 -0
  213. package/src/theme/components/statusBadge.ts +1 -1
  214. package/src/theme/components/structuredContent.ts +54 -0
  215. package/src/theme/components/template.ts +10 -10
  216. package/src/theme/components/text.ts +6 -6
  217. package/src/theme/components/textInput.ts +1 -0
  218. package/src/theme/components/toggle.ts +9 -5
  219. package/src/theme/components/videoPlayer.ts +0 -2
  220. package/src/theme/foundations/global.ts +2 -2
  221. package/src/theme/foundations/typography.ts +84 -12
  222. package/src/theme/index.ts +6 -0
  223. package/src/utils/componentCategories.ts +1 -1
  224. package/src/utils/utils.ts +17 -0
  225. package/dist/__tests__/utils/bem.test.d.ts +0 -1
  226. package/dist/components/CardEdition/CardEdition.d.ts +0 -21
  227. package/dist/components/CardEdition/CardEdition.stories.d.ts +0 -27
  228. package/dist/components/Input/Input.d.ts +0 -36
  229. package/dist/components/Input/Input.stories.d.ts +0 -29
  230. package/dist/components/Input/InputTypes.d.ts +0 -6
  231. package/dist/components/StyleGuide/UIDocCard.d.ts +0 -11
  232. package/dist/helpers/CSSVariablesHelper.d.ts +0 -3
  233. package/dist/helpers/getCSSVariable.d.ts +0 -1
  234. package/dist/interfaces.d.ts +0 -3
  235. package/dist/utils/bem.d.ts +0 -1
  236. package/src/__tests__/utils/bem.test.ts +0 -37
  237. package/src/components/CardEdition/CardEdition.stories.tsx +0 -122
  238. package/src/components/CardEdition/CardEdition.test.tsx +0 -395
  239. package/src/components/CardEdition/CardEdition.tsx +0 -60
  240. package/src/components/CardEdition/_CardEdition.scss +0 -137
  241. package/src/components/Input/Input.stories.tsx +0 -133
  242. package/src/components/Input/Input.test.tsx +0 -266
  243. package/src/components/Input/Input.tsx +0 -81
  244. package/src/components/Input/InputTypes.tsx +0 -8
  245. package/src/components/Input/_Input.scss +0 -78
  246. package/src/components/StyleGuide/UIDocCard.tsx +0 -36
  247. package/src/helpers/CSSVariablesHelper.tsx +0 -34
  248. package/src/helpers/getCSSVariable.tsx +0 -5
  249. package/src/interfaces.ts +0 -3
  250. package/src/utils/bem.ts +0 -44
@@ -28,14 +28,14 @@ const textInputProps = {
28
28
  name: "textInputName",
29
29
  placeholder: "Item Search",
30
30
  };
31
- const helperErrorText = "Search for items in Animal Crossing New Horizons";
31
+ const helperText = "Search for items in Animal Crossing New Horizons";
32
32
  const invalidText = "Could not find the item :(";
33
33
 
34
34
  describe("SearchBar Accessibility", () => {
35
35
  it("passes axe accessibility test", async () => {
36
36
  const { container } = render(
37
37
  <SearchBar
38
- helperErrorText={helperErrorText}
38
+ helperText={helperText}
39
39
  id="id"
40
40
  invalidText={invalidText}
41
41
  labelText="Searchbar"
@@ -55,7 +55,7 @@ describe("SearchBar", () => {
55
55
  it("renders the basic form", () => {
56
56
  render(
57
57
  <SearchBar
58
- helperErrorText={helperErrorText}
58
+ helperText={helperText}
59
59
  id="id"
60
60
  labelText="searchbar"
61
61
  onSubmit={searchBarSubmit}
@@ -74,7 +74,7 @@ describe("SearchBar", () => {
74
74
  it("renders an optional Select component", () => {
75
75
  render(
76
76
  <SearchBar
77
- helperErrorText={helperErrorText}
77
+ helperText={helperText}
78
78
  id="id"
79
79
  labelText="searchbar"
80
80
  onSubmit={searchBarSubmit}
@@ -89,7 +89,7 @@ describe("SearchBar", () => {
89
89
  it("renders the invalid text in the invalid state", () => {
90
90
  render(
91
91
  <SearchBar
92
- helperErrorText={helperErrorText}
92
+ helperText={helperText}
93
93
  id="id"
94
94
  invalidText={invalidText}
95
95
  isInvalid
@@ -100,13 +100,13 @@ describe("SearchBar", () => {
100
100
  />
101
101
  );
102
102
  expect(screen.getByText(invalidText)).toBeInTheDocument();
103
- expect(screen.queryByText(helperErrorText)).not.toBeInTheDocument();
103
+ expect(screen.queryByText(helperText)).not.toBeInTheDocument();
104
104
  });
105
105
 
106
106
  it("does not render the default invalid text from the Select or TextInput components", () => {
107
107
  render(
108
108
  <SearchBar
109
- helperErrorText={helperErrorText}
109
+ helperText={helperText}
110
110
  id="id"
111
111
  invalidText={invalidText}
112
112
  isInvalid
@@ -124,7 +124,7 @@ describe("SearchBar", () => {
124
124
  it("calls the callback function on submit ", () => {
125
125
  render(
126
126
  <SearchBar
127
- helperErrorText={helperErrorText}
127
+ helperText={helperText}
128
128
  id="id"
129
129
  labelText="searchBar"
130
130
  onSubmit={searchBarSubmit}
@@ -174,7 +174,7 @@ describe("SearchBar", () => {
174
174
  const basic = renderer
175
175
  .create(
176
176
  <SearchBar
177
- helperErrorText={helperErrorText}
177
+ helperText={helperText}
178
178
  id="basic"
179
179
  labelText="searchbar"
180
180
  onSubmit={jest.fn()}
@@ -185,7 +185,7 @@ describe("SearchBar", () => {
185
185
  const withSelect = renderer
186
186
  .create(
187
187
  <SearchBar
188
- helperErrorText={helperErrorText}
188
+ helperText={helperText}
189
189
  id="withSelect"
190
190
  labelText="searchbar"
191
191
  onSubmit={jest.fn()}
@@ -238,6 +238,50 @@ describe("SearchBar", () => {
238
238
  />
239
239
  )
240
240
  .toJSON();
241
+ const noBrandButtonType = renderer
242
+ .create(
243
+ <SearchBar
244
+ id="noBrandButtonType"
245
+ isDisabled
246
+ isRequired
247
+ labelText="searchbar"
248
+ noBrandButtonType={true}
249
+ onSubmit={jest.fn()}
250
+ textInputProps={textInputProps}
251
+ />
252
+ )
253
+ .toJSON();
254
+ const withHeading = renderer
255
+ .create(
256
+ <SearchBar
257
+ id="withHeading"
258
+ labelText="searchbar"
259
+ onSubmit={jest.fn()}
260
+ headingText="A Heading"
261
+ />
262
+ )
263
+ .toJSON();
264
+ const withDescription = renderer
265
+ .create(
266
+ <SearchBar
267
+ id="withDescription"
268
+ labelText="searchbar"
269
+ onSubmit={jest.fn()}
270
+ descriptionText="A description"
271
+ />
272
+ )
273
+ .toJSON();
274
+ const withHeadingAndDescription = renderer
275
+ .create(
276
+ <SearchBar
277
+ id="withHeadingAndDescription"
278
+ labelText="searchbar"
279
+ onSubmit={jest.fn()}
280
+ headingText="A Heading"
281
+ descriptionText="A description"
282
+ />
283
+ )
284
+ .toJSON();
241
285
 
242
286
  expect(basic).toMatchSnapshot();
243
287
  expect(withSelect).toMatchSnapshot();
@@ -245,5 +289,9 @@ describe("SearchBar", () => {
245
289
  expect(invalidState).toMatchSnapshot();
246
290
  expect(disabledState).toMatchSnapshot();
247
291
  expect(requiredState).toMatchSnapshot();
292
+ expect(noBrandButtonType).toMatchSnapshot();
293
+ expect(withHeading).toMatchSnapshot();
294
+ expect(withDescription).toMatchSnapshot();
295
+ expect(withHeadingAndDescription).toMatchSnapshot();
248
296
  });
249
297
  });
@@ -1,10 +1,10 @@
1
1
  import {
2
- Meta,
3
- Story,
4
2
  ArgsTable,
5
3
  Canvas,
6
4
  Description,
7
- } from "@storybook/addon-docs/blocks";
5
+ Meta,
6
+ Story,
7
+ } from "@storybook/addon-docs";
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
10
  import SearchBar from "./SearchBar";
@@ -24,16 +24,34 @@ import DSProvider from "../../theme/provider";
24
24
  jest: ["SearchBar.test.tsx"],
25
25
  }}
26
26
  argTypes={{
27
- action: { table: { disable: true } },
28
- ariaLabel: { table: { disable: true } },
29
- buttonOnClick: { table: { disable: true } },
30
- className: { table: { disable: true } },
31
- id: { table: { disable: true } },
32
- method: { table: { disable: true } },
33
- onSubmit: { table: { disable: true } },
34
- selectProps: { table: { disable: true } },
35
- textInputProps: { table: { disable: true } },
36
- textInputElement: { table: { disable: true } },
27
+ action: { control: false },
28
+ ariaLabel: { control: false },
29
+ buttonOnClick: {
30
+ control: false,
31
+ table: { defaultValue: { summary: "null" } },
32
+ },
33
+ className: { control: false },
34
+ id: { control: false },
35
+ isDisabled: {
36
+ table: { defaultValue: { summary: false } },
37
+ },
38
+ isInvalid: {
39
+ table: { defaultValue: { summary: false } },
40
+ },
41
+ isRequired: {
42
+ table: { defaultValue: { summary: false } },
43
+ },
44
+ method: { control: false },
45
+ onSubmit: { control: false },
46
+ selectProps: { control: false },
47
+ showHelperText: {
48
+ description: "Only used for Storybook",
49
+ },
50
+ showSelect: {
51
+ description: "Only used for Storybook",
52
+ },
53
+ textInputElement: { control: false },
54
+ textInputProps: { control: false },
37
55
  }}
38
56
  />
39
57
 
@@ -42,7 +60,7 @@ import DSProvider from "../../theme/provider";
42
60
  | Component Version | DS Version |
43
61
  | ----------------- | ---------- |
44
62
  | Added | `0.0.4` |
45
- | Latest | `0.25.6` |
63
+ | Latest | `0.25.9` |
46
64
 
47
65
  <Description of={SearchBar} />
48
66
 
@@ -73,20 +91,30 @@ export const optionsGroup = [
73
91
 
74
92
  <Canvas withToolbar>
75
93
  <Story
76
- name="Basic"
94
+ name="SearchBar with Controls"
77
95
  args={{
78
- helperErrorText: "Search for items in Animal Crossing New Horizons",
96
+ action: undefined,
97
+ buttonOnClick: undefined,
98
+ className: undefined,
99
+ helperText: "Search for items in Animal Crossing New Horizons",
100
+ id: "searchBar-id",
79
101
  invalidText: "Could not find the item :(",
80
102
  isDisabled: false,
81
103
  isInvalid: false,
82
104
  isRequired: false,
105
+ labelText: "SearchBar Label",
106
+ method: undefined,
107
+ noBrandButtonType: false,
108
+ onSubmit: () => {},
109
+ selectProps: undefined,
83
110
  showHelperText: true,
84
111
  showSelect: true,
112
+ textInputElement: undefined,
113
+ textInputProps: undefined,
85
114
  }}
86
115
  >
87
116
  {(args) => (
88
117
  <SearchBar
89
- onSubmit={() => {}}
90
118
  {...args}
91
119
  selectProps={
92
120
  args.showSelect && {
@@ -100,13 +128,13 @@ export const optionsGroup = [
100
128
  name: "textInputName",
101
129
  placeholder: "Item Search",
102
130
  }}
103
- helperErrorText={args.showHelperText && args.helperErrorText}
131
+ helperText={args.showHelperText && args.helperText}
104
132
  />
105
133
  )}
106
134
  </Story>
107
135
  </Canvas>
108
136
 
109
- <ArgsTable story="Basic" />
137
+ <ArgsTable story="SearchBar with Controls" />
110
138
 
111
139
  ## Component Props
112
140
 
@@ -181,23 +209,54 @@ A `Button` component will automatically be rendered for the `SearchBar`
181
209
  component. If you want to pass a callback function to the `Button`, use the
182
210
  `buttonOnClick` prop.
183
211
 
212
+ It's also possible to render the `ButtonType.NoBrand` variant style when the
213
+ `noBrandButtonType` prop is set to `true`. The `ButtonType.Primary` variant
214
+ style is used by default.
215
+
184
216
  ### HelperErrorText Component
185
217
 
186
- To render the `HelperErrorText` component, pass a string value to the
187
- `helperErrorText` prop. For the invalid state when `isInvalid` is true, pass the
188
- error string in the `invalidText` prop.
218
+ To render the `HelperErrorText` component, pass a string or HTML to the
219
+ `helperText` prop. For the invalid state when `isInvalid` is true, pass the
220
+ error string or HTML in the `invalidText` prop.
189
221
 
190
222
  ```
191
- const helperErrorText = "";
223
+ const helperText = "";
192
224
 
193
225
  // ...
194
226
  <SearchBar
195
227
  onSubmit={() => {}}
196
- helperErrorText="Search for items in Animal Crossing New Horizons"
228
+ helperText="Search for items in <b>Animal Crossing New Horizons</b>."
197
229
  // ...
198
230
  />
199
231
  ```
200
232
 
233
+ <Canvas>
234
+ <DSProvider>
235
+ <SearchBar
236
+ descriptionText="The helper text below contains HTML in a string."
237
+ helperText="Search for items in <b>Animal Crossing New Horizons</b>."
238
+ onSubmit={() => {}}
239
+ textInputProps={{
240
+ labelText: "Item Search",
241
+ name: "textInputName",
242
+ placeholder: "Item Search",
243
+ }}
244
+ />
245
+ <br />
246
+ <SearchBar
247
+ descriptionText="The invalid text below contains HTML in a string."
248
+ isInvalid
249
+ invalidText="Could <b>not</b> find the item <b>:(</b>"
250
+ onSubmit={() => {}}
251
+ textInputProps={{
252
+ labelText: "Item Search",
253
+ name: "textInputName",
254
+ placeholder: "Item Search",
255
+ }}
256
+ />
257
+ </DSProvider>
258
+ </Canvas>
259
+
201
260
  ## Search Autocomplete
202
261
 
203
262
  While the Design System does not implement an `Autosuggest` or `Autocomplete`
@@ -225,7 +284,7 @@ precedence.
225
284
  <SearchBar
226
285
  onSubmit={() => {}}
227
286
  textInputElement={stories.SearchBarExample()}
228
- helperErrorText="Select your home library. Start by typing the name of the library. Try 'ba'."
287
+ helperText="Select your home library. Start by typing the name of the library. Try 'ba'."
229
288
  {...args}
230
289
  />
231
290
  </div>
@@ -253,7 +312,7 @@ handle the error state yourself.
253
312
  name: "textInputName",
254
313
  placeholder: "Item Search",
255
314
  }}
256
- helperErrorText="This is the helper text!"
315
+ helperText="This is the helper text!"
257
316
  invalidText="Could not find the item :("
258
317
  isInvalid
259
318
  />
@@ -269,18 +328,38 @@ handle the disabled state yourself.
269
328
  <Canvas>
270
329
  <DSProvider>
271
330
  <SearchBar
272
- obSubmit={() => {}}
331
+ onSubmit={() => {}}
273
332
  textInputProps={{
274
333
  labelText: "Item Search",
275
334
  name: "textInputName",
276
335
  placeholder: "Item Search",
277
336
  }}
278
- helperErrorText="Reason for disabled state."
337
+ helperText="Reason for disabled state."
279
338
  isDisabled
280
339
  />
281
340
  </DSProvider>
282
341
  </Canvas>
283
342
 
343
+ ### With Heading and Description Text
344
+
345
+ Use the `descriptionText` and `headingText` props to render a heading and
346
+ description above the main `SearchBar` form component.
347
+
348
+ <Canvas>
349
+ <DSProvider>
350
+ <SearchBar
351
+ descriptionText="This is the description for this `SearchBar` instance."
352
+ headingText="Heading for this `SearchBar`"
353
+ onSubmit={() => {}}
354
+ textInputProps={{
355
+ labelText: "Item Search",
356
+ name: "textInputName",
357
+ placeholder: "Item Search",
358
+ }}
359
+ />
360
+ </DSProvider>
361
+ </Canvas>
362
+
284
363
  ### TextInput and onSubmit Values
285
364
 
286
365
  _NOTE: open the browser console to see the values logged in the example below._
@@ -328,7 +407,7 @@ function SearchBarValueExample() {
328
407
  onChange: textInputOnChange,
329
408
  placeholder: "Item Search",
330
409
  }}
331
- helperErrorText="Search for an item"
410
+ helperText="Search for an item"
332
411
  invalidText="Could not find the item :("
333
412
  />
334
413
  );
@@ -358,7 +437,7 @@ export function SearchBarValueExample() {
358
437
  onChange: textInputOnChange,
359
438
  placeholder: "Item Search",
360
439
  }}
361
- helperErrorText="Search for an item"
440
+ helperText="Search for an item"
362
441
  invalidText="Could not find the item :("
363
442
  />
364
443
  );
@@ -1,16 +1,17 @@
1
- import * as React from "react";
2
1
  import { Box, useMultiStyleConfig } from "@chakra-ui/react";
2
+ import * as React from "react";
3
3
 
4
- import generateUUID from "../../helpers/generateUUID";
5
- import Select from "../Select/Select";
6
- import TextInput from "../TextInput/TextInput";
7
- import { TextInputTypes, TextInputVariants } from "../TextInput/TextInputTypes";
8
4
  import Button from "../Button/Button";
9
5
  import { ButtonTypes } from "../Button/ButtonTypes";
6
+ import ComponentWrapper from "../ComponentWrapper/ComponentWrapper";
7
+ import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
10
8
  import Icon from "../Icons/Icon";
11
9
  import { IconAlign, IconNames, IconSizes } from "../Icons/IconTypes";
12
- import HelperErrorText from "../HelperErrorText/HelperErrorText";
10
+ import Select from "../Select/Select";
13
11
  import { SelectTypes } from "../Select/SelectTypes";
12
+ import TextInput from "../TextInput/TextInput";
13
+ import { TextInputTypes, TextInputVariants } from "../TextInput/TextInputTypes";
14
+ import generateUUID from "../../helpers/generateUUID";
14
15
 
15
16
  // Internal interfaces that are used only for `SearchBar` props.
16
17
  interface SelectProps {
@@ -37,13 +38,17 @@ export interface SearchBarProps {
37
38
  buttonOnClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;
38
39
  /** A class name for the `form` element. */
39
40
  className?: string;
41
+ /** Optional string for the SearchBar's description above the component. */
42
+ descriptionText?: string;
43
+ /** Optional string for the SearchBar's heading text above the component. */
44
+ headingText?: string;
40
45
  /** The text to display below the form in a `HelperErrorText` component. */
41
- helperErrorText?: string;
46
+ helperText?: HelperErrorTextType;
42
47
  /** ID that other components can cross reference for accessibility purposes */
43
48
  id?: string;
44
49
  /** Optional string to populate the `HelperErrorText` for the error state
45
50
  * when `isInvalid` is true. */
46
- invalidText?: string;
51
+ invalidText?: HelperErrorTextType;
47
52
  /** Sets children form components in the disabled state. */
48
53
  isDisabled?: boolean;
49
54
  /** Sets children form components in the error state. */
@@ -54,6 +59,9 @@ export interface SearchBarProps {
54
59
  labelText: string;
55
60
  /** Adds 'method' property to the `form` element. */
56
61
  method?: string;
62
+ /** Sets the `Button` variant type to `ButtonTypes.NoBrand` when true;
63
+ * false by default which sets the type to `ButtonTypes.Primary`. */
64
+ noBrandButtonType?: boolean;
57
65
  /** Handler function when the form is submitted. */
58
66
  onSubmit: (event: React.FormEvent) => void;
59
67
  /** Required props to render a `Select` element. */
@@ -73,7 +81,9 @@ export default function SearchBar(props: SearchBarProps) {
73
81
  action,
74
82
  buttonOnClick = null,
75
83
  className,
76
- helperErrorText,
84
+ descriptionText,
85
+ headingText,
86
+ helperText,
77
87
  id = generateUUID(),
78
88
  invalidText,
79
89
  isDisabled = false,
@@ -81,6 +91,7 @@ export default function SearchBar(props: SearchBarProps) {
81
91
  isRequired = false,
82
92
  labelText,
83
93
  method,
94
+ noBrandButtonType = false,
84
95
  onSubmit,
85
96
  selectProps,
86
97
  textInputElement,
@@ -97,11 +108,20 @@ export default function SearchBar(props: SearchBarProps) {
97
108
  };
98
109
  const helperErrorTextID = generateUUID();
99
110
  const ariaDescribedby = helperErrorTextID;
100
- const footnote = isInvalid ? invalidText : helperErrorText;
111
+ const footnote = isInvalid ? invalidText : helperText;
101
112
  const finalAriaLabel = footnote ? `${labelText} - ${footnote}` : labelText;
102
113
  const textInputPlaceholder = `${textInputProps?.placeholder} ${
103
114
  isRequired ? "(Required)" : ""
104
115
  }`;
116
+ const buttonType = noBrandButtonType
117
+ ? ButtonTypes.NoBrand
118
+ : ButtonTypes.Primary;
119
+ const searchBarButtonStyles = {
120
+ borderLeftRadius: "none",
121
+ borderRightRadius: { base: "none", md: "sm" },
122
+ lineHeight: "1.70",
123
+ marginBottom: "auto",
124
+ };
105
125
  // Render the `Select` component.
106
126
  const selectElem = selectProps && (
107
127
  <Select
@@ -139,11 +159,12 @@ export default function SearchBar(props: SearchBarProps) {
139
159
  // Render the `Button` component.
140
160
  const buttonElem = (
141
161
  <Button
162
+ additionalStyles={searchBarButtonStyles}
163
+ buttonType={buttonType}
142
164
  id={generateUUID()}
143
- buttonType={ButtonTypes.SearchBar}
144
- type="submit"
145
- onClick={buttonOnClick}
146
165
  isDisabled={isDisabled}
166
+ onClick={buttonOnClick}
167
+ type="submit"
147
168
  >
148
169
  <Icon
149
170
  name={IconNames.Search}
@@ -153,35 +174,35 @@ export default function SearchBar(props: SearchBarProps) {
153
174
  Search
154
175
  </Button>
155
176
  );
156
- // Render the `HelperErrorText` component.
157
- const helperErrorTextElem = footnote && (
158
- <HelperErrorText id={helperErrorTextID} isInvalid={isInvalid}>
159
- {footnote}
160
- </HelperErrorText>
161
- );
162
177
  // If a custom input element was passed, use that instead of the
163
178
  // `TextInput` component.
164
179
  const textInputElem = textInputElement || textInputNative;
165
180
 
166
181
  return (
167
- <Box
168
- as="form"
182
+ <ComponentWrapper
183
+ descriptionText={descriptionText}
184
+ headingText={headingText}
185
+ helperText={helperText}
169
186
  id={id}
170
- className={className}
171
- role="search"
172
- aria-label={finalAriaLabel}
173
- aria-describedby={ariaDescribedby}
174
- onSubmit={onSubmit}
175
- method={method}
176
- action={action}
177
- __css={styles}
187
+ invalidText={invalidText}
188
+ isInvalid={isInvalid}
178
189
  >
179
- <Box __css={styles.topRow}>
190
+ <Box
191
+ as="form"
192
+ id={`${id}-form`}
193
+ className={className}
194
+ role="search"
195
+ aria-label={finalAriaLabel}
196
+ aria-describedby={ariaDescribedby}
197
+ onSubmit={onSubmit}
198
+ method={method}
199
+ action={action}
200
+ __css={styles}
201
+ >
180
202
  {selectElem}
181
203
  {textInputElem}
182
204
  {buttonElem}
183
205
  </Box>
184
- {helperErrorTextElem}
185
- </Box>
206
+ </ComponentWrapper>
186
207
  );
187
208
  }
@@ -1,18 +1,22 @@
1
+ import { VStack } from "@chakra-ui/react";
1
2
  import {
2
- Meta,
3
- Story,
4
- Canvas,
5
3
  ArgsTable,
4
+ Canvas,
6
5
  Description,
7
- } from "@storybook/addon-docs/blocks";
6
+ Meta,
7
+ Story,
8
+ } from "@storybook/addon-docs";
8
9
  import { withDesign } from "storybook-addon-designs";
9
10
 
10
- import { VStack } from "@chakra-ui/react";
11
- import Select from "./Select";
12
- import Form from "../Form/Form";
13
11
  import Button from "../Button/Button";
12
+ import Form from "../Form/Form";
13
+ import Select from "./Select";
14
+ import { SelectTypes } from "./SelectTypes";
14
15
  import { getCategory } from "../../utils/componentCategories";
15
16
  import DSProvider from "../../theme/provider";
17
+ import { getStorybookEnumValues } from "../../utils/utils";
18
+
19
+ export const enumValues = getStorybookEnumValues(SelectTypes, "SelectTypes");
16
20
 
17
21
  <Meta
18
22
  title={getCategory("Select")}
@@ -27,10 +31,34 @@ import DSProvider from "../../theme/provider";
27
31
  }}
28
32
  argTypes={{
29
33
  children: { table: { disable: true } },
30
- id: { table: { disable: true } },
31
- name: { table: { disable: true } },
32
- onChange: { table: { disable: true } },
33
- value: { table: { disable: true } },
34
+ id: { control: false },
35
+ isDisabled: {
36
+ table: { defaultValue: { summary: false } },
37
+ },
38
+ isInvalid: {
39
+ table: { defaultValue: { summary: false } },
40
+ },
41
+ isRequired: {
42
+ table: { defaultValue: { summary: false } },
43
+ },
44
+ name: { control: false },
45
+ key: { table: { disable: true } },
46
+ onChange: { control: false },
47
+ ref: { table: { disable: true } },
48
+ showHelperInvalidText: {
49
+ table: { defaultValue: { summary: true } },
50
+ },
51
+ showLabel: {
52
+ table: { defaultValue: { summary: true } },
53
+ },
54
+ showOptReqLabel: {
55
+ table: { defaultValue: { summary: true } },
56
+ },
57
+ type: {
58
+ control: false,
59
+ table: { defaultValue: { summary: "SelectTypes.Default" } },
60
+ },
61
+ value: { control: false },
34
62
  }}
35
63
  />
36
64
 
@@ -39,7 +67,7 @@ import DSProvider from "../../theme/provider";
39
67
  | Component Version | DS Version |
40
68
  | ----------------- | ---------- |
41
69
  | Added | `0.7.0` |
42
- | Latest | `0.25.8` |
70
+ | Latest | `0.25.9` |
43
71
 
44
72
  <Description of={Select} />
45
73
 
@@ -64,17 +92,23 @@ elements, but the select options _need_ to be child `<option>` HTML elements.
64
92
 
65
93
  <Canvas withToolbar>
66
94
  <Story
67
- name="Select"
95
+ name="Select with Controls"
68
96
  args={{
97
+ className: undefined,
69
98
  helperText: "This is the helper text.",
99
+ id: "select-id",
70
100
  invalidText: "This is the error text :(",
71
101
  isDisabled: false,
72
102
  isInvalid: false,
73
103
  isRequired: false,
74
104
  labelText: "What is your favorite color?",
75
105
  name: "color",
106
+ onChange: undefined,
107
+ showHelperInvalidText: undefined,
76
108
  showLabel: true,
77
109
  showOptReqLabel: true,
110
+ type: SelectTypes.Default,
111
+ value: undefined,
78
112
  }}
79
113
  >
80
114
  {(args) => (
@@ -89,7 +123,7 @@ elements, but the select options _need_ to be child `<option>` HTML elements.
89
123
  </Story>
90
124
  </Canvas>
91
125
 
92
- <ArgsTable story="Select" />
126
+ <ArgsTable story="Select with Controls" />
93
127
 
94
128
  ## Labelling Variations
95
129