@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
@@ -19,8 +19,7 @@ import DSProvider from "../../theme/provider";
19
19
  parameters={{
20
20
  design: {
21
21
  type: "figma",
22
- url:
23
- "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11689%3A423",
22
+ url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11689%3A423",
24
23
  },
25
24
  jest: ["SearchBar.test.tsx"],
26
25
  }}
@@ -43,7 +42,7 @@ import DSProvider from "../../theme/provider";
43
42
  | Component Version | DS Version |
44
43
  | ----------------- | ---------- |
45
44
  | Added | `0.0.4` |
46
- | Latest | `0.25.3` |
45
+ | Latest | `0.25.6` |
47
46
 
48
47
  <Description of={SearchBar} />
49
48
 
@@ -56,6 +55,9 @@ based on the required props.
56
55
  The `Select` dropdown narrows the search within a specific category, typically
57
56
  title or author. Toggle the `Select` through the Controls.
58
57
 
58
+ Note: The labels for the `Select` and `TextInput` components are not visible but
59
+ aria-labels are used to make these children components accessible.
60
+
59
61
  export const optionsGroup = [
60
62
  "Art",
61
63
  "Bushes",
@@ -73,13 +75,13 @@ export const optionsGroup = [
73
75
  <Story
74
76
  name="Basic"
75
77
  args={{
76
- showHelperText: true,
77
- showSelect: true,
78
+ helperErrorText: "Search for items in Animal Crossing New Horizons",
78
79
  invalidText: "Could not find the item :(",
79
80
  isDisabled: false,
80
81
  isInvalid: false,
81
82
  isRequired: false,
82
- helperErrorText: "Search for items in Animal Crossing New Horizons",
83
+ showHelperText: true,
84
+ showSelect: true,
83
85
  }}
84
86
  >
85
87
  {(args) => (
@@ -88,13 +90,14 @@ export const optionsGroup = [
88
90
  {...args}
89
91
  selectProps={
90
92
  args.showSelect && {
91
- name: "nhItemSearch",
92
93
  labelText: "Select a category",
94
+ name: "selectName",
93
95
  optionsData: optionsGroup,
94
96
  }
95
97
  }
96
98
  textInputProps={{
97
99
  labelText: "Item Search",
100
+ name: "textInputName",
98
101
  placeholder: "Item Search",
99
102
  }}
100
103
  helperErrorText={args.showHelperText && args.helperErrorText}
@@ -132,14 +135,19 @@ const selectProps = {
132
135
  ### TextInput Component
133
136
 
134
137
  To render the `TextInput` component, an object must be passed to the
135
- `textInputProps` prop. It _must_ include `labelText` and `placeholder`
138
+ `textInputProps` prop. It _must_ include `labelText`, `name`, and `placeholder`
136
139
  properties. The `labelText` value won't be rendered but will be used for its
137
- `aria-label` attribute.
140
+ `aria-label` attribute. Optional values to pass include `onChange` and `value`.
138
141
 
139
142
  ```
140
143
  const textInputProps = {
141
144
  labelText: "Item Search",
145
+ name: "textInputName",
146
+ onChange: (event) => {
147
+ console.log(event.target.value);
148
+ },
142
149
  placeholder: "Item Search",
150
+ value: "Horizon"
143
151
  };
144
152
 
145
153
  // ...
@@ -207,8 +215,8 @@ precedence.
207
215
  <Story
208
216
  name="Search Autocomplete"
209
217
  args={{
210
- isInvalid: false,
211
218
  isDisabled: false,
219
+ isInvalid: false,
212
220
  isRequired: false,
213
221
  }}
214
222
  >
@@ -242,9 +250,10 @@ handle the error state yourself.
242
250
  onSubmit={() => {}}
243
251
  textInputProps={{
244
252
  labelText: "Item Search",
253
+ name: "textInputName",
245
254
  placeholder: "Item Search",
246
255
  }}
247
- helperErrorText="Sorry, we can't find that item!"
256
+ helperErrorText="This is the helper text!"
248
257
  invalidText="Could not find the item :("
249
258
  isInvalid
250
259
  />
@@ -263,6 +272,7 @@ handle the disabled state yourself.
263
272
  obSubmit={() => {}}
264
273
  textInputProps={{
265
274
  labelText: "Item Search",
275
+ name: "textInputName",
266
276
  placeholder: "Item Search",
267
277
  }}
268
278
  helperErrorText="Reason for disabled state."
@@ -270,3 +280,92 @@ handle the disabled state yourself.
270
280
  />
271
281
  </DSProvider>
272
282
  </Canvas>
283
+
284
+ ### TextInput and onSubmit Values
285
+
286
+ _NOTE: open the browser console to see the values logged in the example below._
287
+
288
+ It is possible to get certain values from the `SearchBar` component by passing
289
+ callback functions as props.
290
+
291
+ The keyword value in the `TextInput` component can be accessed by passing a
292
+ function to the `onChange` property in the `textInputProp` prop. This is useful
293
+ for validating the keyword the user entered.
294
+
295
+ To get values when the form is submitted, you must:
296
+
297
+ - pass values for the `name` property in the `selectProps` and `textInputProps`
298
+ prop objects.
299
+ - get the values returned in the `onSubmit` callback function.
300
+
301
+ In the following example, the `name` for the `Select` is "selectName" and the
302
+ `name` for the `TextInput` is "textInputName". The `onSubmit` function can get
303
+ the submitted values through the `event` object. In the example below, the
304
+ values can be retrieved as `event.target.selectName.value` and
305
+ `event.target.textInputName.value`.
306
+
307
+ ```tsx
308
+ function SearchBarValueExample() {
309
+ const textInputOnChange = (event) => {
310
+ console.log(`onChange TextInput value: ${event.target.value}`);
311
+ };
312
+ const onSubmit = (event) => {
313
+ event.preventDefault();
314
+ console.log(`onSubmit Select value: ${event.target.searchName.value}`);
315
+ console.log(`onSubmit TextInput value ${event.target.textInputName.value}`);
316
+ };
317
+ return (
318
+ <SearchBar
319
+ onSubmit={onSubmit}
320
+ selectProps={{
321
+ labelText: "Select a category",
322
+ name: "selectName",
323
+ optionsData: optionsGroup,
324
+ }}
325
+ textInputProps={{
326
+ labelText: "Item Search",
327
+ name: "textInputName",
328
+ onChange: textInputOnChange,
329
+ placeholder: "Item Search",
330
+ }}
331
+ helperErrorText="Search for an item"
332
+ invalidText="Could not find the item :("
333
+ />
334
+ );
335
+ }
336
+ ```
337
+
338
+ export function SearchBarValueExample() {
339
+ const textInputOnChange = (event) => {
340
+ console.log(`onChange TextInput value: ${event.target.value}`);
341
+ };
342
+ const onSubmit = (event) => {
343
+ event.preventDefault();
344
+ console.log(`onSubmit Select value: ${event.target.selectName.value}`);
345
+ console.log(`onSubmit TextInput value ${event.target.textInputName.value}`);
346
+ };
347
+ return (
348
+ <SearchBar
349
+ onSubmit={onSubmit}
350
+ selectProps={{
351
+ labelText: "Select a category",
352
+ name: "selectName",
353
+ optionsData: optionsGroup,
354
+ }}
355
+ textInputProps={{
356
+ labelText: "Item Search",
357
+ name: "textInputName",
358
+ onChange: textInputOnChange,
359
+ placeholder: "Item Search",
360
+ }}
361
+ helperErrorText="Search for an item"
362
+ invalidText="Could not find the item :("
363
+ />
364
+ );
365
+ }
366
+
367
+ <Canvas>
368
+ <DSProvider>
369
+ <SearchBarValueExample />
370
+ </DSProvider>
371
+ </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. */
@@ -95,6 +99,9 @@ export default function SearchBar(props: SearchBarProps) {
95
99
  const ariaDescribedby = helperErrorTextID;
96
100
  const footnote = isInvalid ? invalidText : helperErrorText;
97
101
  const finalAriaLabel = footnote ? `${labelText} - ${footnote}` : labelText;
102
+ const textInputPlaceholder = `${textInputProps?.placeholder} ${
103
+ isRequired ? "(Required)" : ""
104
+ }`;
98
105
  // Render the `Select` component.
99
106
  const selectElem = selectProps && (
100
107
  <Select
@@ -116,13 +123,16 @@ export default function SearchBar(props: SearchBarProps) {
116
123
  <TextInput
117
124
  id={generateUUID()}
118
125
  labelText={textInputProps?.labelText}
119
- placeholder={textInputProps?.placeholder}
126
+ placeholder={textInputPlaceholder}
127
+ onChange={textInputProps?.onChange}
128
+ name={textInputProps?.name}
120
129
  type={TextInputTypes.text}
121
130
  variantType={
122
131
  selectElem
123
132
  ? TextInputVariants.SearchBarSelect
124
133
  : TextInputVariants.SearchBar
125
134
  }
135
+ value={textInputProps?.value}
126
136
  {...stateProps}
127
137
  />
128
138
  );
@@ -133,7 +143,7 @@ export default function SearchBar(props: SearchBarProps) {
133
143
  buttonType={ButtonTypes.SearchBar}
134
144
  type="submit"
135
145
  onClick={buttonOnClick}
136
- disabled={isDisabled}
146
+ isDisabled={isDisabled}
137
147
  >
138
148
  <Icon
139
149
  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",