@nypl/design-system-react-components 0.26.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 +56 -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/Modal/Modal.d.ts +28 -8
- 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 +977 -1213
- 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 +976 -1276
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/types.d.ts +1 -0
- package/dist/index.d.ts +27 -48
- package/dist/styles.css +1 -1
- 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 -10
- 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 +15 -16
- 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/Card/__snapshots__/Card.test.tsx.snap +1 -1
- 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/Checkbox/__snapshots__/Checkbox.test.tsx.snap +9 -9
- 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 +24 -35
- 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 -94
- package/src/components/Link/Link.test.tsx +25 -75
- 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 +245 -139
- package/src/components/Modal/Modal.test.tsx +147 -10
- package/src/components/Modal/Modal.tsx +140 -20
- package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
- 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 +3 -4
- 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 +1 -13
- package/src/components/Select/Select.stories.mdx +10 -25
- package/src/components/Select/Select.test.tsx +6 -7
- package/src/components/Select/Select.tsx +28 -35
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +24 -24
- 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 +52 -46
- package/src/styles.scss +0 -1
- 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 -6
- 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/Modal/_Modal.scss +0 -18
- 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
|
@@ -2,7 +2,6 @@ import { Meta, Story, Canvas } from "@storybook/addon-docs";
|
|
|
2
2
|
import { Box, Stack, HStack, VStack, Circle } from "@chakra-ui/react";
|
|
3
3
|
|
|
4
4
|
import Icon from "../Icons/Icon";
|
|
5
|
-
import { IconNames, IconSizes } from "../Icons/IconTypes";
|
|
6
5
|
import { getCategory } from "../../utils/componentCategories";
|
|
7
6
|
import DSProvider from "../../theme/provider";
|
|
8
7
|
|
|
@@ -53,13 +52,13 @@ elements both horizontally and vertically through the `direction` prop and the
|
|
|
53
52
|
{(args) => (
|
|
54
53
|
<Stack {...args}>
|
|
55
54
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
56
|
-
<Icon name=
|
|
55
|
+
<Icon name="errorFilled" size="large" />
|
|
57
56
|
</Circle>
|
|
58
57
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
59
|
-
<Icon name=
|
|
58
|
+
<Icon name="errorOutline" size="large" />
|
|
60
59
|
</Circle>
|
|
61
60
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
62
|
-
<Icon name=
|
|
61
|
+
<Icon name="check" size="large" />
|
|
63
62
|
</Circle>
|
|
64
63
|
</Stack>
|
|
65
64
|
)}
|
|
@@ -75,13 +74,13 @@ a `direction` value of `"row"`.
|
|
|
75
74
|
<DSProvider>
|
|
76
75
|
<HStack spacing="s">
|
|
77
76
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
78
|
-
<Icon name=
|
|
77
|
+
<Icon name="errorFilled" size="large" />
|
|
79
78
|
</Circle>
|
|
80
79
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
81
|
-
<Icon name=
|
|
80
|
+
<Icon name="errorOutline" size="large" />
|
|
82
81
|
</Circle>
|
|
83
82
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
84
|
-
<Icon name=
|
|
83
|
+
<Icon name="check" size="large" />
|
|
85
84
|
</Circle>
|
|
86
85
|
</HStack>
|
|
87
86
|
</DSProvider>
|
|
@@ -97,13 +96,13 @@ all the elements in the stack.
|
|
|
97
96
|
<DSProvider>
|
|
98
97
|
<VStack align="left" spacing="s">
|
|
99
98
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
100
|
-
<Icon name=
|
|
99
|
+
<Icon name="errorFilled" size="large" />
|
|
101
100
|
</Circle>
|
|
102
101
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
103
|
-
<Icon name=
|
|
102
|
+
<Icon name="errorOutline" size="large" />
|
|
104
103
|
</Circle>
|
|
105
104
|
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
106
|
-
<Icon name=
|
|
105
|
+
<Icon name="check" size="large" />
|
|
107
106
|
</Circle>
|
|
108
107
|
</VStack>
|
|
109
108
|
</DSProvider>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flex, Spacer } from "@chakra-ui/react";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import { render, screen } from "@testing-library/react";
|
|
4
3
|
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import * as React from "react";
|
|
5
5
|
import { axe } from "jest-axe";
|
|
6
6
|
import renderer from "react-test-renderer";
|
|
7
7
|
|
|
@@ -39,7 +39,7 @@ describe("Checkbox Accessibility", () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
describe("Checkbox", () => {
|
|
42
|
-
let changeHandler
|
|
42
|
+
let changeHandler: jest.MockedFunction<() => void>;
|
|
43
43
|
|
|
44
44
|
beforeEach(() => {
|
|
45
45
|
changeHandler = jest.fn();
|
|
@@ -5,11 +5,23 @@ import {
|
|
|
5
5
|
useMultiStyleConfig,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
7
|
import * as React from "react";
|
|
8
|
+
import { AriaAttributes } from "../../utils/interfaces";
|
|
8
9
|
|
|
9
10
|
import HelperErrorText, {
|
|
10
11
|
HelperErrorTextType,
|
|
11
12
|
} from "../HelperErrorText/HelperErrorText";
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
interface CheckboxIconProps {
|
|
15
|
+
/** When using the Checkbox as a "controlled" form element, you can specify
|
|
16
|
+
* the Checkbox's checked state using this prop.
|
|
17
|
+
* Learn more about controlled and uncontrolled form fields:
|
|
18
|
+
* https://goshakkk.name/controlled-vs-uncontrolled-inputs-react/ */
|
|
19
|
+
isChecked?: boolean;
|
|
20
|
+
/** Adds the indeterminate state to the `Checkbox`. */
|
|
21
|
+
isIndeterminate?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CheckboxProps extends CheckboxIconProps {
|
|
13
25
|
/** className you can add in addition to 'input' */
|
|
14
26
|
className?: string;
|
|
15
27
|
/** Optional string to populate the HelperErrorText for standard state */
|
|
@@ -19,16 +31,9 @@ export interface CheckboxProps {
|
|
|
19
31
|
/** Optional string to populate the HelperErrorText for the error state
|
|
20
32
|
* when `isInvalid` is true. */
|
|
21
33
|
invalidText?: HelperErrorTextType;
|
|
22
|
-
/** When using the Checkbox as a "controlled" form element, you can specify
|
|
23
|
-
* the Checkbox's checked state using this prop.
|
|
24
|
-
* Learn more about controlled and uncontrolled form fields:
|
|
25
|
-
* https://goshakkk.name/controlled-vs-uncontrolled-inputs-react/ */
|
|
26
|
-
isChecked?: boolean;
|
|
27
34
|
/** Adds the 'disabled' and `aria-disabled` attributes to the input when true.
|
|
28
35
|
* This also makes the text italic and color scheme gray. */
|
|
29
36
|
isDisabled?: boolean;
|
|
30
|
-
/** Adds the indeterminate state to the `Checkbox`. */
|
|
31
|
-
isIndeterminate?: boolean;
|
|
32
37
|
/** Adds the 'aria-invalid' attribute to the input when true. This also makes
|
|
33
38
|
* the color theme "NYPL error" red for the button and text. */
|
|
34
39
|
isInvalid?: boolean;
|
|
@@ -55,7 +60,7 @@ export const onChangeDefault = () => {
|
|
|
55
60
|
return;
|
|
56
61
|
};
|
|
57
62
|
|
|
58
|
-
function CheckboxIcon(props) {
|
|
63
|
+
function CheckboxIcon(props: CheckboxIconProps) {
|
|
59
64
|
// We don't need the `isIndeterminate` or `isChecked` props but it
|
|
60
65
|
// causes rendering issues on the SVG element, so we remove them
|
|
61
66
|
// before passing all the props to the `Icon` component.
|
|
@@ -91,8 +96,8 @@ export const Checkbox = chakra(
|
|
|
91
96
|
...rest
|
|
92
97
|
} = props;
|
|
93
98
|
const styles = useMultiStyleConfig("Checkbox", {});
|
|
94
|
-
const footnote
|
|
95
|
-
const ariaAttributes = {};
|
|
99
|
+
const footnote = isInvalid ? invalidText : helperText;
|
|
100
|
+
const ariaAttributes: AriaAttributes = {};
|
|
96
101
|
const onChange = props.onChange || onChangeDefault;
|
|
97
102
|
// Use Chakra's default indeterminate icon.
|
|
98
103
|
const icon = !isIndeterminate ? <CheckboxIcon /> : undefined;
|
|
@@ -110,7 +115,9 @@ export const Checkbox = chakra(
|
|
|
110
115
|
);
|
|
111
116
|
}
|
|
112
117
|
ariaAttributes["aria-label"] =
|
|
113
|
-
labelText && footnote
|
|
118
|
+
labelText && footnote
|
|
119
|
+
? `${labelText} - ${footnote}`
|
|
120
|
+
: (labelText as string);
|
|
114
121
|
} else {
|
|
115
122
|
if (footnote) ariaAttributes["aria-describedby"] = `${id}-helperText`;
|
|
116
123
|
}
|
|
@@ -145,10 +152,10 @@ export const Checkbox = chakra(
|
|
|
145
152
|
</ChakraCheckbox>
|
|
146
153
|
{footnote && showHelperInvalidText && (
|
|
147
154
|
<HelperErrorText
|
|
148
|
-
additionalStyles={styles.helperErrorText}
|
|
149
155
|
id={`${id}-helperText`}
|
|
150
156
|
isInvalid={isInvalid}
|
|
151
157
|
text={footnote}
|
|
158
|
+
__css={styles.helperErrorText}
|
|
152
159
|
/>
|
|
153
160
|
)}
|
|
154
161
|
</>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Checkbox Renders the UI snapshot correctly 1`] = `
|
|
4
4
|
<label
|
|
5
|
-
className="chakra-checkbox css-
|
|
5
|
+
className="chakra-checkbox css-scawxr"
|
|
6
6
|
onClick={[Function]}
|
|
7
7
|
>
|
|
8
8
|
<input
|
|
@@ -65,7 +65,7 @@ exports[`Checkbox Renders the UI snapshot correctly 1`] = `
|
|
|
65
65
|
|
|
66
66
|
exports[`Checkbox Renders the UI snapshot correctly 2`] = `
|
|
67
67
|
<label
|
|
68
|
-
className="chakra-checkbox css-
|
|
68
|
+
className="chakra-checkbox css-scawxr"
|
|
69
69
|
data-checked=""
|
|
70
70
|
onClick={[Function]}
|
|
71
71
|
>
|
|
@@ -131,7 +131,7 @@ exports[`Checkbox Renders the UI snapshot correctly 2`] = `
|
|
|
131
131
|
|
|
132
132
|
exports[`Checkbox Renders the UI snapshot correctly 3`] = `
|
|
133
133
|
<label
|
|
134
|
-
className="chakra-checkbox css-
|
|
134
|
+
className="chakra-checkbox css-scawxr"
|
|
135
135
|
data-checked=""
|
|
136
136
|
onClick={[Function]}
|
|
137
137
|
>
|
|
@@ -219,7 +219,7 @@ exports[`Checkbox Renders the UI snapshot correctly 3`] = `
|
|
|
219
219
|
|
|
220
220
|
exports[`Checkbox Renders the UI snapshot correctly 4`] = `
|
|
221
221
|
<label
|
|
222
|
-
className="chakra-checkbox css-
|
|
222
|
+
className="chakra-checkbox css-scawxr"
|
|
223
223
|
onClick={[Function]}
|
|
224
224
|
>
|
|
225
225
|
<input
|
|
@@ -282,7 +282,7 @@ exports[`Checkbox Renders the UI snapshot correctly 4`] = `
|
|
|
282
282
|
|
|
283
283
|
exports[`Checkbox Renders the UI snapshot correctly 5`] = `
|
|
284
284
|
<label
|
|
285
|
-
className="chakra-checkbox css-
|
|
285
|
+
className="chakra-checkbox css-scawxr"
|
|
286
286
|
data-invalid=""
|
|
287
287
|
onClick={[Function]}
|
|
288
288
|
>
|
|
@@ -348,7 +348,7 @@ exports[`Checkbox Renders the UI snapshot correctly 5`] = `
|
|
|
348
348
|
|
|
349
349
|
exports[`Checkbox Renders the UI snapshot correctly 6`] = `
|
|
350
350
|
<label
|
|
351
|
-
className="chakra-checkbox css-
|
|
351
|
+
className="chakra-checkbox css-scawxr"
|
|
352
352
|
data-disabled=""
|
|
353
353
|
onClick={[Function]}
|
|
354
354
|
>
|
|
@@ -414,7 +414,7 @@ exports[`Checkbox Renders the UI snapshot correctly 6`] = `
|
|
|
414
414
|
|
|
415
415
|
exports[`Checkbox Renders the UI snapshot correctly 7`] = `
|
|
416
416
|
<label
|
|
417
|
-
className="chakra-checkbox css-
|
|
417
|
+
className="chakra-checkbox css-scawxr"
|
|
418
418
|
onClick={[Function]}
|
|
419
419
|
>
|
|
420
420
|
<input
|
|
@@ -490,7 +490,7 @@ exports[`Checkbox Renders the UI snapshot correctly 7`] = `
|
|
|
490
490
|
|
|
491
491
|
exports[`Checkbox Renders the UI snapshot correctly 8`] = `
|
|
492
492
|
<label
|
|
493
|
-
className="chakra-checkbox css-
|
|
493
|
+
className="chakra-checkbox css-wkfjn4"
|
|
494
494
|
onClick={[Function]}
|
|
495
495
|
>
|
|
496
496
|
<input
|
|
@@ -553,7 +553,7 @@ exports[`Checkbox Renders the UI snapshot correctly 8`] = `
|
|
|
553
553
|
|
|
554
554
|
exports[`Checkbox Renders the UI snapshot correctly 9`] = `
|
|
555
555
|
<label
|
|
556
|
-
className="chakra-checkbox css-
|
|
556
|
+
className="chakra-checkbox css-scawxr"
|
|
557
557
|
data-testid="testid"
|
|
558
558
|
onClick={[Function]}
|
|
559
559
|
>
|
|
@@ -10,12 +10,8 @@ import { withDesign } from "storybook-addon-designs";
|
|
|
10
10
|
|
|
11
11
|
import Checkbox from "../Checkbox/Checkbox";
|
|
12
12
|
import CheckboxGroup from "./CheckboxGroup";
|
|
13
|
-
import { LayoutTypes } from "../../helpers/enums";
|
|
14
13
|
import { getCategory } from "../../utils/componentCategories";
|
|
15
14
|
import DSProvider from "../../theme/provider";
|
|
16
|
-
import { getStorybookEnumValues } from "../../utils/utils";
|
|
17
|
-
|
|
18
|
-
export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
|
|
19
15
|
|
|
20
16
|
<Meta
|
|
21
17
|
title={getCategory("CheckboxGroup")}
|
|
@@ -46,9 +42,7 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
|
|
|
46
42
|
},
|
|
47
43
|
key: { table: { disable: true } },
|
|
48
44
|
layout: {
|
|
49
|
-
|
|
50
|
-
table: { defaultValue: { summary: "LayoutTypes.Column" } },
|
|
51
|
-
options: enumValues.options,
|
|
45
|
+
table: { defaultValue: { summary: "column" } },
|
|
52
46
|
},
|
|
53
47
|
name: { control: false },
|
|
54
48
|
onChange: { control: false },
|
|
@@ -70,7 +64,7 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
|
|
|
70
64
|
| Component Version | DS Version |
|
|
71
65
|
| ----------------- | ---------- |
|
|
72
66
|
| Added | `0.25.1` |
|
|
73
|
-
| Latest | `0.
|
|
67
|
+
| Latest | `0.28.0` |
|
|
74
68
|
|
|
75
69
|
## Table of Contents
|
|
76
70
|
|
|
@@ -104,7 +98,7 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
|
|
|
104
98
|
isInvalid: false,
|
|
105
99
|
isRequired: false,
|
|
106
100
|
labelText: "Standard Checkbox Group",
|
|
107
|
-
layout: "
|
|
101
|
+
layout: "column",
|
|
108
102
|
name: "checkbox-story",
|
|
109
103
|
onChange: undefined,
|
|
110
104
|
showHelperInvalidText: true,
|
|
@@ -113,7 +107,7 @@ export const enumValues = getStorybookEnumValues(LayoutTypes, "LayoutTypes");
|
|
|
113
107
|
}}
|
|
114
108
|
>
|
|
115
109
|
{(args) => (
|
|
116
|
-
<CheckboxGroup {...args}
|
|
110
|
+
<CheckboxGroup {...args}>
|
|
117
111
|
<Checkbox value="2" labelText="Checkbox 2" />
|
|
118
112
|
<Checkbox value="3" labelText="Checkbox 3" />
|
|
119
113
|
<Checkbox value="4" labelText="Checkbox 4" />
|
|
@@ -153,12 +147,7 @@ a row.
|
|
|
153
147
|
<Checkbox value="5" labelText="Checkbox 5" />
|
|
154
148
|
</CheckboxGroup>
|
|
155
149
|
<br />
|
|
156
|
-
<CheckboxGroup
|
|
157
|
-
id="row"
|
|
158
|
-
labelText="Row"
|
|
159
|
-
name="row-example"
|
|
160
|
-
layout={LayoutTypes.Row}
|
|
161
|
-
>
|
|
150
|
+
<CheckboxGroup id="row" labelText="Row" name="row-example" layout="row">
|
|
162
151
|
<Checkbox value="2" labelText="Checkbox 2" />
|
|
163
152
|
<Checkbox value="3" labelText="Checkbox 3" />
|
|
164
153
|
<Checkbox value="4" labelText="Checkbox 4" />
|
|
@@ -296,7 +285,7 @@ children are checked, the parent will be in the "checked" state.
|
|
|
296
285
|
The following working example can be used in your application to keep track of
|
|
297
286
|
the checked and indeterminate states - taken and modified from Chakra's
|
|
298
287
|
[Checkbox](https://chakra-ui.com/docs/form/checkbox#indeterminate) documentation.
|
|
299
|
-
Note that this example is specifically using Reservoir Design System (DS)
|
|
288
|
+
Note that this example is specifically using Reservoir Design System (DS)
|
|
300
289
|
`Checkbox` and `CheckboxGroup` components.
|
|
301
290
|
|
|
302
291
|
```tsx
|
|
@@ -7,7 +7,6 @@ import renderer from "react-test-renderer";
|
|
|
7
7
|
|
|
8
8
|
import CheckboxGroup from "./CheckboxGroup";
|
|
9
9
|
import Checkbox from "../Checkbox/Checkbox";
|
|
10
|
-
import { LayoutTypes } from "../../helpers/enums";
|
|
11
10
|
|
|
12
11
|
describe("CheckboxGroup Accessibility", () => {
|
|
13
12
|
it("passes axe accessibility with string labels ", async () => {
|
|
@@ -305,12 +304,7 @@ describe("Checkbox", () => {
|
|
|
305
304
|
.toJSON();
|
|
306
305
|
const row = renderer
|
|
307
306
|
.create(
|
|
308
|
-
<CheckboxGroup
|
|
309
|
-
labelText="row"
|
|
310
|
-
name="row"
|
|
311
|
-
id="row"
|
|
312
|
-
layout={LayoutTypes.Row}
|
|
313
|
-
>
|
|
307
|
+
<CheckboxGroup labelText="row" name="row" id="row" layout="row">
|
|
314
308
|
<Checkbox id="checkbox2" value="2" labelText="Checkbox 2" />
|
|
315
309
|
<Checkbox id="checkbox3" value="3" labelText="Checkbox 3" />
|
|
316
310
|
</CheckboxGroup>
|
|
@@ -11,8 +11,9 @@ import Fieldset from "../Fieldset/Fieldset";
|
|
|
11
11
|
import HelperErrorText, {
|
|
12
12
|
HelperErrorTextType,
|
|
13
13
|
} from "../HelperErrorText/HelperErrorText";
|
|
14
|
-
import { LayoutTypes } from "../../helpers/
|
|
14
|
+
import { LayoutTypes } from "../../helpers/types";
|
|
15
15
|
import { spacing } from "../../theme/foundations/spacing";
|
|
16
|
+
|
|
16
17
|
export interface CheckboxGroupProps {
|
|
17
18
|
/** Any child node passed to the component. */
|
|
18
19
|
children: React.ReactNode;
|
|
@@ -73,7 +74,7 @@ export const CheckboxGroup = chakra(
|
|
|
73
74
|
isInvalid = false,
|
|
74
75
|
isRequired = false,
|
|
75
76
|
labelText,
|
|
76
|
-
layout =
|
|
77
|
+
layout = "column",
|
|
77
78
|
name,
|
|
78
79
|
onChange,
|
|
79
80
|
showHelperInvalidText = true,
|
|
@@ -81,12 +82,12 @@ export const CheckboxGroup = chakra(
|
|
|
81
82
|
showRequiredLabel = true,
|
|
82
83
|
...rest
|
|
83
84
|
} = props;
|
|
84
|
-
const footnote
|
|
85
|
+
const footnote = isInvalid ? invalidText : helperText;
|
|
86
|
+
const newChildren: JSX.Element[] = [];
|
|
85
87
|
const spacingProp =
|
|
86
|
-
layout ===
|
|
88
|
+
layout === "column"
|
|
87
89
|
? spacing.input.group.default.vstack
|
|
88
90
|
: spacing.input.group.default.hstack;
|
|
89
|
-
const newChildren = [];
|
|
90
91
|
const checkboxProps =
|
|
91
92
|
defaultValue && onChange
|
|
92
93
|
? {
|
|
@@ -102,31 +103,34 @@ export const CheckboxGroup = chakra(
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// Go through the Checkbox children and update them as needed.
|
|
105
|
-
React.Children.map(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (child.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
React.Children.map(
|
|
107
|
+
children as JSX.Element,
|
|
108
|
+
(child: React.ReactElement, i) => {
|
|
109
|
+
if (child.type !== Checkbox) {
|
|
110
|
+
// Special case for Storybook MDX documentation.
|
|
111
|
+
if (child.props.mdxType && child.props.mdxType === "Checkbox") {
|
|
112
|
+
noop();
|
|
113
|
+
} else {
|
|
114
|
+
console.warn(
|
|
115
|
+
"NYPL Reservoir CheckboxGroup: Only `Checkbox` components are " +
|
|
116
|
+
"allowed as children."
|
|
117
|
+
);
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
|
-
}
|
|
117
120
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
if (child !== undefined && child !== null) {
|
|
122
|
+
const newProps = {
|
|
123
|
+
key: i,
|
|
124
|
+
id: `${id}-${i}`,
|
|
125
|
+
name,
|
|
126
|
+
isDisabled,
|
|
127
|
+
isInvalid,
|
|
128
|
+
isRequired,
|
|
129
|
+
};
|
|
130
|
+
newChildren.push(React.cloneElement(child, newProps));
|
|
131
|
+
}
|
|
128
132
|
}
|
|
129
|
-
|
|
133
|
+
);
|
|
130
134
|
|
|
131
135
|
// Get the Chakra-based styles for the custom elements in this component.
|
|
132
136
|
const styles = useMultiStyleConfig("CheckboxGroup", { isFullWidth });
|
|
@@ -147,7 +151,7 @@ export const CheckboxGroup = chakra(
|
|
|
147
151
|
direction={[layout]}
|
|
148
152
|
spacing={spacingProp}
|
|
149
153
|
ref={ref}
|
|
150
|
-
aria-label={!showLabel ? labelText :
|
|
154
|
+
aria-label={!showLabel ? labelText : undefined}
|
|
151
155
|
sx={styles.stack}
|
|
152
156
|
>
|
|
153
157
|
{newChildren}
|
|
@@ -155,10 +159,10 @@ export const CheckboxGroup = chakra(
|
|
|
155
159
|
</ChakraCheckboxGroup>
|
|
156
160
|
{footnote && showHelperInvalidText && (
|
|
157
161
|
<HelperErrorText
|
|
158
|
-
additionalStyles={styles.helperErrorText}
|
|
159
162
|
id={`${id}-helperErrorText`}
|
|
160
163
|
isInvalid={isInvalid}
|
|
161
164
|
text={footnote}
|
|
165
|
+
__css={styles.helperErrorText}
|
|
162
166
|
/>
|
|
163
167
|
)}
|
|
164
168
|
</Fieldset>
|