@nypl/design-system-react-components 0.28.0 → 1.0.2

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 (99) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +10 -10
  3. package/dist/components/Checkbox/Checkbox.d.ts +0 -1
  4. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +8 -0
  5. package/dist/components/Heading/Heading.d.ts +2 -0
  6. package/dist/components/Logo/Logo.d.ts +1 -1
  7. package/dist/components/Logo/LogoSvgs.d.ts +4 -0
  8. package/dist/design-system-react-components.cjs.development.js +1021 -683
  9. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  10. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  11. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  12. package/dist/design-system-react-components.esm.js +1022 -684
  13. package/dist/design-system-react-components.esm.js.map +1 -1
  14. package/dist/theme/components/button.d.ts +1 -0
  15. package/dist/theme/components/card.d.ts +98 -13
  16. package/dist/theme/components/checkboxGroup.d.ts +1 -1
  17. package/dist/theme/components/global.d.ts +1 -1
  18. package/dist/theme/components/heading.d.ts +4 -16
  19. package/dist/theme/components/image.d.ts +6 -0
  20. package/dist/theme/components/radioGroup.d.ts +1 -1
  21. package/dist/theme/components/skipNavigation.d.ts +3 -0
  22. package/dist/theme/components/structuredContent.d.ts +0 -5
  23. package/dist/utils/utils.d.ts +15 -0
  24. package/package.json +6 -6
  25. package/src/components/Accordion/Accordion.stories.mdx +18 -46
  26. package/src/components/Accordion/Accordion.tsx +3 -2
  27. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +12 -12
  28. package/src/components/Button/Button.stories.mdx +1 -1
  29. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +33 -2
  30. package/src/components/ButtonGroup/ButtonGroup.tsx +2 -1
  31. package/src/components/Card/Card.stories.mdx +2 -4
  32. package/src/components/Card/Card.tsx +2 -1
  33. package/src/components/Chakra/Box.stories.mdx +1 -1
  34. package/src/components/Chakra/Center.stories.mdx +1 -1
  35. package/src/components/Chakra/Flex.stories.mdx +1 -1
  36. package/src/components/Chakra/Grid.stories.mdx +1 -1
  37. package/src/components/Chakra/Stack.stories.mdx +1 -1
  38. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  39. package/src/components/Checkbox/Checkbox.test.tsx +42 -11
  40. package/src/components/Checkbox/Checkbox.tsx +25 -39
  41. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +589 -544
  42. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +1 -1
  43. package/src/components/CheckboxGroup/CheckboxGroup.tsx +1 -1
  44. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1540 -1420
  45. package/src/components/ComponentWrapper/ComponentWrapper.tsx +12 -3
  46. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +5 -0
  47. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +36 -17
  48. package/src/components/Grid/SimpleGrid.stories.mdx +1 -3
  49. package/src/components/Heading/Heading.stories.mdx +4 -1
  50. package/src/components/Heading/Heading.tsx +4 -1
  51. package/src/components/Image/Image.stories.mdx +1 -1
  52. package/src/components/Logo/Logo.stories.mdx +10 -5
  53. package/src/components/Logo/Logo.tsx +4 -0
  54. package/src/components/Logo/LogoSvgs.tsx +8 -0
  55. package/src/components/Modal/Modal.stories.mdx +83 -90
  56. package/src/components/Pagination/Pagination.stories.mdx +1 -1
  57. package/src/components/Radio/Radio.stories.mdx +1 -1
  58. package/src/components/Radio/Radio.tsx +22 -31
  59. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +405 -365
  60. package/src/components/RadioGroup/RadioGroup.stories.mdx +2 -1
  61. package/src/components/RadioGroup/RadioGroup.tsx +2 -1
  62. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1116
  63. package/src/components/SearchBar/SearchBar.stories.mdx +3 -3
  64. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +32 -10
  65. package/src/components/Select/Select.stories.mdx +1 -1
  66. package/src/components/Select/Select.tsx +24 -22
  67. package/src/components/Select/__snapshots__/Select.test.tsx.snap +21 -11
  68. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +2 -2
  69. package/src/components/Slider/Slider.stories.mdx +1 -1
  70. package/src/components/Slider/Slider.tsx +14 -14
  71. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +66 -33
  72. package/src/components/StyleGuide/Buttons.stories.mdx +1 -1
  73. package/src/components/StyleGuide/Colors.stories.mdx +2 -2
  74. package/src/components/StyleGuide/Forms.stories.mdx +2 -1
  75. package/src/components/StyleGuide/Iconography.stories.mdx +2 -2
  76. package/src/components/StyleGuide/Spacing.stories.mdx +1 -1
  77. package/src/components/StyleGuide/Typography.stories.mdx +1 -1
  78. package/src/components/Table/Table.stories.mdx +1 -5
  79. package/src/components/Table/Table.test.tsx +33 -0
  80. package/src/components/Table/Table.tsx +21 -0
  81. package/src/components/Template/Template.stories.mdx +9 -5
  82. package/src/components/TextInput/TextInput.stories.mdx +1 -1
  83. package/src/components/TextInput/TextInput.tsx +21 -21
  84. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +19 -9
  85. package/src/components/Toggle/Toggle.stories.mdx +1 -1
  86. package/src/components/Toggle/Toggle.tsx +22 -20
  87. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +400 -372
  88. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +1 -0
  89. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +5 -0
  90. package/src/docs/Chakra.stories.mdx +2 -2
  91. package/src/theme/components/button.ts +1 -0
  92. package/src/theme/components/card.ts +9 -3
  93. package/src/theme/components/componentWrapper.ts +1 -1
  94. package/src/theme/components/global.ts +1 -1
  95. package/src/theme/components/heading.ts +3 -3
  96. package/src/theme/components/image.ts +1 -0
  97. package/src/theme/components/skipNavigation.ts +3 -0
  98. package/src/theme/foundations/colors.ts +6 -9
  99. package/src/utils/utils.ts +40 -0
