@nypl/design-system-react-components 0.25.2 → 0.25.6

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 (238) hide show
  1. package/CHANGELOG.md +101 -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 -8
  6. package/dist/components/Button/ButtonTypes.d.ts +2 -1
  7. package/dist/components/Card/Card.d.ts +36 -52
  8. package/dist/components/Card/CardTypes.d.ts +0 -15
  9. package/dist/components/Checkbox/Checkbox.d.ts +8 -9
  10. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
  11. package/dist/components/DatePicker/DatePicker.d.ts +36 -36
  12. package/dist/components/Fieldset/Fieldset.d.ts +25 -0
  13. package/dist/components/HelperErrorText/HelperErrorText.d.ts +4 -0
  14. package/dist/components/HorizontalRule/HorizontalRule.d.ts +10 -3
  15. package/dist/components/Icons/Icon.d.ts +4 -0
  16. package/dist/components/Icons/IconSvgs.d.ts +11 -0
  17. package/dist/components/Icons/IconTypes.d.ts +11 -0
  18. package/dist/components/Image/Image.d.ts +19 -9
  19. package/dist/components/Image/ImageTypes.d.ts +20 -0
  20. package/dist/components/Link/Link.d.ts +4 -0
  21. package/dist/components/List/List.d.ts +7 -1
  22. package/dist/components/Notification/Notification.d.ts +6 -4
  23. package/dist/components/Pagination/Pagination.d.ts +16 -13
  24. package/dist/components/Pagination/Pagination.stories.d.ts +2 -0
  25. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
  26. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
  27. package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
  28. package/dist/components/SearchBar/SearchBar.d.ts +3 -3
  29. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +18 -14
  30. package/dist/components/Slider/Slider.d.ts +57 -0
  31. package/dist/components/Tabs/Tabs.d.ts +1 -1
  32. package/dist/components/TextInput/TextInput.d.ts +10 -0
  33. package/dist/design-system-react-components.cjs.development.js +3058 -936
  34. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  35. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  36. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  37. package/dist/design-system-react-components.esm.js +3049 -921
  38. package/dist/design-system-react-components.esm.js.map +1 -1
  39. package/dist/index.d.ts +12 -6
  40. package/dist/resources.scss +180 -170
  41. package/dist/styles.css +1 -1
  42. package/dist/theme/components/breadcrumb.d.ts +9 -0
  43. package/dist/theme/components/button.d.ts +22 -8
  44. package/dist/theme/components/card.d.ts +168 -0
  45. package/dist/theme/components/checkbox.d.ts +5 -1
  46. package/dist/theme/components/checkboxGroup.d.ts +12 -0
  47. package/dist/theme/components/datePicker.d.ts +16 -0
  48. package/dist/theme/components/fieldset.d.ts +27 -0
  49. package/dist/theme/components/global.d.ts +23 -13
  50. package/dist/theme/components/globalMixins.d.ts +9 -1
  51. package/dist/theme/components/heading.d.ts +5 -0
  52. package/dist/theme/components/image.d.ts +31 -0
  53. package/dist/theme/components/label.d.ts +5 -3
  54. package/dist/theme/components/link.d.ts +4 -0
  55. package/dist/theme/components/list.d.ts +5 -1
  56. package/dist/theme/components/notification.d.ts +4 -14
  57. package/dist/theme/components/pagination.d.ts +19 -0
  58. package/dist/theme/components/progressIndicator.d.ts +50 -0
  59. package/dist/theme/components/radioGroup.d.ts +12 -0
  60. package/dist/theme/components/select.d.ts +11 -2
  61. package/dist/theme/components/skeletonLoader.d.ts +98 -0
  62. package/dist/theme/components/slider.d.ts +51 -0
  63. package/dist/theme/components/textInput.d.ts +8 -0
  64. package/dist/theme/foundations/breakpoints.d.ts +8 -8
  65. package/dist/theme/foundations/global.d.ts +6 -1
  66. package/package.json +72 -84
  67. package/src/__tests__/setup.ts +2 -2
  68. package/src/components/Accordion/Accordion.stories.mdx +39 -42
  69. package/src/components/Autosuggest/Autosuggest.stories.mdx +3 -3
  70. package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -0
  71. package/src/components/Autosuggest/_Autosuggest.scss +5 -5
  72. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +24 -8
  73. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +33 -0
  74. package/src/components/Breadcrumbs/Breadcrumbs.tsx +5 -1
  75. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
  76. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +298 -1
  77. package/src/components/Button/Button.stories.mdx +15 -10
  78. package/src/components/Button/Button.test.tsx +21 -7
  79. package/src/components/Button/Button.tsx +18 -33
  80. package/src/components/Button/ButtonTypes.tsx +1 -0
  81. package/src/components/Button/__snapshots__/Button.test.tsx.snap +41 -10
  82. package/src/components/Card/Card.stories.mdx +296 -259
  83. package/src/components/Card/Card.test.tsx +156 -84
  84. package/src/components/Card/Card.tsx +195 -145
  85. package/src/components/Card/CardTypes.tsx +0 -17
  86. package/src/components/Card/__snapshots__/Card.test.tsx.snap +410 -0
  87. package/src/components/CardEdition/CardEdition.stories.tsx +15 -47
  88. package/src/components/CardEdition/_CardEdition.scss +22 -23
  89. package/src/components/Chakra/Box.stories.mdx +14 -15
  90. package/src/components/Chakra/Center.stories.mdx +15 -8
  91. package/src/components/Chakra/Grid.stories.mdx +16 -7
  92. package/src/components/Chakra/Stack.stories.mdx +35 -18
  93. package/src/components/Checkbox/Checkbox.stories.mdx +33 -11
  94. package/src/components/Checkbox/Checkbox.test.tsx +30 -3
  95. package/src/components/Checkbox/Checkbox.tsx +27 -27
  96. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +90 -2
  97. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +82 -2
  98. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -1
  99. package/src/components/CheckboxGroup/CheckboxGroup.tsx +14 -15
  100. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +44 -80
  101. package/src/components/DatePicker/DatePicker.stories.mdx +163 -62
  102. package/src/components/DatePicker/DatePicker.test.tsx +248 -65
  103. package/src/components/DatePicker/DatePicker.tsx +158 -130
  104. package/src/components/DatePicker/_DatePicker.scss +33 -67
  105. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +818 -0
  106. package/src/components/Fieldset/Fieldset.stories.mdx +55 -0
  107. package/src/components/Fieldset/Fieldset.test.tsx +125 -0
  108. package/src/components/Fieldset/Fieldset.tsx +52 -0
  109. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +68 -0
  110. package/src/components/Form/Form.stories.mdx +4 -5
  111. package/src/components/Form/Form.tsx +1 -0
  112. package/src/components/Grid/SimpleGrid.stories.mdx +32 -39
  113. package/src/components/Grid/SimpleGrid.test.tsx +4 -4
  114. package/src/components/Heading/Heading.stories.mdx +3 -4
  115. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -1
  116. package/src/components/HelperErrorText/HelperErrorText.tsx +5 -1
  117. package/src/components/Hero/HeroTypes.tsx +1 -0
  118. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +7 -7
  119. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +6 -5
  120. package/src/components/HorizontalRule/HorizontalRule.test.tsx +17 -0
  121. package/src/components/HorizontalRule/HorizontalRule.tsx +21 -4
  122. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +5 -5
  123. package/src/components/Icons/Icon.stories.mdx +11 -3
  124. package/src/components/Icons/Icon.test.tsx +18 -0
  125. package/src/components/Icons/Icon.tsx +6 -0
  126. package/src/components/Icons/IconSvgs.tsx +22 -0
  127. package/src/components/Icons/IconTypes.tsx +11 -0
  128. package/src/components/Image/Image.stories.mdx +220 -0
  129. package/src/components/Image/Image.test.tsx +131 -29
  130. package/src/components/Image/Image.tsx +84 -56
  131. package/src/components/Image/ImageTypes.ts +22 -0
  132. package/src/components/Image/__snapshots__/Image.test.tsx.snap +190 -0
  133. package/src/components/Input/Input.stories.tsx +20 -64
  134. package/src/components/Input/_Input.scss +23 -14
  135. package/src/components/Link/Link.tsx +4 -1
  136. package/src/components/List/List.stories.mdx +1 -1
  137. package/src/components/List/List.tsx +11 -4
  138. package/src/components/Modal/Modal.stories.mdx +3 -3
  139. package/src/components/Modal/_Modal.scss +2 -2
  140. package/src/components/Notification/Notification.stories.mdx +1 -3
  141. package/src/components/Notification/Notification.tsx +24 -9
  142. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +2 -0
  143. package/src/components/Pagination/Pagination.stories.mdx +26 -27
  144. package/src/components/Pagination/Pagination.stories.tsx +11 -16
  145. package/src/components/Pagination/Pagination.test.tsx +276 -146
  146. package/src/components/Pagination/Pagination.tsx +174 -154
  147. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +285 -0
  148. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
  149. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
  150. package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
  151. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
  152. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
  153. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
  154. package/src/components/RadioGroup/RadioGroup.stories.mdx +3 -4
  155. package/src/components/RadioGroup/RadioGroup.tsx +11 -16
  156. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +39 -71
  157. package/src/components/SearchBar/SearchBar.Test.tsx +66 -21
  158. package/src/components/SearchBar/SearchBar.stories.mdx +114 -10
  159. package/src/components/SearchBar/SearchBar.tsx +15 -5
  160. package/src/components/Select/SelectTypes.tsx +1 -0
  161. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +28 -59
  162. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +97 -177
  163. package/src/components/SkeletonLoader/SkeletonLoader.tsx +74 -71
  164. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +739 -0
  165. package/src/components/Slider/Slider.stories.mdx +529 -0
  166. package/src/components/Slider/Slider.test.tsx +653 -0
  167. package/src/components/Slider/Slider.tsx +303 -0
  168. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
  169. package/src/components/StyleGuide/Bidirectionality.stories.mdx +1 -1
  170. package/src/components/StyleGuide/Breakpoints.stories.mdx +21 -7
  171. package/src/components/StyleGuide/Buttons.stories.mdx +69 -15
  172. package/src/components/StyleGuide/ColorCard.tsx +0 -1
  173. package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
  174. package/src/components/StyleGuide/Iconography.stories.mdx +51 -62
  175. package/src/components/Tabs/Tabs.tsx +5 -5
  176. package/src/components/Template/Template.stories.mdx +11 -16
  177. package/src/components/TextInput/TextInput.stories.mdx +1 -1
  178. package/src/components/TextInput/TextInput.tsx +23 -6
  179. package/src/components/TextInput/TextInputTypes.tsx +2 -0
  180. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -3
  181. package/src/docs/Chakra.stories.mdx +2 -2
  182. package/src/index.ts +20 -12
  183. package/src/resources.scss +5 -5
  184. package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
  185. package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
  186. package/src/styles/base/{_04-base.scss → _03-base.scss} +7 -2
  187. package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
  188. package/src/styles/base/_place-holder.scss +14 -3
  189. package/src/styles/{03-space → space}/_space-inline.scss +14 -14
  190. package/src/styles/{03-space → space}/_space-inset.scss +10 -10
  191. package/src/styles/space/_space-stack.scss +116 -0
  192. package/src/styles.scss +13 -55
  193. package/src/theme/components/breadcrumb.ts +10 -0
  194. package/src/theme/components/button.ts +18 -12
  195. package/src/theme/components/card.ts +174 -0
  196. package/src/theme/components/checkbox.ts +7 -2
  197. package/src/theme/components/checkboxGroup.ts +8 -0
  198. package/src/theme/components/datePicker.ts +17 -0
  199. package/src/theme/components/fieldset.ts +18 -0
  200. package/src/theme/components/global.ts +26 -15
  201. package/src/theme/components/globalMixins.ts +9 -1
  202. package/src/theme/components/heading.ts +5 -0
  203. package/src/theme/components/image.ts +116 -0
  204. package/src/theme/components/label.ts +3 -10
  205. package/src/theme/components/link.ts +4 -0
  206. package/src/theme/components/list.ts +6 -3
  207. package/src/theme/components/notification.ts +12 -14
  208. package/src/theme/components/pagination.ts +20 -0
  209. package/src/theme/components/progressIndicator.ts +62 -0
  210. package/src/theme/components/radioGroup.ts +8 -0
  211. package/src/theme/components/select.ts +5 -2
  212. package/src/theme/components/skeletonLoader.ts +107 -0
  213. package/src/theme/components/slider.ts +79 -0
  214. package/src/theme/components/textInput.ts +2 -0
  215. package/src/theme/foundations/breakpoints.ts +8 -8
  216. package/src/theme/foundations/global.ts +6 -1
  217. package/src/theme/index.ts +22 -4
  218. package/src/utils/componentCategories.ts +4 -3
  219. package/dist/components/Image/Image.stories.d.ts +0 -18
  220. package/dist/theme/components/customCheckboxGroup.d.ts +0 -18
  221. package/dist/theme/components/customRadioGroup.d.ts +0 -18
  222. package/src/components/Button/_Button.scss +0 -32
  223. package/src/components/Card/_Card.scss +0 -308
  224. package/src/components/Image/Image.stories.tsx +0 -54
  225. package/src/components/Image/_Image.scss +0 -38
  226. package/src/components/Pagination/_Pagination.scss +0 -40
  227. package/src/components/SkeletonLoader/_SkeletonLoader.scss +0 -142
  228. package/src/styles/01-colors/_colors-brand.scss +0 -62
  229. package/src/styles/01-colors/_colors-utility.scss +0 -67
  230. package/src/styles/02-typography/_type-scale.css +0 -11
  231. package/src/styles/02-typography/_type-weight.css +0 -7
  232. package/src/styles/02-typography/_typefaces.css +0 -4
  233. package/src/styles/03-space/_space-stack.scss +0 -116
  234. package/src/styles/03-space/_space.css +0 -30
  235. package/src/styles/base/_card-grid.scss +0 -77
  236. package/src/styles/base/_typography.scss +0 -11
  237. package/src/theme/components/customCheckboxGroup.ts +0 -12
  238. package/src/theme/components/customRadioGroup.ts +0 -12
