@nypl/design-system-react-components 0.25.13 → 0.26.0

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 (299) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +10 -10
  3. package/dist/components/Accordion/Accordion.d.ts +1 -1
  4. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  5. package/dist/components/Button/Button.d.ts +2 -2
  6. package/dist/components/Card/Card.d.ts +11 -9
  7. package/dist/components/Checkbox/Checkbox.d.ts +2 -2
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
  9. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
  10. package/dist/components/DatePicker/DatePicker.d.ts +5 -6
  11. package/dist/components/Fieldset/Fieldset.d.ts +5 -6
  12. package/dist/components/Form/Form.d.ts +6 -6
  13. package/dist/components/Grid/GridTypes.d.ts +7 -7
  14. package/dist/components/Grid/SimpleGrid.d.ts +1 -1
  15. package/dist/components/Heading/Heading.d.ts +1 -1
  16. package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
  17. package/dist/components/Hero/Hero.d.ts +2 -1
  18. package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
  19. package/dist/components/Icons/Icon.d.ts +2 -1
  20. package/dist/components/Image/Image.d.ts +2 -2
  21. package/dist/components/Label/Label.d.ts +7 -4
  22. package/dist/components/Link/Link.d.ts +1 -1
  23. package/dist/components/List/List.d.ts +11 -11
  24. package/dist/components/List/ListTypes.d.ts +1 -1
  25. package/dist/components/Logo/Logo.d.ts +2 -1
  26. package/dist/components/Logo/LogoSvgs.d.ts +2 -0
  27. package/dist/components/Logo/LogoTypes.d.ts +2 -0
  28. package/dist/components/Notification/Notification.d.ts +4 -4
  29. package/dist/components/Pagination/Pagination.d.ts +2 -2
  30. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
  31. package/dist/components/Radio/Radio.d.ts +4 -6
  32. package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
  33. package/dist/components/SearchBar/SearchBar.d.ts +4 -4
  34. package/dist/components/Select/Select.d.ts +10 -6
  35. package/dist/components/Select/SelectTypes.d.ts +4 -0
  36. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
  37. package/dist/components/Slider/Slider.d.ts +6 -4
  38. package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
  39. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  40. package/dist/components/Table/Table.d.ts +1 -1
  41. package/dist/components/Tabs/Tabs.d.ts +4 -3
  42. package/dist/components/Template/Template.d.ts +4 -3
  43. package/dist/components/Text/Text.d.ts +1 -1
  44. package/dist/components/TextInput/TextInput.d.ts +5 -5
  45. package/dist/components/Toggle/Toggle.d.ts +3 -4
  46. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  47. package/dist/design-system-react-components.cjs.development.js +1663 -1139
  48. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  49. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  50. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  51. package/dist/design-system-react-components.esm.js +1667 -1143
  52. package/dist/design-system-react-components.esm.js.map +1 -1
  53. package/dist/hooks/useCarouselStyles.d.ts +3 -2
  54. package/dist/hooks/useNYPLTheme.d.ts +12 -0
  55. package/dist/index.d.ts +4 -1
  56. package/dist/styles.css +1 -1
  57. package/dist/theme/components/button.d.ts +10 -2
  58. package/dist/theme/components/card.d.ts +42 -22
  59. package/dist/theme/components/checkbox.d.ts +5 -4
  60. package/dist/theme/components/checkboxGroup.d.ts +1 -1
  61. package/dist/theme/components/componentWrapper.d.ts +2 -2
  62. package/dist/theme/components/customTable.d.ts +84 -1
  63. package/dist/theme/components/fieldset.d.ts +4 -14
  64. package/dist/theme/components/global.d.ts +23 -17
  65. package/dist/theme/components/heading.d.ts +53 -0
  66. package/dist/theme/components/helperErrorText.d.ts +1 -0
  67. package/dist/theme/components/hero.d.ts +20 -14
  68. package/dist/theme/components/label.d.ts +9 -10
  69. package/dist/theme/components/list.d.ts +99 -9
  70. package/dist/theme/components/radio.d.ts +6 -4
  71. package/dist/theme/components/radioGroup.d.ts +1 -1
  72. package/dist/theme/components/select.d.ts +34 -5
  73. package/dist/theme/components/skeletonLoader.d.ts +2 -2
  74. package/dist/theme/components/slider.d.ts +6 -3
  75. package/dist/theme/components/structuredContent.d.ts +197 -0
  76. package/dist/theme/components/textInput.d.ts +18 -6
  77. package/dist/theme/components/toggle.d.ts +7 -4
  78. package/dist/theme/foundations/global.d.ts +2 -0
  79. package/dist/theme/foundations/radii.d.ts +1 -0
  80. package/dist/theme/foundations/spacing.d.ts +46 -43
  81. package/package.json +5 -6
  82. package/src/components/Accordion/Accordion.stories.mdx +9 -9
  83. package/src/components/Accordion/Accordion.test.tsx +21 -0
  84. package/src/components/Accordion/Accordion.tsx +13 -9
  85. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
  86. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  87. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
  88. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
  89. package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
  90. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
  91. package/src/components/Button/Button.stories.mdx +87 -23
  92. package/src/components/Button/Button.test.tsx +25 -0
  93. package/src/components/Button/Button.tsx +18 -7
  94. package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
  95. package/src/components/Card/Card.stories.mdx +287 -194
  96. package/src/components/Card/Card.test.tsx +102 -0
  97. package/src/components/Card/Card.tsx +73 -32
  98. package/src/components/Card/__snapshots__/Card.test.tsx.snap +195 -35
  99. package/src/components/Chakra/Grid.stories.mdx +4 -4
  100. package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
  101. package/src/components/Checkbox/Checkbox.test.tsx +32 -9
  102. package/src/components/Checkbox/Checkbox.tsx +20 -15
  103. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
  104. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
  105. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
  106. package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
  107. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
  108. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
  109. package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
  110. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
  111. package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
  112. package/src/components/DatePicker/DatePicker.test.tsx +89 -13
  113. package/src/components/DatePicker/DatePicker.tsx +62 -56
  114. package/src/components/DatePicker/_DatePicker.scss +71 -13
  115. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
  116. package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
  117. package/src/components/Fieldset/Fieldset.test.tsx +58 -28
  118. package/src/components/Fieldset/Fieldset.tsx +35 -30
  119. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
  120. package/src/components/Form/Form.stories.mdx +72 -39
  121. package/src/components/Form/Form.test.tsx +58 -15
  122. package/src/components/Form/Form.tsx +89 -67
  123. package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
  124. package/src/components/Grid/GridTypes.tsx +7 -7
  125. package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
  126. package/src/components/Grid/SimpleGrid.test.tsx +9 -0
  127. package/src/components/Grid/SimpleGrid.tsx +29 -20
  128. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
  129. package/src/components/Heading/Heading.stories.mdx +36 -3
  130. package/src/components/Heading/Heading.test.tsx +10 -0
  131. package/src/components/Heading/Heading.tsx +56 -50
  132. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
  133. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
  134. package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
  135. package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
  136. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
  137. package/src/components/Hero/Hero.stories.mdx +125 -95
  138. package/src/components/Hero/Hero.test.tsx +33 -0
  139. package/src/components/Hero/Hero.tsx +135 -126
  140. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
  141. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
  142. package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
  143. package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
  144. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
  145. package/src/components/Icons/Icon.stories.mdx +31 -6
  146. package/src/components/Icons/Icon.test.tsx +38 -0
  147. package/src/components/Icons/Icon.tsx +93 -76
  148. package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
  149. package/src/components/Image/Image.stories.mdx +29 -5
  150. package/src/components/Image/Image.test.tsx +8 -0
  151. package/src/components/Image/Image.tsx +38 -26
  152. package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
  153. package/src/components/Label/Label.stories.mdx +42 -20
  154. package/src/components/Label/Label.test.tsx +42 -17
  155. package/src/components/Label/Label.tsx +22 -13
  156. package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
  157. package/src/components/Link/Link.stories.mdx +25 -1
  158. package/src/components/Link/Link.test.tsx +21 -0
  159. package/src/components/Link/Link.tsx +8 -8
  160. package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
  161. package/src/components/List/List.stories.mdx +75 -40
  162. package/src/components/List/List.test.tsx +67 -19
  163. package/src/components/List/List.tsx +38 -25
  164. package/src/components/List/ListTypes.tsx +1 -1
  165. package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
  166. package/src/components/Logo/Logo.stories.mdx +30 -6
  167. package/src/components/Logo/Logo.test.tsx +17 -0
  168. package/src/components/Logo/Logo.tsx +18 -6
  169. package/src/components/Logo/LogoSvgs.tsx +4 -0
  170. package/src/components/Logo/LogoTypes.tsx +2 -0
  171. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
  172. package/src/components/Modal/Modal.stories.mdx +13 -0
  173. package/src/components/Notification/Notification.stories.mdx +25 -1
  174. package/src/components/Notification/Notification.test.tsx +23 -0
  175. package/src/components/Notification/Notification.tsx +46 -44
  176. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
  177. package/src/components/Pagination/Pagination.stories.mdx +24 -4
  178. package/src/components/Pagination/Pagination.test.tsx +25 -0
  179. package/src/components/Pagination/Pagination.tsx +6 -6
  180. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
  181. package/src/components/Placeholder/Placeholder.tsx +3 -1
  182. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
  183. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
  184. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
  185. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
  186. package/src/components/Radio/Radio.stories.mdx +64 -12
  187. package/src/components/Radio/Radio.test.tsx +28 -8
  188. package/src/components/Radio/Radio.tsx +66 -63
  189. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
  190. package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
  191. package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
  192. package/src/components/RadioGroup/RadioGroup.tsx +106 -100
  193. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
  194. package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
  195. package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
  196. package/src/components/SearchBar/SearchBar.tsx +17 -8
  197. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
  198. package/src/components/Select/Select.stories.mdx +128 -49
  199. package/src/components/Select/Select.test.tsx +63 -16
  200. package/src/components/Select/Select.tsx +125 -92
  201. package/src/components/Select/SelectTypes.tsx +5 -0
  202. package/src/components/Select/__snapshots__/Select.test.tsx.snap +749 -409
  203. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
  204. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
  205. package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
  206. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
  207. package/src/components/Slider/Slider.stories.mdx +91 -42
  208. package/src/components/Slider/Slider.test.tsx +65 -17
  209. package/src/components/Slider/Slider.tsx +26 -19
  210. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
  211. package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
  212. package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
  213. package/src/components/StatusBadge/StatusBadge.tsx +25 -20
  214. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
  215. package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
  216. package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
  217. package/src/components/StructuredContent/StructuredContent.tsx +80 -75
  218. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
  219. package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
  220. package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
  221. package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
  222. package/src/components/StyleGuide/ColorCard.tsx +1 -1
  223. package/src/components/StyleGuide/Colors.stories.mdx +1 -2
  224. package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
  225. package/src/components/StyleGuide/Forms.stories.mdx +27 -12
  226. package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
  227. package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
  228. package/src/components/StyleGuide/Typography.stories.mdx +30 -21
  229. package/src/components/Table/Table.stories.mdx +38 -11
  230. package/src/components/Table/Table.test.tsx +15 -0
  231. package/src/components/Table/Table.tsx +7 -7
  232. package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
  233. package/src/components/Tabs/Tabs.stories.mdx +52 -3
  234. package/src/components/Tabs/Tabs.test.tsx +16 -0
  235. package/src/components/Tabs/Tabs.tsx +10 -6
  236. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
  237. package/src/components/Template/Template.stories.mdx +47 -43
  238. package/src/components/Template/Template.test.tsx +33 -0
  239. package/src/components/Template/Template.tsx +65 -60
  240. package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
  241. package/src/components/Text/Text.stories.mdx +20 -1
  242. package/src/components/Text/Text.test.tsx +12 -0
  243. package/src/components/Text/Text.tsx +6 -4
  244. package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
  245. package/src/components/TextInput/TextInput.stories.mdx +65 -19
  246. package/src/components/TextInput/TextInput.test.tsx +42 -28
  247. package/src/components/TextInput/TextInput.tsx +121 -113
  248. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
  249. package/src/components/Toggle/Toggle.stories.mdx +80 -22
  250. package/src/components/Toggle/Toggle.test.tsx +27 -9
  251. package/src/components/Toggle/Toggle.tsx +22 -18
  252. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
  253. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
  254. package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
  255. package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
  256. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
  257. package/src/docs/Chakra.stories.mdx +50 -9
  258. package/src/docs/Welcome.stories.mdx +160 -41
  259. package/src/hooks/useCarouselStyles.stories.mdx +22 -2
  260. package/src/hooks/useCarouselStyles.ts +3 -2
  261. package/src/hooks/useNYPLTheme.stories.mdx +101 -0
  262. package/src/hooks/useNYPLTheme.ts +30 -6
  263. package/src/hooks/useWindowSize.stories.mdx +23 -0
  264. package/src/index.ts +4 -1
  265. package/src/styles/base/_place-holder.scss +1 -1
  266. package/src/theme/components/button.ts +15 -7
  267. package/src/theme/components/card.ts +30 -19
  268. package/src/theme/components/checkbox.ts +10 -8
  269. package/src/theme/components/checkboxGroup.ts +1 -1
  270. package/src/theme/components/componentWrapper.ts +2 -2
  271. package/src/theme/components/customTable.ts +39 -31
  272. package/src/theme/components/fieldset.ts +1 -2
  273. package/src/theme/components/global.ts +25 -20
  274. package/src/theme/components/heading.ts +1 -1
  275. package/src/theme/components/helperErrorText.ts +1 -0
  276. package/src/theme/components/hero.ts +13 -15
  277. package/src/theme/components/label.ts +4 -3
  278. package/src/theme/components/list.ts +73 -66
  279. package/src/theme/components/notification.ts +2 -2
  280. package/src/theme/components/radio.ts +9 -9
  281. package/src/theme/components/radioGroup.ts +1 -1
  282. package/src/theme/components/select.ts +35 -22
  283. package/src/theme/components/skeletonLoader.ts +3 -3
  284. package/src/theme/components/slider.ts +8 -7
  285. package/src/theme/components/statusBadge.ts +2 -2
  286. package/src/theme/components/structuredContent.ts +66 -1
  287. package/src/theme/components/tabs.ts +2 -2
  288. package/src/theme/components/template.ts +9 -9
  289. package/src/theme/components/textInput.ts +13 -12
  290. package/src/theme/components/toggle.ts +17 -10
  291. package/src/theme/components/videoPlayer.ts +1 -1
  292. package/src/theme/foundations/colors.ts +1 -1
  293. package/src/theme/foundations/radii.ts +1 -0
  294. package/src/theme/foundations/spacing.ts +70 -22
  295. package/src/theme/foundations/typography.ts +2 -2
  296. package/src/utils/componentCategories.ts +1 -2
  297. package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
  298. package/dist/helpers/generateUUID.d.ts +0 -1
  299. package/src/helpers/generateUUID.tsx +0 -5