@@ -2,7 +2,8 @@
2
2
 
3
3
  exports[`UI Snapshots renders the text input UI snapshot correctly 1`] = `
4
4
  <div
5
- className="css-1xdhyk6"
5
+ className="css-1u8qly9"
6
+ id="myTextInput-wrapper"
6
7
  >
7
8
  <label
8
9
  className="css-1xdhyk6"
@@ -31,7 +32,8 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 1`] = `
31
32
 
32
33
  exports[`UI Snapshots renders the text input UI snapshot correctly 2`] = `
33
34
  <div
34
- className="css-1xdhyk6"
35
+ className="css-1u8qly9"
36
+ id="myTextInput-wrapper"
35
37
  >
36
38
  <label
37
39
  className="css-1xdhyk6"
@@ -56,7 +58,8 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 2`] = `
56
58
 
57
59
  exports[`UI Snapshots renders the text input UI snapshot correctly 3`] = `
58
60
  <div
59
- className="css-1xdhyk6"
61
+ className="css-1u8qly9"
62
+ id="myTextInput-wrapper"
60
63
  >
61
64
  <input
62
65
  aria-label="Custom Input Label"
@@ -76,7 +79,8 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 3`] = `
76
79
 
77
80
  exports[`UI Snapshots renders the text input UI snapshot correctly 4`] = `
78
81
  <div
79
- className="css-1xdhyk6"
82
+ className="css-1u8qly9"
83
+ id="myTextInput-wrapper"
80
84
  >
81
85
  <label
82
86
  className="css-1xdhyk6"
@@ -118,7 +122,8 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 4`] = `
118
122
 
119
123
  exports[`UI Snapshots renders the text input UI snapshot correctly 5`] = `
120
124
  <div
121
- className="css-1xdhyk6"
125
+ className="css-1u8qly9"
126
+ id="myTextInput-wrapper"
122
127
  >
123
128
  <label
124
129
  className="css-1xdhyk6"
@@ -131,6 +136,7 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 5`] = `
131
136
  </span>
132
137
  </label>
133
138
  <input
139
+ aria-describedby="myTextInput-helperText"
134
140
  aria-invalid={true}
135
141
  aria-required={true}
136
142
  className="chakra-input css-0"
@@ -160,7 +166,8 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 5`] = `
160
166
 
161
167
  exports[`UI Snapshots renders the text input UI snapshot correctly 6`] = `
162
168
  <div
163
- className="css-1xdhyk6"
169
+ className="css-1u8qly9"
170
+ id="myTextInput-wrapper"
164
171
  >
165
172
  <label
166
173
  className="css-1xdhyk6"
@@ -189,7 +196,8 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 6`] = `
189
196
 
