@nypl/design-system-react-components 0.25.1 → 0.25.5
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 +118 -1
- package/README.md +98 -50
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/dist/components/Button/Button.d.ts +13 -8
- package/dist/components/Button/ButtonTypes.d.ts +2 -1
- package/dist/components/Card/Card.d.ts +36 -52
- package/dist/components/Card/CardTypes.d.ts +0 -15
- package/dist/components/Checkbox/Checkbox.d.ts +17 -13
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +4 -2
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +15 -0
- package/dist/components/DatePicker/DatePicker.d.ts +36 -34
- package/dist/components/Fieldset/Fieldset.d.ts +25 -0
- package/dist/components/Heading/Heading.d.ts +4 -4
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +17 -14
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +10 -9
- package/dist/components/Icons/Icon.d.ts +8 -0
- package/dist/components/Icons/IconSvgs.d.ts +11 -0
- package/dist/components/Icons/IconTypes.d.ts +11 -0
- package/dist/components/Image/Image.d.ts +19 -9
- package/dist/components/Image/ImageTypes.d.ts +20 -0
- package/dist/components/Link/Link.d.ts +4 -0
- package/dist/components/List/List.d.ts +19 -14
- package/dist/components/Notification/Notification.d.ts +37 -16
- package/dist/components/Pagination/Pagination.d.ts +16 -13
- package/dist/components/Pagination/Pagination.stories.d.ts +2 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
- package/dist/components/Radio/Radio.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
- package/dist/components/SearchBar/SearchBar.d.ts +3 -3
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +18 -14
- package/dist/components/Slider/Slider.d.ts +57 -0
- package/dist/components/StyleGuide/ColorCard.d.ts +12 -0
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +12 -0
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +6 -8
- package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +2 -2
- package/dist/design-system-react-components.cjs.development.js +6131 -3715
- 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 +6124 -3699
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/tests/useCarouselStyles.test.d.ts +1 -0
- package/dist/hooks/useCarouselStyles.d.ts +16 -0
- package/dist/hooks/useNYPLTheme.d.ts +54 -0
- package/dist/hooks/useWindowSize.d.ts +10 -0
- package/dist/index.d.ts +13 -8
- package/dist/resources.scss +180 -170
- package/dist/styles.css +1 -1
- package/dist/theme/components/button.d.ts +22 -8
- package/dist/theme/components/card.d.ts +168 -0
- package/dist/theme/components/checkbox.d.ts +5 -1
- package/dist/theme/components/checkboxGroup.d.ts +12 -0
- package/dist/theme/components/componentWrapper.d.ts +11 -0
- package/dist/theme/components/datePicker.d.ts +16 -0
- package/dist/theme/components/fieldset.d.ts +27 -0
- package/dist/theme/components/global.d.ts +23 -13
- package/dist/theme/components/globalMixins.d.ts +9 -1
- package/dist/theme/components/heading.d.ts +5 -0
- package/dist/theme/components/helperErrorText.d.ts +10 -0
- package/dist/theme/components/hero.d.ts +1 -0
- package/dist/theme/components/horizontalRule.d.ts +14 -0
- package/dist/theme/components/image.d.ts +31 -0
- package/dist/theme/components/label.d.ts +5 -3
- package/dist/theme/components/link.d.ts +4 -0
- package/dist/theme/components/list.d.ts +89 -0
- package/dist/theme/components/notification.d.ts +75 -0
- package/dist/theme/components/pagination.d.ts +19 -0
- package/dist/theme/components/progressIndicator.d.ts +50 -0
- package/dist/theme/components/radioGroup.d.ts +12 -0
- package/dist/theme/components/select.d.ts +11 -2
- package/dist/theme/components/skeletonLoader.d.ts +98 -0
- package/dist/theme/components/slider.d.ts +51 -0
- package/dist/theme/components/tabs.d.ts +54 -3
- package/dist/theme/components/textInput.d.ts +8 -1
- package/dist/theme/components/videoPlayer.d.ts +40 -0
- package/dist/theme/foundations/breakpoints.d.ts +8 -8
- package/dist/theme/foundations/global.d.ts +6 -1
- package/dist/theme/foundations/radii.d.ts +5 -0
- package/dist/theme/foundations/spacing.d.ts +16 -16
- package/package.json +72 -83
- package/src/__tests__/setup.ts +2 -2
- package/src/components/Accordion/Accordion.stories.mdx +39 -44
- package/src/components/Autosuggest/Autosuggest.stories.mdx +3 -3
- package/src/components/Autosuggest/Autosuggest.stories.tsx +2 -1
- package/src/components/Autosuggest/_Autosuggest.scss +5 -5
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +14 -10
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +23 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +5 -1
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +199 -1
- package/src/components/Button/Button.stories.mdx +15 -10
- package/src/components/Button/Button.test.tsx +21 -7
- package/src/components/Button/Button.tsx +22 -34
- package/src/components/Button/ButtonTypes.tsx +1 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +41 -10
- package/src/components/Card/Card.stories.mdx +296 -259
- package/src/components/Card/Card.test.tsx +156 -84
- package/src/components/Card/Card.tsx +195 -145
- package/src/components/Card/CardTypes.tsx +0 -17
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +410 -0
- package/src/components/CardEdition/CardEdition.stories.tsx +15 -47
- package/src/components/CardEdition/_CardEdition.scss +22 -23
- package/src/components/Chakra/Box.stories.mdx +15 -16
- package/src/components/Chakra/Center.stories.mdx +31 -16
- package/src/components/Chakra/Grid.stories.mdx +28 -15
- package/src/components/Chakra/Stack.stories.mdx +35 -18
- package/src/components/Checkbox/Checkbox.stories.mdx +33 -11
- package/src/components/Checkbox/Checkbox.test.tsx +47 -2
- package/src/components/Checkbox/Checkbox.tsx +39 -33
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +90 -2
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +82 -2
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +29 -2
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +22 -18
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +47 -81
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +63 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +163 -62
- package/src/components/DatePicker/DatePicker.test.tsx +264 -64
- package/src/components/DatePicker/DatePicker.tsx +159 -128
- package/src/components/DatePicker/_DatePicker.scss +33 -67
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +818 -0
- package/src/components/Fieldset/Fieldset.stories.mdx +55 -0
- package/src/components/Fieldset/Fieldset.test.tsx +125 -0
- package/src/components/Fieldset/Fieldset.tsx +52 -0
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +68 -0
- package/src/components/Form/Form.stories.mdx +24 -6
- package/src/components/Form/Form.test.tsx +1 -1
- package/src/components/Form/Form.tsx +1 -0
- package/src/components/Grid/SimpleGrid.stories.mdx +32 -39
- package/src/components/Grid/SimpleGrid.test.tsx +4 -4
- package/src/components/Heading/Heading.stories.mdx +3 -4
- package/src/components/Heading/Heading.tsx +5 -5
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +124 -0
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +39 -44
- package/src/components/HelperErrorText/HelperErrorText.tsx +37 -39
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +25 -0
- package/src/components/Hero/Hero.stories.mdx +12 -2
- package/src/components/Hero/Hero.tsx +1 -1
- package/src/components/Hero/HeroTypes.tsx +1 -0
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +7 -7
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +8 -6
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +33 -28
- package/src/components/HorizontalRule/HorizontalRule.tsx +27 -29
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +27 -9
- package/src/components/Icons/Icon.stories.mdx +12 -4
- package/src/components/Icons/Icon.test.tsx +18 -0
- package/src/components/Icons/Icon.tsx +16 -1
- package/src/components/Icons/IconSvgs.tsx +22 -0
- package/src/components/Icons/IconTypes.tsx +11 -0
- package/src/components/Image/Image.stories.mdx +220 -0
- package/src/components/Image/Image.test.tsx +131 -29
- package/src/components/Image/Image.tsx +84 -56
- package/src/components/Image/ImageTypes.ts +22 -0
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +190 -0
- package/src/components/Input/Input.stories.tsx +23 -67
- package/src/components/Input/Input.test.tsx +4 -4
- package/src/components/Input/_Input.scss +23 -14
- package/src/components/Link/Link.tsx +4 -1
- package/src/components/List/List.stories.mdx +124 -49
- package/src/components/List/List.test.tsx +142 -63
- package/src/components/List/List.tsx +89 -93
- package/src/components/List/__snapshots__/List.test.tsx.snap +109 -0
- package/src/components/Modal/Modal.stories.mdx +3 -3
- package/src/components/Modal/_Modal.scss +2 -2
- package/src/components/Notification/Notification.stories.mdx +109 -112
- package/src/components/Notification/Notification.test.tsx +99 -110
- package/src/components/Notification/Notification.tsx +156 -159
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +159 -8
- package/src/components/Pagination/Pagination.stories.mdx +26 -27
- package/src/components/Pagination/Pagination.stories.tsx +11 -16
- package/src/components/Pagination/Pagination.test.tsx +276 -146
- package/src/components/Pagination/Pagination.tsx +174 -154
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +285 -0
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
- package/src/components/Radio/Radio.test.tsx +20 -4
- package/src/components/Radio/Radio.tsx +6 -3
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +3 -4
- package/src/components/RadioGroup/RadioGroup.test.tsx +24 -1
- package/src/components/RadioGroup/RadioGroup.tsx +19 -19
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +42 -72
- package/src/components/SearchBar/SearchBar.Test.tsx +20 -1
- package/src/components/SearchBar/SearchBar.stories.mdx +113 -8
- package/src/components/SearchBar/SearchBar.tsx +20 -10
- package/src/components/Select/Select.test.tsx +12 -0
- package/src/components/Select/Select.tsx +5 -2
- package/src/components/Select/SelectTypes.tsx +1 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +28 -59
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +97 -177
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +74 -71
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +739 -0
- package/src/components/Slider/Slider.stories.mdx +529 -0
- package/src/components/Slider/Slider.test.tsx +653 -0
- package/src/components/Slider/Slider.tsx +303 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +1 -1
- package/src/components/StyleGuide/Breakpoints.stories.mdx +34 -10
- package/src/components/StyleGuide/Buttons.stories.mdx +89 -73
- package/src/components/StyleGuide/ColorCard.tsx +46 -0
- package/src/components/StyleGuide/Colors.stories.mdx +171 -311
- package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
- package/src/components/StyleGuide/Forms.stories.mdx +9 -7
- package/src/components/StyleGuide/Iconography.stories.mdx +85 -91
- package/src/components/StyleGuide/Spacing.stories.mdx +31 -23
- package/src/components/StyleGuide/Typography.stories.mdx +202 -189
- package/src/components/StyleGuide/UIDocCard.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.mdx +73 -11
- package/src/components/Tabs/Tabs.tsx +87 -64
- package/src/components/Template/Template.stories.mdx +25 -27
- package/src/components/TextInput/TextInput.stories.mdx +1 -1
- package/src/components/TextInput/TextInput.test.tsx +22 -2
- package/src/components/TextInput/TextInput.tsx +28 -8
- package/src/components/TextInput/TextInputTypes.tsx +2 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +17 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +54 -53
- package/src/components/VideoPlayer/VideoPlayer.tsx +50 -51
- package/src/components/VideoPlayer/VideoPlayerTypes.tsx +2 -2
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +91 -0
- package/src/docs/Chakra.stories.mdx +244 -63
- package/src/docs/Intro.stories.mdx +5 -2
- package/src/hooks/tests/useCarouselStyles.test.ts +140 -0
- package/src/hooks/tests/useNYPLTheme.test.tsx +36 -0
- package/src/hooks/useCarouselStyles.ts +34 -0
- package/src/hooks/useNYPLTheme.ts +67 -0
- package/src/hooks/useWindowSize.ts +40 -0
- package/src/index.ts +22 -19
- package/src/resources.scss +5 -5
- package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
- package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
- package/src/styles/base/{_04-base.scss → _03-base.scss} +7 -2
- package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
- package/src/styles/base/_place-holder.scss +14 -3
- package/src/styles/{03-space → space}/_space-inline.scss +14 -14
- package/src/styles/{03-space → space}/_space-inset.scss +10 -10
- package/src/styles/space/_space-stack.scss +116 -0
- package/src/styles.scss +13 -60
- package/src/theme/components/button.ts +21 -15
- package/src/theme/components/card.ts +174 -0
- package/src/theme/components/checkbox.ts +8 -3
- package/src/theme/components/checkboxGroup.ts +8 -0
- package/src/theme/components/componentWrapper.ts +10 -0
- package/src/theme/components/datePicker.ts +17 -0
- package/src/theme/components/fieldset.ts +18 -0
- package/src/theme/components/global.ts +26 -15
- package/src/theme/components/globalMixins.ts +9 -1
- package/src/theme/components/heading.ts +10 -5
- package/src/theme/components/helperErrorText.ts +9 -0
- package/src/theme/components/hero.ts +4 -3
- package/src/theme/components/horizontalRule.ts +13 -0
- package/src/theme/components/icon.ts +9 -9
- package/src/theme/components/image.ts +116 -0
- package/src/theme/components/label.ts +3 -10
- package/src/theme/components/link.ts +5 -1
- package/src/theme/components/list.ts +73 -0
- package/src/theme/components/notification.ts +93 -0
- package/src/theme/components/pagination.ts +20 -0
- package/src/theme/components/progressIndicator.ts +62 -0
- package/src/theme/components/radio.ts +2 -2
- package/src/theme/components/radioGroup.ts +8 -0
- package/src/theme/components/select.ts +6 -3
- package/src/theme/components/skeletonLoader.ts +107 -0
- package/src/theme/components/slider.ts +79 -0
- package/src/theme/components/statusBadge.ts +1 -2
- package/src/theme/components/tabs.ts +49 -19
- package/src/theme/components/template.ts +8 -8
- package/src/theme/components/textInput.ts +5 -4
- package/src/theme/components/videoPlayer.ts +49 -0
- package/src/theme/foundations/breakpoints.ts +8 -8
- package/src/theme/foundations/global.ts +6 -1
- package/src/theme/foundations/radii.ts +6 -0
- package/src/theme/foundations/spacing.ts +24 -24
- package/src/theme/index.ts +41 -10
- package/src/utils/componentCategories.ts +4 -3
- package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +0 -16
- package/dist/components/Image/Image.stories.d.ts +0 -18
- package/dist/components/List/List.stories.d.ts +0 -7
- package/dist/theme/components/customCheckboxGroup.d.ts +0 -18
- package/dist/theme/components/customRadioGroup.d.ts +0 -18
- package/src/components/Button/_Button.scss +0 -32
- package/src/components/Card/_Card.scss +0 -308
- package/src/components/HelperErrorText/HelperErrorText.stories.tsx +0 -48
- package/src/components/HelperErrorText/_HelperErrorText.scss +0 -9
- package/src/components/HorizontalRule/_HorizontalRule.scss +0 -15
- package/src/components/Image/Image.stories.tsx +0 -54
- package/src/components/Image/_Image.scss +0 -38
- package/src/components/List/List.stories.tsx +0 -139
- package/src/components/List/_List.scss +0 -76
- package/src/components/Notification/_Notification.scss +0 -110
- package/src/components/Pagination/_Pagination.scss +0 -40
- package/src/components/SkeletonLoader/_SkeletonLoader.scss +0 -142
- package/src/components/VideoPlayer/_VideoPlayer.scss +0 -38
- package/src/styles/01-colors/_colors-brand.scss +0 -62
- package/src/styles/01-colors/_colors-utility.scss +0 -67
- package/src/styles/02-typography/_type-scale.css +0 -11
- package/src/styles/02-typography/_type-weight.css +0 -7
- package/src/styles/02-typography/_typefaces.css +0 -4
- package/src/styles/03-space/_space-stack.scss +0 -116
- package/src/styles/03-space/_space.css +0 -30
- package/src/styles/base/_card-grid.scss +0 -78
- package/src/styles/base/_typography.scss +0 -11
- package/src/theme/components/customCheckboxGroup.ts +0 -12
- package/src/theme/components/customRadioGroup.ts +0 -12
|
@@ -130,6 +130,94 @@ exports[`Checkbox Renders the UI snapshot correctly 2`] = `
|
|
|
130
130
|
`;
|
|
131
131
|
|
|
132
132
|
exports[`Checkbox Renders the UI snapshot correctly 3`] = `
|
|
133
|
+
<label
|
|
134
|
+
className="chakra-checkbox css-1uiwwan"
|
|
135
|
+
data-checked=""
|
|
136
|
+
onClick={[Function]}
|
|
137
|
+
>
|
|
138
|
+
<input
|
|
139
|
+
aria-disabled={false}
|
|
140
|
+
aria-invalid={false}
|
|
141
|
+
checked={true}
|
|
142
|
+
className="chakra-checkbox__input"
|
|
143
|
+
disabled={false}
|
|
144
|
+
id="checkbox-checked"
|
|
145
|
+
name="default"
|
|
146
|
+
onBlur={[Function]}
|
|
147
|
+
onChange={[Function]}
|
|
148
|
+
onFocus={[Function]}
|
|
149
|
+
onKeyDown={[Function]}
|
|
150
|
+
onKeyUp={[Function]}
|
|
151
|
+
required={false}
|
|
152
|
+
style={
|
|
153
|
+
Object {
|
|
154
|
+
"border": "0px",
|
|
155
|
+
"clip": "rect(0px, 0px, 0px, 0px)",
|
|
156
|
+
"height": "1px",
|
|
157
|
+
"margin": "-1px",
|
|
158
|
+
"overflow": "hidden",
|
|
159
|
+
"padding": "0px",
|
|
160
|
+
"position": "absolute",
|
|
161
|
+
"whiteSpace": "nowrap",
|
|
162
|
+
"width": "1px",
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
type="checkbox"
|
|
166
|
+
/>
|
|
167
|
+
<span
|
|
168
|
+
aria-hidden={true}
|
|
169
|
+
className="chakra-checkbox__control css-dnty2r"
|
|
170
|
+
data-checked=""
|
|
171
|
+
data-indeterminate=""
|
|
172
|
+
onMouseDown={[Function]}
|
|
173
|
+
onMouseEnter={[Function]}
|
|
174
|
+
onMouseLeave={[Function]}
|
|
175
|
+
onMouseUp={[Function]}
|
|
176
|
+
>
|
|
177
|
+
<div
|
|
178
|
+
style={
|
|
179
|
+
Object {
|
|
180
|
+
"alignItems": "center",
|
|
181
|
+
"display": "flex",
|
|
182
|
+
"height": "100%",
|
|
183
|
+
"justifyContent": "center",
|
|
184
|
+
"transform": "none",
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
>
|
|
188
|
+
<svg
|
|
189
|
+
className="css-o8vbdw"
|
|
190
|
+
style={
|
|
191
|
+
Object {
|
|
192
|
+
"opacity": 1,
|
|
193
|
+
"stroke": "currentColor",
|
|
194
|
+
"strokeWidth": 4,
|
|
195
|
+
"transform": "none",
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
viewBox="0 0 24 24"
|
|
199
|
+
>
|
|
200
|
+
<line
|
|
201
|
+
x1="21"
|
|
202
|
+
x2="3"
|
|
203
|
+
y1="12"
|
|
204
|
+
y2="12"
|
|
205
|
+
/>
|
|
206
|
+
</svg>
|
|
207
|
+
</div>
|
|
208
|
+
</span>
|
|
209
|
+
<span
|
|
210
|
+
className="chakra-checkbox__label css-1oeb2oe"
|
|
211
|
+
data-checked=""
|
|
212
|
+
onMouseDown={[Function]}
|
|
213
|
+
onTouchStart={[Function]}
|
|
214
|
+
>
|
|
215
|
+
Test Label
|
|
216
|
+
</span>
|
|
217
|
+
</label>
|
|
218
|
+
`;
|
|
219
|
+
|
|
220
|
+
exports[`Checkbox Renders the UI snapshot correctly 4`] = `
|
|
133
221
|
<label
|
|
134
222
|
className="chakra-checkbox css-1uiwwan"
|
|
135
223
|
onClick={[Function]}
|
|
@@ -192,7 +280,7 @@ exports[`Checkbox Renders the UI snapshot correctly 3`] = `
|
|
|
192
280
|
</label>
|
|
193
281
|
`;
|
|
194
282
|
|
|
195
|
-
exports[`Checkbox Renders the UI snapshot correctly
|
|
283
|
+
exports[`Checkbox Renders the UI snapshot correctly 5`] = `
|
|
196
284
|
<label
|
|
197
285
|
className="chakra-checkbox css-1uiwwan"
|
|
198
286
|
data-invalid=""
|
|
@@ -258,7 +346,7 @@ exports[`Checkbox Renders the UI snapshot correctly 4`] = `
|
|
|
258
346
|
</label>
|
|
259
347
|
`;
|
|
260
348
|
|
|
261
|
-
exports[`Checkbox Renders the UI snapshot correctly
|
|
349
|
+
exports[`Checkbox Renders the UI snapshot correctly 6`] = `
|
|
262
350
|
<label
|
|
263
351
|
className="chakra-checkbox css-1uiwwan"
|
|
264
352
|
data-disabled=""
|
|
@@ -39,7 +39,7 @@ import Checkbox from "../Checkbox/Checkbox";
|
|
|
39
39
|
| Component Version | DS Version |
|
|
40
40
|
| ----------------- | ---------- |
|
|
41
41
|
| Added | `0.25.1` |
|
|
42
|
-
| Latest | `0.25.
|
|
42
|
+
| Latest | `0.25.3` |
|
|
43
43
|
|
|
44
44
|
<Description of={CheckboxGroup} />
|
|
45
45
|
|
|
@@ -48,8 +48,8 @@ import Checkbox from "../Checkbox/Checkbox";
|
|
|
48
48
|
name="CheckboxGroup"
|
|
49
49
|
args={{
|
|
50
50
|
defaultValue: ["4"],
|
|
51
|
-
invalidText: "This is the error text :(",
|
|
52
51
|
helperText: "This is the helper text for the full group.",
|
|
52
|
+
invalidText: "This is the error text :(",
|
|
53
53
|
isDisabled: false,
|
|
54
54
|
isInvalid: false,
|
|
55
55
|
isRequired: false,
|
|
@@ -57,6 +57,7 @@ import Checkbox from "../Checkbox/Checkbox";
|
|
|
57
57
|
layout: CheckboxGroupLayoutTypes.Column,
|
|
58
58
|
name: "checkbox-story",
|
|
59
59
|
optReqFlag: true,
|
|
60
|
+
showHelperInvalidText: true,
|
|
60
61
|
showLabel: true,
|
|
61
62
|
}}
|
|
62
63
|
>
|
|
@@ -143,6 +144,85 @@ a row.
|
|
|
143
144
|
</DSProvider>
|
|
144
145
|
</Canvas>
|
|
145
146
|
|
|
147
|
+
## Indeterminate Example
|
|
148
|
+
|
|
149
|
+
The "indeterminate" state can be used when a group of checkboxes are not all
|
|
150
|
+
checked or unchecked. In the following example, if only one child checkebox is
|
|
151
|
+
checked, the parent checkbox will be in the "indeterminate" state. Once both
|
|
152
|
+
children are checked, the parent will be in the "checked" state.
|
|
153
|
+
|
|
154
|
+
The following working example can be used in your application to keep track of
|
|
155
|
+
the checked and indeterminate states - taken and modified from Chakra's
|
|
156
|
+
[Checkbox](https://chakra-ui.com/docs/form/checkbox#indeterminate) documentation.
|
|
157
|
+
Note that this example is specifically using NYPL DS `Checkbox` and
|
|
158
|
+
`CheckboxGroup` components.
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
export function IndeterminateExample() {
|
|
162
|
+
const [checkedItems, setCheckedItems] = React.useState([false, false]);
|
|
163
|
+
const allChecked = checkedItems.every(Boolean);
|
|
164
|
+
const isIndeterminate = checkedItems.some(Boolean) && !allChecked;
|
|
165
|
+
return (
|
|
166
|
+
<CheckboxGroup
|
|
167
|
+
labelText="Indeterminate Example"
|
|
168
|
+
name="indeterminate-example"
|
|
169
|
+
>
|
|
170
|
+
<Checkbox
|
|
171
|
+
isChecked={allChecked}
|
|
172
|
+
isIndeterminate={isIndeterminate}
|
|
173
|
+
onChange={(e) => setCheckedItems([e.target.checked, e.target.checked])}
|
|
174
|
+
labelText="Parent Checkbox"
|
|
175
|
+
/>
|
|
176
|
+
<Checkbox
|
|
177
|
+
isChecked={checkedItems[0]}
|
|
178
|
+
onChange={(e) => setCheckedItems([e.target.checked, checkedItems[1]])}
|
|
179
|
+
labelText="Child Checkbox 1"
|
|
180
|
+
/>
|
|
181
|
+
<Checkbox
|
|
182
|
+
isChecked={checkedItems[1]}
|
|
183
|
+
onChange={(e) => setCheckedItems([checkedItems[0], e.target.checked])}
|
|
184
|
+
labelText="Child Checkbox 2"
|
|
185
|
+
/>
|
|
186
|
+
</CheckboxGroup>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
export function IndeterminateExample() {
|
|
192
|
+
const [checkedItems, setCheckedItems] = React.useState([false, false]);
|
|
193
|
+
const allChecked = checkedItems.every(Boolean);
|
|
194
|
+
const isIndeterminate = checkedItems.some(Boolean) && !allChecked;
|
|
195
|
+
return (
|
|
196
|
+
<CheckboxGroup
|
|
197
|
+
labelText="Indeterminate Example"
|
|
198
|
+
name="indeterminate-example"
|
|
199
|
+
>
|
|
200
|
+
<Checkbox
|
|
201
|
+
isChecked={allChecked}
|
|
202
|
+
isIndeterminate={isIndeterminate}
|
|
203
|
+
onChange={(e) => setCheckedItems([e.target.checked, e.target.checked])}
|
|
204
|
+
labelText="Parent Checkbox"
|
|
205
|
+
/>
|
|
206
|
+
<Checkbox
|
|
207
|
+
isChecked={checkedItems[0]}
|
|
208
|
+
onChange={(e) => setCheckedItems([e.target.checked, checkedItems[1]])}
|
|
209
|
+
labelText="Child Checkbox 1"
|
|
210
|
+
/>
|
|
211
|
+
<Checkbox
|
|
212
|
+
isChecked={checkedItems[1]}
|
|
213
|
+
onChange={(e) => setCheckedItems([checkedItems[0], e.target.checked])}
|
|
214
|
+
labelText="Child Checkbox 2"
|
|
215
|
+
/>
|
|
216
|
+
</CheckboxGroup>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
<Canvas>
|
|
221
|
+
<DSProvider>
|
|
222
|
+
<IndeterminateExample />
|
|
223
|
+
</DSProvider>
|
|
224
|
+
</Canvas>
|
|
225
|
+
|
|
146
226
|
## Getting Checkbox Data Values
|
|
147
227
|
|
|
148
228
|
### Controlled Component using `name`, `defaultValue`, and `onChange` props
|
|
@@ -114,7 +114,7 @@ describe("Checkbox", () => {
|
|
|
114
114
|
// The "group" role here is for the `fieldset` element.
|
|
115
115
|
expect(screen.getByRole("group")).toHaveAttribute(
|
|
116
116
|
"id",
|
|
117
|
-
"checkbox-group
|
|
117
|
+
"some-id-checkbox-group"
|
|
118
118
|
);
|
|
119
119
|
});
|
|
120
120
|
|
|
@@ -192,7 +192,34 @@ describe("Checkbox", () => {
|
|
|
192
192
|
|
|
193
193
|
it("sets the error state for all its Checkbox children", () => {
|
|
194
194
|
render(
|
|
195
|
-
<CheckboxGroup
|
|
195
|
+
<CheckboxGroup
|
|
196
|
+
labelText="Test Label"
|
|
197
|
+
name="test9"
|
|
198
|
+
isInvalid
|
|
199
|
+
invalidText="There's an error!"
|
|
200
|
+
>
|
|
201
|
+
<Checkbox value="2" labelText="Checkbox 2" />
|
|
202
|
+
<Checkbox value="3" labelText="Checkbox 3" />
|
|
203
|
+
<Checkbox value="4" labelText="Checkbox 4" />
|
|
204
|
+
</CheckboxGroup>
|
|
205
|
+
);
|
|
206
|
+
const Checkboxes = screen.getAllByRole("checkbox");
|
|
207
|
+
|
|
208
|
+
expect(Checkboxes).toHaveLength(3);
|
|
209
|
+
expect(Checkboxes[0]).toHaveAttribute("aria-invalid");
|
|
210
|
+
expect(Checkboxes[1]).toHaveAttribute("aria-invalid");
|
|
211
|
+
expect(Checkboxes[2]).toHaveAttribute("aria-invalid");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("does not render the invalid text when 'isInvalid' is true but 'showHelperInvalidText' is false", () => {
|
|
215
|
+
render(
|
|
216
|
+
<CheckboxGroup
|
|
217
|
+
labelText="Test Label"
|
|
218
|
+
name="test9"
|
|
219
|
+
isInvalid
|
|
220
|
+
invalidText="There's an error!"
|
|
221
|
+
showHelperInvalidText={false}
|
|
222
|
+
>
|
|
196
223
|
<Checkbox value="2" labelText="Checkbox 2" />
|
|
197
224
|
<Checkbox value="3" labelText="Checkbox 3" />
|
|
198
225
|
<Checkbox value="4" labelText="Checkbox 4" />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
|
-
Stack,
|
|
5
4
|
CheckboxGroup as ChakraCheckboxGroup,
|
|
5
|
+
Stack,
|
|
6
6
|
useMultiStyleConfig,
|
|
7
7
|
} from "@chakra-ui/react";
|
|
8
8
|
|
|
@@ -11,18 +11,19 @@ import generateUUID from "../../helpers/generateUUID";
|
|
|
11
11
|
import { spacing } from "../../theme/foundations/spacing";
|
|
12
12
|
import { CheckboxGroupLayoutTypes } from "./CheckboxGroupLayoutTypes";
|
|
13
13
|
import Checkbox from "../Checkbox/Checkbox";
|
|
14
|
+
import Fieldset from "../Fieldset/Fieldset";
|
|
14
15
|
|
|
15
16
|
export interface CheckboxGroupProps {
|
|
16
17
|
/** Any child node passed to the component. */
|
|
17
18
|
children: React.ReactNode;
|
|
18
19
|
/** Populates the initial value of the input */
|
|
19
20
|
defaultValue?: string[];
|
|
20
|
-
/** Optional string to populate the HelperErrorText for error state */
|
|
21
|
-
invalidText?: string;
|
|
22
21
|
/** Optional string to populate the HelperErrorText for standard state */
|
|
23
22
|
helperText?: string;
|
|
24
23
|
/** ID that other components can cross reference for accessibility purposes */
|
|
25
24
|
id?: string;
|
|
25
|
+
/** Optional string to populate the HelperErrorText for error state */
|
|
26
|
+
invalidText?: string;
|
|
26
27
|
/** Adds the 'disabled' prop to the input when true. */
|
|
27
28
|
isDisabled?: boolean;
|
|
28
29
|
/** A`dds the 'aria-invalid' attribute to the input and
|
|
@@ -41,6 +42,8 @@ export interface CheckboxGroupProps {
|
|
|
41
42
|
onChange?: (value: string[]) => void;
|
|
42
43
|
/** Whether or not to display "Required"/"Optional" in the label text. */
|
|
43
44
|
optReqFlag?: boolean;
|
|
45
|
+
/** Offers the ability to hide the helper/invalid text. */
|
|
46
|
+
showHelperInvalidText?: boolean;
|
|
44
47
|
/** Offers the ability to show the group's legend onscreen or hide it. Refer
|
|
45
48
|
* to the `labelText` property for more information. */
|
|
46
49
|
showLabel?: boolean;
|
|
@@ -59,9 +62,9 @@ const CheckboxGroup = React.forwardRef<HTMLInputElement, CheckboxGroupProps>(
|
|
|
59
62
|
const {
|
|
60
63
|
children,
|
|
61
64
|
defaultValue = [],
|
|
62
|
-
invalidText,
|
|
63
65
|
helperText,
|
|
64
66
|
id = generateUUID(),
|
|
67
|
+
invalidText,
|
|
65
68
|
isDisabled = false,
|
|
66
69
|
isInvalid = false,
|
|
67
70
|
isRequired = false,
|
|
@@ -70,6 +73,7 @@ const CheckboxGroup = React.forwardRef<HTMLInputElement, CheckboxGroupProps>(
|
|
|
70
73
|
name,
|
|
71
74
|
onChange,
|
|
72
75
|
optReqFlag = true,
|
|
76
|
+
showHelperInvalidText = true,
|
|
73
77
|
showLabel = true,
|
|
74
78
|
} = props;
|
|
75
79
|
const footnote = isInvalid ? invalidText : helperText;
|
|
@@ -110,19 +114,16 @@ const CheckboxGroup = React.forwardRef<HTMLInputElement, CheckboxGroupProps>(
|
|
|
110
114
|
}
|
|
111
115
|
});
|
|
112
116
|
|
|
113
|
-
// Get the Chakra-based styles for
|
|
114
|
-
const styles = useMultiStyleConfig("
|
|
117
|
+
// Get the Chakra-based styles for the custom elements in this component.
|
|
118
|
+
const styles = useMultiStyleConfig("CheckboxGroup", {});
|
|
115
119
|
|
|
116
120
|
return (
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
</Box>
|
|
124
|
-
)}
|
|
125
|
-
</legend>
|
|
121
|
+
<Fieldset
|
|
122
|
+
id={`${id}-checkbox-group`}
|
|
123
|
+
isLegendHidden={!showLabel}
|
|
124
|
+
legendText={labelText}
|
|
125
|
+
optReqFlag={optReqFlag}
|
|
126
|
+
>
|
|
126
127
|
<ChakraCheckboxGroup {...checkboxProps}>
|
|
127
128
|
<Stack
|
|
128
129
|
id={id}
|
|
@@ -131,16 +132,19 @@ const CheckboxGroup = React.forwardRef<HTMLInputElement, CheckboxGroupProps>(
|
|
|
131
132
|
spacing={spacingProp}
|
|
132
133
|
ref={ref}
|
|
133
134
|
aria-label={!showLabel ? labelText : null}
|
|
135
|
+
sx={styles.stack}
|
|
134
136
|
>
|
|
135
137
|
{newChildren}
|
|
136
138
|
</Stack>
|
|
137
139
|
</ChakraCheckboxGroup>
|
|
138
|
-
{footnote && (
|
|
140
|
+
{footnote && showHelperInvalidText && (
|
|
139
141
|
<Box __css={styles.helper}>
|
|
140
|
-
<HelperErrorText
|
|
142
|
+
<HelperErrorText isInvalid={isInvalid} id={`${id}-helperErrorText`}>
|
|
143
|
+
{footnote}
|
|
144
|
+
</HelperErrorText>
|
|
141
145
|
</Box>
|
|
142
146
|
)}
|
|
143
|
-
</
|
|
147
|
+
</Fieldset>
|
|
144
148
|
);
|
|
145
149
|
}
|
|
146
150
|
);
|
|
@@ -3,19 +3,15 @@
|
|
|
3
3
|
exports[`Checkbox renders the UI snapshot correctly 1`] = `
|
|
4
4
|
<fieldset
|
|
5
5
|
className="css-0"
|
|
6
|
-
id="checkbox-group
|
|
6
|
+
id="column-checkbox-group"
|
|
7
7
|
>
|
|
8
|
-
<legend
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<span>
|
|
12
|
-
column
|
|
13
|
-
</span>
|
|
14
|
-
<span
|
|
8
|
+
<legend>
|
|
9
|
+
column
|
|
10
|
+
<div
|
|
15
11
|
className="css-0"
|
|
16
12
|
>
|
|
17
13
|
Optional
|
|
18
|
-
</
|
|
14
|
+
</div>
|
|
19
15
|
</legend>
|
|
20
16
|
<div
|
|
21
17
|
aria-label={null}
|
|
@@ -152,19 +148,15 @@ exports[`Checkbox renders the UI snapshot correctly 1`] = `
|
|
|
152
148
|
exports[`Checkbox renders the UI snapshot correctly 2`] = `
|
|
153
149
|
<fieldset
|
|
154
150
|
className="css-0"
|
|
155
|
-
id="checkbox-group
|
|
151
|
+
id="row-checkbox-group"
|
|
156
152
|
>
|
|
157
|
-
<legend
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
<span>
|
|
161
|
-
row
|
|
162
|
-
</span>
|
|
163
|
-
<span
|
|
153
|
+
<legend>
|
|
154
|
+
row
|
|
155
|
+
<div
|
|
164
156
|
className="css-0"
|
|
165
157
|
>
|
|
166
158
|
Optional
|
|
167
|
-
</
|
|
159
|
+
</div>
|
|
168
160
|
</legend>
|
|
169
161
|
<div
|
|
170
162
|
aria-label={null}
|
|
@@ -301,19 +293,15 @@ exports[`Checkbox renders the UI snapshot correctly 2`] = `
|
|
|
301
293
|
exports[`Checkbox renders the UI snapshot correctly 3`] = `
|
|
302
294
|
<fieldset
|
|
303
295
|
className="css-0"
|
|
304
|
-
id="checkbox-group
|
|
296
|
+
id="noLabel-checkbox-group"
|
|
305
297
|
>
|
|
306
|
-
<legend
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
<span>
|
|
310
|
-
no label
|
|
311
|
-
</span>
|
|
312
|
-
<span
|
|
298
|
+
<legend>
|
|
299
|
+
no label
|
|
300
|
+
<div
|
|
313
301
|
className="css-0"
|
|
314
302
|
>
|
|
315
303
|
Optional
|
|
316
|
-
</
|
|
304
|
+
</div>
|
|
317
305
|
</legend>
|
|
318
306
|
<div
|
|
319
307
|
aria-label="no label"
|
|
@@ -450,19 +438,15 @@ exports[`Checkbox renders the UI snapshot correctly 3`] = `
|
|
|
450
438
|
exports[`Checkbox renders the UI snapshot correctly 4`] = `
|
|
451
439
|
<fieldset
|
|
452
440
|
className="css-0"
|
|
453
|
-
id="checkbox-group
|
|
441
|
+
id="helperText-checkbox-group"
|
|
454
442
|
>
|
|
455
|
-
<legend
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
<span>
|
|
459
|
-
helperText
|
|
460
|
-
</span>
|
|
461
|
-
<span
|
|
443
|
+
<legend>
|
|
444
|
+
helperText
|
|
445
|
+
<div
|
|
462
446
|
className="css-0"
|
|
463
447
|
>
|
|
464
448
|
Optional
|
|
465
|
-
</
|
|
449
|
+
</div>
|
|
466
450
|
</legend>
|
|
467
451
|
<div
|
|
468
452
|
aria-label={null}
|
|
@@ -599,7 +583,9 @@ exports[`Checkbox renders the UI snapshot correctly 4`] = `
|
|
|
599
583
|
<div
|
|
600
584
|
aria-atomic={true}
|
|
601
585
|
aria-live="off"
|
|
602
|
-
className="
|
|
586
|
+
className=" css-0"
|
|
587
|
+
data-isinvalid={false}
|
|
588
|
+
id="helperText-helperErrorText"
|
|
603
589
|
>
|
|
604
590
|
helper text
|
|
605
591
|
</div>
|
|
@@ -610,19 +596,15 @@ exports[`Checkbox renders the UI snapshot correctly 4`] = `
|
|
|
610
596
|
exports[`Checkbox renders the UI snapshot correctly 5`] = `
|
|
611
597
|
<fieldset
|
|
612
598
|
className="css-0"
|
|
613
|
-
id="checkbox-group
|
|
599
|
+
id="invalidText-checkbox-group"
|
|
614
600
|
>
|
|
615
|
-
<legend
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
<span>
|
|
619
|
-
invalidText
|
|
620
|
-
</span>
|
|
621
|
-
<span
|
|
601
|
+
<legend>
|
|
602
|
+
invalidText
|
|
603
|
+
<div
|
|
622
604
|
className="css-0"
|
|
623
605
|
>
|
|
624
606
|
Optional
|
|
625
|
-
</
|
|
607
|
+
</div>
|
|
626
608
|
</legend>
|
|
627
609
|
<div
|
|
628
610
|
aria-label={null}
|
|
@@ -759,14 +741,10 @@ exports[`Checkbox renders the UI snapshot correctly 5`] = `
|
|
|
759
741
|
exports[`Checkbox renders the UI snapshot correctly 6`] = `
|
|
760
742
|
<fieldset
|
|
761
743
|
className="css-0"
|
|
762
|
-
id="checkbox-group
|
|
744
|
+
id="optReq-checkbox-group"
|
|
763
745
|
>
|
|
764
|
-
<legend
|
|
765
|
-
|
|
766
|
-
>
|
|
767
|
-
<span>
|
|
768
|
-
no optional or required label
|
|
769
|
-
</span>
|
|
746
|
+
<legend>
|
|
747
|
+
no optional or required label
|
|
770
748
|
</legend>
|
|
771
749
|
<div
|
|
772
750
|
aria-label={null}
|
|
@@ -903,19 +881,15 @@ exports[`Checkbox renders the UI snapshot correctly 6`] = `
|
|
|
903
881
|
exports[`Checkbox renders the UI snapshot correctly 7`] = `
|
|
904
882
|
<fieldset
|
|
905
883
|
className="css-0"
|
|
906
|
-
id="checkbox-group
|
|
884
|
+
id="required-checkbox-group"
|
|
907
885
|
>
|
|
908
|
-
<legend
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
<span>
|
|
912
|
-
required
|
|
913
|
-
</span>
|
|
914
|
-
<span
|
|
886
|
+
<legend>
|
|
887
|
+
required
|
|
888
|
+
<div
|
|
915
889
|
className="css-0"
|
|
916
890
|
>
|
|
917
|
-
|
|
918
|
-
</
|
|
891
|
+
Optional
|
|
892
|
+
</div>
|
|
919
893
|
</legend>
|
|
920
894
|
<div
|
|
921
895
|
aria-label={null}
|
|
@@ -1052,19 +1026,15 @@ exports[`Checkbox renders the UI snapshot correctly 7`] = `
|
|
|
1052
1026
|
exports[`Checkbox renders the UI snapshot correctly 8`] = `
|
|
1053
1027
|
<fieldset
|
|
1054
1028
|
className="css-0"
|
|
1055
|
-
id="checkbox-group
|
|
1029
|
+
id="invalid-checkbox-group"
|
|
1056
1030
|
>
|
|
1057
|
-
<legend
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
<span>
|
|
1061
|
-
invalid
|
|
1062
|
-
</span>
|
|
1063
|
-
<span
|
|
1031
|
+
<legend>
|
|
1032
|
+
invalid
|
|
1033
|
+
<div
|
|
1064
1034
|
className="css-0"
|
|
1065
1035
|
>
|
|
1066
1036
|
Optional
|
|
1067
|
-
</
|
|
1037
|
+
</div>
|
|
1068
1038
|
</legend>
|
|
1069
1039
|
<div
|
|
1070
1040
|
aria-label={null}
|
|
@@ -1207,19 +1177,15 @@ exports[`Checkbox renders the UI snapshot correctly 8`] = `
|
|
|
1207
1177
|
exports[`Checkbox renders the UI snapshot correctly 9`] = `
|
|
1208
1178
|
<fieldset
|
|
1209
1179
|
className="css-0"
|
|
1210
|
-
id="checkbox-group
|
|
1180
|
+
id="disabled-checkbox-group"
|
|
1211
1181
|
>
|
|
1212
|
-
<legend
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
<span>
|
|
1216
|
-
disabled
|
|
1217
|
-
</span>
|
|
1218
|
-
<span
|
|
1182
|
+
<legend>
|
|
1183
|
+
disabled
|
|
1184
|
+
<div
|
|
1219
1185
|
className="css-0"
|
|
1220
1186
|
>
|
|
1221
1187
|
Optional
|
|
1222
|
-
</
|
|
1188
|
+
</div>
|
|
1223
1189
|
</legend>
|
|
1224
1190
|
<div
|
|
1225
1191
|
aria-label={null}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Box, useMultiStyleConfig } from "@chakra-ui/react";
|
|
3
|
+
import generateUUID from "../../helpers/generateUUID";
|
|
4
|
+
import Heading from "../Heading/Heading";
|
|
5
|
+
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
6
|
+
import HelperErrorText from "../HelperErrorText/HelperErrorText";
|
|
7
|
+
import Text from "../Text/Text";
|
|
8
|
+
|
|
9
|
+
export interface ComponentWrapperProps {
|
|
10
|
+
/** The UI elements that will be wrapped by this component */
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
/** Optional string to set the text for a video description */
|
|
13
|
+
descriptionText?: string;
|
|
14
|
+
/** Optional string to set the text for a `Heading` component */
|
|
15
|
+
headingText?: string;
|
|
16
|
+
/** Optional string to set the text for a `HelperErrorText` component */
|
|
17
|
+
helperText?: string;
|
|
18
|
+
/** ID that other components can cross reference for accessibility purposes */
|
|
19
|
+
id?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ComponentWrapper(
|
|
23
|
+
props: React.PropsWithChildren<ComponentWrapperProps>
|
|
24
|
+
) {
|
|
25
|
+
const {
|
|
26
|
+
children,
|
|
27
|
+
descriptionText,
|
|
28
|
+
headingText,
|
|
29
|
+
helperText,
|
|
30
|
+
id = generateUUID(),
|
|
31
|
+
} = props;
|
|
32
|
+
const hasChildren = !!children;
|
|
33
|
+
const styles = useMultiStyleConfig("ComponentWrapper", { hasChildren });
|
|
34
|
+
|
|
35
|
+
if (!hasChildren) {
|
|
36
|
+
console.warn("Component Wrapper has no children.");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Box __css={styles}>
|
|
41
|
+
<>
|
|
42
|
+
{headingText && (
|
|
43
|
+
<Heading
|
|
44
|
+
id={`${id}-heading`}
|
|
45
|
+
level={HeadingLevels.Two}
|
|
46
|
+
text={headingText}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
{descriptionText && <Text>{descriptionText}</Text>}
|
|
50
|
+
{children}
|
|
51
|
+
{helperText && (
|
|
52
|
+
<Box __css={styles.helperText}>
|
|
53
|
+
<HelperErrorText id={`${id}-helperText`} isInvalid={false}>
|
|
54
|
+
{helperText}
|
|
55
|
+
</HelperErrorText>
|
|
56
|
+
</Box>
|
|
57
|
+
)}
|
|
58
|
+
</>
|
|
59
|
+
</Box>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default ComponentWrapper;
|