@@ -0,0 +1,55 @@
1
+ import {
2
+ Meta,
3
+ Story,
4
+ Canvas,
5
+ ArgsTable,
6
+ Description,
7
+ } from "@storybook/addon-docs/blocks";
8
+ import { withDesign } from "storybook-addon-designs";
9
+
10
+ import Fieldset from "./Fieldset";
11
+ import { getCategory } from "../../utils/componentCategories";
12
+ import DSProvider from "../../theme/provider";
13
+
14
+ <Meta
15
+ title={getCategory("Fieldset")}
16
+ component={Fieldset}
17
+ decorators={[withDesign]}
18
+ parameters={{
19
+ jest: ["Fieldset.test.tsx"],
20
+ }}
21
+ argTypes={{
22
+ children: { table: { disable: true } },
23
+ className: { table: { disable: true } },
24
+ id: { table: { disable: true } },
25
+ }}
26
+ />
27
+
28
+ # Fieldset
29
+
30
+ | Component Version | DS Version |
31
+ | ----------------- | ---------- |
32
+ | Added | `0.25.3` |
33
+ | Latest | `0.25.3` |
34
+
35
+ <Description of={Fieldset} />
36
+
37
+ <Canvas withToolbar>
38
+ <Story
39
+ name="Basic"
40
+ args={{
41
+ isLegendHidden: false,
42
+ isRequired: false,
43
+ legendText: "This is the legend text",
44
+ optReqFlag: true,
45
+ }}
46
+ >
47
+ {(args) => (
48
+ <Fieldset {...args}>
49
+ <p>Text children in the Fieldset component.</p>
50
+ </Fieldset>
51
+ )}
52
+ </Story>
53
+ </Canvas>
54
+
55
+ <ArgsTable story="Basic" />
@@ -0,0 +1,125 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import { axe } from "jest-axe";
4
+ import renderer from "react-test-renderer";
5
+
6
+ import Fieldset from "./Fieldset";
7
+
8
+ describe("Fieldset Accessibility", () => {
9
+ it("passes axe accessibility", async () => {
10
+ const { container } = render(
11
+ <Fieldset legendText="Legend Text">
12
+ <p>Some other fields</p>
13
+ </Fieldset>
14
+ );
15
+ expect(await axe(container)).toHaveNoViolations();
16
+ });
17
+
18
+ it("passes axe accessibility with the legend hidden", async () => {
19
+ const { container } = render(
20
+ <Fieldset legendText="Legend Text" isLegendHidden>
21
+ <p>Some other fields</p>
22
+ </Fieldset>
23
+ );
24
+ expect(await axe(container)).toHaveNoViolations();
25
+ });
26
+ });
27
+
28
+ describe("Fieldset", () => {
29
+ it("renders text in a legend and fieldset along with its children", () => {
30
+ render(
31
+ <Fieldset legendText="Legend Text">
32
+ <p>Some other fields</p>
33
+ </Fieldset>
34
+ );
35
+
36
+ expect(screen.getByRole("group")).toBeInTheDocument();
37
+ // `legend` has no HTML role
38
+ expect(screen.getByText(/Legend Text/i)).toBeInTheDocument();
39
+ expect(screen.getByText("Some other fields")).toBeInTheDocument();
40
+ });
41
+
42
+ it("renders 'Optional' text by default in the legend", () => {
43
+ render(
44
+ <Fieldset legendText="Legend Text">
45
+ <p>Some other fields</p>
46
+ </Fieldset>
47
+ );
48
+
49
+ expect(screen.getByText(/Optional/i)).toBeInTheDocument();
50
+ });
51
+
52
+ it("renders 'Required' text in the legend", () => {
53
+ render(
54
+ <Fieldset legendText="Legend Text" isRequired>
55
+ <p>Some other fields</p>
56
+ </Fieldset>
57
+ );
58
+
59
+ expect(screen.getByText(/Required/i)).toBeInTheDocument();
60
+ });
61
+
62
+ it("can hide the 'Required'/'Optional' text in the legend but still show the main text", () => {
63
+ const { rerender } = render(
64
+ <Fieldset legendText="Legend Text" isRequired>
65
+ <p>Some other fields</p>
66
+ </Fieldset>
67
+ );
68
+
69
+ expect(screen.getByText(/Required/i)).toBeInTheDocument();
70
+
71
+ rerender(
72
+ <Fieldset legendText="Legend Text" optReqFlag={false}>
73
+ <p>Some other fields</p>
74
+ </Fieldset>
75
+ );
76
+
77
+ expect(screen.getByText(/Legend Text/i)).toBeInTheDocument();
78
+ expect(screen.queryByText(/Optional/i)).not.toBeInTheDocument();
79
+
80
+ rerender(
81
+ <Fieldset legendText="Legend Text" isRequired optReqFlag={false}>
82
+ <p>Some other fields</p>
83
+ </Fieldset>
84
+ );
85
+
86
+ expect(screen.getByText(/Legend Text/i)).toBeInTheDocument();
87
+ expect(screen.queryByText(/Required/i)).not.toBeInTheDocument();
88
+ });
89
+
90
+ it("renders the UI snapshot correctly", () => {
91
+ const basic = renderer
92
+ .create(
93
+ <Fieldset legendText="Legend Text">
94
+ <p>Some other fields</p>
95
+ </Fieldset>
96
+ )
97
+ .toJSON();
98
+ const required = renderer
99
+ .create(
100
+ <Fieldset legendText="Legend Text" isRequired>
101
+ <p>Some other fields</p>
102
+ </Fieldset>
103
+ )
104
+ .toJSON();
105
+ const hiddenHelperText = renderer
106
+ .create(
107
+ <Fieldset legendText="Legend Text" isRequired optReqFlag={false}>
108
+ <p>Some other fields</p>
109
+ </Fieldset>
110
+ )
111
+ .toJSON();
112
+ const hiddenLegend = renderer
113
+ .create(
114
+ <Fieldset legendText="Legend Text" isLegendHidden>
115
+ <p>Some other fields</p>
116
+ </Fieldset>
117
+ )
118
+ .toJSON();
119
+
120
+ expect(basic).toMatchSnapshot();
121
+ expect(required).toMatchSnapshot();
122
+ expect(hiddenHelperText).toMatchSnapshot();
123
+ expect(hiddenLegend).toMatchSnapshot();
124
+ });
125
+ });
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import { Box, useMultiStyleConfig } from "@chakra-ui/react";
3
+
4
+ interface FieldsetProps {
5
+ /** Children to render. Typically form-related components are used. */
6
+ children: React.ReactNode;
7
+ /** Additional class name to add. */
8
+ className?: string;
9
+ /** ID that other components can cross reference for accessibility purposes */
10
+ id?: string;
11
+ /** Flag to show or hide the text in the `legend` element. False by default. */
12
+ isLegendHidden?: boolean;
13
+ /** Flag to render "Required" or "Optional" in the `legend`.
14
+ * False/"Optional" by default. */
15
+ isRequired?: boolean;
16
+ /** Text to display in the `legend` element. */
17
+ legendText?: string;
18
+ /** Flag to show or hide the "Required"/"Optional" text in the `legend`.
19
+ * True by default. */
20
+ optReqFlag?: boolean;
21
+ }
22
+
23
+ /**
24
+ * A wrapper component that renders a `fieldset` element along with a `legend`
25
+ * element as its first child. Commonly used to wrap form components.
26
+ */
27
+ const Fieldset: React.FC<FieldsetProps> = ({
28
+ children,
29
+ className,
30
+ id,
31
+ isLegendHidden = false,
32
+ isRequired = false,
33
+ legendText,
34
+ optReqFlag = true,
35
+ }) => {
36
+ const styles = useMultiStyleConfig("Fieldset", { isLegendHidden });
37
+ return (
38
+ <Box as="fieldset" id={id} __css={styles} className={className}>
39
+ <legend>
40
+ {legendText}
41
+ {optReqFlag && (
42
+ <Box __css={styles.helper}>
43
+ {isRequired ? "Required" : "Optional"}
44
+ </Box>
45
+ )}
46
+ </legend>
47
+ {children}
48
+ </Box>
49
+ );
50
+ };
51
+
52
+ export default Fieldset;
@@ -0,0 +1,68 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Fieldset renders the UI snapshot correctly 1`] = `
4
+ <fieldset
5
+ className="css-0"
6
+ >
7
+ <legend>
8
+ Legend Text
9
+ <div
10
+ className="css-0"
11
+ >
12
+ Optional
13
+ </div>
14
+ </legend>
15
+ <p>
16
+ Some other fields
17
+ </p>
18
+ </fieldset>
19
+ `;
20
+
21
+ exports[`Fieldset renders the UI snapshot correctly 2`] = `
22
+ <fieldset
23
+ className="css-0"
24
+ >
25
+ <legend>
26
+ Legend Text
27
+ <div
28
+ className="css-0"
29
+ >
30
+ Required
31
+ </div>
32
+ </legend>
33
+ <p>
34
+ Some other fields
35
+ </p>
36
+ </fieldset>
37
+ `;
38
+
39
+ exports[`Fieldset renders the UI snapshot correctly 3`] = `
40
+ <fieldset
41
+ className="css-0"
42
+ >
43
+ <legend>
44
+ Legend Text
45
+ </legend>
46
+ <p>
47
+ Some other fields
48
+ </p>
49
+ </fieldset>
50
+ `;
51
+
52
+ exports[`Fieldset renders the UI snapshot correctly 4`] = `
53
+ <fieldset
54
+ className="css-0"
55
+ >
56
+ <legend>
57
+ Legend Text
58
+ <div
59
+ className="css-0"
60
+ >
61
+ Optional
62
+ </div>
63
+ </legend>
64
+ <p>
65
+ Some other fields
66
+ </p>
67
+ </fieldset>
68
+ `;
@@ -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";
@@ -57,7 +56,7 @@ The `Form` component renders a standard `<form>` element and should be used to h
57
56
 
58
57
  `FormRow` should be used as a parent of multiple `FormField` components when you need to render multiple input components in a horizontal row.
59
58
 
60
- <Preview withToolbar>
59
+ <Canvas withToolbar>
61
60
  <Story
62
61
  name="Form"
63
62
  args={{
@@ -187,7 +186,7 @@ The `Form` component renders a standard `<form>` element and should be used to h
187
186
  </Form>
188
187
  )}
189
188
  </Story>
190
- </Preview>
189
+ </Canvas>
191
190
 
192
191
  <ArgsTable story="Form" />
193
192
 
@@ -254,7 +253,7 @@ By default, the `Form` component will handle the NYPL spacing around form input
254
253
 
255
254
  Below are the spacing variants available with the `FormSpacing` enum.
256
255
 
257
- <Preview>
256
+ <Canvas>
258
257
  <Story
259
258
  name="Spacing Variants"
260
259
  args={{
@@ -263,7 +262,7 @@ Below are the spacing variants available with the `FormSpacing` enum.
263
262
  >
264
263
  {getForms(sizes)}
265
264
  </Story>
266
- </Preview>
265
+ </Canvas>
267
266
 
268
267
  ## Example Code
269
268
 
@@ -33,6 +33,7 @@ export function FormRow(props: React.PropsWithChildren<FormChildProps>) {
33
33
  const alteredChildren = React.Children.map(
34
34
  children,
35
35
  (child: React.ReactElement, i) => {
36
+ if (!child) return null;
36
37
  return React.cloneElement(child, { id: `${id}-grandchild${i}` });
37
38
  }
38
39
  );
@@ -8,17 +8,8 @@ import {
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
10
  import SimpleGrid from "./SimpleGrid";
11
- import Card, {
12
- CardImage,
13
- CardHeading,
14
- CardContent,
15
- CardActions,
16
- } from "../Card/Card";
17
- import {
18
- CardImageRatios,
19
- CardImageSizes,
20
- CardLayouts,
21
- } from "../Card/CardTypes";
11
+ import Card, { CardHeading, CardContent, CardActions } from "../Card/Card";
12
+ import { CardLayouts } from "../Card/CardTypes";
22
13
  import { HeadingDisplaySizes, HeadingLevels } from "../Heading/HeadingTypes";
23
14
  import Icon from "../Icons/Icon";
24
15
  import {
@@ -28,6 +19,7 @@ import {
28
19
  IconRotationTypes,
29
20
  } from "../Icons/IconTypes";
30
21
  import Image from "../Image/Image";
22
+ import { ImageRatios } from "../Image/ImageTypes";
31
23
 
32
24
  import { getCategory } from "../../utils/componentCategories";
33
25
  import DSProvider from "../../theme/provider";
@@ -86,9 +78,9 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
86
78
  {(args) => (
87
79
  <SimpleGrid {...args}>
88
80
  <Card
89
- imageSrc="https://placeimg.com/500/200/animals"
81
+ imageSrc="https://placeimg.com/400/220/animals"
90
82
  imageAlt="Alt text"
91
- imageAspectRatio={CardImageRatios.TwoByOne}
83
+ imageAspectRatio={ImageRatios.TwoByOne}
92
84
  >
93
85
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
94
86
  <CardContent>
@@ -99,7 +91,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
99
91
  <Card
100
92
  imageSrc="https://placeimg.com/400/220/animals"
101
93
  imageAlt="Alt text"
102
- imageAspectRatio={CardImageRatios.TwoByOne}
94
+ imageAspectRatio={ImageRatios.TwoByOne}
103
95
  >
104
96
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
105
97
  <CardContent>
@@ -110,7 +102,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
110
102
  <Card
111
103
  imageSrc="https://placeimg.com/400/240/animals"
112
104
  imageAlt="Alt text"
113
- imageAspectRatio={CardImageRatios.TwoByOne}
105
+ imageAspectRatio={ImageRatios.TwoByOne}
114
106
  >
115
107
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
116
108
  <CardContent>
@@ -121,7 +113,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
121
113
  <Card
122
114
  imageSrc="https://placeimg.com/400/260/animals"
123
115
  imageAlt="Alt text"
124
- imageAspectRatio={CardImageRatios.TwoByOne}
116
+ imageAspectRatio={ImageRatios.TwoByOne}
125
117
  >
126
118
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
127
119
  <CardContent>
@@ -132,7 +124,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
132
124
  <Card
133
125
  imageSrc="https://placeimg.com/400/320/animals"
134
126
  imageAlt="Alt text"
135
- imageAspectRatio={CardImageRatios.TwoByOne}
127
+ imageAspectRatio={ImageRatios.TwoByOne}
136
128
  >
137
129
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
138
130
  <CardContent>
@@ -143,7 +135,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
143
135
  <Card
144
136
  imageSrc="https://placeimg.com/400/300/animals"
145
137
  imageAlt="Alt text"
146
- imageAspectRatio={CardImageRatios.TwoByOne}
138
+ imageAspectRatio={ImageRatios.TwoByOne}
147
139
  >
148
140
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
149
141
  <CardContent>
@@ -169,6 +161,7 @@ for (const icon in IconNames) {
169
161
  const iname = `Example icon: ${IconNames[icon]}`;
170
162
  const iconRender = (
171
163
  <Icon
164
+ key={icon}
172
165
  name={IconNames[icon]}
173
166
  size={IconSizes.ExtraExtraExtraLarge}
174
167
  titleText={iname}
@@ -190,24 +183,24 @@ This example is rendering square `Image` components with the `columns` prop set
190
183
  <Canvas>
191
184
  <DSProvider>
192
185
  <SimpleGrid columns={6}>
193
- <Image src="https://placeimg.com/300/300/animals?x=1" />
194
- <Image src="https://placeimg.com/300/300/animals?x=2" />
195
- <Image src="https://placeimg.com/300/300/animals?x=3" />
196
- <Image src="https://placeimg.com/300/300/animals?x=4" />
197
- <Image src="https://placeimg.com/300/300/animals?x=5" />
198
- <Image src="https://placeimg.com/300/300/animals?x=6" />
199
- <Image src="https://placeimg.com/300/300/animals?x=7" />
200
- <Image src="https://placeimg.com/300/300/animals?x=8" />
201
- <Image src="https://placeimg.com/300/300/animals?x=9" />
202
- <Image src="https://placeimg.com/300/300/animals?x=10" />
203
- <Image src="https://placeimg.com/300/300/animals?x=11" />
204
- <Image src="https://placeimg.com/300/300/animals?x=12" />
205
- <Image src="https://placeimg.com/300/300/animals?x=13" />
206
- <Image src="https://placeimg.com/300/300/animals?x=14" />
207
- <Image src="https://placeimg.com/300/300/animals?x=15" />
208
- <Image src="https://placeimg.com/300/300/animals?x=16" />
209
- <Image src="https://placeimg.com/300/300/animals?x=17" />
210
- <Image src="https://placeimg.com/300/300/animals?x=18" />
186
+ <Image src="https://placeimg.com/300/300/animals?x=1" alt="" />
187
+ <Image src="https://placeimg.com/300/300/animals?x=2" alt="" />
188
+ <Image src="https://placeimg.com/300/300/animals?x=3" alt="" />
189
+ <Image src="https://placeimg.com/300/300/animals?x=4" alt="" />
190
+ <Image src="https://placeimg.com/300/300/animals?x=5" alt="" />
191
+ <Image src="https://placeimg.com/300/300/animals?x=6" alt="" />
192
+ <Image src="https://placeimg.com/300/300/animals?x=7" alt="" />
193
+ <Image src="https://placeimg.com/300/300/animals?x=8" alt="" />
194
+ <Image src="https://placeimg.com/300/300/animals?x=9" alt="" />
195
+ <Image src="https://placeimg.com/300/300/animals?x=10" alt="" />
196
+ <Image src="https://placeimg.com/300/300/animals?x=11" alt="" />
197
+ <Image src="https://placeimg.com/300/300/animals?x=12" alt="" />
198
+ <Image src="https://placeimg.com/300/300/animals?x=13" alt="" />
199
+ <Image src="https://placeimg.com/300/300/animals?x=14" alt="" />
200
+ <Image src="https://placeimg.com/300/300/animals?x=15" alt="" />
201
+ <Image src="https://placeimg.com/300/300/animals?x=16" alt="" />
202
+ <Image src="https://placeimg.com/300/300/animals?x=17" alt="" />
203
+ <Image src="https://placeimg.com/300/300/animals?x=18" alt="" />
211
204
  </SimpleGrid>
212
205
  </DSProvider>
213
206
  </Canvas>
@@ -225,7 +218,7 @@ This example is rendering horizontal `Card` components with the `columns` prop s
225
218
  center
226
219
  imageSrc="https://placeimg.com/400/200/animals"
227
220
  imageAlt="Alt text"
228
- imageAspectRatio={CardImageRatios.FourByThree}
221
+ imageAspectRatio={ImageRatios.FourByThree}
229
222
  >
230
223
  <CardHeading level={HeadingLevels.Four} id="heading1">
231
224
  Card Heading
@@ -242,7 +235,7 @@ This example is rendering horizontal `Card` components with the `columns` prop s
242
235
  center
243
236
  imageSrc="https://placeimg.com/410/210/animals"
244
237
  imageAlt="Alt text"
245
- imageAspectRatio={CardImageRatios.FourByThree}
238
+ imageAspectRatio={ImageRatios.FourByThree}
246
239
  >
247
240
  <CardHeading level={HeadingLevels.Four} id="heading2">
248
241
  Card Heading
@@ -259,7 +252,7 @@ This example is rendering horizontal `Card` components with the `columns` prop s
259
252
  center
260
253
  imageSrc="https://placeimg.com/320/320/animals"
261
254
  imageAlt="Alt text"
262
- imageAspectRatio={CardImageRatios.FourByThree}
255
+ imageAspectRatio={ImageRatios.FourByThree}
263
256
  >
264
257
  <CardHeading level={HeadingLevels.Four} id="heading3">
265
258
  Card Heading
@@ -5,7 +5,7 @@ import renderer from "react-test-renderer";
5
5
 
6
6
  import SimpleGrid from "./SimpleGrid";
7
7
  import Card, { CardHeading, CardContent } from "../Card/Card";
8
- import { CardImageRatios } from "../Card/CardTypes";
8
+ import { ImageRatios } from "../Image/ImageTypes";
9
9
  import { HeadingLevels } from "../Heading/HeadingTypes";
10
10
 
11
11
  describe("Grid Accessibility", () => {
@@ -15,7 +15,7 @@ describe("Grid Accessibility", () => {
15
15
  <Card
16
16
  imageSrc="https://placeimg.com/500/200/animals"
17
17
  imageAlt="Alt text"
18
- imageAspectRatio={CardImageRatios.TwoByOne}
18
+ imageAspectRatio={ImageRatios.TwoByOne}
19
19
  >
20
20
  <CardHeading level={HeadingLevels.Two}>Card Heading</CardHeading>
21
21
  <CardContent>
@@ -26,7 +26,7 @@ describe("Grid Accessibility", () => {
26
26
  <Card
27
27
  imageSrc="https://placeimg.com/400/220/animals"
28
28
  imageAlt="Alt text"
29
- imageAspectRatio={CardImageRatios.TwoByOne}
29
+ imageAspectRatio={ImageRatios.TwoByOne}
30
30
  >
31
31
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
32
32
  <CardContent>
@@ -37,7 +37,7 @@ describe("Grid Accessibility", () => {
37
37
  <Card
38
38
  imageSrc="https://placeimg.com/400/240/animals"
39
39
  imageAlt="Alt text"
40
- imageAspectRatio={CardImageRatios.TwoByOne}
40
+ imageAspectRatio={ImageRatios.TwoByOne}
41
41
  >
42
42
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
43
43
  <CardContent>
@@ -25,10 +25,9 @@ import { getCategory } from "../../utils/componentCategories";
25
25
  jest: ["Heading.test.tsx"],
26
26
  }}
27
27
  argTypes={{
28
- blockName: { table: { disable: true } },
28
+ additionalStyles: { table: { disable: true } },
29
29
  className: { table: { disable: true } },
30
- modifiers: { table: { disable: true } },
31
- sx: { table: { disable: true } },
30
+ id: { table: { disable: true } },
32
31
  }}
33
32
  />
34
33
 
@@ -37,7 +36,7 @@ import { getCategory } from "../../utils/componentCategories";
37
36
  | Component Version | DS Version |
38
37
  | ----------------- | ---------- |
39
38
  | Added | `0.0.4` |
40
- | Latest | `0.25.0` |
39
+ | Latest | `0.25.2` |
41
40
 
42
41
  <Description of={Heading} />
43
42
 
@@ -35,7 +35,7 @@ import DSProvider from "../../theme/provider";
35
35
  | Component Version | DS Version |
36
36
  | ----------------- | ---------- |
37
37
  | Added | `0.0.10` |
38
- | Latest | `0.25.2` |
38
+ | Latest | `0.25.3` |
39
39
 
40
40
  <Description of={HelperErrorText} />
41
41
 
@@ -6,6 +6,8 @@ import generateUUID from "../../helpers/generateUUID";
6
6
  export type AriaLiveValues = "assertive" | "off" | "polite";
7
7
 
8
8
  interface HelperErrorTextProps {
9
+ /** Optionally pass in additional Chakra-based styles. */
10
+ additionalStyles?: { [key: string]: any };
9
11
  /** Aria attribute. When true, assistive technologies will
10
12
  * read the entire DOM element. When false, only changes (additionals or
11
13
  * removals) will be read. True by default. */
@@ -31,6 +33,7 @@ export default function HelperErrorText(
31
33
  props: React.PropsWithChildren<HelperErrorTextProps>
32
34
  ) {
33
35
  const {
36
+ additionalStyles = {},
34
37
  ariaAtomic = true,
35
38
  ariaLive = "polite",
36
39
  children,
@@ -41,6 +44,7 @@ export default function HelperErrorText(
41
44
  // Only announce the text in the invalid state.
42
45
  const announceAriaLive = isInvalid;
43
46
  const styles = useStyleConfig("HelperErrorText", { isInvalid });
47
+ const finalStyles = { ...styles, ...additionalStyles };
44
48
 
45
49
  return (
46
50
  <Box
@@ -49,7 +53,7 @@ export default function HelperErrorText(
49
53
  aria-atomic={ariaAtomic}
50
54
  data-isinvalid={isInvalid}
51
55
  aria-live={announceAriaLive ? ariaLive : "off"}
52
- __css={styles}
56
+ __css={finalStyles}
53
57
  >
54
58
  {children}
55
59
  </Box>
@@ -10,6 +10,7 @@ export enum HeroTypes {
10
10
  FiftyFifty = "fiftyfifty",
11
11
  }
12
12
 
13
+ // Only used for internal purposes.
13
14
  export const HeroSecondaryTypes = [
14
15
  HeroTypes.Secondary,
15
16
  HeroTypes.SecondaryBooksAndMore,