@nypl/design-system-react-components 0.25.3 → 0.25.7

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 (135) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +47 -11
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
  4. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -0
  5. package/dist/components/Button/Button.d.ts +9 -6
  6. package/dist/components/Button/ButtonTypes.d.ts +2 -1
  7. package/dist/components/Card/Card.d.ts +0 -25
  8. package/dist/components/Icons/IconSvgs.d.ts +3 -0
  9. package/dist/components/Icons/IconTypes.d.ts +3 -0
  10. package/dist/components/Notification/Notification.d.ts +6 -4
  11. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
  12. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
  13. package/dist/components/SearchBar/SearchBar.d.ts +3 -3
  14. package/dist/components/Slider/Slider.d.ts +57 -0
  15. package/dist/components/Tabs/Tabs.d.ts +1 -1
  16. package/dist/components/TextInput/TextInput.d.ts +6 -0
  17. package/dist/design-system-react-components.cjs.development.js +1022 -455
  18. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  19. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  20. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  21. package/dist/design-system-react-components.esm.js +1015 -444
  22. package/dist/design-system-react-components.esm.js.map +1 -1
  23. package/dist/index.d.ts +8 -3
  24. package/dist/resources.scss +180 -170
  25. package/dist/styles.css +1 -1
  26. package/dist/theme/components/breadcrumb.d.ts +9 -0
  27. package/dist/theme/components/button.d.ts +10 -0
  28. package/dist/theme/components/progressIndicator.d.ts +50 -0
  29. package/dist/theme/components/slider.d.ts +51 -0
  30. package/dist/theme/foundations/breakpoints.d.ts +8 -8
  31. package/dist/theme/foundations/global.d.ts +6 -1
  32. package/package.json +71 -83
  33. package/src/__tests__/setup.ts +2 -2
  34. package/src/components/Accordion/Accordion.stories.mdx +30 -34
  35. package/src/components/Autosuggest/Autosuggest.stories.mdx +3 -3
  36. package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -0
  37. package/src/components/Autosuggest/_Autosuggest.scss +5 -5
  38. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +24 -8
  39. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +33 -0
  40. package/src/components/Breadcrumbs/Breadcrumbs.tsx +5 -1
  41. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
  42. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +297 -1
  43. package/src/components/Button/Button.stories.mdx +8 -6
  44. package/src/components/Button/Button.test.tsx +20 -0
  45. package/src/components/Button/Button.tsx +14 -23
  46. package/src/components/Button/ButtonTypes.tsx +1 -0
  47. package/src/components/Button/__snapshots__/Button.test.tsx.snap +29 -4
  48. package/src/components/Card/Card.stories.mdx +1 -1
  49. package/src/components/Card/Card.tsx +3 -3
  50. package/src/components/CardEdition/CardEdition.stories.tsx +15 -47
  51. package/src/components/CardEdition/_CardEdition.scss +22 -23
  52. package/src/components/Chakra/Box.stories.mdx +14 -15
  53. package/src/components/Chakra/Center.stories.mdx +15 -8
  54. package/src/components/Chakra/Grid.stories.mdx +16 -7
  55. package/src/components/Chakra/Stack.stories.mdx +35 -18
  56. package/src/components/DatePicker/DatePicker.test.tsx +31 -30
  57. package/src/components/DatePicker/DatePicker.tsx +7 -4
  58. package/src/components/DatePicker/_DatePicker.scss +4 -4
  59. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +19 -5
  60. package/src/components/Form/Form.stories.mdx +4 -5
  61. package/src/components/Grid/SimpleGrid.stories.mdx +1 -0
  62. package/src/components/Hero/HeroTypes.tsx +1 -0
  63. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +2 -3
  64. package/src/components/Icons/Icon.stories.mdx +2 -3
  65. package/src/components/Icons/IconSvgs.tsx +6 -0
  66. package/src/components/Icons/IconTypes.tsx +3 -0
  67. package/src/components/Image/Image.stories.mdx +2 -3
  68. package/src/components/Input/Input.stories.tsx +20 -64
  69. package/src/components/Input/_Input.scss +23 -14
  70. package/src/components/Modal/Modal.stories.mdx +3 -3
  71. package/src/components/Modal/_Modal.scss +2 -2
  72. package/src/components/Notification/Notification.stories.mdx +1 -1
  73. package/src/components/Notification/Notification.tsx +13 -4
  74. package/src/components/Pagination/Pagination.stories.mdx +3 -2
  75. package/src/components/Pagination/Pagination.stories.tsx +1 -2
  76. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
  77. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
  78. package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
  79. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
  80. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
  81. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
  82. package/src/components/RadioGroup/RadioGroup.stories.mdx +2 -3
  83. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +4 -0
  84. package/src/components/SearchBar/SearchBar.Test.tsx +66 -21
  85. package/src/components/SearchBar/SearchBar.stories.mdx +110 -11
  86. package/src/components/SearchBar/SearchBar.tsx +15 -5
  87. package/src/components/Select/SelectTypes.tsx +1 -0
  88. package/src/components/Slider/Slider.stories.mdx +529 -0
  89. package/src/components/Slider/Slider.test.tsx +653 -0
  90. package/src/components/Slider/Slider.tsx +303 -0
  91. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
  92. package/src/components/StyleGuide/Bidirectionality.stories.mdx +1 -1
  93. package/src/components/StyleGuide/Breakpoints.stories.mdx +21 -7
  94. package/src/components/StyleGuide/Buttons.stories.mdx +9 -2
  95. package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
  96. package/src/components/Tabs/Tabs.tsx +5 -5
  97. package/src/components/Template/Template.stories.mdx +6 -6
  98. package/src/components/TextInput/TextInput.stories.mdx +1 -1
  99. package/src/components/TextInput/TextInput.tsx +15 -2
  100. package/src/components/TextInput/TextInputTypes.tsx +2 -0
  101. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -3
  102. package/src/docs/Chakra.stories.mdx +2 -2
  103. package/src/index.ts +12 -6
  104. package/src/resources.scss +5 -5
  105. package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
  106. package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
  107. package/src/styles/base/{_04-base.scss → _03-base.scss} +7 -2
  108. package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
  109. package/src/styles/base/_place-holder.scss +14 -3
  110. package/src/styles/{03-space → space}/_space-inline.scss +14 -14
  111. package/src/styles/{03-space → space}/_space-inset.scss +10 -10
  112. package/src/styles/space/_space-stack.scss +116 -0
  113. package/src/styles.scss +13 -44
  114. package/src/theme/components/breadcrumb.ts +10 -0
  115. package/src/theme/components/button.ts +10 -2
  116. package/src/theme/components/card.ts +11 -9
  117. package/src/theme/components/datePicker.ts +1 -1
  118. package/src/theme/components/list.ts +2 -2
  119. package/src/theme/components/notification.ts +5 -3
  120. package/src/theme/components/progressIndicator.ts +62 -0
  121. package/src/theme/components/skeletonLoader.ts +1 -1
  122. package/src/theme/components/slider.ts +79 -0
  123. package/src/theme/foundations/breakpoints.ts +8 -8
  124. package/src/theme/foundations/global.ts +6 -1
  125. package/src/theme/index.ts +4 -0
  126. package/src/utils/componentCategories.ts +3 -3
  127. package/src/styles/01-colors/_colors-brand.scss +0 -62
  128. package/src/styles/01-colors/_colors-utility.scss +0 -67
  129. package/src/styles/02-typography/_type-scale.css +0 -11
  130. package/src/styles/02-typography/_type-weight.css +0 -7
  131. package/src/styles/02-typography/_typefaces.css +0 -4
  132. package/src/styles/03-space/_space-stack.scss +0 -116
  133. package/src/styles/03-space/_space.css +0 -30
  134. package/src/styles/base/_card-grid.scss +0 -77
  135. package/src/styles/base/_typography.scss +0 -11
