@nypl/design-system-react-components 0.25.13 → 0.27.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 +85 -0
- package/README.md +10 -10
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Card/Card.d.ts +11 -9
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +5 -6
- package/dist/components/Fieldset/Fieldset.d.ts +5 -6
- package/dist/components/Form/Form.d.ts +6 -6
- package/dist/components/Grid/GridTypes.d.ts +7 -7
- package/dist/components/Grid/SimpleGrid.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
- package/dist/components/Hero/Hero.d.ts +2 -1
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
- package/dist/components/Icons/Icon.d.ts +2 -1
- package/dist/components/Image/Image.d.ts +2 -2
- package/dist/components/Label/Label.d.ts +7 -4
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/List/List.d.ts +11 -11
- package/dist/components/List/ListTypes.d.ts +1 -1
- package/dist/components/Logo/Logo.d.ts +2 -1
- package/dist/components/Logo/LogoSvgs.d.ts +2 -0
- package/dist/components/Logo/LogoTypes.d.ts +2 -0
- package/dist/components/Modal/Modal.d.ts +28 -8
- package/dist/components/Notification/Notification.d.ts +4 -4
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
- package/dist/components/Radio/Radio.d.ts +4 -6
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
- package/dist/components/SearchBar/SearchBar.d.ts +4 -4
- package/dist/components/Select/Select.d.ts +10 -6
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
- package/dist/components/Slider/Slider.d.ts +6 -4
- package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -3
- package/dist/components/Template/Template.d.ts +4 -3
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +5 -5
- package/dist/components/Toggle/Toggle.d.ts +3 -4
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +1767 -1180
- 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 +1774 -1188
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/useCarouselStyles.d.ts +3 -2
- package/dist/hooks/useNYPLTheme.d.ts +12 -0
- package/dist/index.d.ts +5 -2
- package/dist/styles.css +1 -1
- package/dist/theme/components/button.d.ts +10 -2
- package/dist/theme/components/card.d.ts +42 -22
- package/dist/theme/components/checkbox.d.ts +5 -4
- package/dist/theme/components/checkboxGroup.d.ts +1 -1
- package/dist/theme/components/componentWrapper.d.ts +2 -2
- package/dist/theme/components/customTable.d.ts +84 -1
- package/dist/theme/components/fieldset.d.ts +4 -14
- package/dist/theme/components/global.d.ts +23 -17
- package/dist/theme/components/heading.d.ts +53 -0
- package/dist/theme/components/helperErrorText.d.ts +1 -0
- package/dist/theme/components/hero.d.ts +20 -14
- package/dist/theme/components/label.d.ts +9 -10
- package/dist/theme/components/list.d.ts +99 -9
- package/dist/theme/components/radio.d.ts +6 -4
- package/dist/theme/components/radioGroup.d.ts +1 -1
- package/dist/theme/components/select.d.ts +28 -5
- package/dist/theme/components/skeletonLoader.d.ts +2 -2
- package/dist/theme/components/slider.d.ts +6 -3
- package/dist/theme/components/structuredContent.d.ts +197 -0
- package/dist/theme/components/textInput.d.ts +18 -6
- package/dist/theme/components/toggle.d.ts +7 -4
- package/dist/theme/foundations/global.d.ts +2 -0
- package/dist/theme/foundations/radii.d.ts +1 -0
- package/dist/theme/foundations/spacing.d.ts +46 -43
- package/package.json +17 -19
- package/src/components/Accordion/Accordion.stories.mdx +9 -9
- package/src/components/Accordion/Accordion.test.tsx +21 -0
- package/src/components/Accordion/Accordion.tsx +13 -9
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
- package/src/components/Button/Button.stories.mdx +87 -23
- package/src/components/Button/Button.test.tsx +25 -0
- package/src/components/Button/Button.tsx +18 -7
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
- package/src/components/Card/Card.stories.mdx +287 -194
- package/src/components/Card/Card.test.tsx +102 -0
- package/src/components/Card/Card.tsx +73 -32
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +196 -36
- package/src/components/Chakra/Grid.stories.mdx +4 -4
- package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
- package/src/components/Checkbox/Checkbox.test.tsx +32 -9
- package/src/components/Checkbox/Checkbox.tsx +20 -15
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
- package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
- package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
- package/src/components/DatePicker/DatePicker.test.tsx +89 -13
- package/src/components/DatePicker/DatePicker.tsx +62 -56
- package/src/components/DatePicker/_DatePicker.scss +71 -13
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
- package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
- package/src/components/Fieldset/Fieldset.test.tsx +58 -28
- package/src/components/Fieldset/Fieldset.tsx +35 -30
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
- package/src/components/Form/Form.stories.mdx +72 -39
- package/src/components/Form/Form.test.tsx +58 -15
- package/src/components/Form/Form.tsx +89 -67
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
- package/src/components/Grid/GridTypes.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
- package/src/components/Grid/SimpleGrid.test.tsx +9 -0
- package/src/components/Grid/SimpleGrid.tsx +29 -20
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
- package/src/components/Heading/Heading.stories.mdx +36 -3
- package/src/components/Heading/Heading.test.tsx +10 -0
- package/src/components/Heading/Heading.tsx +56 -50
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
- package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
- package/src/components/Hero/Hero.stories.mdx +125 -95
- package/src/components/Hero/Hero.test.tsx +33 -0
- package/src/components/Hero/Hero.tsx +135 -126
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
- package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
- package/src/components/Icons/Icon.stories.mdx +31 -6
- package/src/components/Icons/Icon.test.tsx +38 -0
- package/src/components/Icons/Icon.tsx +93 -76
- package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
- package/src/components/Image/Image.stories.mdx +29 -5
- package/src/components/Image/Image.test.tsx +8 -0
- package/src/components/Image/Image.tsx +38 -26
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
- package/src/components/Label/Label.stories.mdx +42 -20
- package/src/components/Label/Label.test.tsx +42 -17
- package/src/components/Label/Label.tsx +22 -13
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
- package/src/components/Link/Link.stories.mdx +25 -15
- package/src/components/Link/Link.test.tsx +21 -22
- package/src/components/Link/Link.tsx +8 -8
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
- package/src/components/List/List.stories.mdx +75 -40
- package/src/components/List/List.test.tsx +67 -19
- package/src/components/List/List.tsx +38 -25
- package/src/components/List/ListTypes.tsx +1 -1
- package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
- package/src/components/Logo/Logo.stories.mdx +30 -6
- package/src/components/Logo/Logo.test.tsx +17 -0
- package/src/components/Logo/Logo.tsx +18 -6
- package/src/components/Logo/LogoSvgs.tsx +4 -0
- package/src/components/Logo/LogoTypes.tsx +2 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
- package/src/components/Modal/Modal.stories.mdx +256 -136
- package/src/components/Modal/Modal.test.tsx +151 -9
- 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 +25 -1
- package/src/components/Notification/Notification.test.tsx +23 -0
- package/src/components/Notification/Notification.tsx +46 -44
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
- package/src/components/Pagination/Pagination.stories.mdx +25 -6
- package/src/components/Pagination/Pagination.test.tsx +25 -0
- package/src/components/Pagination/Pagination.tsx +6 -6
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
- package/src/components/Placeholder/Placeholder.tsx +3 -1
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
- package/src/components/Radio/Radio.stories.mdx +64 -12
- package/src/components/Radio/Radio.test.tsx +28 -8
- package/src/components/Radio/Radio.tsx +66 -63
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
- package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
- package/src/components/RadioGroup/RadioGroup.tsx +106 -100
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
- package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
- package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
- package/src/components/SearchBar/SearchBar.tsx +17 -8
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
- package/src/components/Select/Select.stories.mdx +128 -49
- package/src/components/Select/Select.test.tsx +63 -16
- package/src/components/Select/Select.tsx +131 -92
- package/src/components/Select/SelectTypes.tsx +5 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +765 -425
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
- package/src/components/Slider/Slider.stories.mdx +91 -42
- package/src/components/Slider/Slider.test.tsx +65 -17
- package/src/components/Slider/Slider.tsx +26 -19
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
- package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
- package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
- package/src/components/StatusBadge/StatusBadge.tsx +25 -20
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
- package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
- package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
- package/src/components/StructuredContent/StructuredContent.tsx +80 -75
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
- package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
- package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
- package/src/components/StyleGuide/ColorCard.tsx +1 -1
- package/src/components/StyleGuide/Colors.stories.mdx +1 -2
- package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
- package/src/components/StyleGuide/Forms.stories.mdx +27 -12
- package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
- package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
- package/src/components/StyleGuide/Typography.stories.mdx +30 -21
- package/src/components/Table/Table.stories.mdx +38 -11
- package/src/components/Table/Table.test.tsx +15 -0
- package/src/components/Table/Table.tsx +7 -7
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
- package/src/components/Tabs/Tabs.stories.mdx +52 -3
- package/src/components/Tabs/Tabs.test.tsx +16 -0
- package/src/components/Tabs/Tabs.tsx +10 -6
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
- package/src/components/Template/Template.stories.mdx +47 -43
- package/src/components/Template/Template.test.tsx +33 -0
- package/src/components/Template/Template.tsx +65 -60
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
- package/src/components/Text/Text.stories.mdx +20 -1
- package/src/components/Text/Text.test.tsx +12 -0
- package/src/components/Text/Text.tsx +6 -4
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
- package/src/components/TextInput/TextInput.stories.mdx +65 -19
- package/src/components/TextInput/TextInput.test.tsx +42 -28
- package/src/components/TextInput/TextInput.tsx +121 -113
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
- package/src/components/Toggle/Toggle.stories.mdx +80 -22
- package/src/components/Toggle/Toggle.test.tsx +27 -9
- package/src/components/Toggle/Toggle.tsx +22 -18
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
- package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
- package/src/docs/Chakra.stories.mdx +50 -9
- package/src/docs/Welcome.stories.mdx +160 -41
- package/src/hooks/useCarouselStyles.stories.mdx +22 -2
- package/src/hooks/useCarouselStyles.ts +3 -2
- package/src/hooks/useNYPLTheme.stories.mdx +101 -0
- package/src/hooks/useNYPLTheme.ts +30 -6
- package/src/hooks/useWindowSize.stories.mdx +23 -0
- package/src/index.ts +5 -2
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/styles.scss +0 -1
- package/src/theme/components/button.ts +15 -7
- package/src/theme/components/card.ts +30 -19
- package/src/theme/components/checkbox.ts +10 -8
- package/src/theme/components/checkboxGroup.ts +1 -1
- package/src/theme/components/componentWrapper.ts +2 -2
- package/src/theme/components/customTable.ts +39 -31
- package/src/theme/components/fieldset.ts +1 -2
- package/src/theme/components/global.ts +25 -20
- package/src/theme/components/heading.ts +1 -1
- package/src/theme/components/helperErrorText.ts +1 -0
- package/src/theme/components/hero.ts +13 -15
- package/src/theme/components/label.ts +4 -3
- package/src/theme/components/list.ts +73 -66
- package/src/theme/components/notification.ts +2 -2
- package/src/theme/components/radio.ts +9 -9
- package/src/theme/components/radioGroup.ts +1 -1
- package/src/theme/components/select.ts +31 -22
- package/src/theme/components/skeletonLoader.ts +3 -3
- package/src/theme/components/slider.ts +8 -7
- package/src/theme/components/statusBadge.ts +2 -2
- package/src/theme/components/structuredContent.ts +66 -1
- package/src/theme/components/tabs.ts +2 -2
- package/src/theme/components/template.ts +9 -9
- package/src/theme/components/textInput.ts +13 -12
- package/src/theme/components/toggle.ts +17 -10
- package/src/theme/components/videoPlayer.ts +1 -1
- package/src/theme/foundations/colors.ts +1 -1
- package/src/theme/foundations/radii.ts +1 -0
- package/src/theme/foundations/spacing.ts +70 -22
- package/src/theme/foundations/typography.ts +2 -2
- package/src/utils/componentCategories.ts +1 -2
- package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
- package/dist/helpers/generateUUID.d.ts +0 -1
- package/src/components/Modal/_Modal.scss +0 -18
- package/src/helpers/generateUUID.tsx +0 -5
|
@@ -143,9 +143,21 @@ describe("ComponentWrapper", () => {
|
|
|
143
143
|
</ComponentWrapper>
|
|
144
144
|
)
|
|
145
145
|
.toJSON();
|
|
146
|
+
const withChakraProps = renderer.create(
|
|
147
|
+
<ComponentWrapper id="chakra" p="20px" color="ui.error.primary">
|
|
148
|
+
<div>children elements</div>
|
|
149
|
+
</ComponentWrapper>
|
|
150
|
+
);
|
|
151
|
+
const withOtherProps = renderer.create(
|
|
152
|
+
<ComponentWrapper id="props" data-testid="props">
|
|
153
|
+
<div>children elements</div>
|
|
154
|
+
</ComponentWrapper>
|
|
155
|
+
);
|
|
146
156
|
|
|
147
157
|
expect(basic).toMatchSnapshot();
|
|
148
158
|
expect(onlyWithChildren).toMatchSnapshot();
|
|
149
159
|
expect(isInvalid).toMatchSnapshot();
|
|
160
|
+
expect(withChakraProps).toMatchSnapshot();
|
|
161
|
+
expect(withOtherProps).toMatchSnapshot();
|
|
150
162
|
});
|
|
151
163
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, useMultiStyleConfig } from "@chakra-ui/react";
|
|
1
|
+
import { Box, chakra, useMultiStyleConfig } from "@chakra-ui/react";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
4
|
import Heading from "../Heading/Heading";
|
|
@@ -7,8 +7,6 @@ import HelperErrorText, {
|
|
|
7
7
|
HelperErrorTextType,
|
|
8
8
|
} from "../HelperErrorText/HelperErrorText";
|
|
9
9
|
import Text from "../Text/Text";
|
|
10
|
-
import generateUUID from "../../helpers/generateUUID";
|
|
11
|
-
|
|
12
10
|
export interface ComponentWrapperProps {
|
|
13
11
|
/** The UI elements that will be wrapped by this component */
|
|
14
12
|
children: React.ReactNode;
|
|
@@ -27,50 +25,50 @@ export interface ComponentWrapperProps {
|
|
|
27
25
|
isInvalid?: boolean;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
props: React.PropsWithChildren<ComponentWrapperProps>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
export const ComponentWrapper = chakra(
|
|
29
|
+
(props: React.PropsWithChildren<ComponentWrapperProps>) => {
|
|
30
|
+
const {
|
|
31
|
+
children,
|
|
32
|
+
descriptionText,
|
|
33
|
+
headingText,
|
|
34
|
+
helperText,
|
|
35
|
+
id,
|
|
36
|
+
invalidText,
|
|
37
|
+
isInvalid = false,
|
|
38
|
+
...rest
|
|
39
|
+
} = props;
|
|
40
|
+
const hasChildren = !!children;
|
|
41
|
+
const styles = useMultiStyleConfig("ComponentWrapper", { hasChildren });
|
|
42
|
+
const footnote: HelperErrorTextType = isInvalid ? invalidText : helperText;
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
// Note: Typescript warns when there are no children passed and
|
|
45
|
+
// doesn't compile. This is meant to log in non-Typescript apps.
|
|
46
|
+
if (!hasChildren) {
|
|
47
|
+
console.warn("NYPL Reservoir ComponentWrapper: No children were passed.");
|
|
48
|
+
}
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<Box __css={styles.helperText}>
|
|
50
|
+
return (
|
|
51
|
+
<Box __css={styles} {...rest}>
|
|
52
|
+
{headingText && (
|
|
53
|
+
<Heading
|
|
54
|
+
id={`${id}-heading`}
|
|
55
|
+
level={HeadingLevels.Two}
|
|
56
|
+
text={headingText}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
{descriptionText && <Text>{descriptionText}</Text>}
|
|
60
|
+
{children}
|
|
61
|
+
{footnote && (
|
|
65
62
|
<HelperErrorText
|
|
63
|
+
additionalStyles={styles.helperErrorText}
|
|
66
64
|
id={`${id}-helperText`}
|
|
67
65
|
isInvalid={isInvalid}
|
|
68
66
|
text={footnote}
|
|
69
67
|
/>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
)}
|
|
69
|
+
</Box>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
75
73
|
|
|
76
74
|
export default ComponentWrapper;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`ComponentWrapper Renders the UI snapshot correctly 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
className="css-
|
|
5
|
+
className="css-1xdhyk6"
|
|
6
6
|
>
|
|
7
7
|
<h2
|
|
8
|
-
className="chakra-heading css-
|
|
8
|
+
className="chakra-heading css-1xdhyk6"
|
|
9
9
|
id="id-heading"
|
|
10
10
|
>
|
|
11
11
|
heading text
|
|
12
12
|
</h2>
|
|
13
13
|
<p
|
|
14
|
-
className="chakra-text css-
|
|
14
|
+
className="chakra-text css-1xdhyk6"
|
|
15
15
|
>
|
|
16
16
|
description text
|
|
17
17
|
</p>
|
|
@@ -19,27 +19,23 @@ exports[`ComponentWrapper Renders the UI snapshot correctly 1`] = `
|
|
|
19
19
|
children elements
|
|
20
20
|
</div>
|
|
21
21
|
<div
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dangerouslySetInnerHTML={
|
|
29
|
-
Object {
|
|
30
|
-
"__html": "helper text",
|
|
31
|
-
}
|
|
22
|
+
aria-atomic={true}
|
|
23
|
+
aria-live="off"
|
|
24
|
+
className="css-1xdhyk6"
|
|
25
|
+
dangerouslySetInnerHTML={
|
|
26
|
+
Object {
|
|
27
|
+
"__html": "helper text",
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
}
|
|
30
|
+
data-isinvalid={false}
|
|
31
|
+
id="id-helperText"
|
|
32
|
+
/>
|
|
37
33
|
</div>
|
|
38
34
|
`;
|
|
39
35
|
|
|
40
36
|
exports[`ComponentWrapper Renders the UI snapshot correctly 2`] = `
|
|
41
37
|
<div
|
|
42
|
-
className="css-
|
|
38
|
+
className="css-1xdhyk6"
|
|
43
39
|
>
|
|
44
40
|
<div>
|
|
45
41
|
children elements
|
|
@@ -49,16 +45,16 @@ exports[`ComponentWrapper Renders the UI snapshot correctly 2`] = `
|
|
|
49
45
|
|
|
50
46
|
exports[`ComponentWrapper Renders the UI snapshot correctly 3`] = `
|
|
51
47
|
<div
|
|
52
|
-
className="css-
|
|
48
|
+
className="css-1xdhyk6"
|
|
53
49
|
>
|
|
54
50
|
<h2
|
|
55
|
-
className="chakra-heading css-
|
|
51
|
+
className="chakra-heading css-1xdhyk6"
|
|
56
52
|
id="id-heading"
|
|
57
53
|
>
|
|
58
54
|
heading text
|
|
59
55
|
</h2>
|
|
60
56
|
<p
|
|
61
|
-
className="chakra-text css-
|
|
57
|
+
className="chakra-text css-1xdhyk6"
|
|
62
58
|
>
|
|
63
59
|
description text
|
|
64
60
|
</p>
|
|
@@ -66,20 +62,37 @@ exports[`ComponentWrapper Renders the UI snapshot correctly 3`] = `
|
|
|
66
62
|
children elements
|
|
67
63
|
</div>
|
|
68
64
|
<div
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
dangerouslySetInnerHTML={
|
|
76
|
-
Object {
|
|
77
|
-
"__html": "invalid text",
|
|
78
|
-
}
|
|
65
|
+
aria-atomic={true}
|
|
66
|
+
aria-live="polite"
|
|
67
|
+
className="css-1xdhyk6"
|
|
68
|
+
dangerouslySetInnerHTML={
|
|
69
|
+
Object {
|
|
70
|
+
"__html": "invalid text",
|
|
79
71
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
}
|
|
73
|
+
data-isinvalid={true}
|
|
74
|
+
id="id-helperText"
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
exports[`ComponentWrapper Renders the UI snapshot correctly 4`] = `
|
|
80
|
+
<div
|
|
81
|
+
className="css-kle7zy"
|
|
82
|
+
>
|
|
83
|
+
<div>
|
|
84
|
+
children elements
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
exports[`ComponentWrapper Renders the UI snapshot correctly 5`] = `
|
|
90
|
+
<div
|
|
91
|
+
className="css-1xdhyk6"
|
|
92
|
+
data-testid="props"
|
|
93
|
+
>
|
|
94
|
+
<div>
|
|
95
|
+
children elements
|
|
83
96
|
</div>
|
|
84
97
|
</div>
|
|
85
98
|
`;
|
|
@@ -67,7 +67,7 @@ export const enumValues = getStorybookEnumValues(
|
|
|
67
67
|
showLabel: {
|
|
68
68
|
table: { defaultValue: { summary: true } },
|
|
69
69
|
},
|
|
70
|
-
|
|
70
|
+
showRequiredLabel: {
|
|
71
71
|
table: { defaultValue: { summary: true } },
|
|
72
72
|
},
|
|
73
73
|
}}
|
|
@@ -78,7 +78,20 @@ export const enumValues = getStorybookEnumValues(
|
|
|
78
78
|
| Component Version | DS Version |
|
|
79
79
|
| ----------------- | ---------- |
|
|
80
80
|
| Added | `0.24.0` |
|
|
81
|
-
| Latest | `0.
|
|
81
|
+
| Latest | `0.26.0` |
|
|
82
|
+
|
|
83
|
+
## Table of Contents
|
|
84
|
+
|
|
85
|
+
- [Overview](#overview)
|
|
86
|
+
- [Component Props](#component-props)
|
|
87
|
+
- [Accessibility](#accessibility)
|
|
88
|
+
- [Date Range](#date-range)
|
|
89
|
+
- [Calendar Types](#calendar-types)
|
|
90
|
+
- [Other States](#other-states)
|
|
91
|
+
- [Date Inputs and Output](#date-inputs-and-output)
|
|
92
|
+
- [Getting Date Input Values](#getting-date-input-values)
|
|
93
|
+
|
|
94
|
+
## Overview
|
|
82
95
|
|
|
83
96
|
<Description of={DatePicker} />
|
|
84
97
|
|
|
@@ -86,6 +99,8 @@ This is fully customizable to allow selectable full dates, only the month, or
|
|
|
86
99
|
only they year as input. Initial date values and max and min date values can
|
|
87
100
|
also be added through props.
|
|
88
101
|
|
|
102
|
+
## Component Props
|
|
103
|
+
|
|
89
104
|
<Canvas withToolbar>
|
|
90
105
|
<Story
|
|
91
106
|
name="DatePicker with Controls"
|
|
@@ -97,33 +112,58 @@ also be added through props.
|
|
|
97
112
|
helperTextFrom: "Select start date.",
|
|
98
113
|
helperTextTo: "Select end date.",
|
|
99
114
|
id: "datePicker-id",
|
|
100
|
-
initialDate: "
|
|
101
|
-
initialDateTo: "1/
|
|
115
|
+
initialDate: "4/1/2022",
|
|
116
|
+
initialDateTo: "12/1/2022",
|
|
102
117
|
invalidText: "Please select a valid date.",
|
|
103
118
|
isDateRange: false,
|
|
104
119
|
isDisabled: false,
|
|
105
120
|
isInvalid: false,
|
|
106
121
|
isRequired: false,
|
|
107
122
|
labelText: "Select the date you want to visit NYPL",
|
|
108
|
-
maxDate: "1/1/
|
|
109
|
-
minDate: "1/1/
|
|
123
|
+
maxDate: "1/1/2023",
|
|
124
|
+
minDate: "1/1/2022",
|
|
110
125
|
nameFrom: "visit-dates-from",
|
|
111
126
|
nameTo: "visit-dates-to",
|
|
112
127
|
onChange: undefined,
|
|
113
128
|
refTo: undefined,
|
|
114
129
|
showHelperInvalidText: true,
|
|
115
130
|
showLabel: true,
|
|
116
|
-
|
|
131
|
+
showRequiredLabel: true,
|
|
117
132
|
}}
|
|
118
133
|
>
|
|
119
134
|
{(args) => (
|
|
120
|
-
<DatePicker
|
|
135
|
+
<DatePicker
|
|
136
|
+
{...args}
|
|
137
|
+
dateType={enumValues.getValue(args.dateType)}
|
|
138
|
+
onChange={undefined}
|
|
139
|
+
/>
|
|
121
140
|
)}
|
|
122
141
|
</Story>
|
|
123
142
|
</Canvas>
|
|
124
143
|
|
|
125
144
|
<ArgsTable story="DatePicker with Controls" />
|
|
126
145
|
|
|
146
|
+
## Accessibility
|
|
147
|
+
|
|
148
|
+
The Reservoir `DatePicker` component implements the `react-datepicker` npm package.
|
|
149
|
+
This package exports a component that is used internally to display the popup
|
|
150
|
+
calendar, manage its data, and associate the `<label>` element with its corresponding
|
|
151
|
+
`<input>` element. This component is accessible through keyboard navigation.
|
|
152
|
+
|
|
153
|
+
The Reservoir `DatePicker` handles the grouping of the two `<input>` elements in
|
|
154
|
+
the "date range" mode by wrapping the elements in a `<fieldset>` element with
|
|
155
|
+
its own `<legend>` label for the group. Note that this is in addition to the two
|
|
156
|
+
labels that each `<input>` element is associated with.
|
|
157
|
+
|
|
158
|
+
When `showLabel` is set to false, the single `<input>` element's `aria-label`
|
|
159
|
+
attribute is set to the required `labelText` value. In the "date range" mode,
|
|
160
|
+
when `showLabel` is set to false, the `<fieldset>`'s `<legend>` will have the
|
|
161
|
+
`labelText` visually hidden.
|
|
162
|
+
|
|
163
|
+
Resources:
|
|
164
|
+
|
|
165
|
+
- [react-datepicker Accessibility](https://github.com/Hacker0x01/react-datepicker#accessibility)
|
|
166
|
+
|
|
127
167
|
## Date Range
|
|
128
168
|
|
|
129
169
|
A date range can be rendered by setting the `isDateRange` prop to `true`. This
|
|
@@ -133,8 +173,8 @@ will share the props and styling. Note that for date range types, a `fieldset`
|
|
|
133
173
|
is used as the parent wrapper and the `labelText` is used for the `legend`
|
|
134
174
|
element text.
|
|
135
175
|
|
|
136
|
-
Note: In the following example, the minimum date is "1/1/
|
|
137
|
-
is "
|
|
176
|
+
Note: In the following example, the minimum date is "1/1/2022" and the max date
|
|
177
|
+
is "7/1/22". This means only values within this range are selectable from the
|
|
138
178
|
popup calendar.
|
|
139
179
|
|
|
140
180
|
<Canvas withToolbar>
|
|
@@ -143,8 +183,8 @@ popup calendar.
|
|
|
143
183
|
id="date-range"
|
|
144
184
|
dateFormat="yyyy-MM-dd"
|
|
145
185
|
dateType={DatePickerTypes.Full}
|
|
146
|
-
minDate="1/1/
|
|
147
|
-
maxDate="
|
|
186
|
+
minDate="1/1/2022"
|
|
187
|
+
maxDate="7/1/2022"
|
|
148
188
|
labelText="Select the date range you want to visit NYPL"
|
|
149
189
|
nameFrom="visit-dates-from"
|
|
150
190
|
nameTo="visit-dates-to"
|
|
@@ -152,7 +192,6 @@ popup calendar.
|
|
|
152
192
|
helperTextTo="To this date."
|
|
153
193
|
helperText="Select a valid date range."
|
|
154
194
|
invalidText="There was an error with the date range :("
|
|
155
|
-
showOptReqLabel={false}
|
|
156
195
|
isDateRange
|
|
157
196
|
/>
|
|
158
197
|
</Story>
|
|
@@ -198,7 +237,6 @@ calendar; the four previous years, the current year, and the next seven years.
|
|
|
198
237
|
dateType={DatePickerTypes.Year}
|
|
199
238
|
labelText="Select the year you want to visit NYPL"
|
|
200
239
|
helperText="Note that the Library may be closed on Sundays."
|
|
201
|
-
showOptReqLabel={false}
|
|
202
240
|
/>
|
|
203
241
|
</Story>
|
|
204
242
|
</Canvas>
|
|
@@ -215,7 +253,6 @@ calendar; the four previous years, the current year, and the next seven years.
|
|
|
215
253
|
labelText="Select the year you want to visit NYPL"
|
|
216
254
|
helperText="Note that the Library may be closed on Sundays."
|
|
217
255
|
invalidText="Please select a valid date."
|
|
218
|
-
showOptReqLabel={false}
|
|
219
256
|
isInvalid
|
|
220
257
|
isDateRange
|
|
221
258
|
/>
|
|
@@ -230,7 +267,6 @@ calendar; the four previous years, the current year, and the next seven years.
|
|
|
230
267
|
id="disabled-date"
|
|
231
268
|
dateType={DatePickerTypes.Full}
|
|
232
269
|
labelText="Select the year you want to visit NYPL"
|
|
233
|
-
showOptReqLabel={false}
|
|
234
270
|
isDateRange
|
|
235
271
|
isDisabled
|
|
236
272
|
/>
|
|
@@ -239,8 +275,8 @@ calendar; the four previous years, the current year, and the next seven years.
|
|
|
239
275
|
|
|
240
276
|
### Required State
|
|
241
277
|
|
|
242
|
-
The "Required"
|
|
243
|
-
|
|
278
|
+
The "Required" text in the legend in the date range, or the label in a normal
|
|
279
|
+
date input, can be hidden when `showRequiredLabel` is set to `false`.
|
|
244
280
|
|
|
245
281
|
<Canvas>
|
|
246
282
|
<DSProvider>
|
|
@@ -302,7 +338,7 @@ written in [ISO-8601 format](https://www.w3.org/TR/NOTE-datetime).
|
|
|
302
338
|
|
|
303
339
|
The maximum and minimum date values can be set through the `maxDate` and
|
|
304
340
|
`minDate` props, respectively. In this example, go back to January through
|
|
305
|
-
February to see the dates that are available to select.
|
|
341
|
+
February to see the dates that are available to select in 2022.
|
|
306
342
|
|
|
307
343
|
<Canvas>
|
|
308
344
|
<DSProvider>
|
|
@@ -311,22 +347,22 @@ February to see the dates that are available to select.
|
|
|
311
347
|
dateFormat="MM-dd-yyyy"
|
|
312
348
|
dateType={DatePickerTypes.Full}
|
|
313
349
|
labelText="Select the date you want to visit NYPL"
|
|
314
|
-
minDate="1/1/
|
|
315
|
-
maxDate="3/1/
|
|
350
|
+
minDate="1/1/2022"
|
|
351
|
+
maxDate="3/1/2022"
|
|
316
352
|
isDateRange
|
|
317
353
|
/>
|
|
318
354
|
</DSProvider>
|
|
319
355
|
</Canvas>
|
|
320
356
|
|
|
321
|
-
## Getting Date
|
|
357
|
+
## Getting Date Input Values
|
|
322
358
|
|
|
323
359
|
### Controlled Component Using `onChange` prop
|
|
324
360
|
|
|
325
|
-
If your application uses controlled React components and the
|
|
326
|
-
be controlled, you can extract the data through the
|
|
327
|
-
This will be called every time the date is updated in
|
|
328
|
-
input field or the end date input field. The returned
|
|
329
|
-
`startDate` and `endDate` keys and `Date` object values.
|
|
361
|
+
If your application uses controlled React components and the Reservoir Design
|
|
362
|
+
System (DS) DatePicker must be controlled, you can extract the data through the
|
|
363
|
+
`onChange` prop function. This will be called every time the date is updated in
|
|
364
|
+
either the start date input field or the end date input field. The returned
|
|
365
|
+
data is an object with `startDate` and `endDate` keys and `Date` object values.
|
|
330
366
|
|
|
331
367
|
```tsx
|
|
332
368
|
const onChange = (data) => {
|