@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
|
@@ -9,13 +9,12 @@ exports[`Checkbox renders the UI snapshot correctly 1`] = `
|
|
|
9
9
|
column
|
|
10
10
|
</legend>
|
|
11
11
|
<div
|
|
12
|
-
aria-label={null}
|
|
13
12
|
className="chakra-stack css-1wdv1uh"
|
|
14
13
|
data-testid="checkbox-group"
|
|
15
14
|
id="column"
|
|
16
15
|
>
|
|
17
16
|
<label
|
|
18
|
-
className="chakra-checkbox css-
|
|
17
|
+
className="chakra-checkbox css-scawxr"
|
|
19
18
|
onClick={[Function]}
|
|
20
19
|
>
|
|
21
20
|
<input
|
|
@@ -76,7 +75,7 @@ exports[`Checkbox renders the UI snapshot correctly 1`] = `
|
|
|
76
75
|
</span>
|
|
77
76
|
</label>
|
|
78
77
|
<label
|
|
79
|
-
className="chakra-checkbox css-
|
|
78
|
+
className="chakra-checkbox css-scawxr"
|
|
80
79
|
onClick={[Function]}
|
|
81
80
|
>
|
|
82
81
|
<input
|
|
@@ -149,13 +148,12 @@ exports[`Checkbox renders the UI snapshot correctly 2`] = `
|
|
|
149
148
|
row
|
|
150
149
|
</legend>
|
|
151
150
|
<div
|
|
152
|
-
aria-label={null}
|
|
153
151
|
className="chakra-stack css-1objuxj"
|
|
154
152
|
data-testid="checkbox-group"
|
|
155
153
|
id="row"
|
|
156
154
|
>
|
|
157
155
|
<label
|
|
158
|
-
className="chakra-checkbox css-
|
|
156
|
+
className="chakra-checkbox css-scawxr"
|
|
159
157
|
onClick={[Function]}
|
|
160
158
|
>
|
|
161
159
|
<input
|
|
@@ -216,7 +214,7 @@ exports[`Checkbox renders the UI snapshot correctly 2`] = `
|
|
|
216
214
|
</span>
|
|
217
215
|
</label>
|
|
218
216
|
<label
|
|
219
|
-
className="chakra-checkbox css-
|
|
217
|
+
className="chakra-checkbox css-scawxr"
|
|
220
218
|
onClick={[Function]}
|
|
221
219
|
>
|
|
222
220
|
<input
|
|
@@ -295,7 +293,7 @@ exports[`Checkbox renders the UI snapshot correctly 3`] = `
|
|
|
295
293
|
id="noLabel"
|
|
296
294
|
>
|
|
297
295
|
<label
|
|
298
|
-
className="chakra-checkbox css-
|
|
296
|
+
className="chakra-checkbox css-scawxr"
|
|
299
297
|
onClick={[Function]}
|
|
300
298
|
>
|
|
301
299
|
<input
|
|
@@ -356,7 +354,7 @@ exports[`Checkbox renders the UI snapshot correctly 3`] = `
|
|
|
356
354
|
</span>
|
|
357
355
|
</label>
|
|
358
356
|
<label
|
|
359
|
-
className="chakra-checkbox css-
|
|
357
|
+
className="chakra-checkbox css-scawxr"
|
|
360
358
|
onClick={[Function]}
|
|
361
359
|
>
|
|
362
360
|
<input
|
|
@@ -429,13 +427,12 @@ exports[`Checkbox renders the UI snapshot correctly 4`] = `
|
|
|
429
427
|
helperText
|
|
430
428
|
</legend>
|
|
431
429
|
<div
|
|
432
|
-
aria-label={null}
|
|
433
430
|
className="chakra-stack css-1wdv1uh"
|
|
434
431
|
data-testid="checkbox-group"
|
|
435
432
|
id="helperText"
|
|
436
433
|
>
|
|
437
434
|
<label
|
|
438
|
-
className="chakra-checkbox css-
|
|
435
|
+
className="chakra-checkbox css-scawxr"
|
|
439
436
|
onClick={[Function]}
|
|
440
437
|
>
|
|
441
438
|
<input
|
|
@@ -496,7 +493,7 @@ exports[`Checkbox renders the UI snapshot correctly 4`] = `
|
|
|
496
493
|
</span>
|
|
497
494
|
</label>
|
|
498
495
|
<label
|
|
499
|
-
className="chakra-checkbox css-
|
|
496
|
+
className="chakra-checkbox css-scawxr"
|
|
500
497
|
onClick={[Function]}
|
|
501
498
|
>
|
|
502
499
|
<input
|
|
@@ -581,13 +578,12 @@ exports[`Checkbox renders the UI snapshot correctly 5`] = `
|
|
|
581
578
|
invalidText
|
|
582
579
|
</legend>
|
|
583
580
|
<div
|
|
584
|
-
aria-label={null}
|
|
585
581
|
className="chakra-stack css-1wdv1uh"
|
|
586
582
|
data-testid="checkbox-group"
|
|
587
583
|
id="invalidText"
|
|
588
584
|
>
|
|
589
585
|
<label
|
|
590
|
-
className="chakra-checkbox css-
|
|
586
|
+
className="chakra-checkbox css-scawxr"
|
|
591
587
|
onClick={[Function]}
|
|
592
588
|
>
|
|
593
589
|
<input
|
|
@@ -648,7 +644,7 @@ exports[`Checkbox renders the UI snapshot correctly 5`] = `
|
|
|
648
644
|
</span>
|
|
649
645
|
</label>
|
|
650
646
|
<label
|
|
651
|
-
className="chakra-checkbox css-
|
|
647
|
+
className="chakra-checkbox css-scawxr"
|
|
652
648
|
onClick={[Function]}
|
|
653
649
|
>
|
|
654
650
|
<input
|
|
@@ -721,13 +717,12 @@ exports[`Checkbox renders the UI snapshot correctly 6`] = `
|
|
|
721
717
|
no optional or required label
|
|
722
718
|
</legend>
|
|
723
719
|
<div
|
|
724
|
-
aria-label={null}
|
|
725
720
|
className="chakra-stack css-1wdv1uh"
|
|
726
721
|
data-testid="checkbox-group"
|
|
727
722
|
id="noRequiredLabel"
|
|
728
723
|
>
|
|
729
724
|
<label
|
|
730
|
-
className="chakra-checkbox css-
|
|
725
|
+
className="chakra-checkbox css-scawxr"
|
|
731
726
|
onClick={[Function]}
|
|
732
727
|
>
|
|
733
728
|
<input
|
|
@@ -788,7 +783,7 @@ exports[`Checkbox renders the UI snapshot correctly 6`] = `
|
|
|
788
783
|
</span>
|
|
789
784
|
</label>
|
|
790
785
|
<label
|
|
791
|
-
className="chakra-checkbox css-
|
|
786
|
+
className="chakra-checkbox css-scawxr"
|
|
792
787
|
onClick={[Function]}
|
|
793
788
|
>
|
|
794
789
|
<input
|
|
@@ -864,13 +859,12 @@ exports[`Checkbox renders the UI snapshot correctly 7`] = `
|
|
|
864
859
|
</span>
|
|
865
860
|
</legend>
|
|
866
861
|
<div
|
|
867
|
-
aria-label={null}
|
|
868
862
|
className="chakra-stack css-1wdv1uh"
|
|
869
863
|
data-testid="checkbox-group"
|
|
870
864
|
id="required"
|
|
871
865
|
>
|
|
872
866
|
<label
|
|
873
|
-
className="chakra-checkbox css-
|
|
867
|
+
className="chakra-checkbox css-scawxr"
|
|
874
868
|
onClick={[Function]}
|
|
875
869
|
>
|
|
876
870
|
<input
|
|
@@ -931,7 +925,7 @@ exports[`Checkbox renders the UI snapshot correctly 7`] = `
|
|
|
931
925
|
</span>
|
|
932
926
|
</label>
|
|
933
927
|
<label
|
|
934
|
-
className="chakra-checkbox css-
|
|
928
|
+
className="chakra-checkbox css-scawxr"
|
|
935
929
|
onClick={[Function]}
|
|
936
930
|
>
|
|
937
931
|
<input
|
|
@@ -1004,13 +998,12 @@ exports[`Checkbox renders the UI snapshot correctly 8`] = `
|
|
|
1004
998
|
invalid
|
|
1005
999
|
</legend>
|
|
1006
1000
|
<div
|
|
1007
|
-
aria-label={null}
|
|
1008
1001
|
className="chakra-stack css-1wdv1uh"
|
|
1009
1002
|
data-testid="checkbox-group"
|
|
1010
1003
|
id="invalid"
|
|
1011
1004
|
>
|
|
1012
1005
|
<label
|
|
1013
|
-
className="chakra-checkbox css-
|
|
1006
|
+
className="chakra-checkbox css-scawxr"
|
|
1014
1007
|
data-invalid=""
|
|
1015
1008
|
onClick={[Function]}
|
|
1016
1009
|
>
|
|
@@ -1074,7 +1067,7 @@ exports[`Checkbox renders the UI snapshot correctly 8`] = `
|
|
|
1074
1067
|
</span>
|
|
1075
1068
|
</label>
|
|
1076
1069
|
<label
|
|
1077
|
-
className="chakra-checkbox css-
|
|
1070
|
+
className="chakra-checkbox css-scawxr"
|
|
1078
1071
|
data-invalid=""
|
|
1079
1072
|
onClick={[Function]}
|
|
1080
1073
|
>
|
|
@@ -1150,13 +1143,12 @@ exports[`Checkbox renders the UI snapshot correctly 9`] = `
|
|
|
1150
1143
|
disabled
|
|
1151
1144
|
</legend>
|
|
1152
1145
|
<div
|
|
1153
|
-
aria-label={null}
|
|
1154
1146
|
className="chakra-stack css-1wdv1uh"
|
|
1155
1147
|
data-testid="checkbox-group"
|
|
1156
1148
|
id="disabled"
|
|
1157
1149
|
>
|
|
1158
1150
|
<label
|
|
1159
|
-
className="chakra-checkbox css-
|
|
1151
|
+
className="chakra-checkbox css-scawxr"
|
|
1160
1152
|
data-disabled=""
|
|
1161
1153
|
onClick={[Function]}
|
|
1162
1154
|
>
|
|
@@ -1220,7 +1212,7 @@ exports[`Checkbox renders the UI snapshot correctly 9`] = `
|
|
|
1220
1212
|
</span>
|
|
1221
1213
|
</label>
|
|
1222
1214
|
<label
|
|
1223
|
-
className="chakra-checkbox css-
|
|
1215
|
+
className="chakra-checkbox css-scawxr"
|
|
1224
1216
|
data-disabled=""
|
|
1225
1217
|
onClick={[Function]}
|
|
1226
1218
|
>
|
|
@@ -1296,13 +1288,12 @@ exports[`Checkbox renders the UI snapshot correctly 10`] = `
|
|
|
1296
1288
|
jsxLabels
|
|
1297
1289
|
</legend>
|
|
1298
1290
|
<div
|
|
1299
|
-
aria-label={null}
|
|
1300
1291
|
className="chakra-stack css-1wdv1uh"
|
|
1301
1292
|
data-testid="checkbox-group"
|
|
1302
1293
|
id="jsxLabels"
|
|
1303
1294
|
>
|
|
1304
1295
|
<label
|
|
1305
|
-
className="chakra-checkbox css-
|
|
1296
|
+
className="chakra-checkbox css-scawxr"
|
|
1306
1297
|
onClick={[Function]}
|
|
1307
1298
|
>
|
|
1308
1299
|
<input
|
|
@@ -1375,7 +1366,7 @@ exports[`Checkbox renders the UI snapshot correctly 10`] = `
|
|
|
1375
1366
|
</span>
|
|
1376
1367
|
</label>
|
|
1377
1368
|
<label
|
|
1378
|
-
className="chakra-checkbox css-
|
|
1369
|
+
className="chakra-checkbox css-scawxr"
|
|
1379
1370
|
onClick={[Function]}
|
|
1380
1371
|
>
|
|
1381
1372
|
<input
|
|
@@ -1460,13 +1451,12 @@ exports[`Checkbox renders the UI snapshot correctly 11`] = `
|
|
|
1460
1451
|
chakraProps
|
|
1461
1452
|
</legend>
|
|
1462
1453
|
<div
|
|
1463
|
-
aria-label={null}
|
|
1464
1454
|
className="chakra-stack css-1wdv1uh"
|
|
1465
1455
|
data-testid="checkbox-group"
|
|
1466
1456
|
id="chakraProps"
|
|
1467
1457
|
>
|
|
1468
1458
|
<label
|
|
1469
|
-
className="chakra-checkbox css-
|
|
1459
|
+
className="chakra-checkbox css-scawxr"
|
|
1470
1460
|
onClick={[Function]}
|
|
1471
1461
|
>
|
|
1472
1462
|
<input
|
|
@@ -1527,7 +1517,7 @@ exports[`Checkbox renders the UI snapshot correctly 11`] = `
|
|
|
1527
1517
|
</span>
|
|
1528
1518
|
</label>
|
|
1529
1519
|
<label
|
|
1530
|
-
className="chakra-checkbox css-
|
|
1520
|
+
className="chakra-checkbox css-scawxr"
|
|
1531
1521
|
onClick={[Function]}
|
|
1532
1522
|
>
|
|
1533
1523
|
<input
|
|
@@ -1601,13 +1591,12 @@ exports[`Checkbox renders the UI snapshot correctly 12`] = `
|
|
|
1601
1591
|
otherProps
|
|
1602
1592
|
</legend>
|
|
1603
1593
|
<div
|
|
1604
|
-
aria-label={null}
|
|
1605
1594
|
className="chakra-stack css-1wdv1uh"
|
|
1606
1595
|
data-testid="checkbox-group"
|
|
1607
1596
|
id="otherProps"
|
|
1608
1597
|
>
|
|
1609
1598
|
<label
|
|
1610
|
-
className="chakra-checkbox css-
|
|
1599
|
+
className="chakra-checkbox css-scawxr"
|
|
1611
1600
|
onClick={[Function]}
|
|
1612
1601
|
>
|
|
1613
1602
|
<input
|
|
@@ -1668,7 +1657,7 @@ exports[`Checkbox renders the UI snapshot correctly 12`] = `
|
|
|
1668
1657
|
</span>
|
|
1669
1658
|
</label>
|
|
1670
1659
|
<label
|
|
1671
|
-
className="chakra-checkbox css-
|
|
1660
|
+
className="chakra-checkbox css-scawxr"
|
|
1672
1661
|
onClick={[Function]}
|
|
1673
1662
|
>
|
|
1674
1663
|
<input
|
|
@@ -2,7 +2,6 @@ import { Box, chakra, useMultiStyleConfig } from "@chakra-ui/react";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
4
|
import Heading from "../Heading/Heading";
|
|
5
|
-
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
6
5
|
import HelperErrorText, {
|
|
7
6
|
HelperErrorTextType,
|
|
8
7
|
} from "../HelperErrorText/HelperErrorText";
|
|
@@ -39,7 +38,7 @@ export const ComponentWrapper = chakra(
|
|
|
39
38
|
} = props;
|
|
40
39
|
const hasChildren = !!children;
|
|
41
40
|
const styles = useMultiStyleConfig("ComponentWrapper", { hasChildren });
|
|
42
|
-
const footnote
|
|
41
|
+
const footnote = isInvalid ? invalidText : helperText;
|
|
43
42
|
|
|
44
43
|
// Note: Typescript warns when there are no children passed and
|
|
45
44
|
// doesn't compile. This is meant to log in non-Typescript apps.
|
|
@@ -49,21 +48,15 @@ export const ComponentWrapper = chakra(
|
|
|
49
48
|
|
|
50
49
|
return (
|
|
51
50
|
<Box __css={styles} {...rest}>
|
|
52
|
-
{headingText &&
|
|
53
|
-
<Heading
|
|
54
|
-
id={`${id}-heading`}
|
|
55
|
-
level={HeadingLevels.Two}
|
|
56
|
-
text={headingText}
|
|
57
|
-
/>
|
|
58
|
-
)}
|
|
51
|
+
{headingText && <Heading id={`${id}-heading`} text={headingText} />}
|
|
59
52
|
{descriptionText && <Text>{descriptionText}</Text>}
|
|
60
53
|
{children}
|
|
61
54
|
{footnote && (
|
|
62
55
|
<HelperErrorText
|
|
63
|
-
additionalStyles={styles.helperErrorText}
|
|
64
56
|
id={`${id}-helperText`}
|
|
65
57
|
isInvalid={isInvalid}
|
|
66
58
|
text={footnote}
|
|
59
|
+
__css={styles.helperErrorText}
|
|
67
60
|
/>
|
|
68
61
|
)}
|
|
69
62
|
</Box>
|
|
@@ -8,15 +8,8 @@ import {
|
|
|
8
8
|
import { withDesign } from "storybook-addon-designs";
|
|
9
9
|
|
|
10
10
|
import DatePicker from "./DatePicker";
|
|
11
|
-
import { DatePickerTypes } from "./DatePickerTypes";
|
|
12
11
|
import { getCategory } from "../../utils/componentCategories";
|
|
13
12
|
import DSProvider from "../../theme/provider";
|
|
14
|
-
import { getStorybookEnumValues } from "../../utils/utils";
|
|
15
|
-
|
|
16
|
-
export const enumValues = getStorybookEnumValues(
|
|
17
|
-
DatePickerTypes,
|
|
18
|
-
"DatePickerTypes"
|
|
19
|
-
);
|
|
20
13
|
|
|
21
14
|
<Meta
|
|
22
15
|
title={getCategory("DatePicker")}
|
|
@@ -36,8 +29,7 @@ export const enumValues = getStorybookEnumValues(
|
|
|
36
29
|
},
|
|
37
30
|
dateType: {
|
|
38
31
|
control: { type: "select" },
|
|
39
|
-
table: { defaultValue: { summary: "
|
|
40
|
-
options: enumValues.options,
|
|
32
|
+
table: { defaultValue: { summary: "full" } },
|
|
41
33
|
},
|
|
42
34
|
id: { control: false },
|
|
43
35
|
isDateRange: {
|
|
@@ -78,7 +70,7 @@ export const enumValues = getStorybookEnumValues(
|
|
|
78
70
|
| Component Version | DS Version |
|
|
79
71
|
| ----------------- | ---------- |
|
|
80
72
|
| Added | `0.24.0` |
|
|
81
|
-
| Latest | `0.
|
|
73
|
+
| Latest | `0.28.0` |
|
|
82
74
|
|
|
83
75
|
## Table of Contents
|
|
84
76
|
|
|
@@ -107,7 +99,7 @@ also be added through props.
|
|
|
107
99
|
args={{
|
|
108
100
|
className: undefined,
|
|
109
101
|
dateFormat: "yyyy-MM-dd",
|
|
110
|
-
dateType: "
|
|
102
|
+
dateType: "full",
|
|
111
103
|
helperText: "Note that the Library may be closed on Sundays.",
|
|
112
104
|
helperTextFrom: "Select start date.",
|
|
113
105
|
helperTextTo: "Select end date.",
|
|
@@ -131,13 +123,7 @@ also be added through props.
|
|
|
131
123
|
showRequiredLabel: true,
|
|
132
124
|
}}
|
|
133
125
|
>
|
|
134
|
-
{(args) =>
|
|
135
|
-
<DatePicker
|
|
136
|
-
{...args}
|
|
137
|
-
dateType={enumValues.getValue(args.dateType)}
|
|
138
|
-
onChange={undefined}
|
|
139
|
-
/>
|
|
140
|
-
)}
|
|
126
|
+
{(args) => <DatePicker {...args} onChange={undefined} />}
|
|
141
127
|
</Story>
|
|
142
128
|
</Canvas>
|
|
143
129
|
|
|
@@ -182,7 +168,7 @@ popup calendar.
|
|
|
182
168
|
<DatePicker
|
|
183
169
|
id="date-range"
|
|
184
170
|
dateFormat="yyyy-MM-dd"
|
|
185
|
-
dateType=
|
|
171
|
+
dateType="full"
|
|
186
172
|
minDate="1/1/2022"
|
|
187
173
|
maxDate="7/1/2022"
|
|
188
174
|
labelText="Select the date range you want to visit NYPL"
|
|
@@ -204,19 +190,19 @@ popup calendar.
|
|
|
204
190
|
By default, the `DatePicker` will display the input date value in the full
|
|
205
191
|
format that contains the year, month, and day such as "2021-01-30". Although
|
|
206
192
|
this is the default, it can be explicitly set through the `dateType` prop with
|
|
207
|
-
value of `
|
|
193
|
+
value of `"full"`.
|
|
208
194
|
|
|
209
195
|
### Month Date Input
|
|
210
196
|
|
|
211
197
|
It's possible to select dates by skipping the day value and only selecting
|
|
212
|
-
the month and the year when `dateType` is set to `
|
|
198
|
+
the month and the year when `dateType` is set to `"month"`. Note
|
|
213
199
|
that all 12 months will appear in the popup calendar with their abbreviated names.
|
|
214
200
|
|
|
215
201
|
<Canvas withToolbar>
|
|
216
202
|
<Story name="Month Date Input">
|
|
217
203
|
<DatePicker
|
|
218
204
|
id="month-date"
|
|
219
|
-
dateType=
|
|
205
|
+
dateType="month"
|
|
220
206
|
labelText="Select the month you want to visit NYPL"
|
|
221
207
|
helperText="Note that the Library may be closed on Sundays."
|
|
222
208
|
invalidText="Please select a valid month."
|
|
@@ -227,14 +213,14 @@ that all 12 months will appear in the popup calendar with their abbreviated name
|
|
|
227
213
|
### Year Date Input
|
|
228
214
|
|
|
229
215
|
It's possible to select dates by only the year when `dateType` is set to
|
|
230
|
-
`
|
|
231
|
-
|
|
216
|
+
`"year"`. Note that only 12 values will appear in the popup calendar; the four
|
|
217
|
+
previous years, the current year, and the next seven years.
|
|
232
218
|
|
|
233
219
|
<Canvas withToolbar>
|
|
234
220
|
<Story name="Year Date Input">
|
|
235
221
|
<DatePicker
|
|
236
222
|
id="year-date"
|
|
237
|
-
dateType=
|
|
223
|
+
dateType="year"
|
|
238
224
|
labelText="Select the year you want to visit NYPL"
|
|
239
225
|
helperText="Note that the Library may be closed on Sundays."
|
|
240
226
|
/>
|
|
@@ -249,7 +235,7 @@ calendar; the four previous years, the current year, and the next seven years.
|
|
|
249
235
|
<DSProvider>
|
|
250
236
|
<DatePicker
|
|
251
237
|
id="invalid-date"
|
|
252
|
-
dateType=
|
|
238
|
+
dateType="full"
|
|
253
239
|
labelText="Select the year you want to visit NYPL"
|
|
254
240
|
helperText="Note that the Library may be closed on Sundays."
|
|
255
241
|
invalidText="Please select a valid date."
|
|
@@ -265,7 +251,7 @@ calendar; the four previous years, the current year, and the next seven years.
|
|
|
265
251
|
<DSProvider>
|
|
266
252
|
<DatePicker
|
|
267
253
|
id="disabled-date"
|
|
268
|
-
dateType=
|
|
254
|
+
dateType="full"
|
|
269
255
|
labelText="Select the year you want to visit NYPL"
|
|
270
256
|
isDateRange
|
|
271
257
|
isDisabled
|
|
@@ -281,8 +267,8 @@ date input, can be hidden when `showRequiredLabel` is set to `false`.
|
|
|
281
267
|
<Canvas>
|
|
282
268
|
<DSProvider>
|
|
283
269
|
<DatePicker
|
|
284
|
-
id="
|
|
285
|
-
dateType=
|
|
270
|
+
id="required-date"
|
|
271
|
+
dateType="full"
|
|
286
272
|
labelText="Select the year you want to visit NYPL"
|
|
287
273
|
isDateRange
|
|
288
274
|
isRequired
|
|
@@ -305,7 +291,7 @@ styleguide, we display dates as "year-month-day" by default.
|
|
|
305
291
|
<DSProvider>
|
|
306
292
|
<DatePicker
|
|
307
293
|
id="init-dates"
|
|
308
|
-
dateType=
|
|
294
|
+
dateType="full"
|
|
309
295
|
labelText="Select the date you want to visit NYPL"
|
|
310
296
|
initialDate="12/1/21"
|
|
311
297
|
initialDateTo="12/10/21"
|
|
@@ -325,7 +311,7 @@ written in [ISO-8601 format](https://www.w3.org/TR/NOTE-datetime).
|
|
|
325
311
|
<DatePicker
|
|
326
312
|
id="format-date"
|
|
327
313
|
dateFormat="MM-dd-yyyy"
|
|
328
|
-
dateType=
|
|
314
|
+
dateType="full"
|
|
329
315
|
labelText="Select the date you want to visit NYPL"
|
|
330
316
|
initialDate="12/1/21"
|
|
331
317
|
initialDateTo="12/10/21"
|
|
@@ -345,7 +331,7 @@ February to see the dates that are available to select in 2022.
|
|
|
345
331
|
<DatePicker
|
|
346
332
|
id="max-min-dates"
|
|
347
333
|
dateFormat="MM-dd-yyyy"
|
|
348
|
-
dateType=
|
|
334
|
+
dateType="full"
|
|
349
335
|
labelText="Select the date you want to visit NYPL"
|
|
350
336
|
minDate="1/1/2022"
|
|
351
337
|
maxDate="3/1/2022"
|
|
@@ -358,10 +344,10 @@ February to see the dates that are available to select in 2022.
|
|
|
358
344
|
|
|
359
345
|
### Controlled Component Using `onChange` prop
|
|
360
346
|
|
|
361
|
-
If your application uses controlled React components and the Reservoir Design
|
|
347
|
+
If your application uses controlled React components and the Reservoir Design
|
|
362
348
|
System (DS) DatePicker must be controlled, you can extract the data through the
|
|
363
349
|
`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
|
|
350
|
+
either the start date input field or the end date input field. The returned
|
|
365
351
|
data is an object with `startDate` and `endDate` keys and `Date` object values.
|
|
366
352
|
|
|
367
353
|
```tsx
|
|
@@ -381,7 +367,7 @@ const onChange = (data) => {
|
|
|
381
367
|
// Example of the DS DatePicker instance with the function above:
|
|
382
368
|
<DatePicker
|
|
383
369
|
id="date-range"
|
|
384
|
-
dateType=
|
|
370
|
+
dateType="full"
|
|
385
371
|
labelText="Select the date range you want to visit NYPL"
|
|
386
372
|
invalidText="Please select a valid date range."
|
|
387
373
|
onChange={onChange}
|
|
@@ -425,7 +411,7 @@ const submitForm = (formData) => {
|
|
|
425
411
|
>
|
|
426
412
|
<DatePicker
|
|
427
413
|
id="date-range"
|
|
428
|
-
dateType=
|
|
414
|
+
dateType="full"
|
|
429
415
|
labelText="Select the date range you want to visit NYPL"
|
|
430
416
|
nameFrom="visitDateFrom"
|
|
431
417
|
nameTo="visitDateTo"
|
|
@@ -446,7 +432,7 @@ const refEnd = React.createRef<TextInputRefType>();
|
|
|
446
432
|
// ...
|
|
447
433
|
<DatePicker
|
|
448
434
|
id="date-range"
|
|
449
|
-
dateType=
|
|
435
|
+
dateType="full"
|
|
450
436
|
labelText="Select the date range you want to visit NYPL"
|
|
451
437
|
nameFrom="visitDateFrom"
|
|
452
438
|
nameTo="visitDateTo"
|
|
@@ -4,13 +4,12 @@ import { axe } from "jest-axe";
|
|
|
4
4
|
import userEvent from "@testing-library/user-event";
|
|
5
5
|
import renderer from "react-test-renderer";
|
|
6
6
|
|
|
7
|
-
import DatePicker from "./DatePicker";
|
|
8
|
-
import { DatePickerTypes } from "./DatePickerTypes";
|
|
7
|
+
import DatePicker, { DatePickerTypes, FullDateType } from "./DatePicker";
|
|
9
8
|
import { TextInputRefType } from "../TextInput/TextInput";
|
|
10
9
|
|
|
11
10
|
/** This adds a "0" padding for date values under "10". */
|
|
12
|
-
const strPad = (n) => String("0" + n).slice(-2);
|
|
13
|
-
const monthArray = [
|
|
11
|
+
const strPad = (n: number) => String("0" + n).slice(-2);
|
|
12
|
+
const monthArray: string[] = [
|
|
14
13
|
"January",
|
|
15
14
|
"February",
|
|
16
15
|
"March",
|
|
@@ -58,11 +57,11 @@ describe("DatePicker", () => {
|
|
|
58
57
|
return [year, month, day];
|
|
59
58
|
};
|
|
60
59
|
/** Returns today's date in string format based on the DatePicker type. */
|
|
61
|
-
const getTodaysDateDisplay = (type
|
|
60
|
+
const getTodaysDateDisplay = (type?: DatePickerTypes) => {
|
|
62
61
|
const [year, month, day] = getTodaysValues();
|
|
63
|
-
if (
|
|
62
|
+
if ("year" === type) {
|
|
64
63
|
return `${year}`;
|
|
65
|
-
} else if (
|
|
64
|
+
} else if ("month" === type) {
|
|
66
65
|
return `${month}-${year}`;
|
|
67
66
|
}
|
|
68
67
|
return `${year}-${month}-${day}`;
|
|
@@ -106,12 +105,12 @@ describe("DatePicker", () => {
|
|
|
106
105
|
render(
|
|
107
106
|
<DatePicker
|
|
108
107
|
id="datePicker"
|
|
109
|
-
dateType=
|
|
108
|
+
dateType="month"
|
|
110
109
|
labelText="Select the month you want to visit NYPL"
|
|
111
110
|
/>
|
|
112
111
|
);
|
|
113
112
|
const [year, month] = getTodaysValues();
|
|
114
|
-
const date = getTodaysDateDisplay(
|
|
113
|
+
const date = getTodaysDateDisplay("month");
|
|
115
114
|
|
|
116
115
|
expect(
|
|
117
116
|
screen.getByLabelText(/Select the month you want to visit NYPL/i)
|
|
@@ -125,12 +124,12 @@ describe("DatePicker", () => {
|
|
|
125
124
|
render(
|
|
126
125
|
<DatePicker
|
|
127
126
|
id="datePicker"
|
|
128
|
-
dateType=
|
|
127
|
+
dateType="year"
|
|
129
128
|
labelText="Select the month you want to visit NYPL"
|
|
130
129
|
/>
|
|
131
130
|
);
|
|
132
131
|
const [year] = getTodaysValues();
|
|
133
|
-
const date = getTodaysDateDisplay(
|
|
132
|
+
const date = getTodaysDateDisplay("year");
|
|
134
133
|
|
|
135
134
|
expect(
|
|
136
135
|
screen.getByLabelText(/Select the month you want to visit NYPL/i)
|
|
@@ -316,8 +315,11 @@ describe("DatePicker", () => {
|
|
|
316
315
|
});
|
|
317
316
|
|
|
318
317
|
it("should pass the value to the `onChange` function", () => {
|
|
319
|
-
let dateObject:
|
|
320
|
-
|
|
318
|
+
let dateObject: FullDateType = {
|
|
319
|
+
startDate: new Date(),
|
|
320
|
+
endDate: new Date(),
|
|
321
|
+
};
|
|
322
|
+
const onChange = (data: FullDateType) => {
|
|
321
323
|
dateObject = data;
|
|
322
324
|
};
|
|
323
325
|
render(
|
|
@@ -370,7 +372,7 @@ describe("DatePicker", () => {
|
|
|
370
372
|
it("should throw a warning when `onChange` is passed as well as a `ref` prop.", () => {
|
|
371
373
|
const warn = jest.spyOn(console, "warn");
|
|
372
374
|
const ref = React.createRef<TextInputRefType>();
|
|
373
|
-
const onChange = (_data) => {};
|
|
375
|
+
const onChange = (_data: {}) => {};
|
|
374
376
|
render(
|
|
375
377
|
<DatePicker
|
|
376
378
|
id="datePicker"
|
|
@@ -788,7 +790,7 @@ describe("DatePicker", () => {
|
|
|
788
790
|
userEvent.click(screen.getByText(midMonthDay));
|
|
789
791
|
// So only the month should change accordingly.
|
|
790
792
|
const newMonthValue = `${newDayValue.substr(0, 5)}${strPad(
|
|
791
|
-
|
|
793
|
+
10
|
|
792
794
|
)}${newDayValue.substr(7)}`;
|
|
793
795
|
expect(screen.getByDisplayValue(newMonthValue)).toBeInTheDocument();
|
|
794
796
|
});
|
|
@@ -797,7 +799,7 @@ describe("DatePicker", () => {
|
|
|
797
799
|
render(
|
|
798
800
|
<DatePicker
|
|
799
801
|
id="datePicker"
|
|
800
|
-
dateType=
|
|
802
|
+
dateType="month"
|
|
801
803
|
labelText="Select the month you want to visit NYPL"
|
|
802
804
|
/>
|
|
803
805
|
);
|
|
@@ -824,7 +826,7 @@ describe("DatePicker", () => {
|
|
|
824
826
|
render(
|
|
825
827
|
<DatePicker
|
|
826
828
|
id="datePicker"
|
|
827
|
-
dateType=
|
|
829
|
+
dateType="month"
|
|
828
830
|
initialDate="4/1/1988"
|
|
829
831
|
labelText="Select the month you want to visit NYPL"
|
|
830
832
|
/>
|
|
@@ -864,7 +866,7 @@ describe("DatePicker", () => {
|
|
|
864
866
|
render(
|
|
865
867
|
<DatePicker
|
|
866
868
|
id="datePicker"
|
|
867
|
-
dateType=
|
|
869
|
+
dateType="year"
|
|
868
870
|
labelText="Select the year you want to visit NYPL"
|
|
869
871
|
/>
|
|
870
872
|
);
|
|
@@ -902,7 +904,7 @@ describe("DatePicker", () => {
|
|
|
902
904
|
render(
|
|
903
905
|
<DatePicker
|
|
904
906
|
id="datePicker"
|
|
905
|
-
dateType=
|
|
907
|
+
dateType="year"
|
|
906
908
|
labelText="Select the year you want to visit NYPL"
|
|
907
909
|
/>
|
|
908
910
|
);
|