@@ -0,0 +1,357 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ProgressIndicator Renders the UI snapshot correctly 1`] = `
4
+ <div
5
+ className="css-0"
6
+ >
7
+ <label
8
+ className="css-0"
9
+ htmlFor="linearBasic"
10
+ id="linearBasic-label"
11
+ >
12
+ Linear
13
+ </label>
14
+ <div
15
+ className="css-0"
16
+ >
17
+ <div
18
+ className="css-kdwx3d"
19
+ id="linearBasic"
20
+ >
21
+ <div
22
+ aria-label={null}
23
+ aria-labelledby="linearBasic-label"
24
+ aria-valuemax={100}
25
+ aria-valuemin={0}
26
+ aria-valuenow={50}
27
+ className="css-1jy0d03"
28
+ role="progressbar"
29
+ style={
30
+ Object {
31
+ "width": "50%",
32
+ }
33
+ }
34
+ />
35
+ </div>
36
+ <div
37
+ className="css-0"
38
+ >
39
+ 50
40
+ %
41
+ </div>
42
+ </div>
43
+ </div>
44
+ `;
45
+
46
+ exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
47
+ <div
48
+ className="css-0"
49
+ >
50
+ <div
51
+ className="css-0"
52
+ >
53
+ <div
54
+ aria-label={null}
55
+ aria-labelledby="circularBasic-label"
56
+ aria-valuemax={100}
57
+ aria-valuemin={0}
58
+ aria-valuenow={50}
59
+ className="chakra-progress css-120wkjd"
60
+ id="circularBasic"
61
+ role="progressbar"
62
+ >
63
+ <svg
64
+ className="css-kn46u7"
65
+ viewBox="0 0 100 100"
66
+ >
67
+ <circle
68
+ className="chakra-progress__track css-1bhxzgy"
69
+ cx={50}
70
+ cy={50}
71
+ r={42}
72
+ strokeWidth="10px"
73
+ />
74
+ <circle
75
+ className="chakra-progress__indicator css-5hfhx0"
76
+ cx={50}
77
+ cy={50}
78
+ r={42}
79
+ strokeDasharray="132 132"
80
+ strokeDashoffset={66}
81
+ strokeWidth="10px"
82
+ />
83
+ </svg>
84
+ <div
85
+ className="css-f1j64i"
86
+ >
87
+ 50
88
+ %
89
+ </div>
90
+ </div>
91
+ <label
92
+ className="css-0"
93
+ htmlFor="circularBasic"
94
+ id="circularBasic-label"
95
+ >
96
+ Circular
97
+ </label>
98
+ </div>
99
+ </div>
100
+ `;
101
+
102
+ exports[`ProgressIndicator Renders the UI snapshot correctly 3`] = `
103
+ <div
104
+ className="css-0"
105
+ >
106
+ <div
107
+ className="css-0"
108
+ >
109
+ <div
110
+ className="css-kdwx3d"
111
+ id="linearNoLabel"
112
+ >
113
+ <div
114
+ aria-label="Linear"
115
+ aria-labelledby={null}
116
+ aria-valuemax={100}
117
+ aria-valuemin={0}
118
+ aria-valuenow={50}
119
+ className="css-1jy0d03"
120
+ role="progressbar"
121
+ style={
122
+ Object {
123
+ "width": "50%",
124
+ }
125
+ }
126
+ />
127
+ </div>
128
+ </div>
129
+ </div>
130
+ `;
131
+
132
+ exports[`ProgressIndicator Renders the UI snapshot correctly 4`] = `
133
+ <div
134
+ className="css-0"
135
+ >
136
+ <div
137
+ className="css-0"
138
+ >
139
+ <div
140
+ aria-label="Circular"
141
+ aria-labelledby={null}
142
+ aria-valuemax={100}
143
+ aria-valuemin={0}
144
+ aria-valuenow={50}
145
+ className="chakra-progress css-120wkjd"
146
+ id="circularNoLabel"
147
+ role="progressbar"
148
+ >
149
+ <svg
150
+ className="css-kn46u7"
151
+ viewBox="0 0 100 100"
152
+ >
153
+ <circle
154
+ className="chakra-progress__track css-1bhxzgy"
155
+ cx={50}
156
+ cy={50}
157
+ r={42}
158
+ strokeWidth="10px"
159
+ />
160
+ <circle
161
+ className="chakra-progress__indicator css-5hfhx0"
162
+ cx={50}
163
+ cy={50}
164
+ r={42}
165
+ strokeDasharray="132 132"
166
+ strokeDashoffset={66}
167
+ strokeWidth="10px"
168
+ />
169
+ </svg>
170
+ </div>
171
+ </div>
172
+ </div>
173
+ `;
174
+
175
+ exports[`ProgressIndicator Renders the UI snapshot correctly 5`] = `
176
+ <div
177
+ className="css-0"
178
+ >
179
+ <label
180
+ className="css-0"
181
+ htmlFor="linearIndeterminate"
182
+ id="linearIndeterminate-label"
183
+ >
184
+ Linear
185
+ </label>
186
+ <div
187
+ className="css-0"
188
+ >
189
+ <div
190
+ className="css-kdwx3d"
191
+ id="linearIndeterminate"
192
+ >
193
+ <div
194
+ aria-label={null}
195
+ aria-labelledby="linearIndeterminate-label"
196
+ aria-valuemax={100}
197
+ aria-valuemin={0}
198
+ className="css-1demtxk"
199
+ data-indeterminate=""
200
+ role="progressbar"
201
+ style={
202
+ Object {
203
+ "width": "0%",
204
+ }
205
+ }
206
+ />
207
+ </div>
208
+ </div>
209
+ </div>
210
+ `;
211
+
212
+ exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
213
+ <div
214
+ className="css-0"
215
+ >
216
+ <div
217
+ className="css-0"
218
+ >
219
+ <div
220
+ aria-label={null}
221
+ aria-labelledby="circularIndeterminate-label"
222
+ aria-valuemax={100}
223
+ aria-valuemin={0}
224
+ className="chakra-progress css-120wkjd"
225
+ data-indeterminate=""
226
+ id="circularIndeterminate"
227
+ role="progressbar"
228
+ >
229
+ <svg
230
+ className="css-jf70f3"
231
+ viewBox="0 0 100 100"
232
+ >
233
+ <circle
234
+ className="chakra-progress__track css-1bhxzgy"
235
+ cx={50}
236
+ cy={50}
237
+ r={42}
238
+ strokeWidth="10px"
239
+ />
240
+ <circle
241
+ className="chakra-progress__indicator css-tueqm1"
242
+ cx={50}
243
+ cy={50}
244
+ r={42}
245
+ strokeWidth="10px"
246
+ />
247
+ </svg>
248
+ </div>
249
+ <label
250
+ className="css-0"
251
+ htmlFor="circularIndeterminate"
252
+ id="circularIndeterminate-label"
253
+ >
254
+ Circular
255
+ </label>
256
+ </div>
257
+ </div>
258
+ `;
259
+
260
+ exports[`ProgressIndicator Renders the UI snapshot correctly 7`] = `
261
+ <div
262
+ className="css-0"
263
+ >
264
+ <label
265
+ className="css-0"
266
+ htmlFor="linearDarkMode"
267
+ id="linearDarkMode-label"
268
+ >
269
+ Linear
270
+ </label>
271
+ <div
272
+ className="css-0"
273
+ >
274
+ <div
275
+ className="css-kdwx3d"
276
+ id="linearDarkMode"
277
+ >
278
+ <div
279
+ aria-label={null}
280
+ aria-labelledby="linearDarkMode-label"
281
+ aria-valuemax={100}
282
+ aria-valuemin={0}
283
+ aria-valuenow={50}
284
+ className="css-1jy0d03"
285
+ role="progressbar"
286
+ style={
287
+ Object {
288
+ "width": "50%",
289
+ }
290
+ }
291
+ />
292
+ </div>
293
+ <div
294
+ className="css-0"
295
+ >
296
+ 50
297
+ %
298
+ </div>
299
+ </div>
300
+ </div>
301
+ `;
302
+
303
+ exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
304
+ <div
305
+ className="css-0"
306
+ >
307
+ <div
308
+ className="css-0"
309
+ >
310
+ <div
311
+ aria-label={null}
312
+ aria-labelledby="circularDarkMode-label"
313
+ aria-valuemax={100}
314
+ aria-valuemin={0}
315
+ aria-valuenow={50}
316
+ className="chakra-progress css-120wkjd"
317
+ id="circularDarkMode"
318
+ role="progressbar"
319
+ >
320
+ <svg
321
+ className="css-kn46u7"
322
+ viewBox="0 0 100 100"
323
+ >
324
+ <circle
325
+ className="chakra-progress__track css-1bhxzgy"
326
+ cx={50}
327
+ cy={50}
328
+ r={42}
329
+ strokeWidth="10px"
330
+ />
331
+ <circle
332
+ className="chakra-progress__indicator css-5hfhx0"
333
+ cx={50}
334
+ cy={50}
335
+ r={42}
336
+ strokeDasharray="132 132"
337
+ strokeDashoffset={66}
338
+ strokeWidth="10px"
339
+ />
340
+ </svg>
341
+ <div
342
+ className="css-f1j64i"
343
+ >
344
+ 50
345
+ %
346
+ </div>
347
+ </div>
348
+ <label
349
+ className="css-0"
350
+ htmlFor="circularDarkMode"
351
+ id="circularDarkMode-label"
352
+ >
353
+ Circular
354
+ </label>
355
+ </div>
356
+ </div>
357
+ `;
@@ -51,6 +51,7 @@ exports[`Radio Button renders the UI snapshot correctly 1`] = `
51
51
  exports[`Radio Button renders the UI snapshot correctly 2`] = `
