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

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 (131) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +47 -11
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
  4. package/dist/components/Button/Button.d.ts +9 -6
  5. package/dist/components/Button/ButtonTypes.d.ts +2 -1
  6. package/dist/components/Card/Card.d.ts +0 -25
  7. package/dist/components/Icons/IconSvgs.d.ts +3 -0
  8. package/dist/components/Icons/IconTypes.d.ts +3 -0
  9. package/dist/components/Notification/Notification.d.ts +6 -4
  10. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
  11. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
  12. package/dist/components/SearchBar/SearchBar.d.ts +3 -3
  13. package/dist/components/Slider/Slider.d.ts +57 -0
  14. package/dist/components/Tabs/Tabs.d.ts +1 -1
  15. package/dist/components/TextInput/TextInput.d.ts +6 -0
  16. package/dist/design-system-react-components.cjs.development.js +707 -454
  17. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  18. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  19. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  20. package/dist/design-system-react-components.esm.js +700 -441
  21. package/dist/design-system-react-components.esm.js.map +1 -1
  22. package/dist/index.d.ts +6 -3
  23. package/dist/resources.scss +180 -170
  24. package/dist/styles.css +1 -1
  25. package/dist/theme/components/button.d.ts +10 -0
  26. package/dist/theme/components/progressIndicator.d.ts +50 -0
  27. package/dist/theme/components/slider.d.ts +51 -0
  28. package/dist/theme/foundations/breakpoints.d.ts +8 -8
  29. package/dist/theme/foundations/global.d.ts +6 -1
  30. package/package.json +72 -84
  31. package/src/__tests__/setup.ts +2 -2
  32. package/src/components/Accordion/Accordion.stories.mdx +30 -34
  33. package/src/components/Autosuggest/Autosuggest.stories.mdx +3 -3
  34. package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -0
  35. package/src/components/Autosuggest/_Autosuggest.scss +5 -5
  36. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +5 -6
  37. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +23 -0
  38. package/src/components/Breadcrumbs/Breadcrumbs.tsx +5 -1
  39. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +198 -1
  40. package/src/components/Button/Button.stories.mdx +8 -6
  41. package/src/components/Button/Button.test.tsx +20 -0
  42. package/src/components/Button/Button.tsx +14 -23
  43. package/src/components/Button/ButtonTypes.tsx +1 -0
  44. package/src/components/Button/__snapshots__/Button.test.tsx.snap +29 -4
  45. package/src/components/Card/Card.stories.mdx +1 -1
  46. package/src/components/Card/Card.tsx +3 -3
  47. package/src/components/CardEdition/CardEdition.stories.tsx +15 -47
  48. package/src/components/CardEdition/_CardEdition.scss +22 -23
  49. package/src/components/Chakra/Box.stories.mdx +14 -15
  50. package/src/components/Chakra/Center.stories.mdx +15 -8
  51. package/src/components/Chakra/Grid.stories.mdx +16 -7
  52. package/src/components/Chakra/Stack.stories.mdx +35 -18
  53. package/src/components/DatePicker/DatePicker.test.tsx +31 -30
  54. package/src/components/DatePicker/DatePicker.tsx +7 -4
  55. package/src/components/DatePicker/_DatePicker.scss +4 -4
  56. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +19 -5
  57. package/src/components/Form/Form.stories.mdx +4 -5
  58. package/src/components/Grid/SimpleGrid.stories.mdx +1 -0
  59. package/src/components/Hero/HeroTypes.tsx +1 -0
  60. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +2 -3
  61. package/src/components/Icons/Icon.stories.mdx +2 -3
  62. package/src/components/Icons/IconSvgs.tsx +6 -0
  63. package/src/components/Icons/IconTypes.tsx +3 -0
  64. package/src/components/Image/Image.stories.mdx +2 -3
  65. package/src/components/Input/Input.stories.tsx +20 -64
  66. package/src/components/Input/_Input.scss +23 -14
  67. package/src/components/Modal/Modal.stories.mdx +3 -3
  68. package/src/components/Modal/_Modal.scss +2 -2
  69. package/src/components/Notification/Notification.stories.mdx +1 -1
  70. package/src/components/Notification/Notification.tsx +13 -4
  71. package/src/components/Pagination/Pagination.stories.mdx +3 -2
  72. package/src/components/Pagination/Pagination.stories.tsx +1 -2
  73. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
  74. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
  75. package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
  76. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
  77. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
  78. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
  79. package/src/components/RadioGroup/RadioGroup.stories.mdx +2 -3
  80. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +4 -0
  81. package/src/components/SearchBar/SearchBar.Test.tsx +2 -1
  82. package/src/components/SearchBar/SearchBar.stories.mdx +109 -9
  83. package/src/components/SearchBar/SearchBar.tsx +11 -4
  84. package/src/components/Select/SelectTypes.tsx +1 -0
  85. package/src/components/Slider/Slider.stories.mdx +529 -0
  86. package/src/components/Slider/Slider.test.tsx +653 -0
  87. package/src/components/Slider/Slider.tsx +303 -0
  88. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
  89. package/src/components/StyleGuide/Bidirectionality.stories.mdx +1 -1
  90. package/src/components/StyleGuide/Breakpoints.stories.mdx +21 -7
  91. package/src/components/StyleGuide/Buttons.stories.mdx +9 -2
  92. package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
  93. package/src/components/Tabs/Tabs.tsx +5 -5
  94. package/src/components/Template/Template.stories.mdx +6 -6
  95. package/src/components/TextInput/TextInput.stories.mdx +1 -1
  96. package/src/components/TextInput/TextInput.tsx +15 -2
  97. package/src/components/TextInput/TextInputTypes.tsx +2 -0
  98. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -3
  99. package/src/docs/Chakra.stories.mdx +2 -2
  100. package/src/index.ts +10 -6
  101. package/src/resources.scss +5 -5
  102. package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
  103. package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
  104. package/src/styles/base/{_04-base.scss → _03-base.scss} +7 -2
  105. package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
  106. package/src/styles/base/_place-holder.scss +14 -3
  107. package/src/styles/{03-space → space}/_space-inline.scss +14 -14
  108. package/src/styles/{03-space → space}/_space-inset.scss +10 -10
  109. package/src/styles/space/_space-stack.scss +116 -0
  110. package/src/styles.scss +13 -44
  111. package/src/theme/components/button.ts +10 -2
  112. package/src/theme/components/card.ts +11 -9
  113. package/src/theme/components/datePicker.ts +1 -1
  114. package/src/theme/components/list.ts +2 -2
  115. package/src/theme/components/notification.ts +5 -3
  116. package/src/theme/components/progressIndicator.ts +62 -0
  117. package/src/theme/components/skeletonLoader.ts +1 -1
  118. package/src/theme/components/slider.ts +79 -0
  119. package/src/theme/foundations/breakpoints.ts +8 -8
  120. package/src/theme/foundations/global.ts +6 -1
  121. package/src/theme/index.ts +4 -0
  122. package/src/utils/componentCategories.ts +3 -3
  123. package/src/styles/01-colors/_colors-brand.scss +0 -62
  124. package/src/styles/01-colors/_colors-utility.scss +0 -67
  125. package/src/styles/02-typography/_type-scale.css +0 -11
  126. package/src/styles/02-typography/_type-weight.css +0 -7
  127. package/src/styles/02-typography/_typefaces.css +0 -4
  128. package/src/styles/03-space/_space-stack.scss +0 -116
  129. package/src/styles/03-space/_space.css +0 -30
  130. package/src/styles/base/_card-grid.scss +0 -77
  131. 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";
