@nypl/design-system-react-components 0.27.0 → 0.28.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 +29 -0
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
- package/dist/components/Button/Button.d.ts +2 -10
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
- package/dist/components/Card/Card.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +10 -8
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/Form/Form.d.ts +2 -2
- package/dist/components/Grid/SimpleGrid.d.ts +6 -3
- package/dist/components/Heading/Heading.d.ts +2 -5
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
- package/dist/components/Hero/Hero.d.ts +13 -9
- package/dist/components/Icons/Icon.d.ts +6 -5
- package/dist/components/Icons/IconSvgs.d.ts +21 -21
- package/dist/components/Image/Image.d.ts +8 -5
- package/dist/components/Link/Link.d.ts +1 -9
- package/dist/components/List/List.d.ts +7 -11
- package/dist/components/Logo/Logo.d.ts +2 -5
- package/dist/components/Logo/LogoSvgs.d.ts +39 -39
- package/dist/components/Notification/Notification.d.ts +1 -1
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +2 -5
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
- package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Template/Template.d.ts +2 -0
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +21 -9
- package/dist/components/Toggle/Toggle.d.ts +1 -5
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +856 -1155
- 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 +858 -1220
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/types.d.ts +1 -0
- package/dist/index.d.ts +26 -47
- package/dist/theme/components/buttonGroup.d.ts +11 -0
- package/dist/theme/components/card.d.ts +104 -8
- package/dist/theme/components/componentWrapper.d.ts +4 -3
- package/dist/theme/components/customTable.d.ts +11 -14
- package/dist/theme/components/fieldset.d.ts +4 -3
- package/dist/theme/components/helperErrorText.d.ts +4 -3
- package/dist/theme/components/hero.d.ts +1 -1
- package/dist/theme/components/horizontalRule.d.ts +4 -3
- package/dist/theme/components/icon.d.ts +47743 -1
- package/dist/theme/components/image.d.ts +563 -10
- package/dist/theme/components/label.d.ts +4 -3
- package/dist/theme/components/list.d.ts +6 -7
- package/dist/theme/components/logo.d.ts +474 -1
- package/dist/theme/components/notification.d.ts +20 -16
- package/dist/theme/components/progressIndicator.d.ts +6 -4
- package/dist/theme/components/select.d.ts +4 -4
- package/dist/theme/components/skeletonLoader.d.ts +14 -10
- package/dist/theme/components/skipNavigation.d.ts +22 -0
- package/dist/theme/components/slider.d.ts +7 -6
- package/dist/theme/components/structuredContent.d.ts +10 -9
- package/dist/theme/components/text.d.ts +7 -1
- package/dist/theme/components/toggle.d.ts +6 -4
- package/dist/theme/provider.d.ts +2 -4
- package/dist/utils/componentCategories.d.ts +1 -1
- package/dist/utils/interfaces.d.ts +5 -0
- package/dist/utils/utils.d.ts +2 -18
- package/package.json +2 -2
- package/src/__tests__/setup.ts +3 -3
- package/src/__tests__/utils/utils.test.ts +1 -23
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
- package/src/components/Accordion/Accordion.stories.mdx +43 -44
- package/src/components/Accordion/Accordion.test.tsx +5 -13
- package/src/components/Accordion/Accordion.tsx +14 -18
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
- package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
- package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
- package/src/components/Button/Button.stories.mdx +89 -126
- package/src/components/Button/Button.test.tsx +16 -30
- package/src/components/Button/Button.tsx +14 -20
- package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
- package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
- package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
- package/src/components/Card/Card.stories.mdx +143 -177
- package/src/components/Card/Card.test.tsx +36 -97
- package/src/components/Card/Card.tsx +78 -74
- package/src/components/Chakra/Box.stories.mdx +2 -6
- package/src/components/Chakra/Center.stories.mdx +5 -23
- package/src/components/Chakra/Flex.stories.mdx +4 -6
- package/src/components/Chakra/Stack.stories.mdx +9 -10
- package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.test.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +20 -13
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +0 -11
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
- package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
- package/src/components/DatePicker/DatePicker.test.tsx +21 -19
- package/src/components/DatePicker/DatePicker.tsx +57 -49
- package/src/components/Form/Form.stories.mdx +46 -31
- package/src/components/Form/Form.test.tsx +1 -18
- package/src/components/Form/Form.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
- package/src/components/Grid/SimpleGrid.test.tsx +7 -9
- package/src/components/Grid/SimpleGrid.tsx +14 -11
- package/src/components/Heading/Heading.stories.mdx +27 -72
- package/src/components/Heading/Heading.test.tsx +18 -44
- package/src/components/Heading/Heading.tsx +7 -10
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
- package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
- package/src/components/Hero/Hero.stories.mdx +219 -216
- package/src/components/Hero/Hero.test.tsx +107 -223
- package/src/components/Hero/Hero.tsx +63 -61
- package/src/components/Icons/Icon.stories.mdx +172 -118
- package/src/components/Icons/Icon.test.tsx +8 -16
- package/src/components/Icons/Icon.tsx +75 -29
- package/src/components/Icons/IconSvgs.tsx +42 -42
- package/src/components/Image/Image.stories.mdx +45 -132
- package/src/components/Image/Image.test.tsx +16 -31
- package/src/components/Image/Image.tsx +28 -12
- package/src/components/Link/Link.stories.mdx +30 -80
- package/src/components/Link/Link.test.tsx +25 -53
- package/src/components/Link/Link.tsx +43 -56
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
- package/src/components/List/List.stories.mdx +20 -31
- package/src/components/List/List.test.tsx +24 -43
- package/src/components/List/List.tsx +25 -36
- package/src/components/Logo/Logo.stories.mdx +94 -50
- package/src/components/Logo/Logo.test.tsx +10 -19
- package/src/components/Logo/Logo.tsx +50 -17
- package/src/components/Logo/LogoSvgs.tsx +78 -78
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
- package/src/components/Modal/Modal.stories.mdx +8 -9
- package/src/components/Modal/Modal.test.tsx +5 -10
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/components/Notification/Notification.stories.mdx +10 -28
- package/src/components/Notification/Notification.test.tsx +9 -12
- package/src/components/Notification/Notification.tsx +34 -37
- package/src/components/Pagination/Pagination.stories.mdx +2 -2
- package/src/components/Pagination/Pagination.tsx +15 -10
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
- package/src/components/Radio/Radio.stories.mdx +1 -1
- package/src/components/Radio/Radio.tsx +9 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
- package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
- package/src/components/RadioGroup/RadioGroup.tsx +28 -24
- package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
- package/src/components/SearchBar/SearchBar.test.tsx +1 -1
- package/src/components/SearchBar/SearchBar.tsx +14 -22
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +0 -12
- package/src/components/Select/Select.stories.mdx +8 -23
- package/src/components/Select/Select.test.tsx +6 -7
- package/src/components/Select/Select.tsx +13 -26
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
- package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
- package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
- package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
- package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
- package/src/components/Slider/Slider.stories.mdx +19 -53
- package/src/components/Slider/Slider.test.tsx +2 -2
- package/src/components/Slider/Slider.tsx +10 -12
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
- package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
- package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
- package/src/components/StatusBadge/StatusBadge.tsx +3 -10
- package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
- package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
- package/src/components/StructuredContent/StructuredContent.tsx +9 -18
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
- package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
- package/src/components/StyleGuide/ColorCard.tsx +2 -4
- package/src/components/StyleGuide/Colors.stories.mdx +7 -8
- package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
- package/src/components/StyleGuide/Forms.stories.mdx +0 -1
- package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
- package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
- package/src/components/StyleGuide/Typography.stories.mdx +15 -18
- package/src/components/Table/Table.stories.mdx +85 -1
- package/src/components/Table/Table.test.tsx +57 -1
- package/src/components/Table/Table.tsx +7 -4
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
- package/src/components/Tabs/Tabs.stories.mdx +1 -1
- package/src/components/Tabs/Tabs.test.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +26 -27
- package/src/components/Template/Template.stories.mdx +49 -54
- package/src/components/Template/Template.tsx +9 -3
- package/src/components/Text/Text.stories.mdx +5 -11
- package/src/components/Text/Text.test.tsx +3 -6
- package/src/components/Text/Text.tsx +3 -5
- package/src/components/TextInput/TextInput.stories.mdx +10 -22
- package/src/components/TextInput/TextInput.test.tsx +32 -62
- package/src/components/TextInput/TextInput.tsx +61 -30
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
- package/src/components/Toggle/Toggle.stories.mdx +5 -16
- package/src/components/Toggle/Toggle.test.tsx +2 -3
- package/src/components/Toggle/Toggle.tsx +9 -10
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
- package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
- package/src/docs/Chakra.stories.mdx +14 -11
- package/src/docs/Welcome.stories.mdx +23 -43
- package/src/helpers/types.ts +1 -0
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useNYPLTheme.stories.mdx +3 -6
- package/src/index.ts +51 -45
- package/src/theme/components/buttonGroup.ts +10 -0
- package/src/theme/components/card.ts +50 -15
- package/src/theme/components/componentWrapper.ts +5 -1
- package/src/theme/components/customTable.ts +8 -2
- package/src/theme/components/fieldset.ts +5 -1
- package/src/theme/components/helperErrorText.ts +5 -1
- package/src/theme/components/hero.ts +2 -2
- package/src/theme/components/horizontalRule.ts +5 -1
- package/src/theme/components/icon.ts +7 -1
- package/src/theme/components/image.ts +14 -3
- package/src/theme/components/label.ts +5 -1
- package/src/theme/components/list.ts +8 -2
- package/src/theme/components/logo.ts +5 -1
- package/src/theme/components/notification.ts +38 -14
- package/src/theme/components/progressIndicator.ts +10 -5
- package/src/theme/components/select.ts +5 -2
- package/src/theme/components/skeletonLoader.ts +8 -2
- package/src/theme/components/skipNavigation.ts +26 -0
- package/src/theme/components/slider.ts +13 -1
- package/src/theme/components/structuredContent.ts +11 -1
- package/src/theme/components/text.ts +12 -5
- package/src/theme/components/toggle.ts +9 -3
- package/src/theme/index.ts +4 -0
- package/src/theme/provider.tsx +1 -1
- package/src/utils/componentCategories.ts +13 -5
- package/src/utils/interfaces.ts +5 -0
- package/src/utils/utils.ts +2 -32
- package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
- package/dist/components/Button/ButtonTypes.d.ts +0 -8
- package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
- package/dist/components/Form/FormTypes.d.ts +0 -2
- package/dist/components/Grid/GridTypes.d.ts +0 -9
- package/dist/components/Heading/HeadingTypes.d.ts +0 -14
- package/dist/components/Hero/HeroTypes.d.ts +0 -12
- package/dist/components/Icons/IconTypes.d.ts +0 -77
- package/dist/components/Image/ImageTypes.d.ts +0 -22
- package/dist/components/Link/LinkTypes.d.ts +0 -8
- package/dist/components/List/ListTypes.d.ts +0 -5
- package/dist/components/Logo/LogoTypes.d.ts +0 -54
- package/dist/components/Notification/NotificationTypes.d.ts +0 -5
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
- package/dist/components/Select/SelectTypes.d.ts +0 -8
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
- package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
- package/dist/components/Text/TextTypes.d.ts +0 -6
- package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
- package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
- package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
- package/dist/helpers/enums.d.ts +0 -4
- package/dist/utils/siteSections.d.ts +0 -2
- package/src/components/Accordion/AccordionTypes.tsx +0 -5
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
- package/src/components/Button/ButtonTypes.tsx +0 -8
- package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
- package/src/components/Form/FormTypes.tsx +0 -3
- package/src/components/Grid/GridTypes.tsx +0 -9
- package/src/components/Heading/HeadingTypes.tsx +0 -15
- package/src/components/Hero/HeroTypes.tsx +0 -20
- package/src/components/Icons/IconTypes.tsx +0 -83
- package/src/components/Image/ImageTypes.ts +0 -24
- package/src/components/Link/LinkTypes.tsx +0 -8
- package/src/components/List/ListTypes.tsx +0 -5
- package/src/components/Logo/LogoTypes.tsx +0 -56
- package/src/components/Notification/NotificationTypes.tsx +0 -5
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
- package/src/components/Select/SelectTypes.tsx +0 -10
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
- package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
- package/src/components/Text/TextTypes.tsx +0 -6
- package/src/components/TextInput/TextInputTypes.tsx +0 -48
- package/src/components/Toggle/ToggleTypes.tsx +0 -4
- package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
- package/src/helpers/enums.ts +0 -4
- package/src/utils/siteSections.ts +0 -10
|
@@ -3,8 +3,8 @@ import React, { useState, useRef } from "react";
|
|
|
3
3
|
|
|
4
4
|
import Link from "../Link/Link";
|
|
5
5
|
import List from "../List/List";
|
|
6
|
-
import { ListTypes } from "../List/ListTypes";
|
|
7
6
|
import { range } from "../../utils/utils";
|
|
7
|
+
|
|
8
8
|
export interface PaginationProps {
|
|
9
9
|
/** Additional className. */
|
|
10
10
|
className?: string;
|
|
@@ -51,7 +51,7 @@ export const Pagination = chakra((props: PaginationProps) => {
|
|
|
51
51
|
// function exists, then set the internal state – selectedPage –
|
|
52
52
|
// to the new currentPage and update the refCurrentPage with that value.
|
|
53
53
|
React.useEffect(() => {
|
|
54
|
-
if (onPageChange && currentPage !== refCurrentPage.current) {
|
|
54
|
+
if (onPageChange && currentPage && currentPage !== refCurrentPage.current) {
|
|
55
55
|
setSelectedPage(currentPage);
|
|
56
56
|
refCurrentPage.current = currentPage;
|
|
57
57
|
}
|
|
@@ -110,7 +110,10 @@ export const Pagination = chakra((props: PaginationProps) => {
|
|
|
110
110
|
* 2. Otherwise, we stay on the same page by setting the `href` attribute to
|
|
111
111
|
* "#" and call the `onPageChange` prop through the `onClick` callback.
|
|
112
112
|
*/
|
|
113
|
-
const getLinkElement = (
|
|
113
|
+
const getLinkElement = (
|
|
114
|
+
type: "items" | "previous" | "next",
|
|
115
|
+
item?: number
|
|
116
|
+
) => {
|
|
114
117
|
const isSelectedPage = selectedPage === item;
|
|
115
118
|
// The current page link has different styles.
|
|
116
119
|
const currentStyles = isSelectedPage
|
|
@@ -121,11 +124,13 @@ export const Pagination = chakra((props: PaginationProps) => {
|
|
|
121
124
|
: {};
|
|
122
125
|
const allAttrs = {
|
|
123
126
|
items: {
|
|
124
|
-
href: changeUrls ? getPageHref(item) : "#",
|
|
127
|
+
href: changeUrls ? getPageHref(item as number) : "#",
|
|
125
128
|
attributes: {
|
|
126
129
|
"aria-label": `Page ${item}`,
|
|
127
130
|
"aria-current": isSelectedPage ? "page" : null,
|
|
128
|
-
onClick: changeUrls
|
|
131
|
+
onClick: changeUrls
|
|
132
|
+
? undefined
|
|
133
|
+
: (e: Event) => handlePageClick(e, item as number),
|
|
129
134
|
},
|
|
130
135
|
text: item,
|
|
131
136
|
},
|
|
@@ -149,13 +154,13 @@ export const Pagination = chakra((props: PaginationProps) => {
|
|
|
149
154
|
const linkAttrs = allAttrs[type];
|
|
150
155
|
return (
|
|
151
156
|
<Link
|
|
152
|
-
|
|
157
|
+
href={linkAttrs.href}
|
|
158
|
+
id={`${id}-${linkAttrs.text}`}
|
|
159
|
+
{...linkAttrs.attributes}
|
|
160
|
+
__css={{
|
|
153
161
|
...styles.link,
|
|
154
162
|
...currentStyles,
|
|
155
163
|
}}
|
|
156
|
-
attributes={linkAttrs.attributes}
|
|
157
|
-
href={linkAttrs.href}
|
|
158
|
-
id={`${id}-${linkAttrs.text}`}
|
|
159
164
|
>
|
|
160
165
|
{linkAttrs.text}
|
|
161
166
|
</Link>
|
|
@@ -252,7 +257,7 @@ export const Pagination = chakra((props: PaginationProps) => {
|
|
|
252
257
|
__css={styles}
|
|
253
258
|
{...rest}
|
|
254
259
|
>
|
|
255
|
-
<List type=
|
|
260
|
+
<List type="ul" inline noStyling id={`${id}-list`}>
|
|
256
261
|
{previousLiLink}
|
|
257
262
|
{getPaginationNumbers(selectedPage)}
|
|
258
263
|
{nextLiLink}
|
|
@@ -8,25 +8,10 @@ import {
|
|
|
8
8
|
} from "@storybook/addon-docs";
|
|
9
9
|
import { withDesign } from "storybook-addon-designs";
|
|
10
10
|
|
|
11
|
-
import { GridGaps } from "../Grid/GridTypes";
|
|
12
11
|
import ProgressIndicator from "./ProgressIndicator";
|
|
13
|
-
import {
|
|
14
|
-
ProgressIndicatorSizes,
|
|
15
|
-
ProgressIndicatorTypes,
|
|
16
|
-
} from "./ProgressIndicatorTypes";
|
|
17
12
|
import SimpleGrid from "../Grid/SimpleGrid";
|
|
18
13
|
import { getCategory } from "../../utils/componentCategories";
|
|
19
14
|
import DSProvider from "../../theme/provider";
|
|
20
|
-
import { getStorybookEnumValues } from "../../utils/utils";
|
|
21
|
-
|
|
22
|
-
export const sizesEnumValues = getStorybookEnumValues(
|
|
23
|
-
ProgressIndicatorSizes,
|
|
24
|
-
"ProgressIndicatorSizes"
|
|
25
|
-
);
|
|
26
|
-
export const typesEnumValues = getStorybookEnumValues(
|
|
27
|
-
ProgressIndicatorTypes,
|
|
28
|
-
"ProgressIndicatorTypes"
|
|
29
|
-
);
|
|
30
15
|
|
|
31
16
|
<Meta
|
|
32
17
|
title={getCategory("ProgressIndicator")}
|
|
@@ -45,9 +30,7 @@ export const typesEnumValues = getStorybookEnumValues(
|
|
|
45
30
|
},
|
|
46
31
|
id: { control: false },
|
|
47
32
|
indicatorType: {
|
|
48
|
-
|
|
49
|
-
table: { defaultValue: { summary: "ProgressIndicatorTypes.Linear" } },
|
|
50
|
-
options: typesEnumValues.options,
|
|
33
|
+
table: { defaultValue: { summary: "linear" } },
|
|
51
34
|
},
|
|
52
35
|
isIndeterminate: {
|
|
53
36
|
table: { defaultValue: { summary: false } },
|
|
@@ -56,9 +39,7 @@ export const typesEnumValues = getStorybookEnumValues(
|
|
|
56
39
|
table: { defaultValue: { summary: true } },
|
|
57
40
|
},
|
|
58
41
|
size: {
|
|
59
|
-
|
|
60
|
-
table: { defaultValue: { summary: "ProgressIndicatorSizes.Default" } },
|
|
61
|
-
options: sizesEnumValues.options,
|
|
42
|
+
table: { defaultValue: { summary: "default" } },
|
|
62
43
|
},
|
|
63
44
|
value: {
|
|
64
45
|
table: { defaultValue: { summary: 0 } },
|
|
@@ -71,7 +52,7 @@ export const typesEnumValues = getStorybookEnumValues(
|
|
|
71
52
|
| Component Version | DS Version |
|
|
72
53
|
| ----------------- | ---------- |
|
|
73
54
|
| Added | `0.25.4` |
|
|
74
|
-
| Latest | `0.
|
|
55
|
+
| Latest | `0.28.0` |
|
|
75
56
|
|
|
76
57
|
## Table of Contents
|
|
77
58
|
|
|
@@ -98,21 +79,15 @@ export const typesEnumValues = getStorybookEnumValues(
|
|
|
98
79
|
args={{
|
|
99
80
|
darkMode: false,
|
|
100
81
|
id: "progressIndicator-id",
|
|
101
|
-
indicatorType: "
|
|
82
|
+
indicatorType: "linear",
|
|
102
83
|
isIndeterminate: false,
|
|
103
84
|
labelText: "Progress",
|
|
104
85
|
showLabel: true,
|
|
105
|
-
size: "
|
|
86
|
+
size: "default",
|
|
106
87
|
value: 50,
|
|
107
88
|
}}
|
|
108
89
|
>
|
|
109
|
-
{(args) =>
|
|
110
|
-
<ProgressIndicator
|
|
111
|
-
{...args}
|
|
112
|
-
indicatorType={typesEnumValues.getValue(args.indicatorType)}
|
|
113
|
-
size={sizesEnumValues.getValue(args.size)}
|
|
114
|
-
/>
|
|
115
|
-
)}
|
|
90
|
+
{(args) => <ProgressIndicator {...args} />}
|
|
116
91
|
</Story>
|
|
117
92
|
</Canvas>
|
|
118
93
|
|
|
@@ -152,7 +127,7 @@ dialogs, etc.
|
|
|
152
127
|
>
|
|
153
128
|
<ProgressIndicator
|
|
154
129
|
id="linear"
|
|
155
|
-
indicatorType=
|
|
130
|
+
indicatorType="linear"
|
|
156
131
|
labelText="Linear Progress Type"
|
|
157
132
|
value={50}
|
|
158
133
|
/>
|
|
@@ -162,8 +137,7 @@ dialogs, etc.
|
|
|
162
137
|
## Circular Type
|
|
163
138
|
|
|
164
139
|
The circular progress type is preferred for large content areas and for
|
|
165
|
-
full-screen loading. Set the `indicatorType` prop to
|
|
166
|
-
`ProgressIndicatorTypes.Circular` for this type.
|
|
140
|
+
full-screen loading. Set the `indicatorType` prop to `"circular"` for this type.
|
|
167
141
|
|
|
168
142
|
<Canvas>
|
|
169
143
|
<Story
|
|
@@ -174,7 +148,7 @@ full-screen loading. Set the `indicatorType` prop to
|
|
|
174
148
|
>
|
|
175
149
|
<ProgressIndicator
|
|
176
150
|
id="circular"
|
|
177
|
-
indicatorType=
|
|
151
|
+
indicatorType="circular"
|
|
178
152
|
labelText="Linear Progress Type"
|
|
179
153
|
value={50}
|
|
180
154
|
/>
|
|
@@ -187,11 +161,11 @@ The starting height for the progress bar is 4px on mobile and 8px for desktop.
|
|
|
187
161
|
The `size` prop can be used to optionally set the height to 4px for desktop
|
|
188
162
|
through the `ProgressIndicatorSizes.Small` value.
|
|
189
163
|
|
|
190
|
-
`size=
|
|
164
|
+
`size="small"`
|
|
191
165
|
|
|
192
166
|
<Canvas>
|
|
193
167
|
<DSProvider>
|
|
194
|
-
<SimpleGrid columns={1} gap=
|
|
168
|
+
<SimpleGrid columns={1} gap="grid.m">
|
|
195
169
|
<ProgressIndicator
|
|
196
170
|
id="default-size"
|
|
197
171
|
labelText="Default 8px size"
|
|
@@ -200,7 +174,7 @@ through the `ProgressIndicatorSizes.Small` value.
|
|
|
200
174
|
<ProgressIndicator
|
|
201
175
|
id="small-size"
|
|
202
176
|
labelText="Small 4px size"
|
|
203
|
-
size=
|
|
177
|
+
size="small"
|
|
204
178
|
value={50}
|
|
205
179
|
/>
|
|
206
180
|
</SimpleGrid>
|
|
@@ -212,22 +186,22 @@ The starting size for the circular progress is 48px and can be made smaller to
|
|
|
212
186
|
changes in content. Note that in the small size, the label text and the
|
|
213
187
|
percentage will not displayed.
|
|
214
188
|
|
|
215
|
-
`size=
|
|
189
|
+
`size="small"`
|
|
216
190
|
|
|
217
191
|
<Canvas>
|
|
218
192
|
<DSProvider>
|
|
219
|
-
<SimpleGrid columns={1} gap=
|
|
193
|
+
<SimpleGrid columns={1} gap="grid.m">
|
|
220
194
|
<ProgressIndicator
|
|
221
195
|
id="default-size"
|
|
222
|
-
indicatorType=
|
|
196
|
+
indicatorType="circular"
|
|
223
197
|
labelText="Default 48px size"
|
|
224
198
|
value={50}
|
|
225
199
|
/>
|
|
226
200
|
<ProgressIndicator
|
|
227
201
|
id="small-size"
|
|
228
|
-
indicatorType=
|
|
202
|
+
indicatorType="circular"
|
|
229
203
|
labelText="Small 24px size"
|
|
230
|
-
size=
|
|
204
|
+
size="small"
|
|
231
205
|
value={50}
|
|
232
206
|
/>
|
|
233
207
|
</SimpleGrid>
|
|
@@ -246,7 +220,7 @@ the progress element to provide a description of the progress for screen readers
|
|
|
246
220
|
|
|
247
221
|
<Canvas>
|
|
248
222
|
<DSProvider>
|
|
249
|
-
<SimpleGrid columns={1} gap=
|
|
223
|
+
<SimpleGrid columns={1} gap="grid.m">
|
|
250
224
|
<ProgressIndicator
|
|
251
225
|
id="label"
|
|
252
226
|
labelText="This label will be added through aria-label"
|
|
@@ -255,7 +229,7 @@ the progress element to provide a description of the progress for screen readers
|
|
|
255
229
|
/>
|
|
256
230
|
<ProgressIndicator
|
|
257
231
|
id="label-hidden"
|
|
258
|
-
indicatorType=
|
|
232
|
+
indicatorType="circular"
|
|
259
233
|
labelText="This label will be added through aria-label"
|
|
260
234
|
showLabel={false}
|
|
261
235
|
value={50}
|
|
@@ -272,7 +246,7 @@ exact value or progress of the task is unknown.
|
|
|
272
246
|
|
|
273
247
|
<Canvas>
|
|
274
248
|
<DSProvider>
|
|
275
|
-
<SimpleGrid columns={1} gap=
|
|
249
|
+
<SimpleGrid columns={1} gap="grid.m">
|
|
276
250
|
<ProgressIndicator
|
|
277
251
|
id="indeterminate"
|
|
278
252
|
isIndeterminate
|
|
@@ -281,7 +255,7 @@ exact value or progress of the task is unknown.
|
|
|
281
255
|
/>
|
|
282
256
|
<ProgressIndicator
|
|
283
257
|
id="indeterminate-circular"
|
|
284
|
-
indicatorType=
|
|
258
|
+
indicatorType="circular"
|
|
285
259
|
isIndeterminate
|
|
286
260
|
labelText="Indeterminate state"
|
|
287
261
|
value={50}
|
|
@@ -300,7 +274,7 @@ Note: the background is manually set to better showcase the `darkMode` prop.
|
|
|
300
274
|
<Canvas>
|
|
301
275
|
<DSProvider>
|
|
302
276
|
<Box bg="black" w="100%" h="200px" p="20px">
|
|
303
|
-
<SimpleGrid columns={1} gap=
|
|
277
|
+
<SimpleGrid columns={1} gap="grid.m">
|
|
304
278
|
<ProgressIndicator
|
|
305
279
|
darkMode
|
|
306
280
|
id="darkmode"
|
|
@@ -310,7 +284,7 @@ Note: the background is manually set to better showcase the `darkMode` prop.
|
|
|
310
284
|
<ProgressIndicator
|
|
311
285
|
darkMode
|
|
312
286
|
id="darkmode-circular"
|
|
313
|
-
indicatorType=
|
|
287
|
+
indicatorType="circular"
|
|
314
288
|
labelText="Dark Mode"
|
|
315
289
|
value={50}
|
|
316
290
|
/>
|
|
@@ -337,7 +311,7 @@ function ProgressIndicatorExample() {
|
|
|
337
311
|
return () => clearInterval(interval);
|
|
338
312
|
}, []);
|
|
339
313
|
return (
|
|
340
|
-
<SimpleGrid columns={1} gap=
|
|
314
|
+
<SimpleGrid columns={1} gap="grid.m">
|
|
341
315
|
<ProgressIndicator
|
|
342
316
|
id="example"
|
|
343
317
|
labelText="Progress example"
|
|
@@ -345,7 +319,7 @@ function ProgressIndicatorExample() {
|
|
|
345
319
|
/>
|
|
346
320
|
<ProgressIndicator
|
|
347
321
|
id="example-circular"
|
|
348
|
-
indicatorType=
|
|
322
|
+
indicatorType="circular"
|
|
349
323
|
labelText="Progress example"
|
|
350
324
|
value={value}
|
|
351
325
|
/>
|
|
@@ -363,7 +337,7 @@ export function ProgressIndicatorExample() {
|
|
|
363
337
|
return () => clearInterval(interval);
|
|
364
338
|
}, []);
|
|
365
339
|
return (
|
|
366
|
-
<SimpleGrid columns={1} gap=
|
|
340
|
+
<SimpleGrid columns={1} gap="grid.m">
|
|
367
341
|
<ProgressIndicator
|
|
368
342
|
id="example"
|
|
369
343
|
labelText="Progress example"
|
|
@@ -371,7 +345,7 @@ export function ProgressIndicatorExample() {
|
|
|
371
345
|
/>
|
|
372
346
|
<ProgressIndicator
|
|
373
347
|
id="example-circular"
|
|
374
|
-
indicatorType=
|
|
348
|
+
indicatorType="circular"
|
|
375
349
|
labelText="Progress example"
|
|
376
350
|
value={value}
|
|
377
351
|
/>
|
|
@@ -4,7 +4,6 @@ import { axe } from "jest-axe";
|
|
|
4
4
|
import renderer from "react-test-renderer";
|
|
5
5
|
|
|
6
6
|
import ProgressIndicator from "./ProgressIndicator";
|
|
7
|
-
import { ProgressIndicatorTypes } from "./ProgressIndicatorTypes";
|
|
8
7
|
|
|
9
8
|
describe("ProgressIndicator Accessibility", () => {
|
|
10
9
|
it("passes axe accessibility for linear and circular types", async () => {
|
|
@@ -20,7 +19,7 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
20
19
|
id="progressIndicatorCircular"
|
|
21
20
|
labelText="Circular"
|
|
22
21
|
value={50}
|
|
23
|
-
indicatorType=
|
|
22
|
+
indicatorType="circular"
|
|
24
23
|
/>
|
|
25
24
|
);
|
|
26
25
|
expect(await axe(linearUtils.container)).toHaveNoViolations();
|
|
@@ -41,7 +40,7 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
41
40
|
id="progressIndicatorCircular"
|
|
42
41
|
labelText="Circular"
|
|
43
42
|
value={50}
|
|
44
|
-
indicatorType=
|
|
43
|
+
indicatorType="circular"
|
|
45
44
|
showLabel={false}
|
|
46
45
|
/>
|
|
47
46
|
);
|
|
@@ -63,7 +62,7 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
63
62
|
id="progressIndicatorCircular"
|
|
64
63
|
labelText="Circular"
|
|
65
64
|
value={50}
|
|
66
|
-
indicatorType=
|
|
65
|
+
indicatorType="circular"
|
|
67
66
|
isIndeterminate
|
|
68
67
|
/>
|
|
69
68
|
);
|
|
@@ -85,7 +84,7 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
85
84
|
id="progressIndicatorCircular"
|
|
86
85
|
labelText="Circular"
|
|
87
86
|
value={50}
|
|
88
|
-
indicatorType=
|
|
87
|
+
indicatorType="circular"
|
|
89
88
|
darkMode
|
|
90
89
|
/>
|
|
91
90
|
);
|
|
@@ -108,7 +107,7 @@ describe("ProgressIndicator", () => {
|
|
|
108
107
|
<ProgressIndicator
|
|
109
108
|
id="progressIndicator"
|
|
110
109
|
labelText="Circular"
|
|
111
|
-
indicatorType=
|
|
110
|
+
indicatorType="circular"
|
|
112
111
|
value={50}
|
|
113
112
|
/>
|
|
114
113
|
);
|
|
@@ -196,7 +195,7 @@ describe("ProgressIndicator", () => {
|
|
|
196
195
|
id="circularBasic"
|
|
197
196
|
labelText="Circular"
|
|
198
197
|
value={50}
|
|
199
|
-
indicatorType=
|
|
198
|
+
indicatorType="circular"
|
|
200
199
|
/>
|
|
201
200
|
)
|
|
202
201
|
.toJSON();
|
|
@@ -216,7 +215,7 @@ describe("ProgressIndicator", () => {
|
|
|
216
215
|
id="circularNoLabel"
|
|
217
216
|
labelText="Circular"
|
|
218
217
|
value={50}
|
|
219
|
-
indicatorType=
|
|
218
|
+
indicatorType="circular"
|
|
220
219
|
showLabel={false}
|
|
221
220
|
/>
|
|
222
221
|
)
|
|
@@ -237,7 +236,7 @@ describe("ProgressIndicator", () => {
|
|
|
237
236
|
id="circularIndeterminate"
|
|
238
237
|
labelText="Circular"
|
|
239
238
|
value={50}
|
|
240
|
-
indicatorType=
|
|
239
|
+
indicatorType="circular"
|
|
241
240
|
isIndeterminate
|
|
242
241
|
/>
|
|
243
242
|
)
|
|
@@ -258,7 +257,7 @@ describe("ProgressIndicator", () => {
|
|
|
258
257
|
id="circularDarkMode"
|
|
259
258
|
labelText="Circular"
|
|
260
259
|
value={50}
|
|
261
|
-
indicatorType=
|
|
260
|
+
indicatorType="circular"
|
|
262
261
|
darkMode
|
|
263
262
|
/>
|
|
264
263
|
)
|
|
@@ -8,12 +8,10 @@ import {
|
|
|
8
8
|
} from "@chakra-ui/react";
|
|
9
9
|
import React from "react";
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
ProgressIndicatorSizes,
|
|
13
|
-
ProgressIndicatorTypes,
|
|
14
|
-
} from "./ProgressIndicatorTypes";
|
|
15
11
|
import Label from "../Label/Label";
|
|
16
12
|
|
|
13
|
+
export type ProgressIndicatorSizes = "default" | "small";
|
|
14
|
+
export type ProgressIndicatorTypes = "circular" | "linear";
|
|
17
15
|
export interface ProgressIndicatorProps {
|
|
18
16
|
/** Flag to render the component in a dark background. */
|
|
19
17
|
darkMode?: boolean;
|
|
@@ -44,11 +42,11 @@ export const ProgressIndicator = chakra((props: ProgressIndicatorProps) => {
|
|
|
44
42
|
const {
|
|
45
43
|
darkMode = false,
|
|
46
44
|
id,
|
|
47
|
-
indicatorType =
|
|
45
|
+
indicatorType = "linear",
|
|
48
46
|
isIndeterminate = false,
|
|
49
47
|
labelText,
|
|
50
48
|
showLabel = true,
|
|
51
|
-
size =
|
|
49
|
+
size = "default",
|
|
52
50
|
value = 0,
|
|
53
51
|
...rest
|
|
54
52
|
} = props;
|
|
@@ -74,33 +72,31 @@ export const ProgressIndicator = chakra((props: ProgressIndicatorProps) => {
|
|
|
74
72
|
id,
|
|
75
73
|
// If the label is visually shown, associate it with the progress indicator.
|
|
76
74
|
// Otherwise, the `aria-label` will be added.
|
|
77
|
-
"aria-label": showLabel ?
|
|
78
|
-
"aria-labelledby": showLabel ? `${id}-label` :
|
|
75
|
+
"aria-label": showLabel ? undefined : labelText,
|
|
76
|
+
"aria-labelledby": showLabel ? `${id}-label` : undefined,
|
|
79
77
|
// If `isIndeterminate` is true, then it overrides the `value` prop.
|
|
80
|
-
isIndeterminate: isIndeterminate ||
|
|
81
|
-
value: isIndeterminate ?
|
|
78
|
+
isIndeterminate: isIndeterminate || undefined,
|
|
79
|
+
value: isIndeterminate ? undefined : finalValue,
|
|
82
80
|
};
|
|
83
|
-
const progressComponent = (indicatorType) => {
|
|
81
|
+
const progressComponent = (indicatorType: ProgressIndicatorTypes) => {
|
|
84
82
|
// Only display the percentage text for the default size, not in the
|
|
85
83
|
// indeterminate state, and when `showLabel` is true.
|
|
86
|
-
if (indicatorType ===
|
|
84
|
+
if (indicatorType === "circular") {
|
|
87
85
|
// For the small size, since the label won't be visible, we need to add
|
|
88
86
|
// it to the parent component's `aria-label` attribute.
|
|
89
|
-
if (size ===
|
|
87
|
+
if (size === "small") {
|
|
90
88
|
progressProps["aria-label"] = labelText;
|
|
91
89
|
}
|
|
92
90
|
return (
|
|
93
91
|
<Box __css={styles.circularContainer}>
|
|
94
92
|
<ChakraCircularProgress {...progressProps} sx={styles.circular}>
|
|
95
|
-
{showLabel &&
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</ChakraCircularProgressLabel>
|
|
101
|
-
)}
|
|
93
|
+
{showLabel && !isIndeterminate && size !== "small" && (
|
|
94
|
+
<ChakraCircularProgressLabel>
|
|
95
|
+
{finalValue}%
|
|
96
|
+
</ChakraCircularProgressLabel>
|
|
97
|
+
)}
|
|
102
98
|
</ChakraCircularProgress>
|
|
103
|
-
{showLabel && size !==
|
|
99
|
+
{showLabel && size !== "small" && (
|
|
104
100
|
<Label id={`${id}-label`} htmlFor={id}>
|
|
105
101
|
{labelText}
|
|
106
102
|
</Label>
|
|
@@ -19,7 +19,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 1`] = `
|
|
|
19
19
|
id="linearBasic"
|
|
20
20
|
>
|
|
21
21
|
<div
|
|
22
|
-
aria-label={null}
|
|
23
22
|
aria-labelledby="linearBasic-label"
|
|
24
23
|
aria-valuemax={100}
|
|
25
24
|
aria-valuemin={0}
|
|
@@ -51,7 +50,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
|
|
|
51
50
|
className="css-0"
|
|
52
51
|
>
|
|
53
52
|
<div
|
|
54
|
-
aria-label={null}
|
|
55
53
|
aria-labelledby="circularBasic-label"
|
|
56
54
|
aria-valuemax={100}
|
|
57
55
|
aria-valuemin={0}
|
|
@@ -112,7 +110,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 3`] = `
|
|
|
112
110
|
>
|
|
113
111
|
<div
|
|
114
112
|
aria-label="Linear"
|
|
115
|
-
aria-labelledby={null}
|
|
116
113
|
aria-valuemax={100}
|
|
117
114
|
aria-valuemin={0}
|
|
118
115
|
aria-valuenow={50}
|
|
@@ -138,7 +135,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 4`] = `
|
|
|
138
135
|
>
|
|
139
136
|
<div
|
|
140
137
|
aria-label="Circular"
|
|
141
|
-
aria-labelledby={null}
|
|
142
138
|
aria-valuemax={100}
|
|
143
139
|
aria-valuemin={0}
|
|
144
140
|
aria-valuenow={50}
|
|
@@ -191,7 +187,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 5`] = `
|
|
|
191
187
|
id="linearIndeterminate"
|
|
192
188
|
>
|
|
193
189
|
<div
|
|
194
|
-
aria-label={null}
|
|
195
190
|
aria-labelledby="linearIndeterminate-label"
|
|
196
191
|
aria-valuemax={100}
|
|
197
192
|
aria-valuemin={0}
|
|
@@ -217,7 +212,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
|
|
|
217
212
|
className="css-0"
|
|
218
213
|
>
|
|
219
214
|
<div
|
|
220
|
-
aria-label={null}
|
|
221
215
|
aria-labelledby="circularIndeterminate-label"
|
|
222
216
|
aria-valuemax={100}
|
|
223
217
|
aria-valuemin={0}
|
|
@@ -276,7 +270,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 7`] = `
|
|
|
276
270
|
id="linearDarkMode"
|
|
277
271
|
>
|
|
278
272
|
<div
|
|
279
|
-
aria-label={null}
|
|
280
273
|
aria-labelledby="linearDarkMode-label"
|
|
281
274
|
aria-valuemax={100}
|
|
282
275
|
aria-valuemin={0}
|
|
@@ -308,7 +301,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
|
|
|
308
301
|
className="css-0"
|
|
309
302
|
>
|
|
310
303
|
<div
|
|
311
|
-
aria-label={null}
|
|
312
304
|
aria-labelledby="circularDarkMode-label"
|
|
313
305
|
aria-valuemax={100}
|
|
314
306
|
aria-valuemin={0}
|
|
@@ -375,7 +367,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 9`] = `
|
|
|
375
367
|
id="chakra"
|
|
376
368
|
>
|
|
377
369
|
<div
|
|
378
|
-
aria-label={null}
|
|
379
370
|
aria-labelledby="chakra-label"
|
|
380
371
|
aria-valuemax={100}
|
|
381
372
|
aria-valuemin={0}
|
|
@@ -419,7 +410,6 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 10`] = `
|
|
|
419
410
|
id="props"
|
|
420
411
|
>
|
|
421
412
|
<div
|
|
422
|
-
aria-label={null}
|
|
423
413
|
aria-labelledby="props-label"
|
|
424
414
|
aria-valuemax={100}
|
|
425
415
|
aria-valuemin={0}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
useMultiStyleConfig,
|
|
5
5
|
} from "@chakra-ui/react";
|
|
6
6
|
import * as React from "react";
|
|
7
|
+
import { AriaAttributes } from "../../utils/interfaces";
|
|
7
8
|
|
|
8
9
|
import HelperErrorText, {
|
|
9
10
|
HelperErrorTextType,
|
|
@@ -69,7 +70,7 @@ export const Radio = chakra(
|
|
|
69
70
|
} = props;
|
|
70
71
|
const styles = useMultiStyleConfig("Radio", {});
|
|
71
72
|
const footnote = isInvalid ? invalidText : helperText;
|
|
72
|
-
const
|
|
73
|
+
const ariaAttributes: AriaAttributes = {};
|
|
73
74
|
|
|
74
75
|
if (!id) {
|
|
75
76
|
console.warn(
|
|
@@ -83,10 +84,12 @@ export const Radio = chakra(
|
|
|
83
84
|
"NYPL Reservoir Radio: `labelText` must be a string when `showLabel` is false."
|
|
84
85
|
);
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
-
labelText && footnote
|
|
87
|
+
ariaAttributes["aria-label"] =
|
|
88
|
+
labelText && footnote
|
|
89
|
+
? `${labelText} - ${footnote}`
|
|
90
|
+
: (labelText as string);
|
|
88
91
|
} else if (footnote) {
|
|
89
|
-
|
|
92
|
+
ariaAttributes["aria-describedby"] = `${id}-helperText`;
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
return (
|
|
@@ -104,17 +107,17 @@ export const Radio = chakra(
|
|
|
104
107
|
ref={ref}
|
|
105
108
|
alignItems="flex-start"
|
|
106
109
|
__css={styles}
|
|
107
|
-
{...
|
|
110
|
+
{...ariaAttributes}
|
|
108
111
|
{...rest}
|
|
109
112
|
>
|
|
110
113
|
{showLabel && labelText}
|
|
111
114
|
</ChakraRadio>
|
|
112
115
|
{footnote && showHelperInvalidText && (
|
|
113
116
|
<HelperErrorText
|
|
114
|
-
additionalStyles={styles.helperErrorText}
|
|
115
117
|
id={`${id}-helperText`}
|
|
116
118
|
isInvalid={isInvalid}
|
|
117
119
|
text={footnote}
|
|
120
|
+
__css={styles.helperErrorText}
|
|
118
121
|
/>
|
|
119
122
|
)}
|
|
120
123
|
</>
|