52
52
  <label
53
53
  className="chakra-radio css-78joka"
54
+ data-checked=""
54
55
  >
55
56
  <input
56
57
  checked={true}
@@ -150,6 +151,7 @@ exports[`Radio Button renders the UI snapshot correctly 3`] = `
150
151
  exports[`Radio Button renders the UI snapshot correctly 4`] = `
151
152
  <label
152
153
  className="chakra-radio css-78joka"
154
+ data-invalid=""
153
155
  >
154
156
  <input
155
157
  aria-invalid={true}
@@ -201,6 +203,7 @@ exports[`Radio Button renders the UI snapshot correctly 4`] = `
201
203
  exports[`Radio Button renders the UI snapshot correctly 5`] = `
202
204
  <label
203
205
  className="chakra-radio css-78joka"
206
+ data-disabled=""
204
207
  >
205
208
  <input
206
209
  aria-disabled={true}
@@ -3,7 +3,6 @@ import {
3
3
  Story,
4
4
  Canvas,
5
5
  ArgsTable,
6
- Preview,
7
6
  Description,
8
7
  } from "@storybook/addon-docs/blocks";
9
8
  import { withDesign } from "storybook-addon-designs";
@@ -43,7 +42,7 @@ import Radio from "../Radio/Radio";
43
42
 
