@nypl/design-system-react-components 0.25.11 → 0.26.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 +151 -0
- package/README.md +14 -26
- package/dist/components/Accordion/Accordion.d.ts +6 -4
- package/dist/components/Accordion/AccordionTypes.d.ts +5 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +2 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Card/Card.d.ts +22 -29
- package/dist/components/Checkbox/Checkbox.d.ts +3 -3
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +9 -6
- 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 +5 -5
- package/dist/components/Heading/HeadingTypes.d.ts +1 -1
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
- package/dist/components/Hero/Hero.d.ts +9 -5
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
- package/dist/components/Icons/Icon.d.ts +2 -1
- package/dist/components/Icons/IconTypes.d.ts +10 -7
- package/dist/components/Image/Image.d.ts +27 -9
- package/dist/components/Image/ImageTypes.d.ts +4 -4
- 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 +8 -0
- package/dist/components/Logo/LogoTypes.d.ts +10 -2
- package/dist/components/Notification/Notification.d.ts +7 -7
- package/dist/components/Pagination/Pagination.d.ts +8 -4
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
- package/dist/components/Radio/Radio.d.ts +5 -7
- package/dist/components/RadioGroup/RadioGroup.d.ts +16 -8
- package/dist/components/SearchBar/SearchBar.d.ts +5 -5
- package/dist/components/Select/Select.d.ts +12 -8
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +8 -6
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -4
- 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 +10 -23
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +7 -6
- package/dist/components/Template/Template.d.ts +18 -9
- package/dist/components/Text/Text.d.ts +4 -4
- package/dist/components/Text/TextTypes.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +7 -7
- package/dist/components/Toggle/Toggle.d.ts +8 -10
- package/dist/components/Toggle/{ToggleSizes.d.ts → ToggleTypes.d.ts} +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +2802 -1686
- 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 +2811 -1699
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/enums.d.ts +4 -0
- package/dist/hooks/useCarouselStyles.d.ts +3 -2
- package/dist/hooks/useNYPLTheme.d.ts +12 -0
- package/dist/index.d.ts +11 -9
- package/dist/styles.css +1 -1
- package/dist/theme/components/accordion.d.ts +7 -12
- package/dist/theme/components/breadcrumb.d.ts +6 -0
- package/dist/theme/components/button.d.ts +10 -2
- package/dist/theme/components/card.d.ts +44 -24
- package/dist/theme/components/checkbox.d.ts +6 -6
- package/dist/theme/components/checkboxGroup.d.ts +4 -2
- 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 +6 -14
- package/dist/theme/components/global.d.ts +37 -29
- package/dist/theme/components/globalMixins.d.ts +8 -8
- 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 +21 -15
- package/dist/theme/components/image.d.ts +1 -1
- package/dist/theme/components/label.d.ts +9 -10
- package/dist/theme/components/list.d.ts +105 -9
- package/dist/theme/components/notification.d.ts +7 -4
- package/dist/theme/components/pagination.d.ts +2 -5
- package/dist/theme/components/radio.d.ts +10 -6
- package/dist/theme/components/radioGroup.d.ts +4 -2
- package/dist/theme/components/select.d.ts +38 -13
- package/dist/theme/components/skeletonLoader.d.ts +2 -2
- package/dist/theme/components/slider.d.ts +14 -7
- package/dist/theme/components/structuredContent.d.ts +197 -0
- package/dist/theme/components/textInput.d.ts +22 -14
- package/dist/theme/components/toggle.d.ts +25 -6
- package/dist/theme/foundations/global.d.ts +33 -3
- package/dist/theme/foundations/radii.d.ts +1 -0
- package/dist/theme/foundations/spacing.d.ts +46 -43
- package/dist/utils/utils.d.ts +10 -0
- package/package.json +5 -6
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +34 -0
- package/src/components/Accordion/Accordion.stories.mdx +150 -66
- package/src/components/Accordion/Accordion.test.tsx +65 -17
- package/src/components/Accordion/Accordion.tsx +61 -27
- package/src/components/Accordion/AccordionTypes.tsx +5 -0
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +505 -14
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +53 -18
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +66 -35
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +14 -13
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +2 -1
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +308 -10
- 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 +493 -329
- package/src/components/Card/Card.test.tsx +138 -18
- package/src/components/Card/Card.tsx +151 -85
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +220 -100
- package/src/components/Chakra/Center.stories.mdx +2 -2
- package/src/components/Chakra/Grid.stories.mdx +4 -4
- package/src/components/Checkbox/Checkbox.stories.mdx +73 -9
- package/src/components/Checkbox/Checkbox.test.tsx +89 -10
- package/src/components/Checkbox/Checkbox.tsx +27 -16
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +209 -6
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +135 -23
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +216 -90
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +39 -26
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +493 -89
- 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 +94 -15
- package/src/components/DatePicker/DatePicker.tsx +67 -58
- 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 +118 -47
- package/src/components/Form/Form.test.tsx +59 -16
- package/src/components/Form/Form.tsx +89 -65
- 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 +87 -41
- package/src/components/Grid/SimpleGrid.test.tsx +24 -9
- 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 +56 -25
- package/src/components/Heading/Heading.test.tsx +17 -7
- package/src/components/Heading/Heading.tsx +60 -58
- package/src/components/Heading/HeadingTypes.tsx +1 -1
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +27 -8
- 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 +143 -113
- package/src/components/Hero/Hero.test.tsx +146 -58
- package/src/components/Hero/Hero.tsx +144 -112
- 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 -17
- package/src/components/HorizontalRule/HorizontalRule.tsx +9 -25
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
- package/src/components/Icons/Icon.stories.mdx +80 -23
- package/src/components/Icons/Icon.test.tsx +51 -2
- package/src/components/Icons/Icon.tsx +93 -71
- package/src/components/Icons/IconTypes.tsx +9 -6
- package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
- package/src/components/Image/Image.stories.mdx +160 -71
- package/src/components/Image/Image.test.tsx +40 -48
- package/src/components/Image/Image.tsx +80 -48
- package/src/components/Image/ImageTypes.ts +4 -4
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +84 -21
- 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 -1
- package/src/components/Link/Link.test.tsx +21 -0
- package/src/components/Link/Link.tsx +16 -9
- 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 +73 -22
- package/src/components/List/List.tsx +44 -28
- 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 +40 -16
- package/src/components/Logo/Logo.test.tsx +29 -2
- package/src/components/Logo/Logo.tsx +28 -11
- package/src/components/Logo/LogoSvgs.tsx +16 -0
- package/src/components/Logo/LogoTypes.tsx +9 -1
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
- package/src/components/Modal/Modal.stories.mdx +13 -0
- package/src/components/Notification/Notification.stories.mdx +34 -5
- package/src/components/Notification/Notification.test.tsx +43 -9
- package/src/components/Notification/Notification.tsx +59 -55
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +256 -32
- package/src/components/Pagination/Pagination.stories.mdx +76 -13
- package/src/components/Pagination/Pagination.test.tsx +116 -5
- package/src/components/Pagination/Pagination.tsx +54 -29
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +247 -30
- package/src/components/Placeholder/Placeholder.tsx +3 -1
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +87 -13
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +20 -10
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
- package/src/components/Radio/Radio.stories.mdx +75 -11
- package/src/components/Radio/Radio.test.tsx +83 -9
- package/src/components/Radio/Radio.tsx +70 -61
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +168 -10
- package/src/components/RadioGroup/RadioGroup.stories.mdx +293 -94
- package/src/components/RadioGroup/RadioGroup.test.tsx +193 -68
- package/src/components/RadioGroup/RadioGroup.tsx +110 -101
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1258 -902
- package/src/components/SearchBar/SearchBar.stories.mdx +104 -39
- package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +66 -6
- package/src/components/SearchBar/SearchBar.tsx +23 -13
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
- package/src/components/Select/Select.stories.mdx +151 -62
- package/src/components/Select/Select.test.tsx +56 -44
- package/src/components/Select/Select.tsx +125 -104
- package/src/components/Select/SelectTypes.tsx +5 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +749 -409
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +53 -23
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +14 -8
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +80 -78
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
- package/src/components/Slider/Slider.stories.mdx +123 -41
- package/src/components/Slider/Slider.test.tsx +65 -17
- package/src/components/Slider/Slider.tsx +34 -24
- 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 +19 -1
- 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 +229 -61
- package/src/components/StructuredContent/StructuredContent.test.tsx +162 -101
- package/src/components/StructuredContent/StructuredContent.tsx +98 -103
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -9
- package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
- package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
- package/src/components/StyleGuide/ColorCard.tsx +4 -4
- package/src/components/StyleGuide/Colors.stories.mdx +34 -20
- 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 +47 -33
- package/src/components/Table/Table.stories.mdx +38 -11
- package/src/components/Table/Table.test.tsx +16 -1
- package/src/components/Table/Table.tsx +10 -8
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
- package/src/components/Tabs/Tabs.stories.mdx +59 -10
- package/src/components/Tabs/Tabs.test.tsx +29 -11
- package/src/components/Tabs/Tabs.tsx +28 -21
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
- package/src/components/Template/Template.stories.mdx +73 -32
- package/src/components/Template/Template.test.tsx +68 -5
- package/src/components/Template/Template.tsx +86 -72
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +195 -22
- package/src/components/Text/Text.stories.mdx +32 -15
- package/src/components/Text/Text.test.tsx +14 -11
- package/src/components/Text/Text.tsx +13 -16
- package/src/components/Text/TextTypes.tsx +1 -1
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
- package/src/components/TextInput/TextInput.stories.mdx +73 -27
- package/src/components/TextInput/TextInput.test.tsx +65 -50
- package/src/components/TextInput/TextInput.tsx +123 -115
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
- package/src/components/Toggle/Toggle.stories.mdx +74 -26
- package/src/components/Toggle/Toggle.test.tsx +41 -10
- package/src/components/Toggle/Toggle.tsx +31 -27
- package/src/components/Toggle/{ToggleSizes.tsx → ToggleTypes.tsx} +1 -1
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +195 -8
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +41 -6
- package/src/components/VideoPlayer/VideoPlayer.tsx +134 -120
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
- package/src/docs/Chakra.stories.mdx +51 -10
- package/src/docs/Welcome.stories.mdx +168 -0
- package/src/{components/Card/CardTypes.tsx → helpers/enums.ts} +2 -2
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useCarouselStyles.stories.mdx +30 -0
- package/src/hooks/useCarouselStyles.ts +3 -2
- package/src/hooks/useNYPLTheme.stories.mdx +101 -0
- package/src/hooks/useNYPLTheme.ts +31 -7
- package/src/hooks/useWindowSize.stories.mdx +23 -0
- package/src/index.ts +11 -15
- package/src/styles/base/_place-holder.scss +3 -1
- package/src/styles.scss +0 -2
- package/src/theme/components/accordion.ts +7 -12
- package/src/theme/components/breadcrumb.ts +7 -0
- package/src/theme/components/button.ts +15 -7
- package/src/theme/components/card.ts +56 -36
- package/src/theme/components/checkbox.ts +12 -14
- package/src/theme/components/checkboxGroup.ts +4 -2
- package/src/theme/components/componentWrapper.ts +2 -2
- package/src/theme/components/customTable.ts +39 -31
- package/src/theme/components/fieldset.ts +3 -2
- package/src/theme/components/global.ts +42 -33
- package/src/theme/components/globalMixins.ts +8 -8
- package/src/theme/components/heading.ts +1 -1
- package/src/theme/components/helperErrorText.ts +1 -0
- package/src/theme/components/hero.ts +14 -16
- package/src/theme/components/icon.ts +5 -2
- package/src/theme/components/image.ts +1 -1
- package/src/theme/components/label.ts +4 -3
- package/src/theme/components/list.ts +76 -65
- package/src/theme/components/notification.ts +10 -7
- package/src/theme/components/pagination.ts +2 -5
- package/src/theme/components/progressIndicator.ts +3 -3
- package/src/theme/components/radio.ts +11 -14
- package/src/theme/components/radioGroup.ts +4 -2
- package/src/theme/components/select.ts +37 -18
- package/src/theme/components/skeletonLoader.ts +3 -3
- package/src/theme/components/slider.ts +19 -15
- 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 +76 -42
- package/src/theme/components/videoPlayer.ts +1 -1
- package/src/theme/foundations/colors.ts +20 -13
- package/src/theme/foundations/global.ts +17 -5
- package/src/theme/foundations/radii.ts +1 -0
- package/src/theme/foundations/spacing.ts +70 -22
- package/src/theme/foundations/typography.ts +3 -3
- package/src/utils/componentCategories.ts +28 -21
- package/src/utils/utils.ts +28 -0
- package/dist/components/Card/CardTypes.d.ts +0 -4
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +0 -4
- package/dist/components/Pagination/Pagination.stories.d.ts +0 -13
- package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +0 -4
- package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
- package/dist/helpers/generateUUID.d.ts +0 -1
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +0 -4
- package/src/components/Pagination/Pagination.stories.tsx +0 -54
- package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +0 -4
- package/src/docs/Intro.stories.mdx +0 -53
- package/src/helpers/generateUUID.tsx +0 -5
- package/src/styles/base/_03-base.scss +0 -25
- package/src/styles/base/_04-focus.scss +0 -22
|
@@ -60,7 +60,20 @@ import DSProvider from "../../theme/provider";
|
|
|
60
60
|
| Component Version | DS Version |
|
|
61
61
|
| ----------------- | ---------- |
|
|
62
62
|
| Added | `0.0.4` |
|
|
63
|
-
| Latest | `0.
|
|
63
|
+
| Latest | `0.26.0` |
|
|
64
|
+
|
|
65
|
+
## Table of Contents
|
|
66
|
+
|
|
67
|
+
- [Overview](#overview)
|
|
68
|
+
- [Component Props](#component-props)
|
|
69
|
+
- [Accessibility](#accessibility)
|
|
70
|
+
- [Form Components](#form-components)
|
|
71
|
+
- [Search Autocomplete](#search-autocomplete)
|
|
72
|
+
- [Form States](#form-states)
|
|
73
|
+
- [With Heading and Description Text](#with-heading-and-description-text)
|
|
74
|
+
- [TextInput and onSubmit Values](#textinput-and-onsubmit-values)
|
|
75
|
+
|
|
76
|
+
## Overview
|
|
64
77
|
|
|
65
78
|
<Description of={SearchBar} />
|
|
66
79
|
|
|
@@ -89,6 +102,8 @@ export const optionsGroup = [
|
|
|
89
102
|
"Villagers",
|
|
90
103
|
];
|
|
91
104
|
|
|
105
|
+
## Component Props
|
|
106
|
+
|
|
92
107
|
<Canvas withToolbar>
|
|
93
108
|
<Story
|
|
94
109
|
name="SearchBar with Controls"
|
|
@@ -113,50 +128,75 @@ export const optionsGroup = [
|
|
|
113
128
|
textInputProps: undefined,
|
|
114
129
|
}}
|
|
115
130
|
>
|
|
116
|
-
{(args) =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
131
|
+
{(args) => {
|
|
132
|
+
const { helperText, showHelperText, showSelect, ...rest } = args;
|
|
133
|
+
return (
|
|
134
|
+
<SearchBar
|
|
135
|
+
{...rest}
|
|
136
|
+
selectProps={
|
|
137
|
+
showSelect && {
|
|
138
|
+
labelText: "Select a category",
|
|
139
|
+
name: "selectName",
|
|
140
|
+
optionsData: optionsGroup,
|
|
141
|
+
}
|
|
124
142
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
textInputProps={{
|
|
144
|
+
labelText: "Item Search",
|
|
145
|
+
name: "textInputName",
|
|
146
|
+
placeholder: "Item Search",
|
|
147
|
+
}}
|
|
148
|
+
helperText={showHelperText && helperText}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
}}
|
|
134
152
|
</Story>
|
|
135
153
|
</Canvas>
|
|
136
154
|
|
|
137
155
|
<ArgsTable story="SearchBar with Controls" />
|
|
138
156
|
|
|
139
|
-
##
|
|
157
|
+
## Accessibility
|
|
158
|
+
|
|
159
|
+
The `SearchBar` component is implemented with Reservoir `Select`, `TextInput`,
|
|
160
|
+
and `Button` accessible components. This a "complete" component that renders an
|
|
161
|
+
HTML `<form>` element that is submitted with a `<button>` element of `type="submit"`.
|
|
162
|
+
The `<form>` element also has a `role="search"` attribute that allows
|
|
163
|
+
screenreaders to pick up this entire search form.
|
|
164
|
+
|
|
165
|
+
Resources:
|
|
166
|
+
|
|
167
|
+
- [Reservoir Select](https://nypl.github.io/nypl-design-system/storybook-static/?path=/docs/components-form-elements-select--select-with-controls)
|
|
168
|
+
- [Reservoir TextInput](https://nypl.github.io/nypl-design-system/storybook-static/?path=/docs/components-form-elements-textinput--text-input-with-controls)
|
|
169
|
+
- [a11ymatters Accessible Search Form](https://www.a11ymatters.com/pattern/accessible-search/)
|
|
170
|
+
- [MDN ARIA: search role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/search_role)
|
|
171
|
+
|
|
172
|
+
## Form Components
|
|
140
173
|
|
|
141
174
|
### Select Component
|
|
142
175
|
|
|
143
176
|
To render an optional `Select` component, an object must be passed to the
|
|
144
177
|
`selectProps` prop. It _must_ include `name`, `labelText`, and `optionsData`
|
|
145
|
-
properties. The `onChange`
|
|
146
|
-
rendered but will be used for its `aria-label` attribute.
|
|
178
|
+
properties. The `onChange` and `value` properties are optional. The `labelText`
|
|
179
|
+
value won't be rendered but will be used for its `aria-label` attribute.
|
|
180
|
+
|
|
181
|
+
If you want to control the `Select` component, you **must** pass the `onChange`
|
|
182
|
+
and `value` props to the `selectProps` prop object. You must then control the
|
|
183
|
+
state of the selected value in your application. See the example at end of this
|
|
184
|
+
page for a full demonstration.
|
|
147
185
|
|
|
148
186
|
```
|
|
149
187
|
const selectProps = {
|
|
150
|
-
name: "select-form-name",
|
|
151
188
|
labelText: "Select a category",
|
|
152
|
-
|
|
189
|
+
name: "select-form-name",
|
|
153
190
|
onChange: (event) => {
|
|
154
191
|
console.log(event.target.value);
|
|
155
192
|
},
|
|
193
|
+
optionsData: optionsGroup,
|
|
194
|
+
value: "Art",
|
|
156
195
|
};
|
|
157
196
|
|
|
158
197
|
// ...
|
|
159
198
|
<SearchBar
|
|
199
|
+
id="searchBar"
|
|
160
200
|
onSubmit={() => {}}
|
|
161
201
|
selectProps={selectProps}
|
|
162
202
|
// ...
|
|
@@ -166,9 +206,9 @@ const selectProps = {
|
|
|
166
206
|
### TextInput Component
|
|
167
207
|
|
|
168
208
|
To render the `TextInput` component, an object must be passed to the
|
|
169
|
-
`textInputProps` prop. It _must_ include `labelText
|
|
170
|
-
|
|
171
|
-
|
|
209
|
+
`textInputProps` prop. It _must_ include `labelText` and `name` properties. The
|
|
210
|
+
`labelText` value won't be rendered but will be used for its `aria-label`
|
|
211
|
+
attribute. Optional properties to pass include `onChange`, `placeholder`, and `value`.
|
|
172
212
|
|
|
173
213
|
```
|
|
174
214
|
const textInputProps = {
|
|
@@ -183,6 +223,7 @@ const textInputProps = {
|
|
|
183
223
|
|
|
184
224
|
// ...
|
|
185
225
|
<SearchBar
|
|
226
|
+
id="searchBar"
|
|
186
227
|
onSubmit={() => {}}
|
|
187
228
|
textInputProps={textInputProps}
|
|
188
229
|
// ...
|
|
@@ -200,6 +241,7 @@ const textInputElement = <CustomInput {...props} />;
|
|
|
200
241
|
|
|
201
242
|
// ...
|
|
202
243
|
<SearchBar
|
|
244
|
+
id="searchBar"
|
|
203
245
|
onSubmit={() => {}}
|
|
204
246
|
textInputElement={textInputElement}
|
|
205
247
|
// ...
|
|
@@ -227,6 +269,7 @@ const helperText = "";
|
|
|
227
269
|
|
|
228
270
|
// ...
|
|
229
271
|
<SearchBar
|
|
272
|
+
id="searchBar"
|
|
230
273
|
onSubmit={() => {}}
|
|
231
274
|
helperText="Search for items in <b>Animal Crossing New Horizons</b>."
|
|
232
275
|
// ...
|
|
@@ -238,6 +281,7 @@ const helperText = "";
|
|
|
238
281
|
<SearchBar
|
|
239
282
|
descriptionText="The helper text below contains HTML in a string."
|
|
240
283
|
helperText="Search for items in <b>Animal Crossing New Horizons</b>."
|
|
284
|
+
id="helper-text"
|
|
241
285
|
onSubmit={() => {}}
|
|
242
286
|
textInputProps={{
|
|
243
287
|
labelText: "Item Search",
|
|
@@ -248,6 +292,7 @@ const helperText = "";
|
|
|
248
292
|
<br />
|
|
249
293
|
<SearchBar
|
|
250
294
|
descriptionText="The invalid text below contains HTML in a string."
|
|
295
|
+
id="invalid-text"
|
|
251
296
|
isInvalid
|
|
252
297
|
invalidText="Could <b>not</b> find the item <b>:(</b>"
|
|
253
298
|
onSubmit={() => {}}
|
|
@@ -277,6 +322,7 @@ precedence.
|
|
|
277
322
|
<Story
|
|
278
323
|
name="Search Autocomplete"
|
|
279
324
|
args={{
|
|
325
|
+
id: "autocomplete",
|
|
280
326
|
isDisabled: false,
|
|
281
327
|
isInvalid: false,
|
|
282
328
|
isRequired: false,
|
|
@@ -295,7 +341,7 @@ precedence.
|
|
|
295
341
|
</Story>
|
|
296
342
|
</Canvas>
|
|
297
343
|
|
|
298
|
-
##
|
|
344
|
+
## Form States
|
|
299
345
|
|
|
300
346
|
Use the Controls in the `Basic` example to see different states in real time.
|
|
301
347
|
Here are the same possible states of the `SearchBar` component in static examples.
|
|
@@ -309,15 +355,16 @@ handle the error state yourself.
|
|
|
309
355
|
<Canvas>
|
|
310
356
|
<DSProvider>
|
|
311
357
|
<SearchBar
|
|
358
|
+
helperText="This is the helper text!"
|
|
359
|
+
id="error-state"
|
|
360
|
+
invalidText="Could not find the item :("
|
|
361
|
+
isInvalid
|
|
312
362
|
onSubmit={() => {}}
|
|
313
363
|
textInputProps={{
|
|
314
364
|
labelText: "Item Search",
|
|
315
365
|
name: "textInputName",
|
|
316
366
|
placeholder: "Item Search",
|
|
317
367
|
}}
|
|
318
|
-
helperText="This is the helper text!"
|
|
319
|
-
invalidText="Could not find the item :("
|
|
320
|
-
isInvalid
|
|
321
368
|
/>
|
|
322
369
|
</DSProvider>
|
|
323
370
|
</Canvas>
|
|
@@ -331,19 +378,20 @@ handle the disabled state yourself.
|
|
|
331
378
|
<Canvas>
|
|
332
379
|
<DSProvider>
|
|
333
380
|
<SearchBar
|
|
381
|
+
helperText="Reason for disabled state."
|
|
382
|
+
id="disabled-state"
|
|
383
|
+
isDisabled
|
|
334
384
|
onSubmit={() => {}}
|
|
335
385
|
textInputProps={{
|
|
336
386
|
labelText: "Item Search",
|
|
337
387
|
name: "textInputName",
|
|
338
388
|
placeholder: "Item Search",
|
|
339
389
|
}}
|
|
340
|
-
helperText="Reason for disabled state."
|
|
341
|
-
isDisabled
|
|
342
390
|
/>
|
|
343
391
|
</DSProvider>
|
|
344
392
|
</Canvas>
|
|
345
393
|
|
|
346
|
-
|
|
394
|
+
## With Heading and Description Text
|
|
347
395
|
|
|
348
396
|
Use the `descriptionText` and `headingText` props to render a heading and
|
|
349
397
|
description above the main `SearchBar` form component.
|
|
@@ -353,6 +401,7 @@ description above the main `SearchBar` form component.
|
|
|
353
401
|
<SearchBar
|
|
354
402
|
descriptionText="This is the description for this `SearchBar` instance."
|
|
355
403
|
headingText="Heading for this `SearchBar`"
|
|
404
|
+
id="heading-and-description"
|
|
356
405
|
onSubmit={() => {}}
|
|
357
406
|
textInputProps={{
|
|
358
407
|
labelText: "Item Search",
|
|
@@ -363,7 +412,7 @@ description above the main `SearchBar` form component.
|
|
|
363
412
|
</DSProvider>
|
|
364
413
|
</Canvas>
|
|
365
414
|
|
|
366
|
-
|
|
415
|
+
## TextInput and onSubmit Values
|
|
367
416
|
|
|
368
417
|
_NOTE: open the browser console to see the values logged in the example below._
|
|
369
418
|
|
|
@@ -387,7 +436,12 @@ values can be retrieved as `event.target.selectName.value` and
|
|
|
387
436
|
`event.target.textInputName.value`.
|
|
388
437
|
|
|
389
438
|
```tsx
|
|
390
|
-
function SearchBarValueExample() {
|
|
439
|
+
export function SearchBarValueExample() {
|
|
440
|
+
const [selectValue, setSelectValue] = React.useState("Tools");
|
|
441
|
+
const selectOnChange = (event) => {
|
|
442
|
+
console.log(`onChange Select value: ${event.target.value}`);
|
|
443
|
+
setSelectValue(event.target.value);
|
|
444
|
+
};
|
|
391
445
|
const textInputOnChange = (event) => {
|
|
392
446
|
console.log(`onChange TextInput value: ${event.target.value}`);
|
|
393
447
|
};
|
|
@@ -398,11 +452,16 @@ function SearchBarValueExample() {
|
|
|
398
452
|
};
|
|
399
453
|
return (
|
|
400
454
|
<SearchBar
|
|
455
|
+
helperText="Search for an item"
|
|
456
|
+
invalidText="Could not find the item :("
|
|
457
|
+
id="example-1"
|
|
401
458
|
onSubmit={onSubmit}
|
|
402
459
|
selectProps={{
|
|
403
460
|
labelText: "Select a category",
|
|
404
461
|
name: "selectName",
|
|
462
|
+
onChange: selectOnChange,
|
|
405
463
|
optionsData: optionsGroup,
|
|
464
|
+
value: selectValue,
|
|
406
465
|
}}
|
|
407
466
|
textInputProps={{
|
|
408
467
|
labelText: "Item Search",
|
|
@@ -410,14 +469,17 @@ function SearchBarValueExample() {
|
|
|
410
469
|
onChange: textInputOnChange,
|
|
411
470
|
placeholder: "Item Search",
|
|
412
471
|
}}
|
|
413
|
-
helperText="Search for an item"
|
|
414
|
-
invalidText="Could not find the item :("
|
|
415
472
|
/>
|
|
416
473
|
);
|
|
417
474
|
}
|
|
418
475
|
```
|
|
419
476
|
|
|
420
477
|
export function SearchBarValueExample() {
|
|
478
|
+
const [selectValue, setSelectValue] = React.useState("Tools");
|
|
479
|
+
const selectOnChange = (event) => {
|
|
480
|
+
console.log(`onChange Select value: ${event.target.value}`);
|
|
481
|
+
setSelectValue(event.target.value);
|
|
482
|
+
};
|
|
421
483
|
const textInputOnChange = (event) => {
|
|
422
484
|
console.log(`onChange TextInput value: ${event.target.value}`);
|
|
423
485
|
};
|
|
@@ -428,11 +490,16 @@ export function SearchBarValueExample() {
|
|
|
428
490
|
};
|
|
429
491
|
return (
|
|
430
492
|
<SearchBar
|
|
493
|
+
helperText="Search for an item"
|
|
494
|
+
invalidText="Could not find the item :("
|
|
495
|
+
id="example-1"
|
|
431
496
|
onSubmit={onSubmit}
|
|
432
497
|
selectProps={{
|
|
433
498
|
labelText: "Select a category",
|
|
434
499
|
name: "selectName",
|
|
500
|
+
onChange: selectOnChange,
|
|
435
501
|
optionsData: optionsGroup,
|
|
502
|
+
value: selectValue,
|
|
436
503
|
}}
|
|
437
504
|
textInputProps={{
|
|
438
505
|
labelText: "Item Search",
|
|
@@ -440,8 +507,6 @@ export function SearchBarValueExample() {
|
|
|
440
507
|
onChange: textInputOnChange,
|
|
441
508
|
placeholder: "Item Search",
|
|
442
509
|
}}
|
|
443
|
-
helperText="Search for an item"
|
|
444
|
-
invalidText="Could not find the item :("
|
|
445
510
|
/>
|
|
446
511
|
);
|
|
447
512
|
}
|
|
@@ -22,6 +22,7 @@ const selectProps: SelectProps = {
|
|
|
22
22
|
name: "selectName",
|
|
23
23
|
labelText: "Select a category",
|
|
24
24
|
optionsData: optionsGroup,
|
|
25
|
+
value: "Songs",
|
|
25
26
|
};
|
|
26
27
|
const textInputProps: TextInputProps = {
|
|
27
28
|
labelText: "Item Search",
|
|
@@ -162,7 +163,9 @@ describe("SearchBar", () => {
|
|
|
162
163
|
});
|
|
163
164
|
|
|
164
165
|
it("calls the Select onChange callback function", () => {
|
|
165
|
-
|
|
166
|
+
let selectValue = "Songs";
|
|
167
|
+
selectProps.onChange = (e) => (selectValue = e.target.value);
|
|
168
|
+
selectProps.value = selectValue;
|
|
166
169
|
|
|
167
170
|
render(
|
|
168
171
|
<SearchBar
|
|
@@ -175,13 +178,13 @@ describe("SearchBar", () => {
|
|
|
175
178
|
/>
|
|
176
179
|
);
|
|
177
180
|
const select = screen.getByLabelText(selectProps.labelText);
|
|
178
|
-
expect(
|
|
181
|
+
expect(selectValue).toEqual("Songs");
|
|
179
182
|
|
|
180
183
|
userEvent.selectOptions(select, "Flowers");
|
|
181
|
-
expect(
|
|
184
|
+
expect(selectValue).toEqual("Flowers");
|
|
182
185
|
|
|
183
186
|
userEvent.selectOptions(select, "Furniture");
|
|
184
|
-
expect(
|
|
187
|
+
expect(selectValue).toEqual("Furniture");
|
|
185
188
|
});
|
|
186
189
|
|
|
187
190
|
it("calls the callback function for the Button component ", () => {
|
|
@@ -217,6 +220,25 @@ describe("SearchBar", () => {
|
|
|
217
220
|
expect(searchBarSubmit).toHaveBeenCalledTimes(1);
|
|
218
221
|
});
|
|
219
222
|
|
|
223
|
+
it("renders a default placeholder", () => {
|
|
224
|
+
const textInputProps: TextInputProps = {
|
|
225
|
+
labelText: "Item Search",
|
|
226
|
+
name: "textInputName",
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
render(
|
|
230
|
+
<SearchBar
|
|
231
|
+
id="requiredState"
|
|
232
|
+
isDisabled
|
|
233
|
+
labelText={labelText}
|
|
234
|
+
onSubmit={jest.fn()}
|
|
235
|
+
textInputProps={textInputProps}
|
|
236
|
+
/>
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
expect(screen.getByPlaceholderText("Search terms")).toBeInTheDocument();
|
|
240
|
+
});
|
|
241
|
+
|
|
220
242
|
it("renders 'required' in the placeholder text", () => {
|
|
221
243
|
const { rerender } = render(
|
|
222
244
|
<SearchBar
|
|
@@ -247,8 +269,19 @@ describe("SearchBar", () => {
|
|
|
247
269
|
).toBeInTheDocument();
|
|
248
270
|
});
|
|
249
271
|
|
|
250
|
-
|
|
251
|
-
|
|
272
|
+
it("logs a warning when there is no `id` passed", () => {
|
|
273
|
+
const warn = jest.spyOn(console, "warn");
|
|
274
|
+
render(
|
|
275
|
+
// @ts-ignore: Typescript complains when a required prop is not passed, but
|
|
276
|
+
// here we don't want to pass the required prop to make sure the warning appears.
|
|
277
|
+
<SearchBar labelText={labelText} onSubmit={jest.fn()} />
|
|
278
|
+
);
|
|
279
|
+
expect(warn).toHaveBeenCalledWith(
|
|
280
|
+
"NYPL Reservoir SearchBar: This component's required `id` prop was not passed."
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it("renders the UI snapshot correctly", () => {
|
|
252
285
|
const basic = renderer
|
|
253
286
|
.create(
|
|
254
287
|
<SearchBar
|
|
@@ -360,6 +393,31 @@ describe("SearchBar", () => {
|
|
|
360
393
|
/>
|
|
361
394
|
)
|
|
362
395
|
.toJSON();
|
|
396
|
+
const withChakraProps = renderer
|
|
397
|
+
.create(
|
|
398
|
+
<SearchBar
|
|
399
|
+
helperText={helperText}
|
|
400
|
+
id="chakra"
|
|
401
|
+
labelText={labelText}
|
|
402
|
+
onSubmit={jest.fn()}
|
|
403
|
+
textInputProps={textInputProps}
|
|
404
|
+
p="20px"
|
|
405
|
+
color="ui.error.primary"
|
|
406
|
+
/>
|
|
407
|
+
)
|
|
408
|
+
.toJSON();
|
|
409
|
+
const withOtherProps = renderer
|
|
410
|
+
.create(
|
|
411
|
+
<SearchBar
|
|
412
|
+
helperText={helperText}
|
|
413
|
+
id="props"
|
|
414
|
+
labelText={labelText}
|
|
415
|
+
onSubmit={jest.fn()}
|
|
416
|
+
textInputProps={textInputProps}
|
|
417
|
+
data-testid="props"
|
|
418
|
+
/>
|
|
419
|
+
)
|
|
420
|
+
.toJSON();
|
|
363
421
|
|
|
364
422
|
expect(basic).toMatchSnapshot();
|
|
365
423
|
expect(withSelect).toMatchSnapshot();
|
|
@@ -371,5 +429,7 @@ describe("SearchBar", () => {
|
|
|
371
429
|
expect(withHeading).toMatchSnapshot();
|
|
372
430
|
expect(withDescription).toMatchSnapshot();
|
|
373
431
|
expect(withHeadingAndDescription).toMatchSnapshot();
|
|
432
|
+
expect(withChakraProps).toMatchSnapshot();
|
|
433
|
+
expect(withOtherProps).toMatchSnapshot();
|
|
374
434
|
});
|
|
375
435
|
});
|
|
@@ -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 Button from "../Button/Button";
|
|
@@ -11,8 +11,6 @@ import Select from "../Select/Select";
|
|
|
11
11
|
import { SelectTypes } from "../Select/SelectTypes";
|
|
12
12
|
import TextInput from "../TextInput/TextInput";
|
|
13
13
|
import { TextInputTypes, TextInputVariants } from "../TextInput/TextInputTypes";
|
|
14
|
-
import generateUUID from "../../helpers/generateUUID";
|
|
15
|
-
|
|
16
14
|
interface BaseProps {
|
|
17
15
|
labelText: string;
|
|
18
16
|
name: string;
|
|
@@ -21,14 +19,14 @@ interface BaseProps {
|
|
|
21
19
|
| React.ChangeEvent<HTMLInputElement>
|
|
22
20
|
| React.ChangeEvent<HTMLTextAreaElement>
|
|
23
21
|
) => void;
|
|
22
|
+
value?: string;
|
|
24
23
|
}
|
|
25
24
|
// Internal interfaces that are used only for `SearchBar` props.
|
|
26
25
|
export interface SelectProps extends BaseProps {
|
|
27
26
|
optionsData: string[];
|
|
28
27
|
}
|
|
29
28
|
export interface TextInputProps extends BaseProps {
|
|
30
|
-
placeholder
|
|
31
|
-
value?: string;
|
|
29
|
+
placeholder?: string;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
export interface SearchBarProps {
|
|
@@ -45,7 +43,7 @@ export interface SearchBarProps {
|
|
|
45
43
|
/** The text to display below the form in a `HelperErrorText` component. */
|
|
46
44
|
helperText?: HelperErrorTextType;
|
|
47
45
|
/** ID that other components can cross reference for accessibility purposes */
|
|
48
|
-
id
|
|
46
|
+
id: string;
|
|
49
47
|
/** Optional string to populate the `HelperErrorText` for the error state
|
|
50
48
|
* when `isInvalid` is true. */
|
|
51
49
|
invalidText?: HelperErrorTextType;
|
|
@@ -76,7 +74,7 @@ export interface SearchBarProps {
|
|
|
76
74
|
* Renders a wrapper `form` element to be used with `Select` (optional),
|
|
77
75
|
* `Input`, and `Button` components together.
|
|
78
76
|
*/
|
|
79
|
-
export
|
|
77
|
+
export const SearchBar = chakra((props: SearchBarProps) => {
|
|
80
78
|
const {
|
|
81
79
|
action,
|
|
82
80
|
buttonOnClick = null,
|
|
@@ -84,7 +82,7 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
84
82
|
descriptionText,
|
|
85
83
|
headingText,
|
|
86
84
|
helperText,
|
|
87
|
-
id
|
|
85
|
+
id,
|
|
88
86
|
invalidText,
|
|
89
87
|
isDisabled = false,
|
|
90
88
|
isInvalid = false,
|
|
@@ -96,6 +94,7 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
96
94
|
selectProps,
|
|
97
95
|
textInputElement,
|
|
98
96
|
textInputProps,
|
|
97
|
+
...rest
|
|
99
98
|
} = props;
|
|
100
99
|
const styles = useMultiStyleConfig("SearchBar", {});
|
|
101
100
|
const stateProps = {
|
|
@@ -108,7 +107,8 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
108
107
|
};
|
|
109
108
|
const footnote = isInvalid ? invalidText : helperText;
|
|
110
109
|
const finalAriaLabel = footnote ? `${labelText} - ${footnote}` : labelText;
|
|
111
|
-
const
|
|
110
|
+
const inputPlaceholder = textInputProps?.placeholder || "Search terms";
|
|
111
|
+
const textInputPlaceholder = `${inputPlaceholder} ${
|
|
112
112
|
isRequired ? "(Required)" : ""
|
|
113
113
|
}`;
|
|
114
114
|
const buttonType = noBrandButtonType
|
|
@@ -120,6 +120,12 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
120
120
|
lineHeight: "1.70",
|
|
121
121
|
marginBottom: "auto",
|
|
122
122
|
};
|
|
123
|
+
|
|
124
|
+
if (!id) {
|
|
125
|
+
console.warn(
|
|
126
|
+
"NYPL Reservoir SearchBar: This component's required `id` prop was not passed."
|
|
127
|
+
);
|
|
128
|
+
}
|
|
123
129
|
// Render the `Select` component.
|
|
124
130
|
const selectElem = selectProps && (
|
|
125
131
|
<Select
|
|
@@ -128,7 +134,8 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
128
134
|
labelText={selectProps?.labelText}
|
|
129
135
|
name={selectProps?.name}
|
|
130
136
|
onChange={selectProps?.onChange}
|
|
131
|
-
|
|
137
|
+
selectType={SelectTypes.SearchBar}
|
|
138
|
+
value={selectProps?.value}
|
|
132
139
|
{...stateProps}
|
|
133
140
|
>
|
|
134
141
|
{selectProps?.optionsData.map((option) => (
|
|
@@ -146,12 +153,12 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
146
153
|
name={textInputProps?.name}
|
|
147
154
|
onChange={textInputProps?.onChange}
|
|
148
155
|
placeholder={textInputPlaceholder}
|
|
149
|
-
|
|
150
|
-
variantType={
|
|
156
|
+
textInputType={
|
|
151
157
|
selectElem
|
|
152
158
|
? TextInputVariants.SearchBarSelect
|
|
153
159
|
: TextInputVariants.SearchBar
|
|
154
160
|
}
|
|
161
|
+
type={TextInputTypes.text}
|
|
155
162
|
value={textInputProps?.value}
|
|
156
163
|
{...stateProps}
|
|
157
164
|
/>
|
|
@@ -187,6 +194,7 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
187
194
|
id={id}
|
|
188
195
|
invalidText={invalidText}
|
|
189
196
|
isInvalid={isInvalid}
|
|
197
|
+
{...rest}
|
|
190
198
|
>
|
|
191
199
|
<Box
|
|
192
200
|
as="form"
|
|
@@ -205,4 +213,6 @@ export default function SearchBar(props: SearchBarProps) {
|
|
|
205
213
|
</Box>
|
|
206
214
|
</ComponentWrapper>
|
|
207
215
|
);
|
|
208
|
-
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
export default SearchBar;
|