@@ -1,4 +1,4 @@
1
- import { Flex, Spacer } from "@chakra-ui/react";
1
+ import { ButtonGroup, Flex, Spacer } from "@chakra-ui/react";
2
2
  import {
3
3
  ArgsTable,
4
4
  Canvas,
@@ -8,9 +8,12 @@ import {
8
8
  } from "@storybook/addon-docs";
9
9
  import { withDesign } from "storybook-addon-designs";
10
10
 
11
+ import Button from "../Button/Button";
12
+ import Form from "../Form/Form";
11
13
  import Radio from "../Radio/Radio";
12
- import RadioGroup, { onChangeDefault } from "./RadioGroup";
14
+ import RadioGroup from "./RadioGroup";
13
15
  import { LayoutTypes } from "../../helpers/enums";
16
+ import SimpleGrid from "../Grid/SimpleGrid";
14
17
  import { getCategory } from "../../utils/componentCategories";
15
18
  import DSProvider from "../../theme/provider";
16
19
  import { getStorybookEnumValues } from "../../utils/utils";
@@ -52,15 +55,15 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
52
55
  key: { table: { disable: true } },
53
56
  onChange: { control: false },
54
57
  ref: { table: { disable: true } },
55
- optReqFlag: {
56
- table: { defaultValue: { summary: true } },
57
- },
58
58
  showHelperInvalidText: {
59
59
  table: { defaultValue: { summary: true } },
60
60
  },
61
61
  showLabel: {
62
62
  table: { defaultValue: { summary: true } },
63
63
  },
64
+ showRequiredLabel: {
65
+ table: { defaultValue: { summary: true } },
66
+ },
64
67
  }}