44
43
  <Description of={RadioGroup} />
45
44
 
46
- <Preview withToolbar>
45
+ <Canvas withToolbar>
47
46
  <Story
48
47
  name="RadioGroup"
49
48
  args={{
@@ -69,7 +68,7 @@ import Radio from "../Radio/Radio";
69
68
  </RadioGroup>
70
69
  )}
71
70
  </Story>
72
- </Preview>
71
+ </Canvas>
73
72
 
74
73
  <ArgsTable story="RadioGroup" />
75
74
 
@@ -842,6 +842,7 @@ exports[`Radio Button renders the UI snapshot correctly 8`] = `
842
842
  >
843
843
  <label
844
844
  className="chakra-radio css-78joka"
845
+ data-invalid=""
845
846
  >
846
847
  <input
847
848
  aria-invalid={true}
@@ -892,6 +893,7 @@ exports[`Radio Button renders the UI snapshot correctly 8`] = `
892
893
  </label>
893
894
  <label
894
895
  className="chakra-radio css-78joka"
896
+ data-invalid=""
895
897
  >
896
898
  <input
897
899
  aria-invalid={true}
@@ -964,6 +966,7 @@ exports[`Radio Button renders the UI snapshot correctly 9`] = `
964
966
  >
965
967
  <label
966
968
  className="chakra-radio css-78joka"
969
+ data-disabled=""
967
970
  >
968
971
  <input
969
972
  aria-disabled={true}
@@ -1014,6 +1017,7 @@ exports[`Radio Button renders the UI snapshot correctly 9`] = `
1014
1017
  </label>