190
197
  exports[`UI Snapshots renders the text input UI snapshot correctly 7`] = `
191
198
  <div
192
- className="css-kle7zy"
199
+ className="css-1y4kn3e"
200
+ id="chakra-wrapper"
193
201
  >
194
202
  <label
195
203
  className="css-1xdhyk6"
@@ -214,8 +222,9 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 7`] = `
214
222
 
215
223
  exports[`UI Snapshots renders the text input UI snapshot correctly 8`] = `
216
224
  <div
217
- className="css-1xdhyk6"
225
+ className="css-1u8qly9"
218
226
  data-testid="props"
227
+ id="props-wrapper"
219
228
  >
220
229
  <label
221
230
  className="css-1xdhyk6"
@@ -241,7 +250,8 @@ exports[`UI Snapshots renders the text input UI snapshot correctly 8`] = `
241
250
 
242
251
  exports[`UI Snapshots renders the textarea UI snapshot correctly 1`] = `
243
252
  <div
244
- className="css-1xdhyk6"
253
+ className="css-1u8qly9"
254
+ id="myTextarea-wrapper"
245
255
  >
246
256
  <label
247
257
  className="css-1xdhyk6"
@@ -45,7 +45,7 @@ import DSProvider from "../../theme/provider";
45
45
  | Component Version | DS Version |
46
46
  | ----------------- | ---------- |
47
47
  | Added | `0.25.8` |
48
- | Latest | `0.28.0` |
48
+ | Latest | `1.0.2` |
49
49
 
50
50
  ## Table of Contents
51
51
 
@@ -7,10 +7,9 @@ import {
7
7
  } from "@chakra-ui/react";
8
8
  import * as React from "react";
9
9
 
10
- import HelperErrorText, {
11
- HelperErrorTextType,
12
- } from "../HelperErrorText/HelperErrorText";
13
- import { AriaAttributes } from "../../utils/interfaces";
10
+ import ComponentWrapper from "../ComponentWrapper/ComponentWrapper";
11
+ import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
12
+ import { getAriaAttrs } from "../../utils/utils";
14
13
 
15
14
  export type ToggleSizes = "default" | "small";
16
15
  export interface ToggleProps {
@@ -71,12 +70,16 @@ export const Toggle = chakra(
71
70
  size = "default",
72
71
  ...rest
73
72
  } = props;
74
- const footnote = isInvalid ? invalidText : helperText;
75
- const ariaAttributes: AriaAttributes = {};
76
73
  const styles = useMultiStyleConfig("Toggle", { isDisabled, size });
77
74
  const switchStyles = useStyleConfig("Switch", { size });
78
- ariaAttributes["aria-label"] =
79
- labelText && footnote ? `${labelText} - ${footnote}` : labelText;
75
+ const footnote = isInvalid ? invalidText : helperText;
76
+ const ariaAttributes = getAriaAttrs({
77
+ footnote,
78
+ id,
79
+ labelText,
80
+ name: "Toggle",
81
+ showLabel: true,
82
+ });
80
83
 
81
84
  if (!id) {
82
85
  console.warn(
@@ -85,14 +88,21 @@ export const Toggle = chakra(
85
88
  }
86
89
 
87
90
  return (
88
- <>
89
- <Box __css={styles} {...rest}>
91
+ <ComponentWrapper
92
+ helperText={helperText}
93
+ helperTextStyles={styles.helperErrorText}
94
+ id={id}
95
+ invalidText={invalidText}
96
+ isInvalid={isInvalid}
97
+ {...rest}
98
+ >
99
+ <Box __css={styles}>
90
100
  <Switch
91
101
  id={id}
92
- name={name || "default"}
93
102
  isDisabled={isDisabled}
94
103
  isInvalid={isInvalid}
95
104
  isRequired={isRequired}
105
+ name={name || "default"}
96
106
  ref={ref}
97
107
  size={size === "default" ? "lg" : "sm"}
98
108
  lineHeight="1.5"
@@ -110,15 +120,7 @@ export const Toggle = chakra(
110
120
  {labelText}
111
121
  </Switch>
112
122
  </Box>
113
- {footnote && (
114
- <HelperErrorText
115
- id={`${id}-helperText`}
116
- isInvalid={isInvalid}
117
- text={footnote}
118
- __css={styles.helperErrorText}
119
- />
120
- )}
121
- </>
123
+ </ComponentWrapper>
122
124
  );
123
125
  })
124
126
  );