@@ -43,7 +43,7 @@ import DSProvider from "../../theme/provider";
43
43
  | Component Version | DS Version |
44
44
  | ----------------- | ---------- |
45
45
  | Added | `0.0.4` |
46
- | Latest | `0.25.3` |
46
+ | Latest | `0.25.4` |
47
47
 
48
48
  <Description of={SearchBar} />
49
49
 
@@ -56,6 +56,9 @@ based on the required props.
56
56
  The `Select` dropdown narrows the search within a specific category, typically
57
57
  title or author. Toggle the `Select` through the Controls.
58
58
 
59
+ Note: The labels for the `Select` and `TextInput` components are not visible but
60
+ aria-labels are used to make these children components accessible.
61
+
59
62
  export const optionsGroup = [
60
63
  "Art",
61
64
  "Bushes",
@@ -73,13 +76,13 @@ export const optionsGroup = [
73
76
  <Story
74
77
  name="Basic"
75
78
  args={{
76
- showHelperText: true,
77
- showSelect: true,
79
+ helperErrorText: "Search for items in Animal Crossing New Horizons",
78
80
  invalidText: "Could not find the item :(",
79
81
  isDisabled: false,
80
82
  isInvalid: false,
81
83
  isRequired: false,
82
- helperErrorText: "Search for items in Animal Crossing New Horizons",
84
+ showHelperText: true,
85
+ showSelect: true,
83
86
  }}
84
87
  >
85
88
  {(args) => (
@@ -88,13 +91,14 @@ export const optionsGroup = [
88
91
  {...args}
89
92
  selectProps={
90
93
  args.showSelect && {
91
- name: "nhItemSearch",
92
94
  labelText: "Select a category",
95
+ name: "selectName",
93
96
  optionsData: optionsGroup,
94
97
  }
95
98
  }
96
99
  textInputProps={{
97
100
  labelText: "Item Search",
101
+ name: "textInputName",
98
102
  placeholder: "Item Search",
99
103
  }}
100
104
  helperErrorText={args.showHelperText && args.helperErrorText}
@@ -132,14 +136,19 @@ const selectProps = {
132
136
  ### TextInput Component
133
137
 
134
138
  To render the `TextInput` component, an object must be passed to the
135
- `textInputProps` prop. It _must_ include `labelText` and `placeholder`
139
+ `textInputProps` prop. It _must_ include `labelText`, `name`, and `placeholder`
136
140
  properties. The `labelText` value won't be rendered but will be used for its
137
- `aria-label` attribute.
141
+ `aria-label` attribute. Optional values to pass include `onChange` and `value`.
138
142
 
139
143
  ```
140
144
  const textInputProps = {
141
145
  labelText: "Item Search",
146
+ name: "textInputName",
147
+ onChange: (event) => {
148
+ console.log(event.target.value);
149
+ },
142
150
  placeholder: "Item Search",
151
+ value: "Horizon"
143
152
  };
144
153
 
145
154
  // ...
@@ -207,8 +216,8 @@ precedence.
207
216
  <Story
208
217
  name="Search Autocomplete"
209
218
  args={{
210
- isInvalid: false,
211
219
  isDisabled: false,
220
+ isInvalid: false,
212
221
  isRequired: false,
213
222
  }}
214
223
  >
@@ -242,9 +251,10 @@ handle the error state yourself.
242
251
  onSubmit={() => {}}
243
252
  textInputProps={{
244
253
  labelText: "Item Search",
254
+ name: "textInputName",
245
255
  placeholder: "Item Search",
246
256
  }}
247
- helperErrorText="Sorry, we can't find that item!"
257
+ helperErrorText="This is the helper text!"
248
258
  invalidText="Could not find the item :("
249
259
  isInvalid
250
260
  />
@@ -263,6 +273,7 @@ handle the disabled state yourself.
263
273
  obSubmit={() => {}}
264
274
  textInputProps={{
265
275
  labelText: "Item Search",
276
+ name: "textInputName",
266
277
  placeholder: "Item Search",
267
278
  }}
268
279
  helperErrorText="Reason for disabled state."
@@ -270,3 +281,92 @@ handle the disabled state yourself.
270
281
  />
271
282
  </DSProvider>
272
283
  </Canvas>
284
+
285
+ ### TextInput and onSubmit Values
286
+
287
+ _NOTE: open the browser console to see the values logged in the example below._
288
+
289
+ It is possible to get certain values from the `SearchBar` component by passing
290
+ callback functions as props.
291
+
292
+ The keyword value in the `TextInput` component can be accessed by passing a
293
+ function to the `onChange` property in the `textInputProp` prop. This is useful
294
+ for validating the keyword the user entered.
295
+
296
+ To get values when the form is submitted, you must:
297
+
298
+ - pass values for the `name` property in the `selectProps` and `textInputProps`
299
+ prop objects.
300
+ - get the values returned in the `onSubmit` callback function.
301
+
302
+ In the following example, the `name` for the `Select` is "selectName" and the
303
+ `name` for the `TextInput` is "textInputName". The `onSubmit` function can get
304
+ the submitted values through the `event` object. In the example below, the
305
+ values can be retrieved as `event.target.selectName.value` and
306
+ `event.target.textInputName.value`.
307
+
308
+ ```tsx
309
+ function SearchBarValueExample() {
310
+ const textInputOnChange = (event) => {
311
+ console.log(`onChange TextInput value: ${event.target.value}`);
312
+ };
313
+ const onSubmit = (event) => {
314
+ event.preventDefault();
315
+ console.log(`onSubmit Select value: ${event.target.searchName.value}`);
316
+ console.log(`onSubmit TextInput value ${event.target.textInputName.value}`);
317
+ };
318
+ return (
319
+ <SearchBar
320
+ onSubmit={onSubmit}
321
+ selectProps={{
322
+ labelText: "Select a category",
323
+ name: "selectName",
324
+ optionsData: optionsGroup,
325
+ }}
326
+ textInputProps={{
327
+ labelText: "Item Search",
328
+ name: "textInputName",
329
+ onChange: textInputOnChange,
330
+ placeholder: "Item Search",
331
+ }}
332
+ helperErrorText="Search for an item"
333
+ invalidText="Could not find the item :("
334
+ />
335
+ );
336
+ }
337
+ ```
338
+
339
+ export function SearchBarValueExample() {
340
+ const textInputOnChange = (event) => {
341
+ console.log(`onChange TextInput value: ${event.target.value}`);
342
+ };
343
+ const onSubmit = (event) => {
344
+ event.preventDefault();
345
+ console.log(`onSubmit Select value: ${event.target.selectName.value}`);
346
+ console.log(`onSubmit TextInput value ${event.target.textInputName.value}`);
347
+ };
348
+ return (
349
+ <SearchBar
350
+ onSubmit={onSubmit}
351
+ selectProps={{
352
+ labelText: "Select a category",
353
+ name: "selectName",
354
+ optionsData: optionsGroup,
355
+ }}
356
+ textInputProps={{
357
+ labelText: "Item Search",
358
+ name: "textInputName",
359
+ onChange: textInputOnChange,
360
+ placeholder: "Item Search",
361
+ }}
362
+ helperErrorText="Search for an item"
363
+ invalidText="Could not find the item :("
364
+ />
365
+ );
366
+ }
367
+
368
+ <Canvas>
369
+ <DSProvider>
370
+ <SearchBarValueExample />
371
+ </DSProvider>
372
+ </Canvas>
@@ -20,7 +20,14 @@ interface SelectProps {
20
20
  }
21
21
  interface TextInputProps {
22
22
  labelText: string;
23
+ name: string;
24
+ onChange?: (
25
+ event:
26
+ | React.ChangeEvent<HTMLInputElement>
27
+ | React.ChangeEvent<HTMLTextAreaElement>
28
+ ) => void;
23
29
  placeholder: string;
30
+ value?: string;
24
31
  }
25
32
 
26
33
  export interface SearchBarProps {
@@ -51,9 +58,6 @@ export interface SearchBarProps {
51
58
  onSubmit: (event: React.FormEvent) => void;
52
59
  /** Required props to render a `Select` element. */
53
60
  selectProps?: SelectProps | undefined;
54
- /** Will be used to visually display the label text for this
55
- * `SearchBar` component. False by default. */
56
- showLabel?: boolean;
57
61
  /** Custom input element to render instead of a `TextInput` element. */
58
62
  textInputElement?: JSX.Element;
59
63
  /** Required props to render a `TextInput` element. */
@@ -117,12 +121,15 @@ export default function SearchBar(props: SearchBarProps) {
117
121
  id={generateUUID()}
118
122
  labelText={textInputProps?.labelText}
119
123
  placeholder={textInputProps?.placeholder}
124
+ onChange={textInputProps?.onChange}
125
+ name={textInputProps?.name}
120
126
  type={TextInputTypes.text}
121
127
  variantType={
122
128
  selectElem
123
129
  ? TextInputVariants.SearchBarSelect
124
130
  : TextInputVariants.SearchBar
125
131
  }
132
+ value={textInputProps?.value}
126
133
  {...stateProps}
127
134
  />
128
135
  );
@@ -133,7 +140,7 @@ export default function SearchBar(props: SearchBarProps) {
133
140
  buttonType={ButtonTypes.SearchBar}
134
141
  type="submit"
135
142
  onClick={buttonOnClick}
136
- disabled={isDisabled}
143
+ isDisabled={isDisabled}
137
144
  >
138
145
  <Icon
139
146
  name={IconNames.Search}
@@ -1,3 +1,4 @@
1
+ // Only used for internal purposes.
1
2
  export enum SelectTypes {
2
3
  Default = "default",
3
4
  SearchBar = "searchbar",