1015
1018
  <label
1016
1019
  className="chakra-radio css-78joka"
1020
+ data-disabled=""
1017
1021
  >
1018
1022
  <input
1019
1023
  aria-disabled={true}
@@ -19,12 +19,13 @@ const optionsGroup = [
19
19
  "Villagers",
20
20
  ];
21
21
  const selectProps = {
22
- name: "nhItemSearch",
22
+ name: "selectName",
23
23
  labelText: "Select a category",
24
24
  optionsData: optionsGroup,
25
25
  };
26
26
  const textInputProps = {
27
27
  labelText: "Item Search",
28
+ name: "textInputName",
28
29
  placeholder: "Item Search",
29
30
  };
30
31
  const helperErrorText = "Search for items in Animal Crossing New Horizons";
@@ -34,13 +35,13 @@ describe("SearchBar Accessibility", () => {
34
35
  it("passes axe accessibility test", async () => {
35
36
  const { container } = render(
36
37
  <SearchBar
38
+ helperErrorText={helperErrorText}
37
39
  id="id"
40
+ invalidText={invalidText}
38
41
  labelText="Searchbar"
39
42
  onSubmit={jest.fn()}
40
43
  selectProps={selectProps}
41
44
  textInputProps={textInputProps}
42
- helperErrorText={helperErrorText}
43
- invalidText={invalidText}
44
45
  />
45
46
  );
46
47
  expect(await axe(container)).toHaveNoViolations();
@@ -54,11 +55,11 @@ describe("SearchBar", () => {
54
55
  it("renders the basic form", () => {
55
56
  render(
56
57
  <SearchBar
58
+ helperErrorText={helperErrorText}
57
59
  id="id"
58
60
  labelText="searchbar"
59
61
  onSubmit={searchBarSubmit}
60
62
  textInputProps={textInputProps}
61
- helperErrorText={helperErrorText}
62
63
  />
63
64
  );
64
65
  expect(screen.getByRole("search")).toBeInTheDocument();
@@ -73,12 +74,12 @@ describe("SearchBar", () => {
73
74
  it("renders an optional Select component", () => {
74
75
  render(
75
76
  <SearchBar
77
+ helperErrorText={helperErrorText}
76
78
  id="id"
77
79
  labelText="searchbar"
78
80
  onSubmit={searchBarSubmit}
79
81
  selectProps={selectProps}
80
82
  textInputProps={textInputProps}
81
- helperErrorText={helperErrorText}
82
83
  />
83
84
  );
84
85
  expect(screen.getByRole("combobox")).toBeInTheDocument();
@@ -88,14 +89,14 @@ describe("SearchBar", () => {
88
89
  it("renders the invalid text in the invalid state", () => {
89
90
  render(
90
91
  <SearchBar
92
+ helperErrorText={helperErrorText}
91
93
  id="id"
94
+ invalidText={invalidText}
95
+ isInvalid
92
96
  labelText="searchbar"
93
97
  onSubmit={searchBarSubmit}
94
98
  selectProps={selectProps}
95
99
  textInputProps={textInputProps}
96
- helperErrorText={helperErrorText}
97
- invalidText={invalidText}
98
- isInvalid
99
100
  />
100
101
  );
101
102
  expect(screen.getByText(invalidText)).toBeInTheDocument();
@@ -105,14 +106,14 @@ describe("SearchBar", () => {
105
106
  it("does not render the default invalid text from the Select or TextInput components", () => {
106
107
  render(
107
108
  <SearchBar
109
+ helperErrorText={helperErrorText}
108
110
  id="id"
111
+ invalidText={invalidText}
112
+ isInvalid
109
113
  labelText="searchbar"
110
114
  onSubmit={searchBarSubmit}
111
115
  selectProps={selectProps}
112
116
  textInputProps={textInputProps}
113
- helperErrorText={helperErrorText}
114
- invalidText={invalidText}
115
- isInvalid
116
117
  />
117
118
  );
118
119
  expect(
@@ -123,12 +124,12 @@ describe("SearchBar", () => {
123
124
  it("calls the callback function on submit ", () => {
124
125
  render(
125
126
  <SearchBar
126
- labelText="searchBar"
127
+ helperErrorText={helperErrorText}
127
128
  id="id"
129
+ labelText="searchBar"
128
130
  onSubmit={searchBarSubmit}
129
131
  selectProps={selectProps}
130
132
  textInputProps={textInputProps}
131
- helperErrorText={helperErrorText}
132
133
  />
133
134
  );
134
135
  expect(searchBarSubmit).toHaveBeenCalledTimes(0);
@@ -138,34 +139,65 @@ describe("SearchBar", () => {
138
139
  expect(buttonCallback).toHaveBeenCalledTimes(1);
139
140
  });
140
141
 
142
+ it("Renders 'required' in the placeholder text", () => {
143
+ const { rerender } = render(
144
+ <SearchBar
145
+ id="requiredState"
146
+ isDisabled
147
+ isRequired
148
+ labelText="searchbar"
149
+ onSubmit={jest.fn()}
150
+ textInputProps={textInputProps}
151
+ />
152
+ );
153
+
154
+ expect(
155
+ screen.getByPlaceholderText("Item Search (Required)")
156
+ ).not.toBeInTheDocument();
157
+
158
+ rerender(
159
+ <SearchBar
160
+ id="requiredState"
161
+ isDisabled
162
+ isRequired
163
+ labelText="searchbar"
164
+ onSubmit={jest.fn()}
165
+ textInputProps={textInputProps}
166
+ />
167
+ );
168
+ expect(
169
+ screen.getByPlaceholderText("Item Search (Required)")
170
+ ).toBeInTheDocument();
171
+ });
172
+
141
173
  it("Renders the UI snapshot correctly", () => {
142
174
  const basic = renderer
143
175
  .create(
144
176
  <SearchBar
145
- id="id"
177
+ helperErrorText={helperErrorText}
178
+ id="basic"
146
179
  labelText="searchbar"
147
180
  onSubmit={jest.fn()}
148
181
  textInputProps={textInputProps}
149
- helperErrorText={helperErrorText}
150
182
  />
151
183
  )
152
184
  .toJSON();
153
185
  const withSelect = renderer
154
186
  .create(
155
187
  <SearchBar
156
- id="id"
188
+ helperErrorText={helperErrorText}
189
+ id="withSelect"
157
190
  labelText="searchbar"
158
191
  onSubmit={jest.fn()}
159
192
  selectProps={selectProps}
160
193
  textInputProps={textInputProps}
161
- helperErrorText={helperErrorText}
162
194
  />
163
195
  )
164
196
  .toJSON();
165
197
  const withoutHelperText = renderer
166
198
  .create(
167
199
  <SearchBar
168
- id="id"
200
+ id="withoutHelperText"
169
201
  labelText="searchbar"
170
202
  onSubmit={jest.fn()}
171
203
  textInputProps={textInputProps}
@@ -175,22 +207,34 @@ describe("SearchBar", () => {
175
207
  const invalidState = renderer
176
208
  .create(
177
209
  <SearchBar
178
- id="id"
210
+ id="invalidState"
211
+ isInvalid
179
212
  labelText="searchbar"
180
213
  onSubmit={jest.fn()}
181
214
  textInputProps={textInputProps}
182
- isInvalid
183
215
  />
184
216
  )
185
217
  .toJSON();
186
218
  const disabledState = renderer
187
219
  .create(
188
220
  <SearchBar
189
- id="id"
221
+ id="disabledState"
222
+ isDisabled
190
223
  labelText="searchbar"
191
224
  onSubmit={jest.fn()}
192
225
  textInputProps={textInputProps}
226
+ />
227
+ )
228
+ .toJSON();
229
+ const requiredState = renderer
230
+ .create(
231
+ <SearchBar
232
+ id="requiredState"
193
233
  isDisabled
234
+ isRequired
235
+ labelText="searchbar"
236
+ onSubmit={jest.fn()}
237
+ textInputProps={textInputProps}
194
238
  />
195
239
  )
196
240
  .toJSON();
@@ -200,5 +244,6 @@ describe("SearchBar", () => {
200
244
  expect(withoutHelperText).toMatchSnapshot();
201
245
  expect(invalidState).toMatchSnapshot();
202
246
  expect(disabledState).toMatchSnapshot();
247
+ expect(requiredState).toMatchSnapshot();
203
248
  });
204
249
  });