@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.
- package/CHANGELOG.md +58 -0
- package/README.md +10 -10
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Card/Card.d.ts +11 -9
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +5 -6
- package/dist/components/Fieldset/Fieldset.d.ts +5 -6
- package/dist/components/Form/Form.d.ts +6 -6
- package/dist/components/Grid/GridTypes.d.ts +7 -7
- package/dist/components/Grid/SimpleGrid.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
- package/dist/components/Hero/Hero.d.ts +2 -1
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
- package/dist/components/Icons/Icon.d.ts +2 -1
- package/dist/components/Image/Image.d.ts +2 -2
- package/dist/components/Label/Label.d.ts +7 -4
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/List/List.d.ts +11 -11
- package/dist/components/List/ListTypes.d.ts +1 -1
- package/dist/components/Logo/Logo.d.ts +2 -1
- package/dist/components/Logo/LogoSvgs.d.ts +2 -0
- package/dist/components/Logo/LogoTypes.d.ts +2 -0
- package/dist/components/Notification/Notification.d.ts +4 -4
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
- package/dist/components/Radio/Radio.d.ts +4 -6
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
- package/dist/components/SearchBar/SearchBar.d.ts +4 -4
- package/dist/components/Select/Select.d.ts +10 -6
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
- package/dist/components/Slider/Slider.d.ts +6 -4
- package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -3
- package/dist/components/Template/Template.d.ts +4 -3
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +5 -5
- package/dist/components/Toggle/Toggle.d.ts +3 -4
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +1663 -1139
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +1667 -1143
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/useCarouselStyles.d.ts +3 -2
- package/dist/hooks/useNYPLTheme.d.ts +12 -0
- package/dist/index.d.ts +4 -1
- package/dist/styles.css +1 -1
- package/dist/theme/components/button.d.ts +10 -2
- package/dist/theme/components/card.d.ts +42 -22
- package/dist/theme/components/checkbox.d.ts +5 -4
- package/dist/theme/components/checkboxGroup.d.ts +1 -1
- package/dist/theme/components/componentWrapper.d.ts +2 -2
- package/dist/theme/components/customTable.d.ts +84 -1
- package/dist/theme/components/fieldset.d.ts +4 -14
- package/dist/theme/components/global.d.ts +23 -17
- package/dist/theme/components/heading.d.ts +53 -0
- package/dist/theme/components/helperErrorText.d.ts +1 -0
- package/dist/theme/components/hero.d.ts +20 -14
- package/dist/theme/components/label.d.ts +9 -10
- package/dist/theme/components/list.d.ts +99 -9
- package/dist/theme/components/radio.d.ts +6 -4
- package/dist/theme/components/radioGroup.d.ts +1 -1
- package/dist/theme/components/select.d.ts +34 -5
- package/dist/theme/components/skeletonLoader.d.ts +2 -2
- package/dist/theme/components/slider.d.ts +6 -3
- package/dist/theme/components/structuredContent.d.ts +197 -0
- package/dist/theme/components/textInput.d.ts +18 -6
- package/dist/theme/components/toggle.d.ts +7 -4
- package/dist/theme/foundations/global.d.ts +2 -0
- package/dist/theme/foundations/radii.d.ts +1 -0
- package/dist/theme/foundations/spacing.d.ts +46 -43
- package/package.json +5 -6
- package/src/components/Accordion/Accordion.stories.mdx +9 -9
- package/src/components/Accordion/Accordion.test.tsx +21 -0
- package/src/components/Accordion/Accordion.tsx +13 -9
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
- package/src/components/Button/Button.stories.mdx +87 -23
- package/src/components/Button/Button.test.tsx +25 -0
- package/src/components/Button/Button.tsx +18 -7
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
- package/src/components/Card/Card.stories.mdx +287 -194
- package/src/components/Card/Card.test.tsx +102 -0
- package/src/components/Card/Card.tsx +73 -32
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +195 -35
- package/src/components/Chakra/Grid.stories.mdx +4 -4
- package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
- package/src/components/Checkbox/Checkbox.test.tsx +32 -9
- package/src/components/Checkbox/Checkbox.tsx +20 -15
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
- package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
- package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
- package/src/components/DatePicker/DatePicker.test.tsx +89 -13
- package/src/components/DatePicker/DatePicker.tsx +62 -56
- package/src/components/DatePicker/_DatePicker.scss +71 -13
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
- package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
- package/src/components/Fieldset/Fieldset.test.tsx +58 -28
- package/src/components/Fieldset/Fieldset.tsx +35 -30
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
- package/src/components/Form/Form.stories.mdx +72 -39
- package/src/components/Form/Form.test.tsx +58 -15
- package/src/components/Form/Form.tsx +89 -67
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
- package/src/components/Grid/GridTypes.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
- package/src/components/Grid/SimpleGrid.test.tsx +9 -0
- package/src/components/Grid/SimpleGrid.tsx +29 -20
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
- package/src/components/Heading/Heading.stories.mdx +36 -3
- package/src/components/Heading/Heading.test.tsx +10 -0
- package/src/components/Heading/Heading.tsx +56 -50
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
- package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
- package/src/components/Hero/Hero.stories.mdx +125 -95
- package/src/components/Hero/Hero.test.tsx +33 -0
- package/src/components/Hero/Hero.tsx +135 -126
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
- package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
- package/src/components/Icons/Icon.stories.mdx +31 -6
- package/src/components/Icons/Icon.test.tsx +38 -0
- package/src/components/Icons/Icon.tsx +93 -76
- package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
- package/src/components/Image/Image.stories.mdx +29 -5
- package/src/components/Image/Image.test.tsx +8 -0
- package/src/components/Image/Image.tsx +38 -26
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
- package/src/components/Label/Label.stories.mdx +42 -20
- package/src/components/Label/Label.test.tsx +42 -17
- package/src/components/Label/Label.tsx +22 -13
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
- package/src/components/Link/Link.stories.mdx +25 -1
- package/src/components/Link/Link.test.tsx +21 -0
- package/src/components/Link/Link.tsx +8 -8
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
- package/src/components/List/List.stories.mdx +75 -40
- package/src/components/List/List.test.tsx +67 -19
- package/src/components/List/List.tsx +38 -25
- package/src/components/List/ListTypes.tsx +1 -1
- package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
- package/src/components/Logo/Logo.stories.mdx +30 -6
- package/src/components/Logo/Logo.test.tsx +17 -0
- package/src/components/Logo/Logo.tsx +18 -6
- package/src/components/Logo/LogoSvgs.tsx +4 -0
- package/src/components/Logo/LogoTypes.tsx +2 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
- package/src/components/Modal/Modal.stories.mdx +13 -0
- package/src/components/Notification/Notification.stories.mdx +25 -1
- package/src/components/Notification/Notification.test.tsx +23 -0
- package/src/components/Notification/Notification.tsx +46 -44
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
- package/src/components/Pagination/Pagination.stories.mdx +24 -4
- package/src/components/Pagination/Pagination.test.tsx +25 -0
- package/src/components/Pagination/Pagination.tsx +6 -6
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
- package/src/components/Placeholder/Placeholder.tsx +3 -1
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
- package/src/components/Radio/Radio.stories.mdx +64 -12
- package/src/components/Radio/Radio.test.tsx +28 -8
- package/src/components/Radio/Radio.tsx +66 -63
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
- package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
- package/src/components/RadioGroup/RadioGroup.tsx +106 -100
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
- package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
- package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
- package/src/components/SearchBar/SearchBar.tsx +17 -8
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
- package/src/components/Select/Select.stories.mdx +128 -49
- package/src/components/Select/Select.test.tsx +63 -16
- package/src/components/Select/Select.tsx +125 -92
- package/src/components/Select/SelectTypes.tsx +5 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +749 -409
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
- package/src/components/Slider/Slider.stories.mdx +91 -42
- package/src/components/Slider/Slider.test.tsx +65 -17
- package/src/components/Slider/Slider.tsx +26 -19
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
- package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
- package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
- package/src/components/StatusBadge/StatusBadge.tsx +25 -20
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
- package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
- package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
- package/src/components/StructuredContent/StructuredContent.tsx +80 -75
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
- package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
- package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
- package/src/components/StyleGuide/ColorCard.tsx +1 -1
- package/src/components/StyleGuide/Colors.stories.mdx +1 -2
- package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
- package/src/components/StyleGuide/Forms.stories.mdx +27 -12
- package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
- package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
- package/src/components/StyleGuide/Typography.stories.mdx +30 -21
- package/src/components/Table/Table.stories.mdx +38 -11
- package/src/components/Table/Table.test.tsx +15 -0
- package/src/components/Table/Table.tsx +7 -7
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
- package/src/components/Tabs/Tabs.stories.mdx +52 -3
- package/src/components/Tabs/Tabs.test.tsx +16 -0
- package/src/components/Tabs/Tabs.tsx +10 -6
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
- package/src/components/Template/Template.stories.mdx +47 -43
- package/src/components/Template/Template.test.tsx +33 -0
- package/src/components/Template/Template.tsx +65 -60
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
- package/src/components/Text/Text.stories.mdx +20 -1
- package/src/components/Text/Text.test.tsx +12 -0
- package/src/components/Text/Text.tsx +6 -4
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
- package/src/components/TextInput/TextInput.stories.mdx +65 -19
- package/src/components/TextInput/TextInput.test.tsx +42 -28
- package/src/components/TextInput/TextInput.tsx +121 -113
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
- package/src/components/Toggle/Toggle.stories.mdx +80 -22
- package/src/components/Toggle/Toggle.test.tsx +27 -9
- package/src/components/Toggle/Toggle.tsx +22 -18
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
- package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
- package/src/docs/Chakra.stories.mdx +50 -9
- package/src/docs/Welcome.stories.mdx +160 -41
- package/src/hooks/useCarouselStyles.stories.mdx +22 -2
- package/src/hooks/useCarouselStyles.ts +3 -2
- package/src/hooks/useNYPLTheme.stories.mdx +101 -0
- package/src/hooks/useNYPLTheme.ts +30 -6
- package/src/hooks/useWindowSize.stories.mdx +23 -0
- package/src/index.ts +4 -1
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/theme/components/button.ts +15 -7
- package/src/theme/components/card.ts +30 -19
- package/src/theme/components/checkbox.ts +10 -8
- package/src/theme/components/checkboxGroup.ts +1 -1
- package/src/theme/components/componentWrapper.ts +2 -2
- package/src/theme/components/customTable.ts +39 -31
- package/src/theme/components/fieldset.ts +1 -2
- package/src/theme/components/global.ts +25 -20
- package/src/theme/components/heading.ts +1 -1
- package/src/theme/components/helperErrorText.ts +1 -0
- package/src/theme/components/hero.ts +13 -15
- package/src/theme/components/label.ts +4 -3
- package/src/theme/components/list.ts +73 -66
- package/src/theme/components/notification.ts +2 -2
- package/src/theme/components/radio.ts +9 -9
- package/src/theme/components/radioGroup.ts +1 -1
- package/src/theme/components/select.ts +35 -22
- package/src/theme/components/skeletonLoader.ts +3 -3
- package/src/theme/components/slider.ts +8 -7
- package/src/theme/components/statusBadge.ts +2 -2
- package/src/theme/components/structuredContent.ts +66 -1
- package/src/theme/components/tabs.ts +2 -2
- package/src/theme/components/template.ts +9 -9
- package/src/theme/components/textInput.ts +13 -12
- package/src/theme/components/toggle.ts +17 -10
- package/src/theme/components/videoPlayer.ts +1 -1
- package/src/theme/foundations/colors.ts +1 -1
- package/src/theme/foundations/radii.ts +1 -0
- package/src/theme/foundations/spacing.ts +70 -22
- package/src/theme/foundations/typography.ts +2 -2
- package/src/utils/componentCategories.ts +1 -2
- package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
- package/dist/helpers/generateUUID.d.ts +0 -1
- 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
|
|
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.
|
|
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
|
|
101
|
-
<Radio
|
|
102
|
-
<Radio
|
|
103
|
-
<Radio
|
|
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
|
|
124
|
-
<Radio
|
|
125
|
-
<Radio
|
|
126
|
-
<Radio
|
|
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
|
|
136
|
-
<Radio
|
|
137
|
-
<Radio
|
|
138
|
-
<Radio
|
|
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
|
-
|
|
149
|
-
|
|
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
|
|
155
|
-
<Radio
|
|
156
|
-
<Radio
|
|
157
|
-
<Radio
|
|
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
|
|
174
|
-
<Radio
|
|
175
|
-
<Radio
|
|
176
|
-
<Radio
|
|
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
|
|
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
|
|
248
|
-
be controlled, you can extract the data through the
|
|
249
|
-
This will be called every time a new `Radio` value
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
|
310
|
-
<Radio
|
|
311
|
-
<Radio
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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>
|