65
68
  />
66
69
 
@@ -69,10 +72,26 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
69
72
  | Component Version | DS Version |
70
73
  | ----------------- | ---------- |
71
74
  | Added | `0.25.0` |
72
- | Latest | `0.25.13` |
75
+ | Latest | `0.26.0` |
76
+
77
+ ## Table of Contents
78
+
79
+ - [Overview](#overview)
80
+ - [Component Props](#component-props)
81
+ - [Accessibility](#accessibility)
82
+ - [Layout Patterns](#layout-patterns)
83
+ - [Errored](#errored)
84
+ - [Required](#required)
85
+ - [Disabled](#disabled)
86
+ - [With JSX Element labels](#with-jsx-element-labels)
87
+ - [Getting Radio Input Values](#getting-radio-input-values)
88
+
89
+ ## Overview
73
90
 
74
91
  <Description of={RadioGroup} />
75
92
 
93
+ ## Component Props
94
+
76
95
  <Canvas withToolbar>
77
96
  <Story
78
97
  name="RadioGroup"
@@ -81,7 +100,7 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
81
100
  defaultValue: "4",
82
101
  helperText: "This is the helper text for the full group.",
83
102
  id: "radioGroup-id",
84
- invalidText: "error!",
103
+ invalidText: "An error occurred :(",
85
104
  isDisabled: false,
86
105
  isFullWidth: false,
87
106
  isInvalid: false,
@@ -90,17 +109,17 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
90
109
  layout: "LayoutTypes.Column",
91
110
  name: "radio-story",
92
111
  onChange: undefined,
93
- optReqFlag: true,
94
112
  showHelperInvalidText: true,
95
113
  showLabel: true,
114
+ showRequiredLabel: true,
96
115
  }}
97
116
  >
98
117
  {(args) => (
99
118
  <RadioGroup {...args} layout={enumValues.getValue(args.layout)}>
100
- <Radio value="2" labelText="Radio 2" />
101
- <Radio value="3" labelText="Radio 3" />
102
- <Radio value="4" labelText="Radio 4" />
103
- <Radio value="5" labelText="Radio 5" />
119
+ <Radio id="main-2" labelText="Radio 2" value="2" />
120
+ <Radio id="main-3" labelText="Radio 3" value="3" />
121
+ <Radio id="main-4" labelText="Radio 4" value="4" />
122
+ <Radio id="main-5" labelText="Radio 5" value="5" />
104
123
  </RadioGroup>
105
124
  )}
106
125
  </Story>
@@ -108,6 +127,18 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
108
127
 
109
128
  <ArgsTable story="RadioGroup" />
110
129
 
130
+ ## Accessibility
131
+
132
+ The `RadioGroup` renders a group of `Radio` components that are wrapped in a
133
+ `<fieldset>` element. The `<fieldset>` element renders a `<legend>` element that
134
+ can be visually hidden through the `showLabel` prop.
135
+
136
+ Resources:
137
+
138
+ - [W3C ARIA radiogroup and radio example](https://www.w3.org/TR/2016/WD-wai-aria-practices-1.1-20160317/examples/radio/radio.html)
139
+ - [Deque University Radio and Radio Group](https://dequeuniversity.com/library/aria/radio-and-radio-group)
140
+ - [Chakra UI Radio](https://chakra-ui.com/docs/components/form/radio)
141
+
111
142
  ## Layout Patterns
112
143
 
113
144
  Use the `layout` prop to set the `Radio` buttons to display in a column or in
@@ -116,26 +147,28 @@ a row.
116
147
  <Canvas>
117
148
  <DSProvider>
118
149
  <RadioGroup
150
+ defaultValue="4"
151
+ id="column"
119
152
  labelText="Column (default)"
120
153
  name="column-example"
121
- optReqFlag={false}
122
154
  >
123
- <Radio value="2" labelText="Radio 2" />
124
- <Radio value="3" labelText="Radio 3" />
125
- <Radio value="4" labelText="Radio 4" />
126
- <Radio value="5" labelText="Radio 5" />
155
+ <Radio id="column-2" labelText="Radio 2" value="2" />
156
+ <Radio id="column-3" labelText="Radio 3" value="3" />
157
+ <Radio id="column-4" labelText="Radio 4" value="4" />
158
+ <Radio id="column-5" labelText="Radio 5" value="5" />
127
159
  </RadioGroup>
128
160
  <br />
129
161
  <RadioGroup
162
+ defaultValue="3"
163
+ id="row"
130
164
  labelText="Row"
131
165
  name="row-example"
132
166
  layout={LayoutTypes.Row}
133
- optReqFlag={false}
134
167
  >
135
- <Radio value="2" labelText="Radio 2" />
136
- <Radio value="3" labelText="Radio 3" />
137
- <Radio value="4" labelText="Radio 4" />
138
- <Radio value="5" labelText="Radio 5" />
168
+ <Radio id="row-2" labelText="Radio 2" value="2" />
169
+ <Radio id="row-3" labelText="Radio 3" value="3" />
170
+ <Radio id="row-4" labelText="Radio 4" value="4" />
171
+ <Radio id="row-5" labelText="Radio 5" value="5" />
139
172
  </RadioGroup>
140
173
  </DSProvider>
141
174
  </Canvas>
@@ -145,16 +178,36 @@ a row.
145
178
  <Canvas>
146
179
  <DSProvider>
147
180
  <RadioGroup
148
- labelText="Errored Radio Group"
149
- name="errored-example"
150
- optReqFlag={false}
181
+ defaultValue="4"
182
+ id="errored"
151
183
  invalidText="Error message for the full group."
152
184
  isInvalid
185
+ labelText="Errored Radio Group"
186
+ name="errored-example"
153
187
  >
154
- <Radio value="2" labelText="Radio 2" />
155
- <Radio value="3" labelText="Radio 3" />
156
- <Radio value="4" labelText="Radio 4" />
157
- <Radio value="5" labelText="Radio 5" />
188
+ <Radio id="radio-2" labelText="Radio 2" value="2" />
189
+ <Radio id="radio-3" labelText="Radio 3" value="3" />
190
+ <Radio id="radio-4" labelText="Radio 4" value="4" />
191
+ <Radio id="radio-5" labelText="Radio 5" value="5" />
192
+ </RadioGroup>
193
+ </DSProvider>
194
+ </Canvas>
195
+
196
+ ## Required
197
+
198
+ <Canvas>
199
+ <DSProvider>
200
+ <RadioGroup
201
+ helperText="The reason for being required."
202
+ id="required"
203
+ isRequired
204
+ labelText="Required Radio Group"
205
+ name="required-example"
206
+ >
207
+ <Radio id="required-2" labelText="Radio 2" value="2" />
208
+ <Radio id="required-3" labelText="Radio 3" value="3" />
209
+ <Radio id="required-4" labelText="Radio 4" value="4" />
210
+ <Radio id="required-5" labelText="Radio 5" value="5" />
158
211
  </RadioGroup>
159
212
  </DSProvider>
160
213
  </Canvas>
@@ -164,16 +217,16 @@ a row.
164
217
  <Canvas>
165
218
  <DSProvider>
166
219
  <RadioGroup
167
- labelText="Disabled Radio Group"
168
- name="disabled-example"
169
- optReqFlag={false}
170
220
  helperText="The reason for being disabled."
221
+ id="disabled"
171
222
  isDisabled
223
+ labelText="Disabled Radio Group"
224
+ name="disabled-example"
172
225
  >
173
- <Radio value="2" labelText="Radio 2" />
174
- <Radio value="3" labelText="Radio 3" />
175
- <Radio value="4" labelText="Radio 4" />
176
- <Radio value="5" labelText="Radio 5" />
226
+ <Radio id="required-2" labelText="Radio 2" value="2" />
227
+ <Radio id="required-3" labelText="Radio 3" value="3" />
228
+ <Radio id="required-4" labelText="Radio 4" value="4" />
229
+ <Radio id="required-5" labelText="Radio 5" value="5" />
177
230
  </RadioGroup>
178
231
  </DSProvider>
179
232
  </Canvas>
@@ -191,12 +244,13 @@ order to make this work, pass in the `isFullWidth` prop.
191
244
  <Canvas>
192
245
  <DSProvider>
193
246
  <RadioGroup
247
+ id="jsx-radiogroup"
248
+ isFullWidth
194
249
  labelText="Radio Group"
195
250
  name="radio-example"
196
- optReqFlag={false}
197
- isFullWidth
198
251
  >
199
252
  <Radio
253
+ id="arts"
200
254
  labelText={
201
255
  <Flex>
202
256
  <span>Arts</span>
@@ -207,6 +261,7 @@ order to make this work, pass in the `isFullWidth` prop.
207
261
  value="arts"
208
262
  />
209
263
  <Radio
264
+ id="english"
210
265
  labelText={
211
266
  <Flex>
212
267
  <span>English</span>
@@ -217,6 +272,7 @@ order to make this work, pass in the `isFullWidth` prop.
217
272
  value="English"
218
273
  />
219
274
  <Radio
275
+ id="science"
220
276
  labelText={
221
277
  <Flex>
222
278
  <span>Science</span>
@@ -227,6 +283,7 @@ order to make this work, pass in the `isFullWidth` prop.
227
283
  value="Science"
228
284
  />
229
285
  <Radio
286
+ id="math"
230
287
  labelText={
231
288
  <Flex>
232
289
  <span>Math</span>
@@ -240,39 +297,70 @@ order to make this work, pass in the `isFullWidth` prop.
240
297
  </DSProvider>
241
298
  </Canvas>
242
299
 
243
- ## Getting Radio Data Values
300
+ ## Getting Radio Input Values
244
301
 
245
302
  ### Controlled Component using `name` and `onChange` props
246
303
 
247
- If your application uses controlled React components and the DS RadioGroup must
248
- be controlled, you can extract the data through the `name` and `onChange` props.
249
- This will be called every time a new `Radio` value is selected.
304
+ If your application uses controlled React components and the Reservoir Design
305
+ System (DS) `RadioGroup` must be controlled, you can extract the data through the
306
+ `name` and `onChange` props. This will be called every time a new `Radio` value
307
+ is selected. Open the browser's console to see the output.
250
308
 
251
309
  ```jsx
252
- const onChange = (data) => {
253
- // This will return the value selected as a string.
254
- console.log(data);
255
- };
256
- // ...
257
-
258
- // Example of the DS RadioGroup instance with the function above:
259
- <RadioGroup
260
- id="controlled-example"
261
- labelText="Radio Group"
262
- name="radioExample"
263
- defaultValue="3"
264
- onChange={onChange}
265
- >
266
- <Radio value="2" labelText="Radio 2" />
267
- <Radio value="3" labelText="Radio 3" />
268
- <Radio value="4" labelText="Radio 4" />
269
- </RadioGroup>;
310
+ function RadioGroupControlledExample() {
311
+ const onChange = (selected) => {
312
+ // This will return the value selected as a string.
313
+ console.log(`Controlled example. Selected: ${selected}`);
314
+ };
315
+ return (
316
+ <RadioGroup
317
+ defaultValue="3"
318
+ id="controlled-example"
319
+ labelText="Controlled RadioGroup"
320
+ name="radioGroupExample"
321
+ onChange={onChange}
322
+ >
323
+ <Radio id="2" labelText="Radio 2" value="2" />
324
+ <Radio id="3" labelText="Radio 3" value="3" />
325
+ <Radio id="4" labelText="Radio 4" value="4" />
326
+ </RadioGroup>
327
+ );
328
+ }
270
329
  ```
271
330
 
331
+ export function RadioGroupControlledExample() {
332
+ const onChange = (selected) => {
333
+ // This will return the value selected as a string.
334
+ console.log(`Controlled example. Selected: ${selected}`);
335
+ };
336
+ return (
337
+ <RadioGroup
338
+ defaultValue="3"
339
+ id="controlled-example"
340
+ labelText="Controlled RadioGroup"
341
+ name="radioGroupExample"
342
+ onChange={onChange}
343
+ >
344
+ <Radio id="2" labelText="Radio 2" value="2" />
345
+ <Radio id="3" labelText="Radio 3" value="3" />
346
+ <Radio id="4" labelText="Radio 4" value="4" />
347
+ </RadioGroup>
348
+ );
349
+ }
350
+
351
+ <Canvas>
352
+ <DSProvider>
353
+ <RadioGroupControlledExample />
354
+ </DSProvider>
355
+ </Canvas>
356
+
272
357
  ### Uncontrolled Component using `ref`s
273
358
 
359
+ **NOTE: this, along with Chakra's own `RadioGroup` component, are not working
360
+ at this time and we recommend to use the controlled pattern above.**
361
+
274
362
  If your application uses uncontrolled components, you can pass React `ref` props
275
- to the DS RadioGroup component to get the selected value from the DOM.
363
+ to the DS `RadioGroup` component to get the selected value from the DOM.
276
364
 
277
365
  The following example is using the `register` React `ref` from the
278
366
  `react-hook-form` package.
@@ -300,45 +388,92 @@ const submitForm = (formData) => {
300
388
  <Controller
301
389
  as={
302
390
  <RadioGroup
303
- id="uncontrolled-example"
304
- labelText="Radio Group"
305
- name="radioExample"
306
391
  defaultValue="3"
392
+ id="uncontrolled-example"
393
+ labelText="RadioGroup Uncontrolled"
394
+ name="radioGroupExample"
307
395
  ref={register()}
308
396
  >
309
- <Radio value="2" labelText="Radio 2" />
310
- <Radio value="3" labelText="Radio 3" />
311
- <Radio value="4" labelText="Radio 4" />
397
+ <Radio id="2" labelText="Radio 2" value="2" />
398
+ <Radio id="3" labelText="Radio 3" value="3" />
399
+ <Radio id="4" labelText="Radio 4" value="4" />
312
400
  </RadioGroup>
313
401
  }
314
- name="radioExample"
315
402
  control={control}
403
+ name="radioGroupExample"
316
404
  />
317
405
  </form>;
318
406
  ```
319
407
 
320
408
  The above is specific to `react-hook-form` but a similar pattern can be used
321
- with normal React `ref` values.
409
+ with normal React `ref` values. Open the browser's console to see the output
410
+ **although, at the moment, forwarding the ref to Chakra's own `RadioGroup`
411
+ component is not working.**
322
412
 
323
413
  ```jsx
324
- const radioGroupRef = React.createRef<HTMLInputElement>();
325
- // ...
326
- <RadioGroup
327
- id="uncontrolled-example"
328
- labelText="Radio Group"
329
- name="radioExample"
330
- defaultValue="3"
331
- ref={radioGroupRef}
332
- >
333
- <Radio value="2" labelText="Radio 2" />
334
- <Radio value="3" labelText="Radio 3" />
335
- <Radio value="4" labelText="Radio 4" />
336
- </RadioGroup>
337
-
338
- // ...
339
- // Get the value through:
340
- const onSubmit = () => {
341
- // ...
342
- const radioGroupValue = radioGroupRef.current.value;
343
- };
414
+ export function RadioGroupUncontrolledExample() {
415
+ const radioGroupRef = React.createRef();
416
+ // Get the value through:
417
+ const onSubmit = (e) => {
418
+ e.preventDefault();
419
+ const radioGroupValue = radioGroupRef.current.value;
420
+ console.log(`Uncontrolled example. Selected: ${radioGroupValue}`);
421
+ };
422
+ return (
423
+ <Form onSubmit={onSubmit}>
424
+ <SimpleGrid columns="1">
425
+ <RadioGroup
426
+ defaultValue="3"
427
+ id="uncontrolled-example"
428
+ labelText="Uncontrolled RadioGroup"
429
+ name="radioGroupExample"
430
+ ref={radioGroupRef}
431
+ >
432
+ <Radio id="2" labelText="Radio 2" value="2" />
433
+ <Radio id="3" labelText="Radio 3" value="3" />
434
+ <Radio id="4" labelText="Radio 4" value="4" />
435
+ </RadioGroup>
436
+ <ButtonGroup>
437
+ <Button type="submit">Submit</Button>
438
+ </ButtonGroup>
439
+ </SimpleGrid>
440
+ </Form>
441
+ );
442
+ }
344
443
  ```
444
+
445
+ export function RadioGroupUncontrolledExample() {
446
+ const radioGroupRef = React.createRef();
447
+ // Get the value through:
448
+ const onSubmit = (e) => {
449
+ e.preventDefault();
450
+ const radioGroupValue = radioGroupRef.current.value;
451
+ console.log(`Uncontrolled example. Selected: ${radioGroupValue}`);
452
+ };
453
+ return (
454
+ <Form onSubmit={onSubmit}>
455
+ <SimpleGrid columns="1">
456
+ <RadioGroup
457
+ defaultValue="3"
458
+ id="uncontrolled-example"
459
+ labelText="Uncontrolled RadioGroup"
460
+ name="radioGroupExample"
461
+ ref={radioGroupRef}
462
+ >
463
+ <Radio id="2" labelText="Radio 2" value="2" />
464
+ <Radio id="3" labelText="Radio 3" value="3" />
465
+ <Radio id="4" labelText="Radio 4" value="4" />
466
+ </RadioGroup>
467
+ <ButtonGroup>
468
+ <Button type="submit">Submit</Button>
469
+ </ButtonGroup>
470
+ </SimpleGrid>
471
+ </Form>
472
+ );
473
+ }
474
+
475
+ <Canvas>
476
+ <DSProvider>
477
+ <RadioGroupUncontrolledExample />
478
+ </DSProvider>
479
+ </Canvas>